From b535bc0cb96c919312d26ed7b203f87f143ad936 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 11:27:04 +0200 Subject: [PATCH 01/77] start dev --- htdocs/core/lib/company.lib.php | 1 + .../install/mysql/migration/10.0.0-11.0.0.sql | 17 +++++++++-- .../mysql/tables/llx_societe_contact.key.sql | 22 ++++++++++++++ .../mysql/tables/llx_societe_contact.sql | 29 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_societe_contact.key.sql create mode 100644 htdocs/install/mysql/tables/llx_societe_contact.sql diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2f6c474e632..8d862d3a9af 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -896,6 +896,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), + 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), ); // Extra fields diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 8efe44db103..5bc114c2294 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -89,5 +89,18 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0; UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0; - - \ No newline at end of file +create table llx_societe_contact +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime NULL, -- date de creation de l'enregistrement + statut smallint DEFAULT 5, -- 5 inactif, 4 actif + + element_id int NOT NULL, -- la reference de l'element. + fk_c_type_contact int NOT NULL, -- nature du contact. + fk_socpeople integer NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); + +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.key.sql b/htdocs/install/mysql/tables/llx_societe_contact.key.sql new file mode 100644 index 00000000000..1409e7edc24 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_contact.key.sql @@ -0,0 +1,22 @@ +-- ======================================================================== +-- Copyright (C) 2019 Florian HENRY +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); + +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.sql b/htdocs/install/mysql/tables/llx_societe_contact.sql new file mode 100644 index 00000000000..040f8ded124 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_societe_contact.sql @@ -0,0 +1,29 @@ +-- ======================================================================== +-- Copyright (C) 2019 Florian HENRY +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + + +create table llx_societe_contact +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime NULL, -- date de creation de l'enregistrement + statut smallint DEFAULT 5, -- 5 inactif, 4 actif + + element_id int NOT NULL, -- la reference de l'element. + fk_c_type_contact int NOT NULL, -- nature du contact. + fk_socpeople integer NOT NULL +)ENGINE=innodb; From 405c92640c077c4fbda99604123f4574681b1816 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 14:47:32 +0200 Subject: [PATCH 02/77] on going --- htdocs/contact/class/contact.class.php | 50 +++++++++++++- htdocs/core/class/commonobject.class.php | 69 +++++++++++++++++++ htdocs/core/lib/company.lib.php | 44 ++++++++++-- .../install/mysql/migration/10.0.0-11.0.0.sql | 23 ++++--- ...t.key.sql => llx_societe_contacts.key.sql} | 8 +-- ...e_contact.sql => llx_societe_contacts.sql} | 17 ++--- htdocs/langs/en_US/main.lang | 14 +++- 7 files changed, 195 insertions(+), 30 deletions(-) rename htdocs/install/mysql/tables/{llx_societe_contact.key.sql => llx_societe_contacts.key.sql} (61%) rename htdocs/install/mysql/tables/{llx_societe_contact.sql => llx_societe_contacts.sql} (69%) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e064b93504d..db6ab29b802 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -82,7 +82,7 @@ class Contact extends CommonObject public $civility_id; // In fact we store civility_code public $civility_code; - public $civility; + public $civility; public $address; public $zip; public $town; @@ -139,6 +139,8 @@ class Contact extends CommonObject public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $roles=array(); + /** * Constructor @@ -1449,4 +1451,50 @@ class Contact extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } + + /** + * Fetch Role for a contact + * + * @return float|int + * @throws Exception + */ + public function fetchRole() + { + + global $langs; + $error= 0; + $num=0; + + $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe_contacts as sc "; + $sql.=" INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql.=" ON tc.rowid = sc.fk_c_type_contact"; + $sql.=" AND sc.fk_socpeople = ". $this->id; + $sql.=" AND tc.source = 'external' AND tc.active=1"; + $sql.=" AND sc.entity IN (".getEntity('societe').')'; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + + $this->roles=array(); + $resql=$this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) { + $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; + $this->roles[$this->id]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); + } + } + } else { + $error++; + $this->errors[]=$this->db->lasterror(); + } + + if (empty($error)) { + return $num; + } else { + return $error * -1; + } + } + } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c57148124be..0eea968ecd2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1210,6 +1210,75 @@ abstract class CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array with list of possible values for type of contacts + * + * @param string $source 'internal', 'external' or 'all' + * @param int $option 0=Return array id->label, 1=Return array code->label + * @param int $activeonly 0=all status of contact, 1=only the active + * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') + * @param string $element Filter Element Type + * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) + */ + public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '') + { + // phpcs:enable + global $langs; + + if (empty($order)) $order='position'; + if ($order == 'position') $order.=',code'; + + $tab = array(); + $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; + + $sqlWhere=array(); + if (!empty($element)) + $sqlWhere[]=" tc.element='".$this->db->escape($element)."'"; + + if ($activeonly == 1) + $sqlWhere[]=" tc.active=1"; // only the active types + + if (! empty($source) && $source != 'all') + $sqlWhere[]=" tc.source='".$this->db->escape($source)."'"; + + if (! empty($code)) + $sqlWhere[]=" tc.code='".$this->db->escape($code)."'"; + + if (count($sqlWhere)>0) { + $sql .= " WHERE ". implode(' AND ', $sqlWhere); + } + + $sql.= $this->db->order('tc.element, tc.position', 'ASC'); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $libelle_element = $langs->trans('ContactDefault_'.ucfirst($obj->element)); + $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; + $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); + if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; + else $tab[$obj->code]=$libelle_element.' - '.$libelle_type; + $i++; + } + return $tab; + } + else + { + $this->error=$this->db->lasterror(); + //dol_print_error($this->db); + return null; + } + } + /** * Return id of contacts for a source and a contact code. * Example: contact client de facturation ('external', 'BILLING') diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8d862d3a9af..cfc1fcfb30f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -869,6 +869,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if ($search_status=='') $search_status=1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_addressphone = GETPOST("search_addressphone", 'alpha'); + $search_role = GETPOST("search_role", 'array'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="t.lastname"; @@ -887,7 +888,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), - 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), + 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), ); // Definition of fields for list @@ -896,8 +898,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'class'=>'center'), + 'sc.role'=>array('label'=>"Role", 'checked'=>1, 'position'=>40), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), ); // Extra fields if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) @@ -927,6 +929,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { $search_status = ''; $search_name = ''; + $search_role = ''; $search_addressphone = ''; $search_array_options=array(); @@ -968,6 +971,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $param="socid=".urlencode($object->id); if ($search_status != '') $param.='&search_status='.urlencode($search_status); + if (count($search_role)>0) $param.=implode('&search_role[]=', $search_role); if ($search_name != '') $param.='&search_name='.urlencode($search_name); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -978,9 +982,15 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; + if (count($search_role)>0) { + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_contacts as sc on (sc.fk_socpeople = t.rowid)"; + } $sql .= " WHERE t.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); + if (count($search_role)>0) { + $sql .= ' AND sc.fk_c_type_contact IN ('.implode(',',$search_role).')'; + } // Add where from extra fields $extrafieldsobjectkey=$contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -993,6 +1003,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $num = $db->num_rows($result); + // Fields title search // -------------------------------------------------------------------- print ''; @@ -1002,11 +1013,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + print ''; if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); + elseif (in_array($key, array('role'))) { + $contactType=$contactstatic->listeTypeContacts('external', '', 1); + print $form->multiselectarray('search_role', $contactType, $search_role); + } print ''; } } @@ -1035,7 +1051,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + if ($key == 'role') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + } } // Extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1082,6 +1101,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); + $resultRole=$contactstatic->fetchRole(); + if ($resultRole<0) { + setEventMessages(null, $contactstatic->errors,'errors'); + } + if (is_array($contactstatic->array_options)) { foreach($contactstatic->array_options as $key => $val) @@ -1125,6 +1149,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''; } + // Role + if (! empty($arrayfields['sc.role']['checked'])) + { + print ''; + foreach($contactstatic->roles as $key=>$val) { + print '
    '.implode(' ', $val['label']).'
'; + } + print ''; + } + // Status if (! empty($arrayfields['t.statut']['checked'])) { diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 5bc114c2294..1b705133a19 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -89,18 +89,19 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0; UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0; -create table llx_societe_contact +create table llx_societe_contacts ( rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime NULL, -- date de creation de l'enregistrement - statut smallint DEFAULT 5, -- 5 inactif, 4 actif - - element_id int NOT NULL, -- la reference de l'element. - fk_c_type_contact int NOT NULL, -- nature du contact. - fk_socpeople integer NOT NULL + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + fk_soc integer NOT NULL, + fk_c_type_contact int NOT NULL, + fk_socpeople integer NOT NULL, + tms TIMESTAMP, + import_key VARCHAR(14) )ENGINE=innodb; -ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); - -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); +ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.key.sql b/htdocs/install/mysql/tables/llx_societe_contacts.key.sql similarity index 61% rename from htdocs/install/mysql/tables/llx_societe_contact.key.sql rename to htdocs/install/mysql/tables/llx_societe_contacts.key.sql index 1409e7edc24..2b2eae8b2ca 100644 --- a/htdocs/install/mysql/tables/llx_societe_contact.key.sql +++ b/htdocs/install/mysql/tables/llx_societe_contacts.key.sql @@ -16,7 +16,7 @@ -- -- ======================================================================== -ALTER TABLE llx_societe_contact ADD UNIQUE INDEX idx_societe_contact_idx1 (element_id, fk_c_type_contact, fk_socpeople); - -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); -ALTER TABLE llx_societe_contact ADD CONSTRAINT fk_societe_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); +ALTER TABLE llx_societe_contacts ADD UNIQUE INDEX idx_societe_contacts_idx1 (entity, fk_soc, fk_c_type_contact, fk_socpeople); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_c_type_contact FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe(rowid); +ALTER TABLE llx_societe_contacts ADD CONSTRAINT fk_societe_contacts_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople(rowid); diff --git a/htdocs/install/mysql/tables/llx_societe_contact.sql b/htdocs/install/mysql/tables/llx_societe_contacts.sql similarity index 69% rename from htdocs/install/mysql/tables/llx_societe_contact.sql rename to htdocs/install/mysql/tables/llx_societe_contacts.sql index 040f8ded124..31d82f3003d 100644 --- a/htdocs/install/mysql/tables/llx_societe_contact.sql +++ b/htdocs/install/mysql/tables/llx_societe_contacts.sql @@ -17,13 +17,14 @@ -- ======================================================================== -create table llx_societe_contact +create table llx_societe_contacts ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime NULL, -- date de creation de l'enregistrement - statut smallint DEFAULT 5, -- 5 inactif, 4 actif - - element_id int NOT NULL, -- la reference de l'element. - fk_c_type_contact int NOT NULL, -- nature du contact. - fk_socpeople integer NOT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, + date_creation datetime NOT NULL, + fk_soc integer NOT NULL, + fk_c_type_contact int NOT NULL, + fk_socpeople integer NOT NULL, + tms TIMESTAMP, + import_key VARCHAR(14) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 5c3e30967de..2b92ed783fe 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -989,4 +989,16 @@ ToApprove=To approve GlobalOpenedElemView=Global view NoArticlesFoundForTheKeyword=No article found for the keyword '%s' NoArticlesFoundForTheCategory=No article found for the category -ToAcceptRefuse=To accept | refuse \ No newline at end of file +ToAcceptRefuse=To accept | refuse +ContactDefault_agenda=Event +ContactDefault_commande=Order +ContactDefault_contrat=Contract +ContactDefault_facture=Invoice +ContactDefault_fichinter=Intervention +ContactDefault_invoice_supplier=Supplier Invoice +ContactDefault_order_supplier=Supplier Order +ContactDefault_project=Project +ContactDefault_project_task=Task +ContactDefault_propal=Proposal +ContactDefault_supplier_proposal=Supplier Proposal +ContactDefault_ticketsup=Ticket From d811de4da2e7028d4ffd4150532dcd95ffeb5548 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 2 Sep 2019 22:01:48 +0200 Subject: [PATCH 03/77] let only triggers part --- htdocs/contact/card.php | 28 ++++++- htdocs/contact/class/contact.class.php | 93 +++++++++++++++++++++++- htdocs/contact/list.php | 10 +++ htdocs/core/class/commonobject.class.php | 7 +- htdocs/core/class/html.form.class.php | 40 ++++++++++ htdocs/core/lib/company.lib.php | 29 ++++---- 6 files changed, 179 insertions(+), 28 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 76d0e3911b5..20a61ec4e3e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -371,6 +371,7 @@ if (empty($reshook)) $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -474,9 +475,6 @@ else // Si edition contact deja existant $object = new Contact($db); $res=$object->fetch($id, $user); - if ($res < 0) { dol_print_error($db, $object->error); exit; } - $res=$object->fetch_optionals(); - if ($res < 0) { dol_print_error($db, $object->error); exit; } // Show tabs $head = contact_prepare_head($object); @@ -724,6 +722,15 @@ else print ""; } + //Role + if (!empty($socid)) { + print '' . $langs->trans("Role") . ''; + print ''; + $contactType = $object->listeTypeContacts('external', '', 1); + print $form->multiselectarray('roles', $contactType); + print ''; + } + // Other attributes $parameters=array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1040,6 +1047,14 @@ else print ""; } + //Role + if (!empty($object->socid)) { + print '' . $langs->trans("Role") . ''; + print ''; + print $form->showRoles("roles", $object, 'edit' ,$object->roles); + print ''; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1238,6 +1253,13 @@ else print ''; } + if (!empty($object->socid)) { + print '' . $langs->trans("Roles") . ''; + print ''; + print $form->showRoles("roles", $object, 'view'); + print ''; + } + // Other attributes $cols = 3; $parameters=array('socid'=>$socid); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index db6ab29b802..d718a898f2d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -399,6 +399,14 @@ class Contact extends CommonObject } } + if (! $error) { + $result=$this->updateRoles(); + if ($result < 0) + { + $error++; + } + } + if (! $error && $this->user_id > 0) { $tmpobj = new User($this->db); @@ -861,6 +869,11 @@ class Contact extends CommonObject // fetch optionals attributes and labels $this->fetch_optionals(); + $resultRole=$this->fetchRoles(); + if ($resultRole<0) { + return $resultRole; + } + return 1; } else @@ -995,6 +1008,20 @@ class Contact extends CommonObject } } + if (! $error) + { + // Remove Roles + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error .= $this->db->lasterror(); + $errorflag=-1; + } + } + if (! $error) { // Remove category @@ -1458,14 +1485,13 @@ class Contact extends CommonObject * @return float|int * @throws Exception */ - public function fetchRole() + public function fetchRoles() { - global $langs; $error= 0; $num=0; - $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle"; + $sql ="SELECT tc.rowid, tc.element, tc.source, tc.code, tc.libelle, sc.rowid as contactroleid"; $sql.=" FROM ".MAIN_DB_PREFIX."societe_contacts as sc "; $sql.=" INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.=" ON tc.rowid = sc.fk_c_type_contact"; @@ -1482,11 +1508,13 @@ class Contact extends CommonObject if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) { $transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code; - $this->roles[$this->id]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); + $libelle_element = $langs->trans('ContactDefault_'.$obj->element); + $this->roles[$obj->contactroleid]=array('id'=>$obj->rowid,'element'=>$obj->element,'source'=>$obj->source,'code'=>$obj->code,'label'=>$libelle_element. ' - '.($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle)); } } } else { $error++; + $this->error=$this->db->lasterror(); $this->errors[]=$this->db->lasterror(); } @@ -1497,4 +1525,61 @@ class Contact extends CommonObject } } + /** + * Updates Roles + * + * @return float|int + * @throws Exception + */ + public function updateRoles() + { + global $conf; + + $error=0; + + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid; + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + $result = $this->db->query($sql); + if (!$result) { + $this->errors[]=$this->db->lasterror().' sql='.$sql; + $error++; + } else { + if (count($this->roles)>0) { + foreach ($this->roles as $keyRoles => $valRoles) { + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_contacts"; + $sql .= " (entity,"; + $sql .= "date_creation,"; + $sql .= "fk_soc,"; + $sql .= "fk_c_type_contact,"; + $sql .= "fk_socpeople) "; + $sql .= " VALUES (" . $conf->entity . ","; + $sql .= "'" . $this->db->idate(dol_now()) . "',"; + $sql .= $this->socid . ", "; + $sql .= $valRoles . " , " ; + $sql .= $this->id; + $sql .= ")"; + dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + + $result = $this->db->query($sql); + if (!$result) + { + $this->errors[]=$this->db->lasterror().' sql='.$sql; + $error++; + } + } + } + } + if (empty($error)) { + $this->db->commit(); + return 1; + } else { + $this->error=implode(' ', $this->errors); + $this->db->rollback(); + return $error*-1; + } + } + } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b0db8b0affb..585d6db499d 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -84,6 +84,7 @@ $search_zip=GETPOST('search_zip', 'alpha'); $search_town=GETPOST('search_town', 'alpha'); $search_import_key=GETPOST("search_import_key", "alpha"); $search_country=GETPOST("search_country", 'intcomma'); +$search_roles=GETPOST("search_roles", 'array'); if ($search_status=='') $search_status=1; // always display active customer first @@ -242,6 +243,7 @@ if (empty($reshook)) $search_import_key=''; $toselect=''; $search_array_options=array(); + $search_roles=array(); } // Mass actions @@ -334,6 +336,9 @@ if (strlen($search_linkedin)) $sql.= natural_search('p.linkedin', $search_ if (strlen($search_email)) $sql.= natural_search('p.email', $search_email); if (strlen($search_zip)) $sql.= natural_search("p.zip", $search_zip); if (strlen($search_town)) $sql.= natural_search("p.town", $search_town); +if (count($search_roles)>0) { + $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; +} if ($search_no_email != '' && $search_no_email >= 0) $sql.= " AND p.no_email = ".$db->escape($search_no_email); if ($search_status != '' && $search_status >= 0) $sql.= " AND p.statut = ".$db->escape($search_status); @@ -438,6 +443,7 @@ if ($search_status != '') $param.='&search_status='.urlencode($search_status if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -510,6 +516,10 @@ if (! empty($conf->categorie->enabled)) $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); $moreforfilter.=''; } + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Roles'). ': '; + $moreforfilter.=$form->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter.='
'; } if ($moreforfilter) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0eea968ecd2..716b615f503 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1226,9 +1226,6 @@ abstract class CommonObject // phpcs:enable global $langs; - if (empty($order)) $order='position'; - if ($order == 'position') $order.=',code'; - $tab = array(); $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1262,11 +1259,11 @@ abstract class CommonObject { $obj = $this->db->fetch_object($resql); - $libelle_element = $langs->trans('ContactDefault_'.ucfirst($obj->element)); + $libelle_element = $langs->trans('ContactDefault_'.$obj->element); $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - else $tab[$obj->code]=$libelle_element.' - '.$libelle_type; + else $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; $i++; } return $tab; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5ee969a73a0..4eca1ef0f85 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6484,6 +6484,46 @@ class Form return 'ErrorBadValueForParameterRenderMode'; // Should not happened } + /** + * showContactRoles on view and edit mode + * + * @param string $htmlname Html component name and id + * @param Contact $contact Contact Obejct + * @param string $rendermode view, edit + * @param array $selected $key=>$val $val is selected Roles for input mode + * @return string String with contacts roles + */ + public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + { + if ($rendermode === 'view') { + $toprint = array(); + foreach ($contact->roles as $key => $val) { + $toprint[] = '
  • ' . $val['label'] . '
  • '; + } + return '
      ' . implode(' ', $toprint) . '
    '; + } + + if ($rendermode === 'edit') + { + $contactType=$contact->listeTypeContacts('external', '', 1); + + if (count($selected)>0) { + $newselected=array(); + foreach($selected as $key=>$val) { + if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { + $newselected[]=$val['id']; + } else { + break; + } + } + if (count($newselected)>0) $selected=$newselected; + } + return $this->multiselectarray($htmlname, $contactType, $selected); + } + + return 'ErrorBadValueForParameterRenderMode'; // Should not happened + } + /** * Show linked object block. diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index cfc1fcfb30f..14b20bbe46b 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -869,7 +869,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if ($search_status=='') $search_status=1; // always display active customer first $search_name = GETPOST("search_name", 'alpha'); $search_addressphone = GETPOST("search_addressphone", 'alpha'); - $search_role = GETPOST("search_role", 'array'); + $search_roles = GETPOST("search_roles", 'array'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="t.lastname"; @@ -898,7 +898,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), - 'sc.role'=>array('label'=>"Role", 'checked'=>1, 'position'=>40), + 'sc.role'=>array('label'=>"Roles", 'checked'=>1, 'position'=>40), 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'), ); // Extra fields @@ -929,7 +929,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') { $search_status = ''; $search_name = ''; - $search_role = ''; + $search_roles = array(); $search_addressphone = ''; $search_array_options=array(); @@ -971,7 +971,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $param="socid=".urlencode($object->id); if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if (count($search_role)>0) $param.=implode('&search_role[]=', $search_role); + if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); if ($search_name != '') $param.='&search_name='.urlencode($search_name); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields @@ -982,14 +982,11 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $sql .= " t.civility as civility_id, t.address, t.zip, t.town"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; - if (count($search_role)>0) { - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_contacts as sc on (sc.fk_socpeople = t.rowid)"; - } $sql .= " WHERE t.fk_soc = ".$object->id; if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status); if ($search_name) $sql .= natural_search(array('t.lastname', 't.firstname'), $search_name); - if (count($search_role)>0) { - $sql .= ' AND sc.fk_c_type_contact IN ('.implode(',',$search_role).')'; + if (count($search_roles)>0) { + $sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } // Add where from extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1020,8 +1017,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); elseif (in_array($key, array('role'))) { - $contactType=$contactstatic->listeTypeContacts('external', '', 1); - print $form->multiselectarray('search_role', $contactType, $search_role); + print $form->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } print ''; } @@ -1052,9 +1048,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center'; if ($key == 'role') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked']) || ! empty($arrayfields['sc.'.$key]['checked'])) { + if (! empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } + if (! empty($arrayfields['sc.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'sc.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + } } // Extra fields $extrafieldsobjectkey=$contactstatic->table_element; @@ -1101,7 +1100,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->setGenderFromCivility(); $contactstatic->fetch_optionals(); - $resultRole=$contactstatic->fetchRole(); + $resultRole=$contactstatic->fetchRoles(); if ($resultRole<0) { setEventMessages(null, $contactstatic->errors,'errors'); } @@ -1153,9 +1152,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (! empty($arrayfields['sc.role']['checked'])) { print ''; - foreach($contactstatic->roles as $key=>$val) { - print '
      '.implode(' ', $val['label']).'
    '; - } + print $form->showRoles("roles", $contactstatic, 'view'); print ''; } From 6c20fbafdf0c5811a5802da2c11468b0798a0359 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 3 Sep 2019 17:04:42 +0200 Subject: [PATCH 04/77] add trigger files --- htdocs/contact/card.php | 4 +- htdocs/contact/class/contact.class.php | 43 +++++++ htdocs/contact/list.php | 4 +- htdocs/core/class/commonobject.class.php | 42 +++--- htdocs/core/class/html.form.class.php | 41 ------ htdocs/core/class/html.formcompany.class.php | 64 +++++++--- htdocs/core/lib/company.lib.php | 6 +- ...rface_90_modSociete_ContactRoles.class.php | 120 ++++++++++++++++++ 8 files changed, 241 insertions(+), 83 deletions(-) create mode 100644 htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 20a61ec4e3e..5861cc71d38 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1051,7 +1051,7 @@ else if (!empty($object->socid)) { print '' . $langs->trans("Role") . ''; print ''; - print $form->showRoles("roles", $object, 'edit' ,$object->roles); + print $formcompany->showRoles("roles", $object, 'edit' ,$object->roles); print ''; } @@ -1256,7 +1256,7 @@ else if (!empty($object->socid)) { print '' . $langs->trans("Roles") . ''; print ''; - print $form->showRoles("roles", $object, 'view'); + print $formcompany->showRoles("roles", $object, 'view'); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d718a898f2d..6b46e32f532 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1525,6 +1525,49 @@ class Contact extends CommonObject } } + /** + * Get Contact roles for a thirdparty + * + * @param string $element element type + * @return array|int + * @throws Exception + */ + public function getContactRoles($element = '') + { + $tab=array(); + + $sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; + $sql.= ", ".MAIN_DB_PREFIX."societe_contacts sc"; + $sql.= " WHERE sc.fk_soc =".$this->socid; + $sql.= " AND sc.fk_c_type_contact=tc.rowid"; + $sql.= " AND tc.element='".$element."'"; + $sql.= " AND tc.active=1"; + + dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $tab[]=array('fk_socpeople'=>$obj->id, 'type_contact'=>$obj->fk_c_type_contact); + + $i++; + } + + return $tab; + } + else + { + $this->error=$this->db->error(); + dol_print_error($this->db); + return -1; + } + } + /** * Updates Roles * diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 585d6db499d..6b595a05860 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -36,6 +36,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "suppliers", "categories")); @@ -264,6 +265,7 @@ if ($search_priv < 0) $search_priv=''; $form=new Form($db); $formother=new FormOther($db); +$formcompany=new FormCompany($db); $contactstatic=new Contact($db); $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); @@ -518,7 +520,7 @@ if (! empty($conf->categorie->enabled)) } $moreforfilter.='
    '; $moreforfilter.=$langs->trans('Roles'). ': '; - $moreforfilter.=$form->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter.=$formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); $moreforfilter.='
    '; } if ($moreforfilter) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 716b615f503..1a1b5c597ce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1224,9 +1224,10 @@ abstract class CommonObject public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '') { // phpcs:enable - global $langs; + global $langs, $conf; $tab = array(); + $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position, tc.element"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; @@ -1251,27 +1252,36 @@ abstract class CommonObject dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - - $libelle_element = $langs->trans('ContactDefault_'.$obj->element); - $transkey="TypeContact_".$this->element."_".$source."_".$obj->code; - $libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle); - if (empty($option)) $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - else $tab[$obj->rowid]=$libelle_element.' - '.$libelle_type; - $i++; + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num > 0) { + while ($obj = $this->db->fetch_object($resql)) { + if (strpos($obj->element, 'project')!==false) { + $element='projet'; + } elseif($obj->element=='contrat') { + $element='contract'; + } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { + $element='fournisseur'; + } elseif(strpos($obj->element, 'supplier')!==false && $obj->element!='supplier_proposal') { + $element='fournisseur'; + } else { + $element=$obj->element; + } + if ($conf->{$element}->enabled) { + $libelle_element = $langs->trans('ContactDefault_' . $obj->element); + $transkey = "TypeContact_" . $this->element . "_" . $source . "_" . $obj->code; + $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); + if (empty($option)) + $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; + else $tab[$obj->rowid] = $libelle_element . ' - ' . $libelle_type; + } + } } return $tab; } else { $this->error=$this->db->lasterror(); - //dol_print_error($this->db); return null; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4eca1ef0f85..f351a361d14 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6484,47 +6484,6 @@ class Form return 'ErrorBadValueForParameterRenderMode'; // Should not happened } - /** - * showContactRoles on view and edit mode - * - * @param string $htmlname Html component name and id - * @param Contact $contact Contact Obejct - * @param string $rendermode view, edit - * @param array $selected $key=>$val $val is selected Roles for input mode - * @return string String with contacts roles - */ - public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) - { - if ($rendermode === 'view') { - $toprint = array(); - foreach ($contact->roles as $key => $val) { - $toprint[] = '
  • ' . $val['label'] . '
  • '; - } - return '
      ' . implode(' ', $toprint) . '
    '; - } - - if ($rendermode === 'edit') - { - $contactType=$contact->listeTypeContacts('external', '', 1); - - if (count($selected)>0) { - $newselected=array(); - foreach($selected as $key=>$val) { - if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { - $newselected[]=$val['id']; - } else { - break; - } - } - if (count($newselected)>0) $selected=$newselected; - } - return $this->multiselectarray($htmlname, $contactType, $selected); - } - - return 'ErrorBadValueForParameterRenderMode'; // Should not happened - } - - /** * Show linked object block. * diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 2207ab8ab2b..81b87b6f340 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -29,28 +29,11 @@ * Class to build HTML component for third parties management * Only common components are here. */ -class FormCompany + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +class FormCompany extends Form { - /** - * @var DoliDB Database handler. - */ - public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** @@ -763,6 +746,45 @@ class FormCompany } } + /** + * showContactRoles on view and edit mode + * + * @param string $htmlname Html component name and id + * @param Contact $contact Contact Obejct + * @param string $rendermode view, edit + * @param array $selected $key=>$val $val is selected Roles for input mode + * @return string String with contacts roles + */ + public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + { + if ($rendermode === 'view') { + $toprint = array(); + foreach ($contact->roles as $key => $val) { + $toprint[] = '
  • ' . $val['label'] . '
  • '; + } + return '
      ' . implode(' ', $toprint) . '
    '; + } + + if ($rendermode === 'edit') + { + $contactType=$contact->listeTypeContacts('external', '', 1); + if (count($selected)>0) { + $newselected=array(); + foreach($selected as $key=>$val) { + if (is_array($val) && array_key_exists('id', $val) && in_array($val['id'], array_keys($contactType))) { + $newselected[]=$val['id']; + } else { + break; + } + } + if (count($newselected)>0) $selected=$newselected; + } + return $this->multiselectarray($htmlname, $contactType, $selected); + } + + return 'ErrorBadValueForParameterRenderMode'; // Should not happened + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a select list with zip codes and their town diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 14b20bbe46b..331b03bacc4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -859,6 +859,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') global $user,$conf,$extrafields,$hookmanager; global $contextpage; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($db); $form = new Form($db); $optioncss = GETPOST('optioncss', 'alpha'); @@ -1017,7 +1019,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('lastname','name'))) print ''; elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0, 1),'1'=>$contactstatic->LibStatut(1, 1)), $search_status); elseif (in_array($key, array('role'))) { - print $form->showRoles("search_roles", $contactstatic, 'edit', $search_roles); + print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); } print ''; } @@ -1152,7 +1154,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (! empty($arrayfields['sc.role']['checked'])) { print ''; - print $form->showRoles("roles", $contactstatic, 'view'); + print $formcompany->showRoles("roles", $contactstatic, 'view'); print ''; } diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php new file mode 100644 index 00000000000..8fba51e7a69 --- /dev/null +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -0,0 +1,120 @@ + + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2013 Cedric GROSS + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php + * \ingroup agenda + * \brief Trigger file for agenda module + */ + +require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; + + +/** + * Class of triggered functions for agenda module + */ +class InterfaceContactRoles extends DolibarrTriggers +{ + public $family = 'agenda'; + public $description = "Triggers of this module add actions in agenda according to setup made in agenda setup."; + + /** + * Version of the trigger + * @var string + */ + public $version = self::VERSION_DOLIBARR; + + /** + * @var string Image of the trigger + */ + public $picto = 'action'; + + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: + * $object->actiontypecode (translation action code: AC_OTH, ...) + * $object->actionmsg (note, long text) + * $object->actionmsg2 (label, short text) + * $object->sendtoid (id of contact or array of ids) + * $object->socid (id of thirdparty) + * $object->fk_project + * $object->fk_element + * $object->elementtype + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) + { + // Lors de la création d'un document, récupération des contacts et rôle associés à la société et association avec le document + if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' + || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') { + + if(!empty($object->socid) && $object->socid != '-1') { + global $db, $langs; + + $contactdefault = new Contact($this->db); + $contactdefault->socid=$object->socid; + $TContact = $contactdefault->getContactRoles(); + + // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug + $TContactAlreadyLinked = array(); + if ($object->id > 0) + { + $class = get_class($object); + $cloneFrom = new $class($db); + $r = $cloneFrom->fetch($object->id); + + if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1,'external'), $cloneFrom->liste_contact(-1,'internal')); + } + + foreach($TContact as $i => $infos) { + // Gestion du cas du clone + foreach ($TContactAlreadyLinked as $contactData) { + if($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]); + } + } + + $nb = 0; + foreach($TContact as $infos) { + // Gestion du cas spécifique de la création de propale avec sélection du contact, cela créé un bug si le contact est ajouté par le module contactdefault + $res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']); + if($res > 0) $nb++; + } + + if($nb > 0) { + setEventMessage($langs->trans('ContactAddedAutomatically', $nb)); + } + } + + dol_syslog( + "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id + ); + } + } +} From d50114df649a0d7752f4a549e5d541da1dc27eeb Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 6 Sep 2019 09:20:18 +0200 Subject: [PATCH 05/77] mostlyDone --- htdocs/contact/class/contact.class.php | 2 +- ...rface_90_modSociete_ContactRoles.class.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 6b46e32f532..fad72d69637 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1544,7 +1544,7 @@ class Contact extends CommonObject $sql.= " AND tc.element='".$element."'"; $sql.= " AND tc.active=1"; - dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 8fba51e7a69..36a8274c602 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -71,16 +71,20 @@ class InterfaceContactRoles extends DolibarrTriggers */ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) { - // Lors de la création d'un document, récupération des contacts et rôle associés à la société et association avec le document + if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') { - if(!empty($object->socid) && $object->socid != '-1') { - global $db, $langs; + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc); + + if(!empty($socid) && $socid != '-1') { + global $db, $langs; + var_dump($socid); $contactdefault = new Contact($this->db); - $contactdefault->socid=$object->socid; - $TContact = $contactdefault->getContactRoles(); + $contactdefault->socid=$socid; + $TContact = $contactdefault->getContactRoles($object->element); // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug $TContactAlreadyLinked = array(); @@ -90,7 +94,7 @@ class InterfaceContactRoles extends DolibarrTriggers $cloneFrom = new $class($db); $r = $cloneFrom->fetch($object->id); - if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1,'external'), $cloneFrom->liste_contact(-1,'internal')); + if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal')); } foreach($TContact as $i => $infos) { @@ -111,10 +115,6 @@ class InterfaceContactRoles extends DolibarrTriggers setEventMessage($langs->trans('ContactAddedAutomatically', $nb)); } } - - dol_syslog( - "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id - ); } } } From 617e430998034d71b59b5b864f5a7e0911be9b9a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 12:31:17 +0200 Subject: [PATCH 06/77] fix stravis and sticker --- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 81b87b6f340..c7467922da5 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -755,7 +755,7 @@ class FormCompany extends Form * @param array $selected $key=>$val $val is selected Roles for input mode * @return string String with contacts roles */ - public function showRoles($htmlname = '', Contact $contact, $rendermode = 'view', $selected = array()) + public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array()) { if ($rendermode === 'view') { $toprint = array(); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index ec124c8a1a1..2caf438b471 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -175,4 +175,5 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, m INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-REPUBLICDAY', 0, 117, '', 0, 1, 26, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('IN-GANDI', 0, 117, '', 0, 10, 2, 1); - +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start; From 42b3640a5a0cdb0ffc463e720c5f6e0a04fe9c15 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:12:28 +0200 Subject: [PATCH 07/77] fix travis --- .../triggers/interface_90_modSociete_ContactRoles.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 36a8274c602..8d2418a8a94 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -81,12 +81,11 @@ class InterfaceContactRoles extends DolibarrTriggers if(!empty($socid) && $socid != '-1') { global $db, $langs; - var_dump($socid); + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); $contactdefault->socid=$socid; $TContact = $contactdefault->getContactRoles($object->element); - // Le trigger est appelé avant que le core n'ajoute lui-même des contacts (contact propale, clone), il ne faut pas les associer avant sinon bug $TContactAlreadyLinked = array(); if ($object->id > 0) { @@ -98,7 +97,6 @@ class InterfaceContactRoles extends DolibarrTriggers } foreach($TContact as $i => $infos) { - // Gestion du cas du clone foreach ($TContactAlreadyLinked as $contactData) { if($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]); } @@ -106,7 +104,6 @@ class InterfaceContactRoles extends DolibarrTriggers $nb = 0; foreach($TContact as $infos) { - // Gestion du cas spécifique de la création de propale avec sélection du contact, cela créé un bug si le contact est ajouté par le module contactdefault $res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']); if($res > 0) $nb++; } From ee931d0f25dfe42fa9138b180815a9beca1f7ceb Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:53:23 +0200 Subject: [PATCH 08/77] fix travis --- .../interface_90_modSociete_ContactRoles.class.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index 8d2418a8a94..e9bf9d38a50 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -53,14 +53,8 @@ class InterfaceContactRoles extends DolibarrTriggers * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) * * Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database: - * $object->actiontypecode (translation action code: AC_OTH, ...) - * $object->actionmsg (note, long text) - * $object->actionmsg2 (label, short text) - * $object->sendtoid (id of contact or array of ids) - * $object->socid (id of thirdparty) - * $object->fk_project - * $object->fk_element - * $object->elementtype + * $object->socid or $object->fk_soc(id of thirdparty) + * $object->element (element type of object) * * @param string $action Event action code * @param Object $object Object @@ -113,5 +107,6 @@ class InterfaceContactRoles extends DolibarrTriggers } } } - } + return 0; + } } From ad92efaee14e8ad5e8523fd6064928ad917cee7a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 9 Sep 2019 14:58:29 +0200 Subject: [PATCH 09/77] add trans --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c4611836a51..04f45f8de4b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1004,3 +1004,4 @@ ContactDefault_project_task=Task ContactDefault_propal=Proposal ContactDefault_supplier_proposal=Supplier Proposal ContactDefault_ticketsup=Ticket +ContactAddedAutomatically=Contact added from contact thirdparty roles From a005408d8310d9435f53ca85d33a443cc95b937a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 23 Sep 2019 20:42:50 +0200 Subject: [PATCH 10/77] NEW Accountancy - Add an option to hide FAQ on index and add widget in area --- htdocs/accountancy/admin/index.php | 36 ++- .../class/accountingjournal.class.php | 2 +- .../accountancy/class/bookkeeping.class.php | 16 +- htdocs/accountancy/index.php | 289 +++++++++++------- htdocs/admin/boxes.php | 2 +- .../box_accountancy_last_manual_entries.php | 183 +++++++++++ .../box_accountancy_suspense_account.php | 135 ++++++++ htdocs/core/class/html.formother.class.php | 4 +- htdocs/core/class/infobox.class.php | 10 +- htdocs/core/modules/modAccounting.class.php | 5 +- htdocs/langs/en_US/accountancy.lang | 6 +- htdocs/langs/en_US/boxes.lang | 9 +- 12 files changed, 557 insertions(+), 140 deletions(-) create mode 100644 htdocs/core/boxes/box_accountancy_last_manual_entries.php create mode 100644 htdocs/core/boxes/box_accountancy_suspense_account.php diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index b842c8115da..e11355b1f50 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -83,6 +83,19 @@ if ($action == 'update') { } // TO DO Mutualize code for yes/no constants +if ($action == 'setdisablefaq') { + $setdisablefaq = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_FAQ", $setdisablefaq, 'yesno', 0, '', $conf->entity); + if (! $res > 0) + $error ++; + + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); @@ -212,6 +225,19 @@ if (! empty($user->admin)) { // TO DO Mutualize code for yes/no constants print ''; + print '' . $langs->trans("ACCOUNTING_DISABLE_FAQ") . ''; + if (! empty($conf->global->ACCOUNTING_DISABLE_FAQ)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } + print ''; + + print ''; print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { print ''; @@ -224,7 +250,7 @@ if (! empty($user->admin)) } print ''; - print ''; + print ''; print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . ''; if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { print ''; @@ -237,7 +263,7 @@ if (! empty($user->admin)) } print ''; - print ''; + print ''; print '' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . ''; if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { print ''; @@ -250,7 +276,7 @@ if (! empty($user->admin)) } print ''; - print ''; + print ''; print '' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . ''; if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print ''; @@ -263,7 +289,7 @@ if (! empty($user->admin)) } print ''; - print ''; + print ''; print '' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . ''; if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print ''; @@ -276,7 +302,7 @@ if (! empty($user->admin)) } print ''; - print ''; + print ''; print '' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . ''; if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { print ''; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index e8caaab8a89..5f44c0d32b7 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -235,7 +235,7 @@ class AccountingJournal extends CommonObject { if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAccoutingJournal"); + $label=$langs->trans("ShowAccountingJournal"); $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 9e59093b885..f442730355c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -406,7 +406,7 @@ class BookKeeping extends CommonObject } /** - * Return a link to the object card (with optionaly the picto) + * Return a link to the object card (with optionally the picto) * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param string $option On what the link point to ('nolink', ...) @@ -1309,7 +1309,7 @@ class BookKeeping extends CommonObject } /** - * Delete bookkepping by importkey + * Delete bookkeeping by importkey * * @param string $importkey Import key * @return int Result @@ -1337,7 +1337,7 @@ class BookKeeping extends CommonObject } /** - * Delete bookkepping by year + * Delete bookkeeping by year * * @param string $delyear Year to delete * @param string $journal Journal to delete @@ -1379,7 +1379,7 @@ class BookKeeping extends CommonObject } /** - * Delete bookkepping by piece number + * Delete bookkeeping by piece number * * @param int $piecenum Piecenum to delete * @return int Result @@ -1624,12 +1624,12 @@ class BookKeeping extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Export bookkeping + * Export bookkeeping * * @param string $model Model * @return int Result */ - public function export_bookkeping($model = 'ebp') + public function export_bookkeeping($model = 'ebp') { // phpcs:enable global $conf; @@ -1641,7 +1641,7 @@ class BookKeeping extends CommonObject $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; - dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); + dol_syslog(get_class($this) . "::export_bookkeeping", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1679,7 +1679,7 @@ class BookKeeping extends CommonObject return $num; } else { $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::export_bookkeping " . $this->error, LOG_ERR); + dol_syslog(get_class($this) . "::export_bookkeeping " . $this->error, LOG_ERR); return - 1; } } diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 0bede00d86d..d3ea4ccfb24 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -26,6 +26,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict")); @@ -41,8 +42,17 @@ $hookmanager->initHooks(array('accountancyindex')); * Actions */ -// None +if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone=GETPOST('areacode', 'aZ09'); + $userid=GETPOST('userid', 'int'); + $boxorder=GETPOST('boxorder', 'aZ09'); + $boxorder.=GETPOST('boxcombo', 'aZ09'); + $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); +} /* * View @@ -50,134 +60,185 @@ $hookmanager->initHooks(array('accountancyindex')); llxHeader('', $langs->trans("AccountancyArea")); -print load_fiche_titre($langs->trans("AccountancyArea"), '', 'title_accountancy'); -//dol_fiche_head(); - -$step = 0; - if ($conf->accounting->enabled) { - print ''.$langs->trans("AccountancyAreaDescIntro")."
    \n"; - print "
    \n";print "
    \n"; + $resultboxes=FormOther::getBoxesArea($user, "1"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; - print '
    '; - print "
    \n"; + print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy'); - // STEPS - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '
    '.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''.''); - print "
    \n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''.''); - print "
    \n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''.''); - print "
    \n"; + // FAQ + if (empty($conf->global->ACCOUNTING_DISABLE_FAQ)) { + $step = 0; - print "
    \n"; - print $langs->trans("AccountancyAreaDescActionOnceBis"); - print "
    \n"; - print "
    \n"; + print '' . $langs->trans("AccountancyAreaDescIntro") . "
    \n"; + print "
    \n"; + print "
    \n"; + print load_fiche_titre(' ' . $langs->trans("AccountancyAreaDescActionOnce"), + '', '') . "\n"; + print '
    '; + print "
    \n"; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''.''); - print "
    \n"; - - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").''.'')."\n"; - print "
    \n"; - - $step++; - $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''.''; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); - print "
    \n"; - if (! empty($conf->tax->enabled)) - { - $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''.''; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); - print "
    \n"; - } - /*if (! empty($conf->salaries->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - // htdocs/admin/salaries.php - print "
    \n"; - print "
    \n"; - }*/ - if (! empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''.''); - print "
    \n"; - } - /* - if (! empty($conf->loan->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - } - if (! empty($conf->don->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - } - if (! empty($conf->adherents->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - }*/ - - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''.''); - print "
    \n"; - - - print '
    '; - - // Step A - E - - print "
    \n"; - print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); - print '
    '; - print "
    \n"; - $step = 0; - - $langs->loadLangs(array('bills', 'trips')); - - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").''.'')."\n"; - print "
    \n"; - - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").''.'')."\n"; - print "
    \n"; - - if (! empty($conf->expensereport->enabled) || ! empty($conf->deplacement->enabled)) - { + // STEPS $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").''.'')."\n"; - print "
    \n"; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescJournalSetup", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("AccountingJournals") . '' . ''); + print "
    \n"; + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescChartModel", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("Pcg_version") . '' . ''); + print "
    \n"; + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescChart", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("Chartofaccounts") . '' . ''); + print "
    \n"; + + print "
    \n"; + print $langs->trans("AccountancyAreaDescActionOnceBis"); + print "
    \n"; + print "
    \n"; + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescDefault", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . '' . ''); + print "
    \n"; + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBank", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuBankAccounts") . '' . '') . "\n"; + print "
    \n"; + + $step++; + $textlink = '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuVatAccounts") . '' . ''; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescVat", $step, $textlink); + print "
    \n"; + if (!empty($conf->tax->enabled)) { + $textlink = '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuTaxAccounts") . '' . ''; + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescContrib", $step, $textlink); + print "
    \n"; + } + /*if (! empty($conf->salaries->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + // htdocs/admin/salaries.php + print "
    \n"; + print "
    \n"; + }*/ + if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. + { + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescExpenseReport", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuExpenseReportAccounts") . '' . ''); + print "
    \n"; + } + /* + if (! empty($conf->loan->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + } + if (! empty($conf->don->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + } + if (! empty($conf->adherents->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + }*/ + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescProd", $step, + '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("ProductsBinding") . '' . ''); + print "
    \n"; + + print '
    '; + + // Step A - E + + print "
    \n"; + print load_fiche_titre(' ' . $langs->trans("AccountancyAreaDescActionFreq"), + '', ''); + print '
    '; + print "
    \n"; + $step = 0; + + $langs->loadLangs(array('bills', 'trips')); + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), + $langs->transnoentitiesnoconv("BillsCustomers"), + '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("CustomersVentilation") . '' . '') . "\n"; + print "
    \n"; + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), + $langs->transnoentitiesnoconv("BillsSuppliers"), + '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("SuppliersVentilation") . '' . '') . "\n"; + print "
    \n"; + + if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) { + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), + $langs->transnoentitiesnoconv("ExpenseReports"), + '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("ExpenseReportsVentilation") . '' . '') . "\n"; + print "
    \n"; + } + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), + $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("RegistrationInAccounting"), + $langs->transnoentitiesnoconv("WriteBookKeeping")) . "\n"; + print "
    \n"; + + $step++; + print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step)) . "
    \n"; + print "
    \n"; } - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; - print "
    \n"; + print '
    '; - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."
    \n"; - print "
    \n"; + print '
    '; + + /* + * Show boxes + */ + $boxlist.='
    '; + + $boxlist.='
    '; + if(!empty($nbworkboardcount)) + { + $boxlist.=$boxwork; + } + + $boxlist.=$resultboxes['boxlista']; + + $boxlist.= '
    '; + + $boxlist.= '
    '; + + $boxlist.=$boxstat; + $boxlist.=$resultboxes['boxlistb']; + + $boxlist.= '
    '; + $boxlist.= "\n"; + + $boxlist.='
    '; + + + print $boxlist; + + print '
    '; } else { print $langs->trans("Module10Desc")."
    \n"; } -//dol_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 2e81a2c6dad..da400cf6764 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'boxes')); +$langs->loadLangs(array('admin', 'boxes', 'accountancy')); if (! $user->admin) accessforbidden(); diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php new file mode 100644 index 00000000000..d87f2f6cc50 --- /dev/null +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -0,0 +1,183 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_accountancy_last_manual_entries.php + * \ingroup Accountancy + * \brief Module to generated widget of last manual entries + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last manual entries + */ +class box_accountancy_last_manual_entries extends ModeleBoxes +{ + public $boxcode="accountancy_last_manual_entries"; + public $boximg="object_invoice"; + public $boxlabel="BoxLastManualEntries"; + public $depends = array("accounting"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->accounting->mouvements->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $db, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + + $bookkeepingstatic = new BookKeeping($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); + + if ($user->rights->accounting->mouvements->lire) + { + $sql = "SELECT DISTINCT b.piece_num"; + $sql.= ", b.doc_date as date_movement"; + $sql.= ", b.label_operation"; + $sql.= ", b.montant"; + $sql.= ", b.code_journal"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql.= " WHERE b.fk_doc = 0"; + $sql.= " AND b.entity = ".$conf->entity; + $sql.= " ORDER BY b.piece_num DESC "; + $sql.= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $db->fetch_object($result); + $date = $db->jdate($objp->date_movement); + $journal = $objp->code_journal; + $label = $objp->label_operation; + $amount = $objp->montant; + + $bookkeepingstatic->id = $objp->id; + $bookkeepingstatic->piece_num = $objp->piece_num; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $bookkeepingstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($date, 'day'), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="center"', + 'text' => $journal, + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $label, + 'asis' => 1, + ); + + /* + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); + */ + + $this->info_box_contents[$line][] = array( + 'td' => 'class="nowrap right"', + 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedManualEntries")); + + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php new file mode 100644 index 00000000000..8f2851bc823 --- /dev/null +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -0,0 +1,135 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_accountancy_suspense_account.php + * \ingroup Accountancy + * \brief Module to generated widget of suspense account + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show suspense account + */ +class box_accountancy_suspense_account extends ModeleBoxes +{ + public $boxcode="accountancy_suspense_account"; + public $boximg="object_invoice"; + public $boxlabel="BoxSuspenseAccount"; + public $depends = array("accounting"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->accounting->mouvements->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox() + { + global $user, $langs, $db, $conf; + + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; + + $bookkeepingstatic = new BookKeeping($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); + + if ($user->rights->accounting->mouvements->lire) + { + $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE; + if (! empty($suspenseAccount) && $suspenseAccount > 0) + { + $sql = "SELECT COUNT(*) as nb_suspense_account"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as b"; + $sql .= " WHERE b.numero_compte = ". $suspenseAccount; + $sql .= " AND b.entity = " . $conf->entity; + + $result = $db->query($sql); + if ($result) + { + $obj=$db->fetch_object($result); + $nbSuspenseAccount = $obj->nb_suspense_account; + } + + $this->info_box_contents[0][0] = array( + 'td' => '', + 'text' => $langs->trans("NumberOfLinesInSuspenseAccount") . ':' + ); + + $this->info_box_contents[0][1] = array( + 'td' => 'class="right"', + 'text' => '' . $nbSuspenseAccount . '', + 'asis' => 1 + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("SuspenseAccountNotDefined") + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c6a138b2a02..01dfbb6e985 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -989,8 +989,8 @@ class FormOther * Class 'Form' must be known. * * @param User $user Object User - * @param String $areacode Code of area for pages ('0'=value for Home page) - * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) + * @param String $areacode Code of area for pages - 0 = Home page / 1 = Accountancy page + * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) */ public static function getBoxesArea($user, $areacode) { diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 1138e3a69ad..f2257f8f894 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -28,13 +28,13 @@ class InfoBox { /** - * Name of positions 0=Home, 1=... + * Name of positions 0=Home, 1=Accountancy, 2=xxx * * @return string[] Array with list of zones */ public static function getListOfPagesForBoxes() { - return array(0=>'Home'); + return array(0=>'Home',1=>'Accountancy'); } /** @@ -42,7 +42,7 @@ class InfoBox * * @param DoliDB $db Database handler * @param string $mode 'available' or 'activated' - * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) + * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for Accountancy, 2 for xxx, ...) * @param User|null $user Object user to filter * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @param int $includehidden Include also hidden boxes @@ -71,7 +71,7 @@ class InfoBox { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; } dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); @@ -113,7 +113,7 @@ class InfoBox // box properties $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); $box->id = (empty($obj->box_id) ? '' : $obj->box_id); - $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must staty '0' + $box->position = ($obj->position == '' ? '' : $obj->position); // '0' must stay '0' $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile= $relsourcefile; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 12f95053dc0..48e6e7df400 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -162,7 +162,10 @@ class modAccounting extends DolibarrModules $this->module_parts = array(); // Boxes - $this->boxes = array(); + $this->boxes = array( + 0=>array('file'=>'box_accountancy_last_manual_entries.php', 'enabledbydefaulton'=>'Accountancy'), + 1=>array('file'=>'box_accountancy_suspense_account.php', 'enabledbydefaulton'=>'Accountancy') + ); // Permissions $this->rights_class = 'accounting'; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8e44c378ba6..ce056b1f981 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -1,4 +1,5 @@ -# Dolibarr language file - en_US - Accounting Expert +# Dolibarr language file - en_US - Accountancy (Double entries) +Accountancy=Accountancy Accounting=Accounting ACCOUNTING_EXPORT_SEPARATORCSV=Column separator for export file ACCOUNTING_EXPORT_DATE=Date format for export file @@ -133,6 +134,7 @@ NotVentilatedinAccount=Not bound to the accounting account XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account +ACCOUNTING_DISABLE_FAQ=Disable FAQ on accountancy area ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50) ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements @@ -264,7 +266,7 @@ CategoryDeleted=Category for the accounting account has been removed AccountingJournals=Accounting journals AccountingJournal=Accounting journal NewAccountingJournal=New accounting journal -ShowAccoutingJournal=Show accounting journal +ShowAccountingJournal=Show accounting journal NatureOfJournal=Nature of Journal AccountingJournalType1=Miscellaneous operations AccountingJournalType2=Sales diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b1ab8e41fbc..eedc75e7ca0 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -84,4 +84,11 @@ ForProposals=Proposals LastXMonthRolling=The latest %s month rolling ChooseBoxToAdd=Add widget to your dashboard BoxAdded=Widget was added in your dashboard -BoxTitleUserBirthdaysOfMonth=Birthdays of this month \ No newline at end of file +BoxTitleUserBirthdaysOfMonth=Birthdays of this month +BoxLastManualEntries=Last manual entries in accountancy +BoxTitleLastManualEntries=%s last manual entries +NoRecordedManualEntries=No manual entries record in accountancy +BoxSuspenseAccount=Count accountancy operation with suspense account +BoxTitleSuspenseAccount=Number of unallocated lines +NumberOfLinesInSuspenseAccount=Number of line in suspense account +SuspenseAccountNotDefined=Suspense account isn't defined From e5268f98c2a4e3f715774402c06f8ad431daed34 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 23 Sep 2019 20:48:30 +0200 Subject: [PATCH 11/77] Correct Stickler --- htdocs/core/boxes/box_accountancy_suspense_account.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index 8f2851bc823..dd2d9a17695 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -66,7 +66,6 @@ class box_accountancy_suspense_account extends ModeleBoxes /** * Load data for box to show them later * - * @param int $max Maximum number of records to load * @return void */ public function loadBox() From 1b2558bb1f7002e837161d1f054042f1b05fe5cf Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 23 Sep 2019 21:43:11 +0200 Subject: [PATCH 12/77] typo --- .../core/boxes/box_accountancy_last_manual_entries.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index d87f2f6cc50..1f2b8d634d9 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ /** @@ -134,14 +134,6 @@ class box_accountancy_last_manual_entries extends ModeleBoxes 'asis' => 1, ); - /* - $this->info_box_contents[$line][] = array( - 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', - 'text' => $societestatic->getNomUrl(1), - 'asis' => 1, - ); - */ - $this->info_box_contents[$line][] = array( 'td' => 'class="nowrap right"', 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency), From f1d098adccc5b624c27e578cb263275ac74ca76b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 27 Sep 2019 20:15:11 +0200 Subject: [PATCH 13/77] fix remove error dispplaying --- htdocs/contact/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5861cc71d38..e4fc61f2e54 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -475,6 +475,9 @@ else // Si edition contact deja existant $object = new Contact($db); $res=$object->fetch($id, $user); + if ($res<0) { + setEventMessage($this->error,'errors'); + } // Show tabs $head = contact_prepare_head($object); From f91513937af5ee563fae27e0e1f4d4526880d0f5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 30 Sep 2019 21:37:20 +0200 Subject: [PATCH 14/77] Remove option to hide FAQ --- htdocs/accountancy/admin/index.php | 29 +---------------------------- htdocs/accountancy/index.php | 2 +- htdocs/langs/en_US/accountancy.lang | 1 - 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index e11355b1f50..7f4ce79e165 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -82,20 +82,6 @@ if ($action == 'update') { } } -// TO DO Mutualize code for yes/no constants -if ($action == 'setdisablefaq') { - $setdisablefaq = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_FAQ", $setdisablefaq, 'yesno', 0, '', $conf->entity); - if (! $res > 0) - $error ++; - - if (! $error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'mesgs'); - } -} - if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); @@ -225,20 +211,7 @@ if (! empty($user->admin)) { // TO DO Mutualize code for yes/no constants print ''; - print '' . $langs->trans("ACCOUNTING_DISABLE_FAQ") . ''; - if (! empty($conf->global->ACCOUNTING_DISABLE_FAQ)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; + print '' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . ''; if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index d3ea4ccfb24..e5189a11540 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -64,7 +64,7 @@ if ($conf->accounting->enabled) { $resultboxes=FormOther::getBoxesArea($user, "1"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy'); + print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy'); // FAQ if (empty($conf->global->ACCOUNTING_DISABLE_FAQ)) { diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index ce056b1f981..38b0798d47d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -134,7 +134,6 @@ NotVentilatedinAccount=Not bound to the accounting account XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account -ACCOUNTING_DISABLE_FAQ=Disable FAQ on accountancy area ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50) ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements From 4d5547636d16da36b6e947205f2db6db1162958b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Oct 2019 08:43:35 +0200 Subject: [PATCH 15/77] Accountancy FAQ - Move to toggle() --- htdocs/accountancy/index.php | 334 ++++++++++++++-------------- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 170 insertions(+), 165 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index e5189a11540..8076264655b 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -1,7 +1,7 @@ - * Copyright (C) 2016-2019 Alexandre Spangaro - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016-2019 Alexandre Spangaro + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,14 +44,14 @@ $hookmanager->initHooks(array('accountancyindex')); if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) { - require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone=GETPOST('areacode', 'aZ09'); - $userid=GETPOST('userid', 'int'); - $boxorder=GETPOST('boxorder', 'aZ09'); - $boxorder.=GETPOST('boxcombo', 'aZ09'); + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone=GETPOST('areacode', 'aZ09'); + $userid=GETPOST('userid', 'int'); + $boxorder=GETPOST('boxorder', 'aZ09'); + $boxorder.=GETPOST('boxcombo', 'aZ09'); - $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); - if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); + $result=InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); } /* @@ -62,181 +62,185 @@ llxHeader('', $langs->trans("AccountancyArea")); if ($conf->accounting->enabled) { - $resultboxes=FormOther::getBoxesArea($user, "1"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $step = 0; - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy'); + $resultboxes=FormOther::getBoxesArea($user, "1"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - // FAQ - if (empty($conf->global->ACCOUNTING_DISABLE_FAQ)) { - $step = 0; + print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy'); - print '' . $langs->trans("AccountancyAreaDescIntro") . "
    \n"; - print "
    \n"; - print "
    \n"; - print load_fiche_titre(' ' . $langs->trans("AccountancyAreaDescActionOnce"), - '', '') . "\n"; - print '
    '; - print "
    \n"; + print '
    '; - // STEPS - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescJournalSetup", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("AccountingJournals") . '' . ''); - print "
    \n"; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescChartModel", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("Pcg_version") . '' . ''); - print "
    \n"; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescChart", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("Chartofaccounts") . '' . ''); - print "
    \n"; + print ''; - print "
    \n"; - print $langs->trans("AccountancyAreaDescActionOnceBis"); - print "
    \n"; - print "
    \n"; + print '
    '; // hideobject is to start hidden + print "
    \n"; + print ''.$langs->trans("AccountancyAreaDescIntro")."
    \n"; + print "
    \n";print "
    \n"; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescDefault", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . '' . ''); - print "
    \n"; + print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; + print '
    '; + print "
    \n"; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBank", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuBankAccounts") . '' . '') . "\n"; - print "
    \n"; + // STEPS + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").''.''); + print "
    \n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").''.''); + print "
    \n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").''.''); + print "
    \n"; - $step++; - $textlink = '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuVatAccounts") . '' . ''; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescVat", $step, $textlink); - print "
    \n"; - if (!empty($conf->tax->enabled)) { - $textlink = '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuTaxAccounts") . '' . ''; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescContrib", $step, $textlink); - print "
    \n"; - } - /*if (! empty($conf->salaries->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - // htdocs/admin/salaries.php - print "
    \n"; - print "
    \n"; - }*/ - if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. - { - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescExpenseReport", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("MenuExpenseReportAccounts") . '' . ''); - print "
    \n"; - } - /* - if (! empty($conf->loan->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - } - if (! empty($conf->don->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - } - if (! empty($conf->adherents->enabled)) - { - $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); - print "
    \n"; - }*/ + print "
    \n"; + print $langs->trans("AccountancyAreaDescActionOnceBis"); + print "
    \n"; + print "
    \n"; - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescProd", $step, - '' . '' . $langs->transnoentitiesnoconv("Setup") . ' - ' . $langs->transnoentitiesnoconv("ProductsBinding") . '' . ''); - print "
    \n"; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''.''); + print "
    \n"; - print '
    '; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").''.'')."\n"; + print "
    \n"; - // Step A - E - - print "
    \n"; - print load_fiche_titre(' ' . $langs->trans("AccountancyAreaDescActionFreq"), - '', ''); - print '
    '; - print "
    \n"; - $step = 0; - - $langs->loadLangs(array('bills', 'trips')); - - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), - $langs->transnoentitiesnoconv("BillsCustomers"), - '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("CustomersVentilation") . '' . '') . "\n"; - print "
    \n"; - - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), - $langs->transnoentitiesnoconv("BillsSuppliers"), - '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("SuppliersVentilation") . '' . '') . "\n"; - print "
    \n"; - - if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) { - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescBind", chr(64 + $step), - $langs->transnoentitiesnoconv("ExpenseReports"), - '' . '' . $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("ExpenseReportsVentilation") . '' . '') . "\n"; - print "
    \n"; - } - - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), - $langs->transnoentitiesnoconv("TransferInAccounting") . ' - ' . $langs->transnoentitiesnoconv("RegistrationInAccounting"), - $langs->transnoentitiesnoconv("WriteBookKeeping")) . "\n"; - print "
    \n"; - - $step++; - print img_picto('', 'puce') . ' ' . $langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step)) . "
    \n"; - print "
    \n"; - } - - print '
    '; - - print '
    '; - - /* - * Show boxes - */ - $boxlist.='
    '; - - $boxlist.='
    '; - if(!empty($nbworkboardcount)) + $step++; + $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''.''; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); + print "
    \n"; + if (! empty($conf->tax->enabled)) { - $boxlist.=$boxwork; + $textlink = ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''.''; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); + print "
    \n"; + } + /*if (! empty($conf->salaries->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSal", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + // htdocs/admin/salaries.php + print "
    \n"; + print "
    \n"; + }*/ + if (! empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''.''); + print "
    \n"; + } + /* + if (! empty($conf->loan->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuSpecialExpenses").' - '.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + } + if (! empty($conf->don->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + } + if (! empty($conf->adherents->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescSubscription", $step, ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print "
    \n"; + }*/ + + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").''.''); + print "
    \n"; + + + print '
    '; + + // Step A - E + + print "
    \n"; + print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); + print '
    '; + print "
    \n"; + $step = 0; + + $langs->loadLangs(array('bills', 'trips')); + + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").''.'')."\n"; + print "
    \n"; + + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").''.'')."\n"; + print "
    \n"; + + if (! empty($conf->expensereport->enabled) || ! empty($conf->deplacement->enabled)) + { + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.''.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").''.'')."\n"; + print "
    \n"; } - $boxlist.=$resultboxes['boxlista']; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; + print "
    \n"; - $boxlist.= '
    '; - - $boxlist.= '
    '; - - $boxlist.=$boxstat; - $boxlist.=$resultboxes['boxlistb']; - - $boxlist.= '
    '; - $boxlist.= "\n"; - - $boxlist.='
    '; - - - print $boxlist; + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."
    \n"; + print "
    \n"; print '
    '; + + print '
    '; + + print '
    '; + + /* + * Show boxes + */ + $boxlist.='
    '; + + $boxlist.='
    '; + if(!empty($nbworkboardcount)) + { + $boxlist.=$boxwork; + } + + $boxlist.=$resultboxes['boxlista']; + + $boxlist.= '
    '; + + $boxlist.= '
    '; + + $boxlist.=$boxstat; + $boxlist.=$resultboxes['boxlistb']; + + $boxlist.= '
    '; + $boxlist.= "\n"; + + $boxlist.='
    '; + + + print $boxlist; + + print '
    '; } else { + print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); + print $langs->trans("Module10Desc")."
    \n"; } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 38b0798d47d..30b060fb4d3 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -257,6 +257,7 @@ ListOfProductsWithoutAccountingAccount=List of products not bound to any account ChangeBinding=Change the binding Accounted=Accounted in ledger NotYetAccounted=Not yet accounted in ledger +ShowFAQ=Show FAQ ## Admin ApplyMassCategories=Apply mass categories From 6d4f3f308e524fecebdaeea11d4871989b558ad6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 2 Oct 2019 08:43:40 +0200 Subject: [PATCH 16/77] NEW expense request and holiday validator fields --- htdocs/expensereport/card.php | 2 +- htdocs/holiday/card.php | 2 +- htdocs/user/card.php | 82 +++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 140d3dcc612..4df08b46004 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1492,7 +1492,7 @@ if ($action == 'create') if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport"); else { - $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + $defaultselectuser=!empty($user->fk_user_expense_validator) ? $user->fk_user_expense_validator : $user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser=GETPOST('fk_user_validator', 'int'); $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE))?0:1), $include_users); diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index fdb9a498778..0e97ef5857d 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1092,7 +1092,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); else { - $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + $defaultselectuser=!empty($user->fk_user_holiday_validator) ? $user->fk_user_holiday_validator : $user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users if (! empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('valideur', 'int') > 0) $defaultselectuser=GETPOST('valideur', 'int'); $s=$form->select_dolusers($defaultselectuser, "valideur", 1, "", 0, $include_users); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d47a8bf4f7d..d5e6776a223 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -223,6 +223,8 @@ if (empty($reshook)) { $object->note = GETPOST("note", 'none'); $object->ldap_sid = GETPOST("ldap_sid", 'alphanohtml'); $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0; + $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0; + $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0; $object->employee = GETPOST('employee', 'alphanohtml'); $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; @@ -376,6 +378,8 @@ if (empty($reshook)) { $object->accountancy_code = GETPOST("accountancy_code", 'alphanohtml'); $object->openid = GETPOST("openid", 'alphanohtml'); $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", 'int') : 0; + $object->fk_user_expense_validator = GETPOST("fk_user_expense_validator", 'int') > 0 ? GETPOST("fk_user_expense_validator", 'int') : 0; + $object->fk_user_holiday_validator = GETPOST("fk_user_holiday_validator", 'int') > 0 ? GETPOST("fk_user_holiday_validator", 'int') : 0; $object->employee = GETPOST('employee', 'int'); $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; @@ -965,6 +969,26 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print "\n"; + // Expense report validator + if(!empty($conf->expensereport->enabled)) + { + print ''.$langs->trans("UserExpenseValidator").''; + print ''; + print $form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300'); + print ''; + print "\n"; + } + + // Holiday request validator + if(!empty($conf->holiday->enabled)) + { + print '' . $langs->trans("UserHolidayValidator") . ''; + print ''; + print $form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300'); + print ''; + print "\n"; + } + print '
    '; @@ -1562,6 +1586,30 @@ else print ''; print "\n"; + // Expense report validator + print ''; + print ''; + print "\n"; + + // Holiday request validator + print ''; + print ''; + print "\n"; + // Position/Job print ''; print ''; @@ -2243,6 +2291,40 @@ else print ''; print "\n"; + // Expense report validator + print ''; + print ''; + print "\n"; + + // Holiday request validator + print ''; + print ''; + print "\n"; + print '
    '.$langs->trans("UserExpenseValidator").''; + if (empty($object->fk_user_expense_validator)) print $langs->trans("None"); + else { + $evuser=new User($db); + $evuser->fetch($object->fk_user_expense_validator); + print $evuser->getNomUrl(1); + } + print '
    '.$langs->trans("UserHolidayValidator").''; + if (empty($object->fk_user_holiday_validator)) print $langs->trans("None"); + else { + $hvuser=new User($db); + $hvuser->fetch($object->fk_user_holiday_validator); + print $hvuser->getNomUrl(1); + } + print '
    '.$langs->trans("PostOrFunction").''.$object->job.'
    '.$langs->trans("UserExpenseValidator").''; + if ($caneditfield) + { + print $form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + } + else + { + print ''; + $evuser=new User($db); + $evuser->fetch($object->fk_user_expense_validator); + print $evuser->getNomUrl(1); + } + print '
    '.$langs->trans("UserHolidayValidator").''; + if ($caneditfield) + { + print $form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $object->entity, 0, 0, '', 0, '', 'maxwidth300'); + } + else + { + print ''; + $hvuser=new User($db); + $hvuser->fetch($object->fk_user_holiday_validator); + print $hvuser->getNomUrl(1); + } + print '

    '; From 848acb6096c5b370da5890e4e13e959a1b704f2a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Oct 2019 08:49:33 +0200 Subject: [PATCH 17/77] Update index --- htdocs/core/modules/modAccounting.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index cd117bd4d96..a806cab111f 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -163,8 +163,8 @@ class modAccounting extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_accountancy_last_manual_entries.php', 'enabledbydefaulton'=>'Accountancy'), - 1=>array('file'=>'box_accountancy_suspense_account.php', 'enabledbydefaulton'=>'Accountancy') + 0=>array('file'=>'box_accountancy_last_manual_entries.php', 'enabledbydefaulton'=>'accountancyindex'), + 1=>array('file'=>'box_accountancy_suspense_account.php', 'enabledbydefaulton'=>'accountancyindex') ); // Permissions From 94179f712d33e8a8fc951fa25580a0c7bdf9f7ff Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 2 Oct 2019 08:58:25 +0200 Subject: [PATCH 18/77] Update areacode --- htdocs/accountancy/index.php | 2 +- htdocs/core/class/html.formother.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 25e9a1fecd3..36ebaf07c94 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -64,7 +64,7 @@ if ($conf->accounting->enabled) { $step = 0; - $resultboxes=FormOther::getBoxesArea($user, "1"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy'); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index e890a2e05e7..48db977255f 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -989,7 +989,7 @@ class FormOther * Class 'Form' must be known. * * @param User $user Object User - * @param String $areacode Code of area for pages - 0 = Home page / 1 = Accountancy page + * @param String $areacode Code of area for pages - 0 = Home page ... See getListOfPagesForBoxes() * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlista'=>, 'boxlistb'=>) */ public static function getBoxesArea($user, $areacode) From 8c9cee156590c001b9346de882f3ec9e75d182e0 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 Oct 2019 12:49:38 +0200 Subject: [PATCH 19/77] resolve conflict --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 5729270fe73..669c1936a50 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -920,7 +920,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $contactstatic->fields=array( 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOrFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), 'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>40), 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))), From eb40d51dda1f4b3d2f69d13926df0bd2c05940a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 18:32:23 +0200 Subject: [PATCH 20/77] Update dav.php --- htdocs/admin/dav.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index cb3f7ab2072..90b82421702 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -123,7 +123,9 @@ else { print ''; // Link -print ''; // Link -print ''; print ''; // Img of credit card print ''; } } - + print '
    '; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); - print $form->textwithpicto($langs->trans($key), $tooltiphelp); + $label = $langs->trans($key); + if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP"); + print $form->textwithpicto($label, $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { From fe0f1902095666302292aa1e204e51e7613e2194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 2 Oct 2019 18:49:05 +0200 Subject: [PATCH 21/77] Update dav.php --- htdocs/admin/dav.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 90b82421702..53971743b20 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -168,6 +168,9 @@ print "
    "; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +if ($_SERVER['HTTPS'] == 'on' || $_SERVER['REQUEST_SCHEME'] == 'https') { + $urlwithroot = str_replace('http://', 'https://', $urlwithroot); +} //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current From 9f2ac7cae308734c38e951b5d5a49e1d8ae84788 Mon Sep 17 00:00:00 2001 From: oscim Date: Thu, 3 Oct 2019 09:47:06 +0200 Subject: [PATCH 22/77] Fix error in triggers process If methode create_from_contact is called; In process this method containt call create methode, but trigger by action USER_CREATE is called twice. the call to the create method should not trigger triggers same for the create_from_members method --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 04ec5bf0698..30eb6f1cd27 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1298,7 +1298,7 @@ class User extends CommonObject $this->db->begin(); // Cree et positionne $this->id - $result=$this->create($user); + $result=$this->create($user, 1); if ($result > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; @@ -1371,7 +1371,7 @@ class User extends CommonObject $this->db->begin(); // Create and set $this->id - $result=$this->create($user); + $result=$this->create($user, 1); if ($result > 0) { $newpass=$this->setPassword($user, $this->pass); From d368bc1b6a6039dd4766426ef4f2eaee3f7ed443 Mon Sep 17 00:00:00 2001 From: oscim Date: Thu, 3 Oct 2019 15:58:40 +0200 Subject: [PATCH 23/77] Update user.class.php actually the create_from_member method does not require this change --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 30eb6f1cd27..57ded5e6c1c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1371,7 +1371,7 @@ class User extends CommonObject $this->db->begin(); // Create and set $this->id - $result=$this->create($user, 1); + $result=$this->create($user); if ($result > 0) { $newpass=$this->setPassword($user, $this->pass); From 02af9b8fa4638d993a1725155f8f941c5926b058 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Oct 2019 17:56:55 +0200 Subject: [PATCH 24/77] Update card.php --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 4df08b46004..7e51d059bf6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1492,7 +1492,7 @@ if ($action == 'create') if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateExpenseReport"); else { - $defaultselectuser=!empty($user->fk_user_expense_validator) ? $user->fk_user_expense_validator : $user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + $defaultselectuser=(empty($user->fk_user_expense_validator) ? $user->fk_user : $user->fk_user_expense_validator); // Will work only if supervisor has permission to approve so is inside include_users if (! empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('fk_user_validator', 'int') > 0) $defaultselectuser=GETPOST('fk_user_validator', 'int'); $s=$form->select_dolusers($defaultselectuser, "fk_user_validator", 1, "", ((empty($defaultselectuser) || empty($conf->global->EXPENSEREPORT_DEFAULT_VALIDATOR_UNCHANGEABLE))?0:1), $include_users); From 1f3e25005365ae4145764cebe8343da38bc02f34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Oct 2019 17:58:07 +0200 Subject: [PATCH 25/77] Update card.php --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 0e97ef5857d..90afdb18747 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1092,7 +1092,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); else { - $defaultselectuser=!empty($user->fk_user_holiday_validator) ? $user->fk_user_holiday_validator : $user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + $defaultselectuser=(empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); // Will work only if supervisor has permission to approve so is inside include_users if (! empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('valideur', 'int') > 0) $defaultselectuser=GETPOST('valideur', 'int'); $s=$form->select_dolusers($defaultselectuser, "valideur", 1, "", 0, $include_users); From ee42cd000e13a364b861897ef8afdd5afec13b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 3 Oct 2019 19:07:26 +0200 Subject: [PATCH 26/77] duration of fichinter rec --- htdocs/fichinter/class/fichinterrec.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 4fabf64be49..f88653e70eb 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -155,7 +155,7 @@ class FichinterRec extends Fichinter $sql.= ", ".($this->socid >0 ? $this->socid : 'null'); $sql.= ", ".$conf->entity; $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".(!empty($fichintsrc->duree)?$fichintsrc->duree:'0'); + $sql.= ", ".(!empty($fichintsrc->duration)?$fichintsrc->duration:'0'); $sql.= ", ".(!empty($this->description)?("'".$this->db->escape($this->description)."'"):"null"); $sql.= ", ".(!empty($fichintsrc->note_private)?("'".$this->db->escape($fichintsrc->note_private)."'"):"null"); $sql.= ", ".(!empty($fichintsrc->note_public)?("'".$this->db->escape($fichintsrc->note_public)."'"):"null"); @@ -271,6 +271,7 @@ class FichinterRec extends Fichinter $this->ref = $obj->titre; $this->description = $obj->description; $this->datec = $obj->datec; + $this->duration = $obj->duree; $this->socid = $obj->fk_soc; $this->statut = 0; $this->fk_project = $obj->fk_projet; From 14381927c73f3ef825c4bf7ce38c0e331d2501dd Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 3 Oct 2019 20:32:15 +0200 Subject: [PATCH 27/77] Fix Bank Fa-icon --- htdocs/compta/bank/list.php | 2 +- htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2bdea48487e..7cb6dbb6968 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -242,7 +242,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, $newcardbutton, '', $limit, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank', 0, $newcardbutton, '', $limit, 1); $topicmail="Information"; //$modelmail="subscription"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aa594a694cd..17388f1c32d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3045,9 +3045,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'address'=> 'address-book', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accountancy'=>'money-check-alt', 'project'=>'sitemap', 'hrm'=>'umbrella-beach', 'members'=>'users', 'ticket'=>'ticket-alt', 'generic'=>'folder-open', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', - 'bank'=>'bank', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', + 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', 'object_list'=>'list-alt','object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', - 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'bank', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' + 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' ); if ($pictowithouttext == 'switch_off') { From d0840b038f06d27f5960b71da9cb0c2cf4c27a0f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 3 Oct 2019 20:42:02 +0200 Subject: [PATCH 28/77] Remove constant MAIN_DISABLE_FONT_AWESOME_5 --- htdocs/core/lib/functions.lib.php | 37 +++++++++---------------------- htdocs/theme/eldy/global.inc.php | 4 ++-- htdocs/theme/md/style.css.php | 6 ++--- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 17388f1c32d..a8922ecfa6b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3036,8 +3036,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda' ) )) { - $fa='fa'; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fa='fas'; + $fa='fas'; $fakey = $pictowithouttext; $facolor = ''; $fasize = ''; @@ -3061,21 +3060,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext]; } elseif ($pictowithouttext == 'off') { - $fakey = 'fa-square-o'; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) - { - $fakey = 'fa-square'; - $fa='far'; - } + $fakey = 'fa-square'; + $fa='far'; $fasize = '1.3em'; } elseif ($pictowithouttext == 'on') { - $fakey = 'fa-check-square-o'; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) - { - $fakey = 'fa-check-square'; - $fa='far'; - } + $fakey = 'fa-check-square'; + $fa='far'; $fasize = '1.3em'; } elseif ($pictowithouttext == 'bank') { @@ -3088,12 +3079,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } elseif ($pictowithouttext == 'edit') { $facolor = '#444'; - $fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext]; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fakey = 'fa-pencil-alt'; + $fakey = 'fa-pencil-alt'; } elseif ($pictowithouttext == 'grip_title' || $pictowithouttext == 'grip') { - $fakey = 'fa-arrows'; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fakey = 'fa-arrows-alt'; + $fakey = 'fa-arrows-alt'; } elseif ($pictowithouttext == 'listlight') { $fakey = 'fa-download'; @@ -3110,11 +3099,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $facolor = '#444'; } elseif ($pictowithouttext == 'note') { - $fakey = 'fa-sticky-note-o'; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) - { - $fakey = 'fa-sticky-note'; $fa = 'far'; - } + $fakey = 'fa-sticky-note'; + $fa = 'far'; $facolor = '#999'; $marginleftonlyshort=1; } @@ -3129,9 +3115,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $marginleftonlyshort = 1; } elseif ($pictowithouttext == 'sign-out') { - $fakey = 'fa-sign-out'; + $fakey = 'fa-sign-out-alt'; $marginleftonlyshort=0; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fakey = 'fa-sign-out-alt'; } elseif ($pictowithouttext == 'unlink') { $fakey = 'fa-chain-broken'; @@ -3150,7 +3135,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } elseif (in_array($pictowithouttext, array('skype', 'twitter', 'facebook', 'linkedin'))) { $fakey = 'fa-'.$pictowithouttext; - if (empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) $fa = 'fab'; + $fa = 'fab'; } // Img for type of views elseif (in_array($pictowithouttext, array('object_list', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser'))) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 98bfddc196d..904f6a197d5 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1660,7 +1660,7 @@ a.tmenuimage:hover{ /* Do not load menu img for other if hidden to save bandwidth */ - global->MAIN_DISABLE_FONT_AWESOME_5)) { ?> + div.mainmenu.home{ @@ -1794,7 +1794,7 @@ a.tmenuimage:hover{ // Img file not found if (! $found) { - if (! defined('DISABLE_FONT_AWSOME') && empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) { + if (! defined('DISABLE_FONT_AWSOME')) { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; print 'div.mainmenu.'.$val.'::before { content: "\f249"; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ec1f04ab9db..dcbbbd1cf4f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1786,7 +1786,7 @@ div.mainmenu { /* Do not load menu img if hidden to save bandwidth */ - global->MAIN_DISABLE_FONT_AWESOME_5)) { ?> + @@ -1926,7 +1926,7 @@ foreach($mainmenuusedarray as $val) // Img file not found if (! $found) { - if (! defined('DISABLE_FONT_AWSOME') && empty($conf->global->MAIN_DISABLE_FONT_AWESOME_5)) { + if (! defined('DISABLE_FONT_AWSOME')) { print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; print 'div.mainmenu.'.$val.'::before { content: "\f249"; @@ -5805,7 +5805,7 @@ border-top-right-radius: 6px; -global->MAIN_DISABLE_FONT_AWESOME_5)) { ?> + Date: Thu, 3 Oct 2019 21:00:59 +0200 Subject: [PATCH 29/77] Add bookmark fa-icon --- htdocs/core/boxes/box_bookmarks.php | 6 +++--- htdocs/core/lib/functions.lib.php | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 5d4f51840fa..eec82f0e091 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -29,7 +29,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_bookmarks extends ModeleBoxes { public $boxcode="bookmarks"; - public $boximg="object_bookmark"; + public $boximg="bookmark"; public $boxlabel="BoxMyLastBookmarks"; public $depends = array("bookmark"); @@ -77,12 +77,12 @@ class box_bookmarks extends ModeleBoxes 'sublink' => DOL_URL_ROOT.'/bookmarks/list.php', ); if ($user->rights->bookmark->creer) { - $this->info_box_head['subpicto']='object_bookmark'; + $this->info_box_head['subpicto']='bookmark'; $this->info_box_head['subtext']=$langs->trans("BookmarksManagement"); } else { - $this->info_box_head['subpicto']='object_bookmark'; + $this->info_box_head['subpicto']='bookmark'; $this->info_box_head['subtext']=$langs->trans("ListOfBookmark"); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a8922ecfa6b..943c5778dce 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3026,7 +3026,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', - 'address', 'bank', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note', + 'address', 'bank', 'building', 'cash-register', 'close_title', 'cubes', 'delete', 'edit', 'ellipsis-h', 'bookmark', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'note', 'object_list','object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'note', 'setup', 'sign-out', 'split', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'wrench', @@ -3043,7 +3043,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $arrayconvpictotofa = array( 'address'=> 'address-book', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accountancy'=>'money-check-alt', 'project'=>'sitemap', 'hrm'=>'umbrella-beach', 'members'=>'users', 'ticket'=>'ticket-alt', 'generic'=>'folder-open', - 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', + 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'bookmark'=>'star', 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', 'object_list'=>'list-alt','object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' @@ -3084,6 +3084,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithouttext == 'grip_title' || $pictowithouttext == 'grip') { $fakey = 'fa-arrows-alt'; } + elseif ($pictowithouttext == 'bookmark') { + $fakey = 'fa-'.$arrayconvpictotofa[$pictowithouttext]; + $fa='far'; + } elseif ($pictowithouttext == 'listlight') { $fakey = 'fa-download'; $facolor = '#999'; From edc4dc3727dd0fed9e04e17287fe54ca6bae67e1 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:20:07 +0200 Subject: [PATCH 30/77] Fix project libStatus to use new dolGetStatus --- htdocs/projet/class/project.class.php | 51 ++++++++------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 027fe6503b2..2382f93c17a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -942,48 +942,27 @@ class Project extends CommonObject /** * Renvoi status label for a status * - * @param int $statut id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $status id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - public function LibStatut($statut, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; - if ($mode == 0) { - return $langs->trans($this->statuts_long[$statut]); - } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$statut]); - } elseif ($mode == 2) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_short[$statut]); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_short[$statut]); - elseif ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); - } elseif ($mode == 3) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); - elseif ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); - } elseif ($mode == 4) { - if ($statut == 0) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut0') . ' ' . $langs->trans($this->statuts_long[$statut]); - elseif ($statut == 1) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut4') . ' ' . $langs->trans($this->statuts_long[$statut]); - if ($statut == 2) - return img_picto($langs->trans($this->statuts_long[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_long[$statut]); - } elseif ($mode == 5) { - if ($statut == 0) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut0'); - elseif ($statut == 1) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut4'); - elseif ($statut == 2) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_long[$statut]), 'statut6'); + $statustrans = array( + 0 => 'status0', + 1 => 'status4', + 2 => 'status6', + ); + + $statusClass = 'status0'; + if(!empty($statustrans[$status])){ + $statusClass = $statustrans[$status]; } + + return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); + } /** From 77f666a23695c441d79334e6e3678c851089693d Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:28:11 +0200 Subject: [PATCH 31/77] Fix dolGetStatus param --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aa594a694cd..7b617471fca 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8164,13 +8164,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; if ($displayMode == 3) { - $return = dolGetBadge($statusLabel, '', $statusType, 'dot'); + $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url); } elseif ($displayMode === 5) { - $return = dolGetBadge($statusLabelShort, $html, $statusType); + $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url); } else { - $return = dolGetBadge($statusLabel, $html, $statusType); + $return = dolGetBadge($statusLabel, $html, $statusType, '', $url); } } From ddadff5731fe7842154c2dacac56095e60525969 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 3 Oct 2019 21:32:55 +0200 Subject: [PATCH 32/77] Add globe fa-icon --- htdocs/adherents/admin/website.php | 2 +- htdocs/admin/agenda_xcal.php | 6 +++--- htdocs/admin/dav.php | 4 ++-- htdocs/admin/translation.php | 2 +- htdocs/api/admin/explorer.php | 4 ++-- htdocs/api/admin/index.php | 4 ++-- htdocs/core/class/html.formfile.class.php | 4 ++-- htdocs/core/lib/cron.lib.php | 4 ++-- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/payments.lib.php | 2 +- htdocs/core/lib/signature.lib.php | 2 +- htdocs/core/tpl/onlinepaymentlinks.tpl.php | 12 ++++++------ htdocs/ecm/file_card.php | 4 ++-- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/results.php | 2 +- htdocs/paypal/lib/paypal.lib.php | 2 +- htdocs/societe/paymentmodes.php | 12 ++++++------ htdocs/stripe/admin/stripe.php | 4 ++-- htdocs/stripe/charge.php | 4 ++-- htdocs/stripe/lib/stripe.lib.php | 2 +- htdocs/stripe/payout.php | 2 +- htdocs/stripe/transaction.php | 2 +- htdocs/webservices/admin/index.php | 4 ++-- htdocs/website/index.php | 2 +- 24 files changed, 46 insertions(+), 46 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 47bd51bdc98..ead5e767243 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -225,7 +225,7 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print '
    '; //print $langs->trans('FollowingLinksArePublic').'
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':
    '; + print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').':
    '; if ($conf->multicompany->enabled) { $entity_qr='?entity='.$conf->entity; } else { diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 65074cbe8f1..f3c16941ebc 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -161,13 +161,13 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain // Show message $message=''; $urlvcal=''.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').''; -$message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); +$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); $message.='
    '; $urlical=''.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').''; -$message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); +$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); $message.='
    '; $urlrss=''.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').''; -$message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport", 'rss', $urlrss); +$message.=img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'rss', $urlrss); $message.='
    '; $message.='
    '; print $message; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index cb3f7ab2072..778f79ff4ce 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -172,13 +172,13 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain // Show message $message=''; $url=''.$urlwithroot.'/dav/fileserver.php'; -$message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebDavServer", 'WebDAV', $url); +$message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV', $url); $message.='
    '; if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { $urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:''); $url=''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; - $message.=img_picto('', 'object_globe.png').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); + $message.=img_picto('', 'globe').' '.$langs->trans("WebDavServer", 'WebDAV public', $url); $message.='
    '; } print $message; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 693ad3d1f47..ad7a2278991 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -553,7 +553,7 @@ if ($mode == 'searchkey') //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; - print '   '.img_picto('FixOnTransifex', 'object_globe').''; + print '   '.img_picto('FixOnTransifex', 'globe').''; } } else diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 278c2750cd4..0f541b93708 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -179,7 +179,7 @@ print '
    '; $message=''; $url=''.$urlwithroot.'/api/index.php/login?login='.urlencode($user->login).'&password=yourpassword[&reset=1]'; $message.=$langs->trans("UrlToGetKeyToUseAPIs").':
    '; -$message.=img_picto('', 'object_globe.png').' '.$url; +$message.=img_picto('', 'globe').' '.$url; print $message; print '
    '; print '
    '; @@ -208,7 +208,7 @@ foreach($listofapis['v1'] as $key => $val) //print $key.' - '.$val['classname'].' - '.$val['fullpath']." - ".DOL_MAIN_URL_ROOT.'/api/index.php/'.strtolower(preg_replace('/Api$/','',$val['classname']))."/xxx
    \n"; $url=$urlwithroot.'/api/index.php/'.$key; $url.='?api_key=token'; - print img_picto('', 'object_globe.png').' '.$method.' '.$url."
    \n"; + print img_picto('', 'globe').' '.$method.' '.$url."
    \n"; } } } diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index b005f257160..f8a354683e0 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -152,7 +152,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain $message=''; $url=$urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; $message.=$langs->trans("UrlToGetKeyToUseAPIs").':
    '; -$message.=img_picto('', 'object_globe.png').' '.$url; +$message.=img_picto('', 'globe').' '.$url; print $message; print '
    '; print '
    '; @@ -162,7 +162,7 @@ print ''.$langs->trans("ApiExporerIs").':
    '; if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) { $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; - print img_picto('', 'object_globe.png').' '.$url."
    \n"; + print img_picto('', 'globe').' '.$url."
    \n"; } else { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8b6b10a4f5f..edf6bd5b050 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1334,7 +1334,7 @@ class FormFile $fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); - print img_picto($langs->trans("FileSharedViaALink"), 'object_globe.png').' '; + print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; print ''; } else @@ -1851,7 +1851,7 @@ class FormFile else { print '
    '; - print img_picto('', 'object_globe').' '; + print img_picto('', 'globe').' '; print ''; print dol_escape_htmltag($link->label); print ''; diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index 57af5cc5a59..4088b00c151 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -95,10 +95,10 @@ function dol_print_cron_urls() print '
    '; print $langs->trans("URLToLaunchCronJobs").':
    '; $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; - print img_picto('', 'object_globe.png').' '.$url."
    \n"; + print img_picto('', 'globe').' '.$url."
    \n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'
    '; $url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; - print img_picto('', 'object_globe.png').' '.$url."
    \n"; + print img_picto('', 'globe').' '.$url."
    \n"; print '
    '; print '
    '; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 943c5778dce..c9eef4db1c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2134,7 +2134,7 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0) if (! preg_match('/^http/i', $url)) $link.='http://'; $link.=dol_trunc($url, $max); $link.=''; - return '
    '.($withpicto?img_picto($langs->trans("Url"), 'object_globe.png').' ':'').$link.'
    '; + return '
    '.($withpicto?img_picto($langs->trans("Url"), 'globe').' ':'').$link.'
    '; } /** @@ -7695,7 +7695,7 @@ function showDirectDownloadLink($object) if ($url) { - $out.= img_picto('', 'object_globe.png').' '.$langs->trans("DirectDownloadLink").'
    '; + $out.= img_picto('', 'globe').' '.$langs->trans("DirectDownloadLink").'
    '; $out.= ''; $out.= ajax_autoselect("directdownloadlink", 0); } diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index e0943be416e..f653662754f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -132,7 +132,7 @@ function showOnlinePaymentUrl($type, $ref) $servicename='Online'; - $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url = getOnlinePaymentUrl(0, $type, $ref); $out.= ''; $out.= ajax_autoselect("onlinepaymenturl", 0); diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index 3ed4fb764d0..c9527c54840 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -33,7 +33,7 @@ function showOnlineSignatureUrl($type, $ref) $servicename='Online'; - $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'
    '; $url = getOnlineSignatureUrl(0, $type, $ref); $out.= ''; $out.= ajax_autoselect("onlinesignatureurl", 0); diff --git a/htdocs/core/tpl/onlinepaymentlinks.tpl.php b/htdocs/core/tpl/onlinepaymentlinks.tpl.php index ef43fd585e2..c06772d8bca 100644 --- a/htdocs/core/tpl/onlinepaymentlinks.tpl.php +++ b/htdocs/core/tpl/onlinepaymentlinks.tpl.php @@ -28,12 +28,12 @@ print ''; // Url list print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':

    '; -print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount", $servicename).':
    '; +print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'free')."

    \n"; if (! empty($conf->commande->enabled)) { print '
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
    '; + print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnOrder", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'order')."
    \n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { @@ -56,7 +56,7 @@ if (! empty($conf->commande->enabled)) if (! empty($conf->facture->enabled)) { print '
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
    '; + print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnInvoice", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'invoice')."
    \n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { @@ -79,7 +79,7 @@ if (! empty($conf->facture->enabled)) if (! empty($conf->contrat->enabled)) { print '
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
    '; + print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnContractLine", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'contractline')."
    \n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { @@ -102,7 +102,7 @@ if (! empty($conf->contrat->enabled)) if (! empty($conf->adherent->enabled)) { print '
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
    '; + print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnMemberSubscription", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'membersubscription')."
    \n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { @@ -125,7 +125,7 @@ if (! empty($conf->adherent->enabled)) if (! empty($conf->don->enabled)) { print '
    '; - print img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation", $servicename).':
    '; + print img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnDonation", $servicename).':
    '; print ''.getOnlinePaymentUrl(1, 'donation')."
    \n"; if (! empty($conf->global->PAYMENT_SECURITY_TOKEN) && ! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index b796dcfd26f..38504088068 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -318,7 +318,7 @@ if ($forcedownload) $rellink.='&attachment=1'; if (! empty($object->entity)) $rellink.='&entity='.$object->entity; $rellink.='&file='.urlencode($filepath); $fulllink=$urlwithroot.$rellink; -print img_picto('', 'object_globe.png').' '; +print img_picto('', 'globe').' '; if ($action != 'edit') print ''; else print $fulllink; if ($action != 'edit') print ' '.$langs->trans("Download").''; // No target here. @@ -343,7 +343,7 @@ if (! empty($object->share)) //if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path //elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content - print img_picto('', 'object_globe.png').' '; + print img_picto('', 'globe').' '; if ($action != 'edit') print ''; else print $fulllink; if ($action != 'edit') print ' '.$langs->trans("Download").''; // No target here diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index ae40a13701d..1cdab974833 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -327,7 +327,7 @@ if ($object->fk_user_creat) { print '
    '.img_picto('', 'object_globe.png').' '.$langs->trans("UrlForSurvey", '').''; +print '
    '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index d30f24694e9..ad31d99e645 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -474,7 +474,7 @@ if ($object->fk_user_creat) { print '
    '.img_picto('', 'object_globe.png').' '.$langs->trans("UrlForSurvey", '').''; +print '
    '.img_picto('', 'globe').' '.$langs->trans("UrlForSurvey", '').''; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 4a528c449a2..22356994008 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -70,7 +70,7 @@ function showPaypalPaymentUrl($type, $ref) $langs->load("paybox"); $servicename='PayPal'; $out='

    '; - $out.=img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; + $out.=img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url=getPaypalPaymentUrl(0, $type, $ref); $out.=''; $out.=ajax_autoselect("paypalurl", 0); diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 4fc28ed070b..5076d1e769d 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -857,7 +857,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'object_globe').''; + print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } print '
    '; if (empty($stripecu)) @@ -911,7 +911,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url='https://dashboard.stripe.com/connect/accounts/'.$stripesupplieracc; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'object_globe').''; + print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } print ''; if (empty($stripesupplieracc)) @@ -1064,7 +1064,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { $url='https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; } - print ' '.img_picto($langs->trans('ShowInStripe'), 'object_globe').''; + print ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; } print ''; @@ -1159,7 +1159,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; $url='https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; } - print " ".img_picto($langs->trans('ShowInStripe'), 'object_globe').""; + print " ".img_picto($langs->trans('ShowInStripe'), 'globe').""; print ''; @@ -1334,7 +1334,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' else $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; } } - + if (is_array($currencybalance)) { foreach ($currencybalance as $cpt) @@ -1342,7 +1342,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print '
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '; print '
    '; } diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 7621f48eeae..05d8937f293 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -207,7 +207,7 @@ if (empty($conf->stripeconnect->enabled)) } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; - $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForTestWebhook").' '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForTestWebhook").' '; $url = dol_buildpath('/public/stripe/ipn.php?test', 3); $out.= ''; $out.= ajax_autoselect("onlinetestwebhookurl", 0); @@ -280,7 +280,7 @@ if (empty($conf->stripeconnect->enabled)) } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; - $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForLiveWebhook").' '; + $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForLiveWebhook").' '; $url = dol_buildpath('/public/stripe/ipn.php', 3); $out.= ''; $out.= ajax_autoselect("onlinelivewebhookurl", 0); diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 200f4c31703..1189b94923b 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -183,7 +183,7 @@ if (!$rowid) $url='https://dashboard.stripe.com/'.$connect.'payments/'.$charge->id; } print ""; - print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." ".$charge->id.""; + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." ".$charge->id.""; print "\n"; // Stripe customer print ""; @@ -195,7 +195,7 @@ if (!$rowid) } if (! empty($charge->customer)) { - print ''.img_picto($langs->trans('ShowInStripe'), 'object_globe').' '.$charge->customer.''; + print ''.img_picto($langs->trans('ShowInStripe'), 'globe').' '.$charge->customer.''; } print "\n"; // Link diff --git a/htdocs/stripe/lib/stripe.lib.php b/htdocs/stripe/lib/stripe.lib.php index 95fb80ce9dc..8a4284f491e 100644 --- a/htdocs/stripe/lib/stripe.lib.php +++ b/htdocs/stripe/lib/stripe.lib.php @@ -70,7 +70,7 @@ function showStripePaymentUrl($type, $ref) $servicename='Stripe'; $out='

    '; - $out.=img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; + $out.=img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
    '; $url=getStripePaymentUrl(0, $type, $ref); $out.='
    '; $out.=ajax_autoselect("stripeurl", 0); diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index e66318506ed..5870427757a 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -169,7 +169,7 @@ if (! $rowid) { $url='https://dashboard.stripe.com/'.$connect.'payouts/'.$payout->id; } - print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $payout->id . "\n"; + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." " . $payout->id . "\n"; // Stripe customer diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 4ad04011f99..873adfc1cf7 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -178,7 +178,7 @@ if (! $rowid) { if ($txn->type == 'stripe_fee' || $txn->type == 'reserve_transaction') { print "".$txn->type.""; } else { - print "".img_picto($langs->trans('ShowInStripe'), 'object_globe')." " . $txn->source . "\n"; + print "".img_picto($langs->trans('ShowInStripe'), 'globe')." " . $txn->source . "\n"; } // Stripe customer diff --git a/htdocs/webservices/admin/index.php b/htdocs/webservices/admin/index.php index 93467c2c964..dbe3082b5de 100644 --- a/htdocs/webservices/admin/index.php +++ b/htdocs/webservices/admin/index.php @@ -120,7 +120,7 @@ foreach($webservices as $name => $right) { if (!empty($right) && !verifCond($right)) continue; $url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl'; - print img_picto('', 'object_globe.png').' '.$url."
    \n"; + print img_picto('', 'globe').' '.$url."
    \n"; } print '
    '; @@ -131,7 +131,7 @@ foreach($webservices as $name => $right) { if (!empty($right) && !verifCond($right)) continue; $url=DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php'; - print img_picto('', 'object_globe.png').' '.$url."
    \n"; + print img_picto('', 'globe').' '.$url."
    \n"; } print '
    '; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 777201707ad..2769fb33cd0 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2064,7 +2064,7 @@ if (! GETPOST('hide_websitemenu')) print ''; $linktotestonwebserver = ''; - $linktotestonwebserver.= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'object_globe'); + $linktotestonwebserver.= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); $linktotestonwebserver.= ''; $htmltext = ''; if (empty($object->fk_default_home)) From 027c8224b0f6003ff4a5e12a5293149145449888 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:34:01 +0200 Subject: [PATCH 33/77] Fix dolGetStatus unused --- htdocs/core/lib/functions.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b617471fca..dab617f5e19 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8109,6 +8109,11 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = ''; + $dolGetBadgeParams = array(); + if(!empty($params['badgeParams'])){ + $dolGetBadgeParams = $params['badgeParams']; + } + // image's filename are still in French $statusImg=array( 'status0' => 'statut0' @@ -8164,13 +8169,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; if ($displayMode == 3) { - $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url); + $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url, $dolGetBadgeParams); } elseif ($displayMode === 5) { - $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url); + $return = dolGetBadge($statusLabelShort, $html, $statusType, '', $url, $dolGetBadgeParams); } else { - $return = dolGetBadge($statusLabel, $html, $statusType, '', $url); + $return = dolGetBadge($statusLabel, $html, $statusType, '', $url, $dolGetBadgeParams); } } From 35c6008e1afbe5d7f79a61add30e4792dbedd9f2 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 21:58:23 +0200 Subject: [PATCH 34/77] Fix supplier order libStatus to use new dolGetStatus --- .../class/fournisseur.commande.class.php | 77 +++++++------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d8f760330b8..0b2d9022b58 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -625,18 +625,17 @@ class CommandeFournisseur extends CommonOrder /** * Return label of a status * - * @param int $statut Id statut + * @param int $status Id statut * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @param int $billed 1=Billed * @return string Label of status */ - public function LibStatut($statut, $mode = 0, $billed = 0) + public function LibStatut($status, $mode = 0, $billed = 0) { // phpcs:enable global $conf, $langs; - if (empty($this->statuts) || empty($this->statutshort)) - { + if (empty($this->statuts) || empty($this->statutshort)){ $langs->load('orders'); $this->statuts[0] = 'StatusSupplierOrderDraft'; @@ -662,55 +661,33 @@ class CommandeFournisseur extends CommonOrder $this->statutshort[9] = 'StatusSupplierOrderRefusedShort'; } - $billedtext=''; - //if ($statut==5 && $this->billed == 1) $statut = 8; - if ($billed == 1) $billedtext=$langs->trans("Billed"); + $statustrans = array( + 0 => 'status0', + 1 => 'status1', + 2 => 'status3', + 3 => 'status3', + 4 => 'status3', + 5 => 'status6', + 6 => 'status5', + 7 => 'status5', - if ($mode == 0) - { - return $langs->trans($this->statuts[$statut]); + 9 => 'status5', + ); + + $statusClass = 'status0'; + if(!empty($statustrans[$status])){ + $statusClass = $statustrans[$status]; } - elseif ($mode == 1) - { - return $langs->trans($this->statutshort[$statut]); - } - elseif ($mode == 2) - { - return $langs->trans($this->statuts[$statut]); - } - elseif ($mode == 3) - { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==4) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==5) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - elseif ($statut==9) return img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - } - elseif ($mode == 4) - { - if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==4) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==5) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==6 || $statut==7) return img_picto($langs->trans($this->statuts[$statut]), 'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - elseif ($statut==9) return img_picto($langs->trans($this->statuts[$statut]), 'statut5').' '.$langs->trans($this->statuts[$statut]).($billedtext?' - '.$billedtext:''); - } - elseif ($mode == 5) - { - if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - elseif ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - elseif ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==3) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==4) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - elseif ($statut==5) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - elseif ($statut==6 || $statut==7) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut5'); - elseif ($statut==9) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut5'); + + $billedtext = ''; + if($mode == 4 && $billed){ + $billedtext = ' - '.$langs->trans("Billed"); } + + $statusLong = $langs->trans($this->statuts_long[$status]).$billedtext; + $statusShort = $langs->trans($this->statutshort[$status]); + + return dolGetStatus($statusLong, $statusShort, '', $statusClass, $mode); } From 5932f0e6b18e32bad9612c712c67178a8d1959ca Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Oct 2019 20:03:23 +0000 Subject: [PATCH 35/77] Fixing style errors. --- htdocs/projet/class/project.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2382f93c17a..4f38fdbe49c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -962,7 +962,6 @@ class Project extends CommonObject } return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); - } /** From 13e456d992e278c743d419cad7f7d4ccf747d02b Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 3 Oct 2019 22:05:48 +0200 Subject: [PATCH 36/77] Fix Project LibStatus langs --- htdocs/projet/class/project.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2382f93c17a..d24cbb144fb 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -949,6 +949,7 @@ class Project extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable + global $langs; $statustrans = array( 0 => 'status0', @@ -961,7 +962,7 @@ class Project extends CommonObject $statusClass = $statustrans[$status]; } - return dolGetStatus($this->statuts_long[$status], $this->statuts_short[$status], '', $statusClass, $mode); + return dolGetStatus($langs->trans($this->statuts_long[$status]), $langs->trans($this->statuts_short[$status]), '', $statusClass, $mode); } From cb34c7e29970c43355ae7e7c90d37858b49344f7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Oct 2019 20:08:42 +0000 Subject: [PATCH 37/77] Fixing style errors. --- htdocs/projet/class/project.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d24cbb144fb..e14cd53c3c3 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -963,7 +963,6 @@ class Project extends CommonObject } return dolGetStatus($langs->trans($this->statuts_long[$status]), $langs->trans($this->statuts_short[$status]), '', $statusClass, $mode); - } /** From b6882af1b681539c4382a1e699134849c764c0be Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Thu, 3 Oct 2019 20:21:13 -0500 Subject: [PATCH 38/77] Add hidden options to send by email for all status --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 39c80269d8f..48837950d33 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2496,7 +2496,7 @@ $formquestion = array_merge($formquestion, array( } // Send - if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) { + if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { print ''; } else diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ff4606655a5..8df27f0e09f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2542,7 +2542,7 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); if (empty($reshook)) { // Send - if ($object->statut > Commande::STATUS_DRAFT) { + if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { print ''; } else diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 15c8c3439ce..4bd99e6db01 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2411,7 +2411,7 @@ elseif (! empty($object->id)) } // Send - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5))) + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($user->rights->fournisseur->commande->commander) { From 0e23fbc6dfd8be42a2cd417a40320b2d6ba42da3 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 4 Oct 2019 10:04:02 +0200 Subject: [PATCH 39/77] NEW add country code in import product model --- htdocs/core/modules/import/import_csv.modules.php | 8 ++++---- htdocs/core/modules/import/import_xlsx.modules.php | 8 ++++---- htdocs/core/modules/modProduct.class.php | 11 ++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index bde888157dd..1e4284dec7f 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -509,12 +509,12 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index a67a0c90c4b..b83199e2ac6 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -536,12 +536,12 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + if ($classinstance->id != '') // id may be 0, it is a found value { - $newval=$classinstance->code; + $newval=$classinstance->id; } else { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 019f5251e60..03c268d6968 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -354,6 +354,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "PublicNote",//public note 'p.note' => "PrivateNote",//private note 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', 'p.price' => "SellingPriceHT",//without 'p.price_min' => "MinPrice", 'p.price_ttc' => "SellingPriceTTC",//with tax @@ -440,7 +441,14 @@ class modProduct extends DolibarrModules 'method' => 'fetch', 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' - ) + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); @@ -485,6 +493,7 @@ class modProduct extends DolibarrModules 'p.note_public' => "a public note (free text)", 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', 'p.price' => "price ex-vat eg. 100", 'p.price_min' => "price ex-vat eg. 100", 'p.price_ttc' => "price inc-vat eg. 110", From bc32d684a497611ed187fe16a56049fa80554c5b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 4 Oct 2019 16:12:33 +0000 Subject: [PATCH 40/77] Fixing style errors. --- htdocs/contact/card.php | 4 ++-- htdocs/contact/class/contact.class.php | 1 - htdocs/core/lib/company.lib.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5b1e302632e..1a271918b61 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -476,7 +476,7 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res<0) { - setEventMessage($this->error,'errors'); + setEventMessage($this->error, 'errors'); } // Show tabs @@ -1054,7 +1054,7 @@ else if (!empty($object->socid)) { print '' . $langs->trans("Role") . ''; print ''; - print $formcompany->showRoles("roles", $object, 'edit' ,$object->roles); + print $formcompany->showRoles("roles", $object, 'edit', $object->roles); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index cb738249a44..560a6e2bc0d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1610,5 +1610,4 @@ class Contact extends CommonObject return $error*-1; } } - } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4ead0601a40..91ba98d0ad4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1142,7 +1142,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') $resultRole=$contactstatic->fetchRoles(); if ($resultRole<0) { - setEventMessages(null, $contactstatic->errors,'errors'); + setEventMessages(null, $contactstatic->errors, 'errors'); } if (is_array($contactstatic->array_options)) From c8fb81710f20dd47a49cb1988568f8a4adc3b87a Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Fri, 4 Oct 2019 18:13:00 +0200 Subject: [PATCH 41/77] fix #12041 - Generate password Secure the generate password method "perso". Now the system checks the minimum possible value. If the value entered is lower then the system will never trigger the update. Since the update is done through GET parameters, I also added a check backend wise. This checks should never be triggered nor in error. [see: #12041] --- htdocs/admin/security.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index df2d2b09ee6..a7707629cff 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -170,9 +170,23 @@ elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'maj_pattern') { - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", GETPOST("pattern"), 'chaine', 0, '', $conf->entity); - header("Location: security.php"); - exit; + $pattern = GETPOST("pattern"); + $explodePattern = explode(';',$pattern); + + $patternInError = false; + if($explodePattern[0] < 1 || $explodePattern[4] < 1){ + $patternInError = true; + } + + if($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]){ + $patternInError = true; + } + + if(!$patternInError){ + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); + header("Location: security.php"); + exit; + } } @@ -278,13 +292,6 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); - /*$this->length2 = $tabConf[0]; - $this->NbMaj = $tabConf[1]; - $this->NbNum = $tabConf[2]; - $this->NbSpe = $tabConf[3]; - $this->NbRepeat = $tabConf[4]; - $this->WithoutAmbi = $tabConf[5]; - */ print '
    '; print ''; print ''; @@ -318,7 +325,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; print '"; - print ''; + print ''; print ''; @@ -350,6 +357,13 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ' }'; print ' function valuePossible(){'; + print ' var fields = ["#minlenght", "#NbMajMin", "#NbNumMin", "#NbSpeMin", "#NbIteConsecutive"];'; + print ' for(var i = 0 ; i < fields.length ; i++){'; + print ' if($(fields[i]).val() < $(fields[i]).attr("min")){'; + print ' return false;'; + print ' }'; + print ' }'; + print ' '; print ' var length = parseInt($("#minlenght").val());'; print ' var length_mini = parseInt($("#NbMajMin").val()) + parseInt($("#NbNumMin").val()) + parseInt($("#NbSpeMin").val());'; print ' return length >= length_mini;'; From a509404636d68158c85b987489e87b124992f94c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 4 Oct 2019 16:26:26 +0000 Subject: [PATCH 42/77] Fixing style errors. --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index a7707629cff..3a786f30a84 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -171,7 +171,7 @@ elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') if ($action == 'maj_pattern') { $pattern = GETPOST("pattern"); - $explodePattern = explode(';',$pattern); + $explodePattern = explode(';', $pattern); $patternInError = false; if($explodePattern[0] < 1 || $explodePattern[4] < 1){ From 10671e3266627c49aeeeaeb4eddb496e3c129284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Oct 2019 21:15:13 +0200 Subject: [PATCH 43/77] api supplier price delete --- htdocs/product/class/api_products.class.php | 33 +++++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 866eeb116cf..da7cd9fa780 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -15,10 +15,11 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** * API class for products @@ -41,6 +42,11 @@ class Products extends DolibarrApi */ public $product; + /** + * @var ProductFournisseur $productsupplier {@type ProductFournisseur} + */ + public $productsupplier; + /** * Constructor */ @@ -49,6 +55,7 @@ class Products extends DolibarrApi global $db, $conf; $this->db = $db; $this->product = new Product($this->db); + $this->productsupplier = new ProductFournisseur($this->db); } /** @@ -475,7 +482,7 @@ class Products extends DolibarrApi * * @url DELETE {id}/purchase_prices/{priceid} * - * @return array + * @return int * * @throws 401 * @throws 404 @@ -494,13 +501,13 @@ class Products extends DolibarrApi if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - - if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id); + $resultsupplier = 0; + if ($result) { + $this->productsupplier->fetch($id); + $resultsupplier = $this->product->remove_product_fournisseur_price($priceid); } - return $this->product->remove_product_fournisseur_price($priceid); + return $resultsupplier; } /** @@ -632,13 +639,13 @@ class Products extends DolibarrApi } if ($includestockdata) { - $this->product->load_stock(); + $this->product->load_stock(); } if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, '', '', 0, 0); + $this->product = new ProductFournisseur($this->db); + $this->product->fetch($id, $ref); + $this->product->list_product_fournisseur_price($id, '', '', 0, 0); } return $this->_cleanObjectDatas($this->product); From b895f8a78f4d03b5c6acbc0c785d79e260dc166b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Oct 2019 21:19:55 +0200 Subject: [PATCH 44/77] api supplier get purchase prices --- htdocs/product/class/api_products.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index da7cd9fa780..346aef06a91 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -642,13 +642,12 @@ class Products extends DolibarrApi $this->product->load_stock(); } - if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, '', '', 0, 0); + if ($result) { + $this->productsupplier->fetch($id, $ref); + $this->productsupplier->list_product_fournisseur_price($id, '', '', 0, 0); } - return $this->_cleanObjectDatas($this->product); + return $this->_cleanObjectDatas($this->productsupplier); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From e70b487c3499e01b9167314163cf64495aa0861b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 5 Oct 2019 22:22:55 +0200 Subject: [PATCH 45/77] Add info about validators saying default is supervisor --- htdocs/user/card.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d5e6776a223..67801b88e4d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -972,7 +972,10 @@ if ($action == 'create' || $action == 'adduserldap') // Expense report validator if(!empty($conf->expensereport->enabled)) { - print ''; + print ''; print ''; @@ -982,7 +985,10 @@ if ($action == 'create' || $action == 'adduserldap') // Holiday request validator if(!empty($conf->holiday->enabled)) { - print ''; + print ''; print ''; @@ -1587,7 +1593,10 @@ else print "\n"; // Expense report validator - print ''; + print ''; print '\n"; // Holiday request validator - print ''; + print ''; print '\n"; // Expense report validator - print ''; + print ''; print '\n"; // Holiday request validator - print ''; + print ''; print ''; print ''; + print ''; } // Full day event From 8a9f08d5a39b17bf67cee2a2a0414d3431ac0c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 11:29:24 +0200 Subject: [PATCH 50/77] lang file for holidays is holiday --- htdocs/core/modules/holiday/modules_holiday.php | 4 ++-- htdocs/holiday/document.php | 4 +--- htdocs/holiday/list.php | 2 +- htdocs/index.php | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 74cbb0dbfd5..c5f5dc16b25 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -96,7 +96,7 @@ class ModelNumRefHolidays public function info() { global $langs; - $langs->load("holidays"); + $langs->load("holiday"); return $langs->trans("NoDescription"); } @@ -108,7 +108,7 @@ class ModelNumRefHolidays public function getExample() { global $langs; - $langs->load("holidays"); + $langs->load("holiday"); return $langs->trans("NoExample"); } diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 00bc7ac1b24..05ddf164105 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page -$langs->loadLangs(array('other', 'holidays', 'companies')); +$langs->loadLangs(array('other', 'holiday', 'companies')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -48,8 +48,6 @@ $confirm = GETPOST('confirm', 'alpha'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'holiday', $id, 'holiday'); -$langs->load("holiday"); - // Get parameters $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cbf2e2f01aa..d6e44261fe8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('users', 'holidays', 'hrm')); +$langs->loadLangs(array('users', 'holiday', 'hrm')); // Protection if external user if ($user->societe_id > 0) accessforbidden(); diff --git a/htdocs/index.php b/htdocs/index.php index 050058cd819..7279eebe80f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -301,7 +301,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT "supplier_proposal", "projects", "trips", - "holidays", + "holiday", "donations" ); From 52da21912b908224f8448dcbe7680dc026282564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 13:21:04 +0200 Subject: [PATCH 51/77] Update agenda.lang --- htdocs/langs/en_US/agenda.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 1ebb2c3edd8..a7b6ea4f4da 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -85,6 +85,7 @@ PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_DELETEInDolibarr=Product %s deleted HOLIDAY_CREATEInDolibarr=Request for leave %s created HOLIDAY_MODIFYInDolibarr=Request for leave %s modified +HOLIDAY_VALIDATEDInDolibarr=Request for leave %s validated HOLIDAY_DELETEInDolibarr=Request for leave %s deleted EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated From 6c1c008d0909020828751bca226f5b48125cf9f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2019 14:57:34 +0200 Subject: [PATCH 52/77] FIX Look and feel v10 --- htdocs/user/group/card.php | 2 +- htdocs/user/group/perms.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 1610210e473..20b0aee410f 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -362,7 +362,7 @@ else print '
    '; print '
    '; - print '
    ' . $langs->trans("NbIteConsecutive")."
    '.$langs->trans("UserExpenseValidator").'
    '; + $text = $langs->trans("UserExpenseValidator"); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; print $form->select_dolusers($object->fk_user_expense_validator, 'fk_user_expense_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300'); print '
    ' . $langs->trans("UserHolidayValidator") . '
    '; + $text = $langs->trans("UserHolidayValidator"); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; print $form->select_dolusers($object->fk_user_holiday_validator, 'fk_user_holiday_validator', 1, array($object->id), 0, '', 0, $conf->entity, 0, 0, '', 0, '', 'maxwidth300'); print '
    '.$langs->trans("UserExpenseValidator").'
    '; + $text = $langs->trans("UserExpenseValidator"); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; if (empty($object->fk_user_expense_validator)) print $langs->trans("None"); else { @@ -1599,7 +1608,10 @@ else print "
    '.$langs->trans("UserHolidayValidator").'
    '; + $text = $langs->trans("UserHolidayValidator"); + print $form->textwithpicto($text , $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; if (empty($object->fk_user_holiday_validator)) print $langs->trans("None"); else { @@ -2292,7 +2304,10 @@ else print "
    '.$langs->trans("UserExpenseValidator").'
    '; + $text = $langs->trans("UserExpenseValidator"); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; if ($caneditfield) { @@ -2309,7 +2324,10 @@ else print "
    '.$langs->trans("UserHolidayValidator").'
    '; + $text = $langs->trans("UserHolidayValidator"); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print ''; if ($caneditfield) { From 848b9cc57a073a0675b20de38a197711b2ef5385 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 5 Oct 2019 22:24:59 +0200 Subject: [PATCH 46/77] Translations --- htdocs/langs/en_US/users.lang | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index fb35cb5e112..d8758ac9dc0 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -109,4 +109,7 @@ UserLogoff=User logout UserLogged=User logged DateEmployment=Employment Start Date DateEmploymentEnd=Employment End Date -CantDisableYourself=You can't disable your own user record \ No newline at end of file +CantDisableYourself=You can't disable your own user record +UserExpenseValidator=Expense report validator +UserHolidayValidator=Leave request validator +ValidatorIsSupervisorByDefault=By default, the supervisor is the validator for expense reports and leave requests From 1047a8ea0f73957461f36b51ef4f0d453402d2f2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 5 Oct 2019 20:25:17 +0000 Subject: [PATCH 47/77] Fixing style errors. --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 40abaea7d3d..6a821664ee7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1610,7 +1610,7 @@ else // Holiday request validator print '
    '; $text = $langs->trans("UserHolidayValidator"); - print $form->textwithpicto($text , $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); + print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; if (empty($object->fk_user_holiday_validator)) print $langs->trans("None"); From 21dcc549fad441f75a537ae47d5b0ae62381b5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 10:09:06 +0200 Subject: [PATCH 48/77] translation for holidays actioncomm --- htdocs/langs/en_US/agenda.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 4a7ab99ca77..1ebb2c3edd8 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -83,6 +83,9 @@ InvoiceDeleted=Invoice deleted PRODUCT_CREATEInDolibarr=Product %s created PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_DELETEInDolibarr=Product %s deleted +HOLIDAY_CREATEInDolibarr=Request for leave %s created +HOLIDAY_MODIFYInDolibarr=Request for leave %s modified +HOLIDAY_DELETEInDolibarr=Request for leave %s deleted EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved From bfd8bc839e38565d384a29d7f78809bc3cb28906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 6 Oct 2019 10:28:09 +0200 Subject: [PATCH 49/77] Update card.php --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4bd5ceb4d8f..4b7695bb503 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1622,7 +1622,7 @@ if ($id > 0) // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print '
    '.$langs->trans("Type").''.$object->type.'
    '.$langs->trans("Type").''.$langs->trans($object->type).'
    '; + print '
    '; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) if (! empty($conf->mutlicompany->enabled)) diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index f4fae8160c4..e80d75e6c0e 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -201,7 +201,7 @@ if ($object->id > 0) * Ecran ajout/suppression permission */ - print '
    '; + print '
    '; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) if (! empty($conf->mutlicompany->enabled)) From fb808d830e1435b1fe70a7b980fcd6d2d7735c23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2019 15:08:05 +0200 Subject: [PATCH 53/77] FIX Look and feel v10 --- htdocs/projet/activity/perday.php | 20 ++++++++++---------- htdocs/projet/activity/perweek.php | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index d06d38ad390..4a9b613bcd5 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -588,27 +588,27 @@ print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +print ''; // TASK fields $extrafieldsobjectkey='projet_task'; $extrafieldsobjectprefix='efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (! empty($arrayfields['t.planned_workload']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['t.progress']['checked'])) { - print ''; + print ''; } /*print ''; if ($usertoprocess->id == $user->id) print ''; else print '';*/ -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; -print ''; +print ''; +print ''; //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4c4f1844be3..280c9944d9f 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -640,26 +640,26 @@ print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; -print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +print ''; // TASK fields $extrafieldsobjectkey='projet_task'; $extrafieldsobjectprefix='efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (! empty($arrayfields['t.planned_workload']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['t.progress']['checked'])) { - print ''; + print ''; } /*print ''; if ($usertoprocess->id == $user->id) print ''; else print '';*/ -print ''; -print ''; +print ''; +print ''; for ($idw=0; $idw<7; $idw++) { @@ -679,7 +679,7 @@ for ($idw=0; $idw<7; $idw++) elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; - print ''; + print ''; } //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); From 753da4791eb0bec828d231faae73cbbce78c501d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Oct 2019 16:11:57 +0200 Subject: [PATCH 54/77] FIX Pb in units of shipments Conflicts: htdocs/expedition/card.php --- htdocs/expedition/card.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d8ac6e752f9..d0f9b3d1c84 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -96,7 +96,6 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes lines and labels $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line); - // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -1570,10 +1569,10 @@ if ($action == 'create') } } - //Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { + //var_dump($line); $colspan=5; $orderLineExtrafields = new Extrafields($db); $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); @@ -1583,7 +1582,7 @@ if ($action == 'create') //$line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); print ''; - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); + print $line->showOptionals($extrafieldsline, 'edit', array('colspan'=>$colspan), $indiceAsked); print ''; } } @@ -1841,8 +1840,8 @@ elseif ($id || $ref) print ''; print ''; print ''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ' '; print ' '; print ''; @@ -1850,7 +1849,7 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units, "weight"):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string(0, "weight", $object->weight_units):''; } // Calculated @@ -1867,7 +1866,7 @@ elseif ($id || $ref) // Width print ''; // Height @@ -1878,8 +1877,8 @@ elseif ($id || $ref) print ''; print ''; print ''; - print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); + print ''; + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); print ' '; print ' '; print ''; @@ -1887,7 +1886,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units, "size"):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string(0, "size", $object->height_units):''; } print ''; @@ -1895,7 +1894,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -2101,8 +2100,6 @@ elseif ($id || $ref) } print "\n"; - $var=false; - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); @@ -2407,14 +2404,14 @@ elseif ($id || $ref) } // Weight - print ''; // Volume - print ''; From 0b9213f4f13bd124cf957394d3ccf686003517f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 7 Oct 2019 08:11:23 +0200 Subject: [PATCH 55/77] Update contrat.class.php --- htdocs/contrat/class/contrat.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c6462cba9b9..99a5f78691f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2077,7 +2077,7 @@ class Contrat extends CommonObject * Return list of line rowid * * @param int $statut Status of lines to get - * @return array Array of line's rowid + * @return array|int Array of line's rowid or <0 if error */ public function array_detail($statut = -1) { @@ -2114,7 +2114,7 @@ class Contrat extends CommonObject * Return list of other contracts for same company than current contract * * @param string $option 'all' or 'others' - * @return array Array of contracts id + * @return array|int Array of contracts id or <0 if error */ public function getListOfContracts($option = 'all') { From fc90638b2b903ef908322e5e3f921c8bf24f6695 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 10:42:18 +0200 Subject: [PATCH 56/77] Code comment --- htdocs/core/class/cunits.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 919d2ad3aae..bce617308a6 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -160,11 +160,11 @@ class CUnits // extends CommonObject /** * Load object in memory from database * - * @param int $id Id object - * @param string $code Code - * @param string $short_label Short Label - * @param string $unit_type unit type - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $code Code + * @param string $short_label Short Label ('g', 'kg', ...) + * @param string $unit_type Unit type ('size', 'surface', 'volume', 'weight', ...) + * @return int <0 if KO, >0 if OK */ public function fetch($id, $code = '', $short_label = '', $unit_type = '') { From 219b0d89255167b53558df0dc3389c5db2502127 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Fri, 4 Oct 2019 10:04:02 +0200 Subject: [PATCH 57/77] FIX Import of product using units --- htdocs/core/class/cunits.class.php | 2 + .../modules/import/import_csv.modules.php | 17 +- .../modules/import/import_xlsx.modules.php | 32 +- htdocs/core/modules/modProduct.class.php | 158 +++++---- htdocs/core/modules/modService.class.php | 318 ++++++++++++++---- 5 files changed, 360 insertions(+), 167 deletions(-) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 501192a68eb..cba2a3c1e5d 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -172,6 +172,7 @@ class CUnits // extends CommonObject $sql.= " t.code,"; $sql.= " t.label,"; $sql.= " t.short_label,"; + $sql.= " t.scale,"; $sql.= " t.unit_type,"; $sql.= " t.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_units as t"; @@ -195,6 +196,7 @@ class CUnits // extends CommonObject $this->code = $obj->code; $this->label = $obj->label; $this->short_label = $obj->short_label; + $this->scale = $obj->scale; $this->unit_type = $obj->unit_type; $this->active = $obj->active; } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0a60d9dc0ae..fd39ed6f49e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -489,7 +489,7 @@ class ImportCsv extends ModeleImports { if (empty($newval)) $newval='0'; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchscalefromcodeunits') { $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -509,16 +509,17 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; - //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; + if ($classinstance->id > 0) // we found record { - $newval=$classinstance->code; + $newval = $scaleorid ? $scaleorid : 0; } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; @@ -677,7 +678,7 @@ class ImportCsv extends ModeleImports // Loop on each hidden fields to add them into listfields/listvalues foreach($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table + if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index af9c0e2c412..a4615579f34 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -516,7 +516,7 @@ class ImportXlsx extends ModeleImports { if (empty($newval)) $newval='0'; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchscalefromcodeunits') { $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -536,17 +536,18 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; - //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value - { - $newval=$classinstance->code; - } - else - { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; + if ($classinstance->id > 0) // we found record + { + $newval = $scaleorid ? $scaleorid : 0; + } + else + { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; @@ -668,8 +669,9 @@ class ImportXlsx extends ModeleImports $errorforthistable++; $error++; } - } elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { - // If test is just a static regex + } + // If test is just a static regex + elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
    "; $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type']='REGEX'; @@ -778,7 +780,7 @@ class ImportXlsx extends ModeleImports $error++; } } else { - // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // We have a last INSERT ID (got by previous pass), so we check if we have a row referencing this foreign key. // This is required when updating table with some extrafields. When inserting a record in parent table, we can make // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 9592e3b185f..f9ab7347792 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -168,16 +168,22 @@ class modProduct extends DolibarrModules $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", - 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface", - 'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", - 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", + 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", + 'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + //'p.duration'=>"Duration", + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.tva_tx'=>'VATRate','p.datec'=>'DateCreation','p.tms'=>'DateModification' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); @@ -187,9 +193,11 @@ class modProduct extends DolibarrModules $this->export_TypeFields_array[$r]=array( 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", 'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date' + //'p.duration'=>"Duree", ); if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); @@ -292,8 +300,9 @@ class modProduct extends DolibarrModules $this->export_fields_array[$r]=array( 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' ); @@ -301,9 +310,10 @@ class modProduct extends DolibarrModules if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", - 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", 'p.datec'=>'Date','p.tms'=>'Date' ); @@ -348,29 +358,21 @@ class modProduct extends DolibarrModules $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array(//field order as per structure of table llx_product 'p.ref' => "Ref*", - 'p.datec' => 'DateCreation', 'p.label' => "Label*", - 'p.description' => "Description", - 'p.note_public' => "PublicNote",//public note - 'p.note' => "PrivateNote",//private note - 'p.customcode' => 'CustomCode', - 'p.price' => "SellingPriceHT",//without - 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax - 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card - 'p.cost_price' => "CostPrice", - 'p.tva_tx' => 'VATRate', - 'p.tosell' => "OnSell*", - 'p.tobuy' => "OnBuy*", - 'p.fk_product_type' => "Type*", - 'p.duration' => "Duration",///duration of service - 'p.url' => "PublicUrl", + 'p.fk_product_type' => "Type*", + 'p.tosell' => "OnSell*", + 'p.tobuy' => "OnBuy*", + 'p.description' => "Description", + 'p.url' => "PublicUrl", + 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', 'p.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", - 'p.weight' => "Weight", + 'p.note_public' => "NotePublic", + 'p.note' => "NotePrivate", + 'p.weight' => "Weight", 'p.weight_units' => "WeightUnits", 'p.length' => "Length", 'p.length_units' => "LengthUnit", @@ -382,7 +384,16 @@ class modProduct extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.finished' => 'Nature', + 'p.duration' => "Duration",//duration of service + 'p.finished' => 'Nature', + 'p.price' => "SellingPriceHT",//without + 'p.price_min' => "MinPrice", + 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", + 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.tva_tx' => 'VATRate', + 'p.datec' => 'DateCreation', + 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( @@ -392,10 +403,9 @@ class modProduct extends DolibarrModules )); } - /* Disabled: The value of fields xxx_units is the scale for reference unit, not the rowid in table llx_c_unit !!! $this->import_convertvalue_array[$r] = array( - 'p.weight_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -403,7 +413,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -411,7 +421,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -419,7 +429,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -427,7 +437,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -435,14 +445,21 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' - ) - );*/ + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); @@ -480,18 +497,19 @@ class modProduct extends DolibarrModules // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "PREF123456", - 'p.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), + 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), 'p.label' => "Product name in default language", 'p.description' => "Product description in default language", 'p.note_public' => "a public note (free text)", 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', - 'p.price' => "price ex-vat eg. 100", - 'p.price_min' => "price ex-vat eg. 100", - 'p.price_ttc' => "price inc-vat eg. 110", - 'p.price_min_ttc' => "price inc-vat eg. 110", + 'p.fk_country' => 'FR', + 'p.price' => "100", + 'p.price_min' => "100", + 'p.price_ttc' => "110", + 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -502,27 +520,27 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'use a unit of measure from the dictionary. g/Kg/T etc....matches field "Scale" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Scale" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Scale" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( - 'p.seuil_stock_alerte' => 'quantity for low-stock warning (empty for no warning)', - 'p.pmp' => '0 (default)', - 'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)' + 'p.seuil_stock_alerte' => '', + 'p.pmp' => '0', + 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'user-editable, used for margin calculations only')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0 / 1 (French VAT NPR yes/no')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); @@ -596,34 +614,34 @@ class modProduct extends DolibarrModules $this->import_examplevalues_array[$r]=array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", - 'sp.ref_fourn' => "eg: XYZ-F123456", + 'sp.ref_fourn' => "XYZ-F123456", 'sp.quantity' => "5", - 'sp.tva_tx' => 'one of the defined rates eg. 21', + 'sp.tva_tx' => '10', 'sp.price'=>"50", 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0', 'sp.default_vat_code' => '', - 'sp.delivery_time_days' => 'eg. 5', + 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.price' => "eg. 50.00", - 'sp.unitprice' => 'eg. 10', + 'sp.price' => "50.00", + 'sp.unitprice' => '10', // TODO Make this field not required and calculate it from price and qty - 'sp.remise_percent' => 'eg: 20' + 'sp.remise_percent' => '20' )); if ($conf->multicurrency->enabled) { $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', - 'sp.multicurrency_code'=>'eg: GBP', - 'sp.multicurrency_tx'=>'currency rate eg: 1.12345', - 'sp.multicurrency_unitprice'=>'cost per unit in supplier currency', + 'sp.multicurrency_code'=>'GBP', + 'sp.multicurrency_tx'=>'1.12345', + 'sp.multicurrency_unitprice'=>'', // TODO Make this field not required and calculate it from price and qty - 'sp.multicurrency_price'=>'cost for min quantity in supplier currency' + 'sp.multicurrency_price'=>'' )); } @@ -653,8 +671,8 @@ class modProduct extends DolibarrModules ); $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"PRODUCT_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", - 'pr.price'=>"100",'pr.price_ttc'=>"110", - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", + 'pr.price'=>"100", 'pr.price_ttc'=>"110", + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', 'pr.recuperableonly'=>'0', 'pr.date_price'=>'2013-04-10'); diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 605c48f0e6b..1a72d9c4463 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -141,19 +141,39 @@ class modService extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + $this->export_fields_array[$r]=array( + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", + 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", + 'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + //'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + 'p.duration'=>"Duration", + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.tva_tx'=>'VATRate','p.datec'=>'DateCreation','p.tms'=>'DateModification' + ); if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric')); + $this->export_TypeFields_array[$r]=array( + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", + 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + 'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean", + 'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date', + 'p.duration'=>"Duree", + ); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); @@ -211,7 +231,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) @@ -243,7 +263,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) @@ -255,8 +275,10 @@ class modService extends DolibarrModules $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array( 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' ); @@ -264,8 +286,10 @@ class modService extends DolibarrModules if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", 'p.datec'=>'Date','p.tms'=>'Date' ); @@ -274,7 +298,8 @@ class modService extends DolibarrModules $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r]=array( 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" @@ -290,55 +315,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; - } - - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) - { - // Exports virtual products - $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' - ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' - ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" - ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } } @@ -357,12 +334,109 @@ class modService extends DolibarrModules $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume", - 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", - 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' + 'p.ref' => "Ref*", + 'p.label' => "Label*", + 'p.fk_product_type' => "Type*", + 'p.tosell' => "OnSell*", + 'p.tobuy' => "OnBuy*", + 'p.description' => "Description", + 'p.url' => "PublicUrl", + 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', + 'p.accountancy_code_sell' => "ProductAccountancySellCode", + 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", + 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", + 'p.note_public' => "NotePublic", + 'p.note' => "NotePrivate", + 'p.weight' => "Weight", + 'p.weight_units' => "WeightUnits", + 'p.length' => "Length", + 'p.length_units' => "LengthUnit", + 'p.width' => "Width", + 'p.width_units' => "VolumeUnits", + 'p.height' => "Height", + 'p.height_units' => "HeightUnit", + 'p.surface' => "Surface", + 'p.surface_units' => "SurfaceUnit", + 'p.volume' => "Volume", + 'p.volume_units' => "VolumeUnits", + 'p.duration' => "Duration",//duration of service + 'p.finished' => 'Nature', + 'p.price' => "SellingPriceHT",//without + 'p.price_min' => "MinPrice", + 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", + 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.tva_tx' => 'VATRate', + 'p.datec' => 'DateCreation', + 'p.cost_price' => "CostPrice", ); - //if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning + 'p.pmp' => 'PMPValue',//weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + } + + $this->import_convertvalue_array[$r] = array( + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'weight', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.length_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.width_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.height_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.surface_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'surface', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.volume_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'volume', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); @@ -387,13 +461,82 @@ class modService extends DolibarrModules $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array( 'p.ref'=>'[^ ]', - 'p.tosell'=>'^[0|1]$', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly'=>'^[0|1]$' - ); - $import_sample=array('p.ref'=>"SERVICE_REF or id:123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); + // field order as per structure of table llx_product + $import_sample = array( + 'p.ref' => "PREF123456", + 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), + 'p.label' => "Product name in default language", + 'p.description' => "Product description in default language", + 'p.note_public' => "a public note (free text)", + 'p.note' => "a private note (free text)", + 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', + 'p.price' => "price ex-vat eg. 100", + 'p.price_min' => "price ex-vat eg. 100", + 'p.price_ttc' => "price inc-vat eg. 110", + 'p.price_min_ttc' => "price inc-vat eg. 110", + 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", + 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', + 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", + 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", + 'p.fk_product_type' => "0 (product) / 1 (service)", + 'p.duration' => "eg. 365d/12m/1y", + 'p.url' => 'link to product (no https)', + 'p.accountancy_code_sell' => "", + 'p.accountancy_code_sell_intra' => "", + 'p.accountancy_code_sell_export' => "", + 'p.accountancy_code_buy' => "", + 'p.weight' => "", + 'p.weight_units' => 'Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length' => "", + 'p.length_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width' => "", + 'p.width_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height' => "", + 'p.height_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface' => "", + 'p.surface_units' => 'Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume' => "", + 'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.finished' => '0 (raw material) / 1 (finished goods)' + ); + //clauses copied from import_fields_array + if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( + 'p.seuil_stock_alerte' => 'quantity for low-stock warning (empty for no warning)', + 'p.pmp' => '0 (default)', + 'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)' + )); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'user-editable, used for margin calculations only')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0 / 1 (French VAT NPR yes/no')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); + if (! empty($conf->global->PRODUCT_USE_UNITS)) { + $import_sample = array_merge( + $import_sample, + array( + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + ) + ); + + $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( + 'p.fk_unit' => array( + 'rule' => 'fetchidfromcodeorlabel', + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'dict' => 'DictionaryUnits' + ) + )); + } $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled @@ -445,12 +588,39 @@ class modService extends DolibarrModules 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); $this->import_examplevalues_array[$r]=array( - 'sp.fk_product'=>"SERVICE_REF or id:123456", - 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', - 'sp.price'=>"50", - 'sp.unitprice'=>'50', - 'sp.remise_percent'=>'0' + 'sp.fk_product' => "PRODUCT_REF or id:123456", + 'sp.fk_soc' => "My Supplier", + 'sp.ref_fourn' => "eg: XYZ-F123456", + 'sp.quantity' => "5", + 'sp.tva_tx' => 'one of the defined rates eg. 21', + 'sp.price'=>"50", + 'sp.unitprice'=>'50', + 'sp.remise_percent'=>'0', + 'sp.default_vat_code' => '', + 'sp.delivery_time_days' => 'eg. 5', + 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.price' => "eg. 50.00", + 'sp.unitprice' => 'eg. 10', + // TODO Make this field not required and calculate it from price and qty + 'sp.remise_percent' => 'eg: 20' + )); + if ($conf->multicurrency->enabled) + { + $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', + 'sp.multicurrency_code'=>'eg: GBP', + 'sp.multicurrency_tx'=>'currency rate eg: 1.12345', + 'sp.multicurrency_unitprice'=>'cost per unit in supplier currency', + // TODO Make this field not required and calculate it from price and qty + 'sp.multicurrency_price'=>'cost for min quantity in supplier currency' + )); + } + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); } From 23de8694fa77bd85b529bb4c63dd2e247ba6bd47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 12:37:01 +0200 Subject: [PATCH 58/77] Fix module files --- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 52 ++++++++++++------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index f9ab7347792..13e9816008e 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -356,7 +356,7 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product + $this->import_fields_array[$r]=array( 'p.ref' => "Ref*", 'p.label' => "Label*", 'p.fk_product_type' => "Type*", diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 1a72d9c4463..b21c954185a 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -479,12 +479,12 @@ class modService extends DolibarrModules 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', 'p.fk_country' => 'FR', - 'p.price' => "price ex-vat eg. 100", - 'p.price_min' => "price ex-vat eg. 100", - 'p.price_ttc' => "price inc-vat eg. 110", - 'p.price_min_ttc' => "price inc-vat eg. 110", + 'p.price' => "100", + 'p.price_min' => "100", + 'p.price_ttc' => "110", + 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -495,27 +495,27 @@ class modService extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( - 'p.seuil_stock_alerte' => 'quantity for low-stock warning (empty for no warning)', - 'p.pmp' => '0 (default)', - 'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)' + 'p.seuil_stock_alerte' => '', + 'p.pmp' => '0', + 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'user-editable, used for margin calculations only')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0 / 1 (French VAT NPR yes/no')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); @@ -590,34 +590,34 @@ class modService extends DolibarrModules $this->import_examplevalues_array[$r]=array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", - 'sp.ref_fourn' => "eg: XYZ-F123456", + 'sp.ref_fourn' => "XYZ-F123456", 'sp.quantity' => "5", - 'sp.tva_tx' => 'one of the defined rates eg. 21', + 'sp.tva_tx' => '10', 'sp.price'=>"50", 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0', 'sp.default_vat_code' => '', - 'sp.delivery_time_days' => 'eg. 5', + 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.price' => "eg. 50.00", - 'sp.unitprice' => 'eg. 10', + 'sp.price' => "50.00", + 'sp.unitprice' => '10', // TODO Make this field not required and calculate it from price and qty - 'sp.remise_percent' => 'eg: 20' + 'sp.remise_percent' => '20' )); if ($conf->multicurrency->enabled) { $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', - 'sp.multicurrency_code'=>'eg: GBP', - 'sp.multicurrency_tx'=>'currency rate eg: 1.12345', - 'sp.multicurrency_unitprice'=>'cost per unit in supplier currency', + 'sp.multicurrency_code'=>'GBP', + 'sp.multicurrency_tx'=>'1.12345', + 'sp.multicurrency_unitprice'=>'', // TODO Make this field not required and calculate it from price and qty - 'sp.multicurrency_price'=>'cost for min quantity in supplier currency' + 'sp.multicurrency_price'=>'' )); } From 7015e711050a3acb0855b1c5547059bb4f262af0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 12:53:32 +0200 Subject: [PATCH 59/77] FIX #12041 --- .../security/generate/modGeneratePassPerso.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index bccb1353087..3229aa1a616 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -206,7 +206,7 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * consecutive iterations of the same character + * Consecutive iterations of the same character * * @param string $password Password to check * @return int 0 if KO, >0 if OK @@ -214,8 +214,12 @@ class modGeneratePassPerso extends ModeleGenPassword public function consecutiveInterationSameCharacter($password) { $last = ""; + + if (empty($this->NbRepeat)) return 1; + $count = 0; $char = str_split($password); + foreach($char as $c) { if($c != $last) { $last = $c; From 91a922a454d7f806736dbd40952f1b862c6034a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 12:54:28 +0200 Subject: [PATCH 60/77] Update security.php --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 3a786f30a84..c4c8026e076 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -325,7 +325,7 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print '
    '; print '"; - print ''; + print ''; print ''; From 68a4ab87a2e4ae7089266341e383a9630f6b7ef0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 12:57:24 +0200 Subject: [PATCH 61/77] Fix can set min repeat to 0 for password --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index c4c8026e076..a945f917ec1 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -174,7 +174,7 @@ if ($action == 'maj_pattern') $explodePattern = explode(';', $pattern); $patternInError = false; - if($explodePattern[0] < 1 || $explodePattern[4] < 1){ + if($explodePattern[0] < 1 || $explodePattern[4] < 0){ $patternInError = true; } From 2bb55200f77b44ccb06b510e16bab0d85bddf306 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 13:46:13 +0200 Subject: [PATCH 62/77] Clean user card --- htdocs/langs/en_US/users.lang | 4 +- htdocs/theme/eldy/global.inc.php | 4 +- htdocs/theme/md/style.css.php | 4 +- htdocs/user/card.php | 78 ++++++++++++++++---------------- 4 files changed, 44 insertions(+), 46 deletions(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index d8758ac9dc0..0aa4bc6c929 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -110,6 +110,6 @@ UserLogged=User logged DateEmployment=Employment Start Date DateEmploymentEnd=Employment End Date CantDisableYourself=You can't disable your own user record -UserExpenseValidator=Expense report validator -UserHolidayValidator=Leave request validator +ForceUserExpenseValidator=Force expense report validator +ForceUserHolidayValidator=Force leave request validator ValidatorIsSupervisorByDefault=By default, the supervisor is the validator for expense reports and leave requests diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 904f6a197d5..4b0ccd45fd5 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -834,7 +834,7 @@ table[summary="list_of_modules"] .fa-cog { .minheight20 { min-height: 20px; } .minheight40 { min-height: 40px; } .titlefieldcreate { width: 20%; } -.titlefield { width: 25%; } +.titlefield { /* width: 25%; */ width: 250px; } .titlefieldmiddle { width: 50%; } .imgmaxwidth180 { max-width: 180px; } .imgmaxheight50 { max-height: 50px; } @@ -852,7 +852,7 @@ table[summary="list_of_modules"] .fa-cog { /* Force values for small screen 1400 */ @media only screen and (max-width: 1400px) { - .titlefield { width: 30% !important; } + .titlefield { /* width: 30% !important; */ } .titlefieldcreate { width: 30% !important; } .minwidth50imp { min-width: 50px !important; } .minwidth75imp { min-width: 75px !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index dcbbbd1cf4f..a17a33bd898 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1003,7 +1003,7 @@ table[summary="list_of_modules"] .fa-cog { .minheight20 { min-height: 20px; } .minheight40 { min-height: 40px; } .titlefieldcreate { width: 20%; } -.titlefield { width: 25%; } +.titlefield { /* width: 25%; */ width: 250px; } .titlefieldmiddle { width: 50%; } .imgmaxwidth180 { max-width: 180px; } @@ -1011,7 +1011,7 @@ table[summary="list_of_modules"] .fa-cog { /* Force values for small screen 1400 */ @media only screen and (max-width: 1400px) { - .titlefield { width: 30% !important; } + .titlefield { /* width: 30% !important; */ } .titlefieldcreate { width: 30% !important; } .minwidth50imp { min-width: 50px !important; } .minwidth75imp { min-width: 75px !important; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3deb0cf870c..bdef850fa6b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -973,7 +973,7 @@ if ($action == 'create' || $action == 'adduserldap') if(!empty($conf->expensereport->enabled)) { print ''; print ''; print ''; - print ''; - // Default warehouse - if (! empty($conf->stock->enabled)) + if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; } + // Position/Job + print ''; + print ''; + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { @@ -1594,12 +1594,11 @@ else // Expense report validator print ''; print ''; print ''; print "\n"; - // Position/Job - print ''; - print ''; - print ''."\n"; - // Default warehouse - if (! empty($conf->stock->enabled)) + if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; $warehousestatic=new Entrepot($db); @@ -1638,7 +1631,12 @@ else print ''; } - //$childids = $user->getAllChildIds(1); + // Position/Job + print ''; + print ''; + print ''."\n"; + + //$childids = $user->getAllChildIds(1); if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) @@ -2305,7 +2303,7 @@ else // Expense report validator print ''; print ''; print ''; - print ''; - // Default warehouse - if (! empty($conf->stock->enabled)) + if (! empty($conf->stock->enabled) && ! empty($conf->global->USER_DEFAULT_WAREHOUSE)) // TODO What is goal of this. How it is used ? { print ''; } - if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) + // Position/Job + print ''; + print ''; + + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { $langs->load("salaries"); From 00df21cf17f894d39a03e49fff4e0f18990a09ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 13:48:09 +0200 Subject: [PATCH 63/77] Trans --- htdocs/langs/en_US/users.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 0aa4bc6c929..8780e7d2c0d 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -112,4 +112,4 @@ DateEmploymentEnd=Employment End Date CantDisableYourself=You can't disable your own user record ForceUserExpenseValidator=Force expense report validator ForceUserHolidayValidator=Force leave request validator -ValidatorIsSupervisorByDefault=By default, the supervisor is the validator for expense reports and leave requests +ValidatorIsSupervisorByDefault=By default, the validator is the supervisor of the user. Keep empty to keep this behaviour. From 1a32a3b7f123210719283e4e9fc204716cc9dd41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 14:21:22 +0200 Subject: [PATCH 64/77] Update dav.php --- htdocs/admin/dav.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 53971743b20..90b82421702 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -168,9 +168,6 @@ print "
    "; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -if ($_SERVER['HTTPS'] == 'on' || $_SERVER['REQUEST_SCHEME'] == 'https') { - $urlwithroot = str_replace('http://', 'https://', $urlwithroot); -} //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current From a9c844460bae8f5465cc1fe3e6f434f80de7aab1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 14:39:29 +0200 Subject: [PATCH 65/77] Debug use of widget on Accounting home page --- htdocs/accountancy/index.php | 41 ++++++++++++++++++----------- htdocs/core/class/infobox.class.php | 7 +++-- htdocs/langs/en_US/accountancy.lang | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 36ebaf07c94..4eab81ea49f 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -64,26 +64,33 @@ if ($conf->accounting->enabled) { $step = 0; - $resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) + $resultboxes=FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) - print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy'); + $helpisexpanded = empty($resultboxes['boxactivated']); // If there is no widget, the tooltip help is expanded by default. + $showtutorial = ''; - print ''; + if (! $helpisexpanded) + { + $showtutorial = ''; - print ''; + $showtutorial .= ''; + } - print '
    '; // hideobject is to start hidden + + print load_fiche_titre($langs->trans("AccountancyArea"), $showtutorial . $resultboxes['selectboxlist'], 'accountancy'); + + print '
    '; // hideobject is to start hidden print "
    \n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
    \n"; print "
    \n";print "
    \n"; @@ -201,6 +208,8 @@ if ($conf->accounting->enabled) print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64+$step))."
    \n"; print "
    \n"; + print '
    '; + print '
    '; print '
    '; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 0c918783e39..a187e58cac1 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -39,7 +39,10 @@ class InfoBox if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) { - return array(0 => 'Home'); + return array( + 0 => 'Home', + 27 => 'Accountancy Home' + ); } else { @@ -71,7 +74,7 @@ class InfoBox 24 => 'expensereportindex', 25 => 'mailingindex', 26 => 'opensurveyindex', - 27 => 'accountancyindex' + 27 => 'Accountancy Home' ); } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 30b060fb4d3..a76e79aa701 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -257,7 +257,7 @@ ListOfProductsWithoutAccountingAccount=List of products not bound to any account ChangeBinding=Change the binding Accounted=Accounted in ledger NotYetAccounted=Not yet accounted in ledger -ShowFAQ=Show FAQ +ShowTutorial=Show Tutorial ## Admin ApplyMassCategories=Apply mass categories From b9a92546b6edc24eddc1407fb5f3b13150f398f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 15:20:52 +0200 Subject: [PATCH 66/77] Update card.php --- htdocs/contact/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 1a271918b61..0e73d0a8786 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -476,7 +476,7 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res<0) { - setEventMessage($this->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } // Show tabs From 240785922e778d317adced723a4e543fc082bc58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 15:23:30 +0200 Subject: [PATCH 67/77] Update interface_90_modSociete_ContactRoles.class.php --- .../triggers/interface_90_modSociete_ContactRoles.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index e9bf9d38a50..f43c127576c 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -103,7 +103,7 @@ class InterfaceContactRoles extends DolibarrTriggers } if($nb > 0) { - setEventMessage($langs->trans('ContactAddedAutomatically', $nb)); + setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs'); } } } From 3a15485e9962fe9dcd783c574d44e745f5870db4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 15:27:23 +0200 Subject: [PATCH 68/77] Update interface_90_modSociete_ContactRoles.class.php --- .../triggers/interface_90_modSociete_ContactRoles.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php index f43c127576c..13eb44d4eee 100644 --- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php +++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php @@ -73,7 +73,7 @@ class InterfaceContactRoles extends DolibarrTriggers $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc); - if(!empty($socid) && $socid != '-1') { + if (! empty($socid) && $socid > 0) { global $db, $langs; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactdefault = new Contact($this->db); From c83f40fc7e48ff82fc538fb61b2d89e847827a5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 15:42:37 +0200 Subject: [PATCH 69/77] Debug contact by default --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 4 +++- htdocs/contact/card.php | 14 +++++++------- htdocs/langs/en_US/companies.lang | 1 + 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 987e81ff94c..92267d97033 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1595,7 +1595,7 @@ if ($action == 'create') if ($socid > 0) { - // Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice. + // Contacts (ask contact only if thirdparty already defined). print "
    '; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3a6f4f67353..968607ed660 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -70,6 +70,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility @@ -1646,8 +1647,9 @@ if ($action == 'create' && $usercancreate) // Contact of order if ($socid > 0) { + // Contacts (ask contact only if thirdparty already defined). print "'; // Ligne info remises tiers diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index e7522a1292b..4139176e84e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -371,7 +371,7 @@ if (empty($reshook)) $object->priv = GETPOST("priv", 'int'); $object->note_public = GETPOST("note_public", 'none'); $object->note_private = GETPOST("note_private", 'none'); - $object->roles = GETPOST("roles", 'array'); + $object->roles = GETPOST("roles", 'array'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -725,9 +725,9 @@ else print ""; } - //Role + // Contact by default if (!empty($socid)) { - print ''; + print ''; print '"; } - //Role + // Contact by default if (!empty($object->socid)) { - print ''; + print ''; print ''; @@ -1206,7 +1206,7 @@ else print $object->getCivilityLabel(); print ''; - // Role + // Job / position print ''; // Email @@ -1257,7 +1257,7 @@ else } if (!empty($object->socid)) { - print ''; + print ''; print ''; diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 532fbf14cb7..a4ab22d47c5 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -298,6 +298,7 @@ FromContactName=Name: NoContactDefinedForThirdParty=No contact defined for this third party NoContactDefined=No contact defined DefaultContact=Default contact/address +ContactByDefaultFor=Default contact/address for AddThirdParty=Create third party DeleteACompany=Delete a company PersonalInformations=Personal data From 297313e7de17764efdd890659893e61dd7c0cb8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 16:01:36 +0200 Subject: [PATCH 70/77] CSS --- htdocs/core/lib/company.lib.php | 2 +- htdocs/societe/agenda.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 4ee95039ce0..36657d48dbc 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1629,7 +1629,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } // Ref - $out.='\n"; if (! $i) $totalarray['nbfield']++; } @@ -1088,7 +1087,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } - // Date cloture + // Date cloture if (! empty($arrayfields['p.date_cloture']['checked'])) { print '
    '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
    ('.$langs->trans("Everybody").')
    '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
    ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
    '.$langs->trans("HourStart").''.$langs->trans("TimeSpent").'
    ('.$langs->trans("Everybody").')
    '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
    ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
    '.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to $restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); @@ -645,8 +645,8 @@ if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['after elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; -print ''.$langs->trans("Duration").''.$langs->trans("Note").''.$langs->trans("Duration").''.$langs->trans("Note").'
    '.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("ProgressDeclared").''.$langs->trans("TimeSpent").''.$langs->trans("TimeSpentByYou").''.$langs->trans("TimeSpentByUser").''.$langs->trans("TimeSpent").'
    ('.$langs->trans("Everybody").')
    '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
    ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
    '.$langs->trans("TimeSpent").'
    ('.$langs->trans("Everybody").')
    '.$langs->trans("TimeSpent").($usertoprocess->firstname?'
    ('.dol_trunc($usertoprocess->firstname, 10).')':'').'
    '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
    '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
    '.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
    '.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
    '.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string($object->width_units, "size"):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string(0, "size", $object->width_units):''; print '
    '.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string($object->depth_units, "size"):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string(0, "size", $object->depth_units):''; print '
    '; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units, "weight"); + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "weight", $lines[$i]->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume"); + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "volume", $lines[$i]->volume_units); else print ' '; print '
    ' . $langs->trans("NbIteConsecutive")."
    '; - $text = $langs->trans("UserExpenseValidator"); + $text = $langs->trans("ForceUserExpenseValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; @@ -986,7 +986,7 @@ if ($action == 'create' || $action == 'adduserldap') if(!empty($conf->holiday->enabled)) { print '
    '; - $text = $langs->trans("UserHolidayValidator"); + $text = $langs->trans("ForceUserHolidayValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; @@ -1231,20 +1231,20 @@ if ($action == 'create' || $action == 'adduserldap') // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) - // Position/Job - print '
    '.$langs->trans("PostOrFunction").''; - print ''; - print '
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); print '
    '.$langs->trans("PostOrFunction").''; + print ''; + print '
    '; - $text = $langs->trans("UserExpenseValidator"); + $text = $langs->trans("ForceUserExpenseValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (empty($object->fk_user_expense_validator)) print $langs->trans("None"); - else { + if (! empty($object->fk_user_expense_validator)) { $evuser=new User($db); $evuser->fetch($object->fk_user_expense_validator); print $evuser->getNomUrl(1); @@ -1609,12 +1608,11 @@ else // Holiday request validator print '
    '; - $text = $langs->trans("UserHolidayValidator"); + $text = $langs->trans("ForceUserHolidayValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; - if (empty($object->fk_user_holiday_validator)) print $langs->trans("None"); - else { + if (! empty($object->fk_user_holiday_validator)) { $hvuser=new User($db); $hvuser->fetch($object->fk_user_holiday_validator); print $hvuser->getNomUrl(1); @@ -1622,13 +1620,8 @@ else print '
    '.$langs->trans("PostOrFunction").''.$object->job.'
    '.$langs->trans("PostOrFunction").''.$object->job.'
    '; - $text = $langs->trans("UserExpenseValidator"); + $text = $langs->trans("ForceUserExpenseValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; @@ -2325,7 +2323,7 @@ else // Holiday request validator print '
    '; - $text = $langs->trans("UserHolidayValidator"); + $text = $langs->trans("ForceUserHolidayValidator"); print $form->textwithpicto($text, $langs->trans("ValidatorIsSupervisorByDefault"), 1, 'help'); print ''; @@ -2689,22 +2687,8 @@ else // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) - // Position/Job - print '
    '.$langs->trans("PostOrFunction").''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->job; - } - print '
    '.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1); @@ -2712,7 +2696,21 @@ else print '
    '.$langs->trans("PostOrFunction").''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->job; + } + print '
    " . $langs->trans("DefaultContact") . ''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '
    " . $langs->trans("DefaultContact") . ''; - $form->select_contacts($soc->id, $setcontact, 'contactid', 1, $srccontactslist, '', 1); + $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); print '
    ' . $langs->trans("Role") . '
    ' . $langs->trans("ContactByDefaultFor") . ''; $contactType = $object->listeTypeContacts('external', '', 1); print $form->multiselectarray('roles', $contactType); @@ -1050,9 +1050,9 @@ else print "
    ' . $langs->trans("Role") . '
    ' . $langs->trans("ContactByDefaultFor") . ''; print $formcompany->showRoles("roles", $object, 'edit', $object->roles); print '
    '.$langs->trans("PostOrFunction").''.$object->poste.'
    ' . $langs->trans("Roles") . '
    ' . $langs->trans("ContactByDefaultFor") . ''; print $formcompany->showRoles("roles", $object, 'view'); print '
    '; + $out.=''; if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { $out.=''.img_object($langs->trans("ShowEMailing"), "email").' '; $out.=$histo[$key]['id']; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index af0d7670141..231174a0afa 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2006-2015 Laurent Destailleur + * Copyright (C) 2006-2019 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015 Marcos García diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4b0ccd45fd5..bfe548fb0fe 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1442,7 +1442,7 @@ img.photorefnoborder { } .trextrafieldseparator td { /* border-bottom: 2px solid rgb() !important; */ - border-bottom: 2px dashed rgb() !important; + border-bottom: 2px solid rgb() !important; } .tdhrthin { From 16eeeecb9ae48edffa67e2eaf36ce388b9eb55d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 17:08:08 +0200 Subject: [PATCH 71/77] Trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fed096cf024..afce2e4fa34 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -526,7 +526,7 @@ Module50Desc=Management of Products Module51Name=Mass mailings Module51Desc=Mass paper mailing management Module52Name=Stocks -Module52Desc=Stock management (for products only) +Module52Desc=Stock management Module53Name=Services Module53Desc=Management of Services Module54Name=Contracts/Subscriptions From 07d1a3fe8bcac4c0a0d43ba7634a2a3920944331 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 18:17:22 +0200 Subject: [PATCH 72/77] css --- htdocs/comm/propal/list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index f81949fb11d..919ad77168d 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1013,9 +1013,8 @@ if ($resql) // Author if (! empty($arrayfields['u.login']['checked'])) { - print ''; + print ''; if ($userstatic->id) print $userstatic->getLoginUrl(1); - else print ' '; print "'; From 51ef2cd20af2670a51fcbc44e4af2c0754f22390 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 20:20:06 +0200 Subject: [PATCH 73/77] FIX #12058 --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index bd6b88d51ff..d503c1bc71d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1562,7 +1562,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $savlabel=$event->label?$event->label:$event->libelle; $event->label=$titletoshow; $event->libelle=$titletoshow; - print $event->getNomUrl(0, $maxnbofchar, 'cal_event', '', 0, 1); + print $event->getNomUrl(0, $maxnbofchar, 'cal_event', '', 0, 0); $event->label=$savlabel; $event->libelle=$savlabel; } From c68de09ba9533f369be39fed3a5df34600309665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 7 Oct 2019 20:27:51 +0200 Subject: [PATCH 74/77] use $this->db in box --- .../box_accountancy_last_manual_entries.php | 20 +++++++++---------- .../box_accountancy_suspense_account.php | 11 +++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 1f2b8d634d9..2c788b66b71 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -71,13 +71,11 @@ class box_accountancy_last_manual_entries extends ModeleBoxes */ public function loadBox($max = 5) { - global $user, $langs, $db, $conf; - - $this->max = $max; + global $user, $langs, $conf; include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($db); + $bookkeepingstatic = new BookKeeping($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max)); @@ -92,17 +90,17 @@ class box_accountancy_last_manual_entries extends ModeleBoxes $sql.= " WHERE b.fk_doc = 0"; $sql.= " AND b.entity = ".$conf->entity; $sql.= " ORDER BY b.piece_num DESC "; - $sql.= $db->plimit($max, 0); + $sql.= $this->db->plimit($max, 0); - $result = $db->query($sql); + $result = $this->db->query($sql); if ($result) { - $num = $db->num_rows($result); + $num = $this->db->num_rows($result); $line = 0; while ($line < $num) { - $objp = $db->fetch_object($result); - $date = $db->jdate($objp->date_movement); + $objp = $this->db->fetch_object($result); + $date = $this->db->jdate($objp->date_movement); $journal = $objp->code_journal; $label = $objp->label_operation; $amount = $objp->montant; @@ -144,12 +142,12 @@ class box_accountancy_last_manual_entries extends ModeleBoxes if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedManualEntries")); - $db->free($result); + $this->db->free($result); } else { $this->info_box_contents[0][0] = array( 'td' => '', 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), + 'text' => ($this->db->error().' sql='.$sql), ); } } else { diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index dd2d9a17695..9740de82fbc 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -37,7 +37,7 @@ class box_accountancy_suspense_account extends ModeleBoxes public $boxlabel="BoxSuspenseAccount"; public $depends = array("accounting"); - /** + /** * @var DoliDB Database handler. */ public $db; @@ -70,11 +70,11 @@ class box_accountancy_suspense_account extends ModeleBoxes */ public function loadBox() { - global $user, $langs, $db, $conf; + global $user, $langs, $conf; include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - $bookkeepingstatic = new BookKeeping($db); + $bookkeepingstatic = new BookKeeping($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount")); @@ -88,10 +88,11 @@ class box_accountancy_suspense_account extends ModeleBoxes $sql .= " WHERE b.numero_compte = ". $suspenseAccount; $sql .= " AND b.entity = " . $conf->entity; - $result = $db->query($sql); + $result = $this->db->query($sql); + $nbSuspenseAccount = 0; if ($result) { - $obj=$db->fetch_object($result); + $obj=$this->db->fetch_object($result); $nbSuspenseAccount = $obj->nb_suspense_account; } From 539f4355c394af0b7d2fc9e16cb8d87a1097f4ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 20:48:44 +0200 Subject: [PATCH 75/77] Try to fix stickler --- dev/namespacemig/aaa.class.php | 10 +++++++++- dev/namespacemig/bbb.class.php | 12 +++++++++--- htdocs/core/modules/modSyslog.class.php | 6 +++++- htdocs/core/tpl/objectline_create.tpl.php | 6 +++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dev/namespacemig/aaa.class.php b/dev/namespacemig/aaa.class.php index 7b165349472..d7578b78e40 100644 --- a/dev/namespacemig/aaa.class.php +++ b/dev/namespacemig/aaa.class.php @@ -2,10 +2,14 @@ namespace Dolibarr; - global $globalaaa; $globalaaa = 'globalaaa'; +/** + * faaa + * + * @return string + */ function faaa() { return 'faaa'; @@ -15,6 +19,10 @@ class Aaa { const AAA='aaa'; + /** + * do + * @return void + */ public function do() { echo 'doaaa'."\n"; diff --git a/dev/namespacemig/bbb.class.php b/dev/namespacemig/bbb.class.php index 0fb6fd3d7ae..f68b3b2f36c 100644 --- a/dev/namespacemig/bbb.class.php +++ b/dev/namespacemig/bbb.class.php @@ -1,11 +1,12 @@ rights_class = 'syslog'; // Cronjobs + $comment = 'Compress and archive log files. The number of versions to keep is defined into the setup of module. '; + $comment.= 'Warning: Main application cron script must be run with same account than your web server to avoid to get log files with different owner than required by web server.'; + $comment.= 'Another solution is to set web server Operating System group as the group of directory documents and set GROUP permission "rws" on this directory so log files will always have the group and permissions of the web server Operating System group.'; + $this->cronjobs = array( 0 => array( 'label' => 'CompressSyslogs', @@ -92,7 +96,7 @@ class modSyslog extends DolibarrModules 'objectname' => 'Utils', 'method' => 'compressSyslogs', 'parameters' => '', - 'comment' => 'Compress and archive log files. The number of versions to keep is defined into the setup of module. Warning: Main application cron script must be run with same account than your web server to avoid to get log files with different owner than required by web server. Another solution is to set web server Operating System group as the group of directory documents and set GROUP permission "rws" on this directory so log files will always have the group and permissions of the web server Operating System group', + 'comment' => $comment, 'frequency' => 1, 'unitfrequency' => 3600 * 24, 'priority' => 50, diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 462af9173c1..876863432be 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -853,9 +853,13 @@ function setforpredef() { jQuery("#prod_entry_mode_predef").prop('checked',true).change(); global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").val('').hide(); + + jQuery("#price_ht").val('').show(); + jQuery("#multicurrency_price_ht").val('').show(); jQuery("#price_ht").val(''); - jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); + jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); jQuery('#trlinefordates, .divlinefordates').show(); From b7e6ee7eea1fff446aa12994c7aaa1e063905832 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 20:55:54 +0200 Subject: [PATCH 76/77] css --- htdocs/theme/eldy/global.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index bfe548fb0fe..7dcac4d68ba 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2068,8 +2068,8 @@ img.userphoto { /* size for user photo in lists */ } img.userphotosmall { /* size for user photo in lists */ border-radius: 6px; - width: 12px; - height: 12px; + width: 1em; + height: 1em; background-size: contain; vertical-align: middle; background-color: #FFF; From 99da69fb69f4bd02f79aa5e94f6812437c91912c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Oct 2019 21:01:52 +0200 Subject: [PATCH 77/77] NEW Can edit the price of predefined product during adding in documents --- htdocs/core/tpl/objectline_create.tpl.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 876863432be..7f860586909 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -677,7 +677,7 @@ jQuery(document).ready(function() { jQuery('#trlinefordates').show(); global->MAIN_EDIT_PREDEF_PRICEHT)) + if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> // get the HT price for the product and display it @@ -851,12 +851,12 @@ function setforpredef() { jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> - jQuery("#price_ht").val('').hide(); - jQuery("#multicurrency_price_ht").val('').hide(); - + global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> jQuery("#price_ht").val('').show(); jQuery("#multicurrency_price_ht").val('').show(); + + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").val('').hide(); jQuery("#price_ht").val(''); jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide();