diff --git a/ChangeLog b/ChangeLog index 32270994e3b..9f275d641ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -72,7 +72,7 @@ FIX: #yogosha21416 For users: ---------- -NEW: Compatibility with PHP 8.2 +NEW: Compatibility with PHP 8.2 (warning must be disabled) NEW: Module Workstation (used to enhance the module BOM and Manufacturing Order) is now stable NEW: Add a confirmation popup when deleting extrafields NEW: Add type 'icon' type for extrafields diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index fb9a61e36d0..38e672e132d 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -128,6 +128,7 @@ $form = new Form($db); // Page Header $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration'; $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); + llxHeader('', $title, $help_url); @@ -300,14 +301,17 @@ if ($resql) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.((int) $limit); } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } if ($search_subaccount) { $param .= '&search_subaccount='.urlencode($search_subaccount); } if ($search_label) { $param .= '&search_label='.urlencode($search_label); } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); + if ($search_type) { + $param .= '&search_type='.urlencode($search_type); } // List of mass actions available @@ -373,7 +377,7 @@ if ($resql) { print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } if (!empty($arrayfields['subaccount']['checked'])) { print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); @@ -391,7 +395,7 @@ if ($resql) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center maxwidthsearch '); } print "\n"; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 0b5b0005694..697962ef486 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -473,9 +473,12 @@ if ($action != 'export_csv') { $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); - for ($i = 0; $i < $nrows; $i++) { - $arr = $resql->fetch_array(); - $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; + if ($resql) { + $nrows = $db->num_rows($resql); + for ($i = 0; $i < $nrows; $i++) { + $arr = $db->fetch_array($resql); + $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; + } } } diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index c11fe60553e..40a8bb29971 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -360,14 +360,14 @@ if ($action == 'create') { print ''.$langs->trans('Title').''; print ''.$langs->trans('DetailTitre').''; - // Picto - print ''.$langs->trans('Image').''; - print ''.$langs->trans('Example').': fa-global'; - // URL print ''.$langs->trans('URL').''; print ''.$langs->trans('DetailUrl').''; + // Picto + print ''.$langs->trans('Image').''; + print ''.$langs->trans('Example').': fa-global'; + // Langs print ''.$langs->trans('LangFile').''; print ''.$langs->trans('DetailLangs').''; diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 9a55c609252..eddb8a40dc5 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -53,7 +53,7 @@ $idproduct = GETPOST('idproduct', 'int'); * View */ -top_httphead(); +top_httphead('application/json'); if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) { $product = new Product($db); @@ -65,3 +65,24 @@ if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) echo json_encode($fk_unit); exit(); } + +if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) { + $product = new Product($db); + $res = $product->fetch($idproduct); + + $result = array(); + + if ($res < 0) { + $error = 'SQL ERROR'; + } elseif ($res == 0) { + $error = 'NOT FOUND'; + } else { + $error = null; + $result['defaultWk']=$product->fk_default_workstation; + } + + $result['error']=$error; + + echo json_encode($result); + exit(); +} diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cfae2ea3e0c..8ea8e3e3edd 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -792,7 +792,7 @@ class BOM extends CommonObject $line->array_options[$key] = $array_options[$key]; } } - if ($fk_default_workstation > 0 && $line->fk_default_workstation != $fk_default_workstation) { + if ($fk_default_workstation >= 0 && $line->fk_default_workstation != $fk_default_workstation) { $line->fk_default_workstation = $fk_default_workstation; } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index db3991eac7d..8beefbc8b01 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -185,7 +185,7 @@ if ($filtertype != 1) { $coldisplay++; print ''; - print ' '; + print $formproduct->selectWorkstations('', 'idworkstations', 1); print ''; $coldisplay++; @@ -235,14 +235,27 @@ jQuery(document).ready(function() { ,type: 'POST' ,data: { 'action': 'getDurationUnitByProduct' + ,'token' : "" ,'idproduct' : idproduct } }).done(function(data) { console.log(data); - var data = JSON.parse(data); $("#fk_unit").val(data).change(); }); + + $.ajax({ + url : "" + ,type: 'POST' + ,data: { + 'action': 'getWorkstationByProduct' + ,'token' : "" + ,'idproduct' : idproduct + } + }).done(function(data) { + $('#idworkstations').val(data.defaultWk).select2(); + + }); }); }); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index a7118ccffcf..dbc0b02d8bf 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -267,7 +267,7 @@ if (empty($reshook)) { $objectlabel = 'Events'; $uploaddir = true; // Only users that can delete any event can remove records. - $permissiontodelete = $user->rights->agenda->allactions->delete; + $permissiontodelete = $user->hasRight('agenda', 'allactions', 'delete'); $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create'); include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -708,7 +708,7 @@ $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); +$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')); $param .= '&mode='.$mode; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c3461197b3e..11bfddf4837 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4428,7 +4428,7 @@ class OrderLine extends CommonOrderLine dol_syslog("OrderLine::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { + if (!$resql) { $this->error = $this->db->lasterror(); $error++; } diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index bf0a08f02db..af21117d21c 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -529,10 +529,10 @@ if (empty($numref)) { print ''; $reg = array(); preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) { + if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) { print $langs->trans($reg[1]); } else { - print $objp->label; + print dol_escape_htmltag($objp->label); } print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c7ea9064b00..51ed4d54e16 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4031,7 +4031,7 @@ class Facture extends CommonInvoice return -2; } } else { - $this->errors[]='status of invoice must be Draft to allow use of ->addline()'; + $this->errors[] = 'status of invoice must be Draft to allow use of ->addline()'; dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR); return -3; } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index f8b7e424a0d..ed9eb1e5c5a 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -167,7 +167,6 @@ class box_external_rss extends ModeleBoxes $title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8 $title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut - $this->info_box_contents["$href"] = "$title"; $tooltip = $title; $description = !empty($item['description']) ? $item['description'] : ''; diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 6ef0df7fb8c..11c70b00f4c 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -26,6 +26,9 @@ class FormSetup */ public $db; + /** @var int */ + public $entity; + /** @var FormSetupItem[] */ public $items = array(); @@ -90,7 +93,8 @@ class FormSetup */ public function __construct($db, $outputLangs = null) { - global $langs; + global $conf, $langs; + $this->db = $db; $this->form = new Form($this->db); @@ -99,6 +103,8 @@ class FormSetup $this->formHiddenInputs['token'] = newToken(); $this->formHiddenInputs['action'] = 'update'; + $this->entity = (is_null($this->entity) ? $conf->entity : $this->entity); + if ($outputLangs) { $this->langs = $outputLangs; } else { @@ -454,6 +460,8 @@ class FormSetup { $item = new FormSetupItem($confKey); + $item->entity = $this->entity; + // set item rank if not defined as last item if (empty($item->rank)) { $item->rank = $this->getCurentItemMaxRank() + 1; @@ -646,7 +654,7 @@ class FormSetupItem /** * Constructor * - * @param string $confKey the conf key used in database + * @param string $confKey the conf key used in database */ public function __construct($confKey) { @@ -660,7 +668,7 @@ class FormSetupItem } $this->langs = $langs; - $this->entity = $conf->entity; + $this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity)); $this->confKey = $confKey; $this->loadValueFromConf(); @@ -1119,7 +1127,7 @@ class FormSetupItem $out.= $this->generateOutputFieldColor(); } elseif ($this->type == 'yesno') { if (!empty($conf->use_javascript_ajax)) { - $out.= ajax_constantonoff($this->confKey); + $out.= ajax_constantonoff($this->confKey, array(), $this->entity); // TODO possibility to add $input parameter } else { if ($this->fieldValue == 1) { $out.= $langs->trans('yes'); diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 801ce765a8c..cc12e5aeedf 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -158,8 +158,12 @@ abstract class Stats dol_mkdir($conf->user->dir_temp); } $fp = fopen($newpathofdestfile, 'w'); - fwrite($fp, json_encode($data)); - fclose($fp); + if ($fp) { + fwrite($fp, json_encode($data)); + fclose($fp); + } else { + dol_syslog("Failed to save cache file ".$newpathofdestfile); + } dolChmod($newpathofdestfile); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 566cccf332a..bd3f1af825d 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1279,9 +1279,9 @@ class DoliDBPgsql extends DoliDB if (isset($field_desc['default']) && $field_desc['default'] != '') { if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') { - $sql .= " DEFAULT ".$this->escape($field_desc['default']); - } elseif ($field_desc['type'] != 'text') { - $sql .= " DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields + $sql .= ", ALTER COLUMN ".$this->escape($field_name)." SET DEFAULT ".((float) $field_desc['default']); + } elseif ($field_desc['type'] != 'text') { // Default not supported on text fields ? + $sql .= ", ALTER COLUMN ".$this->escape($field_name)." SET DEFAULT '".$this->escape($field_desc['default'])."'"; } } diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 50d1086104e..f93575649d4 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -184,7 +184,12 @@ class MenuManager $substitarray['__USERID__'] = $user->id; // For backward compatibility $val['url'] = make_substitutions($val['url'], $substitarray); - $relurl = dol_buildpath($val['url'], 1); + if (!preg_match('/^http/', $val['url'])) { + $relurl = dol_buildpath($val['url'], 1); + } else { + $relurl = $val['url']; + } + $canonurl = preg_replace('/\?.*$/', '', $val['url']); print ''; 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 12e939d43d8..2b4496820f2 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 @@ -243,7 +243,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $object->fetch_thirdparty(); - $dir = $conf->facture->dir_output; + $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index b22f164d6a3..d8be409e84b 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -89,7 +89,7 @@ class modStock extends DolibarrModules $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "stdmovement"; - $this->const[$r][3] = 'Name of PDF model of stock mouvement'; + $this->const[$r][3] = 'Name of PDF model of stock movement'; $this->const[$r][4] = 0; $r++; @@ -113,78 +113,82 @@ class modStock extends DolibarrModules $this->rights = array(); $this->rights_class = 'stock'; - $this->rights[0][0] = 1001; - $this->rights[0][1] = 'Lire les stocks'; - $this->rights[0][2] = 'r'; - $this->rights[0][3] = 0; - $this->rights[0][4] = 'lire'; - $this->rights[0][5] = ''; + $r = 0; - $this->rights[1][0] = 1002; - $this->rights[1][1] = 'Creer/Modifier les stocks'; - $this->rights[1][2] = 'w'; - $this->rights[1][3] = 0; - $this->rights[1][4] = 'creer'; - $this->rights[1][5] = ''; + $this->rights[$r][0] = 1001; + $this->rights[$r][1] = 'Read stocks'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'lire'; + $this->rights[$r][5] = ''; - $this->rights[2][0] = 1003; - $this->rights[2][1] = 'Supprimer les stocks'; - $this->rights[2][2] = 'd'; - $this->rights[2][3] = 0; - $this->rights[2][4] = 'supprimer'; - $this->rights[2][5] = ''; + $r++; + $this->rights[$r][0] = 1002; + $this->rights[$r][1] = 'Create/Modify stocks'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'creer'; + $this->rights[$r][5] = ''; - $this->rights[3][0] = 1004; - $this->rights[3][1] = 'Lire mouvements de stocks'; - $this->rights[3][2] = 'r'; - $this->rights[3][3] = 0; - $this->rights[3][4] = 'mouvement'; - $this->rights[3][5] = 'lire'; + $r++; + $this->rights[$r][0] = 1003; + $this->rights[$r][1] = 'Delete stock'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'supprimer'; + $this->rights[$r][5] = ''; - $this->rights[4][0] = 1005; - $this->rights[4][1] = 'Creer/modifier mouvements de stocks'; - $this->rights[4][2] = 'w'; - $this->rights[4][3] = 0; - $this->rights[4][4] = 'mouvement'; - $this->rights[4][5] = 'creer'; + $r++; + $this->rights[$r][0] = 1004; + $this->rights[$r][1] = 'Read stock movements'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvement'; + $this->rights[$r][5] = 'lire'; - $this->rights[5][0] = 1011; - $this->rights[5][1] = 'inventoryReadPermission'; // Permission label - $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1005; + $this->rights[$r][1] = 'Create/modify stock movements'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mouvement'; + $this->rights[$r][5] = 'creer'; - $this->rights[6][0] = 1012; - $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label - $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1011; + $this->rights[$r][1] = 'inventoryReadPermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][0] = 1013; - $this->rights[6][1] = 'inventoryDeletePermission'; // Permission label - $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1012; + $this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1013; + $this->rights[$r][1] = 'inventoryDeletePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { - $this->rights[8][0] = 1014; - $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label - $this->rights[8][3] = 0; // Permission by default for new user (0/1) - $this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1014; + $this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[9][0] = 1015; - $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label - $this->rights[9][3] = 0; // Permission by default for new user (0/1) - $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - - $this->rights[10][0] = 1016; - $this->rights[10][1] = 'inventoryDeletePermission'; // Permission label - $this->rights[10][3] = 0; // Permission by default for new user (0/1) - $this->rights[10][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[10][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + $this->rights[$r][0] = 1015; + $this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } // Main menu entries diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index be7f3f98f8b..266909fe17b 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -119,7 +119,7 @@ class Cronjob extends CommonObject public $lastoutput; /** - * @var string Unit frequency of job execution + * @var int Unit frequency of job execution (60, 86400, ...) */ public $unitfrequency; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 2a741b7a18f..92385c6ace1 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -474,11 +474,11 @@ class Export case 'FormSelect': //var_dump($NameField); if ($InfoFieldList[1] == 'select_company') { - $szFilterField .= $form->select_company('', $NameField, '', 1); + $szFilterField .= $form->select_company('', $NameField, '', 1, 0, 0, [], 0, 'maxwidth200'); } elseif ($InfoFieldList[1] == 'selectcontacts') { - $szFilterField .= $form->selectcontacts(0, '', $NameField, ' '); + $szFilterField .= $form->selectcontacts(0, '', $NameField, ' ', '', '', 0, 'maxwidth200'); } elseif ($InfoFieldList[1] == 'select_dolusers') { - $szFilterField .= $form->select_dolusers('', $NameField, 1); + $szFilterField .= $form->select_dolusers('', $NameField, 1, null, 0, '', '', '', 0, 0, "", 0, "", "maxwidth200"); } break; case 'List': diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 4c4df29af50..d5f972b64f8 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -82,7 +82,8 @@ $result = @include_once $conffile; // Keep @ because with some error reporting t $listofwrappers = stream_get_wrappers(); // We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar by default. // phar stream does not auto unserialize content (possible code execution) since PHP 8.1 -$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zip', 'zlib'); +// zip stream is necessary by excel import module +$arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zlib'); if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) { $arrayofstreamtodisable = $dolibarr_main_stream_to_disable; } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index bdbc1777acd..d3d60c970f8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -650,17 +650,17 @@ if (!empty($searchCategoryProductList)) { $listofcategoryid = ''; foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { - $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product)"; + $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product)"; } elseif (intval($searchCategoryProduct) > 0) { if ($searchCategoryProductOperator == 0) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; } else { $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); } } } if ($listofcategoryid) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; + $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } if ($searchCategoryProductOperator == 1) { if (!empty($searchCategoryProductSqlList)) { diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index 1d2ed7ab515..3668d71a6de 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -133,9 +133,9 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); // Security check (enable the most restrictive one) if ($user->socid > 0) { diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 461e0259a82..29f9637b285 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -134,9 +134,9 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); // Security check (enable the most restrictive one) if ($user->socid > 0) { diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index 7179a411a82..49cf2325ea8 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -160,7 +160,7 @@ if ($id > 0 || $ref) { $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = "fk_product_type = ".((int) $object->type); $shownav = 1; diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index f70639a6a05..3135c524c7f 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -232,7 +232,7 @@ if ($id > 0 || !empty($ref)) { * Product card */ if ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire')) { - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 2e32646a8b9..70d174da2d9 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -239,7 +239,7 @@ if ($object->id) { } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = "fk_product_type = ".((int) $object->type); $shownav = 1; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index dd42d203d7f..9f5da63879f 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -391,7 +391,7 @@ if ($id > 0 || $ref) { print dol_get_fiche_head($head, 'suppliers', $titre, -1, $picto); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = "fk_product_type = ".((int) $object->type); $shownav = 1; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index cb46caba07f..c5cd328d861 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -861,11 +861,11 @@ if ($type === "") { $params['forcenohideoftext'] = 1; } $newcardbutton .= dolGetButtonTitleSeparator(); -if ($type === "" || $type == Product::TYPE_PRODUCT) { +if ((isModEnabled('product') && $type === "") || $type == Product::TYPE_PRODUCT) { $label = 'NewProduct'; $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params); } -if ($type === "" || $type == Product::TYPE_SERVICE) { +if ((isModEnabled('service') && $type === "") || $type == Product::TYPE_SERVICE) { $label = 'NewService'; $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=1', '', $perm, $params); } diff --git a/htdocs/product/note.php b/htdocs/product/note.php index ad397349125..0054db38d10 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -122,7 +122,7 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_head($head, 'note', $titre, -1, $picto); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = "fk_product_type = ".((int) $object->type); $shownav = 1; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 4df1f623fb5..26b1418c9a4 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -884,7 +884,7 @@ $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); print dol_get_fiche_head($head, 'price', $titre, -1, $picto); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = "fk_product_type = ".((int) $object->type); $shownav = 1; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 993e4ae3e87..8e3bfb36330 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -151,7 +151,7 @@ if ($result && ($id > 0 || !empty($ref)) && empty($notab)) { print dol_get_fiche_head($head, 'stats', $titre, -1, $picto); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index a3ca3c744ad..e88fa90def6 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -164,7 +164,7 @@ if ($id > 0 || !empty($ref)) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 0c5e071f323..3edb2745d31 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -611,7 +611,7 @@ if ($id > 0 || $ref) { dol_htmloutput_events(); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 7a793ba6115..57a84a72696 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -212,7 +212,7 @@ if (!empty($object->multilangs)) { print dol_get_fiche_head($head, 'translation', $titre, 0, $picto); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; $shownav = 1; if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) { diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 9e5d578e01a..9825b331f1b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2151,7 +2151,7 @@ if ($action != 'dopayment') { if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') != 'integral') { print '
 
'; } - print ' '; + print ' '; if (getDolGlobalString('PAYPAL_API_INTEGRAL_OR_PAYPALONLY') == 'integral') { print '
'; print ''.$langs->trans("CreditOrDebitCard").' - '; diff --git a/htdocs/takepos/freezone.php b/htdocs/takepos/freezone.php index 4e66b97f017..71a0879fa9e 100644 --- a/htdocs/takepos/freezone.php +++ b/htdocs/takepos/freezone.php @@ -51,6 +51,8 @@ $langs->loadLangs(array("bills", "cashdesk")); $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : '0'); // $place is id of table for Bar or Restaurant +$invoiceid = GETPOST('invoiceid', 'int'); + $idline = GETPOST('idline', 'int'); $action = GETPOST('action', 'aZ09'); @@ -60,12 +62,13 @@ if (!$user->hasRight('takepos', 'run')) { // get invoice $invoice = new Facture($db); -if ($place > 0) { - $invoice->fetch($place); +if ($invoiceid > 0) { + $invoice->fetch($invoiceid); } else { $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$place.')'); } + // get default vat rate $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION['takeposterminal']; $soc = new Societe($db); @@ -108,8 +111,8 @@ top_htmlhead('', '', 0, 0, $arrayofjs, $arrayofcss); * Save (validate) */ function Save() { - console.log("We click so we call page invoice.php with place= tva_tx="+vatRate); - parent.$("#poslines").load("invoice.php?action=freezone&token=&place=&number="+$('#number').val()+"&tva_tx="+vatRate, {desc:$('#desc').val()}); + console.log("We click so we call page invoice.php with invoiceid=, place=, amount="+$("#number").val()+", tva_tx="+vatRate); + parent.$("#poslines").load("invoice.php?action=freezone&token=&invoiceid=&place=&number="+$("#number").val()+"&tva_tx="+vatRate, {desc:$("#desc").val()}); parent.$.colorbox.close(); } diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index c58d0f5a81b..94a44677b99 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -73,7 +73,6 @@ if ($setcurrency != "") { // We will recalculate amount for foreign currency at next call of invoice.php when $_SESSION["takeposcustomercurrency"] differs from invoice->multicurrency_code. } -$_SESSION["urlfrom"] = '/takepos/index.php'; $langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter", "banks")); @@ -532,11 +531,12 @@ function ClickProduct(position, qty = 1) { } else{ console.log($('#prodiv4').data('rowid')); + invoiceid = $("#invoiceid").val(); idproduct=$('#prodiv'+position).data('rowid'); - console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty); + console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoicdeid="+invoiceid); if (idproduct=="") return; // Call page invoice.php to generate the section with product lines - $("#poslines").load("invoice.php?action=addline&token=&place="+place+"&idproduct="+idproduct+"&qty="+qty, function() { + $("#poslines").load("invoice.php?action=addline&token=&place="+place+"&idproduct="+idproduct+"&qty="+qty+"&invoiceid="+invoiceid, function() { @@ -556,8 +556,9 @@ function ChangeThirdparty(idcustomer) { } function deleteline() { - console.log("Delete line"); - $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline, function() { + invoiceid = $("#invoiceid").val(); + console.log("Delete line invoiceid="+invoiceid); + $("#poslines").load("invoice.php?action=deleteline&token=&place="+place+"&idline="+selectedline+"&invoiceid="+invoiceid, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); ClearSearch(); @@ -603,8 +604,9 @@ function Floors() { } function FreeZone() { - console.log("Open box to enter a free product"); - $.colorbox({href:"freezone.php?action=freezone&token=&place="+place, width:"80%", height:"40%", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); + invoiceid = $("#invoiceid").val(); + console.log("Open box to enter a free product on invoiceid="+invoiceid); + $.colorbox({href:"freezone.php?action=freezone&token=&place="+place+"&invoiceid="+invoiceid, width:"80%", height:"40%", transition:"none", iframe:"true", title:"trans("FreeZone"); ?>"}); } function TakeposOrderNotes() { @@ -1146,7 +1148,7 @@ if (!getDolGlobalString('TAKEPOS_HIDE_HEAD_BAR')) { ?>
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index d0e0d179efc..e2c92f52d24 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -513,6 +513,7 @@ if (empty($reshook)) { } } + // If we add a line by click on product (invoice exists here because it was created juste before if it didn't exists) if ($action == "addline" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { $prod = new Product($db); $prod->fetch($idproduct); @@ -703,6 +704,7 @@ if (empty($reshook)) { $invoice->fetch($placeid); } + // If we add a line by submitting freezone form (invoice exists here because it was created juste before if it didn't exists) if ($action == "freezone" && $user->hasRight('takepos', 'run')) { $customer = new Societe($db); $customer->fetch($invoice->socid); @@ -720,7 +722,10 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); - $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + $res = $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', getDolGlobalInt('TAKEPOS_DISCOUNT_TTC') ? ($number >= 0 ? 'HT' : 'TTC') : (getDolGlobalInt('TAKEPOS_CHANGE_PRICE_HT') ? 'HT' : 'TTC'), $number, 0, -1, 0, '', 0, 0, null, '', '', 0, 100, '', null, 0); + if ($res < 0) { + dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + } $invoice->fetch($placeid); } diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 4713d4e9e97..77fcb90a4b9 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -72,7 +72,7 @@ if ($reshook < 0) { } // Define url to go after disconnect -$urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"]; +$urlfrom = empty($_SESSION["urlfrom"]) ? GETPOST('urlfrom') : $_SESSION["urlfrom"]; // Define url to go $url = DOL_URL_ROOT."/index.php"; // By default go to login page diff --git a/test/phpunit/DoliDBTest.php b/test/phpunit/DoliDBTest.php index 999c3b3e54a..2a380fa637e 100644 --- a/test/phpunit/DoliDBTest.php +++ b/test/phpunit/DoliDBTest.php @@ -160,7 +160,7 @@ class DoliDBTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; // TODO Use $savtype and $savnull instead of hard coded - $field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL'); + $field_desc = array('type'=>'varchar', 'value'=>'16', 'null'=>'NOT NULL', 'default'=>'aaaabbbbccccdddd'); $result = $db->DDLUpdateField($db->prefix().'c_paper_format', 'code', $field_desc); $this->assertEquals(1, $result);