View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - Adding a new parameter values list and use it - ProjeQtOr
 
 

Adding a new parameter values list and use it

More
17 Jun 2014 12:57 - 17 Jun 2014 12:58 #1 by Jean-Luc
In view to internationalize Projeqtor (my company has planned to have several branch in others countries – especially out of Europa, and we have already clients and resources in 50 countries !), I have added a values table for countries (in a first time, only french and english) as following :
CREATE TABLE IF NOT EXISTS `country` (
  `id` int(12) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(4) DEFAULT NULL,
  `lang` varchar(2) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `idle` int(1) unsigned DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `countryCodeLang` (`code`,`lang`),
  KEY `countryCode` (`code`),
  KEY `countryLang` (`lang`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

INSERT INTO `country` VALUES(1, 'af', 'en', 'Afghanistan', 0);
INSERT INTO `country` VALUES(2, 'af', 'fr', 'Afghanistan', 0);
INSERT INTO `country` VALUES(3, 'al', 'en', 'Albania', 0);
INSERT INTO `country` VALUES(4, 'al', 'fr', 'Albanie', 0);
INSERT INTO `country` VALUES(5, 'dz', 'en', 'Algeria', 0);
INSERT INTO `country` VALUES(6, 'dz', 'fr', 'Algérie', 0);
INSERT INTO `country` VALUES(7, 'ad', 'en', 'Andorra', 0);
INSERT INTO `country` VALUES(8, 'ad', 'fr', 'Andorre', 0);
(…)
(As I understand, the ‘idle’ column is requested for use of the table in a combo box, is this true?)

I have added a new entry in ‘menu’ table :
INSERT INTO `menu` VALUES(135, 'menuCountry', 36, 'object', 710, NULL, 0);
… so it should comes in menu under ‘parameters / Values lists‘ before ‘roles’

I have created model/Country.php:
<?php 
/* ============================================================================
 * Country defines list of countries.
 */ 
require_once('_securityCheck.php');
class Country extends SqlElement {

  // extends SqlElement, so has $id
  public $_col_1_2_Description;
  public $id;    // redefine $id to specify its visible place
  public $code;
  public $lang;
  public $name;
  
  // Define the layout that will be used for lists
  private static $_layout='
    <th field="id" formatter="numericFormatter" width="10%"># ${id}</th>
    <th field="code" width="10%">${code}</th>    
    <th field="lang" width="10%">${lang}</th>
    <th field="name" width="70%">${name}</th>
    ';

  private static $_fieldsAttributes=array("code"=>"required", 
                                          "lang"=>"required",
                                          "name"=>"required" 
  );    
  
   /** ==========================================================================
   * Constructor
   * @param $id the id of the object in the database (null if not stored yet)
   * @return void
   */ 
  function __construct($id = NULL) {
    parent::__construct($id);
  }

  
   /** ==========================================================================
   * Destructor
   * @return void
   */ 
  function __destruct() {
    parent::__destruct();
  }

// ============================================================================**********
// GET STATIC DATA FUNCTIONS
// ============================================================================**********
  
  /** ==========================================================================
   * Return the specific layout
   * @return the layout
   */
  protected function getStaticLayout() {
    return self::$_layout;
  }
     /** ==========================================================================
   * Return the specific fieldsAttributes
   * @return the fieldsAttributes
   */
  protected function getStaticFieldsAttributes() {
    return self::$_fieldsAttributes;
  }
  
}
?>
Of course, I also added translations in adequate ‘lang‘ files:
colCountryCode: "country code",
colCountryName: "country name",
colLang: "language",
menuCountry: "Countries",
and
colCountryCode: "code pays",
colCountryName: "libellé pays",
colLang: "language",
menuCountry: "Pays",

… but I have two problems:

1. This new table does not appears in main menu! What have I missed?

2. How redefines ‘country‘ field in model/Client.php to have a combo box:
    a. filtered on ‘lang’ column with user language (as stored in ‘parameter‘ table)
    b. showing ‘country’ field and storing ‘councode’ in client.country ?
    c. correctly labelled.
public $idCountry;
… don’t build the link with the new table.
Last edit: 17 Jun 2014 12:58 by Jean-Luc.

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 14:06 #2 by babynus

As I understand, the ‘idle’ column is requested for use of the table in a combo box, is this true?

Yes, it is a way to disable some item wothout deleting it

1. This new table does not appears in main menu! What have I missed?

Yes : give access rights !

… don’t build the link with the new table.

idCountry should be added in Client table as int(12) !

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 14:39 - 17 Jun 2014 14:40 #3 by Jean-Luc

babynus wrote:

As I understand, the ‘idle’ column is requested for use of the table in a combo box, is this true?

Yes, it is a way to disable some item wothout deleting it

1. This new table does not appears in main menu! What have I missed?

Yes : give access rights !

But some menu entries – as Role and all other entries under Values lists… and Values lists itself ! – are not in access rigths, however they are presents on menu! (I work as Admin, of course)

babynus wrote:

… don’t build the link with the new table.

idCountry should be added in Client table as int(12) !

But for one country, the id is not the same when langage change…
Last edit: 17 Jun 2014 14:40 by Jean-Luc.

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 15:01 #4 by babynus

But some menu entries – as Role and all other entries under Values lists… and Values lists itself ! – are not in access rigths, however they are presents on menu! (I work as Admin, of course)

YES THEY ARE : in "access to forms"
If you deal with "Access mode to data", only project dependent items are managed here.

But for one country, the id is not the same when langage change…

:huh:
Please explain, it is not clear.

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 15:30 - 17 Jun 2014 17:24 #5 by Jean-Luc

babynus wrote:

But some menu entries – as Role and all other entries under Values lists… and Values lists itself ! – are not in access rigths, however they are presents on menu! (I work as Admin, of course)

YES THEY ARE : in "access to forms"
If you deal with "Access mode to data", only project dependent items are managed here.

O.K., found.
Technically, it's not the 'accessright' table as I thought, but 'habilitation'. :)

And how add an icone in the menu ?
I have created iconCountry16.png, iconCountry22.png and iconCountry32.png in view/css/images, but noting appears…

babynus wrote:

But for one country, the id is not the same when langage change…

:huh:
Please explain, it is not clear.

there as many lines per country as number of languages used. At now, two :
Country code 'de' is for Germany, but with two lines (id, code, lang, name) :
121     de     en     Germany
122     de     fr     Allemagne
i.e. country is identified by code, not by line id.
In future, there could be added also, p.e.
487     de     de     Deutchland
503     de     nl     Duitsland
733     de     es     Alemania
999     de     gr     Γερµανία
etc.

And, even with country as int(12), nothing changes… only [colIdCountry] as label, and a (long) text input field.
Last edit: 17 Jun 2014 17:24 by Jean-Luc.

Please Log in or Create an account to join the conversation.

More
17 Jun 2014 18:15 #6 by babynus

And how add an icone in the menu ?
I have created iconCountry16.png, iconCountry22.png and iconCountry32.png in view/css/images, but noting appears…

Update /css/projectorIcon.css

there as many lines per country as number of languages used. At now, two :
Country code 'de' is for Germany, but with two lines (id, code, lang, name) :
121 de en Germany
122 de fr Allemagne
i.e. country is identified by code, not by line id.
In future, there could be added also, p.e.
487 de de Deutchland
503 de nl Duitsland
733 de es Alemania
999 de gr Γερµανία
etc.

You complicated much too much, and will have to code correct list.
Just single list with translatable name would be easier : just have to define field $_isTranslatable in the class :whistle:

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.057 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.