Standardize code. Debug module HRM
This commit is contained in:
parent
23cda5f464
commit
03af14294a
@ -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 = '')
|
||||
{
|
||||
|
||||
@ -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 = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||
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 '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
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 '<tr class="oddeven">';
|
||||
print '<td>'.$establishmentstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="left">'.$obj->address.'</td>';
|
||||
print '<td>'.$obj->label.'</td>';
|
||||
print '<td class="left">'.$obj->address.'</td>';
|
||||
print '<td class="left">'.$obj->zip.'</td>';
|
||||
print '<td class="left">'.$obj->town.'</td>';
|
||||
|
||||
print '<td class="right">';
|
||||
print $establishmentstatic->getLibStatut(5);
|
||||
print '</td>';
|
||||
@ -130,7 +130,7 @@ if ($result)
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -142,7 +142,7 @@ dol_fiche_end();
|
||||
|
||||
// Buttons
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="../establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/hrm/establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
|
||||
print '</div>';
|
||||
|
||||
// End of page
|
||||
|
||||
@ -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 '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">'.$langs->trans('Journaux').'</td>';
|
||||
print '<td colspan="3">'.$langs->trans('Parameters').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($list as $key) {
|
||||
|
||||
@ -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 = '<u>'.$langs->trans("Establishment").'</u>';
|
||||
$label .= '<br>'.$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';
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 '<tr>';
|
||||
print '<td>'.$form->editfieldkey('Name', 'name', '', $object, 0, 'string', '', 1).'</td>';
|
||||
print '<td><input name="name" id="name" size="32" value="'.GETPOST("name", "alpha").'"></td>';
|
||||
print '<td>'.$form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td>';
|
||||
print '<td><input name="label" id="label" value="'.GETPOST("label", "alphanohtml").'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Entity
|
||||
@ -192,7 +192,7 @@ if ($action == 'create')
|
||||
print '<tr>';
|
||||
print '<td>'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
|
||||
print '<td>';
|
||||
print '<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST('address', 'alpha').'">';
|
||||
print '<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST('address', 'alphanohtml').'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -273,13 +273,13 @@ if (($id || $ref) && $action == 'edit')
|
||||
|
||||
// Ref
|
||||
print "<tr>";
|
||||
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
|
||||
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
|
||||
print $object->id;
|
||||
print '</td></tr>';
|
||||
|
||||
// Name
|
||||
print '<tr><td>'.$form->editfieldkey('Name', 'name', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
print '<input name="name" id="name" class="flat" size="32" value="'.$object->name.'">';
|
||||
print '<tr><td>'.$form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
|
||||
print '<input name="label" id="label" class="flat" value="'.$object->label.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Entity
|
||||
@ -294,7 +294,7 @@ if (($id || $ref) && $action == 'edit')
|
||||
// Address
|
||||
print '<tr><td>'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
|
||||
print '<td>';
|
||||
print '<input name="address" id="address" size="32" value="'.$object->address.'">';
|
||||
print '<input name="address" id="address" value="'.$object->address.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Zipcode / Town
|
||||
@ -369,8 +369,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
// Name
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$object->name.'</td>';
|
||||
print '<td class="titlefield">'.$langs->trans("Label").'</td>';
|
||||
print '<td>'.$object->label.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Entity
|
||||
@ -390,7 +390,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
// Zipcode
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Zipcode").'</td>';
|
||||
print '<td>'.$langs->trans("Zip").'</td>';
|
||||
print '<td>'.$object->zip.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user