From 5940d3705aded09e304058292dc60cb40f3b5bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 21 May 2020 16:00:12 +0200 Subject: [PATCH] add new rule --- htdocs/contrat/class/contrat.class.php | 17 ++++- htdocs/core/ajax/extraparams.php | 31 ++++++++- htdocs/core/lib/functions.lib.php | 94 +++++++++++++++++++++----- htdocs/core/tpl/notes.tpl.php | 24 ++++++- htdocs/takepos/admin/orderprinters.php | 34 +++++++++- 5 files changed, 178 insertions(+), 22 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a702847e23b..c2200a411c2 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2716,7 +2716,22 @@ class ContratLigne extends CommonObjectLine global $langs; $langs->load("contracts"); - if ($status == self::STATUS_INITIAL) { $labelStatus = $langs->trans("ServiceStatusInitial"); $labelStatusShort = $langs->trans("ServiceStatusInitial"); } elseif ($status == self::STATUS_OPEN && $expired == -1) { $labelStatus = $langs->trans("ServiceStatusRunning"); $labelStatusShort = $langs->trans("ServiceStatusRunning"); } elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } + if ($status == self::STATUS_INITIAL) { + $labelStatus = $langs->trans("ServiceStatusInitial"); + $labelStatusShort = $langs->trans("ServiceStatusInitial"); + } elseif ($status == self::STATUS_OPEN && $expired == -1) { + $labelStatus = $langs->trans("ServiceStatusRunning"); + $labelStatusShort = $langs->trans("ServiceStatusRunning"); + } elseif ($status == self::STATUS_OPEN && $expired == 0) { + $labelStatus = $langs->trans("ServiceStatusNotLate"); + $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); + } elseif ($status == self::STATUS_OPEN && $expired == 1) { + $labelStatus = $langs->trans("ServiceStatusLate"); + $labelStatusShort = $langs->trans("ServiceStatusLateShort"); + } elseif ($status == self::STATUS_CLOSED) { + $labelStatus = $langs->trans("ServiceStatusClosed"); + $labelStatusShort = $langs->trans("ServiceStatusClosed"); + } $statusType = 'status'.$status; if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index 803155ce784..16f39af9bde 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -51,11 +51,38 @@ if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) $classpath = $subelement = $element; // For compatibility - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } elseif ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } elseif ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } elseif ($element == 'contract') { $classpath = $subelement = 'contrat'; } elseif ($element == 'shipping') { $classpath = $subelement = 'expedition'; } elseif ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } elseif ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } elseif ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } + if ($element == 'order' || $element == 'commande') { + $classpath = $subelement = 'commande'; + } elseif ($element == 'propal') { + $classpath = 'comm/propal'; + $subelement = 'propal'; + } elseif ($element == 'facture') { + $classpath = 'compta/facture'; + $subelement = 'facture'; + } elseif ($element == 'contract') { + $classpath = $subelement = 'contrat'; + } elseif ($element == 'shipping') { + $classpath = $subelement = 'expedition'; + } elseif ($element == 'deplacement') { + $classpath = 'compta/deplacement'; + $subelement = 'deplacement'; + } elseif ($element == 'order_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.commande'; + } elseif ($element == 'invoice_supplier') { + $classpath = 'fourn'; + $subelement = 'fournisseur.facture'; + } dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } elseif ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } else $classname = ucfirst($subelement); + if ($element == 'order_supplier') { + $classname = 'CommandeFournisseur'; + } elseif ($element == 'invoice_supplier') { + $classname = 'FactureFournisseur'; + } else { + $classname = ucfirst($subelement); + } $object = new $classname($db); $object->fetch($id); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 518215b9b3f..8ab6cb43be9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -492,19 +492,48 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null { $loopnb++; $newout = ''; - if ($reg[1] == 'DAY') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mday']; } elseif ($reg[1] == 'MONTH') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['mon']; } elseif ($reg[1] == 'YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = $tmp['year']; } elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } elseif ($reg[1] == 'NEXT_DAY') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'NEXT_MONTH') { $tmp = dol_getdate(dol_now(), true); $tmp2 = dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'NEXT_YEAR') { $tmp = dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') - { + if ($reg[1] == 'DAY') { + $tmp = dol_getdate(dol_now(), true); + $newout = $tmp['mday']; + } elseif ($reg[1] == 'MONTH') { + $tmp = dol_getdate(dol_now(), true); + $newout = $tmp['mon']; + } elseif ($reg[1] == 'YEAR') { + $tmp = dol_getdate(dol_now(), true); + $newout = $tmp['year']; + } elseif ($reg[1] == 'PREVIOUS_DAY') { + $tmp = dol_getdate(dol_now(), true); + $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); + $newout = $tmp2['day']; + } elseif ($reg[1] == 'PREVIOUS_MONTH') { + $tmp = dol_getdate(dol_now(), true); + $tmp2 = dol_get_prev_month($tmp['mon'], $tmp['year']); + $newout = $tmp2['month']; + } elseif ($reg[1] == 'PREVIOUS_YEAR') { + $tmp = dol_getdate(dol_now(), true); + $newout = ($tmp['year'] - 1); + } elseif ($reg[1] == 'NEXT_DAY') { + $tmp = dol_getdate(dol_now(), true); + $tmp2 = dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); + $newout = $tmp2['day']; + } elseif ($reg[1] == 'NEXT_MONTH') { + $tmp = dol_getdate(dol_now(), true); + $tmp2 = dol_get_next_month($tmp['mon'], $tmp['year']); + $newout = $tmp2['month']; + } elseif ($reg[1] == 'NEXT_YEAR') { + $tmp = dol_getdate(dol_now(), true); + $newout = ($tmp['year'] + 1); + } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') { $newout = $mysoc->country_id; - } elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') - { + } elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') { $newout = $user->id; - } elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') - { + } elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') { $newout = $user->fk_user; - } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') - { + } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') { $newout = $conf->entity; - } else $newout = ''; // Key not found, we replace with empty string + } else { + $newout = ''; // Key not found, we replace with empty string + } //var_dump('__'.$reg[1].'__ -> '.$newout); $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out); } @@ -522,8 +551,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null if (preg_match('/[^0-9,-]+/i', $out)) $out = ''; break; case 'alpha': - if (!is_array($out)) - { + if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals $out = str_replace(array('"', '../'), '', trim($out)); @@ -3285,7 +3313,25 @@ function img_action($titlealt, $numaction) if (empty($titlealt) || $titlealt == 'default') { - if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } else { $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); $numaction = 0; } + if ($numaction == '-1' || $numaction == 'ST_NO') { + $numaction = -1; + $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); + } elseif ($numaction == '0' || $numaction == 'ST_NEVER') { + $numaction = 0; + $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); + } elseif ($numaction == '1' || $numaction == 'ST_TODO') { + $numaction = 1; + $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); + } elseif ($numaction == '2' || $numaction == 'ST_PEND') { + $numaction = 2; + $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); + } elseif ($numaction == '3' || $numaction == 'ST_DONE') { + $numaction = 3; + $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); + } else { + $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); + $numaction = 0; + } } if (!is_numeric($numaction)) $numaction = 0; @@ -3570,7 +3616,9 @@ function img_left($titlealt = 'default', $selected = 0, $moreatt = '') { global $langs; - if ($titlealt == 'default') $titlealt = $langs->trans('Left'); + if ($titlealt == 'default') { + $titlealt = $langs->trans('Left'); + } return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); } @@ -3613,15 +3661,29 @@ function img_allow($allow, $titlealt = 'default') /** * Return image of a credit card according to its brand name * - * @param string $brand Brand name of credit card - * @param string $morecss More CSS + * @param string $brand Brand name of credit card + * @param string $morecss More CSS * @return string Return img tag */ function img_credit_card($brand, $morecss = null) { if (is_null($morecss)) $morecss = 'fa-2x'; - if ($brand == 'visa' || $brand == 'Visa') {$brand = 'cc-visa'; } elseif ($brand == 'mastercard' || $brand == 'MasterCard') {$brand = 'cc-mastercard'; } elseif ($brand == 'amex' || $brand == 'American Express') {$brand = 'cc-amex'; } elseif ($brand == 'discover' || $brand == 'Discover') {$brand = 'cc-discover'; } elseif ($brand == 'jcb' || $brand == 'JCB') {$brand = 'cc-jcb'; } elseif ($brand == 'diners' || $brand == 'Diners club') {$brand = 'cc-diners-club'; } elseif (!in_array($brand, array('cc-visa', 'cc-mastercard', 'cc-amex', 'cc-discover', 'cc-jcb', 'cc-diners-club'))) {$brand = 'credit-card'; } + if ($brand == 'visa' || $brand == 'Visa') { + $brand = 'cc-visa'; + } elseif ($brand == 'mastercard' || $brand == 'MasterCard') { + $brand = 'cc-mastercard'; + } elseif ($brand == 'amex' || $brand == 'American Express') { + $brand = 'cc-amex'; + } elseif ($brand == 'discover' || $brand == 'Discover') { + $brand = 'cc-discover'; + } elseif ($brand == 'jcb' || $brand == 'JCB') { + $brand = 'cc-jcb'; + } elseif ($brand == 'diners' || $brand == 'Diners club') { + $brand = 'cc-diners-club'; + } elseif (!in_array($brand, array('cc-visa', 'cc-mastercard', 'cc-amex', 'cc-discover', 'cc-jcb', 'cc-diners-club'))) { + $brand = 'credit-card'; + } return ''; } diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 8d1f7256ab2..f387725bece 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -57,7 +57,29 @@ if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) } // Special cases -if ($module == 'propal') { $permission = $user->rights->propale->creer; } elseif ($module == 'supplier_proposal') { $permission = $user->rights->supplier_proposal->creer; } elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; } elseif ($module == 'project') { $permission = $user->rights->projet->creer; } elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; } elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; } elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; } elseif ($module == 'societe') { $permission = $user->rights->societe->creer; } elseif ($module == 'contact') { $permission = $user->rights->societe->creer; } elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } elseif ($module == 'product') { $permission = $user->rights->produit->creer; } +if ($module == 'propal') { + $permission = $user->rights->propale->creer; +} elseif ($module == 'supplier_proposal') { + $permission = $user->rights->supplier_proposal->creer; +} elseif ($module == 'fichinter') { + $permission = $user->rights->ficheinter->creer; +} elseif ($module == 'project') { + $permission = $user->rights->projet->creer; +} elseif ($module == 'project_task') { + $permission = $user->rights->projet->creer; +} elseif ($module == 'invoice_supplier') { + $permission = $user->rights->fournisseur->facture->creer; +} elseif ($module == 'order_supplier') { + $permission = $user->rights->fournisseur->commande->creer; +} elseif ($module == 'societe') { + $permission = $user->rights->societe->creer; +} elseif ($module == 'contact') { + $permission = $user->rights->societe->creer; +} elseif ($module == 'shipping') { + $permission = $user->rights->expedition->creer; +} elseif ($module == 'product') { + $permission = $user->rights->produit->creer; +} //else dol_print_error('','Bad value '.$module.' for param module'); if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index a9a4b945d0d..79a16d77861 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -72,9 +72,39 @@ if ($action == "SavePrinter2") { $categstatic = new Categorie($db); $form = new Form($db); -if ($type == Categorie::TYPE_PRODUCT) { $title = $langs->trans("ProductsCategoriesArea"); $typetext = 'product'; } elseif ($type == Categorie::TYPE_SUPPLIER) { $title = $langs->trans("SuppliersCategoriesArea"); $typetext = 'supplier'; } elseif ($type == Categorie::TYPE_CUSTOMER) { $title = $langs->trans("CustomersCategoriesArea"); $typetext = 'customer'; } elseif ($type == Categorie::TYPE_MEMBER) { $title = $langs->trans("MembersCategoriesArea"); $typetext = 'member'; } elseif ($type == Categorie::TYPE_CONTACT) { $title = $langs->trans("ContactsCategoriesArea"); $typetext = 'contact'; } elseif ($type == Categorie::TYPE_ACCOUNT) { $title = $langs->trans("AccountsCategoriesArea"); $typetext = 'bank_account'; } elseif ($type == Categorie::TYPE_PROJECT) { $title = $langs->trans("ProjectsCategoriesArea"); $typetext = 'project'; } elseif ($type == Categorie::TYPE_USER) { $title = $langs->trans("UsersCategoriesArea"); $typetext = 'user'; } else { $title = $langs->trans("CategoriesArea"); $typetext = 'unknown'; } +if ($type == Categorie::TYPE_PRODUCT) { + $title = $langs->trans("ProductsCategoriesArea"); + $typetext = 'product'; +} elseif ($type == Categorie::TYPE_SUPPLIER) { + $title = $langs->trans("SuppliersCategoriesArea"); + $typetext = 'supplier'; +} elseif ($type == Categorie::TYPE_CUSTOMER) { + $title = $langs->trans("CustomersCategoriesArea"); + $typetext = 'customer'; +} elseif ($type == Categorie::TYPE_MEMBER) { + $title = $langs->trans("MembersCategoriesArea"); + $typetext = 'member'; +} elseif ($type == Categorie::TYPE_CONTACT) { + $title = $langs->trans("ContactsCategoriesArea"); + $typetext = 'contact'; +} elseif ($type == Categorie::TYPE_ACCOUNT) { + $title = $langs->trans("AccountsCategoriesArea"); + $typetext = 'bank_account'; +} elseif ($type == Categorie::TYPE_PROJECT) { + $title = $langs->trans("ProjectsCategoriesArea"); + $typetext = 'project'; +} elseif ($type == Categorie::TYPE_USER) { + $title = $langs->trans("UsersCategoriesArea"); + $typetext = 'user'; +} else { + $title = $langs->trans("CategoriesArea"); + $typetext = 'unknown'; +} -$arrayofjs = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); +$arrayofjs = array( + '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', + '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', +); $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss);