diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 31898025c94..5567813db79 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5772,7 +5772,7 @@ class Form * @param int $disabled 1=Html component is disabled * @param string $selected_input_value Value of preselected input text (for use with ajax) * @return string Return HTML string - * @see selectForFormsList() select_thirdparty + * @see selectForFormsList() select_thirdparty() */ public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index a260941ab0d..6661be2c754 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -51,11 +51,14 @@ foreach ($tmpstatus2label as $key => $val) $status2label[$key] = $langs->trans($ * View */ +$form = new Form($db); +$establishmenttmp = new Establishment($db); + llxHeader('', $langs->trans("Establishments")); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortorder = GETPOST("sortorder"); -$sortfield = GETPOST("sortfield"); +$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST("sortfield", 'alpha'); if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "e.rowid"; @@ -68,11 +71,6 @@ $pageprev = $page - 1; $pagenext = $page + 1; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$form = new Form($db); -$establishmenttmp = new Establishment($db); - -dol_htmloutput_mesg($mesg); - // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("HRMSetup"), $linkback); @@ -81,7 +79,7 @@ print load_fiche_titre($langs->trans("HRMSetup"), $linkback); $head = hrm_admin_prepare_head(); dol_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user"); -$sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status"; +$sql = "SELECT e.rowid, e.label, e.address, e.zip, e.town, e.status"; $sql .= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql .= " WHERE e.entity IN (".getEntity('establishment').')'; $sql .= $db->order($sortfield, $sortorder); @@ -96,7 +94,8 @@ if ($result) // Load attribute_label print ''; print ''; - print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "e.name", "", "", "", $sortfield, $sortorder); + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "e.label", "", "", "", $sortfield, $sortorder); print_liste_field_titre("Address", $_SERVER["PHP_SELF"], "e.address", "", "", "", $sortfield, $sortorder); print_liste_field_titre("Zipcode", $_SERVER["PHP_SELF"], "e.zip", "", "", "", $sortfield, $sortorder); print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "e.town", "", "", "", $sortfield, $sortorder); @@ -112,16 +111,17 @@ if ($result) $obj = $db->fetch_object($result); $establishmentstatic->id = $obj->rowid; - $establishmentstatic->name = $obj->name; + $establishmentstatic->ref = $obj->ref; + $establishmentstatic->label = $obj->label; $establishmentstatic->status = $obj->status; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; @@ -130,7 +130,7 @@ if ($result) $i++; } } else { - print ''; + print ''; } print '
'.$establishmentstatic->getNomUrl(1).''.$obj->address.''.$obj->label.''.$obj->address.''.$obj->zip.''.$obj->town.''; print $establishmentstatic->getLibStatut(5); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; @@ -142,7 +142,7 @@ dol_fiche_end(); // Buttons print '
'; -print ''.$langs->trans("NewEstablishment").''; +print ''.$langs->trans("NewEstablishment").''; print '
'; // End of page diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php index c839e7c4cd4..dcf4fe8bbec 100644 --- a/htdocs/hrm/admin/admin_hrm.php +++ b/htdocs/hrm/admin/admin_hrm.php @@ -34,7 +34,7 @@ $action = GETPOST('action', 'alpha'); // Other parameters HRM_* $list = array( - 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example +// 'HRM_EMAIL_EXTERNAL_SERVICE' // To prevent your public accountant for example ); /* @@ -82,7 +82,7 @@ dol_fiche_head($head, 'parameters', $langs->trans("HRM"), -1, "user"); print ''; print ''; -print ''; +print ''; print "\n"; foreach ($list as $key) { diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 2bbe374d1d0..6a4fca3516a 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -75,7 +75,7 @@ class Establishment extends CommonObject */ public $rowid; - public $name; + public $label; /** * @var string Address @@ -97,11 +97,31 @@ class Establishment extends CommonObject public $country_id; - public $statuts = array(); - public $statuts_short = array(); - const STATUS_OPEN = 0; - const STATUS_CLOSED = 1; + const STATUS_OPEN = 1; + const STATUS_CLOSED = 0; + + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), + 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(128)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>22), + 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'fk_state' =>array('type'=>'integer', 'label'=>'Fkstate', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + 'fk_country' =>array('type'=>'integer', 'label'=>'Fkcountry', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + 'profid1' =>array('type'=>'varchar(20)', 'label'=>'Profid1', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'profid2' =>array('type'=>'varchar(20)', 'label'=>'Profid2', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'profid3' =>array('type'=>'varchar(20)', 'label'=>'Profid3', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkuserauthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_user_mod' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fkusermod', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>80), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>85), + 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + ); /** @@ -112,9 +132,6 @@ class Establishment extends CommonObject public function __construct($db) { $this->db = $db; - - $this->statuts_short = array(0 => 'Closed', 1 => 'Open'); - $this->statuts = array(0 => 'Closed', 1 => 'Open'); } /** @@ -128,7 +145,6 @@ class Establishment extends CommonObject global $conf, $langs; $error = 0; - $ret = 0; $now = dol_now(); // Clean parameters @@ -137,11 +153,13 @@ class Establishment extends CommonObject $this->town = ($this->town > 0 ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); + if (empty($this->ref)) $this->ref = '(PROV)'; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."establishment ("; $sql .= "ref"; - $sql .= ", name"; + $sql .= ", label"; $sql .= ", address"; $sql .= ", zip"; $sql .= ", town"; @@ -152,7 +170,8 @@ class Establishment extends CommonObject $sql .= ", fk_user_author"; $sql .= ", fk_user_mod"; $sql .= ") VALUES ("; - $sql .= " '".$this->db->escape($this->name)."'"; + $sql .= "'".$this->db->escape($this->ref)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->town)."'"; @@ -184,6 +203,12 @@ class Establishment extends CommonObject $this->db->rollback(); return -1 * $error; } else { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'establishment'); + + $sql = 'UPDATE '.MAIN_DB_PREFIX."establishment SET ref = '".$this->db->escape($this->id)."'"; + $sql .= " WHERE rowid = ".$this->id; + $this->db->query($sql); + $this->db->commit(); return $this->id; } @@ -200,7 +225,7 @@ class Establishment extends CommonObject global $langs; // Check parameters - if (empty($this->name)) + if (empty($this->label)) { $this->error = 'ErrorBadParameter'; return -1; @@ -209,7 +234,8 @@ class Establishment extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."establishment"; - $sql .= " SET ref = '".$this->db->escape($this->ref)."', name = '".$this->db->escape($this->name)."'"; + $sql .= " SET ref = '".$this->db->escape($this->ref)."'"; + $sql .= ", label = '".$this->db->escape($this->label)."'"; $sql .= ", address = '".$this->db->escape($this->address)."'"; $sql .= ", zip = '".$this->db->escape($this->zip)."'"; $sql .= ", town = '".$this->db->escape($this->town)."'"; @@ -239,7 +265,7 @@ class Establishment extends CommonObject */ public function fetch($id) { - $sql = "SELECT e.rowid, e.ref, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id, e.entity,"; + $sql = "SELECT e.rowid, e.ref, e.label, e.address, e.zip, e.town, e.status, e.fk_country as country_id, e.entity,"; $sql .= ' c.code as country_code, c.label as country'; $sql .= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON e.fk_country = c.rowid'; @@ -253,7 +279,7 @@ class Establishment extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; - $this->name = $obj->name; + $this->label = $obj->label; $this->address = $obj->address; $this->zip = $obj->zip; $this->town = $obj->town; @@ -329,7 +355,7 @@ class Establishment extends CommonObject } $statusType = 'status'.$status; - //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_OPEN) $statusType = 'status4'; if ($status == self::STATUS_CLOSED) $statusType = 'status6'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); @@ -397,11 +423,12 @@ class Establishment extends CommonObject $picto = 'building'; - $label = $langs->trans("Show").': '.$this->name; + $label = ''.$langs->trans("Establishment").''; + $label .= '
'.$langs->trans("Label").': '.$this->label; if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend); if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.$this->name.$linkend; + if ($withpicto != 2) $result .= $link.$this->label.$linkend; return $result; } @@ -432,6 +459,7 @@ class Establishment extends CommonObject public function initAsSpecimen() { $this->id = 0; - $this->ref = 'DEP-AAA'; + $this->ref = '0'; + $this->label = 'Department AAA'; } } diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index c7784d42fb2..55751784630 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -72,10 +72,10 @@ if ($action == 'confirm_delete' && $confirm == "yes") { $error = 0; - $object->name = GETPOST('name', 'alpha'); - if (empty($object->name)) + $object->label = GETPOST('label', 'alpha'); + if (empty($object->label)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $error++; } @@ -114,15 +114,15 @@ elseif ($action == 'update') $error = 0; if (!$cancel) { - $name = GETPOST('name', 'alpha'); + $name = GETPOST('label', 'alpha'); if (empty($name)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Name')), null, 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Label')), null, 'errors'); $error++; } if (empty($error)) { - $object->name = GETPOST('name', 'alpha'); + $object->label = GETPOST('label', 'alphanohtml'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -173,8 +173,8 @@ if ($action == 'create') // Name print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Entity @@ -192,7 +192,7 @@ if ($action == 'create') print ''; print ''; print ''; print ''; @@ -273,13 +273,13 @@ if (($id || $ref) && $action == 'edit') // Ref print ""; - print ''; // Name - print ''; // Entity @@ -294,7 +294,7 @@ if (($id || $ref) && $action == 'edit') // Address print ''; print ''; // Zipcode / Town @@ -369,8 +369,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Name print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Entity @@ -390,7 +390,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Zipcode print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 40eaa96a0fc..4611c47ae37 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -60,10 +60,10 @@ ALTER TABLE llx_commande MODIFY COLUMN date_livraison DATETIME; ALTER TABLE llx_website ADD COLUMN position integer DEFAULT 0; ALTER TABLE llx_establishment ADD COLUMN ref varchar(30); -ALTER TABLE llx_establishment ADD COLUMN name varchar(128); +ALTER TABLE llx_establishment ADD COLUMN label varchar(128); UPDATE llx_establishment SET ref = rowid WHERE ref IS NULL; ALTER TABLE llx_establishment MODIFY COLUMN ref varchar(30) NOT NULL; -ALTER TABLE llx_establishment MODIFY COLUMN name varchar(128); +ALTER TABLE llx_establishment MODIFY COLUMN label varchar(128); INSERT INTO llx_const (name, entity, value, type, visible) VALUES ('PRODUCT_PRICE_BASE_TYPE', 0, 'HT', 'string', 0);
'.$langs->trans('Journaux').''.$langs->trans('Parameters').'
'.$form->editfieldkey('Name', 'name', '', $object, 0, 'string', '', 1).''.$form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'
'.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print ''; + print ''; print '
'.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print $object->id; print '
'.$form->editfieldkey('Name', 'name', '', $object, 0, 'string', '', 1).''; - print ''; + print '
'.$form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).''; + print ''; print '
'.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print ''; + print ''; print '
'.$langs->trans("Name").''.$object->name.''.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Zipcode").''.$langs->trans("Zip").''.$object->zip.'