diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index ddba2ea6fd9..2e49327ae1d 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -171,6 +171,7 @@ then cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" mkdir -p "$documentdir/ecm/Administrative documents" mkdir -p "$documentdir/ecm/Images" + rm -f "$documentdir/doctemplates/"*/index.html echo cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" else diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5e9cbb07ca5..c352f5dc944 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -35,6 +35,7 @@ class AdherentType extends CommonObject public $table_element = 'adherent_type'; public $element = 'adherent_type'; public $picto = 'group'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string @@ -307,7 +308,7 @@ class AdherentType extends CommonObject $sql = "SELECT rowid, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('adherent').")"; + $sql.= " WHERE entity IN (".getEntity('member_type').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 26d3d115f75..f2dfba0367a 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; + $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a04b1df5786..fd418756bd6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -65,7 +65,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; -$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('member_type').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index a01cc379b3c..fc30d6f1ae2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -574,7 +574,7 @@ if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titr include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 142fdb300e2..48df382181d 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -216,7 +216,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index bc48feb076f..dd90774a05b 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -163,8 +163,6 @@ foreach ($modulesdir as $dir) $modules[$i] = $objMod; $filename[$i]= $modName; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { if (!is_array($familyinfo)) $familyinfo=array(); @@ -180,13 +178,11 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -240,7 +236,6 @@ foreach($orders as $tmpkey => $tmpvalue) $i++; } $value = $orders[$key]; -$special = $objMod->special; $tab=explode('_',$value); $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3]; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ee17e647863..db8251d0562 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -358,8 +358,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $modules[$modName] = $objMod; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { $familyinfo = array_merge($familyinfo, $objMod->familyinfo); @@ -374,8 +372,6 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - // Add list of warnings to show into arrayofwarnings and arrayofwarningsext if (! empty($objMod->warnings_activation)) { @@ -390,7 +386,7 @@ foreach ($modulesdir as $dir) $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -531,12 +527,9 @@ if ($mode == 'common') $objMod = $modules[$modName]; $dirofmodule = $dirmod[$key]; - $special = $objMod->special; - - //print $objMod->name." - ".$key." - ".$objMod->special.' - '.$objMod->version."
"; + //print $objMod->name." - ".$key." - ".$objMod->version."
"; //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev') - if (($special >= 4 && $mode != 'expdev') - || ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental')) continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab if (! $objMod->getName()) { @@ -741,12 +734,12 @@ if ($mode == 'common') if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs)) { $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1); - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { $urltouse=$urlpage; - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } } @@ -754,11 +747,11 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } else diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5b824d8c959..ada86667f44 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -715,11 +715,12 @@ class Categorie extends CommonObject } } - // Save object we want to link category to into category instance to provide information to trigger - $this->linkto=$obj; + // Call trigger - $result=$this->call_trigger('CATEGORY_LINK',$user); + $this->linkto=$obj; // Deprecated. Save object we want to link category to into category instance to provide information to trigger + $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_LINK',$user); if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 506b0c6fa8d..aab95264a57 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -189,9 +189,11 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 380edc5a472..02c1b0e65bb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1228,9 +1228,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2b714bbeff8..850fa969bbb 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1316,7 +1316,7 @@ class Propal extends CommonObject function fetch($rowid,$ref='') { - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1362,6 +1362,7 @@ class Propal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 5de43a75b9d..a47625e100b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -614,7 +614,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 21975439872..2cb899fcfe6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1268,9 +1268,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b7ba839b144..92e04e1672b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1567,7 +1567,7 @@ class Commande extends CommonOrder // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; + $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; @@ -1597,12 +1597,14 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - $obj = $this->db->fetch_object($result); - if ($obj) - { - $this->id = $obj->rowid; + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->ref_customer = $obj->ref_client; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index fe8461c3a41..793fb2cf708 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -701,7 +701,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5681b0c339c..969f4d532cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2112,9 +2112,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5a3f9cb0048..c8f5c25e1e8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1237,7 +1237,7 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.datef as df, f.date_pointoftax'; @@ -1274,6 +1274,8 @@ class Facture extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->facnumber; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; @@ -3840,6 +3842,7 @@ class Facture extends CommonInvoice // Initialize parameters $this->id=0; + $this->entity = 1; $this->ref = 'SPECIMEN'; $this->specimen=1; $this->socid = 1; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index f869c01aa53..43d28c9abbd 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -444,9 +444,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 5914f2f06e9..bacaddcffd4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -862,7 +862,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e27bbfb7655..3b7ab5ae49b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -880,7 +880,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0b84b05b6fd..0d5262ac66b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -316,9 +316,10 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function closeAll(User $user, $notrigger=0) + function closeAll(User $user, $notrigger=0, $comment='') { $this->db->begin(); @@ -337,7 +338,7 @@ class Contrat extends CommonObject $contratline->date_cloture=$now; $contratline->fk_user_cloture=$user->id; $contratline->statut='5'; - $result=$contratline->close_line($user, $now); + $result=$contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { $error++; @@ -3140,9 +3141,10 @@ class ContratLigne extends CommonObjectLine * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '') + function close_line($user, $date_end, $comment = '', $notrigger=0) { global $langs, $conf; @@ -3164,15 +3166,19 @@ class ContratLigne extends CommonObjectLine $sql .= " WHERE rowid = " . $this->id . " AND statut = 4"; $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - return -1; + if ($resql) + { + if (! $notrigger) + { + // Call trigger + $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } + // End call triggers } - // End call triggers $this->db->commit(); return 1; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b08993acf8a..fae976dec80 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -46,7 +46,7 @@ if (! empty($massaction) && count($toselect) < 1) $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && count($toselect) > $maxformassaction) +if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $error++; diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 25fa257d098..e5819f0f14c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -88,7 +88,7 @@ class box_members extends ModeleBoxes $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql.= " t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity = ".$conf->entity; + $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c9c250ee1fa..f5a16aa540b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -316,6 +316,14 @@ abstract class CommonDocGenerator 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), ); + + foreach($conf->global as $key => $val) + { + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval = $val; + $array_other['__['.$key.']__'] = $newval; + } + return $array_other; } @@ -345,17 +353,19 @@ abstract class CommonDocGenerator $sumcreditnote = $object->getSumCreditNotesUsed(); } + $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); + $resarray=array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>$object->ref_client, - $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur)?$object->ref_fournisseur:''), + $array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, // Dates - $array_key.'_hour'=>dol_print_date($object->date,'hour'), - $array_key.'_date'=>dol_print_date($object->date,'day'), - $array_key.'_date_rfc'=>dol_print_date($object->date,'dayrfc'), + $array_key.'_hour'=>dol_print_date($date,'hour'), + $array_key.'_date'=>dol_print_date($date,'day'), + $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f69e842ec81..fd221649141 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4116,6 +4116,7 @@ abstract class CommonObject * @param int $hideref 1 to hide product reference. 0 by default * @param null|array $moreparams Array to provide more information * @return int >0 if OK, <0 if KO + * @see addFileIntoDatabaseIndex */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null) { @@ -4354,6 +4355,7 @@ abstract class CommonObject /** * Build thumb + * @TODO Move this into files.lib.php * * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void @@ -4532,7 +4534,7 @@ abstract class CommonObject if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { // we can add this attribute to object - if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) + if (! empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) { //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); $this->array_options["options_".$key]=$this->db->jdate($value); @@ -4629,10 +4631,10 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeLabel = $extrafields->attribute_label[$attributeKey]; - $attributeParam = $extrafields->attribute_param[$attributeKey]; - $attributeRequired = $extrafields->attribute_required[$attributeKey]; + $attributeType = $extrafields->attributes[$this->table_element]['type'][$attributeKey]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; if ($attributeRequired) { @@ -4665,7 +4667,43 @@ abstract class CommonObject $this->array_options[$key] = null; } break;*/ - case 'price': + case 'password': + $algo=''; + if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) + { + // If there is an encryption choice, we use it to crypt data before insert + $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + if ($algo != '') + { + //global $action; // $action may be 'create', 'update', 'update_extras'... + //var_dump($action); + //var_dump($this->oldcopy);exit; + if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value + { + //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); + if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + else + { + // var_dump($algo); + $newvalue = dol_hash($this->array_options[$key], $algo); + $new_array_options[$key] = $newvalue; + } + } + else + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + } + } + else // Common usage + { + $new_array_options[$key] = $this->array_options[$key]; + } + break; + case 'price': $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': @@ -4723,7 +4761,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -4731,8 +4769,8 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + // Add field of attribute + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) { if ($new_array_options[$key] != '') { @@ -4781,7 +4819,7 @@ abstract class CommonObject * Update an exta field value for the current object. * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * - * @param string $key Key of the extrafield + * @param string $key Key of the extrafield (without starting 'options_') * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK @@ -4806,9 +4844,12 @@ abstract class CommonObject $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); $value=$this->array_options["options_".$key]; - $attributeType = $extrafields->attribute_type[$key]; - $attributeLabel = $extrafields->attribute_label[$key]; - $attributeParam = $extrafields->attribute_param[$key]; + + $attributeType = $extrafields->attributes[$this->table_element]['type'][$key]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + switch ($attributeType) { case 'int': @@ -4838,7 +4879,7 @@ abstract class CommonObject $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'link': - $param_list=array_keys($attributeParam ['options']); + $param_list=array_keys($attributeParam['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee165ac6808..db0e7f4284a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -234,7 +234,7 @@ class ExtraFields $lengthdb='11'; } elseif($type=='password') { $typedb='varchar'; - $lengthdb='50'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 84c37a1cf4f..2d66661c839 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2018 Juanjo Menent * * 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 @@ -194,9 +194,12 @@ class FormActions $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; - $buttontoaddnewevent = ''; - $buttontoaddnewevent.= $langs->trans("AddEvent"); - $buttontoaddnewevent.= ''; + if (! empty($conf->agenda->enabled)) + { + $buttontoaddnewevent = ''; + $buttontoaddnewevent.= $langs->trans("AddEvent"); + $buttontoaddnewevent.= ''; + } print ''."\n"; print load_fiche_titre($title, $buttontoaddnewevent, '', 0, 0, '', $morehtmlright); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 922980f62dd..67497b4881b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -984,9 +984,10 @@ class FormMail extends Form * @param Translate $outputlangs Output lang object * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position * @param int $active 1=Only active template, 0=Only disabled, -1=All + * @param string $label Label of template * @return array array('topic'=>,'content'=>,..) */ - public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='') { $ret=array(); @@ -996,6 +997,7 @@ class FormMail extends Form $sql.= " AND entity IN (".getEntity('c_email_templates').")"; $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; + if ($label) $sql.=" AND label ='".$this->db->escape($label)."'"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 5f78fa0e283..cf1b7064a01 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -85,8 +85,6 @@ class FormMargin $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); - if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) - $line->pa_ht += $product->fourn_unitcharges; } // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { @@ -96,7 +94,7 @@ class FormMargin $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); $pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign $pa = $line->qty * $pa_ht; - + // calcul des marges if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 14f017bef55..69fe031459d 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -1027,6 +1027,7 @@ class Translate foreach($this->tab_translate as $code => $label) { $substitutionarray['lang_'.$code] = $label; + $substitutionarray['__('.$code.')__'] = $label; } return $substitutionarray; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 65cc2965bea..7991b711660 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1290,8 +1290,6 @@ function complete_elementList_with_modules(&$elementList) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; if (! empty($objMod->module_parts['contactelement'])) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 85d80f646d0..529f58dbbf1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -950,7 +950,7 @@ function dolCheckVirus($src_file) * Note: * - This function can be used only into a HTML page context. Use dol_move if you are outside. * - Test on antivirus is always done (if antivirus set). - * - Database of files is NOT updated. + * - Database of files is NOT updated (this is done by dol_add_file_process() that calls this function). * * @param string $src_file Source full path filename ($_FILES['field']['tmp_name']) * @param string $dest_file Target full path filename ($_FILES['field']['name']) @@ -1554,28 +1554,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio // Update table of files if ($donotupdatesession) { - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); - - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', 0); + if ($result < 0) { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content - $ecmfile->fullpath_orig = $TFile['name'][$i]; - $ecmfile->gen_or_uploaded = 'uploaded'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } + setEventMessages('FailedToAddFileIntoDatabaseIndex', '', 'warnings'); } } @@ -1679,6 +1661,114 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= } } + +/** + * Add a file into database index. + * Called by dol_add_file_process when uploading a file and on other cases. + * See also commonGenerateDocument that also add/update database index when a file is generated. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $fullpathorig Full path of origin for file (can be '') + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @param int $setsharekey Set also the share key + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0) +{ + global $db, $user; + + $result = 0; + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($dir.'/'.$file)); // MD5 of file content + $ecmfile->fullpath_orig = $fullpathorig; + $ecmfile->gen_or_uploaded = $mode; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + if ($setsharekey) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + + $result = $ecmfile->create($user); + if ($result < 0) + { + dol_syslog($ecmfile->error); + } + } + + return $result; +} + + +/** + * Delete files into database index using search criterias. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded') +{ + global $conf, $db, $user; + + $error = 0; + + if (empty($dir)) + { + dol_syslog("deleteFilesIntoDatabaseIndex: dir parameter can't be empty", LOG_ERR); + return -1; + } + + $db->begin(); + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + if (! $error) + { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; + $sql.= ' WHERE entity = '.$conf->entity; + $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; + if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; + if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; + + $resql = $db->query($sql); + if (!$resql) + { + $error++; + dol_syslog(__METHOD__ . ' ' . $db->lasterror(), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $db->rollback(); + return - 1 * $error; + } else { + $db->commit(); + return 1; + } +} + + /** * Convert an image file into another format. * This need Imagick php extension. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b83257419b6..3f194d3531a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5767,12 +5767,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } @@ -5945,7 +5947,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) if (dol_textishtml($text,1)) $msgishtml = 1; $keyfound = $reg[1]; - $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dda89a7425d..a367579e1cd 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -70,11 +70,11 @@ function dol_decode($chain) /** * Returns a hash of a string. - * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function. - * If constant MAIN_SECURITY_SALT is defined, we use it as a salt. + * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (recommanded value is 'password_hash') + * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ @@ -83,8 +83,10 @@ function dol_hash($chain, $type='0') global $conf; // No need to add salt for password_hash - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) - return password_hash($chain, PASSWORD_DEFAULT); + if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) + { + return password_hash($chain, PASSWORD_DEFAULT); + } // Salt value if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9ff01c9f5b5..8178af40c37 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -163,7 +163,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } $texte.='
'; } - + $texte.= ''; $texte.= ''; @@ -354,21 +354,22 @@ class doc_generic_order_odt extends ModelePDFCommandes { } - // Make substitutions into odt + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in order as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); + // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -392,30 +393,42 @@ class doc_generic_order_odt extends ModelePDFCommandes // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -468,7 +481,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index d99d43396bc..98b644c8cce 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -290,27 +290,40 @@ class doc_generic_contract_odt extends ModelePDFContract { $socobject=$object->thirdparty; } - // Make substitution - $substitutionarray=array( - '__FROM_NAME__' => $this->emetteur->name, - '__FROM_EMAIL__' => $this->emetteur->email, - '__TOTAL_TTC__' => $object->total_ttc, - '__TOTAL_HT__' => $object->total_ht, - '__TOTAL_VAT__' => $object->total_vat - ); - complete_substitutions_array($substitutionarray, $langs, $object); + + $object->fetch_optionals(); + + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object + $array_user=$this->get_substitutionarray_user($user,$outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in contract as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + + $substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $tmparray = $substitutionarray; + // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks // Line of free text $newfreetext=''; - $paramfreetext='contract_FREE_TEXT'; + $paramfreetext='CONTRACT_FREE_TEXT'; if (! empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); + $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); } + // Open and load template require_once ODTPHP_PATH.'odf.php'; try { @@ -344,24 +357,6 @@ class doc_generic_contract_odt extends ModelePDFContract { } - // Make substitutions into odt - $array_contract=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user,$outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in contract as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - - $tmparray = array_merge($array_contract,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); - complete_substitutions_array($tmparray, $outputlangs, $object); - $object->fetch_optionals(); - // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks foreach($tmparray as $key=>$value) { try { @@ -379,33 +374,46 @@ class doc_generic_contract_odt extends ModelePDFContract { } } + // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -456,7 +464,7 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 77a5677c003..9c45c135ac3 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -437,30 +437,42 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -511,7 +523,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 15d48694277..c236c9ad017 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -328,7 +328,15 @@ class pdf_standard extends ModeleExpenseReport $nextColumnPosX = $this->posxprojet; } - $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 10), 0, 'C'); + $expensereporttypecode = $object->lines[$i]->type_fees_code; + $expensereporttypecodetoshow = $outputlangs->transnoentities($expensereporttypecode); + if ($expensereporttypecodetoshow == $expensereporttypecode) + { + $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); + } + $expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); // 10 is too much + + $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); // Project if (! empty($conf->projet->enabled)) diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 79b848c5773..6d9d5172a7f 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -361,20 +361,22 @@ class doc_generic_invoice_odt extends ModelePDFFactures { } - // Make substitutions into odt + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_user=$this->get_substitutionarray_user($user,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); - $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array(); $array_other=$this->get_substitutionarray_other($outputlangs); - // retrieve contact information for use in invoice as contact_xxx tags - $array_thirdparty_contact = array(); - if ($usecontact) - $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + // retrieve contact information for use in invoice as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); + // Call the ODTSubstitution hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -401,30 +403,42 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Replace tags of lines try { - $listlines = $odfHandler->setSegment('lines'); - foreach ($object->lines as $line) - { - $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); - complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); - // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) - { - try - { - $listlines->setVars($key, $val, true, 'UTF-8'); - } - catch(OdfException $e) - { - } - catch(SegmentException $e) - { - } - } - $listlines->merge(); + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line,$outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); } - $odfHandler->mergeSegment($listlines); } catch(OdfException $e) { @@ -475,7 +489,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index a1674d6ab08..f71b6b925f0 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -127,7 +127,7 @@ class mailing_fraise extends MailingTargets $s.=' - + trans("Value"); ?> @@ -224,6 +225,7 @@ else textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"),1,0,'', 0, 2, 'helpvalue5')?> diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 82d6c746640..27b70e1b8cf 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -155,9 +155,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 0141fc1dea5..3b7a2d74818 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -180,9 +180,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a71ba9762b6..dd5db880bc9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -286,9 +286,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -1978,7 +1980,8 @@ else $i = 0;$total = 0; print ''; - print ''.$langs->trans('Piece').''; + print ''.$langs->trans('LineNb').''; + //print ''.$langs->trans('Piece').''; print ''.$langs->trans('Date').''; if (! empty($conf->projet->enabled)) print ''.$langs->trans('Project').''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').''; @@ -2001,15 +2004,21 @@ else foreach ($object->lines as &$line) { - $piece_comptable = $i + 1; + $numline = $i + 1; if ($action != 'editline' || $line->rowid != GETPOST('rowid')) { print ''; print ''; + print $numline; + print ''; + + /*print ''; print img_picto($langs->trans("Document"), "object_generic"); - print ' '.$piece_comptable.''; + print ' '.$piece_comptable.''; + print '';*/ + print ''.dol_print_date($db->jdate($line->date), 'day').''; if (! empty($conf->projet->enabled)) { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 3eddb02c28b..9b623d21279 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -741,9 +741,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 6f06a6778fd..c6f0c8bb446 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -114,9 +114,11 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1ae96927ee6..c4792edac4c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -218,7 +218,7 @@ class CommandeFournisseur extends CommonOrder // Check parameters if (empty($id) && empty($ref)) return -1; - $sql = "SELECT c.rowid, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; + $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; $sql.= " c.localtax1, c.localtax2, "; $sql.= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; @@ -253,6 +253,8 @@ class CommandeFournisseur extends CommonOrder } $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; @@ -2964,7 +2966,58 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } + }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) + {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) + + $close=0; + + if( count($diff_array) > 0 ) + {//there are some difference between the two arrays + + //scan the array of results + foreach($diff_array as $key => $value) + {//if the quantity delivered is greater or equal to wish quantity + if($qtydelivered[$key] >= $qtywished[$key] ) + { + $close++; + } + + } + } + + + if($close == count($diff_array)) + {//all the products are received equal or more than the wished quantity + if ($closeopenorder) + { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 5; + } + else + { + //Diff => received partially + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + + } + else + {//all the products are not received + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + } else { //Diff => received partially diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 0823ceb9fd7..b9a2f72b9bd 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -64,10 +64,6 @@ class ProductFournisseur extends Product var $fourn_unitprice; var $fourn_tva_tx; var $fourn_tva_npr; - /** - * @deprecated - */ - var $fourn_unitcharges; // old version used a buggy system to calculate margin of a charge field on supplier price. Now margin is on pmp, best supplier price or cost price. var $fk_supplier_price_expression; var $supplier_reputation; // reputation of supplier @@ -245,7 +241,6 @@ class ProductFournisseur extends Product $error=0; $unitBuyPrice = price2num($buyprice/$qty,'MU'); - $unitCharges = price2num($charges/$qty,'MU'); $now=dol_now(); @@ -280,7 +275,6 @@ class ProductFournisseur extends Product $sql.= " remise_percent = ".$remise_percent.","; $sql.= " remise = ".$remise.","; $sql.= " unitprice = ".$unitBuyPrice.","; - $sql.= " unitcharges = ".$unitCharges.","; // deprecated $sql.= " fk_availability = ".$availability.","; $sql.= " multicurrency_price = ".(isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; $sql.= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; @@ -342,7 +336,7 @@ class ProductFournisseur extends Product // Add price for this quantity to supplier $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; - $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; + $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; $sql .= " values("; $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; @@ -361,7 +355,6 @@ class ProductFournisseur extends Product $sql .= " " . $unitBuyPrice . ","; $sql .= " " . $tva_tx . ","; $sql .= " " . $charges . ","; - $sql .= " " . $unitCharges . ","; $sql .= " " . $availability . ","; $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; $sql .= " " . $newnpr . ","; @@ -442,7 +435,7 @@ class ProductFournisseur extends Product { global $conf; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,"; - $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price + $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price $sql.= " pfp.supplier_reputation"; $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; @@ -468,7 +461,6 @@ class ProductFournisseur extends Product $this->fourn_remise_percent = $obj->remise_percent; $this->fourn_remise = $obj->remise; $this->fourn_unitprice = $obj->unitprice; - $this->fourn_unitcharges = $obj->unitcharges; // deprecated $this->fourn_tva_tx = $obj->tva_tx; // TODO // $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? @@ -534,7 +526,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; @@ -567,7 +559,6 @@ class ProductFournisseur extends Product $prodfourn->fourn_remise = $record["remise"]; $prodfourn->fourn_unitprice = $record["unitprice"]; $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_unitcharges = $record["unitcharges"]; // deprecated $prodfourn->fourn_tva_tx = $record["tva_tx"]; $prodfourn->fourn_id = $record["fourn_id"]; $prodfourn->fourn_name = $record["supplier_name"]; @@ -657,7 +648,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, "; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; @@ -693,7 +684,7 @@ class ProductFournisseur extends Product { $fourn_price = $record["price"]; // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) + $record["unitcharges"] - $record["remise"]; + $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; @@ -727,7 +718,6 @@ class ProductFournisseur extends Product $this->fourn_remise = $record["remise"]; $this->fourn_unitprice = $record["unitprice"]; $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_unitcharges = $record["unitcharges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; $this->fourn_name = $record["supplier_name"]; @@ -830,14 +820,14 @@ class ProductFournisseur extends Product $out .= ''.$langs->trans("Supplier").''; $out .= ''.$langs->trans("SupplierRef").''; foreach ($productFournList as $productFourn) { - $out.= ''.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''; + $out.= ''.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''; $out.= ''.($showunitprice?$productFourn->fourn_qty:'').''; $out.= ''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''; $out.= ''.$productFourn->fourn_ref.''; } $out .= ''; } else { - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } return $out; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 1992a888a47..4f641b100bf 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -946,9 +946,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index f3deb4b12a3..760c80737f4 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -914,7 +914,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'],$_SERVER["PHP_SELF"],"cf.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 99a4a7edbc1..fc2f543b0a4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1257,9 +1257,11 @@ if (empty($reshook)) } if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 1e056292517..083967935fa 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -762,7 +762,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index b5dbc72fba0..08d3495c33c 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1475,10 +1475,11 @@ if ($step == 5 && $datatoimport) $sourcelinenb=0; $endoffile=0; // Loop on each input file record - while ($sourcelinenb < $nboflines && ! $endoffile) + while (($sourcelinenb < $nboflines) && ! $endoffile) { $sourcelinenb++; // Read line and store it into $arrayrecord + //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb); $arrayrecord=$obj->import_read_record(); if ($arrayrecord === false) { @@ -1487,7 +1488,7 @@ if ($step == 5 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); @@ -1857,7 +1858,7 @@ if ($step == 6 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 1e0388cff94..56659ea714c 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -242,7 +242,7 @@ UPDATE llx_bank_account SET accountancy_journal = 'OD' WHERE accountancy_journal ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); -UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code AND aj.entity = ba.entity) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 6e9e480cdb0..190e0dcf05f 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -321,6 +321,8 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik ( active integer DEFAULT 1 )ENGINE=innodb; +ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL; + CREATE TABLE IF NOT EXISTS llx_c_exp_tax_cat ( rowid integer AUTO_INCREMENT PRIMARY KEY, label varchar(48) NOT NULL, diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 558c3c6292e..74909c7a649 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -29,6 +29,8 @@ -- For 8.0 +ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; + ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; @@ -57,5 +59,6 @@ insert into llx_c_type_container (code,label,module,active) values ('other', ALTER TABLE `llx_product_fournisseur_price` CHANGE `multicurrency_price_ttc` `multicurrency_unitprice` DOUBLE(24,8) NULL DEFAULT NULL; ALTER TABLE `llx_product_fournisseur_price_log` CHANGE `multicurrency_price_ttc` `multicurrency_unitprice` DOUBLE(24,8) NULL DEFAULT NULL; +ALTER TABLE llx_expensereport_det ADD COLUMN docnumber varchar(128) after fk_expensereport; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 5cc7b1b86f5..fc0bd6e697f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -20,9 +20,10 @@ CREATE TABLE llx_expensereport_det ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_expensereport integer NOT NULL, - fk_c_type_fees integer NOT NULL, + docnumber varchar(128), -- To store a ref of a accounting doc (piece) + fk_c_type_fees integer NOT NULL, -- Type of expense fk_c_exp_tax_cat integer, - fk_projet integer, + fk_projet integer, -- Id of project comments text NOT NULL, product_type integer DEFAULT -1, qty real NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 1c86bfe04f8..14664225a9d 100755 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -29,13 +29,12 @@ create table llx_product_fournisseur_price fk_soc integer, ref_fourn varchar(30), fk_availability integer, - price double(24,8) DEFAULT 0, + price double(24,8) DEFAULT 0, -- price without tax for quantity quantity double, remise_percent double NOT NULL DEFAULT 0, remise double NOT NULL DEFAULT 0, - unitprice double(24,8) DEFAULT 0, + unitprice double(24,8) DEFAULT 0, -- unit price without tax charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it. - unitcharges double(24,8) DEFAULT 0, -- deprecated default_vat_code varchar(10), tva_tx double(6,3) NOT NULL, localtax1_tx double(6,3) DEFAULT 0, diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 6b662e4306d..838ef34afa3 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -491,7 +491,7 @@ if (! $error && $db->connected && $action == "set") 'thirdparties' => 'thirdparty', 'usergroups' => 'usergroups', 'users' => 'user', - 'usergroups' => 'usergroups', + 'usergroups' => 'usergroups', ); foreach($docs as $cursordir => $cursorfile) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 02c44ebee88..d6bf4d01fe9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -411,6 +411,7 @@ ExtrafieldCheckBoxFromList=Checkboxes from table ExtrafieldLink=Link to an object ComputedFormula=Computed field ComputedFormulaDesc=You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $object.
WARNING: Only some properties of $object may be available. If you need a properties not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.

Example of formula:
$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)

Example to reload object
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5 : '-1'

Other example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found' +ExtrafieldParamHelpPassword=Keep this field empty means value will be stored without encryption (field must be only hidden with star on screen).
Set here value 'auto' to use the default encryption rule to save password into database (then value read will be the hash only, no way to retreive original value) ExtrafieldParamHelpselect=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
code3,value3
...

In order to have the list depending on another complementary attribute list :
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

In order to have the list depending on another list :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a6a330ad68a..9da257b639d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -857,6 +857,7 @@ FileNotShared=File not shared to exernal public Project=Project Projects=Projects Rights=Permissions +LineNb=Line nb # Week day Monday=Monday Tuesday=Tuesday diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b2218508ef6..06c602df330 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -193,9 +193,11 @@ elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) // Update extrafields if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index b6584f8d909..c34574791c1 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -42,14 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once '../lib/mymodule.lib.php'; // Translations -$langs->load("errors"); -$langs->load("admin"); -$langs->load("mymodule@mymodule"); +$langs->loadLangs(array("errors","admin","mymodule@mymodule")); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); @@ -73,7 +69,7 @@ $page_name = "MyModuleAbout"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 19908d33546..58a572a42ac 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -71,7 +71,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 1d8ba3dace6..eea2a85e656 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -53,7 +53,7 @@ class modMyModule extends DolibarrModules // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'mymodule'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page $this->family = "other"; // Module position in the family on 2 digits ('01', '10', '20', ...) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 72715ec27f1..2ef8fa97030 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -422,7 +422,7 @@ foreach($object->fields as $key => $val) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a6cc3427243..79120aa1191 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -370,7 +370,7 @@ if ($id > 0 || ! empty($ref)) } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index e8fa94c2ae0..462be52b082 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -753,11 +753,6 @@ SCRIPT; print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); - // Charges ???? - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) print_liste_field_titre("UnitCharges"); - } print_liste_field_titre(''); print "\n"; @@ -842,18 +837,6 @@ SCRIPT; } print''; - // Charges ???? - /* - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) - { - print ''; - print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" "); - print ''; - } - }*/ - if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ebb2c0a421a..662c15507f0 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -654,7 +654,7 @@ else // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); @@ -793,7 +793,7 @@ else if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 8e639c90108..f269e260b25 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -122,9 +122,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8dbce2790fa..c8096559c9c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -584,10 +584,10 @@ class Project extends CommonObject $i++; } $this->db->free($result); - - /* Return array */ - return $elements; } + + /* Return array even if empty*/ + return $elements; } else { diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 61685ed8267..61919c54b1a 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -178,8 +178,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; $j++; $i++; @@ -329,7 +327,7 @@ foreach ($demoprofiles as $profilearray) print '
'; } - print '
'."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -340,7 +338,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
'."\n"; + print '
'."\n"; print '
'; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 362834b316d..37f60150dd8 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -327,9 +327,11 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($socid); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) @@ -511,6 +513,8 @@ if (empty($reshook)) { if ($action == 'add') { + $error = 0; + $db->begin(); if (empty($object->client)) $object->code_client=''; @@ -533,11 +537,21 @@ if (empty($reshook)) // Customer categories association $custcats = GETPOST('custcats', 'array'); - $object->setCategories($custcats, 'customer'); + $result = $object->setCategories($custcats, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $suppcats = GETPOST('suppcats', 'array'); - $object->setCategories($suppcats, 'supplier'); + $result = $object->setCategories($suppcats, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; @@ -566,7 +580,7 @@ if (empty($reshook)) } } else - { + { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini @@ -593,7 +607,7 @@ if (empty($reshook)) $error++; } - if ($result >= 0) + if ($result >= 0 && ! $error) { $db->commit(); @@ -622,6 +636,8 @@ if (empty($reshook)) if ($action == 'update') { + $error = 0; + if (GETPOST('cancel','alpha')) { if (! empty($backtopage)) @@ -647,16 +663,27 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } + // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined) - if (!empty($user->rights->categorie->lire)) + if (! $error && !empty($user->rights->categorie->lire)) { // Customer categories association $categories = GETPOST( 'custcats', 'array' ); - $object->setCategories($categories, 'customer'); + $result = $object->setCategories($categories, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $categories = GETPOST('suppcats', 'array'); - $object->setCategories($categories, 'supplier'); + $result = $object->setCategories($categories, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } // Logo/Photo save @@ -686,13 +713,18 @@ if (empty($reshook)) } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + // Create thumbs + $object->addThumbs($newfile); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + // Index file in database + if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + { + require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir + deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', 'uploaded', 1); + // now we index the uploaded logo file + addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); + } } } } @@ -1145,7 +1177,7 @@ else // Address print ''.fieldLabel('Address','address').''; - print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3ca69fdb6fd..f5c0f004794 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1121,10 +1121,11 @@ class Societe extends CommonObject * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) - * @param string $email Email (Warning, this can return several records) + * @param string $email Email of third party (Warning, this can return several records) + * @param string $ref_alias Name_alias of third party (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='', $ref_alias='') { global $langs; global $conf; @@ -1166,17 +1167,18 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; - if ($rowid) $sql .= ' AND s.rowid = '.$rowid; - if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; - if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; - if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; - if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; - if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; - if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; - if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; - if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; + if ($rowid) $sql .= ' AND s.rowid = '.$rowid; + if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; + if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; + if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; + if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; + if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; + if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; + if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; $resql=$this->db->query($sql); if ($resql) @@ -3767,6 +3769,8 @@ class Societe extends CommonObject $to_add = $categories; } + $error = 0; + // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { @@ -3774,12 +3778,20 @@ class Societe extends CommonObject } } foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_text); + if ($c->fetch($add) > 0) + { + $result = $c->add_type($this, $type_text); + if ($result < 0) + { + $error++; + $this->error = $c->error; + $this->errors = $c->errors; + break; + } } } - return 1; + return $error ? -1 : 1; } diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 439586468c4..67a44d87ccf 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -222,7 +222,8 @@ if ($id > 0 || ! empty($ref)) $sql.= " t.libelle as type, t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE d.fk_soc=".$id; + $sql.= " WHERE d.fk_soc = ".$id; + $sql.= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); $resql = $db->query($sql); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index ed5187cf89f..27f38b3a298 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -930,9 +930,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 0bcb328039c..3dce177051e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1134,7 +1134,7 @@ class SupplierProposal extends CommonObject { global $conf; - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1168,6 +1168,7 @@ class SupplierProposal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->remise = $obj->remise; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 1a7d248f83f..685e9531072 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -599,7 +599,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'],$_SERVER["PHP_SELF"],"sp.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index aa169253fb3..9e7c90f79ac 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -67,6 +67,9 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); } +if(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $caneditgroup = ($conf->entity == 1) && ! empty($user->admin) && empty($user->entity); +} // Define value to know what current user can do on properties of edited user if ($id) { @@ -1795,7 +1798,7 @@ else } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 6f9ac1f638a..b5edbafa89e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -406,7 +406,7 @@ if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_t // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);