From abc3209f518af7e528c5b6cc253d2c9a2c66cb18 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 9 Dec 2022 16:31:43 +0100 Subject: [PATCH 001/217] NEW mode view for list of Societe --- htdocs/societe/class/societe.class.php | 29 ++ htdocs/societe/list.php | 696 +++++++++++++------------ 2 files changed, 388 insertions(+), 337 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1fb149ba250..3d918f423af 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5087,4 +5087,33 @@ class Societe extends CommonObject return 1; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'code_client')) { + $return .= '
'.$this->code_client.''; + } + + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 6da7fcf3779..5f9abeb743b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -461,7 +461,6 @@ if ($resql) { } else { dol_print_error($db); } - $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; $sql .= " s.entity,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; @@ -479,7 +478,7 @@ if ($search_sale && $search_sale != '-1') { $sql .= ", sc.fk_soc, sc.fk_user"; } // Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { +if (empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } @@ -493,9 +492,10 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; +if (empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."extrafields as ef on (s.rowid = ef.fk_object)"; } + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)"; @@ -504,7 +504,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale if ($search_sale == -2) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -783,6 +783,9 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -969,7 +972,10 @@ if ($contextpage != 'poslist') { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); } elseif ($user->rights->societe->creer) { $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place); $label = 'MenuNewCustomer'; @@ -986,6 +992,7 @@ print ''; print ''; //print ''; print ''; +print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'building', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1476,349 +1483,364 @@ while ($i < min($num, $limit)) { $companystatic->entity = $obj->entity; } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + // Output Kanban + print $companystatic->getKanbanView(''); + //print_r($obj->nb_rights); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.rowid']['checked'])) { - print ''; - print $obj->rowid; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.nom']['checked'])) { - print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">'; + } else { + print 'name); - } else { - print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.urlencode($place).'\'"'; } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print dol_escape_htmltag($companystatic->name_alias); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Barcode - if (!empty($arrayfields['s.barcode']['checked'])) { - print ''.dol_escape_htmltag($companystatic->barcode).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Customer code - if (!empty($arrayfields['s.code_client']['checked'])) { - print ''.dol_escape_htmltag($companystatic->code_client).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Supplier code - if (!empty($arrayfields['s.code_fournisseur']['checked'])) { - print ''.dol_escape_htmltag($companystatic->code_fournisseur).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Account customer code - if (!empty($arrayfields['s.code_compta']['checked'])) { - print ''.dol_escape_htmltag($companystatic->code_compta_client).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Account supplier code - if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { - print ''.dol_escape_htmltag($companystatic->code_compta_fournisseur).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Address - if (!empty($arrayfields['s.address']['checked'])) { - print ''.dol_escape_htmltag($companystatic->address).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print "".dol_escape_htmltag($companystatic->zip)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''.dol_escape_htmltag($companystatic->town)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".dol_escape_htmltag($obj->state_name)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Region - if (!empty($arrayfields['region.nom']['checked'])) { - print "".dol_escape_htmltag($obj->region_name)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label; - print $labelcountry; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - $labeltypeofcompany= empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; + print '>'; - print ''; - print dol_escape_htmltag($labeltypeofcompany); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Multiprice level - if (!empty($arrayfields['s.price_level']['checked'])) { - print ''.$obj->price_level."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Staff - if (!empty($arrayfields['staff.code']['checked'])) { - print ''; - if (!is_array($staffArray) || count($staffArray) == 0) { - $staffArray = $formcompany->effectif_array(1); - } - print $staffArray[$obj->staff_code]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.email']['checked'])) { - print ''.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.phone']['checked'])) { - print ''.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.fax']['checked'])) { - print ''.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.url']['checked'])) { - print "".dol_print_url($obj->url, '', '', 1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.siren']['checked'])) { - print "".$obj->idprof1."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.siret']['checked'])) { - print "".$obj->idprof2."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.ape']['checked'])) { - print "".$obj->idprof3."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof4']['checked'])) { - print "".$obj->idprof4."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof5']['checked'])) { - print "".$obj->idprof5."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof6']['checked'])) { - print "".$obj->idprof6."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // VAT - if (!empty($arrayfields['s.tva_intra']['checked'])) { - print ''; - if ($companystatic->tva_intra && !isValidVATID($companystatic)) { - print img_warning("BadVATNumber", '', 'pictofixedwidth'); - } - print $companystatic->tva_intra; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type - if (!empty($arrayfields['customerorsupplier']['checked'])) { - print ''; - print $companystatic->getTypeUrl(1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { - // Prospect level - print ''; - print $companystatic->getLibProspLevel(); - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['s.fk_stcomm']['checked'])) { - // Prospect status - print '
'; - print '
'; - print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
-
'; - foreach ($prospectstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; + // Action column (Show the massaction button only when this page is not opend from the Extended POS) + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print '
'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; - if ($companystatic->fk_parent > 0) { - $companyparent->fetch($companystatic->fk_parent); - print $companyparent->getNomUrl(1); - } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['s.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['s.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['s.status']['checked'])) { - print ''.$companystatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Import key - if (!empty($arrayfields['s.import_key']['checked'])) { - print ''; - print dol_escape_htmltag($obj->import_key); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (!empty($arrayfields['s.rowid']['checked'])) { + print ''; + print $obj->rowid; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['s.nom']['checked'])) { + print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">'; + if ($contextpage == 'poslist') { + print dol_escape_htmltag($companystatic->name); + } else { + print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print dol_escape_htmltag($companystatic->name_alias); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Barcode + if (!empty($arrayfields['s.barcode']['checked'])) { + print ''.dol_escape_htmltag($companystatic->barcode).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Customer code + if (!empty($arrayfields['s.code_client']['checked'])) { + print ''.dol_escape_htmltag($companystatic->code_client).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Supplier code + if (!empty($arrayfields['s.code_fournisseur']['checked'])) { + print ''.dol_escape_htmltag($companystatic->code_fournisseur).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Account customer code + if (!empty($arrayfields['s.code_compta']['checked'])) { + print ''.dol_escape_htmltag($companystatic->code_compta_client).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Account supplier code + if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { + print ''.dol_escape_htmltag($companystatic->code_compta_fournisseur).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Address + if (!empty($arrayfields['s.address']['checked'])) { + print ''.dol_escape_htmltag($companystatic->address).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print "".dol_escape_htmltag($companystatic->zip)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''.dol_escape_htmltag($companystatic->town)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".dol_escape_htmltag($obj->state_name)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Region + if (!empty($arrayfields['region.nom']['checked'])) { + print "".dol_escape_htmltag($obj->region_name)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label; + print $labelcountry; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + $labeltypeofcompany= empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; - print ''."\n"; + print ''; + print dol_escape_htmltag($labeltypeofcompany); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Multiprice level + if (!empty($arrayfields['s.price_level']['checked'])) { + print ''.$obj->price_level."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Staff + if (!empty($arrayfields['staff.code']['checked'])) { + print ''; + if (!is_array($staffArray) || count($staffArray) == 0) { + $staffArray = $formcompany->effectif_array(1); + } + print $staffArray[$obj->staff_code]; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.email']['checked'])) { + print ''.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.phone']['checked'])) { + print ''.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.fax']['checked'])) { + print ''.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.url']['checked'])) { + print "".dol_print_url($obj->url, '', '', 1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.siren']['checked'])) { + print "".$obj->idprof1."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.siret']['checked'])) { + print "".$obj->idprof2."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.ape']['checked'])) { + print "".$obj->idprof3."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.idprof4']['checked'])) { + print "".$obj->idprof4."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.idprof5']['checked'])) { + print "".$obj->idprof5."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['s.idprof6']['checked'])) { + print "".$obj->idprof6."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // VAT + if (!empty($arrayfields['s.tva_intra']['checked'])) { + print ''; + if ($companystatic->tva_intra && !isValidVATID($companystatic)) { + print img_warning("BadVATNumber", '', 'pictofixedwidth'); + } + print $companystatic->tva_intra; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type + if (!empty($arrayfields['customerorsupplier']['checked'])) { + print ''; + print $companystatic->getTypeUrl(1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { + // Prospect level + print ''; + print $companystatic->getLibProspLevel(); + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['s.fk_stcomm']['checked'])) { + // Prospect status + print '
'; + print '
'; + print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
-
'; + foreach ($prospectstatic->cacheprospectstatus as $key => $val) { + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($obj->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } + } + print '
'; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print ''; + if ($companystatic->fk_parent > 0) { + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(1); + } + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['s.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['s.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['s.status']['checked'])) { + print ''.$companystatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['s.import_key']['checked'])) { + print ''; + print dol_escape_htmltag($obj->import_key); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column (Show the massaction button only when this page is not opend from the Extended POS) + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + print ''."\n"; + } $i++; } From 1c9a5547068a3826494300cc537efb1c1cec4035 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 21 Dec 2022 13:28:39 +0100 Subject: [PATCH 002/217] New mode view for projects --- htdocs/projet/class/project.class.php | 35 ++ htdocs/projet/list.php | 851 +++++++++++++------------- 2 files changed, 475 insertions(+), 411 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 9c8b4ebee26..33bedb3d56c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2313,4 +2313,39 @@ class Project extends CommonObject $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs,$db,$user; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'date_start_event')) { + $return .= '
'.$langs->trans("DateStart").''; + $return .= ' : '.dol_print_date($db->jdate($this->date_start_event), 'day').''; + } + if (property_exists($this, 'user_author_id')) { + $return .= '
'.$langs->trans("Author").''; + $return .= ' : '.$user->getNomUrl(1).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b31666245d4..b208a64d08f 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -55,6 +55,8 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist'; +$mode = GETPOST('mode', 'alpha'); + $title = $langs->trans("Projects"); @@ -698,6 +700,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -881,6 +886,10 @@ if (!empty($socid)) { if ($search_usage_event_organization == 1) { $url .= '&usage_organize_event=1'; } + +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); print '
'; @@ -893,6 +902,8 @@ print ''; print ''; print ''; print ''; +print ''; + // Show description of content $texthelp = ''; @@ -1333,443 +1344,461 @@ while ($i < $imaxinloop) { $companystatic->town = $obj->town; $companystatic->country_code = $obj->country_code; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + $object->date_start_event = $obj->date_start; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + $userstatic->id = $obj->fk_user_creat; + $object->user_author_id = $userstatic->id; + //var_dump($object->user_author_id);exit; + print $object->getKanbanView(''); + + if ($i == min($num, $limit)-1) { + print '
'; + print ''; + } + } else { + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Project url + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':'')); + if ($object->hasDelay()) { + print img_warning($langs->trans('Late')); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Project url - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':'')); - if ($object->hasDelay()) { - print img_warning($langs->trans('Late')); + // Title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + print $obj->title; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Company + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if ($obj->socid) { + print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Title - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - print $obj->title; - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if ($obj->socid) { + print $companystatic->name_alias; + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Company - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if ($obj->socid) { - print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } else { - print ' '; + // Sales Representatives + if (!empty($arrayfields['commercial']['checked'])) { + print ''; + if ($obj->socid) { + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Date start project + if (!empty($arrayfields['p.dateo']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_start), 'day'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if ($obj->socid) { - print $companystatic->name_alias; - } else { - print ' '; + // Date end project + if (!empty($arrayfields['p.datee']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_end), 'day'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Visibility + if (!empty($arrayfields['p.public']['checked'])) { + print ''; + if ($obj->public) { + print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); + //print $langs->trans('SharedProject'); + } else { + print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); + //print $langs->trans('PrivateProject'); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Sales Representatives - if (!empty($arrayfields['commercial']['checked'])) { - print ''; - if ($obj->socid) { - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + // Contacts of project + if (!empty($arrayfields['c.assigned']['checked'])) { + print ''; + $ifisrt = 1; + foreach (array('internal', 'external') as $source) { + $tab = $object->liste_contact(-1, $source, 0, '', 1); + $numcontact = count($tab); + if (!empty($numcontact)) { + foreach ($tab as $contactproject) { + //var_dump($contacttask); + if ($source == 'internal') { + $c = new User($db); + } else { + $c = new Contact($db); + } + $c->fetch($contactproject['id']); + if (!empty($c->photo)) { + if (get_class($c) == 'User') { + print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); + } else { + print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); + } + } else { + if (get_class($c) == 'User') { + print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); + } else { + print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); + } + } + $ifisrt = 0; } } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Opp Status + if (!empty($arrayfields['p.fk_opp_status']['checked'])) { + print ''; + if ($obj->opp_status_code) { + print $langs->trans("OppStatus".$obj->opp_status_code); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } + // Opp Amount + if (!empty($arrayfields['p.opp_amount']['checked'])) { + print ''; + //if ($obj->opp_status_code) + if (strcmp($obj->opp_amount, '')) { + print ''.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').''; + $totalarray['val']['p.opp_amount'] += $obj->opp_amount; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount'; + } + } + // Opp percent + if (!empty($arrayfields['p.opp_percent']['checked'])) { + print ''; + if ($obj->opp_percent) { + print price($obj->opp_percent, 1, $langs, 1, 0).'%'; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Opp weighted amount + if (!empty($arrayfields['opp_weighted_amount']['checked'])) { + if (!isset($totalarray['val']['opp_weighted_amount'])) { + $totalarray['val']['opp_weighted_amount'] = 0; + } + print ''; + if ($obj->opp_weighted_amount) { + print ''.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').''; + $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; + } + } + // Budget + if (!empty($arrayfields['p.budget_amount']['checked'])) { + print ''; + if ($obj->budget_amount != '') { + print ''.price($obj->budget_amount, 1, $langs, 1, -1, -1).''; + $totalarray['val']['p.budget_amount'] += $obj->budget_amount; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; + } + } + // Usage opportunity + if (!empty($arrayfields['p.usage_opportunity']['checked'])) { + print ''; + if ($obj->usage_opportunity) { + print yn($obj->usage_opportunity); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Usage task + if (!empty($arrayfields['p.usage_task']['checked'])) { + print ''; + if ($obj->usage_task) { + print yn($obj->usage_task); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Bill time + if (!empty($arrayfields['p.usage_bill_time']['checked'])) { + print ''; + if ($obj->usage_bill_time) { + print yn($obj->usage_bill_time); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Event Organization + if (!empty($arrayfields['p.usage_organize_event']['checked'])) { + print ''; + if ($obj->usage_organize_event) { + print yn($obj->usage_organize_event); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Allow unknown people to suggest conferences + if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) { + print ''; + if ($obj->accept_conference_suggestions) { + print yn($obj->accept_conference_suggestions); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Allow unknown people to suggest booth + if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) { + print ''; + if ($obj->accept_booth_suggestions) { + print yn($obj->accept_booth_suggestions); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Price of registration + if (!empty($arrayfields['p.price_registration']['checked'])) { + print ''; + if ($obj->price_registration != '') { + print ''.price($obj->price_registration, 1, $langs, 1, -1, -1).''; + $totalarray['val']['p.price_registration'] += $obj->price_registration; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; + } + } + // Price of booth + if (!empty($arrayfields['p.price_booth']['checked'])) { + print ''; + if ($obj->price_booth != '') { + print ''.price($obj->price_booth, 1, $langs, 1, -1, -1).''; + $totalarray['val']['p.price_booth'] += $obj->price_booth; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; + } + } + // Author + $userstatic->id = $obj->fk_user_creat; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; - // Date start project - if (!empty($arrayfields['p.dateo']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_start), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end project - if (!empty($arrayfields['p.datee']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_end), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - - // Visibility - if (!empty($arrayfields['p.public']['checked'])) { - print ''; - if ($obj->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - //print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - //print $langs->trans('PrivateProject'); + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Email MsgID + if (!empty($arrayfields['p.email_msgid']['checked'])) { + print ''; + print $obj->email_msgid; + print ''; + if (!$i) $totalarray['nbfield']++; } - } - // Contacts of project - if (!empty($arrayfields['c.assigned']['checked'])) { - print ''; - $ifisrt = 1; - foreach (array('internal', 'external') as $source) { - $tab = $object->liste_contact(-1, $source, 0, '', 1); - $numcontact = count($tab); - if (!empty($numcontact)) { - foreach ($tab as $contactproject) { - //var_dump($contacttask); - if ($source == 'internal') { - $c = new User($db); - } else { - $c = new Contact($db); - } - $c->fetch($contactproject['id']); - if (!empty($c->photo)) { - if (get_class($c) == 'User') { - print $c->getNomUrl(-2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); - } else { - print $c->getNomUrl(-2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); - } - } else { - if (get_class($c) == 'User') { - print $c->getNomUrl(2, '', 0, 0, 24, 1, '', ($ifisrt ? '' : 'notfirst')); - } else { - print $c->getNomUrl(2, '', 0, '', -1, 0, ($ifisrt ? '' : 'notfirst')); - } - } - $ifisrt = 0; + // Import key + if (!empty($arrayfields['p.import_key']['checked'])) { + print ''.dol_escape_htmltag($obj->import_key).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.fk_statut']['checked'])) { + print ''.$object->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Opp Status - if (!empty($arrayfields['p.fk_opp_status']['checked'])) { - print ''; - if ($obj->opp_status_code) { - print $langs->trans("OppStatus".$obj->opp_status_code); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Opp Amount - if (!empty($arrayfields['p.opp_amount']['checked'])) { - print ''; - //if ($obj->opp_status_code) - if (strcmp($obj->opp_amount, '')) { - print ''.price($obj->opp_amount, 1, $langs, 1, -1, -1, '').''; - $totalarray['val']['p.opp_amount'] += $obj->opp_amount; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.opp_amount'; - } - } - // Opp percent - if (!empty($arrayfields['p.opp_percent']['checked'])) { - print ''; - if ($obj->opp_percent) { - print price($obj->opp_percent, 1, $langs, 1, 0).'%'; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Opp weighted amount - if (!empty($arrayfields['opp_weighted_amount']['checked'])) { - if (!isset($totalarray['val']['opp_weighted_amount'])) { - $totalarray['val']['opp_weighted_amount'] = 0; - } - print ''; - if ($obj->opp_weighted_amount) { - print ''.price($obj->opp_weighted_amount, 1, $langs, 1, -1, -1, '').''; - $totalarray['val']['opp_weighted_amount'] += $obj->opp_weighted_amount; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'opp_weighted_amount'; - } - } - // Budget - if (!empty($arrayfields['p.budget_amount']['checked'])) { - print ''; - if ($obj->budget_amount != '') { - print ''.price($obj->budget_amount, 1, $langs, 1, -1, -1).''; - $totalarray['val']['p.budget_amount'] += $obj->budget_amount; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.budget_amount'; - } - } - // Usage opportunity - if (!empty($arrayfields['p.usage_opportunity']['checked'])) { - print ''; - if ($obj->usage_opportunity) { - print yn($obj->usage_opportunity); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Usage task - if (!empty($arrayfields['p.usage_task']['checked'])) { - print ''; - if ($obj->usage_task) { - print yn($obj->usage_task); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Bill time - if (!empty($arrayfields['p.usage_bill_time']['checked'])) { - print ''; - if ($obj->usage_bill_time) { - print yn($obj->usage_bill_time); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Event Organization - if (!empty($arrayfields['p.usage_organize_event']['checked'])) { - print ''; - if ($obj->usage_organize_event) { - print yn($obj->usage_organize_event); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Allow unknown people to suggest conferences - if (!empty($arrayfields['p.accept_conference_suggestions']['checked'])) { - print ''; - if ($obj->accept_conference_suggestions) { - print yn($obj->accept_conference_suggestions); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Allow unknown people to suggest booth - if (!empty($arrayfields['p.accept_booth_suggestions']['checked'])) { - print ''; - if ($obj->accept_booth_suggestions) { - print yn($obj->accept_booth_suggestions); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Price of registration - if (!empty($arrayfields['p.price_registration']['checked'])) { - print ''; - if ($obj->price_registration != '') { - print ''.price($obj->price_registration, 1, $langs, 1, -1, -1).''; - $totalarray['val']['p.price_registration'] += $obj->price_registration; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.price_registration'; - } - } - // Price of booth - if (!empty($arrayfields['p.price_booth']['checked'])) { - print ''; - if ($obj->price_booth != '') { - print ''.price($obj->price_booth, 1, $langs, 1, -1, -1).''; - $totalarray['val']['p.price_booth'] += $obj->price_booth; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; - } - } - // Author - $userstatic->id = $obj->fk_user_creat; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } + print "\n"; } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Email MsgID - if (!empty($arrayfields['p.email_msgid']['checked'])) { - print ''; - print $obj->email_msgid; - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Import key - if (!empty($arrayfields['p.import_key']['checked'])) { - print ''.dol_escape_htmltag($obj->import_key).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''.$object->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print "\n"; } $i++; From 411a769a59e45236a2e9fc2c721a14e3d66bb7e8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 22 Dec 2022 10:00:22 +0000 Subject: [PATCH 003/217] Fixing style errors. --- htdocs/societe/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 16f6d467e64..c3a8316dbbe 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -989,7 +989,6 @@ if ($contextpage != 'poslist') { $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); } elseif ($user->rights->societe->creer) { - $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place); $label = 'MenuNewCustomer'; $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url); From 3fdb445cf3a578383eb9d81656c6d6f54d10abfc Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Fri, 13 Jan 2023 14:20:19 +0100 Subject: [PATCH 004/217] modify style for checkbox --- htdocs/hrm/class/skill.class.php | 2 +- htdocs/theme/eldy/info-box.inc.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 5f58412b65a..592fd77ac45 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -1130,7 +1130,7 @@ class Skill extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'skill_type')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index f35516ad58e..9c1f3b443ef 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -491,7 +491,10 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { min-width: 350px; max-width: 350px; } - +/**for make a checkbox in the right of the box in mode kanban */ +.fright { + float:right; +} @media only screen and (max-width: 1740px) { .info-box-module { min-width: 315px; From e4d2e1fec2221cafedc6e62d3abdf94fa463c4ae Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 14:28:09 +0100 Subject: [PATCH 005/217] fix attribute class --- htdocs/hrm/class/skill.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 592fd77ac45..7e178204a3d 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -1130,7 +1130,7 @@ class Skill extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'skill_type')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; From 5c3d35b415724cea6955bf8daea5a9e044d82670 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Mon, 16 Jan 2023 15:48:29 +0100 Subject: [PATCH 006/217] Update list.php fix style --- htdocs/societe/list.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c3a8316dbbe..9f808ec322e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -983,7 +983,6 @@ if ($contextpage != 'poslist') { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); From 340edf8b30da2f8510d0cce3679c3ddc7b6368b5 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 16:41:49 +0100 Subject: [PATCH 007/217] fix error style --- htdocs/theme/eldy/info-box.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 9c1f3b443ef..99e8e5e2ca1 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -491,7 +491,6 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { min-width: 350px; max-width: 350px; } -/**for make a checkbox in the right of the box in mode kanban */ .fright { float:right; } From 06784bb02438ba6ff9f4b4af26fbd1524859d209 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 16 Jan 2023 16:45:02 +0100 Subject: [PATCH 008/217] fix error style --- htdocs/hrm/class/skill.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 7e178204a3d..6ef1cd621bd 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -1130,7 +1130,7 @@ class Skill extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'skill_type')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; From 3d5682d0601043a70efa7c3efd143376d764a730 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 25 Jan 2023 12:02:25 +0100 Subject: [PATCH 009/217] fix error in sql request --- htdocs/societe/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5f9abeb743b..0f8ce9c55cc 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -478,7 +478,7 @@ if ($search_sale && $search_sale != '-1') { $sql .= ", sc.fk_soc, sc.fk_user"; } // Add fields from extrafields -if (empty($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } @@ -492,8 +492,8 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; -if (empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."extrafields as ef on (s.rowid = ef.fk_object)"; +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; @@ -504,7 +504,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale if ($search_sale == -2) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } elseif (!empty($search_sale) && $search_sale != '-1' || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; From 2ec3f2165c0b11c8218591599458cb0bb9527289 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 25 Jan 2023 12:06:05 +0100 Subject: [PATCH 010/217] fix error in sql request --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c7ca20724e6..d0a10d3fea5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -492,7 +492,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sqlfields = $sql; // $sql fields to remove for count total +$sqlfields = $sql; // $sql fields to remove for count totall $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; From f454cf513cc45368129e1c87d54078d7764c9a5e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Mon, 30 Jan 2023 10:17:12 +0100 Subject: [PATCH 011/217] add class to checkbox --- htdocs/hrm/class/skill.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 6ef1cd621bd..7e178204a3d 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -1130,7 +1130,7 @@ class Skill extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'skill_type')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; From 895957e89da1de1e296e3310acb93108d6939642 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 08:41:08 +0100 Subject: [PATCH 012/217] Modify margin rates in offers like VAT rates. --- htdocs/admin/propal.php | 13 ++++++++++ htdocs/comm/propal/card.php | 31 ++++++++++++++++++++++++ htdocs/core/tpl/objectline_title.tpl.php | 16 +++++++++--- htdocs/langs/en_US/margins.lang | 1 + htdocs/langs/fr_FR/margins.lang | 1 + 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 10044e33b5b..289c514c703 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -615,6 +615,19 @@ print " \n"; print ""; +print ''; +print ''.$langs->trans("ModifyMarginRates").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PROPALE_MODIFY_MARGIN_RATES'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("PROPALE_MODIFY_MARGIN_RATES", $arrval, $conf->global->PROPALE_MODIFY_MARGIN_RATES); +} +print "\n"; +print ''; +print "\n"; + print ""; print ''; print ""; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3f74c4a860f..c1912451cc8 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,6 +914,37 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + // Define margin + $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); + foreach ($object->lines as &$line) { + $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); + $prod = new Product($db); + $prod->fetch($line->fk_product); + if ($prod->price_min > $subprice) { + $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); + $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); + setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); + } + // Manage $line->subprice and $line->multicurrency_subprice + $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + // Update DB + $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); + // Update $object with new margin info + $line->price = $subprice; + $line->marge_tx = $margin_rate; + $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; + $line->total_ht = $line->qty * $subprice; + $line->total_tva = $line->tva_tx * $line->qty * $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + // Manage $line->subprice and $line->multicurrency_subprice + $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values + $line->subprice = $subprice; + $line->multicurrency_subprice = $multicurrency_subprice; + } } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 4640d710705..991910865e4 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,9 +140,19 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate').''; - } + if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + print ''.$langs->trans('MarginRate'); + if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; + if (GETPOST('mode', 'aZ09') == 'marginforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } + } + print ''; + } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; } diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index a91b139ec7b..9101966eff2 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -6,6 +6,7 @@ TotalMargin=Total Margin MarginOnProducts=Margin / Products MarginOnServices=Margin / Services MarginRate=Margin rate +ModifyMarginRates=Modify margin rates MarkRate=Mark rate DisplayMarginRates=Display margin rates DisplayMarkRates=Display mark rates diff --git a/htdocs/langs/fr_FR/margins.lang b/htdocs/langs/fr_FR/margins.lang index a8a68c6599f..742b8ce76c0 100644 --- a/htdocs/langs/fr_FR/margins.lang +++ b/htdocs/langs/fr_FR/margins.lang @@ -8,6 +8,7 @@ MarginOnServices=Marge / Services MarginRate=Taux de marge MarkRate=Taux de marque DisplayMarginRates=Afficher les taux de marge +ModifyMarginRates=Modifier les taux de marge DisplayMarkRates=Afficher les taux de marque InputPrice=Saisir un prix margin=Gestion des marges From 35ce7352e8ed9ec613ddaa8b4005ba0330c94405 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Feb 2023 08:09:57 +0000 Subject: [PATCH 013/217] Fixing style errors. --- htdocs/comm/propal/card.php | 62 ++++++++++++------------ htdocs/core/tpl/objectline_title.tpl.php | 26 +++++----- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c1912451cc8..88f3c1e44aa 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,37 +914,37 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { - // Define margin - $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); - foreach ($object->lines as &$line) { - $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); - $prod = new Product($db); - $prod->fetch($line->fk_product); - if ($prod->price_min > $subprice) { - $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); - $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); - setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); - } - // Manage $line->subprice and $line->multicurrency_subprice - $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; - // Update DB - $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); - // Update $object with new margin info - $line->price = $subprice; - $line->marge_tx = $margin_rate; - $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; - $line->total_ht = $line->qty * $subprice; - $line->total_tva = $line->tva_tx * $line->qty * $subprice; - $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; - // Manage $line->subprice and $line->multicurrency_subprice - $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; - // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values - $line->subprice = $subprice; - $line->multicurrency_subprice = $multicurrency_subprice; - } + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + // Define margin + $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); + foreach ($object->lines as &$line) { + $subprice = price2num($line->pa_ht * (1 + $margin_rate/100), 'MU'); + $prod = new Product($db); + $prod->fetch($line->fk_product); + if ($prod->price_min > $subprice) { + $price_subprice = price($subprice, 0, $outlangs, 1, -1, -1, 'auto'); + $price_price_min = price($prod->price_min, 0, $outlangs, 1, -1, -1, 'auto'); + setEventMessages($prod->ref.' - '.$prod->label.' ('.$price_subprice.' < '.$price_price_min.' '.strtolower($langs->trans("MinPrice")).')'."\n", null, 'warnings'); + } + // Manage $line->subprice and $line->multicurrency_subprice + $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice; + // Update DB + $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice); + // Update $object with new margin info + $line->price = $subprice; + $line->marge_tx = $margin_rate; + $line->marque_tx = $margin_rate * $line->pa_ht / $subprice; + $line->total_ht = $line->qty * $subprice; + $line->total_tva = $line->tva_tx * $line->qty * $subprice; + $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice; + // Manage $line->subprice and $line->multicurrency_subprice + $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice; + // Used previous $line->subprice and $line->multicurrency_subprice above, now they can be set to their new values + $line->subprice = $subprice; + $line->multicurrency_subprice = $multicurrency_subprice; + } } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 991910865e4..e2882bcd43f 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,19 +140,19 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate'); - if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { - print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; - if (GETPOST('mode', 'aZ09') == 'marginforalllines') { - print '
'; - print ''; - print ''; - print '
'; - } - } - print ''; - } + if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + print ''.$langs->trans('MarginRate'); + if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; + if (GETPOST('mode', 'aZ09') == 'marginforalllines') { + print '
'; + print ''; + print ''; + print '
'; + } + } + print ''; + } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; } From cd4064c0349138a86afd63f2432e3f0e8bb611c8 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 10:07:52 +0100 Subject: [PATCH 014/217] Dolibarr was using td here but is now using th so th was substituted for td. --- htdocs/core/tpl/objectline_title.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e2882bcd43f..e00a34551a5 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -141,7 +141,7 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { - print ''.$langs->trans('MarginRate'); + print ''.$langs->trans('MarginRate'); if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; if (GETPOST('mode', 'aZ09') == 'marginforalllines') { @@ -151,7 +151,7 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { print '
'; } } - print ''; + print ''; } if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarkRate').''; From 99e5c894843a6084489228a26e9eb94c29a0979b Mon Sep 17 00:00:00 2001 From: mgabriel Date: Thu, 2 Feb 2023 10:20:02 +0100 Subject: [PATCH 015/217] In CodingPhpTest::testPHP, found a GETPOST that uses 'none' as a parameter which is not allowe. --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 88f3c1e44aa..d3310085f1f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,7 +914,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines', 'none') !== '' && $usercancreate) { + } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { // Define margin $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); foreach ($object->lines as &$line) { From 463c87b393c9e5f96fd6e3c37caaf319a3bf77a2 Mon Sep 17 00:00:00 2001 From: hystepik Date: Thu, 2 Feb 2023 13:30:32 +0100 Subject: [PATCH 016/217] first push flowjs-server.php --- htdocs/core/ajax/flowjs-server.php | 146 +++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 htdocs/core/ajax/flowjs-server.php diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php new file mode 100644 index 00000000000..6177b6fda35 --- /dev/null +++ b/htdocs/core/ajax/flowjs-server.php @@ -0,0 +1,146 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/bankconciliate.php + * \brief File to set data for bank concilation + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date + +// Load Dolibarr environment +require '../../main.inc.php'; + + +$action = GETPOST('action', 'aZ09'); +$module = GETPOST('module', 'aZ09'); +$flowFilename = GETPOST('flowFilename', 'alpha'); +$flowIdentifier = GETPOST('flowIdentifier', 'alpha'); +$flowChunkNumber = GETPOST('flowChunkNumber', 'alpha'); +$flowChunkSize = GETPOST('flowChunkSize', 'alpha'); +$flowTotalSize = GETPOST('flowTotalSize', 'alpha'); + +/* + * Action + */ + + +top_httphead(); +dol_syslog(join(',', $_GET)); + +if ($_SERVER['REQUEST_METHOD'] === 'GET' ) { + $temp_dir = DOL_DATA_ROOT.'/'.$module.'/temp/'.$flowIdentifier; + $chunk_file = $temp_dir.'/'.$flowFilename.'.part'.$flowChunkNumber; + if (file_exists($chunk_file)) { + header("HTTP/1.0 200 Ok"); + } else { + header("HTTP/1.0 404 Not Found"); + } +} + + + +// loop through files and move the chunks to a temporarily created directory +if (!empty($_FILES)) foreach ($_FILES as $file) { + // check the error status + if ($file['error'] != 0) { + dol_syslog('error '.$file['error'].' in file '.$flowFilename); + continue; + } + + // init the destination file (format .part<#chunk> + // the file is stored in a temporary directory + $temp_dir = DOL_DATA_ROOT.'/'.$module.'/temp/'.$flowIdentifier; + $dest_file = $temp_dir.'/'.$flowFilename.'.part'.$flowChunkNumber; + + // create the temporary directory + if (!dol_is_dir($temp_dir)) { + dol_mkdir($temp_dir, '', 0777); + } + + // move the temporary file + if (!move_uploaded_file($file['tmp_name'], $dest_file)) { + dol_syslog('Error saving (move_uploaded_file) chunk '.$flowChunkNumber.' for file '.$flowFilename); + } else { + // check if all the parts present, and create the final destination file + createFileFromChunks($temp_dir, $flowFilename, $flowChunkSize, $flowTotalSize); + } +} + + +/** + * Check if all the parts exist, and + * gather all the parts of the file together + * @param string $temp_dir - the temporary directory holding all the parts of the file + * @param string $fileName - the original file name + * @param string $chunkSize - each chunk size (in bytes) + * @param string $totalSize - original file size (in bytes) + * @return bool true if Ok false else + */ +function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) +{ + + dol_syslog(__METHOD__, LOG_DEBUG); + // count all the parts of this file + $total_files = 0; + $files = dol_dir_list($temp_dir, 'files'); + foreach ($files as $file) { + if (stripos($file, $fileName) !== false) { + $total_files++; + } + } + + // check that all the parts are present + // the size of the last part is between chunkSize and 2*$chunkSize + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { + // create the final destination file + if (($fp = fopen($temp_dir.$fileName, 'w')) !== false) { + for ($i=1; $i<=$total_files; $i++) { + fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); + dol_syslog('writing chunk '.$i); + } + fclose($fp); + } else { + dol_syslog('cannot create the destination file'); + return false; + } + + /*// rename the temporary directory (to avoid access from other + // concurrent chunks uploads) and than delete it + if (rename($temp_dir, $temp_dir.'_UNUSED')) { + rrmdir($temp_dir.'_UNUSED'); + } else { + rrmdir($temp_dir); + }*/ + } + return true; +} From 2e7371eee649798adbab3d73dcbb54773ba73bde Mon Sep 17 00:00:00 2001 From: Guenter Lukas Date: Mon, 6 Feb 2023 08:45:44 +0100 Subject: [PATCH 017/217] Fix #23795 --- htdocs/comm/propal/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index eb8ac018979..c702cf66434 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -132,7 +132,6 @@ $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown // Security check if (!empty($user->socid)) { $socid = $user->socid; - $object->id = $user->socid; } restrictedArea($user, 'propal', $object->id); From b8cd507287008ac7e9bdf4bda5969dff203b1930 Mon Sep 17 00:00:00 2001 From: mgabriel Date: Mon, 6 Feb 2023 10:06:23 +0100 Subject: [PATCH 018/217] As suggested by Dolibarr, removed PROPALE_MODIFY_MARGIN_RATES as not needed. --- htdocs/admin/propal.php | 13 ------------- htdocs/comm/propal/card.php | 2 +- htdocs/core/tpl/objectline_title.tpl.php | 4 ++-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 289c514c703..10044e33b5b 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -615,19 +615,6 @@ print " \n"; print ""; -print ''; -print ''.$langs->trans("ModifyMarginRates").''; -print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('PROPALE_MODIFY_MARGIN_RATES'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("PROPALE_MODIFY_MARGIN_RATES", $arrval, $conf->global->PROPALE_MODIFY_MARGIN_RATES); -} -print "\n"; -print ''; -print "\n"; - print ""; print ''; print ""; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d3310085f1f..f1e191b323d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -914,7 +914,7 @@ if (empty($reshook)) { foreach ($object->lines as $line) { $result = $object->updateline($line->id, $line->subprice, $line->qty, $remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); } - } elseif (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { + } elseif ($action == 'addline' && GETPOST('submitforallmargins', 'alpha') && GETPOST('marginforalllines') !== '' && $usercancreate) { // Define margin $margin_rate = (GETPOST('marginforalllines') ? GETPOST('marginforalllines') : 0); foreach ($object->lines as &$line) { diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index e00a34551a5..24231d3fe68 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -140,9 +140,9 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { } } - if (!(empty($conf->global->DISPLAY_MARGIN_RATES) && empty($conf->global->PROPALE_MODIFY_MARGIN_RATES)) && $user->rights->margins->liretous) { + if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { print ''.$langs->trans('MarginRate'); - if (!empty($conf->global->PROPALE_MODIFY_MARGIN_RATES) && $user->hasRight("propal", "creer")) { + if ($user->hasRight("propal", "creer")) { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickmarginforalllines opacitymedium paddingleft cursorpointer"').''; if (GETPOST('mode', 'aZ09') == 'marginforalllines') { print '
'; From 72fc4c1d0b4fa78d5f0afe9129d0062b97a13e20 Mon Sep 17 00:00:00 2001 From: hystepik Date: Mon, 6 Feb 2023 12:24:19 +0100 Subject: [PATCH 019/217] add nologin --- htdocs/core/ajax/flowjs-server.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php index 6177b6fda35..0f536a52acc 100644 --- a/htdocs/core/ajax/flowjs-server.php +++ b/htdocs/core/ajax/flowjs-server.php @@ -35,6 +35,10 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date // Load Dolibarr environment From d034acb3ecdf5c4e3a69337ca2d93b7271e13c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina=20JOUM?= Date: Mon, 13 Feb 2023 12:13:02 +0100 Subject: [PATCH 020/217] add supplier --- htdocs/accountancy/class/accountancyexport.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 232df48761a..900da6890cf 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1913,14 +1913,16 @@ class AccountancyExport //Calcul de la longueur des numéros de comptes $taille_numero = strlen(length_accountg($line->numero_compte)); - //Création du numéro de client générique + //Création du numéro de client et fournisseur générique $numero_cpt_client = '411'; + $numero_cpt_fourn = '401'; for ($i = 1; $i <= ($taille_numero - 3); $i++) { $numero_cpt_client .= '0'; + $numero_cpt_fourn .= '0'; } - //Création des comptes auxiliaire des clients - if (length_accountg($line->numero_compte) == $numero_cpt_client) { + //Création des comptes auxiliaire des clients et fournisseur + if (length_accountg($line->numero_compte) == $numero_cpt_client || length_accountg($line->numero_compte) == $numero_cpt_fourn) { $tab[] = rtrim(length_accounta($line->subledger_account), "0"); } else { $tab[] = length_accountg($line->numero_compte); From a8daf57f715b35fff40ea1365e2bfc4167cc239b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 14:03:34 +0100 Subject: [PATCH 021/217] doc --- htdocs/asset/class/asset.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index c01f4b967c4..5cf9e748d00 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -157,6 +157,11 @@ class Asset extends CommonObject public $status; public $user_cloture_id; + /** + * @var Asset object oldcopy + */ + public $oldcopy; + // /** // * @var string Field with ID of parent key if this object has a parent // */ From 7af9834a0c7b99ebc13794747afd5d3b1a76c8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 21:28:20 +0100 Subject: [PATCH 022/217] enhance member tooltip --- htdocs/adherents/class/adherent.class.php | 4 ++++ htdocs/core/ajax/ajaxtooltip.php | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6e77fd3fa95..b84d622094d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2287,6 +2287,7 @@ class Adherent extends CommonObject global $conf, $langs; $datas = []; + $langs->loadLangs(['members', 'companies']); $nofetch = empty($params['nofetch']) ? false : true; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { @@ -2303,6 +2304,9 @@ class Adherent extends CommonObject $datas['divopen'] = '
'; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Member").' '.$this->getLibStatut(4); + if (!empty($this->morphy)) { + $datas['picto'] .= ' ' . $this->getmorphylib('', 1); + } if (!empty($this->ref)) { $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; } diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 3933f03533b..8652908eced 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -118,7 +118,6 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $module = 'contrat'; $myobject = 'contrat'; } elseif ($objecttype == 'member') { - $langs->load('members'); $classpath = 'adherents/class'; $module = 'adherent'; $myobject = 'adherent'; From e54020ea153b9dd8e49b13bebf68d36bb142a92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 21:32:43 +0100 Subject: [PATCH 023/217] enhance membertype tooltip --- htdocs/adherents/class/adherent_type.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a744ce71bdc..9534ed639ae 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -706,6 +706,9 @@ class AdherentType extends CommonObject if (isset($this->subscription)) { $datas['subscription'] = '
'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription); } + if (isset($this->vote)) { + $datas['vote'] = '
'.$langs->trans("VoteAllowed").': '.yn($this->vote); + } return $datas; } From bd1d487c382a1d12f098145f07d264b8a33af0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 21:40:48 +0100 Subject: [PATCH 024/217] enhance membertype tooltip --- htdocs/adherents/class/adherent_type.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9534ed639ae..ebf0a6fdb7a 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -709,6 +709,15 @@ class AdherentType extends CommonObject if (isset($this->vote)) { $datas['vote'] = '
'.$langs->trans("VoteAllowed").': '.yn($this->vote); } + if (isset($this->duration)) { + $datas['duration'] = '
'.$langs->trans("Duration").': '.$this->duration_value; + if ($this->duration_value > 1) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } elseif ($this->duration_value > 0) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + $datas['duration'] .= " " . (!empty($this->duration_unit) && isset($dur[$this->duration_unit]) ? $langs->trans($dur[$this->duration_unit]) : ''); + } return $datas; } @@ -736,6 +745,7 @@ class AdherentType extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; From 364e8a554ab0489a6506caae8529351010db81fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 21:47:44 +0100 Subject: [PATCH 025/217] enhance membertype tooltip --- htdocs/adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/type.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index ebf0a6fdb7a..eda018e6dca 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -712,7 +712,7 @@ class AdherentType extends CommonObject if (isset($this->duration)) { $datas['duration'] = '
'.$langs->trans("Duration").': '.$this->duration_value; if ($this->duration_value > 1) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($this->duration_value > 0) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c91915f7bdb..8b459e2c7b6 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -522,7 +522,7 @@ if ($rowid > 0) { print ''.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($object->duration_value > 0) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } From 3e91a4b1d142d48f47f911c5a471ecdf5a8232c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 22:51:46 +0100 Subject: [PATCH 026/217] enhance membertype tooltip --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c6cc2acc722..985bd288e30 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2740,7 +2740,7 @@ class FactureFournisseur extends CommonInvoice $alreadypaid = $this->alreadypaid; } - $$datas['picto'] .= ' '.$this->getLibStatut(5, $alreadypaid); + $datas['picto'] .= ' '.$this->getLibStatut(5, $alreadypaid); } if ($moretitle) { $datas['picto'] .= ' - '.$moretitle; From b9243376afb35086d1282f73570f9e86a4a7fc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 23:29:10 +0100 Subject: [PATCH 027/217] enhance shipping tooltip --- htdocs/expedition/class/expedition.class.php | 47 ++++++++++++++++--- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index dd6dfee55b1..812547ed317 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1784,6 +1784,30 @@ class Expedition extends CommonObject } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('shipping'); + $nofetch = empty($params['nofetch']) ? false : true; + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Shipment").''; + if (isset($this->statut)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['refcustomer'] = '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); + + return $datas; + } + /** * Return clicable link of object (with eventually picto) * @@ -1800,9 +1824,20 @@ class Expedition extends CommonObject global $langs, $conf, $hookmanager; $result = ''; - $label = ''.$langs->trans("Shipment").''; - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'nofetch' => 1, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); $url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id; @@ -1827,8 +1862,8 @@ class Expedition extends CommonObject $label = $langs->trans("Shipment"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= $this->ref; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 985bd288e30..c6cc2acc722 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2740,7 +2740,7 @@ class FactureFournisseur extends CommonInvoice $alreadypaid = $this->alreadypaid; } - $datas['picto'] .= ' '.$this->getLibStatut(5, $alreadypaid); + $$datas['picto'] .= ' '.$this->getLibStatut(5, $alreadypaid); } if ($moretitle) { $datas['picto'] .= ' - '.$moretitle; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e3a605a09aa..1b857f2a640 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1317,7 +1317,7 @@ class Holiday extends CommonObject if (isset($this->statut)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } - $datas['label'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; return $datas; } From adc7d1fae2f079f1f44fdd4b9cc53cf635c46348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 13 Feb 2023 23:42:08 +0100 Subject: [PATCH 028/217] enhance shipping tooltip --- htdocs/expedition/class/expedition.class.php | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 812547ed317..0592b5cfdcf 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -90,6 +90,15 @@ class Expedition extends CommonObject */ public $fields = array(); + /** + * @var int ID of user author + */ + public $user_author_id; + + /** + * @var int ID of user author + */ + public $fk_user_author; public $socid; @@ -175,8 +184,35 @@ class Expedition extends CommonObject public $meths; public $listmeths; // List of carriers + /** + * @var int ID of order + */ + public $commande_id; + + /** + * @var Commande order + */ + public $commande; + + /** + * @var ExpeditionLigne[] array of shipping lines + */ public $lines = array(); + // Multicurrency + /** + * @var int Currency ID + */ + public $fk_multicurrency; + + /** + * @var string multicurrency code + */ + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Draft status @@ -565,6 +601,7 @@ class Expedition extends CommonObject $this->ref_ext = $obj->ref_ext; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; + $this->fk_user_author = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_valid = $this->db->jdate($obj->date_valid); $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated From 67ada4bc9c67e0fe72894400065d848b597eb4ef Mon Sep 17 00:00:00 2001 From: HYWZ Date: Tue, 14 Feb 2023 10:46:13 +0300 Subject: [PATCH 029/217] add on common doc generator user attributs Add attributs : * myuser_birth * myuser_dateemployment * myuser_dateemploymentend * myuser_gender --- htdocs/core/class/commondocgenerator.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 33d5e5a97c6..1cd9eb9f05b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -145,7 +145,11 @@ abstract class CommonDocGenerator 'myuser_email'=>$user->email, 'myuser_logo'=>$logotouse, 'myuser_job'=>$user->job, - 'myuser_web'=>'' // url not exist in $user object + 'myuser_web'=>'' // url not exist in $user object, + 'myuser_birth'=>dol_print_date($user->birth, 'day', 'tzuser'), + 'myuser_dateemployment'=>dol_print_date($user->dateemployment, 'day', 'tzuser'), + 'myuser_dateemploymentend'=>dol_print_date($user->dateemploymentend, 'day', 'tzuser'), + 'myuser_gender'=>$user->gender, ); // Retrieve extrafields if (is_array($user->array_options) && count($user->array_options)) { From 8deecaff98e5b3a1372cb86c590434de59fc4ddd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 14 Feb 2023 07:48:26 +0000 Subject: [PATCH 030/217] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1cd9eb9f05b..86ac881ec13 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -147,9 +147,9 @@ abstract class CommonDocGenerator 'myuser_job'=>$user->job, 'myuser_web'=>'' // url not exist in $user object, 'myuser_birth'=>dol_print_date($user->birth, 'day', 'tzuser'), - 'myuser_dateemployment'=>dol_print_date($user->dateemployment, 'day', 'tzuser'), - 'myuser_dateemploymentend'=>dol_print_date($user->dateemploymentend, 'day', 'tzuser'), - 'myuser_gender'=>$user->gender, + 'myuser_dateemployment'=>dol_print_date($user->dateemployment, 'day', 'tzuser'), + 'myuser_dateemploymentend'=>dol_print_date($user->dateemploymentend, 'day', 'tzuser'), + 'myuser_gender'=>$user->gender, ); // Retrieve extrafields if (is_array($user->array_options) && count($user->array_options)) { From 00a6a07d5a685dd4aebf3dd27cf90b7a1760648a Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Tue, 14 Feb 2023 10:31:55 +0100 Subject: [PATCH 031/217] FIX - Shipping address fetch-thirdparty --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 7 ++++--- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 30a61fbb1d3..c3a8fcce500 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2135,9 +2135,10 @@ class pdf_crabe extends ModelePDFFactures if (!empty($idaddressshipping)) { $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);; @@ -2148,7 +2149,7 @@ class pdf_crabe extends ModelePDFFactures // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show shipping name diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 1d106f6f024..9aa96e147ab 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2384,9 +2384,10 @@ class pdf_sponge extends ModelePDFFactures if (!empty($idaddressshipping)) { $contactshipping = $object->fetch_Contact($idaddressshipping[0]); - $object->fetch_thirdparty($object->contact->fk_soc); + $companystatic = new Societe($this->db); + $companystatic->fetch($object->contact->fk_soc); $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs); - $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, $usecontact, 'target', $object); + $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object); } else { $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs); $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object); @@ -2397,7 +2398,7 @@ class pdf_sponge extends ModelePDFFactures // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $langs->trans('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show shipping name From 89a2f7a0c10054de042ec5fe33be3a4004c67c5a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Feb 2023 10:53:59 +0100 Subject: [PATCH 032/217] FIX multicompany compatibility --- htdocs/core/lib/signature.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php index c59acbea209..600f3878a0a 100644 --- a/htdocs/core/lib/signature.lib.php +++ b/htdocs/core/lib/signature.lib.php @@ -120,7 +120,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1) // For multicompany if (!empty($out) && !empty($conf->multicompany->enabled)) { - $out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities + $out .= "&entity=".$object->entity; // Check the entity because we may have the same reference in several entities } return $out; From 98976231c6f27deee9b5227b441fedb83f0935ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 14:23:12 +0100 Subject: [PATCH 033/217] Use recent model by default --- htdocs/core/modules/modCommande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index d7b9d6da1ed..4fae3b1e0c9 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -79,7 +79,7 @@ class modCommande extends DolibarrModules $this->const[$r][0] = "COMMANDE_ADDON_PDF"; $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "einstein"; + $this->const[$r][2] = "eratosthene"; $this->const[$r][3] = 'Name of PDF model of order'; $this->const[$r][4] = 0; From 6745860cac8cc01d263f847c835808af529c48c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 20:24:07 +0100 Subject: [PATCH 034/217] clean code --- htdocs/societe/class/societe.class.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e180d9ab13e..37d383e69a7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2716,25 +2716,28 @@ class Societe extends CommonObject if (!empty($this->code_client) && ($this->client == 1 || $this->client == 3)) { $datas['customercode'] = '
'.$langs->trans('CustomerCode').': '.$this->code_client; } + if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) { + $langs->load('compta'); + $datas['accountancycustomercode'] = '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); + } + // show categories for this record only in ajax to not overload lists + if (!$nofetch && isModEnabled('categorie') && $this->client) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $form = new Form($this->db); + $datas['categories_customer'] = '
' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1, 1); + } if (!empty($this->code_fournisseur) && $this->fournisseur) { $datas['suppliercode'] = '
'.$langs->trans('SupplierCode').': '.$this->code_fournisseur; } - if (isModEnabled('accounting') && ($this->client == 1 || $this->client == 3)) { - $datas['accountancycustomercode'] = '
'.$langs->trans('CustomerAccountancyCode').': '.($this->code_compta ? $this->code_compta : $this->code_compta_client); - } if (isModEnabled('accounting') && $this->fournisseur) { + $langs->load('compta'); $datas['accountancysuppliercode'] = '
'.$langs->trans('SupplierAccountancyCode').': '.$this->code_compta_fournisseur; } // show categories for this record only in ajax to not overload lists - if (isModEnabled('categorie') && !$nofetch) { + if (!$nofetch && isModEnabled('categorie') && $this->fournisseur) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $form = new Form($this->db); - if ($this->client) { - $datas['categories_customer'] = '
' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1); - } - if ($this->fournisseur) { - $datas['categories_supplier'] = '
' . $form->showCategories($this->id, Categorie::TYPE_SUPPLIER, 1); - } + $datas['categories_supplier'] = '
' . $form->showCategories($this->id, Categorie::TYPE_SUPPLIER, 1, 1); } $datas['divclose'] = '
'; From f0a7deb3f78af076ce8d6fb50fee9f5577f962ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 20:39:23 +0100 Subject: [PATCH 035/217] doc --- htdocs/societe/class/societe.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e180d9ab13e..cf8fd42c6d8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -615,10 +615,11 @@ class Societe extends CommonObject /** * Duplicate of code_compta_client (for backward compatibility) * @var string + * @deprecated + * @see $code_compta_client */ public $code_compta; - /** * Accounting code for customer * @var string @@ -637,14 +638,12 @@ class Societe extends CommonObject */ public $accountancy_code_supplier; - /** * Accounting code for product (for level 3 of suggestion of prouct accounting account) * @var string */ public $code_compta_product; - /** * @var string * @deprecated Note is split in public and private notes From 7e307b9e19d6f9dc18195621adba4927b5fa07b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 20:48:53 +0100 Subject: [PATCH 036/217] colspan --- htdocs/hrm/skill_card.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 9c5de6bf7f5..d5b62b26151 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -774,16 +775,16 @@ if ($action != "create" && $action != "edit") { // LINE EDITION | SUPPRESSION print ''; - print ''; - print ''; + + // print ''; // add pencil //@todo change to proper call dol_ //print 'id, 1) . '">'; // add trash //@todo change to proper call dol_ //print 'id,1) .'">'; - //print ''; + // print ''; // Fields from hook @@ -807,7 +808,7 @@ if ($action != "create" && $action != "edit") { // If no record found if ($num == 0) { - $colspan = 1; + $colspan = 2; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { $colspan++; From bd5dc3dbcc7bbf94f405de31c386fa181a5cdc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 21:00:34 +0100 Subject: [PATCH 037/217] add ajaxtooltip on expensereport --- .../class/expensereport.class.php | 76 ++++++++++++++----- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a3c726ef521..9e60ac4b8c7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1693,6 +1693,44 @@ class ExpenseReport extends CommonObject } } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs; + + $langs->load('expensereport'); + $nofetch = empty($params['nofetch']) ? false : true; + $moretitle = $params['moretitle'] ?? ''; + $datas = []; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ExpenseReport").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + if ($moretitle) { + $datas['picto'] .= ' - '.$moretitle; + } + if (!empty($this->ref)) { + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->total_ht)) { + $datas['total_ht'] = '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_tva)) { + $datas['total_tva'] = '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + } + if (!empty($this->total_ttc)) { + $datas['total_ttc'] = '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); + } + + return $datas; + } + /** * Return clicable name (with picto eventually) * @@ -1717,25 +1755,21 @@ class ExpenseReport extends CommonObject return $url; } - $label = img_picto('', $this->picto).' '.$langs->trans("ExpenseReport").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - if (!empty($this->ref)) { - $label .= '
'.$langs->trans('Ref').': '.$this->ref; - } - if (!empty($this->total_ht)) { - $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); - } - if (!empty($this->total_ttc)) { - $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); - } - if ($moretitle) { - $label .= ' - '.$moretitle; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + 'moretitle' => $moretitle, + 'nofetch' => 1, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params='.json_encode($params); + // $label = $langs->trans('Loading'); } + $label = implode($this->getTooltipContentArray($params)); if ($option != 'nolink') { // Add param to save lastsearch_values or not @@ -1759,8 +1793,8 @@ class ExpenseReport extends CommonObject $label = $langs->trans("ShowExpenseReport"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip"'; + $linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="'.$classfortooltip.'"'; } $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { $result .= ($max ? dol_trunc($ref, $max) : $ref); From ae4857113538d51ccd63e73be26752375fcbe426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Feb 2023 22:56:12 +0100 Subject: [PATCH 038/217] use user->hasRight --- htdocs/comm/card.php | 20 ++++----- htdocs/comm/index.php | 4 +- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/comm/propal/contact.php | 6 +-- htdocs/comm/propal/index.php | 2 +- htdocs/comm/prospect/index.php | 4 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/commande/contact.php | 6 +-- htdocs/compta/facture/card-rec.php | 42 +++++++++---------- htdocs/compta/facture/card.php | 12 +++--- htdocs/compta/facture/contact.php | 6 +-- htdocs/compta/facture/prelevement.php | 12 +++--- htdocs/compta/recap-compta.php | 2 +- htdocs/contact/consumption.php | 8 ++-- htdocs/contrat/card.php | 30 ++++++------- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/contrat/contact.php | 6 +-- htdocs/contrat/index.php | 2 +- htdocs/core/ajax/loadinplace.php | 2 +- htdocs/core/ajax/row.php | 8 ++-- htdocs/core/boxes/box_services_contracts.php | 2 +- htdocs/core/lib/product.lib.php | 10 ++--- .../doc/doc_generic_project_odt.modules.php | 10 ++--- .../project/doc/pdf_beluga.modules.php | 10 ++--- htdocs/expedition/shipment.php | 22 +++++----- htdocs/fichinter/card.php | 2 +- htdocs/product/card.php | 6 +-- htdocs/projet/card.php | 8 ++-- htdocs/projet/tasks/time.php | 2 +- htdocs/societe/consumption.php | 8 ++-- htdocs/societe/paymentmodes.php | 16 +++---- .../class/supplier_proposal.class.php | 2 +- htdocs/takepos/invoice.php | 5 +-- 34 files changed, 141 insertions(+), 142 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 46343919cb6..8c4a5197b77 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -699,7 +699,7 @@ if ($object->id > 0) { $boxstat .= ''; $boxstat .= ''; if ($object->thirdparty->client) { $thirdTypeArray['customer'] = $langs->trans("customer"); - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if (isModEnabled('contrat') && $user->rights->contrat->lire) { + if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 54779bb692d..10fe45ced69 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -214,7 +214,7 @@ if (empty($reshook)) { } // Add contract - if ($action == 'add' && $user->rights->contrat->creer) { + if ($action == 'add' && $user->hasRight('contrat', 'creer')) { // Check if (empty($datecontrat)) { $error++; @@ -408,9 +408,9 @@ if (empty($reshook)) { $action = 'create'; } } - } elseif ($action == 'classin' && $user->rights->contrat->creer) { + } elseif ($action == 'classin' && $user->hasRight('contrat', 'creer')) { $object->setProject(GETPOST('projectid')); - } elseif ($action == 'addline' && $user->rights->contrat->creer) { + } elseif ($action == 'addline' && $user->hasRight('contrat', 'creer')) { // Add a new line // Set if we used free entry or predefined product $predef = ''; @@ -682,7 +682,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'updateline' && $user->hasRight('contrat', 'creer') && !GETPOST('cancel', 'alpha')) { $error = 0; $predef = ''; @@ -795,7 +795,7 @@ if (empty($reshook)) { } else { $db->rollback(); } - } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $result = $object->deleteline(GETPOST('lineid', 'int'), $user); if ($result >= 0) { @@ -804,7 +804,7 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $result = $object->validate($user); if ($result > 0) { @@ -830,18 +830,18 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'reopen' && $user->rights->contrat->creer) { + } elseif ($action == 'reopen' && $user->hasRight('contrat', 'creer')) { $result = $object->reopen($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { // Close all lines $result = $object->closeAll($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $date_start = dol_mktime(12, 0, 0, GETPOST('d_startmonth'), GETPOST('d_startday'), GETPOST('d_startyear')); $date_end = dol_mktime(12, 0, 0, GETPOST('d_endmonth'), GETPOST('d_endday'), GETPOST('d_endyear')); $comment = GETPOST('comment', 'alpha'); @@ -857,7 +857,7 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); $result = $contractline->fetch(GETPOSTINT('lineid')); @@ -995,7 +995,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->hasRight('contrat', 'creer')) { if ($action == 'addcontact') { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -1351,7 +1351,7 @@ if ($action == 'create') { // Contract - if (!empty($object->brouillon) && $user->rights->contrat->creer) { + if (!empty($object->brouillon) && $user->hasRight('contrat', 'creer')) { print ''; print ''; print ''; @@ -1448,7 +1448,7 @@ if ($action == 'create') { print ''; - if (!empty($object->brouillon) && $user->rights->contrat->creer) { + if (!empty($object->brouillon) && $user->hasRight('contrat', 'creer')) { print ''; } @@ -1826,7 +1826,7 @@ if ($action == 'create') { /* * Confirmation to delete service line of contract */ - if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { + if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1); if ($ret == 'html') { print '
'; - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { // Box proposals $tmp = $object->getOutstandingProposals(); $outstandingOpened = $tmp['opened']; @@ -720,7 +720,7 @@ if ($object->id > 0) { } } - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { // Box commandes $tmp = $object->getOutstandingOrders(); $outstandingOpened = $tmp['opened']; @@ -741,7 +741,7 @@ if ($object->id > 0) { } } - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { // Box factures $tmp = $object->getOutstandingBills('customer', 0); $outstandingOpened = $tmp['opened']; @@ -820,7 +820,7 @@ if ($object->id > 0) { /* * Latest proposals */ - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $langs->load("propal"); $sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht"; @@ -915,7 +915,7 @@ if ($object->id > 0) { /* * Latest orders */ - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $param =""; $sql = "SELECT s.nom, s.rowid"; @@ -1124,7 +1124,7 @@ if ($object->id > 0) { /* * Latest contracts */ - if (isModEnabled('contrat') && $user->rights->contrat->lire) { + if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,"; $sql .= " c.last_main_doc, c.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; @@ -1318,7 +1318,7 @@ if ($object->id > 0) { /* * Latest invoices templates */ - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $sql = 'SELECT f.rowid as id, f.titre as ref'; $sql .= ', f.total_ht'; $sql .= ', f.total_tva'; @@ -1413,7 +1413,7 @@ if ($object->id > 0) { /* * Latest invoices */ - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $sql = 'SELECT f.rowid as facid, f.ref, f.type'; $sql .= ', f.total_ht'; $sql .= ', f.total_tva'; @@ -1557,12 +1557,12 @@ if ($object->id > 0) { print ''; } - if (isModEnabled("propal") && $user->rights->propal->creer && $object->status == 1) { + if (isModEnabled("propal") && $user->hasRight('propal', 'creer') && $object->status == 1) { $langs->load("propal"); print ''; } - if (isModEnabled('commande') && $user->rights->commande->creer && $object->status == 1) { + if (isModEnabled('commande') && $user->hasRight('commande', 'creer') && $object->status == 1) { $langs->load("orders"); print ''; } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5d71683a311..8987d4ed25f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -321,7 +321,7 @@ if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "l * Draft sales orders */ -if (isModEnabled('commande') && $user->rights->commande->lire) { +if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.total_tva, c.total_ttc, c.fk_statut as status"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; @@ -1008,7 +1008,7 @@ if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { /* * Opened (validated) order */ -if (isModEnabled('commande') && $user->rights->commande->lire) { +if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $sql = "SELECT c.rowid as commandeid, c.total_ttc, c.total_ht, c.total_tva, c.ref, c.ref_client, c.fk_statut, c.date_valid as dv, c.facture as billed"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3f74c4a860f..662a187d1c3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -789,7 +789,7 @@ if (empty($reshook)) { } } } elseif ($action == 'import_lines_from_object' - && $user->rights->propal->creer + && $user->hasRight('propal', 'creer') && $object->statut == Propal::STATUS_DRAFT ) { // add lines from objectlinked diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3a48230de40..da9082da8bc 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3795,7 +3795,7 @@ class Propal extends CommonObject } $linkclose = ''; - if (empty($notooltip) && $user->rights->propal->lire) { + if (empty($notooltip) && $user->hasRight('propal', 'lire')) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Proposal"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 45f2d175f9a..0c616ca2579 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -76,7 +76,7 @@ $usercancreate = $user->hasRight("propal", "creer"); * Add a new contact */ -if ($action == 'addcontact' && $user->rights->propal->creer) { +if ($action == 'addcontact' && $user->hasRight('propal', 'creer')) { if ($object->id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -94,12 +94,12 @@ if ($action == 'addcontact' && $user->rights->propal->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'swapstatut' && $user->rights->propal->creer) { +} elseif ($action == 'swapstatut' && $user->hasRight('propal', 'creer')) { // Toggle the status of a contact if ($object->id > 0) { $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } -} elseif ($action == 'deletecontact' && $user->rights->propal->creer) { +} elseif ($action == 'deletecontact' && $user->hasRight('propal', 'creer')) { // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 4a6d9ec63ed..ef5c295bd72 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -227,7 +227,7 @@ if ($resql) { /* * Open (validated) proposals */ -if (isModEnabled("propal") && $user->rights->propal->lire) { +if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta"; $sql .= ", p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 19bde7072ad..13932d7da0c 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -119,7 +119,7 @@ if ($resql) { /* * Liste des propal brouillons */ -if (isModEnabled("propal") && $user->rights->propal->lire) { +if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as p"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -177,7 +177,7 @@ if (isModEnabled('agenda')) { /* * Dernieres propales ouvertes */ -if (isModEnabled("propal") && $user->rights->propal->lire) { +if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,"; $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5b111f67e6c..38e3accc1fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3820,7 +3820,7 @@ class Commande extends CommonOrder $label = implode($this->getTooltipContentArray($params)); $linkclose = ''; - if (empty($notooltip) && $user->rights->commande->lire) { + if (empty($notooltip) && $user->hasRight('commande', 'lire')) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("Order"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index a6202d5d3bf..a5fc715eb38 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -56,7 +56,7 @@ $object = new Commande($db); * Ajout d'un nouveau contact */ -if ($action == 'addcontact' && $user->rights->commande->creer) { +if ($action == 'addcontact' && $user->hasRight('commande', 'creer')) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { @@ -76,14 +76,14 @@ if ($action == 'addcontact' && $user->rights->commande->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'swapstatut' && $user->rights->commande->creer) { +} elseif ($action == 'swapstatut' && $user->hasRight('commande', 'creer')) { // bascule du statut d'un contact if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { dol_print_error($db); } -} elseif ($action == 'deletecontact' && $user->rights->commande->creer) { +} elseif ($action == 'deletecontact' && $user->hasRight('commande', 'creer')) { // Efface un contact $object->fetch($id); $result = $object->delete_contact(GETPOST("lineid", 'int')); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index e29c5ca1bb3..1af465a806c 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -281,15 +281,15 @@ if (empty($reshook)) { // Update field // Set condition - if ($action == 'setconditions' && $user->rights->facture->creer) { + if ($action == 'setconditions' && $user->hasRight('facture', 'creer')) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - } elseif ($action == 'setmode' && $user->rights->facture->creer) { + } elseif ($action == 'setmode' && $user->hasRight('facture', 'creer')) { // Set mode $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } elseif ($action == 'classin' && $user->rights->facture->creer) { + } elseif ($action == 'classin' && $user->hasRight('facture', 'creer')) { // Set project $object->setProject(GETPOST('projectid', 'int')); - } elseif ($action == 'setref' && $user->rights->facture->creer) { + } elseif ($action == 'setref' && $user->hasRight('facture', 'creer')) { // Set bank account //var_dump(GETPOST('ref', 'alpha'));exit; $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); @@ -306,31 +306,31 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { + } elseif ($action == 'setbankaccount' && $user->hasRight('facture', 'creer')) { // Set bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } elseif ($action == 'setfrequency' && $user->rights->facture->creer) { + } elseif ($action == 'setfrequency' && $user->hasRight('facture', 'creer')) { // Set frequency and unit frequency $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); - } elseif ($action == 'setdate_when' && $user->rights->facture->creer) { + } elseif ($action == 'setdate_when' && $user->hasRight('facture', 'creer')) { // Set next date of execution $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); if (!empty($date)) { $object->setNextDate($date); } - } elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) { + } elseif ($action == 'setnb_gen_max' && $user->hasRight('facture', 'creer')) { // Set max period $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); - } elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { + } elseif ($action == 'setauto_validate' && $user->hasRight('facture', 'creer')) { // Set auto validate $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { + } elseif ($action == 'setgenerate_pdf' && $user->hasRight('facture', 'creer')) { // Set generate pdf $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); - } elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) { + } elseif ($action == 'setmodelpdf' && $user->hasRight('facture', 'creer')) { // Set model pdf $object->setModelpdf(GETPOST('modelpdf', 'alpha')); - } elseif ($action == 'disable' && $user->rights->facture->creer) { + } elseif ($action == 'disable' && $user->hasRight('facture', 'creer')) { // Set status disabled $db->begin(); @@ -347,7 +347,7 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'enable' && $user->rights->facture->creer) { + } elseif ($action == 'enable' && $user->hasRight('facture', 'creer')) { // Set status enabled $db->begin(); @@ -373,7 +373,7 @@ if (empty($reshook)) { } // Delete line - if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) { + if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('facture', 'creer')) { $object->fetch($id); $object->fetch_thirdparty(); @@ -417,7 +417,7 @@ if (empty($reshook)) { } // Add a new line - if ($action == 'addline' && $user->rights->facture->creer) { + if ($action == 'addline' && $user->hasRight('facture', 'creer')) { $langs->load('errors'); $error = 0; @@ -1288,7 +1288,7 @@ if ($action == 'create') { print ''; - if ($action != 'editconditions' && $user->rights->facture->creer) { + if ($action != 'editconditions' && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; @@ -1309,7 +1309,7 @@ if ($action == 'create') { print ''; - if ($action != 'editmode' && $user->rights->facture->creer) { + if ($action != 'editmode' && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -1418,7 +1418,7 @@ if ($action == 'create') { print ''; } print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) { + if (($action != 'editbankaccount') && $user->hasRight('facture', 'creer') && $object->statut == FactureRec::STATUS_DRAFT) { print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; @@ -1436,7 +1436,7 @@ if ($action == 'create') { print ''; } print '
'; print $langs->trans('Model'); print ''; - if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) { + if (($action != 'editmodelpdf') && $user->hasRight('facture', 'creer') && $object->statut == FactureRec::STATUS_DRAFT) { print 'id.'">'.img_edit($langs->trans('SetModel'), 1).'
'; @@ -1482,7 +1482,7 @@ if ($action == 'create') { print ''; - if ($action != 'editfrequency' && $user->rights->facture->creer) { + if ($action != 'editfrequency' && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('Frequency'); print 'id.'">'.img_edit($langs->trans('Edit'), 1).'
'; @@ -1639,7 +1639,7 @@ if ($action == 'create') { } // Form to add new line - if ($object->statut == $object::STATUS_DRAFT && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { + if ($object->statut == $object::STATUS_DRAFT && $user->hasRight('facture', 'creer') && $action != 'valid' && $action != 'editline') { if ($action != 'editline') { // Add free products/services diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3ce88a4a588..220a27436ce 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -391,7 +391,7 @@ if (empty($reshook)) { if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setretainedwarrantyconditions' && $user->rights->facture->creer) { + } elseif ($action == 'setretainedwarrantyconditions' && $user->hasRight('facture', 'creer')) { $object->fetch($id); $object->retained_warranty_fk_cond_reglement = 0; // To clean property $result = $object->setRetainedWarrantyPaymentTerms(GETPOST('retained_warranty_fk_cond_reglement', 'int')); @@ -411,13 +411,13 @@ if (empty($reshook)) { if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { + } elseif ($action == 'setretainedwarranty' && $user->hasRight('facture', 'creer')) { $object->fetch($id); $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { + } elseif ($action == 'setretainedwarrantydatelimit' && $user->hasRight('facture', 'creer')) { $object->fetch($id); $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) { @@ -4684,7 +4684,7 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarranty' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4707,7 +4707,7 @@ if ($action == 'create') { print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarrantypaymentterms' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4742,7 +4742,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarrantydatelimit' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 2548284f97f..38d51f7b8b8 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -65,7 +65,7 @@ $usercancreate = $user->hasRight("facture", "creer"); * Add a new contact */ -if ($action == 'addcontact' && $user->rights->facture->creer) { +if ($action == 'addcontact' && $user->hasRight('facture', 'creer')) { if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -83,10 +83,10 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'swapstatut' && $user->rights->facture->creer) { +} elseif ($action == 'swapstatut' && $user->hasRight('facture', 'creer')) { // Toggle the status of a contact $result = $object->swapContactStatus(GETPOST('ligne', 'int')); -} elseif ($action == 'deletecontact' && $user->rights->facture->creer) { +} elseif ($action == 'deletecontact' && $user->hasRight('facture', 'creer')) { // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 790dc9e26ca..8af2972e1a0 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -483,7 +483,7 @@ if ($object->id > 0) { print '
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
'; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('DateInvoice'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'
'; @@ -506,7 +506,7 @@ if ($object->id > 0) { print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetConditions'), 1).'
'; @@ -527,7 +527,7 @@ if ($object->id > 0) { print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('DateMaxPayment'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'
'; @@ -556,7 +556,7 @@ if ($object->id > 0) { print ''; - if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($action != 'editmode' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentMode'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -577,7 +577,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) { + if (($action != 'editbankaccount') && $user->hasRight('commande', 'creer') && !empty($object->brouillon)) { print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; @@ -662,7 +662,7 @@ if ($object->id > 0) { print ''; - if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('RevenueStamp'); print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
'; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index b8986a449ce..0808e5a7aab 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -117,7 +117,7 @@ if ($id > 0) { dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1); print dol_get_fiche_end(); - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { // Invoice list print load_fiche_titre($langs->trans("CustomerPreview")); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index bbd5bf005d2..3e7a1554367 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -156,16 +156,16 @@ print '
'; @@ -1836,7 +1836,7 @@ if ($action == 'create') { /* * Confirmation to move service toward another contract */ - if ($action == 'move' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { + if ($action == 'move' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { $arraycontractid = array(); foreach ($arrayothercontracts as $contractcursor) { $arraycontractid[$contractcursor->id] = $contractcursor->ref; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 97b586a2cde..c35b0c3515f 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2062,7 +2062,7 @@ class Contrat extends CommonObject $label = implode($this->getTooltipContentArray($params)); $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) { + if (empty($notooltip) && $user->hasRight('contrat', 'lire')) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContract"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 6ca7b9b86ef..2af24364604 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -61,7 +61,7 @@ $permissiontoadd = $user->rights->contrat->creer; // Used by the include * Actions */ -if ($action == 'addcontact' && $user->rights->contrat->creer) { +if ($action == 'addcontact' && $user->hasRight('contrat', 'creer')) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { @@ -86,7 +86,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { } // bascule du statut d'un contact -if ($action == 'swapstatut' && $user->rights->contrat->creer) { +if ($action == 'swapstatut' && $user->hasRight('contrat', 'creer')) { if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { @@ -95,7 +95,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { } // Delete contact -if ($action == 'deletecontact' && $user->rights->contrat->creer) { +if ($action == 'deletecontact' && $user->hasRight('contrat', 'creer')) { $object->fetch($id); $result = $object->delete_contact(GETPOST("lineid", 'int')); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index c40453ec7af..a8ca8a67444 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -239,7 +239,7 @@ print "

"; // Draft contracts -if (isModEnabled('contrat') && $user->rights->contrat->lire) { +if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $sql = "SELECT c.rowid, c.ref,"; $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 1cdecf6306d..af033c8cdd3 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -80,7 +80,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e if ($user->rights->$element->lire || $user->rights->$element->read || (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read)) - || ($element == 'payment' && $user->rights->facture->lire) + || ($element == 'payment' && $user->hasRight('facture', 'lire')) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire)) { if ($type == 'select') { $methodname = 'load_cache_'.$loadmethod; diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 0254a7502f8..ec3ee105420 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -74,13 +74,13 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) // Make test on permission $perm = 0; - if ($table_element_line == 'propaldet' && $user->rights->propal->creer) { + if ($table_element_line == 'propaldet' && $user->hasRight('propal', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'commandedet' && $user->rights->commande->creer) { + } elseif ($table_element_line == 'commandedet' && $user->hasRight('commande', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'facturedet' && $user->rights->facture->creer) { + } elseif ($table_element_line == 'facturedet' && $user->hasRight('facture', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'facturedet_rec' && $user->rights->facture->creer) { + } elseif ($table_element_line == 'facturedet_rec' && $user->hasRight('facture', 'creer')) { $perm = 1; } elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) { $perm = 1; diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 433db55a515..81cd361f4a1 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -81,7 +81,7 @@ class box_services_contracts extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max)); - if ($user->rights->service->lire && $user->rights->contrat->lire) { + if ($user->rights->service->lire && $user->hasRight('contrat', 'lire')) { $contractstatic = new Contrat($this->db); $contractlinestatic = new ContratLigne($this->db); $thirdpartytmp = new Societe($this->db); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e919bf2c8b6..8fc0ce26f7d 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -432,7 +432,7 @@ function show_stats_for_company($product, $socid) print ''; // Customer proposals - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $nblines++; $ret = $product->load_stats_propale($socid); if ($ret < 0) { @@ -470,7 +470,7 @@ function show_stats_for_company($product, $socid) print ''; } // Sales orders - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $nblines++; $ret = $product->load_stats_commande($socid); if ($ret < 0) { @@ -508,7 +508,7 @@ function show_stats_for_company($product, $socid) print ''; } // Customer invoices - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $nblines++; $ret = $product->load_stats_facture($socid); if ($ret < 0) { @@ -527,7 +527,7 @@ function show_stats_for_company($product, $socid) print ''; } // Customer template invoices - if (isModEnabled("facture") && $user->rights->facture->lire) { + if (isModEnabled("facture") && $user->hasRight('facture', 'lire')) { $nblines++; $ret = $product->load_stats_facturerec($socid); if ($ret < 0) { @@ -566,7 +566,7 @@ function show_stats_for_company($product, $socid) } // Contracts - if (isModEnabled('contrat') && $user->rights->contrat->lire) { + if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $nblines++; $ret = $product->load_stats_contrat($socid); if ($ret < 0) { diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index f08a93b4339..6afa6d2efc6 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -945,25 +945,25 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListProposalsAssociatedProject", 'class' => 'Propal', 'table' => 'propal', - 'test' => $conf->propal->enabled && $user->rights->propal->lire + 'test' => $conf->propal->enabled && $user->hasRight('propal', 'lire') ), 'order' => array( 'title' => "ListOrdersAssociatedProject", 'class' => 'Commande', 'table' => 'commande', - 'test' => $conf->commande->enabled && $user->rights->commande->lire + 'test' => $conf->commande->enabled && $user->hasRight('commande', 'lire') ), 'invoice' => array( 'title' => "ListInvoicesAssociatedProject", 'class' => 'Facture', 'table' => 'facture', - 'test' => $conf->facture->enabled && $user->rights->facture->lire + 'test' => $conf->facture->enabled && $user->hasRight('facture', 'lire') ), 'invoice_predefined' => array( 'title' => "ListPredefinedInvoicesAssociatedProject", 'class' => 'FactureRec', 'table' => 'facture_rec', - 'test' => $conf->facture->enabled && $user->rights->facture->lire + 'test' => $conf->facture->enabled && $user->hasRight('facture', 'lire') ), 'proposal_supplier' => array( 'title' => "ListSupplierProposalsAssociatedProject", @@ -987,7 +987,7 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListContractAssociatedProject", 'class' => 'Contrat', 'table' => 'contrat', - 'test' => $conf->contrat->enabled && $user->rights->contrat->lire + 'test' => $conf->contrat->enabled && $user->hasRight('contrat', 'lire') ), 'intervention' => array( 'title' => "ListFichinterAssociatedProject", diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 7cf7c96aef2..8d13e69bdfe 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -374,7 +374,7 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'test'=>$conf->propal->enabled && $user->rights->propal->lire, + 'test'=>$conf->propal->enabled && $user->hasRight('propal', 'lire'), 'lang'=>'propal'), 'order'=>array( 'name'=>"CustomersOrders", @@ -382,7 +382,7 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'Commande', 'table'=>'commande', 'datefieldname'=>'date_commande', - 'test'=>$conf->commande->enabled && $user->rights->commande->lire, + 'test'=>$conf->commande->enabled && $user->hasRight('commande', 'lire'), 'lang'=>'orders'), 'invoice'=>array( 'name'=>"CustomersInvoices", @@ -391,7 +391,7 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'add', 'table'=>'facture', 'datefieldname'=>'datef', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'test'=>$conf->facture->enabled && $user->hasRight('facture', 'lire'), 'lang'=>'bills'), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", @@ -399,7 +399,7 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'FactureRec', 'table'=>'facture_rec', 'datefieldname'=>'datec', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'test'=>$conf->facture->enabled && $user->hasRight('facture', 'lire'), 'lang'=>'bills'), 'order_supplier'=>array( 'name'=>"SuppliersOrders", @@ -424,7 +424,7 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'Contrat', 'table'=>'contrat', 'datefieldname'=>'date_contrat', - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, + 'test'=>$conf->contrat->enabled && $user->hasRight('contrat', 'lire'), 'lang'=>'contract'), 'intervention'=>array( 'name'=>"Interventions", diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index b4a89c5be30..c61249877a3 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -104,7 +104,7 @@ if (empty($reshook)) { if ($action == 'confirm_cloture' && GETPOST('confirm', 'alpha') == 'yes') { $object->fetch($id); $result = $object->cloture($user); - } elseif ($action == 'setref_client' && $user->rights->commande->creer) { + } elseif ($action == 'setref_client' && $user->hasRight('commande', 'creer')) { // Positionne ref commande client $result = $object->set_ref_client($user, GETPOST('ref_client')); if ($result < 0) { @@ -112,7 +112,7 @@ if (empty($reshook)) { } } - if ($action == 'setdatedelivery' && $user->rights->commande->creer) { + if ($action == 'setdatedelivery' && $user->hasRight('commande', 'creer')) { $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); @@ -122,7 +122,7 @@ if (empty($reshook)) { } } /* - if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) + if ($action == 'setdeliveryaddress' && $user->hasRight('commande', 'creer')) { $object = new Commande($db); $object->fetch($id); @@ -131,7 +131,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } */ - if ($action == 'setmode' && $user->rights->commande->creer) { + if ($action == 'setmode' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) { @@ -139,7 +139,7 @@ if (empty($reshook)) { } } - if ($action == 'setavailability' && $user->rights->commande->creer) { + if ($action == 'setavailability' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->availability(GETPOST('availability_id')); if ($result < 0) { @@ -147,7 +147,7 @@ if (empty($reshook)) { } } - if ($action == 'setdemandreason' && $user->rights->commande->creer) { + if ($action == 'setdemandreason' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) { @@ -155,7 +155,7 @@ if (empty($reshook)) { } } - if ($action == 'setconditions' && $user->rights->commande->creer) { + if ($action == 'setconditions' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { @@ -170,7 +170,7 @@ if (empty($reshook)) { } // shipping method - if ($action == 'setshippingmethod' && $user->rights->commande->creer) { + if ($action == 'setshippingmethod' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { @@ -179,7 +179,7 @@ if (empty($reshook)) { } // warehouse - if ($action == 'setwarehouse' && $user->rights->commande->creer) { + if ($action == 'setwarehouse' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) { @@ -210,7 +210,7 @@ if (empty($reshook)) { } } - if ($action == 'set_thirdparty' && $user->rights->commande->creer) { + if ($action == 'set_thirdparty' && $user->hasRight('commande', 'creer')) { $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); @@ -427,7 +427,7 @@ if ($id > 0 || !empty($ref)) { print ''; - if ($action != 'editwarehouse' && $user->rights->commande->creer) { + if ($action != 'editwarehouse' && $user->hasRight('commande', 'creer')) { print ''; } print '
'; print $langs->trans('Warehouse'); print 'id.'">'.img_edit($langs->trans('SetWarehouse'), 1).'
'; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index accf1bb3cb5..253fcd004fd 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) { if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setcontract' && $user->rights->contrat->creer) { + } elseif ($action == 'setcontract' && $user->hasRight('contrat', 'creer')) { // Set into a contract $result = $object->set_contrat($user, GETPOST('contratid', 'int')); if ($result < 0) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5f58678985a..610bd41b1c1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2846,7 +2846,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == //print '
'; // Propals - if (isModEnabled("propal") && $user->rights->propal->creer) { + if (isModEnabled("propal") && $user->hasRight('propal', 'creer')) { $propal = new Propal($db); $langs->load("propal"); @@ -2867,7 +2867,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Commande - if (isModEnabled('commande') && $user->rights->commande->creer) { + if (isModEnabled('commande') && $user->hasRight('commande', 'creer')) { $commande = new Commande($db); $langs->load("orders"); @@ -2887,7 +2887,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Factures - if (isModEnabled('facture') && $user->rights->facture->creer) { + if (isModEnabled('facture') && $user->hasRight('facture', 'creer')) { $invoice = new Facture($db); $langs->load("bills"); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 2adcf05fce9..55f2d51372c 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1530,15 +1530,15 @@ if ($action == 'create' && $user->rights->projet->creer) { print''.$langs->trans("Create").''; print ''; + +} + + print '
'; -print ''; +print ''; print ''; print '
'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 23c38a6b157..04a04ee8cac 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2023 Eric Seigne * * 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 @@ -772,6 +773,11 @@ function ihm_prepare_head() $head[$h][2] = 'login'; $h++; + $head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=css"; + $head[$h][1] = $langs->trans("CSSPage"); + $head[$h][2] = 'css'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin', 'remove'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 082bfc101e0..9f370340a01 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2372,4 +2372,6 @@ WarningModuleHasChangedLastVersionCheckParameter=Warning: the module %s has set WarningModuleHasChangedSecurityCsrfParameter=Warning: the module %s has disabled the CSRF security of your instance. This action is suspect and your installation may no more be secured. Please contact the author of the module for explanation. EMailsInGoingDesc=Incoming emails are managed by the module %s. You must enable and configure it if you need to support ingoing emails. MAIN_IMAP_USE_PHPIMAP=Use the PHP-IMAP library for IMAP instead of native PHP IMAP. This also allows the use of an OAuth2 connection for IMAP (module OAuth must also be activated). -MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) \ No newline at end of file +MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) + +CSSPage=CSS Style diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 889a1900139..3a28077277e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -16,6 +16,7 @@ * Copyright (C) 2021 Frédéric France * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Joachim Küter + * Copyright (C) 2023 Eric Seigne * * 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 @@ -1785,6 +1786,10 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } + //customcss + print ''."\n"; + + // Output standard javascript links if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { // JQuery. Must be before other includes diff --git a/htdocs/theme/custom.css.php b/htdocs/theme/custom.css.php new file mode 100644 index 00000000000..d3502782749 --- /dev/null +++ b/htdocs/theme/custom.css.php @@ -0,0 +1,35 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +require_once __DIR__.'/../main.inc.php'; // __DIR__ allow this script to be included in custom themes +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +// Define css type +top_httphead('text/css'); +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} + +if(file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) { + readfile(DOL_DATA_ROOT.'/admin/customcss.css'); +} From 33a74b65b3702c44a55891d3001d54667e89a15a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 01:53:24 +0100 Subject: [PATCH 075/217] Fix ul must contains li only --- htdocs/website/class/website.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 9cc470a5954..92a2b8f6b45 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1562,9 +1562,9 @@ class Website extends CommonObject if ($countrycode == 'us') { $label = preg_replace('/\s*\(.*\)/', '', $label); } - $out .= '
  • '.$label.''; + $out .= '
  • '.$label.''; $out .= ''; - $out .= '
  • '; + $out .= ''; } $i = 0; if (is_array($languagecodes)) { @@ -1583,11 +1583,11 @@ class Website extends CommonObject if ($countrycode == 'us') { $label = preg_replace('/\s*\(.*\)/', '', $label); } - $out .= '
  • '.$label.''; + $out .= '
  • '.$label.''; if (empty($i) && empty($languagecodeselected)) { $out .= ''; } - $out .= '
  • '; + $out .= ''; $i++; } } From 5c0ace0c89db71ad2cf2ccbfaa440a223bf2dcb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 02:44:33 +0100 Subject: [PATCH 076/217] Fix use absolute links for hreflang links --- htdocs/core/lib/website2.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 6d93d4391b2..744ca519f90 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -219,7 +219,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $tmpshortlangcode = preg_replace('/[_-].*$/', '', $object->lang); // en_US or en-US -> en } if ($tmpshortlangcode != $shortlangcode) { - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; } } } @@ -236,7 +236,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $tmpshortlangcode = preg_replace('/[_-].*$/', '', $obj->lang); // en_US or en-US -> en } if ($tmpshortlangcode != $shortlangcode) { - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; } } } @@ -246,7 +246,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, // Add myself $tplcontent .= 'fk_default_home == $objectpage->id) ? '/' : (($shortlangcode != substr($object->lang, 0, 2)) ? '/'.$shortlangcode : '')).'/'.$objectpage->pageurl.'.php") { ?>'."\n"; - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; } From 3b2d3dc6a6c67b50dfbd8f8481769aa113051d1f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 09:44:38 +0100 Subject: [PATCH 077/217] NEW : batch referential objets --- htdocs/core/lib/product.lib.php | 130 ++++++ htdocs/product/stats/mo.php | 28 ++ .../product/stock/class/productlot.class.php | 283 +++++++++++++ .../stock/stats/commande_fournisseur.php | 375 ++++++++++++++++++ htdocs/product/stock/stats/expedition.php | 369 +++++++++++++++++ htdocs/product/stock/stats/mo.php | 302 ++++++++++++++ htdocs/product/stock/stats/reception.php | 368 +++++++++++++++++ 7 files changed, 1855 insertions(+) create mode 100644 htdocs/product/stock/stats/commande_fournisseur.php create mode 100644 htdocs/product/stock/stats/expedition.php create mode 100644 htdocs/product/stock/stats/mo.php create mode 100644 htdocs/product/stock/stats/reception.php diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e919bf2c8b6..4898ff96cc2 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -253,6 +253,11 @@ function productlot_prepare_head($object) $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT."/product/stock/stats/expedition.php?showmessage=1&id=".$object->id; + $head[$h][1] = $langs->trans('Referers'); + $head[$h][2] = 'referers'; + $h++; + // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; @@ -648,6 +653,131 @@ function show_stats_for_company($product, $socid) return $nblines++; } +/** + * Show stats for company + * + * @param Product $product Product object + * @param int $socid Thirdparty id + * @return integer NB of lines shown into array + */ +function show_stats_for_batch($batch, $socid) +{ + global $conf, $langs, $user, $db, $hookmanager; + + $langs->LoadLangs(array('sendings', 'orders', 'receptions')); + + $form = new Form($db); + + $nblines = 0; + + print ''; + print ''.$langs->trans("Referers").''; + print ''.$langs->trans("NbOfThirdParties").''; + print ''.$langs->trans("NbOfObjectReferers").''; + print ''.$langs->trans("TotalQuantity").''; + print ''; + + // Expeditions + if (isModEnabled('expedition') && !empty($user->rights->expedition->lire)) { + $nblines++; + $ret = $batch->load_stats_expedition($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("Shipments").''; + print ''; + print $batch->stats_expedition['customers']; + print ''; + print $batch->stats_expedition['nb']; + print ''; + print $batch->stats_expedition['qty']; + print ''; + print ''; + } + + if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { + + $nblines++; + $ret = $batch->load_stats_reception($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("Receptions").''; + print ''; + print $batch->stats_reception['customers']; + print ''; + print $batch->stats_reception['nb']; + print ''; + print $batch->stats_reception['qty']; + print ''; + print ''; + + } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { + + $nblines++; + $ret = $batch->load_stats_supplier_order($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("bills"); + print ''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("SuppliersOrders").''; + print ''; + print $batch->stats_supplier_order['customers']; + print ''; + print $batch->stats_supplier_order['nb']; + print ''; + print $batch->stats_supplier_order['qty']; + print ''; + print ''; + + } + + if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { + $nblines++; + $ret = $batch->load_stats_mo($socid); + if ($ret < 0) { + dol_print_error($db); + } + $langs->load("mrp"); + print ''; + print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; + print ''; +// print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; +// print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; +// print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed")); +// print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + print $form->textwithpicto($batch->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced")); + print ''; + print ''; + } + + $parameters = array('socid'=>$socid); + $reshook = $hookmanager->executeHooks('addMoreBatchProductStat', $parameters, $batch, $nblines); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + print $hookmanager->resPrint; + + + return $nblines++; + +} + /** * Return translation label of a unit key. * Function kept for backward compatibility. diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 085a6687f5c..3127f9e83a6 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('mrp', 'products', 'companies')); @@ -63,6 +64,14 @@ if (!$sortfield) { $sortfield = "c.date_valid"; } +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -74,6 +83,7 @@ $staticmo = new Mo($db); $staticmoligne = new MoLine($db); $form = new Form($db); +$formother = new FormOther($db); if ($id > 0 || !empty($ref)) { $product = new Product($db); @@ -139,6 +149,12 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE c.rowid = cd.fk_mo"; $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product = ".((int) $product->id); + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } @@ -190,6 +206,18 @@ if ($id > 0 || !empty($ref)) { $option .= '&page='.urlencode($page); } + print '
    '; + print '
    '; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
    '; + print ''; + print ''; + print '
    '; + print '
    '; + print '
    '; + $i = 0; print '
    '; print ''; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 6fe855543c9..c20f224a584 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -554,6 +554,289 @@ class Productlot extends CommonObject } } + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_expedition($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,"; + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(edb.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; + $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('expedition').")"; + $sql .= " AND edb.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND exp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_expedition['customers'] = $obj->nb_customers; + $this->stats_expedition['nb'] = $obj->nb; + $this->stats_expedition['rows'] = $obj->nb_rows; + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->load_stats_expedition($socid); +// +// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; +// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; +// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; +// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats commande fournisseur pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_supplier_order($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; + $sql .= " COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('expedition').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND cf.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_supplier_order['customers'] = $obj->nb_customers; + $this->stats_supplier_order['nb'] = $obj->nb; + $this->stats_supplier_order['rows'] = $obj->nb_rows; + $this->stats_supplier_order['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->stats_supplier_order($socid); +// +// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; +// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; +// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; +// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_supplier_order = $hookmanager->resArray['stats_supplier_order']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_reception($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; + $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; +// $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('reception').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND recep.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_reception['customers'] = $obj->nb_customers; + $this->stats_reception['nb'] = $obj->nb; + $this->stats_reception['rows'] = $obj->nb_rows; + $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension +// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { +// $TFather = $this->getFather(); +// if (is_array($TFather) && !empty($TFather)) { +// foreach ($TFather as &$fatherData) { +// $pFather = new Product($this->db); +// $pFather->id = $fatherData['id']; +// $qtyCoef = $fatherData['qty']; +// +// if ($fatherData['incdec']) { +// $pFather->load_stats_expedition($socid); +// +// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; +// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; +// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; +// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; +// } +// } +// } +// } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function load_stats_mo($socid = 0) + { + // phpcs:enable + global $user, $hookmanager, $action; + + $error = 0; + + foreach (array('toconsume', 'consumed', 'toproduce', 'produced') as $role) { + $this->stats_mo['customers_'.$role] = 0; + $this->stats_mo['nb_'.$role] = 0; + $this->stats_mo['qty_'.$role] = 0; + + $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; + $sql .= " SUM(mp.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."mrp_mo as c"; + $sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id); + } + $sql .= " WHERE "; + $sql .= " c.entity IN (".getEntity('mo').")"; + + $sql .= " AND mp.batch = '".($this->db->escape($this->batch))."'"; + $sql .= " AND mp.role ='".$this->db->escape($role)."'"; + if ($socid > 0) { + $sql .= " AND c.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0; + $this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0; + $this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() + } else { + $this->error = $this->db->error(); + $error++; + } + } + + if (!empty($error)) { + return -1; + } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_mo = $hookmanager->resArray['stats_mo']; + } + + return 1; + } + /** * Return label of status of object diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php new file mode 100644 index 00000000000..a8a5d529b53 --- /dev/null +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -0,0 +1,375 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/product/stock/stats/commande_fournisseur.php + * \ingroup product service facture + * \brief Page of supplier order statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'orders')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatssupplierorder')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "cf.date_commande"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$commandefournisseurstatic = new CommandeFournisseur($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
    '; + + print '
    '; + print '
    '; + + + // Product + print ''; + print "
    '.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
    "; + + echo '
    '; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
    "; + + print '
    '; + print '
    '; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->fournisseur->commande->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,"; + $sql .= " cfd.rowid, SUM(cfdi.qty) as qty"; +// $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur as cf ON (cf.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('product').")"; + $sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + $sql .= " GROUP BY cf.rowid"; + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht_pondere = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
    '."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
    '; + print '
    '; + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
    '; + print ''; + print ''; + print '
    '; + print '
    '; + print '
    '; + + $i = 0; + print '
    '; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "cf.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("DateDeliveryPlanned", $_SERVER["PHP_SELF"], "cf.date_livraison", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "cfdi.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cf.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + +// $total_ht_pondere += $objp->total_ht_pondere; + $total_qty += $objp->qty; + + $commandefournisseurstatic->id = $objp->facid; + $commandefournisseurstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $commandefournisseurstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; +// print ''; + print ''; + print "
    '; + print $commandefournisseurstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour')."'; + print dol_print_date($db->jdate($objp->delivery_date), 'dayhour')."'.$objp->qty."'.price($objp->total_ht_pondere)."'.$commandefournisseurstatic->LibStatut($objp->statut, 5).'
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.$total_ht_pondere.'
    "; + print '
    '; + print '
    '; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php new file mode 100644 index 00000000000..f675f5745fb --- /dev/null +++ b/htdocs/product/stock/stats/expedition.php @@ -0,0 +1,369 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/product/stock/stats/expedition.php + * \ingroup product service facture + * \brief Page of expedition statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsexpedition')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "exp.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$expeditionstatic = new Expedition($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
    '; + + print '
    '; + print ''; + + + // Product + print ''; + print "
    '.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
    "; + + echo '
    '; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
    "; + + print '
    '; + print '
    '; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->expedition->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; + $sql .= " exp.ref, exp.date_creation, exp.fk_statut as statut, exp.rowid as facid,"; + $sql .= " d.rowid, db.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expedition as exp ON (exp.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet as d ON (d.fk_expedition = exp.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as db ON (db.fk_expeditiondet = d.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('product').")"; + $sql .= " AND db.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(exp.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
    '."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Shipments"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
    '; + print '
    '; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
    '; + print ''; + print ''; + print '
    '; + print '
    '; + print '
    '; + + $i = 0; + print '
    '; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "exp.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "exp.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $expeditionstatic->id = $objp->facid; + $expeditionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $expeditionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
    '; + print $expeditionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$expeditionstatic->LibStatut($objp->statut, 5).'
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
    "; + print '
    '; + print '
    '; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php new file mode 100644 index 00000000000..5a54ad9b75a --- /dev/null +++ b/htdocs/product/stock/stats/mo.php @@ -0,0 +1,302 @@ + + * Copyright (C) 2004-2021 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/product/stats/mo.php + * \ingroup product mo + * \brief Page of MO referring product + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('mrp', 'products', 'companies', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsmo')); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_valid"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$staticmo = new Mo($db); +$staticmoligne = new MoLine($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
    '; + + print '
    '; + print ''; + + // Product + print ''; + print "
    '.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
    "; + + echo '
    '; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
    "; + + print '
    '; + print '
    '; + + print dol_get_fiche_end(); + + + $now = dol_now(); + + $sql = "SELECT"; +// $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; +// $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; + //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_production as cd"; + $sql .= " WHERE c.rowid = cd.fk_mo"; + $sql .= " AND c.entity IN (".getEntity('mo').")"; + $sql .= " AND cd.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } + if ($socid) { + $sql .= " AND s.rowid = ".((int) $socid); + } + $sql .= " GROUP BY c.rowid, c.ref, c.date_valid, c.status"; + //$sql .= ", s.nom, s.rowid, s.code_client"; + $sql .= $db->order($sortfield, $sortorder); + + //Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option = '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
    '."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("MOs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
    '; + print '
    '; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
    '; + print ''; + print ''; + print '
    '; + print '
    '; + print '
    '; + + $i = 0; + print '
    '; + print ''; + + print ''; + + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "c.rowid", "", $option."&id=".$object->id, '', $sortfield, $sortorder); + //print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "c.date_valid", "", $option."&id=".$object->id, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$object->id,'align="right"',$sortfield,$sortorder); +// print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyConsumed", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); +// print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyProduced", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.status", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print "\n"; + + $motmp = new Mo($db); + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + $motmp->id = $objp->rowid; + $motmp->ref = $objp->ref; + $motmp->status = $objp->status; + + print ''; + print '\n"; + print ""; + //print "\n"; + //print ''; + print ''; +// print ''; + print ''; + //$mostatic->LibStatut($objp->statut,5).''; + print ''; + print "\n"; + $i++; + } + } + + print '
    '; + print $motmp->getNomUrl(1, 'production'); + print ""; + print dol_print_date($db->jdate($objp->date_valid), 'dayhour')."".price($objp->total_ht)."'; +// print ''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_consumed > 0 ? $objp->nb_consumed : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_produced > 0 ? $objp->nb_produced : '').''.$motmp->getLibStatut(2).'
    '; + print '
    '; + print '
    '; + } else { + dol_print_error($db); + } + $db->free($result); + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php new file mode 100644 index 00000000000..f289c469a6d --- /dev/null +++ b/htdocs/product/stock/stats/reception.php @@ -0,0 +1,368 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/product/stock/stats/reception.php + * \ingroup product service facture + * \brief Page of reception statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsreception')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "recep.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$receptionstatic = new Reception($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
    '; + + print '
    '; + print ''; + + + // Product + print ''; + print "
    '.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
    "; + + echo '
    '; + +// // Sell by +// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// // Eat by +// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { +// print ''; +// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); +// print ''; +// print ''; +// } +// +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { +// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; +// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; +// // print ''; +// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// } +// +// // Quality control +// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { +// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; +// print ''; +// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; +// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; +// print ''; +// } +// +// // Other attributes +// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
    "; + + print '
    '; + print '
    '; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->reception->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,"; + $sql .= " d.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."reception as recep ON (recep.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as d ON (d.fk_reception = recep.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('product').")"; + $sql .= " AND d.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(recep.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
    '."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Receptions"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
    '; + print '
    '; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
    '; + print ''; + print ''; + print '
    '; + print '
    '; + print '
    '; + + $i = 0; + print '
    '; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "recep.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); +// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "recep.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $receptionstatic->id = $objp->facid; + $receptionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); +// $paiement = $receptionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; +// print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
    '; + print $receptionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$receptionstatic->LibStatut($objp->statut, 5).'
    '.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
    "; + print '
    '; + print '
    '; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); From 373388ca4a14808e2978117a8c3531c396c8dd5f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 09:58:48 +0100 Subject: [PATCH 078/217] FIX : total line on batch stats mo --- htdocs/product/stock/stats/mo.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 5a54ad9b75a..4133448aa63 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -258,6 +258,8 @@ if ($id > 0 || !empty($ref)) { $motmp = new Mo($db); + $total_consumed=$total_produced=0; + if ($num > 0) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); @@ -266,6 +268,9 @@ if ($id > 0 || !empty($ref)) { $motmp->ref = $objp->ref; $motmp->status = $objp->status; + $total_consumed+=$objp->nb_consumed; + $total_produced+=$objp->nb_produced; + print ''; print ''; print $motmp->getNomUrl(1, 'production'); @@ -284,6 +289,19 @@ if ($id > 0 || !empty($ref)) { $i++; } } + print ''; + if ($num < $limit) { + print ''.$langs->trans("Total").''; + } else { + print ''.$langs->trans("Totalforthispage").''; + } + print ''; + print ''.$total_consumed.''; + print ''.$total_produced.''; + print ''; + print ""; + print '
    '; + print ''; print ''; print '
    '; From 40f52afb9e16a85bc3e28575e2172464ebc12c03 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:06:07 +0000 Subject: [PATCH 079/217] Fixing style errors. --- htdocs/core/lib/product.lib.php | 21 ++- .../product/stock/class/productlot.class.php | 120 +++++++++--------- .../stock/stats/commande_fournisseur.php | 100 +++++++-------- htdocs/product/stock/stats/expedition.php | 94 +++++++------- htdocs/product/stock/stats/mo.php | 12 +- htdocs/product/stock/stats/reception.php | 94 +++++++------- 6 files changed, 218 insertions(+), 223 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 7f2f626beee..fc2fa468533 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -697,8 +697,7 @@ function show_stats_for_batch($batch, $socid) print ''; } - if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { - + if (isModEnabled("reception") && !empty($user->rights->reception->lire)) { $nblines++; $ret = $batch->load_stats_reception($socid); if ($ret < 0) { @@ -715,9 +714,7 @@ function show_stats_for_batch($batch, $socid) print $batch->stats_reception['qty']; print ''; print ''; - - } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { - + } elseif (isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { $nblines++; $ret = $batch->load_stats_supplier_order($socid); if ($ret < 0) { @@ -734,7 +731,6 @@ function show_stats_for_batch($batch, $socid) print $batch->stats_supplier_order['qty']; print ''; print ''; - } if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { @@ -747,19 +743,19 @@ function show_stats_for_batch($batch, $socid) print ''; print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; print ''; -// print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced")); print ''; -// print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['nb_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced")); print ''; -// print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['qty_toconsume'], $langs->trans("ToConsume")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed")); -// print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number + // print $form->textwithpicto($batch->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce")); Makes no sense with batch, at this moment we don't know batch number print $form->textwithpicto($batch->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced")); print ''; print ''; @@ -775,7 +771,6 @@ function show_stats_for_batch($batch, $socid) return $nblines++; - } /** diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index c87a63c11e3..182f3ac1a76 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -570,7 +570,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -596,25 +596,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->load_stats_expedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); @@ -645,7 +645,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -671,25 +671,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->stats_supplier_order($socid); -// -// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; -// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; -// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; -// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->stats_supplier_order($socid); + // + // $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; + // $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; + // $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; + // $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); @@ -719,7 +719,7 @@ class Productlot extends CommonObject $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -745,25 +745,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->load_stats_expedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index a8a5d529b53..34fe3780c9f 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
    '; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; -// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; -// // print ''; -// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -214,7 +214,7 @@ if ($id > 0 || !empty($ref)) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; $sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,"; $sql .= " cfd.rowid, SUM(cfdi.qty) as qty"; -// $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; + // $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", sc.fk_soc, sc.fk_user "; } @@ -308,7 +308,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "cf.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateDeliveryPlanned", $_SERVER["PHP_SELF"], "cf.date_livraison", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "cfdi.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cf.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -320,13 +320,13 @@ if ($id > 0 || !empty($ref)) { $objp->qty = -($objp->qty); } -// $total_ht_pondere += $objp->total_ht_pondere; + // $total_ht_pondere += $objp->total_ht_pondere; $total_qty += $objp->qty; $commandefournisseurstatic->id = $objp->facid; $commandefournisseurstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $commandefournisseurstatic->getSommePaiement(); + // $paiement = $commandefournisseurstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; @@ -355,7 +355,7 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; print ''; -// print ''; + // print ''; print ''; print "
    '; @@ -339,7 +339,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->delivery_date), 'dayhour')."'.$objp->qty."'.price($objp->total_ht_pondere)."'.price($objp->total_ht_pondere)."'.$commandefournisseurstatic->LibStatut($objp->statut, 5).'
    '.$total_qty.''.$total_ht_pondere.''.$total_ht_pondere.'
    "; print '
    '; diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index f675f5745fb..0db73a319b3 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
    '; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; -// // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; -// // print ''; -// print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; -// print ''; -// print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; -// print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -306,7 +306,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "exp.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "exp.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -324,7 +324,7 @@ if ($id > 0 || !empty($ref)) { $expeditionstatic->id = $objp->facid; $expeditionstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $expeditionstatic->getSommePaiement(); + // $paiement = $expeditionstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 4133448aa63..ff1e60e046a 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -159,9 +159,9 @@ if ($id > 0 || !empty($ref)) { $now = dol_now(); $sql = "SELECT"; -// $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + // $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; -// $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + // $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; @@ -249,9 +249,9 @@ if ($id > 0 || !empty($ref)) { //print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "c.date_valid", "", $option."&id=".$object->id, 'align="center"', $sortfield, $sortorder); //print_liste_field_titre("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$object->id,'align="right"',$sortfield,$sortorder); -// print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + // print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("QtyAlreadyConsumed", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); -// print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + // print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("QtyAlreadyProduced", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.status", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; @@ -279,9 +279,9 @@ if ($id > 0 || !empty($ref)) { print dol_print_date($db->jdate($objp->date_valid), 'dayhour').""; //print "\n"; //print ''; + // print ''; print ''; -// print ''; + // print ''; print ''; //$mostatic->LibStatut($objp->statut,5).''; print ''; diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f289c469a6d..498a39c41d8 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -152,50 +152,50 @@ if ($id > 0 || !empty($ref)) { echo '
    '; -// // Sell by -// if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { -// print ''; -// print ''; -// } -// -// // Eat by -// if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { -// print ''; -// print ''; -// } -// -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { -// print ''; -// print ''; -// print ''; -// // print ''; -// // print ''; -// // print ''; -// print ''; -// print ''; -// print ''; -// } -// -// // Quality control -// if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { -// print ''; -// print ''; -// print ''; -// print ''; -// print ''; -// print ''; -// } -// -// // Other attributes -// include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''; + // print ''; + // print ''; + // // print ''; + // // print ''; + // // print ''; + // print ''; + // print ''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''; + // print ''; + // print ''; + // print ''; + // print ''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
    '; @@ -335,7 +335,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.price($objp->total_ht)."'.$expeditionstatic->LibStatut($objp->statut, 5).'
    ".price($objp->total_ht)."'; -// print ''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_consumed > 0 ? $objp->nb_consumed : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_produced > 0 ? $objp->nb_produced : '').''.$motmp->getLibStatut(2).'
    '; -// print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); -// print '
    '; -// print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print ''; -// print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); -// print '
    '.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').'
    '; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print '
    '; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print '
    '.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').'
    '.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').'
    '; @@ -305,7 +305,7 @@ if ($id > 0 || !empty($ref)) { print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "recep.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); -// print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "recep.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -323,7 +323,7 @@ if ($id > 0 || !empty($ref)) { $receptionstatic->id = $objp->facid; $receptionstatic->ref = $objp->ref; $societestatic->fetch($objp->socid); -// $paiement = $receptionstatic->getSommePaiement(); + // $paiement = $receptionstatic->getSommePaiement(); print ''; print '"; print '\n"; -// print '\n"; + // print '\n"; print ''; print "\n"; $i++; From 8e2998a50482ee74a50ff46fd0d6a8ad23b43be7 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 10:12:19 +0100 Subject: [PATCH 080/217] NEW : dev name --- htdocs/core/lib/product.lib.php | 1 + htdocs/product/stats/mo.php | 1 + htdocs/product/stock/class/productlot.class.php | 1 + htdocs/product/stock/stats/commande_fournisseur.php | 1 + htdocs/product/stock/stats/expedition.php | 1 + htdocs/product/stock/stats/mo.php | 1 + htdocs/product/stock/stats/reception.php | 1 + 7 files changed, 7 insertions(+) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 4898ff96cc2..89bf0f2537d 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2009-2010 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2015-2016 Marcos García + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 3127f9e83a6..b401b40bc9e 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index c20f224a584..a522f36ad47 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index a8a5d529b53..561f041e35c 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index f675f5745fb..6825cb989d4 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 4133448aa63..ae90127065a 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL * * 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 diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f289c469a6d..e2397e47438 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL * * 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 From e12d10158c8bee720b190e8b7eeda39732d3a8da Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 17 Feb 2023 10:14:20 +0100 Subject: [PATCH 081/217] NEW: add customer code to invoices listing --- htdocs/compta/facture/list.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fd60a6a84a4..709b246602b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -200,6 +200,7 @@ $fieldstosearchall = array( 'f.ref_client'=>'RefCustomer', 'f.note_public'=>'NotePublic', 's.nom'=>"ThirdParty", + 's.code_client'=>"CustomerCodeShort", 's.name_alias'=>"AliasNameShort", 's.zip'=>"Zip", 's.town'=>"Town", @@ -222,6 +223,7 @@ $arrayfields = array( 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), + 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>1, 'position'=>52), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), @@ -574,7 +576,7 @@ $sql .= ' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_so $sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; -$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.code_client as code_client, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; $sql .= " s.parent as fk_parent,"; $sql .= " s2.nom as name2,"; $sql .= ' typent.code as typent_code,'; @@ -687,6 +689,9 @@ if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { if ($search_parent_name) { $sql .= natural_search('s2.nom', $search_parent_name); } +if ($search_company_code_client) { + $sql .= natural_search('s.code_client', $search_company_code_client); +} if ($search_town) { $sql .= natural_search('s.town', $search_town); } @@ -1402,6 +1407,10 @@ if ($resql) { print ''; print ''; } + // Customer Code + if (!empty($arrayfields['s.code_client']['checked'])) { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; @@ -1654,6 +1663,9 @@ if ($resql) { if (!empty($arrayfields['s2.nom']['checked'])) { print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.code_client']['checked'])) { + print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER['PHP_SELF'], 's.code_client', '', $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -1850,6 +1862,7 @@ if ($resql) { $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->name_alias = $obj->alias; + $companystatic->code_client = $obj->code_client; $companystatic->client = $obj->client; $companystatic->fournisseur = $obj->fournisseur; $companystatic->code_client = $obj->code_client; @@ -2095,7 +2108,16 @@ if ($resql) { $totalarray['nbfield']++; } } - // Town + // Customer Code + if (!empty($arrayfields['s.code_client']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['s.code_client']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Town + // Town if (!empty($arrayfields['s.town']['checked'])) { print ''."\n"; print '
    '; @@ -334,7 +334,7 @@ if ($id > 0 || !empty($ref)) { print ''; print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.price($objp->total_ht)."'.$receptionstatic->LibStatut($objp->statut, 5).'
    '; + print dol_escape_htmltag($companystatic->code_client); + print ''; print dol_escape_htmltag($obj->town); From 1bf000a8da79ecd4d2a68a606bf06be24a3c8405 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:21:01 +0000 Subject: [PATCH 082/217] Fixing style errors. --- htdocs/compta/facture/list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 709b246602b..9cefdf00088 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -2109,15 +2109,15 @@ if ($resql) { } } // Customer Code - if (!empty($arrayfields['s.code_client']['checked'])) { - print ''; - print dol_escape_htmltag($companystatic->code_client); - print ''; + print dol_escape_htmltag($companystatic->code_client); + print ''; print dol_escape_htmltag($obj->town); From 8534a9698127cc7c71ac63ff76d4b254c4f98c07 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 17 Feb 2023 10:24:59 +0100 Subject: [PATCH 083/217] FIX : stickler feedbacks --- htdocs/core/lib/product.lib.php | 16 ++++++++-------- htdocs/product/stock/class/productlot.class.php | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 89bf0f2537d..0f12ba4f46f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -655,11 +655,11 @@ function show_stats_for_company($product, $socid) } /** - * Show stats for company + * Show stats for product batch * - * @param Product $product Product object - * @param int $socid Thirdparty id - * @return integer NB of lines shown into array + * @param Productlot $batch Product batch object + * @param int $socid Thirdparty id + * @return integer NB of lines shown into array */ function show_stats_for_batch($batch, $socid) { @@ -681,7 +681,7 @@ function show_stats_for_batch($batch, $socid) // Expeditions if (isModEnabled('expedition') && !empty($user->rights->expedition->lire)) { $nblines++; - $ret = $batch->load_stats_expedition($socid); + $ret = $batch->loadStatsExpedition($socid); if ($ret < 0) { dol_print_error($db); } @@ -701,7 +701,7 @@ function show_stats_for_batch($batch, $socid) if(isModEnabled("reception") && !empty($user->rights->reception->lire)) { $nblines++; - $ret = $batch->load_stats_reception($socid); + $ret = $batch->loadStatsReception($socid); if ($ret < 0) { dol_print_error($db); } @@ -720,7 +720,7 @@ function show_stats_for_batch($batch, $socid) } elseif(isModEnabled('supplier_order') && !empty($user->rights->fournisseur->commande->lire)) { $nblines++; - $ret = $batch->load_stats_supplier_order($socid); + $ret = $batch->loadStatsSupplierOrder($socid); if ($ret < 0) { dol_print_error($db); } @@ -740,7 +740,7 @@ function show_stats_for_batch($batch, $socid) if (isModEnabled('mrp') && !empty($user->rights->mrp->read)) { $nblines++; - $ret = $batch->load_stats_mo($socid); + $ret = $batch->loadStatsMo($socid); if ($ret < 0) { dol_print_error($db); } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index a522f36ad47..95c7240e2c3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -561,7 +561,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_expedition($socid = 0) + public function loadStatsExpedition($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -606,7 +606,7 @@ class Productlot extends CommonObject // $qtyCoef = $fatherData['qty']; // // if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); +// $pFather->loadStatsExpedition($socid); // // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; @@ -636,7 +636,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_supplier_order($socid = 0) + public function loadStatsSupplierOrder($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -711,7 +711,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_reception($socid = 0) + public function loadStatsReception($socid = 0) { // phpcs:enable global $db, $conf, $user, $hookmanager, $action; @@ -755,7 +755,7 @@ class Productlot extends CommonObject // $qtyCoef = $fatherData['qty']; // // if ($fatherData['incdec']) { -// $pFather->load_stats_expedition($socid); +// $pFather->loadStatsReception($socid); // // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; @@ -785,7 +785,7 @@ class Productlot extends CommonObject * @param int $socid Id societe * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok */ - public function load_stats_mo($socid = 0) + public function loadStatsMo($socid = 0) { // phpcs:enable global $user, $hookmanager, $action; From cae9fe0e065b0fa59c928d5d48d28b246391ad4a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:25:42 +0000 Subject: [PATCH 084/217] Fixing style errors. --- htdocs/admin/ihm.php | 9 ++++----- htdocs/theme/custom.css.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 7102217cb8e..d9d734b8705 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -300,8 +300,8 @@ if ($action == 'update') { } if ($mode == 'css') { - $data = GETPOST('CUSTOM_CSS','none'); - file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css',$data); + $data = GETPOST('CUSTOM_CSS', 'none'); + file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); } $_SESSION["mainmenu"] = ""; // The menu manager may have changed @@ -700,13 +700,12 @@ if ($mode == 'css') { $customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); - $doleditor = new DolEditor('CUSTOM_CSS', $customcssValue, '', 400, 'Basic', 'In', false, true, 'ace',80,80,0); - $doleditor->Create(0,'',true,'css','css'); + $doleditor = new DolEditor('CUSTOM_CSS', $customcssValue, '', 400, 'Basic', 'In', false, true, 'ace', 80, 80, 0); + $doleditor->Create(0, '', true, 'css', 'css'); print '
    '."\n"; print '
    '; - } diff --git a/htdocs/theme/custom.css.php b/htdocs/theme/custom.css.php index d3502782749..011d1624a3e 100644 --- a/htdocs/theme/custom.css.php +++ b/htdocs/theme/custom.css.php @@ -30,6 +30,6 @@ if (empty($dolibarr_nocache)) { header('Cache-Control: no-cache'); } -if(file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) { +if (file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) { readfile(DOL_DATA_ROOT.'/admin/customcss.css'); } From bc954af404fc5e2d9c2e0cf481ba36867749c24c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 17 Feb 2023 09:32:05 +0000 Subject: [PATCH 085/217] Fixing style errors. --- .../product/stock/class/productlot.class.php | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 7f05796eeae..7d12acae368 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -571,7 +571,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -597,25 +597,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->loadStatsExpedition($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsExpedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); @@ -646,7 +646,7 @@ class Productlot extends CommonObject $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -672,25 +672,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->stats_supplier_order($socid); -// -// $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; -// $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; -// $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; -// $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->stats_supplier_order($socid); + // + // $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; + // $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; + // $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; + // $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); @@ -720,7 +720,7 @@ class Productlot extends CommonObject $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; -// $sql .= ", ".$this->db->prefix()."societe as s"; + // $sql .= ", ".$this->db->prefix()."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; } @@ -746,25 +746,25 @@ class Productlot extends CommonObject // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) // if it's a virtual product, maybe it is in invoice by extension -// if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { -// $TFather = $this->getFather(); -// if (is_array($TFather) && !empty($TFather)) { -// foreach ($TFather as &$fatherData) { -// $pFather = new Product($this->db); -// $pFather->id = $fatherData['id']; -// $qtyCoef = $fatherData['qty']; -// -// if ($fatherData['incdec']) { -// $pFather->loadStatsReception($socid); -// -// $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; -// $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; -// $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; -// $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; -// } -// } -// } -// } + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsReception($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); From 5750448dd279928dfcdbd07b477d80f3c6130c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 17 Feb 2023 15:11:43 +0100 Subject: [PATCH 086/217] fix search_account if fetched from ref --- htdocs/compta/bank/releve.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 2e532984d99..f7ac2576c2c 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -109,7 +109,8 @@ if (!$sortfield) { $object = new Account($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + // if fetch from ref, $id may be empty + $id = $object->id; // Force the search field on id of account } From 57d26fc7da667301e226c8005aa8ab3331bfec1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 15:43:50 +0100 Subject: [PATCH 087/217] NEW Debug the custom CSS feature to avoid a directory search/scan at each page load --- htdocs/admin/ihm.php | 12 +++++++----- htdocs/main.inc.php | 8 +++++--- htdocs/theme/custom.css.php | 6 +++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index d9d734b8705..b868a847e9e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -300,8 +300,9 @@ if ($action == 'update') { } if ($mode == 'css') { - $data = GETPOST('CUSTOM_CSS', 'none'); - file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); + //file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); + //dol_chmod(DOL_DATA_ROOT.'/admin/customcss.css'); + dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity); } $_SESSION["mainmenu"] = ""; // The menu manager may have changed @@ -310,7 +311,7 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); } - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup&mode=".$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); exit; } @@ -698,9 +699,10 @@ if ($mode == 'css') { print ''; print ''; - $customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); + //$customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); + $customcssValue = getDolGlobalString('MAIN_IHM_CUSTOM_CSS'); - $doleditor = new DolEditor('CUSTOM_CSS', $customcssValue, '', 400, 'Basic', 'In', false, true, 'ace', 80, 80, 0); + $doleditor = new DolEditor('MAIN_IHM_CUSTOM_CSS', $customcssValue, '80%', 400, 'Basic', 'In', true, false, 'ace', 10, '90%'); $doleditor->Create(0, '', true, 'css', 'css'); print ''."\n"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3a28077277e..323af1af532 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1786,9 +1786,11 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } - //customcss - print ''."\n"; - + // Custom CSS + if (getDolGlobalString('MAIN_IHM_CUSTOM_CSS')) { + // If a custom CSS was set, we add link to the custom css php file + print ''."\n"; + } // Output standard javascript links if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { diff --git a/htdocs/theme/custom.css.php b/htdocs/theme/custom.css.php index 011d1624a3e..8caf1696f2f 100644 --- a/htdocs/theme/custom.css.php +++ b/htdocs/theme/custom.css.php @@ -30,6 +30,6 @@ if (empty($dolibarr_nocache)) { header('Cache-Control: no-cache'); } -if (file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) { - readfile(DOL_DATA_ROOT.'/admin/customcss.css'); -} + +print '// Here, the content of the common custom CSS defined into Home - Setup - Display - CSS'."\n"; +print getDolGlobalString('MAIN_IHM_CUSTOM_CSS'); From 800c08e53923606061842d21e706647318f4fc40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 15:52:21 +0100 Subject: [PATCH 088/217] Update list.php --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 9cefdf00088..6faaae15ff8 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -223,7 +223,7 @@ $arrayfields = array( 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), - 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>1, 'position'=>52), + 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>-1, 'position'=>52), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), From a43beaecf4d7ddf04cf1da41e3088d7cd28e5ab2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 15:55:01 +0100 Subject: [PATCH 089/217] Update list.php --- htdocs/compta/facture/list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6faaae15ff8..54510bd3fae 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1387,19 +1387,19 @@ if ($resql) { } // Project ref if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Project label if (!empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) { - print ' 0 ? " disabled" : "").'>'; + print ' 0 ? " disabled" : "").'>'; } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; + print ''; } // Parent company if (!empty($arrayfields['s2.nom']['checked'])) { @@ -1409,7 +1409,7 @@ if ($resql) { } // Customer Code if (!empty($arrayfields['s.code_client']['checked'])) { - print ''; + print ''; } // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -1476,13 +1476,13 @@ if ($resql) { if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Localtax1 print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Localtax2 print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['f.total_ttc']['checked'])) { From a18b5a31e5653f4561082dec7d45298bc591b5a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 16:00:57 +0100 Subject: [PATCH 090/217] Fix phpunit --- test/phpunit/DateLibTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 6f50e5b3085..eef029d26d1 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -344,7 +344,7 @@ class DateLibTest extends PHPUnit\Framework\TestCase $result=convertSecondToTime(86400, 'all', 86400); print __METHOD__." result=".$result."\n"; - $this->assertSame('1 '.strtolower(dol_substr($langs->trans("Day"), 0, 1).'.'), $result); + $this->assertSame('1 '.$langs->trans("d"), $result); return $result; } From c7746bd6f14af1f9d4feeef1f3d1f343111cb4ff Mon Sep 17 00:00:00 2001 From: gautier Date: Wed, 15 Feb 2023 12:10:32 +0100 Subject: [PATCH 091/217] modification on leftmenu by hook not applied related to #23916 -usage of $hookmanager->resArray instead of $hookmanager->results --- htdocs/core/menus/standard/eldy.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b534a998107..7ad2fef730e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -883,10 +883,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks if (is_numeric($reshook)) { - if ($reshook == 0 && !empty($hookmanager->results)) { - $menu_array[] = $hookmanager->results; // add + if ($reshook == 0 && !empty($hookmanager->resArray)) { + $menu_array[] = $hookmanager->resArray; // add } elseif ($reshook == 1) { - $menu_array = $hookmanager->results; // replace + $menu_array = $hookmanager->resArray; // replace } // @todo Sort menu items by 'position' value From bda4def9337bf85dc7e8f608e31d733b3dfad0d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 17:31:55 +0100 Subject: [PATCH 092/217] Debug v18 --- htdocs/user/virtualcard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php index 7ea3049353f..252ae3aca80 100644 --- a/htdocs/user/virtualcard.php +++ b/htdocs/user/virtualcard.php @@ -297,7 +297,7 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { print '
    '; print '
    '; - print $form->buttonsSaveCancel("Save", ($dol_openinpopup ? "Cancel" : ""), array(), 0, '', $dol_openinpopup); + print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup); print '
    '; print '
    '; From d976372d877ab250c6a341f6213b562acdc8bacc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 17:55:46 +0100 Subject: [PATCH 093/217] Fix #huntrf0ffd01e-8054-4e43-96f7-a0d2e652ac7e --- htdocs/core/lib/barcode.lib.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 702d6673527..560f4b772b4 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -334,7 +334,7 @@ function barcode_encode_upc($upc, $encoding = "UPC") */ function barcode_encode_genbarcode($code, $encoding) { - global $genbarcode_loc; + global $conf, $db, $genbarcode_loc; // Clean parameters if (preg_match("/^ean$/i", $encoding) && strlen($code) == 13) { @@ -343,27 +343,34 @@ function barcode_encode_genbarcode($code, $encoding) if (!$encoding) { $encoding = "ANY"; } - $encoding = preg_replace("/[\\\|]/", "_", $encoding); - $code = preg_replace("/[\\\|]/", "_", $code); + $encoding = dol_string_nospecial($encoding, '_'); + $code = dol_string_nospecial($code, "_"); $command = escapeshellarg($genbarcode_loc); - //$paramclear=" \"".str_replace("\"", "\\\"",$code)."\" \"".str_replace("\"", "\\\"",strtoupper($encoding))."\""; $paramclear = " ".escapeshellarg($code)." ".escapeshellarg(strtoupper($encoding)); $fullcommandclear = $command." ".$paramclear." 2>&1"; //print $fullcommandclear."
    \n";exit; dol_syslog("Run command ".$fullcommandclear); - $fp = popen($fullcommandclear, "r"); - if ($fp) { - $bars = fgets($fp, 1024); - $text = fgets($fp, 1024); - $encoding = fgets($fp, 1024); - pclose($fp); + + $outputfile = $conf->user->dir_temp.'/genbarcode.tmp'; // File used with popen method + + // Execute a CLI + include_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php'; + $utils = new Utils($db); + $result = $utils->executeCLI($fullcommandclear, $outputfile); + + if (!empty($result['output'])) { + $tmparr = explode("\n", $result['output']); + $bars = $tmparr[0]; + $text = $tmparr[1]; + $encoding = $tmparr[2]; } else { - dol_syslog("barcode.lib.php::barcode_encode_genbarcode failed to run popen ".$fullcommandclear, LOG_ERR); + dol_syslog("barcode.lib.php::barcode_encode_genbarcode failed to run ".$fullcommandclear, LOG_ERR); return false; } + //var_dump($bars); $ret = array( "bars" => trim($bars), From 8d548d04892c80ff3d3cecaf6685fbf389b3f680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Cendrier?= Date: Fri, 17 Feb 2023 18:28:08 +0100 Subject: [PATCH 094/217] add bookmarks in selectable landing pages for users --- htdocs/user/param_ihm.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index d9528b7afee..fba8cb0611e 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -214,6 +214,28 @@ if (isModEnabled('agenda')) { if (isModEnabled('ticket')) { $tmparray['ticket/list.php?mainmenu=ticket&leftmenu='] = 'Tickets'; } +// add bookmarks to available landing pages +if (!empty($conf->global->MAIN_USE_BOOKMARKS_FOR_LANDING_PAGES)) { + $sql = "SELECT b.rowid, b.fk_user, b.url, b.title,"; + + $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; + $sql .= " WHERE 1=1"; + $sql .= " AND b.entity IN (".getEntity('bookmark').")"; + $sql .= " AND b.url NOT LIKE 'http%'"; + if (!$object->admin) { + $sql .= " AND (b.fk_user = ".((int) $object->id)." OR b.fk_user is NULL OR b.fk_user = 0)"; + } + $resql = $object->db->query($sql); + if ($resql) { + $i = 0; + while ($i < $object->db->num_rows($resql)) { + $obj = $db->fetch_object($resql); + $landing_url = str_replace(DOL_URL_ROOT,'',$obj->url); + $tmparray[$landing_url] = $obj->title; + $i++; + } + } +} // Hook for insertion new items in the List of possible landing pages $reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); From 0b4cacd2914f1024b7e17523f3aff3a41c9a3dd8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Feb 2023 19:30:50 +0100 Subject: [PATCH 095/217] Use dolChmod --- htdocs/admin/security_file.php | 12 ++- htdocs/api/class/api_documents.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- .../class/bonprelevement.class.php | 4 +- htdocs/core/actions_massactions.inc.php | 8 +- htdocs/core/class/CMailFile.class.php | 6 +- htdocs/core/class/CSMSFile.class.php | 8 +- htdocs/core/class/ldap.class.php | 4 +- htdocs/core/class/rssparser.class.php | 5 +- htdocs/core/class/stats.class.php | 15 +-- htdocs/core/class/utils.class.php | 12 +-- htdocs/core/lib/files.lib.php | 50 ++++++--- htdocs/core/lib/functions.lib.php | 7 +- htdocs/core/lib/images.lib.php | 8 +- htdocs/core/lib/invoice2.lib.php | 4 +- htdocs/core/lib/modulebuilder.lib.php | 6 +- htdocs/core/lib/security2.lib.php | 2 +- htdocs/core/lib/website.lib.php | 8 +- htdocs/core/lib/website2.lib.php | 66 ++++-------- htdocs/core/lib/xcal.lib.php | 10 +- htdocs/core/modules/action/rapport.class.php | 4 +- .../doc/doc_generic_asset_odt.modules.php | 4 +- .../asset/doc/pdf_standard_asset.modules.php | 8 +- .../core/modules/bank/doc/pdf_ban.modules.php | 4 +- .../bank/doc/pdf_sepamandate.modules.php | 4 +- .../bom/doc/doc_generic_bom_odt.modules.php | 4 +- .../modules/cheque/doc/pdf_blochet.class.php | 4 +- .../doc/doc_generic_order_odt.modules.php | 4 +- .../commande/doc/pdf_einstein.modules.php | 4 +- .../commande/doc/pdf_eratosthene.modules.php | 4 +- .../doc/doc_generic_contract_odt.modules.php | 4 +- .../contract/doc/pdf_strato.modules.php | 4 +- .../delivery/doc/pdf_storm.modules.php | 4 +- .../delivery/doc/pdf_typhon.modules.php | 4 +- .../modules/dons/html_cerfafr.modules.php | 4 +- .../doc/doc_generic_shipment_odt.modules.php | 4 +- .../expedition/doc/pdf_espadon.modules.php | 4 +- .../expedition/doc/pdf_merou.modules.php | 4 +- .../expedition/doc/pdf_rouget.modules.php | 4 +- .../doc/pdf_standard.modules.php | 4 +- .../doc/doc_generic_invoice_odt.modules.php | 4 +- .../modules/facture/doc/pdf_crabe.modules.php | 4 +- .../facture/doc/pdf_sponge.modules.php | 4 +- .../fichinter/doc/pdf_soleil.modules.php | 4 +- .../doc/doc_generic_member_odt.class.php | 4 +- .../modules/member/doc/pdf_standard.class.php | 5 +- .../movement/doc/pdf_standard.modules.php | 4 +- .../mrp/doc/doc_generic_mo_odt.modules.php | 4 +- .../modules/mrp/doc/pdf_vinci.modules.php | 4 +- .../doc/pdf_standardlabel.class.php | 4 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 5 +- .../doc/doc_generic_product_odt.modules.php | 4 +- .../product/doc/pdf_standard.modules.php | 4 +- .../doc/doc_generic_project_odt.modules.php | 4 +- .../project/doc/pdf_baleine.modules.php | 4 +- .../project/doc/pdf_beluga.modules.php | 4 +- .../project/doc/pdf_timespent.modules.php | 4 +- .../task/doc/doc_generic_task_odt.modules.php | 4 +- .../doc/doc_generic_proposal_odt.modules.php | 4 +- .../modules/propale/doc/pdf_azur.modules.php | 4 +- .../modules/propale/doc/pdf_cyan.modules.php | 4 +- .../modules/rapport/pdf_paiement.class.php | 4 +- .../doc/doc_generic_reception_odt.modules.php | 4 +- .../reception/doc/pdf_squille.modules.php | 4 +- .../societe/doc/doc_generic_odt.modules.php | 4 +- .../doc/doc_generic_stock_odt.modules.php | 4 +- .../stock/doc/pdf_standard.modules.php | 4 +- .../stocktransfer/doc/pdf_eagle.modules.php | 3 +- .../doc/pdf_eagle_proforma.modules.php | 3 +- ...c_generic_supplier_invoice_odt.modules.php | 4 +- .../doc/pdf_canelle.modules.php | 4 +- ...doc_generic_supplier_order_odt.modules.php | 4 +- .../supplier_order/doc/pdf_cornas.modules.php | 4 +- .../doc/pdf_muscadet.modules.php | 4 +- .../doc/pdf_standard.modules.php | 4 +- ..._generic_supplier_proposal_odt.modules.php | 4 +- .../doc/pdf_aurore.modules.php | 4 +- .../core/modules/syslog/mod_syslog_file.php | 2 +- .../doc/doc_generic_ticket_odt.modules.php | 4 +- .../user/doc/doc_generic_user_odt.modules.php | 4 +- .../doc/doc_generic_usergroup_odt.modules.php | 4 +- htdocs/ftp/index.php | 4 +- htdocs/includes/odtphp/odf.php | 2 +- .../containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- .../containers/wrapper.php | 2 +- htdocs/install/step5.php | 10 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/modulebuilder/index.php | 102 +++++++++--------- .../doc/doc_generic_myobject_odt.modules.php | 4 +- .../doc/pdf_standard_myobject.modules.php | 8 +- htdocs/projet/class/projectstats.class.php | 14 +-- ...ric_recruitmentjobposition_odt.modules.php | 4 +- ...tandard_recruitmentjobposition.modules.php | 8 +- htdocs/website/class/website.class.php | 4 +- htdocs/website/index.php | 13 +-- htdocs/website/samples/wrapper.php | 2 +- 101 files changed, 247 insertions(+), 428 deletions(-) diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 5538e0ad952..5ea581296af 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -80,8 +80,18 @@ if ($action == 'updateform') { } if (!$error) { + $tmpumask = GETPOST('MAIN_UMASK', 'alpha'); + $tmpumask = (octdec($tmpumask) & 0666); + $tmpumask = decoct($tmpumask); + if (!preg_match('/^0/', $tmpumask)) { + $tmpumask = '0'.$tmpumask; + } + if (empty($tmpumask) || $tmpumask === '0') { + $tmpumask = '0664'; + } + $res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, "MAIN_UMASK", $tmpumask, 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); if ($res3 && $res4 && $res5 && $res6) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8dae305a989..846e9272fb6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -746,7 +746,7 @@ class Documents extends DolibarrApi if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, $newfilecontent); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 11cb4f98dbd..9999f63b624 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2278,7 +2278,7 @@ class ActionComm extends CommonObject // Create temp file $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file if ($format == 'vcal') { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b9d1fd7c54a..266ddd3b79f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1700,9 +1700,7 @@ class BonPrelevement extends CommonObject } fclose($this->file); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($this->filename, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($this->filename); return $result; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 55d7ec6fdcf..b6513951f22 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -820,9 +820,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // check if pdftk is installed if (file_exists($file)) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -888,9 +886,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 42e936e5cba..9e8593e6d1b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1213,9 +1213,7 @@ class CMailFile } fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -1797,7 +1795,7 @@ class CMailFile if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent)); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { $this->errors[] = "Failed to open file '".$destfiletmp."' for write"; return -1; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 3f082ba6d53..a8dc4bfff9a 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -231,9 +231,7 @@ class CSMSFile fputs($fp, "Message:\n".$this->message); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -257,9 +255,7 @@ class CSMSFile fputs($fp, "\nResult id=".$result); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 8b3c9177d3e..b2b5e2c6e93 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -743,9 +743,7 @@ class Ldap if ($fp) { fputs($fp, $content); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); return 1; } else { return -1; diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index da3257b09c9..d70876c5709 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -295,10 +295,7 @@ class RssParser if ($fp) { fwrite($fp, $str); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->_lastfetchdate = $nowgmt; } else { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 60cdc5d5226..1ef45097594 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -119,10 +119,7 @@ abstract class Stats $fp = fopen($newpathofdestfile, 'w'); fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } @@ -222,10 +219,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } else { dol_syslog("Failed to write cache file", LOG_ERR); } @@ -332,10 +326,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3e310ade5bc..be91b49765b 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -494,9 +494,7 @@ class Utils } } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } else { $langs->load("errors"); dol_syslog("Failed to open file ".$outputfile, LOG_ERR); @@ -739,9 +737,7 @@ class Utils pclose($handlein); fclose($handle); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } // Update with result @@ -1051,7 +1047,7 @@ class Utils fclose($sourcehandle); gzclose($gzfilehandle); - @chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname.'.1.gz'); } dol_delete_file($logpath.'/'.$logname, 0, 0, 0, null, false, 0); @@ -1061,7 +1057,7 @@ class Utils fclose($newlog); //var_dump($logpath.'/'.$logname." - ".octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); - @chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname); } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 93863254a03..e74bd537fb2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -678,7 +678,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask } file_put_contents($newpathoftmpdestfile, $content); - @chmod($newpathoftmpdestfile, octdec($newmask)); + dolChmod($newpathoftmpdestfile, $newmask); // Rename $result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase); @@ -694,7 +694,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask $newmask = '0664'; } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile, $newmask); return 1; } @@ -752,7 +752,7 @@ function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1) $newmask = '0664'; } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile, $newmask); return 1; } @@ -900,6 +900,18 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te } } + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($destfile), $arrayofallowedcommand)) { + //$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + //setEventMessages($langs->trans("ErrorFilenameReserved", basename($destfile)), null, 'errors'); + dol_syslog("files.lib.php::dol_move canceled because target filename ".basename($destfile)." is using a reserved command name. we ignore the move request.", LOG_WARNING); + return false; + } + } + $result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ if (!$result) { if ($destexists) { @@ -975,11 +987,11 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te if (empty($newmask)) { $newmask = empty($conf->global->MAIN_UMASK) ? '0755' : $conf->global->MAIN_UMASK; } - $newmaskdec = octdec($newmask); + // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too) // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this // if ($isdir) $newmaskdec |= octdec('0111'); // Set x bit required for directories - @chmod($newpathofdestfile, $newmaskdec); + dolChmod($newpathofdestfile, $newmask); } return $result; @@ -1219,9 +1231,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable // Move file $return = move_uploaded_file($src_file_osencoded, $file_name_osencoded); if ($return) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file_name_osencoded); dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); return $successcode; // Success } else { @@ -1303,7 +1313,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, // If it fails and it is because of the missing write permission on parent dir if (!$ok && file_exists(dirname($filename)) && !(fileperms(dirname($filename)) & 0200)) { dol_syslog("Error in deletion, but parent directory exists with no permission to write, we try to change permission on parent directory and retry...", LOG_DEBUG); - @chmod(dirname($filename), fileperms(dirname($filename)) | 0200); + dolChmod(dirname($filename), decoct(fileperms(dirname($filename)) | 0200)); // Now we retry deletion if ($nophperrors) { $ok = @unlink($filename); @@ -1592,11 +1602,10 @@ function dol_meta_create($object) $fp = fopen($file, "w"); fputs($fp, $meta); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - return 1; + dolChmod($file); + + return 1; } else { dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); } @@ -1713,6 +1722,17 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $destfile = dol_string_nohtmltag($destfile); $destfull = dol_string_nohtmltag($destfull); + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($destfull), $arrayofallowedcommand)) { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFilenameReserved", basename($destfull)), null, 'errors'); + return -1; + } + } + // Move file from temp directory to final directory. A .noexe may also be appended on file name. $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles, $upload_dir); @@ -2388,7 +2408,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = $newmask = '0664'; } - @chmod($outputfile, octdec($newmask)); + dolChmod($outputfile, $newmask); return 1; } @@ -3215,7 +3235,7 @@ function dol_filecache($directory, $filename, $object) } $cachefile = $directory.$filename; file_put_contents($cachefile, serialize($object), LOCK_EX); - @chmod($cachefile, 0644); + dolChmod($cachefile, '0644'); } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c138ccb743c..125ac7b36c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6864,13 +6864,16 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '') * Change mod of a file * * @param string $filepath Full file path + * @param string $newmask Force new mask. For example '0644' * @return void */ -function dolChmod($filepath) +function dolChmod($filepath, $newmask = '') { global $conf; - if (!empty($conf->global->MAIN_UMASK)) { + if (!empty($newmask)) { + @chmod($filepath, octdec($newmask)); + } elseif (!empty($conf->global->MAIN_UMASK)) { @chmod($filepath, octdec($conf->global->MAIN_UMASK)); } } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 37cc70760eb..b10b000b8e7 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -362,9 +362,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgTargetName, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($imgTargetName); // Free memory. This does not delete image. imagedestroy($img); @@ -761,9 +759,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($imgThumbName); // Free memory. This does not delete image. imagedestroy($img); diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index da01d93fc62..3a9712ba58f 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -277,9 +277,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte if (!$error && $pagecount) { $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); } if ($usestdout) { diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 163c90aa8a9..a60e9a3a78a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -227,7 +227,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $result = file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); if ($result) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; } @@ -369,7 +369,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $result = file_put_contents($pathoffiletoedittarget, $contentsql); if ($result) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); @@ -408,7 +408,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $result2 = file_put_contents($pathoffiletoedittarget, $contentsql); if ($result2) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 93da106aebd..e0bf4a683f0 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -457,7 +457,7 @@ function encodedecode_dbpassconf($level = 0) // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch - //@chmod($file, octdec('0600')); + //dolChmod($file, '0600'); return 1; } else { diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 61a894b2c96..156e0fc1022 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -1210,9 +1210,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filetosave); } } } @@ -1281,9 +1279,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filetosave); } } } diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 744ca519f90..679f6e3fb42 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -45,9 +45,7 @@ function dolSaveMasterFile($filemaster) $mastercontent .= "}\n"; $mastercontent .= '?>'."\n"; $result = file_put_contents($filemaster, $mastercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filemaster); return $result; } @@ -79,9 +77,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealias, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealias, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealias); // Save also alias into language subdirectory if it is not a main language if ($objectpage->lang && in_array($objectpage->lang, explode(',', $object->otherlang))) { @@ -99,9 +95,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealiassub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealiassub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealiassub); } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { // Save also alias into all language subdirectories if it is a main language if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { @@ -122,9 +116,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealiassub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealiassub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealiassub); } } } @@ -276,9 +268,8 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, //var_dump($filetpl);exit; $result = file_put_contents($filetpl, $tplcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); - } + + dolChmod($filetpl); return $result; } @@ -318,9 +309,8 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o $indexcontent .= '// END PHP ?>'."\n"; $result1 = file_put_contents($fileindex, $indexcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); - } + + dolChmod($fileindex); if (is_object($object) && $object->fk_default_home > 0) { $objectpage = new WebsitePage($db); @@ -352,9 +342,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o if ($result === false) { dol_syslog("Failed to write file ".$fileindexsub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($fileindexsub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($fileindexsub); } } } @@ -368,9 +356,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php'); $result2 = file_put_contents($filewrapper, $wrappercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filewrapper); } else { $result2 = true; } @@ -394,9 +380,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filehtmlheader, $htmlheadercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filehtmlheader); return $result; } @@ -416,9 +400,7 @@ function dolSaveCssFile($filecss, $csscontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filecss, $csscontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filecss, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filecss); return $result; } @@ -438,9 +420,7 @@ function dolSaveJsFile($filejs, $jscontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filejs, $jscontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filejs, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filejs); return $result; } @@ -460,9 +440,7 @@ function dolSaveRobotFile($filerobot, $robotcontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filerobot, $robotcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filerobot); return $result; } @@ -482,9 +460,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess) dol_mkdir($pathofwebsite); $result = file_put_contents($filehtaccess, $htaccess); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filehtaccess); return $result; } @@ -504,9 +480,7 @@ function dolSaveManifestJson($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } @@ -526,9 +500,7 @@ function dolSaveReadme($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } @@ -548,9 +520,7 @@ function dolSaveLicense($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 6b5c92881c5..45c7bf17793 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -284,10 +284,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) fwrite($calfileh, "END:VCALENDAR"); fclose($calfileh); - - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } else { dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); return -2; @@ -429,10 +426,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, ""); fclose($fichier); - - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } diff --git a/htdocs/core/modules/action/rapport.class.php b/htdocs/core/modules/action/rapport.class.php index d91b748d7d5..d4805143e59 100644 --- a/htdocs/core/modules/action/rapport.class.php +++ b/htdocs/core/modules/action/rapport.class.php @@ -209,9 +209,7 @@ class CommActionRapport $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index ba4f39919bf..a68b8fd2354 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -480,9 +480,7 @@ class doc_generic_asset_odt extends ModelePDFAsset $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index b20f60fe084..92af12427b2 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -815,13 +815,11 @@ class pdf_standard_asset extends ModelePDFAsset $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index ddc65b1ff8c..2af920da42e 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -250,9 +250,7 @@ class pdf_ban extends ModeleBankAccountDoc $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index ecf7a2a6ad9..00d57161e10 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -429,9 +429,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index ea877432c17..d34844f14f2 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -498,9 +498,7 @@ class doc_generic_bom_odt extends ModelePDFBom $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 43db9a615e6..6d257de6306 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -203,9 +203,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); 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 bbace838183..9172115903b 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 @@ -496,9 +496,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 6fe07506958..533619ed055 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -676,9 +676,7 @@ class pdf_einstein extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 8614238c2c7..bae583ccf4c 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -900,9 +900,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); 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 83e8f2551f7..aec1a96109a 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 @@ -492,9 +492,7 @@ class doc_generic_contract_odt extends ModelePDFContract $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 8921425a8ac..69b7f193a70 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -496,9 +496,7 @@ class pdf_strato extends ModelePDFContract $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 3db75e6ca9b..7ae6356aabc 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -634,9 +634,7 @@ class pdf_storm extends ModelePDFDeliveryOrder $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 281dbf65026..af2fda0f7a8 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -619,9 +619,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 155d16842ec..e48e2e2c092 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -240,9 +240,7 @@ class html_cerfafr extends ModeleDon $handle = fopen($file, "w"); fwrite($handle, $form); fclose($handle); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); 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 f8280aab301..bf264b45c94 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 @@ -559,9 +559,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index bb8eb9e9baf..34699a6e608 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -763,9 +763,7 @@ class pdf_espadon extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index db10c37e7e8..130608be433 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -425,9 +425,7 @@ class pdf_merou extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 87dd02096e8..f0d2fb847a1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -669,9 +669,7 @@ class pdf_rouget extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 4363a7e90f1..5568cd28840 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -539,9 +539,7 @@ class pdf_standard extends ModeleExpenseReport $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); 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 e8fc6325001..14f71fa4f99 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 @@ -520,9 +520,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1c93f32a4d6..207514ca195 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -908,9 +908,7 @@ class pdf_crabe extends ModelePDFFactures $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 4ae1df8dae6..98c2e4552bc 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1058,9 +1058,7 @@ class pdf_sponge extends ModelePDFFactures $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 7616fba5c6b..f209dc67247 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -469,9 +469,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 2d125d2743a..f38f61e6d8a 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -412,9 +412,7 @@ class doc_generic_member_odt extends ModelePDFMember $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 5a038e67c6d..179645e1a97 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -455,10 +455,7 @@ class pdf_standard extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index d42dbaa0666..a1c4ff54654 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -791,9 +791,7 @@ class pdf_standard extends ModelePDFMovement $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 90d1f2f8d6b..340530d8504 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -484,9 +484,7 @@ class doc_generic_mo_odt extends ModelePDFMo $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 492385a53a3..e625d685727 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -684,9 +684,7 @@ class pdf_vinci extends ModelePDFMo $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 0e9eefa1e45..a3195290b21 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -337,9 +337,7 @@ class pdf_standardlabel extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 0d380ce1537..fe18c8cb467 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -360,10 +360,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 6fde0ce16c4..ba98d74fb3f 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -481,9 +481,7 @@ class doc_generic_product_odt extends ModelePDFProduct $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index c8190a362f5..b244f01e0fa 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -581,9 +581,7 @@ class pdf_standard extends ModelePDFProduct $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index c3a8cd796fc..635a627d0a1 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1167,9 +1167,7 @@ class doc_generic_project_odt extends ModelePDFProjects $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index b5c3c6d215b..2bfd73757c9 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -521,9 +521,7 @@ class pdf_baleine extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index e72198e5b22..c1365fde536 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -769,9 +769,7 @@ class pdf_beluga extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 7af10dd170d..c5aa80d5748 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -524,9 +524,7 @@ class pdf_timespent extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index a7f3eab4a30..49522a01d33 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -845,9 +845,7 @@ class doc_generic_task_odt extends ModelePDFTask $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index ac95786cdd2..d1a64bcf039 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -523,9 +523,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9ea524f2977..d3117e526f8 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -873,9 +873,7 @@ class pdf_azur extends ModelePDFPropales $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 8a41e680fc5..ddc4e60ad4c 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -990,9 +990,7 @@ class pdf_cyan extends ModelePDFPropales $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 5440c8e1201..67504bea2cd 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -343,9 +343,7 @@ class pdf_paiement $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 84d95a5036c..463a794faee 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -485,9 +485,7 @@ class doc_generic_reception_odt extends ModelePdfReception $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 127cc790e0c..b605ac68631 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -599,9 +599,7 @@ class pdf_squille extends ModelePdfReception $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return 1; // No error } else { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index d6804c3a397..e8d6c8317dc 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -433,9 +433,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 358369d1f43..4ce652dd55b 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -484,9 +484,7 @@ class doc_generic_stock_odt extends ModelePDFStock $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index ac0bf98b0f3..a5c1d87691d 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -595,9 +595,7 @@ class pdf_standard extends ModelePDFStock $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 35a52f35bd8..b6e38438a69 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -659,8 +659,7 @@ class pdf_eagle extends ModelePdfStockTransfer $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index ed8b46c7746..23feb4bfca6 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -796,8 +796,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index c9e18e7c4ab..c37eef06360 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -483,9 +483,7 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 802abd6a184..d1b8331ea5d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -622,9 +622,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index ca7d1b3d61b..8a747775b3f 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -478,9 +478,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 2343885cb4d..43bfae86af3 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -840,9 +840,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1de4acd1550..cecd9737cdf 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -722,9 +722,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 74f90f1d68e..18cb0796ed0 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -478,9 +478,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 8fca5110896..116b6daf9be 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -510,9 +510,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 2f264cfb928..0efa9cc63be 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -702,9 +702,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 265741f35c6..73ebc0d1d90 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -180,7 +180,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface $message = dol_print_date(dol_now('gmt'), 'standard', 'gmt').$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ?str_pad('', $this->ident, ' ') : '').$content['message']; fwrite($filefd, $message."\n"); fclose($filefd); - @chmod($logfile, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logfile); } } } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index e175115ac28..de316dbc4b1 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -405,9 +405,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 00edf04fac0..e8a15b8f09a 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -433,9 +433,7 @@ class doc_generic_user_odt extends ModelePDFUser $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index a5447260a2f..5700870444f 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -491,9 +491,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index e6c1aac1372..b73748ecf23 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -287,9 +287,7 @@ if ($action == 'download') { if ($result) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($localfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($localfile); // Define mime type $type = 'application/octet-stream'; diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 0bba0e59345..47226a60829 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -880,7 +880,7 @@ IMG; pclose($handlein); fclose($handle); } - if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfile); } if ($retval == 0) { diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php index 4f1c281ee93..648b0e3ef6a 100644 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php @@ -137,7 +137,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 6598843b882..40e1c1b799e 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -443,11 +443,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } @@ -490,11 +491,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9f370340a01..24922a912dc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -374,7 +374,7 @@ DoTestSendHTML=Test sending HTML ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each year if sequence {yy} or {yyyy} is not in mask. ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. -UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
    It must be the octal value (for example, 0666 means read and write for everyone).
    This parameter is useless on a Windows server. +UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
    It must be the octal value (for example, 0666 means read and write for everyone.). Recommended value is 0660
    This parameter is useless on a Windows server. SeeWikiForAllTeam=Take a look at the Wiki page for a list of contributors and their organization UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) DisableLinkToHelpCenter=Hide the link "Need help or support" on the login page diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 164bfc3911c..6e60f238911 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -262,6 +262,7 @@ ErrorParameterMustBeEnabledToAllwoThisFeature=Error, parameter %s must be ErrorLoginDateValidity=Error, this login is outside the validity date range ErrorValueLength=Length of field '%s' must be higher than '%s' ErrorReservedKeyword=The word '%s' is a reserved keyword +ErrorFilenameReserved=The filename %s can't be used as it is a reserved and protected command. ErrorNotAvailableWithThisDistribution=Not available with this distribution ErrorPublicInterfaceNotEnabled=Public interface was not enabled ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 299bae1d6ce..d2fc01ddead 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1246,20 +1246,20 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } if ($objectname != $firstobjectname) { $rightToadd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); @@ -1835,20 +1835,20 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { // regenerate permissions and delete them $rights = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; @@ -2050,10 +2050,10 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { } //prepare stirng to add $rightToAdd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; @@ -2152,18 +2152,18 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e //prepare right want to delete $right = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; // right after editing $rightUpdated = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; if (!$error) { @@ -2209,10 +2209,10 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p $x3 = $permissions[$key][5]; //prepare right want to delete $rightTodelete = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; @@ -2286,7 +2286,7 @@ if ($action == 'savefile' && empty($cancel)) { dol_delete_file($pathoffile); $result = file_put_contents($pathoffile, $content); if ($result) { - @chmod($pathoffile, octdec($newmask)); + dolChmod($pathoffile, $newmask); setEventMessages($langs->trans("FileSaved"), null); } else { @@ -2394,19 +2394,19 @@ if ($dirins && $action == 'confirm_deletemenu' && GETPOST('menukey', 'int')) { if ($menus[$key]['type'] == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$menus[$key]['fk_menu']."', - 'type'=>'".$menus[$key]['type']."', + 'fk_menu'=>'".$menus[$key]['fk_menu']."', + 'type'=>'".$menus[$key]['type']."', 'titre'=>'".$menus[$key]['titre']."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu'=> '', 'url'=>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $check = dolReplaceInFile($moduledescriptorfile, array($menuTop => '',"\t\t".'/*TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n" => '', '/*END TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n\t\t" => '')); } @@ -2579,19 +2579,19 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { if ($type == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$fk_menu."', - 'type'=>'".strtolower($type)."', + 'fk_menu'=>'".$fk_menu."', + 'type'=>'".strtolower($type)."', 'titre'=>'".ucfirst($titre)."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$mainmenu."', 'leftmenu'=> '".$leftmenu."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; $addTopMenu = dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER TOPMENU */' => '/*TOPMENU '.strtolower($titre).'*/'.$menuTop."\n\t\t".'/*END TOPMENU '.strtolower($titre).'*/'."\n\t\t/* END MODULEBUILDER TOPMENU */")); } @@ -2605,7 +2605,7 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { 'mainmenu'=>'".strtolower($module)."', 'leftmenu'=>'".strtolower($leftmenu)."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1100+\$r, 'enabled'=>'\$conf->".strtolower($module)."->enabled', 'perms'=>'".$perms."', @@ -2662,12 +2662,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $fk_menu = GETPOST('fk_type', 'alpha'); @@ -2691,12 +2691,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'".$menus[$key]['enabled']."', + 'enabled'=>'".$menus[$key]['enabled']."', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; @@ -2716,12 +2716,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>'".$user."', + 'user'=>'".$user."', );"; dolReplaceInFile($moduledescriptorfile, array($menuTomodify => $modifiedMenu)); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index f89360e8774..bcd437ad21d 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -498,9 +498,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index b78a2a5f4d7..66d0ae14d58 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -783,13 +783,11 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index e2b6c5129ff..c32e789d429 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -366,10 +366,7 @@ class ProjectStats extends Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } else { dol_syslog("Failed to write cache file", LOG_ERR); } @@ -479,12 +476,11 @@ class ProjectStats extends Stats dol_mkdir($conf->user->dir_temp); } $fp = fopen($newpathofdestfile, 'w'); - fwrite($fp, json_encode($data)); - fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; + if ($fp) { + fwrite($fp, json_encode($data)); + fclose($fp); + dolChmod($newpathofdestfile); } - @chmod($newpathofdestfile, octdec($newmask)); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 147e8ec3519..a415cb5c940 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -482,9 +482,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 61c2eb3ff20..a0747f13f45 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -710,13 +710,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 92a2b8f6b45..28eb11dde90 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1132,9 +1132,7 @@ class Website extends CommonObject fputs($fp, $line); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filesql, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filesql); // Build zip file $filedir = $conf->website->dir_temp.'/'.$website->ref.'/.'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index adccc80e14c..83d675f4394 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -939,8 +939,7 @@ if ($action == 'addcontainer' && $usercanedit) { $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); } */ @@ -1008,8 +1007,7 @@ if ($action == 'addcontainer' && $usercanedit) { //$fp = fopen($filetosave, "w"); //fputs($fp, $tmpgeturl['content']); //fclose($fp); - //if (!empty($conf->global->MAIN_UMASK)) - // @chmod($file, octdec($conf->global->MAIN_UMASK)); + //dolChmod($file); // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $pagecsscontent .= '/* Content of file '.$urltograbbis.' */'."\n"; @@ -2659,9 +2657,7 @@ if ($action == 'generatesitemaps' && $usercanedit) { } $domtree->appendChild($root); if ($domtree->save($tempdir.$xmlname)) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($tempdir.$xmlname, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($tempdir.$xmlname); setEventMessages($langs->trans("SitemapGenerated", $xmlname), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -5022,8 +5018,7 @@ if ((empty($action) || $action == 'preview' || $action == 'createfromclone' || $ print $out; /*file_put_contents($filetpl, $out); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); + dolChmod($filetpl); // Output file on browser dol_syslog("index.php include $filetpl $filename content-type=$type"); diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); From aa7fdaf1949541f20ac55e94c8095fd2b7f85e59 Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Sat, 18 Feb 2023 03:23:45 +0100 Subject: [PATCH 096/217] Update card.php --- htdocs/salaries/card.php | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 42fecf28b37..fd1a7d8bae7 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -5,6 +5,8 @@ * Copyright (C) 2015 Charlie BENKE * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2023 Maxime Nicolas + * Copyright (C) 2023 Benjamin GREMBI * * 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 @@ -148,6 +150,13 @@ if (empty($reshook)) { } $action = ''; } + // Actions to send emails + $triggersendname = 'COMPANY_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromthirdparty'; + $trackid = 'thi'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + } // Link to a project @@ -382,7 +391,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->id = $object->ref = null; if (GETPOST('amount', 'alphanohtml')) { - $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); } if (GETPOST('clone_label', 'alphanohtml')) { @@ -451,7 +460,6 @@ if (isModEnabled('project')) $formproject = new FormProjets($db); $title = $langs->trans('Salary')." - ".$object->ref; $help_url = ""; - llxHeader('', $title, $help_url); @@ -662,9 +670,9 @@ if ($action == 'create' && $permissiontoadd) { print ''; } - // View mode if ($id > 0) { $head = salaries_prepare_head($object); @@ -803,7 +810,7 @@ if ($id > 0) { $morehtmlref .= ''; } - $usercancreate = $permissiontoadd; + $usercancreate = $permissiontoadd; // Project if (isModEnabled('project')) { @@ -969,11 +976,8 @@ if ($id > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; - // Date - print ''; + print ''; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; - // Date print ''.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; @@ -1046,6 +1050,17 @@ if ($id > 0) { print '
    '."\n"; if ($action != 'edit') { + // Dynamic send mail button + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if (empty($user->socid)) { + $canSendMail = true; + + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); + } + } + // Reopen if ($object->paye && $user->rights->salaries->write) { print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); @@ -1137,6 +1152,10 @@ if ($id > 0) { $trackid = 'salary'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + + // Hook to add more things on page + $parameters = array(); + $reshook = $hookmanager->executeHooks('salaryCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } // End of page From 25634fbb50a78eeaf6c8c4d90f664aa689ee683e Mon Sep 17 00:00:00 2001 From: Oarces DEV Date: Sat, 18 Feb 2023 03:24:17 +0100 Subject: [PATCH 097/217] Update card_presend.tpl.php --- htdocs/core/tpl/card_presend.tpl.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 2393524e572..56350588410 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -1,6 +1,8 @@ - * Copyright (C) 2022 Charlene Benke +/* Copyright (C) 2017-2018 Laurent Destailleur + * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Maxime Nicolas + * Copyright (C) 2023 Benjamin GREMBI * * 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 @@ -129,7 +131,11 @@ if ($action == 'presend') { if ($formmail->fromtype === 'user') { $formmail->fromid = $user->id; } - + if ($object->element == 'salary' && !empty($conf->global->INVOICE_EMAIL_SENDER)) { + $formmail->frommail = $conf->global->SINVOICE_EMAIL_SENDER; + $formmail->fromname = (!empty($conf->global->INVOICE_EMAIL_SENDER_NAME) ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); + $formmail->fromtype = 'special'; + } if ($object->element === 'facture' && !empty($conf->global->INVOICE_EMAIL_SENDER)) { $formmail->frommail = $conf->global->INVOICE_EMAIL_SENDER; $formmail->fromname = (!empty($conf->global->INVOICE_EMAIL_SENDER_NAME) ? $conf->global->INVOICE_EMAIL_SENDER_NAME : ''); @@ -194,6 +200,10 @@ if ($action == 'presend') { $liste['contact'] = $object->getFullName($outputlangs)." <".$object->email.">"; } elseif ($object->element == 'user' || $object->element == 'member') { $liste['thirdparty'] = $object->getFullName($outputlangs)." <".$object->email.">"; + } elseif ($object->element == 'salary') { + $fuser = new User($db); + $fuser->fetch($object->fk_user); + $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; } else { if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) { $object->fetch_thirdparty(); From af8e6bfa617d84e5ad904e7fb0293c6dee0fe2fa Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 18 Feb 2023 02:26:38 +0000 Subject: [PATCH 098/217] Fixing style errors. --- htdocs/salaries/card.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index fd1a7d8bae7..c0f4cd8f728 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -156,7 +156,6 @@ if (empty($reshook)) { $mode = 'emailfromthirdparty'; $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - } // Link to a project @@ -810,7 +809,7 @@ if ($id > 0) { $morehtmlref .= ''; } - $usercancreate = $permissiontoadd; + $usercancreate = $permissiontoadd; // Project if (isModEnabled('project')) { @@ -1053,13 +1052,13 @@ if ($id > 0) { // Dynamic send mail button $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - if (empty($user->socid)) { - $canSendMail = true; + if (empty($reshook)) { + if (empty($user->socid)) { + $canSendMail = true; - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); - } + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend'.'&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); } + } // Reopen if ($object->paye && $user->rights->salaries->write) { From a691ecd8d3427a50c076d2b8ed700451da858218 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 10:49:35 +0100 Subject: [PATCH 099/217] trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 24922a912dc..15374722716 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -374,7 +374,7 @@ DoTestSendHTML=Test sending HTML ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each year if sequence {yy} or {yyyy} is not in mask. ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. -UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
    It must be the octal value (for example, 0666 means read and write for everyone.). Recommended value is 0660
    This parameter is useless on a Windows server. +UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
    It must be the octal value (for example, 0666 means read and write for everyone.). Recommended value is 0600 or 0660
    This parameter is useless on a Windows server. SeeWikiForAllTeam=Take a look at the Wiki page for a list of contributors and their organization UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) DisableLinkToHelpCenter=Hide the link "Need help or support" on the login page From 27279a62f87b2f8a3cbffb411d9f812e9a5b7a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 11:01:56 +0100 Subject: [PATCH 100/217] FIx #huntrd6cb06dc-5d10-4197-8f89-847c3203d953 --- htdocs/core/class/conf.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0393803d793..58726c7222f 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -600,7 +600,18 @@ class Conf $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator } if (empty($this->global->MAIN_UMASK)) { - $this->global->MAIN_UMASK = '0664'; // Default mask + $this->global->MAIN_UMASK = '0660'; // Default mask + } else { + // We remove the execute bits on the file umask + $tmpumask = (octdec($this->global->MAIN_UMASK) & 0666); + $tmpumask = decoct($tmpumask); + if (!preg_match('/^0/', $tmpumask)) { + $tmpumask = '0'.$tmpumask; + } + if (empty($tmpumask) || $tmpumask === '0') { + $tmpumask = '0664'; + } + $this->global->MAIN_UMASK = $tmpumask; } // conf->use_javascript_ajax From d5b3625b8c9c90785c8181aa070375d6b0b1ca9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 11:25:32 +0100 Subject: [PATCH 101/217] Fix can't rename a file into a reserved CLI command file --- htdocs/core/actions_linkedfiles.inc.php | 30 ++++++++++++++++++------ htdocs/core/class/commonobject.class.php | 23 ++++++++++++++---- htdocs/core/lib/files.lib.php | 6 ++--- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 4e2cd2873b6..6c5ac91c9bb 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -188,7 +188,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto //error fetching } } elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha') && !empty($permissiontoadd)) { - // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + // For documents pages, upload_dir contains already the path to the file from module dir if (!empty($upload_dir)) { $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents @@ -200,7 +200,22 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto $error++; setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); } - if (!$error && $filenamefrom != $filenameto) { + + // Check that filename is not the one of a reserved allowed CLI command + if (empty($error)) { + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($filenameto), $arrayofallowedcommand)) { + $error++; + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFilenameReserved", basename($filenameto)), null, 'errors'); + } + } + } + + if (empty($error) && $filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. @@ -236,17 +251,18 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) // but when we rename from a tab "Documents", we must regenerate thumbs - if (GETPOST('modulepart') == 'medias') { + if (GETPOST('modulepart', 'aZ09') == 'medias') { $generatethumbs = 0; } if ($generatethumbs) { - if ($object->id) { + if ($object->id > 0) { + // Create thumbs for the new file $object->addThumbs($destpath); - } - // TODO Add revert function of addThumbs to remove thumbs with old name - //$object->delThumbs($srcpath); + // Delete thumb files with old name + $object->delThumbs($srcpath); + } } setEventMessages($langs->trans("FileRenamed"), null); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 69188c9a7e4..b8a986a0663 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5743,12 +5743,12 @@ abstract class CommonObject */ public function addThumbs($file) { - global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... - $file_osencoded = dol_osencode($file); if (file_exists($file_osencoded)) { + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... + // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example vignette($file_osencoded, $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -5759,6 +5759,21 @@ abstract class CommonObject } } + /** + * Delete thumbs + * @todo Move this into files.lib.php + * + * @param string $file Path file in UTF8 to original file to delete thumbs. + * @return void + */ + public function delThumbs($file) + { + $imgThumbName = getImageFileNameForSize($file, '_small'); // Full path of thumb file + dol_delete_file($imgThumbName); + $imgThumbName = getImageFileNameForSize($file, '_mini'); // Full path of thumb file + dol_delete_file($imgThumbName); + } + /* Functions common to commonobject and commonobjectline */ diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e74bd537fb2..c29eec57698 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1714,7 +1714,6 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $info = pathinfo($destfull); $destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); $info = pathinfo($destfile); - $destfile = dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because @@ -1722,13 +1721,14 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $destfile = dol_string_nohtmltag($destfile); $destfull = dol_string_nohtmltag($destfull); + // Check that filename is not the one of a reserved allowed CLI command global $dolibarr_main_restrict_os_commands; if (!empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); - if (in_array(basename($destfull), $arrayofallowedcommand)) { + if (in_array($destfile, $arrayofallowedcommand)) { $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorFilenameReserved", basename($destfull)), null, 'errors'); + setEventMessages($langs->trans("ErrorFilenameReserved", $destfile), null, 'errors'); return -1; } } From 2bca97af2f519db3b9cdd048a151a1728d5f52d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 13:13:05 +0100 Subject: [PATCH 102/217] Fix update of config setup page must not rely on javascript --- htdocs/admin/const.php | 30 +++++++++++++++++++++--------- htdocs/theme/eldy/global.inc.php | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index e5625b0f975..895ce8c1b08 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -32,10 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (!$user->admin) { - accessforbidden(); -} - $rowid = GETPOST('rowid', 'int'); $entity = GETPOST('entity', 'int'); $action = GETPOST('action', 'aZ09'); @@ -44,7 +40,6 @@ $consts = GETPOST('const', 'array'); $constname = GETPOST('constname', 'alphanohtml'); $constvalue = GETPOST('constvalue', 'restricthtml'); // We should be able to send everything here $constnote = GETPOST('constnote', 'alpha'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -63,12 +58,30 @@ if (empty($sortorder)) { $sortorder = 'ASC'; } +if ($action == 'add' && GETPOST('update')) { // Click on button update must be used in priority before param $action + $action = 'update'; +} +if ($action == 'add' && GETPOST('delete')) { // Click on button update must be used in priority before param $action + $action = 'delete'; +} +if ($action == 'update' && GETPOST('add')) { // Click on button add must be used in priority before param $action + $action = 'add'; +} +if ($action == 'delete' && GETPOST('add')) { // Click on button add must be used in priority before param $action + $action = 'add'; +} + +if (!$user->admin) { + accessforbidden(); +} + /* * Actions */ -if ($action == 'add' || (GETPOST('add') && $action != 'update')) { +// Add a new record +if ($action == 'add') { $error = 0; if (empty($constname)) { @@ -157,13 +170,12 @@ jQuery(document).ready(function() { jQuery("#delconst").hide(); jQuery(".checkboxfordelete").click(function() { jQuery("#delconst").show(); - jQuery("#action").val('delete'); }); jQuery(".inputforupdate").keyup(function() { // keypress does not support back var field_id = jQuery(this).attr("id"); var row_num = field_id.split("_"); jQuery("#updateconst").show(); - jQuery("#action").val('update'); + jQuery("#action").val('update'); // so default action if we type enter will be update, but correct action is also detected correctly without that when clicking on "Update" button. jQuery("#check_" + row_num[1]).prop("checked",true); }); }); @@ -180,7 +192,7 @@ $param = ''; print '
    entity) && $debug) ? '?debug=1' : '').'" method="POST">'; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index b006978d5fa..e7d94fe0d8c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -7603,7 +7603,7 @@ div.clipboardCPValue.hidewithsize { } .dropdown dd ul { - max-width: 350px; + max-width: 370px; } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ From 2168578f2e2e668f590654b901c1845803cad8cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 14:00:25 +0100 Subject: [PATCH 103/217] Fix inline css --- htdocs/accountancy/admin/accountmodel.php | 4 ++-- htdocs/accountancy/admin/categories_list.php | 6 +++--- htdocs/accountancy/admin/journals_list.php | 6 +++--- htdocs/accountancy/admin/productaccount.php | 4 ++-- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/accountancy/expensereport/list.php | 7 +++---- htdocs/accountancy/supplier/list.php | 7 +++---- htdocs/adherents/card.php | 2 +- htdocs/adherents/class/adherent.class.php | 3 +-- htdocs/adherents/stats/index.php | 2 +- htdocs/adherents/subscription.php | 2 +- htdocs/admin/dolistore/class/dolistore.class.php | 1 - htdocs/admin/modules.php | 2 -- htdocs/admin/system/security.php | 4 ++-- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/bookmarks/bookmarks.lib.php | 2 +- htdocs/comm/action/card.php | 2 +- htdocs/comm/card.php | 2 +- htdocs/comm/propal/stats/index.php | 2 +- htdocs/commande/stats/index.php | 2 +- htdocs/compta/bank/annuel.php | 2 +- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- htdocs/compta/deplacement/stats/index.php | 2 +- htdocs/compta/facture/stats/index.php | 2 +- htdocs/contact/card.php | 2 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/don/stats/index.php | 2 +- htdocs/expedition/stats/index.php | 2 +- htdocs/expensereport/stats/index.php | 2 +- htdocs/fichinter/stats/index.php | 2 +- htdocs/fourn/card.php | 2 +- htdocs/hrm/compare.php | 2 +- htdocs/intracommreport/card.php | 2 +- htdocs/main.inc.php | 2 +- htdocs/margin/tabs/productMargins.php | 2 +- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/opensurvey/wizard/index.php | 2 +- htdocs/product/card.php | 2 +- htdocs/product/document.php | 2 +- htdocs/product/fournisseurs.php | 2 +- htdocs/product/price.php | 2 +- htdocs/product/stats/bom.php | 2 +- htdocs/product/stats/commande.php | 2 +- htdocs/product/stats/commande_fournisseur.php | 2 +- htdocs/product/stats/contrat.php | 2 +- htdocs/product/stats/facture.php | 2 +- htdocs/product/stats/facture_fournisseur.php | 2 +- htdocs/product/stats/facturerec.php | 2 +- htdocs/product/stats/mo.php | 2 +- htdocs/product/stats/propal.php | 2 +- htdocs/product/stats/supplier_proposal.php | 2 +- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/productlot_document.php | 2 +- htdocs/product/stock/stats/commande_fournisseur.php | 2 +- htdocs/product/stock/stats/expedition.php | 2 +- htdocs/product/stock/stats/mo.php | 2 +- htdocs/product/stock/stats/reception.php | 2 +- htdocs/projet/stats/index.php | 2 +- htdocs/projet/tasks/stats/index.php | 2 +- htdocs/public/ticket/index.php | 2 +- htdocs/reception/stats/index.php | 2 +- htdocs/salaries/stats/index.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/ticket/card.php | 2 +- htdocs/ticket/index.php | 2 +- htdocs/ticket/stats/index.php | 2 +- htdocs/user/bank.php | 2 +- htdocs/user/card.php | 2 +- htdocs/variants/combinations.php | 2 +- 69 files changed, 78 insertions(+), 84 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index c5b8fd20045..f2a7842dbbb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -504,8 +504,8 @@ if ($id) { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 0fd7b9012eb..e77b97fe92d 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -545,9 +545,9 @@ if ($tabname[$id]) { print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index ba2d867ebd6..ef8a0f2767f 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -431,9 +431,9 @@ if ($id) { print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 018a0cfd5e8..620e4158ceb 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -194,7 +194,7 @@ if ($action == 'update') { } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
    '.$sql.'
    '; + $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
    '.$sql.'
    '; $ko++; } else { $sql = ''; @@ -203,7 +203,7 @@ if ($action == 'update') { $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); $resql_exists = $db->query($sql_exists); if (!$resql_exists) { - $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
    '.$resql_exists.'
    '; + $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
    '.$resql_exists.'
    '; $ko++; } else { $nb_exists = $db->num_rows($resql_exists); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 42ac08383ea..384f43223bc 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -527,7 +527,7 @@ if (!empty($object->piece_num)) { print dol_get_fiche_end(); - print '
    '; + print '
    '; print '
    '; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 1cf9149024a..4ad8c80a2c1 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -159,7 +159,6 @@ if (empty($reshook)) { if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $msg = ''; - //print '
    ' . $langs->trans("Processing") . '...
    '; if (!empty($mesCasesCochees)) { $msg = '
    '.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
    '; $msg .= '
    '; @@ -173,7 +172,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $monCompte = GETPOST('codeventil'.$monId); if ($monCompte <= 0) { - $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
    '; + $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
    '; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; @@ -185,10 +184,10 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
    '.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '; + $msg .= '
    '.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '; $ok++; } else { - $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '.$sql.'
    '; + $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '.$sql.'
    '; $ko++; } } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index aae34a51e03..3ec92f490bd 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -170,7 +170,6 @@ if (empty($reshook)) { if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $msg = ''; - //print '
    ' . $langs->trans("Processing") . '...
    '; if (!empty($mesCasesCochees)) { $msg = '
    '.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
    '; $msg .= '
    '; @@ -184,7 +183,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $monCompte = GETPOST('codeventil'.$monId); if ($monCompte <= 0) { - $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
    '; + $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
    '; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; @@ -196,10 +195,10 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { dol_syslog('accountancy/supplier/list.php', LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '; + $msg .= '
    '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '; $ok++; } else { - $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '.$sql.'
    '; + $msg .= '
    '.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
    '.$sql.'
    '; $ko++; } } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f9a43e47f0f..4bc3e3e55e4 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1873,7 +1873,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print "
    \n"; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index b84d622094d..039fd4d51c0 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2299,7 +2299,6 @@ class Adherent extends CommonObject $photo .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); $photo .= '
    '; $datas['photo'] = $photo; - //$label .= '
    '; } $datas['divopen'] = '
    '; @@ -2411,7 +2410,7 @@ class Adherent extends CommonObject if ($withpictoimg) { $paddafterimage = ''; if (abs($withpictoimg) == 1) { - $paddafterimage = 'style="margin-right: 3px;"'; + $morecss .= ' paddingrightonly'; } // Only picto if ($withpictoimg > 0) { diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 30b79f4bd76..0efdda9fbd2 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -225,7 +225,7 @@ print ''; print '
    '; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 004bd7eaf4b..a1aa8b8baa9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -664,7 +664,7 @@ if ($rowid > 0) { print "\n"; print "\n"; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index f890262695f..37cfb53d493 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -329,7 +329,6 @@ class Dolistore $html .= ''; $html .= ' '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.dol_escape_htmltag($product->reference).' - '.dol_escape_htmltag($langs->trans('Id')).': '.((int) $product->id).'

    '.dol_escape_htmltag($product->description_short->language[$this->lang - 1]).''; // do not load if display none - //$html .= ''.$product->description->language[$this->lang - 1].''; $html .= ''; $html .= $price; $html .= ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c3f066a464e..1833df59fd2 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -582,8 +582,6 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss'=>'reposition')); $moreforfilter .= ''; - //$moreforfilter .= '
    '.$moreinfo.' '.$moreinfo2.'
    '; - $moreforfilter .= '
    '; $moreforfilter .= '
    '; $moreforfilter .= img_picto($langs->trans("Filter"), 'filter', 'class="paddingright opacityhigh hideonsmartphone"').''; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index e1b47b5beaa..eec4d564d9f 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -580,14 +580,14 @@ print '
    '; print 'MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED = '.getDolGlobalString('MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
    "; print '
    '; -print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
    "; +print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; img-src *;\")
    "; print '
    '; print 'MAIN_SECURITY_FORCERP = '.getDolGlobalString('MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
    "; print '
    '; print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").''); -print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
    "; +print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com 'unsafe-inline'; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
    "; print '
    '; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
    "; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 8afd1f7e03c..3ce6dbd48a4 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -169,7 +169,7 @@ print ''; print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'
    '; print ''; print ''; -print ''; +print ''; print ''; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 88cae3e4293..12d1b561683 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -196,7 +196,7 @@ function printDropdownBookmarksList() '; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b8a73cf1b9b..8cabb3d3215 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2493,7 +2493,7 @@ if ($id > 0) { if ($action != 'edit') { if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) { - print '
    '; + print '
    '; print ''; // ancre /* diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 600d22b432a..32f6e571fcd 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1539,7 +1539,7 @@ if ($object->id > 0) { } print '
    '; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index db85490e1bb..9473ca3bcb5 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -366,7 +366,7 @@ print '
    '; print '
    '; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 9052ed7ab27..20fccd3f000 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -426,7 +426,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 177855c9302..f3047dacf3e 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -463,7 +463,7 @@ if ($result < 0) { print '
    '; // do not use class="center" here, it will have no effect for the js graph inside. print $show2; print '
    '; - print '
    '; + print '
    '; } diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index dfc8564b34c..a95512a286f 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -671,7 +671,7 @@ if (empty($action) || $action == "view" || $action == "close") { print "\n"; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 1bf7706bf87..4cb75c526ef 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -321,7 +321,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index e1f68a5f79a..5c23057b10b 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -421,7 +421,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index cd94f4ebbac..1584fdbe41c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1500,7 +1500,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index a6a24e056b9..6584d59400c 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -135,7 +135,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $object = null; $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been - print '
    '; + print '
    '; } diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 866cd25eef1..3ca8c0aeab6 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -295,7 +295,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index 3e8cba9def2..9213e2ca849 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -310,7 +310,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index e9fdd03a2be..04ce5d5d648 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -311,7 +311,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 59c3ba83ee1..cec740fdd9c 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -319,7 +319,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 19335656f51..c6bee17d20b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -868,7 +868,7 @@ if ($object->id > 0) { } print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index cfb3f73f7cd..63b40cccb0e 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -188,7 +188,7 @@ $fk_usergroup1 = GETPOST('fk_usergroup1'); -
    +
    diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 403c4b28eae..a5b17803f65 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -274,7 +274,7 @@ if ($id > 0 && $action != 'edit') { print "\n"; print "\n"; - print '
    '; + print '
    '; print dol_get_fiche_end(); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 323af1af532..5d247b4bc27 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2390,7 +2390,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
    '.$logoutLink.'
    -
    +
    diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 107189e5181..1bda53b5c5d 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 00188256619..3202dcb93ce 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -163,7 +163,7 @@ if ($socid > 0) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index b8ccd0d8588..4542ecfa3bd 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -61,7 +61,7 @@ print '
    '; print '
    '; print ''; print '
    '; -print '
    '; +print '
    '; print ''; print ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 610bd41b1c1..197626d69f3 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2722,7 +2722,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); } diff --git a/htdocs/product/document.php b/htdocs/product/document.php index c24082ae6e6..af75cbc71ce 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -259,7 +259,7 @@ if ($object->id) { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index c1b61913d9f..d82fa8b1c41 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -460,7 +460,7 @@ if ($id > 0 || $ref) { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 788857dfd47..08757602907 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1312,7 +1312,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print "\n"; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index 66e673567a6..0ccc249b94f 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -121,7 +121,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 5559eaf8413..1df4f70c063 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 6ae1d7881ef..4d5972529cd 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index bcf9c8c0737..a53c71085fd 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -120,7 +120,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 3ff0b00d56a..c0a4d36793c 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -147,7 +147,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 20bb56a3c19..8e89a05273f 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -132,7 +132,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php index 9b982407825..b09e572763a 100644 --- a/htdocs/product/stats/facturerec.php +++ b/htdocs/product/stats/facturerec.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index b401b40bc9e..561557e62fe 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index b70d2e08161..e1b46677c65 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 50b17b0ac06..a182aa61eb6 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -132,7 +132,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index b0771bc39d9..80a5f969a84 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -903,7 +903,7 @@ if ($id > 0 || $ref) { print ''; print ''; - print '
    '; + print '
    '; } print dol_get_fiche_end(); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index be6c7f640a4..38c5b0503d8 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -197,7 +197,7 @@ if ($object->id) { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index e8f8463493f..22be071ffc5 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -205,7 +205,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index b18bee897e4..19e2640d0bd 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -205,7 +205,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index 06fcad417c7..f0be40d1a1d 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -152,7 +152,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index ec54553ed07..bf944056ccb 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -205,7 +205,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index 32498121045..a0b076197b8 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -329,7 +329,7 @@ print $stringtoshow; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 07b0199d480..ee0bae2dc45 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -224,7 +224,7 @@ print $stringtoshow; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 84652017b37..239d9f71d59 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -89,7 +89,7 @@ print ''; print ''; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index df11e2a9cd5..f951beca058 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -302,7 +302,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ba5d254f22b..c18f59a754a 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -279,7 +279,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 02d0b042aab..30c23781757 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -3185,7 +3185,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 95d290d680a..2a8ee74be33 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1386,7 +1386,7 @@ if ($action == 'create' || $action == 'presend') { } print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index f75a93f7082..35e11b9f1f5 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -446,7 +446,7 @@ print ''; print ''; -print '
    '; +print '
    '; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardTickets', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 7e94af1a431..acbf03b5ba9 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -316,7 +316,7 @@ print ''; print ''; -print '
    '; +print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 4c26ec27021..fc7efd23749 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -757,7 +757,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b3d83ddb239..04086a90304 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1892,7 +1892,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index e5043dcd7fa..4c2b77ce766 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -463,7 +463,7 @@ if (!empty($id) || !empty($ref)) { print "\n"; print ''; - print '
    '; + print '
    '; print dol_get_fiche_end(); From a81510ccd65714bbf08d784c573568532c749fe7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 14:15:39 +0100 Subject: [PATCH 104/217] Better exemple for RCP security string --- htdocs/admin/system/security.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index c23bdb3051f..d7f8884a38a 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -574,13 +574,13 @@ print '
    '; print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)."
    "; print '
    '; -print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
    "; +print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src *; img-src *; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';\")
    "; print '
    '; print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
    "; print '
    '; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
    "; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
    "; print '
    '; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
    "; From fdcce8d26361e0266825157f0cffdfe3594acdb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 15:10:05 +0100 Subject: [PATCH 105/217] Add nonce on javascript tags --- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/ajax/ajaxdirtree.php | 4 +- htdocs/core/boxes/box_actions.php | 4 +- .../boxes/box_graph_invoices_permonth.php | 2 +- .../core/boxes/box_graph_invoices_peryear.php | 2 +- .../box_graph_invoices_supplier_permonth.php | 2 +- .../boxes/box_graph_nb_ticket_last_x_days.php | 2 +- .../core/boxes/box_graph_orders_permonth.php | 2 +- .../box_graph_orders_supplier_permonth.php | 2 +- .../boxes/box_graph_product_distribution.php | 2 +- .../boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_task.php | 4 +- htdocs/core/class/commonobject.class.php | 4 +- .../core/class/commonsocialnetworks.class.php | 2 +- htdocs/core/class/doleditor.class.php | 6 +-- htdocs/core/class/dolgraph.class.php | 4 +- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/class/html.form.class.php | 36 +++++++------- .../core/class/html.formaccounting.class.php | 2 +- htdocs/core/class/html.formactions.class.php | 3 +- htdocs/core/class/html.formbarcode.class.php | 2 +- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 +- htdocs/core/class/html.formmargin.class.php | 10 ++-- htdocs/core/class/html.formother.class.php | 12 ++--- htdocs/core/class/html.formsms.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 16 +++---- htdocs/core/class/openid.class.php | 2 +- htdocs/core/customreports.php | 2 +- htdocs/core/datepicker.php | 4 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/lib/functions.lib.php | 39 ++++++++++----- htdocs/core/lib/project.lib.php | 18 ------- htdocs/core/lib/security2.lib.php | 3 +- htdocs/core/lib/treeview.lib.php | 2 +- htdocs/core/lib/website.lib.php | 14 +++--- htdocs/core/lib/website2.lib.php | 2 +- htdocs/core/photos_resize.php | 2 +- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- htdocs/core/tpl/passwordreset.tpl.php | 3 +- htdocs/main.inc.php | 47 ++++++++++--------- 43 files changed, 143 insertions(+), 140 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 76531832776..2f763c4e576 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -448,7 +448,7 @@ if ($useajax || $action == 'deletefile') { if ($useajax) { print ''."\n"; - print ''; // This ajax service is called only when a directory $selecteddir is opened but not when closed. - //print ''; } diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index ac0df03184a..a47f5d4f744 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -256,7 +256,7 @@ class box_actions extends ModeleBoxes } $out .= ''; if ($actioncejour) { - $out .= ''; } else { - $out .= ''; } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 03b0e1d087b..34dc015a1db 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -227,7 +227,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (!$mesg) { $stringtoshow = ''; - $stringtoshow .= ''; // set cookie by js - $boxcontent .= ''; + $boxcontent .= ''; } $this->info_box_contents[0][] = array( 'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"', diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b8a986a0663..1376155e0e7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7443,7 +7443,7 @@ abstract class CommonObject if (!empty($conf->use_javascript_ajax)) { $out .= ' - '; + $result .= ''; } return $result; @@ -833,7 +833,7 @@ class Form if (!empty($conf->use_javascript_ajax)) { $ret .= ' - '; + print ''; + print 'console.log("hide the margin info"); $("#margintable").hide();'; } + print '});'; } print '
    '; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 7e14474bc96..21e5b608a41 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -104,7 +104,7 @@ class FormOther $out .= '
    '; $out .= '
    '; - $out .= ''; - $out .= ''; + $out .= ''; - $out .= ''; + $out .= ''; } - $stringtoprint .=''; } else { // Default Header Redirect diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index fefdc5880c8..d61a07f59bc 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -443,7 +443,7 @@ if (empty($conf->use_javascript_ajax)) { print ''; } else { print ' - '."\n"; + print ''."\n"; } else { print ''.$langs->trans("Calendar").''; } @@ -93,7 +93,7 @@ $tradTemp = array( $langs->trans("November"), $langs->trans("December") ); -print ' + "; + gtag(\'config\', \''.trim($tmptag).'\'); + '; print "\n"; } } @@ -9772,7 +9772,7 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') function dol_set_focus($selector) { print "\n".''."\n"; - print ''."\n"; + print ''."\n"; } @@ -10074,7 +10074,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link') { global $langs; - $out = '';*/ - print ''; // Note @@ -1656,15 +1647,6 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //$tableCell.=' '; print $tableCell; - // Comment for avoid unnecessary multiple calculation - /*$modeinput = 'hours'; - - print '';*/ - print ''; // Note diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index e0bf4a683f0..c68bb49d93b 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -570,7 +570,8 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token global $conf; if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; } elseif ($type == 'qa') { $ret = ''."\n"; - $ret .= ''; + $out .= ''; $out .= '
    '."\n"; // Reddit @@ -931,7 +931,7 @@ function getSocialNetworkSharingLinks() // Facebook $out .= ''; } -if ($moreforfilter) { +if (!empty($moreforfilter)) { print '
    '; print $moreforfilter; $parameters = array('type'=>$type); @@ -1084,18 +1097,14 @@ if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } -if (empty($arrayfields['customerorsupplier']['checked'])) { - print ''; -} - print '
    '; -print ''."\n"; +print '
    '."\n"; // Fields title search print ''; +// Action column if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - // Action column - print ''; @@ -1331,112 +1340,151 @@ if (!empty($arrayfields['s.import_key']['checked'])) { } if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { // Action column - print ''; } -print "\n"; +print ''."\n"; + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.rowid']['checked'])) { print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, 'actioncolumn '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, 'actioncolumn '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.name_alias']['checked'])) { print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.barcode']['checked'])) { print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.code_client']['checked'])) { print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.code_fournisseur']['checked'])) { print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.code_compta']['checked'])) { print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.address']['checked'])) { print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.zip']['checked'])) { print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['state.nom']['checked'])) { print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['region.nom']['checked'])) { print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['typent.code']['checked'])) { print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['staff.code']['checked'])) { print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.price_level']['checked'])) { print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.email']['checked'])) { print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.phone']['checked'])) { print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.fax']['checked'])) { print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.url']['checked'])) { print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.siren']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.siret']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.ape']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.idprof4']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.idprof5']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.idprof6']['checked'])) { print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.tva_intra']['checked'])) { print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['customerorsupplier']['checked'])) { print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.fk_stcomm']['checked'])) { print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s2.nom']['checked'])) { print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1446,27 +1494,39 @@ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $objec print $hookmanager->resPrint; if (!empty($arrayfields['s.datec']['checked'])) { print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.tms']['checked'])) { print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.status']['checked'])) { print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.import_key']['checked'])) { print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + $totalarray['nbfield']++; // For the column action } -print "\n"; +print ''."\n"; $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } + $parameters = array('staticdata' => $obj); // Note that $action and $object may have been modified by hook // do companystatic fetch in hook if wanted or anything else @@ -1500,13 +1560,11 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { - print ''; From 992fe1286d5b17f83e2248e98f4df80eb430de18 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 18 Feb 2023 16:08:19 +0100 Subject: [PATCH 108/217] FIX request new password with "mc" and "twofactor" authentication --- htdocs/user/class/user.class.php | 3 +++ htdocs/user/passwordforgotten.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9a495a04a91..9ee9bcae43e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2425,6 +2425,9 @@ class User extends CommonObject //print $password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id; $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword'; $url .= '&username='.urlencode($this->login)."&passworduidhash=".urlencode(dol_hash($password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id)); + if (!empty($conf->multicompany->enabled)) { + $url .= '&entity='.(!empty($user->entity) ? $user->entity : 1); + } $msgishtml = 1; diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index dabac0727dc..c529dcc0e19 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -87,7 +87,7 @@ if (empty($reshook)) { // Validate new password if ($action == 'validatenewpassword' && $username && $passworduidhash) { $edituser = new User($db); - $result = $edituser->fetch('', $username); + $result = $edituser->fetch('', $username, '', 0, $conf->entity); if ($result < 0) { $message = '
    '.dol_escape_htmltag($langs->trans("ErrorLoginDoesNotExists", $username)).'
    '; } else { @@ -122,9 +122,9 @@ if (empty($reshook)) { $isanemail = preg_match('/@/', $username); $edituser = new User($db); - $result = $edituser->fetch('', $username, '', 1); + $result = $edituser->fetch('', $username, '', 1, $conf->entity); if ($result == 0 && $isanemail) { - $result = $edituser->fetch('', '', '', 1, -1, $username); + $result = $edituser->fetch('', '', '', 1, $conf->entity, $username); } if ($result <= 0 && $edituser->error == 'USERNOTFOUND') { From 5b81880b9721f4ddb26725887c3b98e5d12354e3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 18 Feb 2023 16:24:56 +0100 Subject: [PATCH 109/217] FIX object $user is not defined --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9ee9bcae43e..f5566cc30e7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2426,7 +2426,7 @@ class User extends CommonObject $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword'; $url .= '&username='.urlencode($this->login)."&passworduidhash=".urlencode(dol_hash($password.'-'.$this->id.'-'.$dolibarr_main_instance_unique_id)); if (!empty($conf->multicompany->enabled)) { - $url .= '&entity='.(!empty($user->entity) ? $user->entity : 1); + $url .= '&entity='.(!empty($this->entity) ? $this->entity : 1); } $msgishtml = 1; From 50721f8df3eb8399930d4f7b7dd2c5e3e1012a39 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 18 Feb 2023 16:31:59 +0100 Subject: [PATCH 110/217] TODO object $user parameter is not use in send_password() ! --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f5566cc30e7..752cbf15c34 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2359,7 +2359,7 @@ class User extends CommonObject /** * Send new password by email * - * @param User $user Object user that send the email (not the user we send too) + * @param User $user Object user that send the email (not the user we send too) @todo object $user is not used ! * @param string $password New password * @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @todo Add method 2 = Send link to reset password * @return int < 0 si erreur, > 0 si ok From fd3dffc892102b60920334aaaba5487a6dae8a1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 19:20:54 +0100 Subject: [PATCH 111/217] Add kanban view for partnership object --- htdocs/hrm/class/position.class.php | 3 +- .../modulebuilder/template/myobject_list.php | 2 +- .../partnership/class/partnership.class.php | 30 +++++++ htdocs/partnership/partnership_list.php | 79 +++++++++++++------ htdocs/product/class/product.class.php | 3 +- htdocs/societe/class/societe.class.php | 3 +- 6 files changed, 91 insertions(+), 29 deletions(-) diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 479479d4b9d..4cb0eb670f8 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1123,9 +1123,10 @@ class Position extends CommonObject * Return clicable link of object (with eventually picto) * * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data * @return string HTML Code for Kanban thumb. */ - public function getKanbanView($option = '') + public function getKanbanView($option = '', $arraydata = null) { global $selected, $langs; $return = '
    '; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7465f2ce161..338ad79affb 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -671,7 +671,7 @@ print ''."\n"; $needToFetchEachLine = 0; if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) { + if ($val && preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object } } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index a6df07655ed..1833fc97d52 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1320,6 +1320,36 @@ class Partnership extends CommonObject return $error; } + + /** + * Return a thumb for kanban views + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $conf, $langs; + $return = '
    '; + $return .= '
    '; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
    '; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= '
    '.$this->label.'
    '; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
    '.$this->getLibStatut(5).'
    '; + } + $return .= '
    '; + $return .= '
    '; + $return .= '
    '; + + return $return; + } } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 7144f201022..a13fb6f8182 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; // Load translation files required by the page $langs->loadLangs(array("partnership", "members", "other")); -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -48,7 +48,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected i $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); @@ -311,9 +311,12 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -420,7 +423,8 @@ $sql=preg_replace('/,\s*$/','', $sql); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); if ($resql) { $objforcount = $db->fetch_object($resql); @@ -429,7 +433,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -576,6 +580,9 @@ if ($managedfor == "member") { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -589,12 +596,16 @@ if ($memberid) { $param .= '&rowid='.urlencode($memberid); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { if ($skey != '') { $param .= '&search_'.$key.'[]='.urlencode($skey); } } + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } @@ -640,15 +651,22 @@ print ''; print ''; print ''; print ''; +print ''; print ''; if ($socid) { print ''; } elseif ($memberid) { print ''; } + + $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) @@ -674,7 +692,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': '; print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
    '; } @@ -704,7 +725,7 @@ if ($managedfor == 'member') { // -------------------------------------------------------------------- print '
    '; // Action column -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; // For the column action } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -790,7 +812,7 @@ foreach ($object->fields as $key => $val) { } $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; $totalarray['nbfield']++; } } @@ -804,13 +826,13 @@ if ($managedfor == 'member') { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; // For the column action } -$totalarray['nbfield']++; print ''."\n"; @@ -857,7 +879,7 @@ while ($i < $imaxinloop) { $j = 0; print ''; // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -888,7 +913,7 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print 'executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print ''."\n"; @@ -970,7 +995,9 @@ while ($i < $imaxinloop) { $i++; } -if ($managedfor != 'member') $totalarray['nbfield']++; // End of subscription date +if ($managedfor != 'member') { + $totalarray['nbfield']++; // End of subscription date +} // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; @@ -983,7 +1010,9 @@ if ($num == 0) { $colspan++; } } - if ($managedfor != 'member') $colspan++; // End of subscription date + if ($managedfor != 'member') { + $colspan++; // End of subscription date + } print ''; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a18a7796541..321c6722018 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6363,9 +6363,10 @@ class Product extends CommonObject * Return clicable link of object (with eventually picto) * * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data * @return string HTML Code for Kanban thumb. */ - public function getKanbanView($option = '') + public function getKanbanView($option = '', $arraydata = null) { global $langs,$conf; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 8aa886e7bd6..02200651a13 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5201,9 +5201,10 @@ class Societe extends CommonObject * Return clicable link of object (with eventually picto) * * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data * @return string HTML Code for Kanban thumb. */ - public function getKanbanView($option = '') + public function getKanbanView($option = '', $arraydata = null) { $return = '
    '; From b35d768d053f6bbee62845b13abd7ffcddb53a46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 20:47:19 +0100 Subject: [PATCH 112/217] Debug v17 --- htdocs/core/class/commonobject.class.php | 8 ++++---- htdocs/core/lib/images.lib.php | 8 ++++++-- htdocs/theme/md/style.css.php | 2 +- htdocs/theme/md/theme_vars.inc.php | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0ac16532246..e4e767b3cee 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8711,9 +8711,9 @@ abstract class CommonObject if ($usesharelink) { if ($val['share']) { - if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { + if (empty($maxHeight) || ($photo_vignette && $imgarray['height'] > $maxHeight)) { $return .= ''; - $return .= ''; + $return .= ''; } else { $return .= ''; $return .= ''; @@ -8723,9 +8723,9 @@ abstract class CommonObject $return .= ''; } } else { - if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight) { + if (empty($maxHeight) || ($photo_vignette && $imgarray['height'] > $maxHeight)) { $return .= ''; - $return .= ''; + $return .= ''; } else { $return .= ''; $return .= ''; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 37cc70760eb..9ca4684ef51 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -130,8 +130,12 @@ function dol_getImageSize($file, $url = false) if ($filetoread) { $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image - $ret['width'] = $infoImg[0]; // Largeur de l'image - $ret['height'] = $infoImg[1]; // Hauteur de l'image + if ($infoImg) { + $ret['width'] = $infoImg[0]; // Largeur de l'image + $ret['height'] = $infoImg[1]; // Hauteur de l'image + } else { + $ret['width'] = $ret['height'] = ''; + } } return $ret; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 945befdae08..6179c64db8c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4900,7 +4900,7 @@ div.titre { color: var(--colortexttitlenotab); } .tertiary { - color: var(--colortexttitlenotab); + color: var(--colortexttitlenotab2); } table.centpercent.notopnoleftnoright.table-fiche-title { diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index 84a1065f781..be799259b32 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -60,6 +60,7 @@ $colorbacklinepairchecked = '230,237,244'; // line checked $colorbacklinebreak = '250,246,251'; $colorbackbody = '248,248,248'; $colortexttitlenotab = '80,71,5'; +$colortexttitlenotab2 = '100,0,100'; $colortexttitle = '20,20,20'; $colortexttitlelink = '0,0,120'; $colortext = '0,0,0'; From 6b12020e7a53e87a794c1e5a6d2b11d60eab1543 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Feb 2023 20:49:38 +0100 Subject: [PATCH 113/217] Look and feel v18 --- htdocs/projet/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 044728227cf..ab1a6800338 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -119,10 +119,11 @@ $morehtml = ''; $morehtml .= ''; $morehtml .= ''; $morehtml .= ''; -$morehtml .= ''; $morehtml .= ''; $morehtml .= ''; $morehtml .= ''; +$morehtml .= ajax_combobox("search_project_user", array(), 0, 0, 'resolve', '-1', 'small'); $morehtml .= ''; $morehtml .= ''; @@ -188,9 +189,8 @@ if ($resql) { print '
    '; -/* - * Statistics - */ + +// Statistics include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php'; From 45a6d12d65c93310dfb630b918c024e6f9022574 Mon Sep 17 00:00:00 2001 From: priojk Date: Sat, 18 Feb 2023 22:33:42 +0100 Subject: [PATCH 114/217] Fix: Original translation change misleading in many places --- htdocs/langs/de_DE/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/de_DE/main.lang b/htdocs/langs/de_DE/main.lang index 4aa75a20c80..56e9c337bfe 100644 --- a/htdocs/langs/de_DE/main.lang +++ b/htdocs/langs/de_DE/main.lang @@ -464,7 +464,7 @@ OtherStatistics=Weitere Statistiken Status=Status Favorite=Favorit ShortInfo=Info. -Ref=Artikelnummer +Ref=Ref.Nr. ExternalRef=Externe-ID RefSupplier=Lieferanten-Zeichen RefPayment=Zahlungsref.-Nr. From 833505b5e2382ea168b2cb896826530baeab512a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 00:17:58 +0100 Subject: [PATCH 115/217] Fix responsive --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3c9e0766a45..3d4a094c30b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2327,7 +2327,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $profilLink = ' '.$langs->trans("Card").''; $urltovirtualcard = '/user/virtualcard.php?id='.((int) $user->id); $virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->trans("PublicVirtualCardUrl").(is_object($user) ? ' - '.$user->getFullName($langs) : ''), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v'); - $logoutLink = ' '.$langs->trans("Logout").''; + $logoutLink = ''.$langs->trans("Logout").''; $profilName = $user->getFullName($langs).' ('.$user->login.')'; if (!empty($user->admin)) { From e2c558f9cc61ed040f85d0610b146a76ea2c8bf2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 01:34:45 +0100 Subject: [PATCH 116/217] Debug v17 --- htdocs/compta/facture/card.php | 51 +++++++++++---------------- htdocs/core/class/html.form.class.php | 16 +++++---- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ccfedf5ad4a..4ea4306a465 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3188,7 +3188,7 @@ if ($action == 'create') { $arrayoutstandingbills = $soc->getOutstandingBills(); $outstandingBills = $arrayoutstandingbills['opened']; print ' - '.$langs->trans('CurrentOutstandingBill').': '; - print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); + print ''.price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency).''; if ($soc->outstanding_limit != '') { if ($outstandingBills > $soc->outstanding_limit) { print img_warning($langs->trans("OutstandingBillReached")); @@ -3307,7 +3307,7 @@ if ($action == 'create') { print '
    '; $tmp = ' '; $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3, 'standardonsmartphone'); print '
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '; + print '
    '; print '
    '; } - // Output Kanban print $companystatic->getKanbanView(''); - //print_r($obj->nb_rights); if ($i == ($imaxinloop - 1)) { print '
    '; print '
    '; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; @@ -723,9 +744,9 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -757,10 +778,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; @@ -774,8 +795,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print '
    '; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -867,6 +889,9 @@ while ($i < $imaxinloop) { print ''; } print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -960,9 +985,9 @@ while ($i < $imaxinloop) { print ''; } print '
    '.$langs->trans("NoRecordFound").'
    '; print ''; - print ''; + print ''; $datem = $db->jdate($obj->dv); print '
    '; print $desc; @@ -3346,7 +3346,7 @@ if ($action == 'create') { jQuery("#radio_deposit").prop("checked", true); setRadioForTypeOfIncoice(); }); - jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() { + jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_creditnote, #radio_template").change(function() { setRadioForTypeOfIncoice(); }); function setRadioForTypeOfIncoice() { @@ -3362,10 +3362,10 @@ if ($action == 'create') { }); '; - $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); print ''; print ''; if (($origin == 'propal') || ($origin == 'commande')) { @@ -3404,7 +3404,7 @@ if ($action == 'create') { print '
    '; $tmp = ' '; $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
    '; @@ -3417,7 +3417,7 @@ if ($action == 'create') { $tmp .= ' disabled'; } $tmp .= '> '; - $text = ' '; + $text = $tmp.' '; $text .= 'id > 0) { $text .= ' disabled'; @@ -3486,26 +3486,18 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
    '; $tmp = ' '; - $text = ' '; + $text = $tmp.' '; $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
    '; - - print '
    '; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
    '; } print '
    '; $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc").'

    '.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'replacementonsmartphone'); print $desc; print '
    '; } @@ -3565,7 +3557,6 @@ if ($action == 'create') { }); '; $text = ' '; - // $text.=''; $text .= ' 0 ? 'checked' : '').' /> "; print '
        0 ? 'checked' : '').' /> "; print ''; @@ -3595,9 +3586,9 @@ if ($action == 'create') { } else { $tmp = ' '; } - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc").'

    '.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'creditnoteonsmartphone'); print $desc; print ''."\n"; } @@ -3606,9 +3597,8 @@ if ($action == 'create') { // Template invoice print '
    '; $tmp = ' '; - $text = ' '; - //$text.= '('.$langs->trans("YouMustCreateStandardInvoiceFirst").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3, 'templateonsmartphone'); print $desc; print '
    '; @@ -3629,7 +3619,8 @@ if ($action == 'create') { $(document).ready(function() { var listType = {'.$jsListType.'}; $("[name=\'type\'").change(function() { - if($( this ).prop("checked")) + console.log("change name=type"); + if ($( this ).prop("checked")) { if(($( this ).val() in listType)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6fef01d3f7e..5ee6efac42f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -724,7 +724,7 @@ class Form * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ @@ -732,11 +732,6 @@ class Form { global $conf, $langs; - $alt = ''; - if ($tooltiptrigger) { - $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); - } - //For backwards compatibility if ($type == '0') { $type = 'info'; @@ -744,6 +739,15 @@ class Form $type = 'help'; } + if (preg_match('/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) { + $tooltiptrigger = preg_replace('/^.*onsmartphone$/', '', $tooltiptrigger); + } + + $alt = ''; + if ($tooltiptrigger) { + $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); + } + // If info or help with no javascript, show only text if (empty($conf->use_javascript_ajax)) { if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { From 4ce5d0f42d5d7a147f8e712f71aed43eae2ef04b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 01:34:45 +0100 Subject: [PATCH 117/217] Debug v17 --- htdocs/compta/facture/card.php | 51 +++++++++++---------------- htdocs/core/class/html.form.class.php | 16 +++++---- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c2469655df6..eaebb294cac 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3189,7 +3189,7 @@ if ($action == 'create') { $arrayoutstandingbills = $soc->getOutstandingBills(); $outstandingBills = $arrayoutstandingbills['opened']; print ' - '.$langs->trans('CurrentOutstandingBill').': '; - print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); + print ''.price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency).''; if ($soc->outstanding_limit != '') { if ($outstandingBills > $soc->outstanding_limit) { print img_warning($langs->trans("OutstandingBillReached")); @@ -3308,7 +3308,7 @@ if ($action == 'create') { print '
    '; $tmp = ' '; $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3, 'standardonsmartphone'); print '
    '; + $tmp = $tmp.''; + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3, 'depositonsmartphone'); print $desc; print '
    '; print '
    '; print $desc; @@ -3347,7 +3347,7 @@ if ($action == 'create') { jQuery("#radio_deposit").prop("checked", true); setRadioForTypeOfIncoice(); }); - jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() { + jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_creditnote, #radio_template").change(function() { setRadioForTypeOfIncoice(); }); function setRadioForTypeOfIncoice() { @@ -3363,10 +3363,10 @@ if ($action == 'create') { }); '; - $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); print ''; print ''; if (($origin == 'propal') || ($origin == 'commande')) { @@ -3405,7 +3405,7 @@ if ($action == 'create') { print '
    '; $tmp = ' '; $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
    '; @@ -3418,7 +3418,7 @@ if ($action == 'create') { $tmp .= ' disabled'; } $tmp .= '> '; - $text = ' '; + $text = $tmp.' '; $text .= 'id > 0) { $text .= ' disabled'; @@ -3487,26 +3487,18 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
    '; $tmp = ' '; - $text = ' '; + $text = $tmp.' '; $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
    '; - - print '
    '; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
    '; } print '
    '; $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc").'

    '.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'replacementonsmartphone'); print $desc; print '
    '; } @@ -3566,7 +3558,6 @@ if ($action == 'create') { }); '; $text = ' '; - // $text.=''; $text .= ' 0 ? 'checked' : '').' /> "; print '
        0 ? 'checked' : '').' /> "; print ''; @@ -3596,9 +3587,9 @@ if ($action == 'create') { } else { $tmp = ' '; } - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc").'

    '.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'creditnoteonsmartphone'); print $desc; print ''."\n"; } @@ -3607,9 +3598,8 @@ if ($action == 'create') { // Template invoice print '
    '; $tmp = ' '; - $text = ' '; - //$text.= '('.$langs->trans("YouMustCreateStandardInvoiceFirst").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3, 'templateonsmartphone'); print $desc; print '
    '; @@ -3630,7 +3620,8 @@ if ($action == 'create') { $(document).ready(function() { var listType = {'.$jsListType.'}; $("[name=\'type\'").change(function() { - if($( this ).prop("checked")) + console.log("change name=type"); + if ($( this ).prop("checked")) { if(($( this ).val() in listType)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a672709cc48..62fee2bc8ec 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -709,7 +709,7 @@ class Form * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ @@ -717,11 +717,6 @@ class Form { global $conf, $langs; - $alt = ''; - if ($tooltiptrigger) { - $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); - } - //For backwards compatibility if ($type == '0') { $type = 'info'; @@ -729,6 +724,15 @@ class Form $type = 'help'; } + if (preg_match('/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) { + $tooltiptrigger = preg_replace('/^.*onsmartphone$/', '', $tooltiptrigger); + } + + $alt = ''; + if ($tooltiptrigger) { + $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); + } + // If info or help with no javascript, show only text if (empty($conf->use_javascript_ajax)) { if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { From 438c7b93f2a73670e21ca1683418b984088e96f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:18:46 +0100 Subject: [PATCH 118/217] Debug v18 --- htdocs/contrat/list.php | 112 ++++++++++++++---- .../modulebuilder/template/myobject_list.php | 8 +- htdocs/user/list.php | 8 +- 3 files changed, 94 insertions(+), 34 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 38c37c1389e..ea072abddf2 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -51,6 +51,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST('mode', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); @@ -88,15 +89,15 @@ if (GETPOSTISSET('formfilteraction')) { } $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array'); -$optioncss = GETPOST('optioncss', 'alpha'); - +// Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -175,6 +176,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); $permissiontoread = $user->rights->contrat->lire; +$permissiontoadd = $user->rights->contrat->creer; $permissiontodelete = $user->rights->contrat->supprimer; @@ -183,7 +185,8 @@ $permissiontodelete = $user->rights->contrat->supprimer; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -243,13 +246,15 @@ if (empty($reshook)) { * View */ -$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $formother = new FormOther($db); $socstatic = new Societe($db); $formcompany = new FormCompany($db); $contracttmp = new Contrat($db); + +$now = dol_now(); + $title = ""; $sql = 'SELECT'; @@ -272,7 +277,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total @@ -452,6 +458,7 @@ if (empty($reshook)) { } $sql .= $hookmanager->resPrint; +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { //$result = $db->query($sql); @@ -485,8 +492,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $page = 0; $offset = 0; } + $db->free($resql); } +// Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); @@ -631,7 +640,7 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); -print '
    '; +print ''."\n"; if ($optioncss != '') { print ''; } @@ -725,10 +734,12 @@ if ($massactionbutton) { print '
    '; print '
    '; + $tmp = $tmp.''; + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3, 'depositonsmartphone'); print $desc; print '
    '."\n"; +// Fields title search +// -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -837,81 +848,114 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print $searchpicto; print ''; } -print "\n"; +print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref']['checked'])) { print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref_customer']['checked'])) { print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.email']['checked'])) { print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.zip']['checked'])) { print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['state.nom']['checked'])) { print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['typent.code']['checked'])) { print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['sale_representative']['checked'])) { print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.date_contrat']['checked'])) { print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // 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.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.tms']['checked'])) { print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action } if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; // For the column action } print "\n"; +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; $typenArray = array(); $cacheCountryIDCode = array(); - -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } $contracttmp->ref = $obj->ref; $contracttmp->id = $obj->rowid; @@ -938,10 +982,10 @@ while ($i < min($num, $limit)) { $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code']; $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label']; } - //mode kanban + if ($mode == 'kanban') { if ($i == 0) { - print ''; } } else { - print ''; + // Show here line of result + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref if (!empty($arrayfields['c.ref']['checked'])) { @@ -987,11 +1035,17 @@ while ($i < min($num, $limit)) { print ''; print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; @@ -1140,6 +1194,12 @@ while ($i < min($num, $limit)) { print ''; print ''; print ''; + if (!$i) { + $totalarray['nbfield']++; + $totalarray['nbfield']++; + $totalarray['nbfield']++; + $totalarray['nbfield']++; + } } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -1152,12 +1212,12 @@ while ($i < min($num, $limit)) { print ''; } print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - print "\n"; + print ''."\n"; } $i++; } @@ -1179,10 +1239,10 @@ $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print '
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print '
    '; + print '
    '; print '
    '; } @@ -949,12 +993,13 @@ while ($i < min($num, $limit)) { $contracttmp->societe = $socstatic->getNomUrl(); $contracttmp->date_contrat = $obj->date_contrat; print $contracttmp->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print '
    '; print '
    '; @@ -966,6 +1011,9 @@ while ($i < min($num, $limit)) { print ''; } print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').'
    '; -print ''; +print '
    '."\n"; +print ''."\n"; -print ''; +print ''."\n"; $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { @@ -1194,8 +1254,8 @@ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortor $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; -$genallowed = $user->rights->contrat->lire; -$delallowed = $user->rights->contrat->lire; +$genallowed = $permissiontoread; +$delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 338ad79affb..ef4753c7199 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -343,7 +343,7 @@ if ($search_all) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; /* If a group by is required @@ -560,10 +560,10 @@ print ''; +print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -615,7 +615,7 @@ print $hookmanager->resPrint; }*/ // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 82a56264f1c..e298da2d14c 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -729,10 +729,10 @@ print '
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
    '; +print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -820,8 +820,8 @@ if (!empty($arrayfields['u.tms']['checked'])) { } if (!empty($arrayfields['u.statut']['checked'])) { // Status - print ''; } // Action column From 07ef94debfeb7e3c9ddfcb8ec9c476a49a94a7a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:29:48 +0100 Subject: [PATCH 119/217] Fix filter on contract list --- htdocs/projet/list.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index dea5848b469..de44d4a0bfc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -789,8 +789,10 @@ if ($search_date_end_end) { if ($socid) { $param .= '&socid='.urlencode($socid); } -if (!empty($search_categ)) { - $param .= '&search_categ='.urlencode($search_categ); +if (!empty($search_category_array)) { + foreach ($search_category_array as $tmpval) { + $param .= '&search_categegory_project_list[]='.urlencode($tmpval); + } } if ($search_ref != '') { $param .= '&search_ref='.urlencode($search_ref); @@ -819,8 +821,8 @@ if ($search_public != '') { if ($search_project_user > 0) { $param .= '&search_project_user='.urlencode($search_project_user); } -if ($search_project_contact != '') { - $param .= '&search_project_user='.urlencode($search_project_contact); +if ($search_project_contact > 0) { + $param .= '&search_project_contact='.urlencode($search_project_contact); } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); From 7d445ff1bd4fd40032633b7202e5263e1a83199f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:29:56 +0100 Subject: [PATCH 120/217] css --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c35b0c3515f..0007bc334b9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2840,7 +2840,7 @@ class Contrat extends CommonObject $return .= '
    '.$this->societe.''; } if (property_exists($this, 'date_contrat')) { - $return .= '
    '.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat).''; + $return .= '
    '.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat, 'day').''; } if (method_exists($this, 'getLibStatut')) { $return .= '
    '.$this->getLibStatut(5).'
    '; From eaa0e5eb3e83bef4ca87ac2157777dcc3a32f79a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:39:39 +0100 Subject: [PATCH 121/217] CSS --- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/admin/emailcollector_list.php | 2 +- htdocs/admin/modules.php | 2 +- htdocs/bom/bom_list.php | 2 +- htdocs/bookcal/availabilities_list.php | 2 +- htdocs/bookcal/booking_list.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/bank/list.php | 2 +- htdocs/compta/bank/various_payment/list.php | 2 +- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/localtax/list.php | 2 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/prelevement/orders_list.php | 2 +- htdocs/compta/sociales/list.php | 2 +- htdocs/compta/tva/list.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/list.php | 2 +- htdocs/don/list.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/expensereport/list.php | 2 +- htdocs/expensereport/payment/list.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/holiday/list.php | 2 +- htdocs/hrm/evaluation_list.php | 2 +- htdocs/hrm/job_list.php | 2 +- htdocs/hrm/position_list.php | 2 +- htdocs/hrm/skill_list.php | 2 +- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- htdocs/loan/list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/mrp/mo_list.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/projet/tasks/list.php | 2 +- htdocs/recruitment/recruitmentcandidature_list.php | 2 +- htdocs/recruitment/recruitmentjobposition_list.php | 2 +- htdocs/salaries/list.php | 2 +- htdocs/salaries/payments.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/ticket/list.php | 2 +- htdocs/user/group/list.php | 2 +- htdocs/user/list.php | 2 +- htdocs/webhook/target_list.php | 2 +- htdocs/workstation/workstation_list.php | 2 +- 54 files changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7684b175ccb..006c43ba1a1 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1051,7 +1051,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print ''; + print ''; $datem = $db->jdate($obj->dp); print '
    '; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; - print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75imp maxwidth125 onrightofpage'); + print ''; + print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
    '; - print '
    '; + print '
    '; } $membertypestatic->id = $obj->type_id; $membertypestatic->label = $obj->type; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index ef47c347cdf..45fbc99b816 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -532,7 +532,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } //fetch informations needs on this mode diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f7f4394a80f..ce9afa976d6 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -336,7 +336,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } //output kanban $membertype->label = $objp->label; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index de18b57b297..3913d10df56 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -552,7 +552,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 1833df59fd2..9dc1b6e0811 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -759,7 +759,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print load_fiche_titre($familytext, '', '', 0, '', 'modulefamilygroup'); if ($mode == 'commonkanban') { - print '
    '; + print '
    '; } else { print '
    '; print ''."\n"; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index c5e5491dff8..7e2098bb119 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -685,7 +685,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''."\n"; // Line text diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4f64cf4c0aa..9b651fb0049 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4110,7 +4110,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', - 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', + 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', 'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced', 'technic', 'ticket', 'error', 'warning', @@ -4159,8 +4159,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'proposal'=>'file-signature', - 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', - 'recent' => 'question', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', + 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'pictoconfirm'=>'check-square', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', + 'recent' => 'check-square', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'region'=>'map-marked', 'replacement'=>'exchange-alt', 'resource'=>'laptop-house', 'recurring'=>'history', 'service'=>'concierge-bell', diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index e84db5c99dd..ee9eabfa289 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -74,12 +74,12 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { $formquestion = array(); if (!empty($categ_types)) { foreach ($categ_types as $categ_type) { - $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); + $categ_arbo_tmp = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 2); $formquestion[] = array( 'type' => 'other', 'name' => 'affecttag_'.$categ_type['code'], 'label' => '', - 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) + 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $categ_arbo_tmp, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) ); } $formquestion[] = array( From 760135a0bbc682423b40afea2294a6797c06759c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 12:10:59 +0100 Subject: [PATCH 128/217] Look and feel v18 --- htdocs/core/tpl/massactions_pre.tpl.php | 20 ++++++++++++-------- htdocs/langs/en_US/main.lang | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 5124a1dce35..67a2e1ebd01 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -63,15 +63,19 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { if (!empty($categ_types)) { foreach ($categ_types as $categ_type) { $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); - $formquestion[] = array('type' => 'other', - 'name' => 'affecttag_'.$categ_type['code'], - 'label' => $langs->trans("Tag").' '.$categ_type['label'], - 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%')); - } - $formquestion[] = array('type' => 'other', - 'name' => 'affecttag_type', + $formquestion[] = array( + 'type' => 'other', + 'name' => 'affecttag_'.$categ_type['code'], 'label' => '', - 'value' => ''); + 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) + ); + } + $formquestion[] = array( + 'type' => 'other', + 'name' => 'affecttag_type', + 'label' => '', + 'value' => '' + ); print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAffectTag"), $langs->trans("ConfirmAffectTagQuestion", count($toselect)), "affecttag", $formquestion, 1, 0, 200, 500, 1); } else { setEventMessage('CategTypeNotFound'); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a79a5083b69..992eb91b050 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -513,6 +513,7 @@ NotYetAvailable=Not yet available NotAvailable=Not available Categories=Tags/categories Category=Tag/category +SelectTheTagsToAssign=Select the tags/categories to assign By=By From=From FromDate=From From 30c0b5e60e09b32caad6885134c4a618197e4c3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 12:39:00 +0100 Subject: [PATCH 129/217] Debug Look and feel v17 --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/core/tpl/massactions_pre.tpl.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 62fee2bc8ec..e04c0bddf11 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5354,7 +5354,7 @@ class Form // Line title $formconfirm .= ''."\n"; // Line text diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 79e3c3e05c7..7ca4b30e0a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4109,7 +4109,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', - 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', + 'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region', 'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced', 'technic', 'ticket', 'error', 'warning', @@ -4158,8 +4158,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'other'=>'square', 'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'proposal'=>'file-signature', - 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', - 'recent' => 'question', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', + 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'pictoconfirm'=>'check-square', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right', + 'recent' => 'check-square', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'region'=>'map-marked', 'replacement'=>'exchange-alt', 'resource'=>'laptop-house', 'recurring'=>'history', 'service'=>'concierge-bell', diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 67a2e1ebd01..24ec6665d03 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -62,12 +62,12 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { $formquestion = array(); if (!empty($categ_types)) { foreach ($categ_types as $categ_type) { - $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); + $categ_arbo_tmp = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 2); $formquestion[] = array( 'type' => 'other', 'name' => 'affecttag_'.$categ_type['code'], 'label' => '', - 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) + 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $categ_arbo_tmp, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) ); } $formquestion[] = array( From b5ec68a1c3182f02f302e003fe84d2cf9735e98a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 13:05:35 +0100 Subject: [PATCH 130/217] Fix look and feel v17 --- htdocs/comm/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 5d71683a311..8f94f29f7ca 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -868,7 +868,7 @@ if (isModEnabled('contrat') && $user->hasRight("contrat", "lire") && 0) { // TOD print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -971,7 +971,7 @@ if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { print '
    '; - print '
    '; + print '
    '; } // Output kanban print $object->getKanbanView(''); diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index 414faf2dc5a..f111b8df8bf 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -639,7 +639,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index 3c78ffea120..2c5355c2824 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -639,7 +639,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index cc507041ac6..323b9627c34 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1718,7 +1718,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $userstatic->fetch($obj->fk_user_author); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9c06f86e8c3..584926cd87e 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1998,7 +1998,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } print $generic_commande->getKanbanView(''); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2a0995af009..668ada03fdb 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -596,7 +596,7 @@ foreach ($accounts as $key => $type) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $objecttmp->getKanbanView(''); diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index edb770bb4e6..204ea92041f 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -605,7 +605,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 0ae54456735..4b3c9b31322 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -575,7 +575,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $object->posmodule = $obj->posmodule; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 54510bd3fae..23c7d87f87a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1921,7 +1921,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $facturestatic->socid = $companystatic->getNomUrl(1, 'company', 15); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 42f4d326811..23fd1186e0e 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -96,7 +96,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $localtax_static->getKanbanView(''); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 38db4fca14b..794db8df39b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -243,7 +243,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $checkdepositstatic->getKanbanView(''); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 8d9489bbec7..ad8570d9268 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -282,7 +282,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index bead580ab31..c2e8c5e4194 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -236,7 +236,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index a132a3650dc..498a28a54f5 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -614,7 +614,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 0497c05d204..80f73c6fe44 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -489,7 +489,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e6dd6baa1db..4bb325f30ae 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -1234,7 +1234,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $contactstatic->photo = $obj->photo; if ($obj->socid > 0) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index ea072abddf2..560b83175fb 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -986,7 +986,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 819e0ea7931..a895db4f3a6 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -298,7 +298,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $donationstatic->amount = $objp->amount; diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 3bbbe328080..3ad6e2702c0 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -885,7 +885,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 26cafe14b5d..b13db1c159b 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -903,7 +903,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $object->socid = $companystatic->getNomUrl(1); $object->date_delivery = $obj->delivery_date; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 918c916a52c..c093bbfd721 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -750,7 +750,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $usertmp->fetch($obj->id_user); $expensereportstatic->fk_user_author = $usertmp->getNomUrl(1); diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 4c838a73b1e..c236e72d514 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -500,7 +500,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $paymentexpensereportstatic->getKanbanView(''); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 2f704384305..d2b326a6ba4 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -703,7 +703,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 394660f3866..b6e94712e0b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1674,7 +1674,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $thirdpartytmp->id = $obj->socid; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 9b790050571..1aab2dd6a45 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1415,7 +1415,7 @@ if ($num > 0) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $facturestatic->socid = $thirdparty->getNomUrl(1, 'supplier', 3); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 05568e08992..421da582e0d 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -832,7 +832,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index adf642597f2..f39030cf3d5 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -579,7 +579,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $object->date_eval = $obj->date_eval; diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index c980cec9abf..b347c32848c 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -606,7 +606,7 @@ while ($i < $imaxinloop) { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 4518d28bf65..f5740834da7 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -615,7 +615,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // get info needed $object->date_start = $obj->date_start; diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php index 03302a812ff..e9d3564c1a4 100644 --- a/htdocs/hrm/skill_list.php +++ b/htdocs/hrm/skill_list.php @@ -556,7 +556,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 3a916cb96ef..f7e49f0f88c 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -643,7 +643,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index b864c9f09ab..d3eace18a88 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -285,7 +285,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $loan_static->datestart= $obj->datestart; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ef4753c7199..7fa1b718dd9 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -697,7 +697,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index c3ae9247c9d..36dbe6c120a 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -609,7 +609,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $object->id = $obj->type_id; $bom->id = $obj->fk_bom; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index a13fb6f8182..4fc78fdbdde 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -866,7 +866,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 9bd1a202245..15f8e93dd6b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1417,7 +1417,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $product_static->price = $obj->price; // Output Kanban diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 9ab992d537b..56f83c26f03 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -634,7 +634,7 @@ while ($i < min($num, $limit)) { if ($mode =='kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $warehouse->getKanbanView(''); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index bc4c8770f0f..00449a30a17 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -1127,7 +1127,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $object->fk_statut = $projectstatic->getLibStatut(1); diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 95b6ac6203d..8fcd62fc078 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -733,7 +733,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } $recuitment = new RecruitmentJobPosition($db); $recuitment->fetch($obj->fk_recruitmentjobposition); diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 670eca08040..8a0d3f06540 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -591,7 +591,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if ($massactionbutton || $massaction) { diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 24b416295d1..35e82e96da1 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -570,7 +570,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $salstatic->getKanbanView(''); diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 7bf61f3021f..807ae82f9af 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -575,7 +575,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 4ddb23379a9..12de0af0f29 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1561,7 +1561,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $companystatic->getKanbanView(''); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 8683d6db205..7162bc7dd2a 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -984,7 +984,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban $userstatic->fetch($obj->fk_user_author); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index f3e2c82d703..a3caccbef6d 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -1008,7 +1008,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // get infos needed from object $userstatic = new User($db); diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 5f017da01c9..05adcf15059 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -386,7 +386,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index e298da2d14c..981c3744028 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -1009,7 +1009,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban diff --git a/htdocs/webhook/target_list.php b/htdocs/webhook/target_list.php index 1db73639103..a5f01c306f8 100644 --- a/htdocs/webhook/target_list.php +++ b/htdocs/webhook/target_list.php @@ -631,7 +631,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 8639adf866d..91818e2b344 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -629,7 +629,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
    '; - print '
    '; + print '
    '; } // Output Kanban print $object->getKanbanView(''); From 35d496de3876859952774cdb1a280b0ca22519ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:41:53 +0100 Subject: [PATCH 122/217] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 752cbf15c34..3329e4fe71e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2359,7 +2359,7 @@ class User extends CommonObject /** * Send new password by email * - * @param User $user Object user that send the email (not the user we send too) @todo object $user is not used ! + * @param User $user Object user that send the email (not the user we send to) @todo object $user is not used ! * @param string $password New password * @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @todo Add method 2 = Send link to reset password * @return int < 0 si erreur, > 0 si ok From 4ba1309a17d0e3b3012db3857a72ab765fb3c033 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:55:11 +0100 Subject: [PATCH 123/217] Update param_ihm.php --- htdocs/user/param_ihm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index fba8cb0611e..43fb3159df4 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -230,7 +230,7 @@ if (!empty($conf->global->MAIN_USE_BOOKMARKS_FOR_LANDING_PAGES)) { $i = 0; while ($i < $object->db->num_rows($resql)) { $obj = $db->fetch_object($resql); - $landing_url = str_replace(DOL_URL_ROOT,'',$obj->url); + $landing_url = str_replace(DOL_URL_ROOT, '', $obj->url); $tmparray[$landing_url] = $obj->title; $i++; } From b3e54b5ed2767a47be828d1d83244d196e34ebca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 02:58:48 +0100 Subject: [PATCH 124/217] Update param_ihm.php --- htdocs/user/param_ihm.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 43fb3159df4..70eb215cda1 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -219,16 +219,16 @@ if (!empty($conf->global->MAIN_USE_BOOKMARKS_FOR_LANDING_PAGES)) { $sql = "SELECT b.rowid, b.fk_user, b.url, b.title,"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; - $sql .= " WHERE 1=1"; - $sql .= " AND b.entity IN (".getEntity('bookmark').")"; + $sql .= " WHERE b.entity IN (".getEntity('bookmark').")"; $sql .= " AND b.url NOT LIKE 'http%'"; if (!$object->admin) { $sql .= " AND (b.fk_user = ".((int) $object->id)." OR b.fk_user is NULL OR b.fk_user = 0)"; } - $resql = $object->db->query($sql); + $resql = $db->query($sql); if ($resql) { $i = 0; - while ($i < $object->db->num_rows($resql)) { + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { $obj = $db->fetch_object($resql); $landing_url = str_replace(DOL_URL_ROOT, '', $obj->url); $tmparray[$landing_url] = $obj->title; From 7454e6cbf1aa7c1a7350146d3a1a126f49264bbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 03:00:02 +0100 Subject: [PATCH 125/217] Update param_ihm.php --- htdocs/user/param_ihm.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 70eb215cda1..9d42e210ada 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -215,9 +215,8 @@ if (isModEnabled('ticket')) { $tmparray['ticket/list.php?mainmenu=ticket&leftmenu='] = 'Tickets'; } // add bookmarks to available landing pages -if (!empty($conf->global->MAIN_USE_BOOKMARKS_FOR_LANDING_PAGES)) { - $sql = "SELECT b.rowid, b.fk_user, b.url, b.title,"; - +if (empty($conf->global->MAIN_NO_BOOKMARKS_FOR_LANDING_PAGES)) { + $sql = "SELECT b.rowid, b.fk_user, b.url, b.title"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE b.entity IN (".getEntity('bookmark').")"; $sql .= " AND b.url NOT LIKE 'http%'"; From 09b84f08379778c1cc87a0d2d61551227352c21c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 12:10:59 +0100 Subject: [PATCH 126/217] Look and feel v18 --- htdocs/core/tpl/massactions_pre.tpl.php | 20 ++++++++++++-------- htdocs/langs/en_US/main.lang | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 66b681cb3ca..e84db5c99dd 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -75,15 +75,19 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { if (!empty($categ_types)) { foreach ($categ_types as $categ_type) { $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); - $formquestion[] = array('type' => 'other', - 'name' => 'affecttag_'.$categ_type['code'], - 'label' => $langs->trans("Tag").' '.$categ_type['label'], - 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%')); - } - $formquestion[] = array('type' => 'other', - 'name' => 'affecttag_type', + $formquestion[] = array( + 'type' => 'other', + 'name' => 'affecttag_'.$categ_type['code'], 'label' => '', - 'value' => ''); + 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, '', 0, '60%', '', '', $langs->trans("SelectTheTagsToAssign")) + ); + } + $formquestion[] = array( + 'type' => 'other', + 'name' => 'affecttag_type', + 'label' => '', + 'value' => '' + ); print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAffectTag"), $langs->trans("ConfirmAffectTagQuestion", count($toselect)), "affecttag", $formquestion, 1, 0, 200, 500, 1); } else { setEventMessage('CategTypeNotFound'); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 22f04a3ad44..6734168621c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -514,6 +514,7 @@ NotYetAvailable=Not yet available NotAvailable=Not available Categories=Tags/categories Category=Tag/category +SelectTheTagsToAssign=Select the tags/categories to assign By=By From=From FromDate=From From 17b22673974367b5b3aa3230d6c84f454dcf2658 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 12:39:00 +0100 Subject: [PATCH 127/217] Debug Look and feel v17 --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/core/tpl/massactions_pre.tpl.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5ee6efac42f..c47add93207 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5369,7 +5369,7 @@ class Form // Line title $formconfirm .= '
    '; - $formconfirm .= img_picto('', 'recent').' '.$title; + $formconfirm .= img_picto('', 'pictoconfirm').' '.$title; $formconfirm .= '
    '; - $formconfirm .= img_picto('', 'recent').' '.$title; + $formconfirm .= img_picto('', 'pictoconfirm').' '.$title; $formconfirm .= '
    '.$staticcontrat->getNomUrl(1).''.$companystatic->getNomUrl(1, 'customer', 44).''.$companystatic->getNomUrl(1, 'customer').''.$staticcontrat->LibStatut($obj->statut, 3).'
    '; print '
    '.$companystatic->getNomUrl(1, 'customer', 44).''.$companystatic->getNomUrl(1, 'customer').''; print dol_print_date($datem, 'day', 'tzserver'); @@ -1091,7 +1091,7 @@ if (isModEnabled('commande') && $user->rights->commande->lire) { print '
    '; print '
    '.$companystatic->getNomUrl(1, 'customer', 44).''.$companystatic->getNomUrl(1, 'customer').''; print dol_print_date($datem, 'day', 'tzserver'); From 836191648b8595a581b12a420e0cb4d474e5ea3a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 19 Feb 2023 13:35:16 +0100 Subject: [PATCH 131/217] fix php error --- htdocs/adherents/type.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index ce9afa976d6..207acc53e6f 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -42,6 +42,7 @@ $langs->load("members"); $rowid = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); From 56add74e71895008b86bd0130a0a04bb0e0e7f20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 13:58:57 +0100 Subject: [PATCH 132/217] Debug v17 --- htdocs/comm/index.php | 2 +- htdocs/core/lib/project.lib.php | 41 +++++++++++++++++++----- htdocs/fourn/facture/list.php | 56 +++++++++++++++++---------------- htdocs/projet/card.php | 2 +- htdocs/projet/index.php | 3 +- 5 files changed, 65 insertions(+), 39 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8f94f29f7ca..415728cb3e9 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -163,7 +163,7 @@ if (isModEnabled("propal") && $user->hasRight("propal", "lire")) { $obj = $db->fetch_object($resql); if ($i >= $max) { - $othernb += 1; + $othernb++; $i++; $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc); continue; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f144b97e922..cdffc5c1961 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2192,13 +2192,16 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) * @param int $status -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) + * @param int $max Max nb of record to show in HTML list * @return void */ -function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array()) +function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0) { global $langs, $conf, $user; global $theme_datacolor; + $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $listofstatus = array_keys($listofoppstatus); @@ -2229,8 +2232,6 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]); } - $arrayidtypeofcontact = array(); - print ''; print '
    '; print ''; @@ -2309,11 +2310,15 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $resql = $db->query($sql2); if ($resql) { + $othernb = 0; $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; + $total_plannedworkload = 0; + $total_declaredprogressworkload = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); $i = 0; print ''; @@ -2340,11 +2345,23 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } print "\n"; - $total_plannedworkload = 0; - $total_declaredprogressworkload = 0; - while ($i < $num) { + while ($i < $nbofloop) { $objp = $db->fetch_object($resql); + if ($max && $i >= $max) { + $othernb++; + $i++; + $total_task += $objp->nb; + $total_opp_amount += $objp->opp_amount; + $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100; + $ponderated_opp_amount += price2num($opp_weighted_amount); + $plannedworkload = $objp->planned_workload; + $total_plannedworkload += $plannedworkload; + $declaredprogressworkload = $objp->declared_progess_workload; + $total_declaredprogressworkload += $declaredprogressworkload; + continue; + } + $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; @@ -2451,13 +2468,21 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print "\n"; - $total_task = $total_task + $objp->nb; - $total_opp_amount = $total_opp_amount + $objp->opp_amount; + $total_task += $objp->nb; + $total_opp_amount += $objp->opp_amount; } $i++; } + if ($othernb) { + print ''; + print ''; + print "\n"; + } + print ''; print '"; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index be215e891eb..ad03c48258b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1028,17 +1028,17 @@ if (!empty($arrayfields['f.ref_supplier']['checked'])) { if (!empty($arrayfields['f.type']['checked'])) { print ''; @@ -1065,11 +1065,11 @@ if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1543,7 +1543,7 @@ if ($num > 0) { // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1551,8 +1551,8 @@ if ($num > 0) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; @@ -1560,7 +1560,7 @@ if ($num > 0) { } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; if (!$i) { @@ -1569,7 +1569,9 @@ if ($num > 0) { } // State if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1620,14 +1622,14 @@ if ($num > 0) { // Amount HT if (!empty($arrayfields['f.total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; } - $totalarray['val']['f.total_ht'] += $obj->total_ht; + $totalarray['val']['f.total_ht'] += $obj->total_ht; } // Amount VAT if (!empty($arrayfields['f.total_vat']['checked'])) { @@ -1726,7 +1728,7 @@ if ($num > 0) { // Currency if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1734,16 +1736,16 @@ if ($num > 0) { // Currency rate if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } } // Amount HT if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index e954f429781..4f743cc58f7 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1102,7 +1102,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''; print ''; } if (!empty($arrayfields['p.fk_statut']['checked'])) { From c3da1554a7edb6cf59d83ee69b52141b08a1d7ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 16:28:04 +0100 Subject: [PATCH 134/217] Debug v17 --- htdocs/core/actions_massactions.inc.php | 9 ++- htdocs/projet/class/project.class.php | 76 +++++++++++++------------ htdocs/projet/list.php | 1 + 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d5731f014af..3338acd1be4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -958,7 +958,14 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $result = $objecttmp->validate($user); + if (method_exists($objecttmp, 'validate')) { + $result = $objecttmp->validate($user); + } elseif (method_exists($objecttmp, 'setValid')) { + $result = $objecttmp->setValid($user); + } else { + $objecttmp->error = 'No method validate or setValid on this object'; + $result = -1; + } if ($result == 0) { $langs->load("errors"); setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 0d6df2ddc98..5375a418ca2 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1098,7 +1098,7 @@ class Project extends CommonObject * * @param User $user User that validate * @param int $notrigger 1=Disable triggers - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, 0=Nothing done, >0 if KO */ public function setValid($user, $notrigger = 0) { @@ -1106,47 +1106,51 @@ class Project extends CommonObject $error = 0; - if ($this->statut != 1) { - // Check parameters - if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) { - $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); - return -1; + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + // Check parameters + if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) { + $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); + return -1; + } + + $this->db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; + $sql .= " SET fk_statut = ".self::STATUS_VALIDATED; + $sql .= " WHERE rowid = ".((int) $this->id); + $sql .= " AND entity = ".((int) $conf->entity); + + dol_syslog(get_class($this)."::setValid", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + // Call trigger + if (empty($notrigger)) { + $result = $this->call_trigger('PROJECT_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers } - $this->db->begin(); - - $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; - $sql .= " SET fk_statut = 1"; - $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND entity = ".((int) $conf->entity); - - dol_syslog(get_class($this)."::setValid", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - if (empty($notrigger)) { - $result = $this->call_trigger('PROJECT_VALIDATE', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } - - if (!$error) { - $this->statut = 1; - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = join(',', $this->errors); - dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR); - return -1; - } + if (!$error) { + $this->statut = 1; + $this->db->commit(); + return 1; } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); + $this->error = join(',', $this->errors); + dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR); return -1; } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + return -1; } } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index c50350c91cc..15fc35f9e84 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -888,6 +888,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( + 'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), From 2cafd2cbc49268b1995f772ac416aab02a3a38aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 16:42:01 +0100 Subject: [PATCH 135/217] Debug v17 --- .../compta/paiement/cheque/class/remisecheque.class.php | 2 +- htdocs/core/actions_massactions.inc.php | 9 +++++++-- htdocs/don/class/don.class.php | 2 +- htdocs/projet/class/project.class.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 3fb82f05cb9..9895e583601 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -261,7 +261,7 @@ class RemiseCheque extends CommonObject $this->errno = $this->db->lasterrno(); } - if (!$this->errno && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { + if (!$this->errno && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_CHEQUE'))) { $res = $this->validate($user); //if ($res < 0) $error++; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 3338acd1be4..9afd82b7eaf 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -984,8 +984,13 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $objecttmp->thirdparty->default_lang; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp, 'thirdparty')) { + if ((property_exists($objecttmp, 'socid') || property_exists($objecttmp, 'fk_soc')) && empty($objecttmp->thirdparty)) { + $objecttmp->fetch_thirparty(); + } + if (!empty($objecttmp->thirdparty)) { + $newlang = $objecttmp->thirdparty->default_lang; + } } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index ceb5b95c1f3..35c5c5ff40a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -438,7 +438,7 @@ class Don extends CommonObject } } - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { + if (!$error && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_DONATION'))) { //$res = $this->setValid($user); //if ($res < 0) $error++; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 5375a418ca2..d6b0515eb1a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -498,7 +498,7 @@ class Project extends CommonObject } } - if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { + if (!$error && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT'))) { $res = $this->setValid($user); if ($res < 0) { $error++; From 6224414b0d36d1c8fe7e0bbad83848ab78eeab88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 16:55:36 +0100 Subject: [PATCH 136/217] Debug v17 --- htdocs/projet/card.php | 44 +++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 4f743cc58f7..bbecfacdae4 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -99,6 +99,8 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti accessforbidden(); } +$permissiontoadd = $user->rights->projet->creer; +$permissiontodelete = $user->rights->projet->supprimer; $permissiondellink = $user->rights->projet->creer; // Used by the include of actions_dellink.inc.php @@ -152,7 +154,20 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - if ($action == 'add' && $user->rights->projet->creer) { + // Action setdraft object + if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) { + $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'PROJECT_MODIFY'); + if ($result >= 0) { + // Nothing else done + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; + } + + // Action add + if ($action == 'add' && $permissiontoadd) { $error = 0; if (!GETPOST('ref')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); @@ -260,7 +275,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) { + if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) { $error = 0; if (empty($ref)) { @@ -376,7 +391,7 @@ if (empty($reshook)) { } // Build doc - if ($action == 'builddoc' && $user->rights->projet->creer) { + if ($action == 'builddoc' && $permissiontoadd) { // Save last template used to generate document if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model', 'alpha')); @@ -395,7 +410,7 @@ if (empty($reshook)) { } // Delete file in doc form - if ($action == 'remove_file' && $user->rights->projet->creer) { + if ($action == 'remove_file' && $permissiontoadd) { if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -413,28 +428,28 @@ if (empty($reshook)) { } - if ($action == 'confirm_validate' && $confirm == 'yes') { + if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setValid($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_close' && $confirm == 'yes') { + if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setClose($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_reopen' && $confirm == 'yes') { + if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setValid($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { $object->fetch($id); $result = $object->delete($user); if ($result > 0) { @@ -447,7 +462,7 @@ if (empty($reshook)) { } } - if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { + if ($action == 'confirm_clone' && $permissiontoadd && $confirm == 'yes') { $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; @@ -1483,6 +1498,17 @@ if ($action == 'create' && $user->rights->projet->creer) { } */ + // Back to draft + if (!getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') && !getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) { + if ($object->statut != Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($userWrite > 0) { + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_setdraft&confirm=yes&token='.newToken().'&id='.$object->id, ''); + } else { + print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('SetToDraft'), 'default', $_SERVER['PHP_SELF']. '#', '', false); + } + } + } + // Modify if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { From 2b8b389bcfae99bfd31046d9e1de63bbd258545a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 17:00:40 +0100 Subject: [PATCH 137/217] Fix regression --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 9afd82b7eaf..6fe7ab2ac5d 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -986,7 +986,7 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp, 'thirdparty')) { if ((property_exists($objecttmp, 'socid') || property_exists($objecttmp, 'fk_soc')) && empty($objecttmp->thirdparty)) { - $objecttmp->fetch_thirparty(); + $objecttmp->fetch_thirdparty(); } if (!empty($objecttmp->thirdparty)) { $newlang = $objecttmp->thirdparty->default_lang; From 8a283f4de4b5b066e51e79db95dedff49a66bb4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 17:12:13 +0100 Subject: [PATCH 138/217] Fix missing extraparams column --- .../install/mysql/migration/16.0.0-17.0.0.sql | 4 ++ htdocs/install/mysql/tables/llx_commande.sql | 2 +- htdocs/install/mysql/tables/llx_projet.sql | 69 ++++++++++--------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 744c000294b..9d0a5a776d6 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -396,3 +396,7 @@ ALTER TABLE llx_c_tva ADD COLUMN use_default tinyint DEFAULT 0; ALTER TABLE llx_commande_fournisseurdet MODIFY COLUMN ref varchar(128); ALTER TABLE llx_facture_fourn_det MODIFY COLUMN ref varchar(128); + +ALTER TABLE llx_projet ADD COLUMN extraparams varchar(255); + + diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 67712178bd3..e64ce7ff14f 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -77,7 +77,7 @@ create table llx_commande fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms import_key varchar(14), - extraparams varchar(255), -- for stock other parameters with json format + extraparams varchar(255), -- to save other parameters with json format fk_multicurrency integer, multicurrency_code varchar(3), diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 3b8bf1be05b..531f0992f2c 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -19,45 +19,46 @@ create table llx_projet ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_soc integer, - datec datetime, -- date creation project - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - dateo date, -- date start project - datee date, -- date end project - ref varchar(50), - entity integer DEFAULT 1 NOT NULL, -- multi company id - title varchar(255) NOT NULL, - description text, - fk_user_creat integer NOT NULL, -- createur du projet - fk_user_modif integer, - public integer, -- project is public or not - fk_statut integer DEFAULT 0 NOT NULL, -- open or close - fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities - opp_percent double(5,2), - fk_opp_status_end integer DEFAULT NULL, -- if project is used to manage opportunities (the opportunity status the project has when set to lose) - date_close datetime DEFAULT NULL, - fk_user_close integer DEFAULT NULL, - note_private text, - note_public text, - email_msgid varchar(175), -- if project or lead is created by email collector, we store here MSG ID. Do not use a too large value, it generates trouble with unique index - --budget_days real, -- budget in days is sum of field planned_workload of tasks - opp_amount double(24,8), - budget_amount double(24,8), + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_soc integer, + datec datetime, -- date creation project + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + dateo date, -- date start project + datee date, -- date end project + ref varchar(50), + entity integer DEFAULT 1 NOT NULL, -- multi company id + title varchar(255) NOT NULL, + description text, + fk_user_creat integer NOT NULL, -- createur du projet + fk_user_modif integer, + public integer, -- project is public or not + fk_statut integer DEFAULT 0 NOT NULL, -- open or close + fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities + opp_percent double(5,2), + fk_opp_status_end integer DEFAULT NULL, -- if project is used to manage opportunities (the opportunity status the project has when set to lose) + date_close datetime DEFAULT NULL, + fk_user_close integer DEFAULT NULL, + note_private text, + note_public text, + email_msgid varchar(175), -- if project or lead is created by email collector, we store here MSG ID. Do not use a too large value, it generates trouble with unique index + --budget_days real, -- budget in days is sum of field planned_workload of tasks + opp_amount double(24,8), + budget_amount double(24,8), usage_opportunity integer DEFAULT 0, -- Set to 1 if project is used to follow an opportunity usage_task integer DEFAULT 1, -- Set to 1 if project is used to manage tasks and/or record timesheet usage_bill_time integer DEFAULT 0, -- Set to 1 if time spent must be converted into invoices usage_organize_event integer DEFAULT 0, -- Set to 1 if you want to use project to organize an event or receive attendees registration - date_start_event datetime, -- date start event - date_end_event datetime, -- date end event - location varchar(255), -- location + date_start_event datetime, -- date start event + date_end_event datetime, -- date end event + location varchar(255), -- location accept_conference_suggestions integer DEFAULT 0, -- Set to 1 if you want to allow unknown people to suggest conferences - accept_booth_suggestions integer DEFAULT 0, -- Set to 1 if you want to Allow unknown people to suggest booth + accept_booth_suggestions integer DEFAULT 0, -- Set to 1 if you want to Allow unknown people to suggest booth max_attendees integer DEFAULT 0, price_registration double(24,8), - price_booth double(24,8), - model_pdf varchar(255), - ip varchar(250), --ip used to create record (for public submission page) - last_main_doc varchar(255), -- relative filepath+filename of last main generated document - import_key varchar(14) -- Import key + price_booth double(24,8), + model_pdf varchar(255), + ip varchar(250), -- ip used to create record (for public submission page) + last_main_doc varchar(255), -- relative filepath+filename of last main generated document + import_key varchar(14), -- Import key + extraparams varchar(255) -- to save other parameters with json format )ENGINE=innodb; From 9966d605a2c7505dab8e0b3016fb966536be5f94 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 17:20:51 +0100 Subject: [PATCH 139/217] Debug v17 --- htdocs/projet/class/project.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d6b0515eb1a..c4303a73950 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1123,7 +1123,7 @@ class Project extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."projet"; $sql .= " SET fk_statut = ".self::STATUS_VALIDATED; $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND entity = ".((int) $conf->entity); + //$sql .= " AND entity = ".((int) $conf->entity); // Disabled, when we use the ID for the where, we must not add any other search condition dol_syslog(get_class($this)."::setValid", LOG_DEBUG); $resql = $this->db->query($sql); From 230c3d2752c7190325b99bcfdad882a1b3e9702c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 18:11:41 +0100 Subject: [PATCH 140/217] Debug v17 --- htdocs/bookmarks/bookmarks.lib.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 88cae3e4293..4141aa671a0 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -102,6 +102,7 @@ function printDropdownBookmarksList() $listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').''; $bookmarkList = ''; + $bookmarkNb = 0; // Menu with list of bookmarks $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; @@ -116,6 +117,7 @@ function printDropdownBookmarksList() $bookmarkList .= dol_escape_htmltag($obj->title); $bookmarkList .= ''; $i++; + $bookmarkNb++; } $bookmarkList .= ''; @@ -141,6 +143,7 @@ function printDropdownBookmarksList() $searchForm .= dol_escape_htmltag($obj->title); $searchForm .= ''; $i++; + $bookmarkNb++; } $searchForm .= ''; } @@ -200,13 +203,15 @@ function printDropdownBookmarksList() '; - $html .= ' - - - '; + if ($bookmarkNb) { + $html .= ' + + + '; + } $html .= ' '; -print '
    '; + print ''.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').''; + print '
    '.$langs->trans("Total")."'; $listtype = array( - FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), - FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), - FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); /* - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); - } - */ + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); + } + */ //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print ''; print '
    '; /* - print $langs->trans('From').' '; - print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1); - print '
    '; - print '
    '; - print $langs->trans('to').' ';*/ + print $langs->trans('From').' '; + print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1); + print '
    '; + print '
    '; + print $langs->trans('to').' ';*/ print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before")); print '
    '.$langs->trans("Alert"); print '
    '; @@ -1487,7 +1487,7 @@ if ($num > 0) { // Label if (!empty($arrayfields['f.label']['checked'])) { print '
    '; - print $obj->label; + print dol_escape_htmltag($obj->label); print ''; - print $thirdparty->name_alias; + print dol_escape_htmltag($thirdparty->name_alias); print ''; - print $obj->town; + print ''; + print dol_escape_htmltag($obj->town); print ''; + print ''; print dol_escape_htmltag($obj->zip); print '".$obj->state_name."'; + print dol_escape_htmltag($obj->state_name); + print "'.price($obj->total_ht)."'.price($obj->total_ht)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_ht)."
    '.$langs->trans("OpportunityStatus").''; print '
    '; - print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 1, 1); + print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1); // Opportunity probability print ' %'; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 2698a4b1a21..27885de31b9 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -193,9 +193,8 @@ print '
    '; */ include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php'; - // List of draft projects -print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress', 'prospectionstatus', 'projectstatus')); +print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress', 'prospectionstatus', 'projectstatus'), $max); print '
    '; From 93927cceff72b02fab0ed468346e45b901601cd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Feb 2023 16:12:28 +0100 Subject: [PATCH 133/217] Debug v17 --- htdocs/core/lib/functions.lib.php | 86 +++++++++++++++++++++---------- htdocs/projet/list.php | 71 ++++++++++++++++--------- 2 files changed, 106 insertions(+), 51 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7ca4b30e0a0..0664bae3f58 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -784,6 +784,12 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } } } else { + // If field name is 'search_xxx' then we force the add of space after each < and > (when following char is numeric) because it means + // we use the < or > to make a search on a numeric value to do higher or lower so we can add a space to break html tags + if (strpos($paramname, 'search_') === 0) { + $out = preg_replace('/([<>])([-+]?\d)/', '\1 \2', $out); + } + $out = sanitizeVal($out, $check, $filter, $options); } @@ -9751,7 +9757,7 @@ function dol_getmypid() * If param $mode is 0, can contains several keywords separated with a space or | * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 - * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" + * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < -1000" * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') @@ -9789,23 +9795,35 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $newres = ''; foreach ($fields as $field) { if ($mode == 1) { - $operator = '='; - $newcrit = preg_replace('/([!<>=]+)/', '', $crit); - - $reg = array(); - preg_match('/([!<>=]+)/', $crit, $reg); - if (!empty($reg[1])) { - $operator = $reg[1]; - } - if ($newcrit != '') { - $numnewcrit = price2num($newcrit); - if (is_numeric($numnewcrit)) { - $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric - } else { - $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false + $tmpcrits = explode('|', $crit); + $i3 = 0; // count the nb of valid criteria added for this field + foreach ($tmpcrits as $tmpcrit) { + if ($tmpcrit !== '0' && empty($tmpcrit)) { + continue; + } + $tmpcrit = trim($tmpcrit); + + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + + $operator = '='; + $newcrit = preg_replace('/([!<>=]+)/', '', $tmpcrit); + + $reg = array(); + preg_match('/([!<>=]+)/', $tmpcrit, $reg); + if (!empty($reg[1])) { + $operator = $reg[1]; + } + if ($newcrit != '') { + $numnewcrit = price2num($newcrit); + if (is_numeric($numnewcrit)) { + $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric + } else { + $newres .= '1 = 2'; // force false, we received a corrupted data + } + $i3++; // a criteria was added to string } - $i2++; // a criteria was added to string } + $i2++; } elseif ($mode == 2 || $mode == -2) { $crit = preg_replace('/[^0-9,]/', '', $crit); // ID are always integer $newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -2 ? 'NOT ' : ''); @@ -9847,28 +9865,36 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } } } - } else // $mode=0 - { + } else { // $mode=0 $tmpcrits = explode('|', $crit); - $i3 = 0; + $i3 = 0; // count the nb of valid criteria added for this field foreach ($tmpcrits as $tmpcrit) { if ($tmpcrit !== '0' && empty($tmpcrit)) { continue; } + $tmpcrit = trim($tmpcrit); - $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + if ($tmpcrit == '^$') { // If we search empty, we must combined different fields with AND + $newres .= (($i2 > 0 || $i3 > 0) ? ' AND ' : ''); + } else { + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + } if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field - $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? ((float) trim($tmpcrit)) : '0'); + $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0'); } else { - $tmpcrit = trim($tmpcrit); $tmpcrit2 = $tmpcrit; $tmpbefore = '%'; $tmpafter = '%'; + $tmps = ''; + if (preg_match('/^!/', $tmpcrit)) { - $newres .= $field." NOT LIKE '"; // ! as exclude character + $tmps .= $field." NOT LIKE "; // ! as exclude character $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2); - } else $newres .= $field." LIKE '"; + } else { + $tmps .= $field." LIKE "; + } + $tmps .= "'"; if (preg_match('/^[\^\$]/', $tmpcrit)) { $tmpbefore = ''; @@ -9878,12 +9904,17 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $tmpafter = ''; $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); } + + if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) { + $tmps = "(".$tmps; + } + $newres .= $tmps; $newres .= $tmpbefore; $newres .= $db->escape($tmpcrit2); $newres .= $tmpafter; $newres .= "'"; - if ($tmpcrit2 == '') { - $newres .= " OR ".$field." IS NULL"; + if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) { + $newres .= " OR ".$field." IS NULL)"; } } @@ -9893,13 +9924,14 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } $i++; } + if ($newres) { $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : ''); } $j++; } $res = ($nofirstand ? "" : " AND ")."(".$res.")"; - //print 'xx'.$res.'yy'; + return $res; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index dea5848b469..c50350c91cc 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -54,6 +54,7 @@ $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); +$optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist'; $title = $langs->trans("Projects"); @@ -113,6 +114,7 @@ $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'i $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); $search_login = GETPOST('search_login', 'alpha'); +$search_import_key = GETPOST('search_import_key', 'alpha'); $searchCategoryCustomerOperator = 0; if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int'); @@ -120,7 +122,7 @@ if (GETPOSTISSET('formfilteraction')) { $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; } $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array'); -$optioncss = GETPOST('optioncss', 'alpha'); + $mine = ((GETPOST('mode') == 'mine') ? 1 : 0); if ($mine) { @@ -134,7 +136,6 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); - $search_date_start_startmonth = GETPOST('search_date_start_startmonth', 'int'); $search_date_start_startyear = GETPOST('search_date_start_startyear', 'int'); $search_date_start_startday = GETPOST('search_date_start_startday', 'int'); @@ -152,6 +153,7 @@ $search_date_end_endmonth = GETPOST('search_date_end_endmonth', 'int'); $search_date_end_endyear = GETPOST('search_date_end_endyear', 'int'); $search_date_end_endday = GETPOST('search_date_end_endday', 'int'); $search_date_end_end = dol_mktime(23, 59, 59, $search_date_end_endmonth, $search_date_end_endday, $search_date_end_endyear); // Use tzserver + if (isModEnabled('categorie')) { $search_category_array = GETPOST("search_category_".Categorie::TYPE_PROJECT."_list", "array"); } @@ -301,6 +303,7 @@ if (empty($reshook)) { $search_price_registration = ''; $search_price_booth = ''; $search_login = ''; + $search_import_key = ''; $toselect = array(); $search_array_options = array(); $search_category_array = array(); @@ -368,6 +371,8 @@ if (empty($reshook)) { $form = new Form($db); $formcompany = new FormCompany($db); +$now = dol_now(); + $companystatic = new Societe($db); $taskstatic = new Task($db); $formother = new FormOther($db); @@ -415,7 +420,7 @@ if (count($listofprojectcontacttypeexternal) == 0) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. +$distinct = 'DISTINCT'; // We add distinct until we have added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat,"; $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,"; $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,"; @@ -436,6 +441,9 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as p"; if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; @@ -546,9 +554,11 @@ if ($search_sale > 0) { // No check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))"; if ($search_project_user > 0) { + // TODO Replace this with a EXISTS and remove the link to table + DISTINCT $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user); } if ($search_project_contact > 0) { + // TODO Replace this with a EXISTS and remove the link to table + DISTINCT $sql .= " AND ecp_contact.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttypeexternal))).") AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = ".((int) $search_project_contact); } if ($search_opp_amount != '') { @@ -584,6 +594,9 @@ if ($search_price_booth != '') { if ($search_login) { $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login); } +if ($search_import_key) { + $sql .= natural_search(array('p.import_key'), $search_import_key); +} // Search for tag/category ($searchCategoryProjectList is an array of ID) $searchCategoryProjectList = $search_category_array; $searchCategoryProjectOperator = 0; @@ -664,37 +677,45 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); +//print $sql; // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if (!empty($limit)) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id); exit; @@ -704,8 +725,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -dol_syslog("list allowed project", LOG_DEBUG); - llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -855,6 +874,9 @@ if ($search_price_booth != '') { if ($search_login) { $param .= '&search_login='.urlencode($search_login); } +if ($search_import_key) { + $param .= '&search_import_key='.urlencode($search_import_key); +} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -1186,6 +1208,7 @@ if (!empty($arrayfields['p.email_msgid']['checked'])) { if (!empty($arrayfields['p.import_key']['checked'])) { // Import key print '
    '; + print ''; print '
    '."\n"; - // Type -/* -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - $listoftype = $partnershipt->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; -} else { - $partnershipt->fetch($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE); - print ''; -} -*/ - $partnershiptype = new PartnershipType($db); $listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000, 0, array('active'=>1)); $listofpartnership = array(); @@ -608,15 +587,17 @@ foreach ($listofpartnershipobj as $partnershipobj) { $listofpartnership[$partnershipobj->id] = $partnershipobj->label; } -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - print ''."\n"; -} else { +if (getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) { print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE]; print ''; } +print '
    '.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $partnershipt->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
    '.$langs->trans('PartnershipType').' *'."\n"; - print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1); - print '
    '."\n"; +if (!getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) { + print ''."\n"; +} // Company print ''."\n"; // Other attributes -$tpl_context = 'public'; // define template context to public +$parameters['tdclass']='titlefield'; +$parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index d4d6b4b68b5..50759aeede9 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -537,7 +537,7 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { } // Other attributes -$tpl_context = 'public'; // define template context to public +$parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; From 8f33945a0b5ef6825dc5bd748df9b24503647707 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 10:37:15 +0100 Subject: [PATCH 190/217] CSS --- htdocs/public/partnership/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 2884c7099c3..c06843a64a8 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -651,7 +651,7 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { // Logo //print ''."\n"; // Other attributes -$parameters['tdclass']='titlefield'; +$parameters['tdclass']='titlefieldauto'; $parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments From 6f869be8c039a309b764e576213d9a02269be7b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 10:41:47 +0100 Subject: [PATCH 191/217] Fix lang --- htdocs/langs/en_US/partnership.lang | 2 +- htdocs/langs/fr_FR/partnership.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 89a1bfa742d..f4ea73a1a8f 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -29,7 +29,7 @@ PartnershipCheckBacklink=Partnership: Check referring backlink # Menu # NewPartnership=New Partnership -NewPartnershipbyWeb= Your partnership was added successfully. +NewPartnershipbyWeb=Your partnership request has been added successfully. We may contact you soon... ListOfPartnerships=List of partnership # diff --git a/htdocs/langs/fr_FR/partnership.lang b/htdocs/langs/fr_FR/partnership.lang index 20c3fc0d801..b12f139abc9 100644 --- a/htdocs/langs/fr_FR/partnership.lang +++ b/htdocs/langs/fr_FR/partnership.lang @@ -29,7 +29,7 @@ PartnershipCheckBacklink=Partenariat : Vérifiez le backlink référent # Menu # NewPartnership=Nouveau partenariat -NewPartnershipbyWeb= Votre partenariat a été ajouté avec succès. +NewPartnershipbyWeb=Votre demande de partenariat a été ajouté avec succès. Nous vous recontacterons surement d'ici peu... ListOfPartnerships=Listes des partenariats # From 5477ec9800ee53f6597c32de27d883a37ced7de7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 10:50:29 +0100 Subject: [PATCH 192/217] Style --- htdocs/public/members/new.php | 2 +- htdocs/public/partnership/new.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index e03ecfb0fda..2c6b7b4c9c5 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -497,7 +497,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // fetch optio llxHeaderVierge($langs->trans("NewSubscription")); - +print '
    '; print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index c06843a64a8..dea912e0653 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -537,7 +537,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // fetch optio llxHeaderVierge($langs->trans("NewPartnershipRequest")); - +print '
    '; print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center'); From 3a561d78b9d6e8606917e7100cbd7cc690438217 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 10:59:04 +0100 Subject: [PATCH 193/217] css --- htdocs/partnership/class/partnership.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 3e16b4bf4e8..fab8b1ce32a 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -104,7 +104,8 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), - 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1,), + 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax100'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax125',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -121,7 +122,6 @@ class Partnership extends CommonObject 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150',), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), ); public $rowid; From a64c41c4ba54dbfddb680e4f5e466410e5a22905 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 12:14:34 +0100 Subject: [PATCH 194/217] Fix due date for supplier invoice not correctly set on clone --- htdocs/core/class/commoninvoice.class.php | 5 ++++- htdocs/fourn/class/fournisseur.facture.class.php | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7818ab2fb11..a3b0810efc6 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -663,7 +663,7 @@ abstract class CommonInvoice extends CommonObject * conditions and billing date. * * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. - * @return integer Date limite de reglement si ok, <0 si ko + * @return integer Date limit of payment if OK, <0 if KO */ public function calculate_date_lim_reglement($cond_reglement = 0) { @@ -674,6 +674,9 @@ abstract class CommonInvoice extends CommonObject if (!$cond_reglement) { $cond_reglement = $this->cond_reglement_id; } + if (!$cond_reglement) { + return $this->date; + } $cdr_nbjour = 0; $cdr_type = 0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2e766fb5cdc..bc0c7b9e232 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3069,16 +3069,17 @@ class FactureFournisseur extends CommonInvoice $object->fk_facture_source = 0; $object->date_creation = ''; $object->date_validation = ''; - $object->date = (empty($this->date) ? '' : $this->date); - $object->date_echeance = ''; + $object->date = (empty($this->date) ? dol_now() : $this->date); $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { + if (getDolGlobalInt('MAIN_DONT_KEEP_NOTE_ON_CLONING') == 1) { $object->note_private = ''; $object->note_public = ''; } + $object->date_echeance = $object->calculate_date_lim_reglement(); + // Loop on each line of new invoice foreach ($object->lines as $i => $line) { if (isset($object->lines[$i]->info_bits) && ($object->lines[$i]->info_bits & 0x02) == 0x02) { // We do not clone line of discounts From ba70262f0459b244bbb3ab35fdeb27d8520ee665 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 12:37:03 +0100 Subject: [PATCH 195/217] Fix qodana warnings --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/core/tpl/massactions_pre.tpl.php | 2 +- htdocs/modulebuilder/index.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 0611e6fe003..2aed109ce26 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1006,7 +1006,7 @@ if (empty($reshook)) { $newcardbutton .= ''.$langs->trans("ClickToHideAlreadyExportedLines").''; $newcardbutton .= ''; } else { - $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"').''; + $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"'); $newcardbutton .= ''.$langs->trans("DocsAlreadyExportedAreExcluded").''; $newcardbutton .= ''; } diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index ee9eabfa289..ce36d2bb899 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -49,7 +49,7 @@ if ($massaction == 'preclonetasks') { $formquestion = array( array('type' => 'other', 'name' => 'projectid', 'label' => $langs->trans('Project') .': ', 'value' => $form->selectProjects('', 'projectid', '', '', '', '', '', '', '', 1, 1)), ); - print $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . $selected . '', $langs->trans('ConfirmMassClone'), '', 'clonetasks', $formquestion, '', 1, 300, 590); + print $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . $selected, $langs->trans('ConfirmMassClone'), '', 'clonetasks', $formquestion, '', 1, 300, 590); } if ($massaction == 'preaffecttag' && isModEnabled('category')) { diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d2fc01ddead..582fddd83df 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1852,7 +1852,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { \$r++; "; - $deleteright = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '', $rights => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => ''."\n\t\t")); + $deleteright = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '', $rights => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => "\n\t\t")); if ($deleteright > 0) { if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); @@ -2218,7 +2218,7 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => ''."\n\t\t")); + $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => "\n\t\t")); if ($check > 0) { //check if all permissions of object was deleted $permsForObj = array(); From d2d6f3974d67b57d6014f9d5f17228db66527673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 12:38:23 +0100 Subject: [PATCH 196/217] Fix qodana warnings --- htdocs/adherents/list.php | 2 +- htdocs/core/lib/project.lib.php | 4 ++-- htdocs/mrp/class/mo.class.php | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 006c43ba1a1..b44abce662d 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -325,7 +325,7 @@ $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); // Page Header -$title = $langs->trans("Members")." - ".$langs->trans("List");; +$title = $langs->trans("Members")." - ".$langs->trans("List"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $title, $help_url); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 48ed501e125..8aa8b6d93b7 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2874,13 +2874,13 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide // good $out .= '
    '; if (!empty($task->progress)) { - $out .= '
    '; + $out .= '
    '; } $out .= '
    '; } else { // bad $out .= '
    '; - $out .= '
    '; + $out .= '
    '; $out .= '
    '; } $out .= ' '; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 452a87b6ab8..64156ca9b37 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -231,10 +231,6 @@ class Mo extends CommonObject */ public $line = array(); - /** - * @var integer Mo parent line - * */ - /** * @var int ID of parent line */ From 44da230012a059395dca02cde614e0f9c3307717 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 12:57:36 +0100 Subject: [PATCH 197/217] Clean code --- htdocs/admin/system/perf.php | 6 +++--- htdocs/admin/system/security.php | 6 +++--- htdocs/admin/tools/purge.php | 6 +++--- htdocs/core/class/conf.class.php | 10 +++++++--- htdocs/core/class/utils.class.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/install/inc.php | 6 ++++++ htdocs/support/inc.php | 4 +++- 8 files changed, 27 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index cc9ab7658db..fd586e24c95 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -82,14 +82,14 @@ print '
    '; // Module log print '
    '; print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 4515e4b7c2a..5775ea5404e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -453,14 +453,14 @@ print load_fiche_titre($langs->trans("Modules"), '', 'folder'); // Module log print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index ee95fd7b44e..6c771abbd32 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -38,8 +38,8 @@ $nbsecondsold = GETPOSTINT('nbsecondsold'); // Define filelog to discard it from purge $filelog = ''; -if (!empty($conf->syslog->enabled)) { - $filelog = $conf->global->SYSLOG_FILE; +if (isModEnabled('syslog')) { + $filelog = getDolGlobalString('SYSLOG_FILE'); $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } @@ -96,7 +96,7 @@ print '
    '.$langs->trans('PartnershipType').' *'."\n"; + print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1); + print '
    '.$langs->trans("Company").' *'; print img_picto('', 'company', 'class="pictofixedwidth"'); @@ -670,7 +651,8 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { // Logo //print '
    '.$langs->trans("URLPhoto").'
    '.$langs->trans("URLPhoto").'
    '; print '\n"; print '';*/ - if (!$conf->expedition_bon->enabled && isModEnabled('stock')) { + if (!isModEnabled('expedition_bon') && isModEnabled('stock')) { // Entrepot $entrepot = new Entrepot($db); $entrepot->fetch($object->entrepot_id); @@ -647,7 +647,7 @@ if ($action == 'create') { } if ($user->rights->expedition->delivery->supprimer) { - if ($conf->expedition_bon->enabled) { + if (isModEnabled('expedition_bon')) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&expid='.$object->origin_id.'&action=delete&token='.newToken().'&backtopage='.urlencode(DOL_URL_ROOT.'/expedition/card.php?id='.$object->origin_id), ''); } else { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index bb0d8ac162d..9a11302e5bd 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -201,7 +201,7 @@ class Delivery extends CommonObject dol_syslog("Delivery::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (!$conf->expedition_bon->enabled) { + if (!isModEnabled('expedition_bon')) { $commande = new Commande($this->db); $commande->id = $this->commande_id; $commande->fetch_lines(); @@ -229,7 +229,7 @@ class Delivery extends CommonObject $error++; } - if (!$conf->expedition_bon->enabled) { + if (!isModEnabled('expedition_bon')) { // TODO standardize status uniformiser les statuts $ret = $this->setStatut(2, $this->origin_id, $this->origin); if (!$ret) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 30c23781757..1649a161034 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -617,7 +617,7 @@ if (empty($reshook)) { $result = $object->create($user); - if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email) && $object->no_email == 1) { + if (empty($error) && isModEnabled('mailing') && !empty($object->email) && $object->no_email == 1) { // Add mass emailing flag into table mailing_unsubscribe $result = $object->setNoEmail($object->no_email); if ($result < 0) { @@ -1633,7 +1633,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; // Unsubscribe - if (!empty($conf->mailing->enabled)) { + if (isModEnabled('mailing')) { if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) { print "\n".'
    '; -if (!empty($conf->syslog->enabled)) { +if (isModEnabled('syslog')) { print 'syslog = new stdClass(); $this->multicompany = new stdClass(); $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); @@ -212,7 +217,6 @@ class Conf // First level object // TODO Remove this part. - $this->syslog = new stdClass(); $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); @@ -1018,7 +1022,7 @@ class Conf } } - if (!empty($this->syslog->enabled)) { + if (isModEnabled('syslog')) { // We init log handlers if (!empty($this->global->SYSLOG_HANDLERS)) { $handlers = json_decode($this->global->SYSLOG_HANDLERS); diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index be91b49765b..f67702ca7c9 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -121,7 +121,7 @@ class Utils $filesarray = dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } - if (!empty($conf->syslog->enabled)) { + if (isModEnabled('syslog')) { $filelog = $conf->global->SYSLOG_FILE; $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c6abf0e5b87..4345c936432 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1641,7 +1641,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = global $conf, $user, $debugbar; // If syslog module enabled - if (empty($conf->syslog->enabled)) { + if (!isModEnabled('syslog')) { return; } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 970fd40261b..9dc12b18277 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -232,6 +232,9 @@ if ($islocked) { // Pages are locked // Force usage of log file for install and upgrades +if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); +} $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { @@ -341,6 +344,9 @@ function conf($dolibarr_main_document_root) $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Force usage of log file for install and upgrades + if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); + } $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index 3f372e97c1e..1c8c4c5d7f8 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -39,7 +39,9 @@ $conf = new stdClass(); // instantiate $conf explicitely $conf->global = new stdClass(); $conf->file = new stdClass(); $conf->db = new stdClass(); -$conf->syslog = new stdClass(); +if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); +} // Force $_REQUEST["logtohtml"] $_REQUEST["logtohtml"] = 1; From ce7c54c570778cd7b048ed5b65fe5ea24e15b83e Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 21 Feb 2023 13:10:13 +0100 Subject: [PATCH 198/217] fix incoherence on permissions --- htdocs/modulebuilder/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d2fc01ddead..89dfc8694e3 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1262,6 +1262,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { \$this->rights[\$r][5] = 'delete'; \$r++; "; + $moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php'; dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); } } @@ -2036,7 +2037,7 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { // if not found permission for the object if (!in_array($objectForPerms, array_unique($allObject))) { $firstRight++; - $existRight = 0; + $existRight++; } if (!$error) { if (isModEnabled(strtolower($module))) { @@ -2058,11 +2059,10 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; if (!$existRight) { - //var_dump(1);exit; dolReplaceInFile($moduledescriptorfile, array('/*END '.strtoupper($objectForPerms).'*/' => $rightToAdd.'/*END '.strtoupper($objectForPerms).'*/')); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } - if ($firstRight) { + if ($firstRight>0) { dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } @@ -4720,8 +4720,8 @@ if ($module == 'initmodule') { print '
    '; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; From b0cf8cd72dfc09578b542671bc2126a76bf9e173 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Feb 2023 13:19:57 +0100 Subject: [PATCH 199/217] Clean code --- htdocs/core/class/conf.class.php | 38 ++++++++++++---------- htdocs/core/lib/propal.lib.php | 4 +-- htdocs/core/lib/sendings.lib.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 6 ++-- htdocs/delivery/card.php | 6 ++-- htdocs/delivery/class/delivery.class.php | 4 +-- htdocs/societe/card.php | 8 ++--- scripts/emailings/mailing-send.php | 5 +++ scripts/emailings/reset-invalid-emails.php | 5 +++ 9 files changed, 46 insertions(+), 32 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 66e0fc07014..12457a41339 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -51,6 +51,12 @@ class Conf public $mycompany; public $admin; public $medias; + //! To store properties of multi-company + public $multicompany; + + //! To store module status of special module names + public $expedition_bon; + public $delivery_note; //! To store if javascript/ajax is enabked @@ -84,8 +90,6 @@ class Conf */ public $loghandlers = array(); - //! To store properties of multi-company - public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -148,8 +152,6 @@ class Conf // First level object that are modules. // TODO Remove this part. $this->multicompany = new stdClass(); - $this->expedition_bon = new stdClass(); - $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -164,7 +166,6 @@ class Conf $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); - $this->mailing = new stdClass(); $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); } @@ -217,8 +218,6 @@ class Conf // First level object // TODO Remove this part. - $this->expedition_bon = new stdClass(); - $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -233,7 +232,6 @@ class Conf $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); - $this->mailing = new stdClass(); $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); @@ -503,8 +501,10 @@ class Conf // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition + $this->expedition_bon = new stdClass(); $this->expedition_bon->enabled = (empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? 0 : $this->global->MAIN_SUBMODULE_EXPEDITION); // Sub module delivery note Sous module bons de livraison + $this->delivery_note = new stdClass(); $this->delivery_note->enabled = (empty($this->global->MAIN_SUBMODULE_DELIVERY) ? 0 : $this->global->MAIN_SUBMODULE_DELIVERY); // Module fournisseur @@ -705,22 +705,26 @@ class Conf $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/".$this->theme."/style.css.php"; - // conf->email_from = email pour envoi par dolibarr des mails automatiques + // conf->email_from = email by default to send Dolibarr automatic emails $this->email_from = "robot@example.com"; if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) { $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; } - // conf->notification->email_from = email pour envoi par Dolibarr des notifications - $this->notification->email_from = $this->email_from; - if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) { - $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM; + // conf->notification->email_from = email by default to send Dolibarr notifications + if (isModEnabled('notification')) { + $this->notification->email_from = $this->email_from; + if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) { + $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM; + } } - // conf->mailing->email_from = email pour envoi par Dolibarr des mailings - $this->mailing->email_from = $this->email_from; - if (!empty($this->global->MAILING_EMAIL_FROM)) { - $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; + // conf->mailing->email_from = email by default to send Dolibarr emailings + if (isModEnabled('mailing')) { + $this->mailing->email_from = $this->email_from; + if (!empty($this->global->MAILING_EMAIL_FROM)) { + $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; + } } if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) { diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 3d380a3904a..b5e459c8637 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -47,10 +47,10 @@ function propal_prepare_head($object) $langs->load("sendings"); $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; - if ($conf->expedition_bon->enabled) { + if (isModEnabled('expedition_bon')) { $text = $langs->trans("Shipment"); } - if ($conf->delivery_note->enabled) { + if (isModEnabled('delivery_note')) { $text .= '/'.$langs->trans("Receivings"); } $head[$h][1] = $text; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index a2fbaeef92e..4013c6d41e9 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -133,7 +133,7 @@ function delivery_prepare_head($object) $h = 0; $head = array(); - if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) { + if (isModEnabled('expedition_bon') && $user->rights->expedition->lire) { $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; $head[$h][1] = $langs->trans("SendingCard"); $head[$h][2] = 'shipping'; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 5c819488971..417744bc49d 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -437,9 +437,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Tools insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($user->socid)', __HANDLER__, 'left', 3900__+MAX_llx_menu__, 'tools', 'email_templates', 8__+MAX_llx_menu__, '/admin/mails_templates.php?mainmenu=tools&leftmenu=email_templates', 'EMailTemplates', 0, '', '', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3910__+MAX_llx_menu__, 'tools', 'mailing', 8__+MAX_llx_menu__, '/comm/mailing/index.php?mainmenu=tools&leftmenu=mailing', 'EMailings', 0, 'mails', '$user->rights->mailing->lire', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3911__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/card.php?mainmenu=tools&leftmenu=mailing&action=create', 'NewMailing', 1, 'mails', '$user->rights->mailing->creer', '', 0, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3912__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/list.php?mainmenu=tools&leftmenu=mailing', 'List', 1, 'mails', '$user->rights->mailing->lire', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("mailing")', __HANDLER__, 'left', 3910__+MAX_llx_menu__, 'tools', 'mailing', 8__+MAX_llx_menu__, '/comm/mailing/index.php?mainmenu=tools&leftmenu=mailing', 'EMailings', 0, 'mails', '$user->rights->mailing->lire', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("mailing")', __HANDLER__, 'left', 3911__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/card.php?mainmenu=tools&leftmenu=mailing&action=create', 'NewMailing', 1, 'mails', '$user->rights->mailing->creer', '', 0, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("mailing")', __HANDLER__, 'left', 3912__+MAX_llx_menu__, 'tools', '', 3910__+MAX_llx_menu__, '/comm/mailing/list.php?mainmenu=tools&leftmenu=mailing', 'List', 1, 'mails', '$user->rights->mailing->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->export->enabled', __HANDLER__, 'left', 4100__+MAX_llx_menu__, 'tools', 'export', 8__+MAX_llx_menu__, '/exports/index.php?mainmenu=tools&leftmenu=export', 'FormatedExport', 0, 'exports', '$user->rights->export->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->export->enabled', __HANDLER__, 'left', 4101__+MAX_llx_menu__, 'tools', '', 4100__+MAX_llx_menu__, '/exports/export.php?mainmenu=tools&leftmenu=export', 'NewExport', 1, 'exports', '$user->rights->export->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->import->enabled', __HANDLER__, 'left', 4130__+MAX_llx_menu__, 'tools', 'import', 8__+MAX_llx_menu__, '/imports/index.php?mainmenu=tools&leftmenu=import', 'FormatedImport', 0, 'exports', '$user->rights->import->run', '', 2, 2, __ENTITY__); diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index c1b27af2ce0..ea345efadcb 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -104,7 +104,7 @@ if ($action == 'add') { $object->commande_id = GETPOST("commande_id", 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - if (!$conf->expedition_bon->enabled && isModEnabled('stock')) { + if (!isModEnabled('expedition_bon') && isModEnabled('stock')) { $expedition->entrepot_id = GETPOST('entrepot_id', 'int'); } @@ -479,7 +479,7 @@ if ($action == 'create') { print '
    '.$object->getLibStatut(4)."
    '.img_picto('', 'globe', 'class="pictofixedwidth"').'