From d7abad4566ee63b1879fdad75664320e0160ef8e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 29 Apr 2019 17:40:59 +0200 Subject: [PATCH 001/110] NEW : mass email action on invoice list use billing contact if exists --- htdocs/core/actions_massactions.inc.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 55dda5a5934..819683af55e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -70,6 +70,7 @@ if (! $error && $massaction == 'confirm_presend') $listofobjectid=array(); $listofobjectthirdparties=array(); + $listofobjectcontacts = array(); $listofobjectref=array(); if (! $error) @@ -94,6 +95,16 @@ if (! $error && $massaction == 'confirm_presend') if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user; if (empty($thirdpartyid)) $thirdpartyid=0; + if ($objectclass == 'Facture') { + $tmparraycontact = array(); + $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'BILLING'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + $listofobjectcontacts[$toselectid][$data_email['id']] = $data_email['email']; + } + } + } + $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; } @@ -216,7 +227,7 @@ if (! $error && $massaction == 'confirm_presend') $resaction.='
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; continue; // Payment done or started or canceled } - if ($objectclass == 'Commande' && $objectoj->statut == Commande::STATUS_DRAFT) + if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; @@ -245,6 +256,16 @@ if (! $error && $massaction == 'confirm_presend') $fuser = new User($db); $fuser->fetch($objectobj->fk_user); $sendto = $fuser->email; + } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { + $emails_to_sends = array(); + $objectobj->fetch_thirdparty(); + foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { + + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property((int)$contactemailid, 'email'); + } + if (count($emails_to_sends) > 0) { + $sendto = implode(',', $emails_to_sends); + } } else { From 8dc494890a8514ba5f988cf62bc9434ed07dcbbe Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 3 May 2019 16:24:25 +0200 Subject: [PATCH 002/110] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20../core/actions=5Fmassactions.inc.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 ef76611359a..2a0795a60ed 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -261,7 +261,7 @@ if (! $error && $massaction == 'confirm_presend') $objectobj->fetch_thirdparty(); foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { - $emails_to_sends[] = $objectobj->thirdparty->contact_get_property((int)$contactemailid, 'email'); + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property((int) $contactemailid, 'email'); } if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); From 7af203e519b0fe7cd4b5963dcf914cd303326b8d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 3 May 2019 16:28:44 +0200 Subject: [PATCH 003/110] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20../core/actions=5Fmassactions.inc.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/core/actions_massactions.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2a0795a60ed..26e168c3dc6 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -72,6 +72,7 @@ if (! $error && $massaction == 'confirm_presend') $listofobjectthirdparties=array(); $listofobjectcontacts = array(); $listofobjectref=array(); + $contactidtosend=array(); if (! $error) { @@ -259,9 +260,13 @@ if (! $error && $massaction == 'confirm_presend') } elseif ($objectobj->element == 'facture' && !empty($listofobjectcontacts[$objectid])) { $emails_to_sends = array(); $objectobj->fetch_thirdparty(); + $contactidtosend=array(); foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { - $emails_to_sends[] = $objectobj->thirdparty->contact_get_property((int) $contactemailid, 'email'); + $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); + if (!in_array($contactemailid, $contactidtosend)) { + $contactidtosend[] = $contactemailid; + } } if (count($emails_to_sends) > 0) { $sendto = implode(',', $emails_to_sends); @@ -480,7 +485,7 @@ if (! $error && $massaction == 'confirm_presend') $actionmsg2=''; // Initialisation donnees - $objectobj2->sendtoid = 0; + $objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend); $objectobj2->actionmsg = $actionmsg; // Long text $objectobj2->actionmsg2 = $actionmsg2; // Short text $objectobj2->fk_element = $objid2; From d79340a6325aada703073a2a295e8be27234e1bd Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 17 Oct 2019 09:55:02 +0200 Subject: [PATCH 004/110] FIX: stock replenish: fetching and freeing non existing SQL result set --- htdocs/product/stock/replenish.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index cc7f5d1f2f5..0bd7f95373b 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -137,7 +137,6 @@ if ($action == 'order' && isset($_POST['valid'])) if ($qty) { //might need some value checks - $obj = $db->fetch_object($resql); $line = new CommandeFournisseurLigne($db); $line->qty = $qty; $line->fk_product = $idprod; @@ -176,7 +175,7 @@ if ($action == 'order' && isset($_POST['valid'])) $error=$db->lasterror(); dol_print_error($db); } - $db->free($resql); + unset($_POST['fourn' . $i]); } unset($_POST[$i]); From 373d6d60e7bbf9c0a75df69d5a6c304526788280 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Oct 2019 21:12:18 +0200 Subject: [PATCH 005/110] Add a message --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index a5d8df20cfc..3c0608c06e2 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -164,7 +164,7 @@ if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) if ($csrfattack) { //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; - print "Access refused by CSRF protection in main.inc.php. Referer of form is outside server that serve the POST.\n"; + print "Access refused by CSRF protection in main.inc.php. Referer of form (".$_SERVER['HTTP_REFERER'].") is outside server that serve the POST.\n"; print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n"; die; } From d442134a51d7cbca93605d968ce2aaa18b7fb23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 17 Oct 2019 21:15:34 +0200 Subject: [PATCH 006/110] fix cant add bookmark with csrf active --- htdocs/bookmarks/bookmarks.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 319c44c9d73..f49fd1f93a3 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -72,6 +72,7 @@ function printBookmarksList($aDb, $aLangs) $ret.= ''."\n"; $ret.= '
'; + $ret.= ''; $ret.= ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5492f760407..f526c5e3c52 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -940,11 +940,11 @@ class Product extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; - + if ($updatetype && ($this->isProduct() || $this->isService())) { $sql.= ", fk_product_type = " . $this->type; } - + $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 59c81c83e29..0362a3767c3 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -440,12 +440,12 @@ while ($i < min($num, $limit)) $cssforfield=(empty($val['css'])?'':$val['css']); if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; - + if (! empty($arrayfields['t.'.$key]['checked'])) { print ''; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 3ee0cb5de1a..d14eba99fae 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -234,7 +234,7 @@ if ($id > 0 || ! empty($ref)) 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; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 15670a2095d..1ed4916e3c9 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -72,10 +72,10 @@ class Thirdparties extends DolibarrApi * * @throws RestException */ - public function get($id) + public function get($id) { - return $this->_fetch($id); - } + return $this->_fetch($id); + } /** * Get properties of a thirdparty object by email. diff --git a/htdocs/takepos/admin/receipt.php b/htdocs/takepos/admin/receipt.php index 92333394edc..ffa4bd6d13b 100644 --- a/htdocs/takepos/admin/receipt.php +++ b/htdocs/takepos/admin/receipt.php @@ -41,12 +41,12 @@ $langs->loadLangs(array("admin", "cashdesk", "commercial")); if (GETPOST('action', 'alpha') == 'set') { $db->begin(); - + $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_SHOW_CUSTOMER", GETPOST('TAKEPOS_SHOW_CUSTOMER', 'alpha'), 'chaine', 0, '', $conf->entity); - + dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); if (! $res > 0) $error++; diff --git a/test/phpunit/BOMTest.php b/test/phpunit/BOMTest.php index b69e59c6283..41cbdd9f247 100644 --- a/test/phpunit/BOMTest.php +++ b/test/phpunit/BOMTest.php @@ -79,7 +79,7 @@ class BOMTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - + print __METHOD__."\n"; } From d921b08e5cf5d5942ab1976c13a04c05323e3f7e Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Sun, 20 Oct 2019 11:44:07 -0500 Subject: [PATCH 014/110] Translate documentation of translate class --- htdocs/core/class/translate.class.php | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 3780ab35b06..e54de5a91d2 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -586,18 +586,18 @@ class Translate /** * Return text translated of text received as parameter (and encode it into HTML) - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel - * Les parametres de cette methode peuvent contenir de balises HTML. + * If there is no match for this text, we look in alternative file and if still not found, + * it is returned as it is + * The parameters of this method can contain HTML tags * * @param string $key Key to translate - * @param string $param1 chaine de param1 - * @param string $param2 chaine de param2 - * @param string $param3 chaine de param3 - * @param string $param4 chaine de param4 + * @param string $param1 param1 string + * @param string $param2 param2 string + * @param string $param3 param3 string + * @param string $param4 param4 string * @param int $maxsize Max length of text * @return string Translated string (encoded into HTML entities and UTF8) - */ + */ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) { global $conf; @@ -647,9 +647,9 @@ class Translate /** * Return translated value of a text string - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel. - * Parameters of this method must not contains any HTML tags. + * If there is no match for this text, we look in alternative file and if still not found + * it is returned as is. + * Parameters of this method must not contain any HTML tags. * * @param string $key Key to translate * @param string $param1 chaine de param1 @@ -667,9 +667,9 @@ class Translate /** * Return translated value of a text string - * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif - * et si toujours pas trouve, il est retourne tel quel. - * No convert to encoding charset of lang object is done. + * If there is no match for this text, we look in alternative file and if still not found, + * it is returned as is. + * No conversion to encoding charset of lang object is done. * Parameters of this method must not contains any HTML tags. * * @param string $key Key to translate @@ -781,7 +781,7 @@ class Translate if (preg_match('/^[a-z]+_[A-Z]+/i', $dir)) { $this->load("languages"); - + if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue; if ($usecode == 2) From f2e5a235471c4cfe1adbb5375b34ad80ff200798 Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Sun, 20 Oct 2019 13:47:39 -0500 Subject: [PATCH 015/110] Declaration of $soc should not be conditional --- htdocs/compta/facture/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cabd2c75fa4..fe88c9ec717 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2566,6 +2566,7 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); +$soc = new Societe($db); $paymentstatic=new Paiement($db); $bankaccountstatic = new Account($db); if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } @@ -2586,7 +2587,6 @@ if ($action == 'create') print load_fiche_titre($langs->trans('NewBill'), '', 'invoicing'); - $soc = new Societe($db); if ($socid > 0) $res = $soc->fetch($socid); @@ -3465,7 +3465,6 @@ elseif ($id > 0 || ! empty($ref)) $result = $object->fetch_thirdparty(); - $soc = new Societe($db); $result=$soc->fetch($object->socid); if ($result < 0) dol_print_error($db); $selleruserevenustamp = $mysoc->useRevenueStamp(); From df181d1f3504815fc55f50c574f53f962379093a Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 20 Oct 2019 22:01:54 +0200 Subject: [PATCH 016/110] Multiple payments in a TakePOS sale --- htdocs/takepos/invoice.php | 13 ++++++++----- htdocs/takepos/pay.php | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6a67d9d03f9..2068981c98d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -165,8 +165,12 @@ if ($action == 'valid' && $user->rights->facture->creer) $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; if ($invoice->statut != Facture::STATUS_DRAFT) { - dol_syslog("Sale already validated"); - dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + //If invoice is validated but it is not fully paid is not error and make the payment + if ($invoice->getRemainToPay()>0) $res=1; + else{ + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } } elseif (count($invoice->lines)==0) { @@ -199,7 +203,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->amounts[$invoice->id] = $amountofpayment; // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->total_ttc; + if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->getRemainToPay(); $payment->paiementid=$paiementid; $payment->num_payment=$invoice->ref; @@ -427,7 +431,6 @@ $sectionwithinvoicelink=''; if ($action=="valid" || $action=="history") { $sectionwithinvoicelink.=''."\n"; - $sectionwithinvoicelink.=''; $sectionwithinvoicelink.=''; $sectionwithinvoicelink.=$invoice->getNomUrl(1, '', 0, 0, '', 0, 0, -1, '_backoffice')." - "; $remaintopay = $invoice->getRemainToPay(); @@ -582,7 +585,7 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) if ($mobilepage=="invoice" || $mobilepage=="") { print $langs->trans('TotalTTC'); print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; - print '
' . $sectionwithinvoicelink; + print '
' . $sectionwithinvoicelink; print ''; } if ($_SESSION["basiclayout"]!=1) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 63bf151f40a..349c03540b2 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -172,9 +172,8 @@ else print "var received=0;"; } console.log("We click on the payment mode to pay amount = "+amountpayed); parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() { - //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight); - parent.$.colorbox.close(); - //parent.setFocusOnSearchField(); // This does not have effect + if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); + else location.reload(); }); } From b21bca17de85b4f74ffb1654e36ebdd739ab6d23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 00:55:52 +0200 Subject: [PATCH 017/110] Add button Save and stay when editing property of web site --- htdocs/admin/company.php | 4 ++-- htdocs/langs/en_US/main.lang | 1 + htdocs/website/index.php | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 912995d7817..09a4e95c0ae 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -476,7 +476,7 @@ if (! empty($conf->barcode->enabled)) { } // Logo -print ''; +print ''; print '
'; print ''; print ''; @@ -493,7 +493,7 @@ print '
'; print ''; // Logo (squarred) -print ''; +print ''; print ''; + // Date invoice print ''; // Ref Product @@ -377,7 +378,13 @@ if ($result) { print ''; - print ''; + // Country + print ''; print ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index a815e5b858b..730aecf9dc1 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -367,6 +367,7 @@ if ($result) { print $objp->invoice_label; print ''; + // Date invoice print ''; // Ref product @@ -387,7 +388,12 @@ if ($result) { print ''; - print ''; + print ''; print ''; From 6ebd9721daa2b4ac0f57006b8533fc302a85166b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 03:50:57 +0200 Subject: [PATCH 020/110] FIX The Button "Automatic binding" did not use the account intracomm or export. --- htdocs/accountancy/customer/index.php | 84 ++++++++++++++++++++++++--- htdocs/accountancy/customer/list.php | 11 ++-- htdocs/accountancy/supplier/index.php | 83 ++++++++++++++++++++++++-- htdocs/accountancy/supplier/list.php | 10 ++-- 4 files changed, 165 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f43ca801c25..c0e45916922 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -29,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Load translation files required by the page @@ -65,6 +66,8 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); + /* * Actions @@ -101,7 +104,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -114,16 +117,83 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Customer Invoice lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index c15ace96ffc..d4cc5f59388 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -219,9 +219,9 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -247,7 +247,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } $sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { @@ -406,7 +406,7 @@ if ($result) { $isSellerInEEC = isInEEC($mysoc); - while ( $i < min($num_lines, $limit) ) { + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $objp->code_sell_l = ''; @@ -518,6 +518,7 @@ if ($result) { print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); print ''; + // Country print ''; - // Ref product + // Ref Product print ''; // Description - print ''; + // Date invoice print ''; // Ref Product @@ -389,7 +390,13 @@ if ($result) { print ''; - print ''; + // Country + print ''; print ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index c4aa1316876..659d428b93b 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -380,6 +380,7 @@ if ($result) { print $objp->invoice_label; print ''; + // Date invoice print ''; // Ref product @@ -400,7 +401,12 @@ if ($result) { print ''; - print ''; + print ''; print ''; From febf9ccd0473d415819c5ccfd7832de1ba471672 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 03:50:57 +0200 Subject: [PATCH 022/110] FIX The Button "Automatic binding" did not use the account intracomm or export. --- htdocs/accountancy/customer/index.php | 84 ++++++++++++++++++++++++--- htdocs/accountancy/customer/list.php | 11 ++-- htdocs/accountancy/supplier/index.php | 83 ++++++++++++++++++++++++-- htdocs/accountancy/supplier/list.php | 10 ++-- 4 files changed, 165 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index f063f832f54..aa3a8d691dd 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -29,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; // Load translation files required by the page @@ -65,6 +66,8 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); + /* * Actions @@ -102,7 +105,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -115,16 +118,83 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Customer Invoice lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_sell_p = $objp->code_sell; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_sell_p = $objp->code_sell_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_sell_p = $objp->code_sell_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 127f1795e19..7826d2b1faf 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -221,9 +221,9 @@ $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -249,7 +249,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -420,7 +420,7 @@ if ($result) { $isSellerInEEC = isInEEC($mysoc); - while ( $i < min($num_lines, $limit) ) { + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $objp->code_sell_l = ''; @@ -532,6 +532,7 @@ if ($result) { print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); print ''; + // Country print ''; - // Ref product + // Ref Product print ''; // Description - print ''; $texte.= ''; @@ -130,7 +130,7 @@ class mod_arctic extends ModeleNumRefFicheinter require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // On défini critere recherche compteur + // We define the search criteria of the counter $mask=$conf->global->FICHINTER_ARTIC_MASK; if (! $mask) From 3024919cd6dfcecadb3e27a54f65260f9c030a2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 10:25:23 +0200 Subject: [PATCH 028/110] fix phpcs --- htdocs/core/actions_massactions.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b14bc0f105e..7d8d621ff92 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -266,7 +266,6 @@ if (! $error && $massaction == 'confirm_presend') $objectobj->fetch_thirdparty(); $contactidtosend=array(); foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { - $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); if (!in_array($contactemailid, $contactidtosend)) { $contactidtosend[] = $contactemailid; From be3f0471fff7ec46a1933e82bba5358f9586943b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 11:27:48 +0200 Subject: [PATCH 029/110] Fix phpcs --- htdocs/accountancy/supplier/index.php | 14 +++---- htdocs/mrp/ajax/ajax_bom.php | 53 +++++++++++++++++++++++++++ htdocs/takepos/ajax/ajax.php | 11 +++++- 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 htdocs/mrp/ajax/ajax_bom.php diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index ef720e99130..bfb6e7b02e4 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -140,13 +140,13 @@ if ($action == 'validatehistory') { setEventMessages($db->lasterror(), null, 'errors'); } else { $num_lines = $db->num_rows($result); - + $isSellerInEEC = isInEEC($mysoc); - + $i = 0; while ($i < min($num_lines, 10000)) { // No more than 10000 at once $objp = $db->fetch_object($result); - + // Search suggested account for product/service $suggestedaccountingaccountfor = ''; if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) @@ -168,13 +168,13 @@ if ($action == 'validatehistory') { $suggestedaccountingaccountfor = 'export'; } } - + if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; - + $resqlupdate = $db->query($sqlupdate); if (! $resqlupdate) { @@ -183,11 +183,11 @@ if ($action == 'validatehistory') { break; } } - + $i++; } } - + if ($error) { $db->rollback(); diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php new file mode 100644 index 00000000000..7f5a2040403 --- /dev/null +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -0,0 +1,53 @@ + + * + * 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/mrp/ajax/ajax.php + * \brief Ajax search component for Mrp. It get BOM content. + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + +$idbom = GETPOST('idbom', 'alpha'); +$action = GETPOST('action', 'alpha'); + + +/* + * View + */ + +$object = new BOM($db); +$result=$object->fetch($idbom); +if ($result) +{ + echo json_encode($result); +} +else +{ + echo 'Failed to load category with id='.$idbom; +} diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 69228b5efb5..2a27094bb90 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -45,9 +45,18 @@ $term = GETPOST('term', 'alpha'); if ($action=="getProducts") { $object = new Categorie($db); $result=$object->fetch($category); - if ($result) + if ($result > 0) { $prods = $object->getObjectsInCateg("product"); + // Removed properties we don't need + if (is_array($prods) && count($prods) > 0) + { + foreach($prods as $prod) + { + unset($prod->fields); + unset($prod->db); + } + } echo json_encode($prods); } else From 38aa64836351d83f2d1087cfb561def8ab827d14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 11:38:35 +0200 Subject: [PATCH 030/110] Autofill the MO with data from BOM --- htdocs/mrp/ajax/ajax_bom.php | 7 +++++-- htdocs/mrp/mo_card.php | 32 ++++++++++++++++++++++++++------ htdocs/mrp/mo_document.php | 1 - htdocs/mrp/mo_list.php | 1 - htdocs/mrp/mo_note.php | 1 - 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php index 7f5a2040403..761a54876ee 100644 --- a/htdocs/mrp/ajax/ajax_bom.php +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -43,9 +43,12 @@ $action = GETPOST('action', 'alpha'); $object = new BOM($db); $result=$object->fetch($idbom); -if ($result) +if ($result > 0) { - echo json_encode($result); + // We remove properties we don't need in answer + unset ($object->fields); + unset ($object->db); + echo json_encode($object); } else { diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index f15b45b96e5..15a1aeff0a1 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 @@ -204,16 +203,37 @@ if ($action == 'create') dol_fiche_end(); - print ' + ?> - '; + '; print ''; diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 09f34ae583e..351274de4b8 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 2f32058a41f..81cb781ccff 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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/mrp/mo_note.php b/htdocs/mrp/mo_note.php index a006f79a609..d7429a4da86 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- * * 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 48f5970c7aea369119874fa8f903e354c6350f65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 14:43:39 +0200 Subject: [PATCH 031/110] Debug net measure --- htdocs/product/card.php | 74 ++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5ee8c502009..f8f64decbfa 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -73,6 +73,7 @@ $ref=GETPOST('ref', 'alpha'); $type=GETPOST('type', 'int'); $action=(GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $socid=GETPOST('socid', 'int'); $duration_value = GETPOST('duration_value', 'int'); @@ -357,8 +358,18 @@ if (empty($reshook)) $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; + if (! empty($backtopage)) + { + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; // Old method + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } else { @@ -950,6 +961,7 @@ else print ''; if (! empty($modBarCodeProduct->code_auto)) print ''; + print ''; if ($type==1) $title=$langs->trans("NewService"); else $title=$langs->trans("NewProduct"); @@ -1070,12 +1082,6 @@ else print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); print ''; - // Net Measure - print ''; - // Brut Weight print ''; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print ''; + } } // Units @@ -1450,18 +1465,12 @@ else print $form->selectarray('finished', $statutarray, $object->finished); print ''; - // Net Measure - print ''; - // Brut Weight print ''; + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length @@ -1488,6 +1497,15 @@ else print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2); print ''; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print ''; + } } // Units if($conf->global->PRODUCT_USE_UNITS) @@ -1863,17 +1881,6 @@ else print $object->getLibFinished(); print ''; - // Net Measure - print '\n"; + if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Brut Length @@ -1930,6 +1938,20 @@ else } print "\n"; } + + if (! empty($conf->global->PRODUCT_ADD_NET_MEASURE)) + { + // Net Measure + print '
'; print ''; print ''; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 04f45f8de4b..656f6fb7a28 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -169,6 +169,7 @@ ToValidate=To validate NotValidated=Not validated Save=Save SaveAs=Save As +SaveAndStay=Save and stay TestConnection=Test connection ToClone=Clone ConfirmClone=Choose data you want to clone: diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1eff07edb39..52dae7ba666 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1236,12 +1236,18 @@ if ($action == 'updatecss') setEventMessages($langs->trans("Saved"), null, 'mesgs'); } - $action='preview'; - - if ($backtopage) + if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect { - header("Location: ".$backtopage); - exit; + $action='preview'; + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + } + else + { + $action = 'editcss'; } } } @@ -2105,6 +2111,7 @@ if (! GETPOST('hide_websitemenu')) if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm'))) { + if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; if ($action != 'preview') print ''; From 0c5fbdf29d8571d41fabbef9f2fa4cd73b2c2e50 Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Sun, 20 Oct 2019 19:18:39 -0500 Subject: [PATCH 018/110] Translate french documentation --- htdocs/societe/class/societe.class.php | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2b4ae2bb7a0..c999c9016f4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -821,7 +821,7 @@ class Societe extends CommonObject * Update parameters of third party * * @param int $id Id of company (deprecated, use 0 here and call update on an object loaded by a fetch) - * @param User $user Utilisateur qui demande la mise a jour + * @param User $user User who requests the update * @param int $call_trigger 0=no, 1=yes * @param int $allowmodcodeclient Inclut modif code client et code compta * @param int $allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur @@ -1638,13 +1638,13 @@ class Societe extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Definit la societe comme un client + * Defines the company as a customer * - * @param float $remise Valeur en % de la remise - * @param string $note Note/Motif de modification de la remise - * @param User $user Utilisateur qui definie la remise + * @param float $remise Value in % of the discount + * @param string $note Note/Reason for changing the discount + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK */ public function set_remise_client($remise, $note, User $user) @@ -1652,7 +1652,7 @@ class Societe extends CommonObject // phpcs:enable global $conf, $langs; - // Nettoyage parametres + // Parameter cleaning $note=trim($note); if (! $note) { @@ -1668,7 +1668,7 @@ class Societe extends CommonObject $now=dol_now(); - // Positionne remise courante + // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql.= " SET remise_client = '".$this->db->escape($remise)."'"; $sql.= " WHERE rowid = " . $this->id; @@ -1680,7 +1680,7 @@ class Societe extends CommonObject return -1; } - // Ecrit trace dans historique des remises + // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; @@ -1701,13 +1701,13 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Definit la societe comme un client + * Defines the company as a customer * - * @param float $remise Valeur en % de la remise - * @param string $note Note/Motif de modification de la remise - * @param User $user Utilisateur qui definie la remise + * @param float $remise Value in % of the discount + * @param string $note Note/Reason for changing the discount + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK */ public function set_remise_supplier($remise, $note, User $user) @@ -1715,7 +1715,7 @@ class Societe extends CommonObject // phpcs:enable global $conf, $langs; - // Nettoyage parametres + // Parameter cleaning $note=trim($note); if (! $note) { @@ -1731,7 +1731,7 @@ class Societe extends CommonObject $now=dol_now(); - // Positionne remise courante + // Position current discount $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql.= " SET remise_supplier = '".$this->db->escape($remise)."'"; $sql.= " WHERE rowid = " . $this->id; @@ -1743,7 +1743,7 @@ class Societe extends CommonObject return -1; } - // Ecrit trace dans historique des remises + // Writes trace in discount history $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier"; $sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; @@ -1827,10 +1827,10 @@ class Societe extends CommonObject } /** - * Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe + * Returns amount of included taxes of the current discounts/credits available from the company * - * @param User $user Filtre sur un user auteur des remises - * @param string $filter Filtre autre + * @param User $user Filter on a user author of discounts + * @param string $filter Other filter * @param integer $maxvalue Filter on max value for discount * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return int <0 if KO, Credit note amount otherwise @@ -2264,13 +2264,13 @@ class Societe extends CommonObject return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $statut Id statut + * @param int $statut Status id * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Libelle du statut + * @return string Status label */ public function LibStatut($statut, $mode = 0) { @@ -2429,11 +2429,11 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie la liste des contacts de cette societe + * Returns the contact list of this company * - * @return array tableau des contacts + * @return array array of contacts */ public function contact_array() { @@ -2463,11 +2463,11 @@ class Societe extends CommonObject return $contacts; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie la liste des contacts de cette societe + * Returns the contact list of this company * - * @return array $contacts tableau des contacts + * @return array $contacts array of contacts */ public function contact_array_objects() { @@ -2608,9 +2608,9 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Attribut un code client a partir du module de controle des codes. + * Assigns a customer code from the code control module. * Return value is stored into this->code_client * * @param Societe $objsoc Object thirdparty @@ -2640,9 +2640,9 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Attribut un code fournisseur a partir du module de controle des codes. + * Assigns a vendor code from the code control module. * Return value is stored into this->code_fournisseur * * @param Societe $objsoc Object thirdparty @@ -2671,10 +2671,10 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie si un code client est modifiable en fonction des parametres - * du module de controle des codes. + * Check if a client code is editable based on the parameters of the + * code control module. * * @return int 0=No, 1=Yes */ @@ -2708,9 +2708,9 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie si un code fournisseur est modifiable dans configuration du module de controle des codes + * Check if a vendor code is editable in the code control module configuration * * @return int 0=No, 1=Yes */ @@ -2818,11 +2818,11 @@ class Societe extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoie un code compta, suivant le module de code compta. - * Peut etre identique a celui saisit ou genere automatiquement. - * A ce jour seule la generation automatique est implementee + * Returns an accounting code, following the accounting code module. + * May be identical to the one entered or generated automatically. + * To date only the automatic generation is implemented * * @param string $type Type of thirdparty ('customer' or 'supplier') * @return string Code compta si ok, 0 si aucun, <0 si ko @@ -2847,7 +2847,7 @@ class Societe extends CommonObject $classname = $conf->global->SOCIETE_CODECOMPTA_ADDON; $mod = new $classname; - // Defini code compta dans $mod->code + // Set code count in $mod->code $result = $mod->get_code($this->db, $this, $type); if ($type == 'customer') $this->code_compta = $mod->code; @@ -2999,9 +2999,9 @@ class Societe extends CommonObject else return false; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...) + * Check the validity of a professional identifier according to the country of the company (siren, siret, ...) * * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) * @param Societe $soc Objet societe @@ -3017,7 +3017,7 @@ class Societe extends CommonObject if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; - // Verifie SIREN si pays FR + // Check SIREN if country FR if ($idprof == 1 && $soc->country_code == 'FR') { $chaine=trim($this->idprof1); @@ -3207,11 +3207,11 @@ class Societe extends CommonObject return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Indique si la societe a des projets + * Indicates if the company has projects * - * @return bool true si la societe a des projets, false sinon + * @return bool true if the company has projects, false otherwise */ public function has_projects() { @@ -3313,9 +3313,9 @@ class Societe extends CommonObject return isInEEC($this); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Charge la liste des categories fournisseurs + * Load the list of provider categories * * @return int 0 if success, <> 0 if error */ @@ -3704,11 +3704,11 @@ class Societe extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set prospect level * - * @param User $user Utilisateur qui definie la remise + * @param User $user User who sets the discount * @return int <0 if KO, >0 if OK * @deprecated Use update function instead */ From 9b1385ee8687163218f78cfb40921be2f575693a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 03:37:44 +0200 Subject: [PATCH 019/110] FIX If country not defined keep value empty --- htdocs/accountancy/customer/lines.php | 9 ++++++++- htdocs/accountancy/supplier/lines.php | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3385eb99b0e..6a5196288e2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -358,6 +358,7 @@ if ($result) { // Ref Invoice print '' . $facture_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print '' . $objp->tva_intra . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print '' . $objp->tva_intra . ''; $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; print $labelcountry; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index faa48ac9176..ef720e99130 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page @@ -63,6 +64,7 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); /* @@ -99,7 +101,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -112,16 +114,85 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Supplier Invoice Lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; + $sql.= " aa.rowid as aarowid,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/supplier/index.php'); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_p = $objp->code_buy; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + //$objp->code_buy_p = $objp->code_buy_intra; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_intra; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + //$objp->code_buy_p = $objp->code_buy_export; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_export; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index f43749f6958..3c61b7a0608 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -222,7 +222,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -307,8 +307,8 @@ if ($result) { $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); if ($search_day) $param.='&search_day='.urlencode($search_day); if ($search_month) $param.='&search_month='.urlencode($search_month); @@ -463,7 +463,7 @@ if ($result) { print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; if ($product_static->id > 0) print $product_static->getNomUrl(1); @@ -471,7 +471,7 @@ if ($result) { print ''; + print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); From 776bfabfc4a15a8faa78093104bfe7a80dfa3a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 03:37:44 +0200 Subject: [PATCH 021/110] FIX If country not defined keep value empty --- htdocs/accountancy/customer/lines.php | 9 ++++++++- htdocs/accountancy/supplier/lines.php | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0e7047b84de..3da2c129e30 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -370,6 +370,7 @@ if ($result) { // Ref Invoice print '' . $facture_static->getNomUrl(1) . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print '' . $objp->tva_intra . '' . dol_print_date($db->jdate($objp->datef), 'day') . '' . vatrate($objp->tva_tx.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')) . '' . $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + if ($objp->country_code) + { + print $langs->trans("Country".$objp->country_code) .' ('.$objp->country_code.')'; + } + print '' . $objp->tva_intra . ''; $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; print $labelcountry; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index bc632118da7..f1bf4377f42 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page @@ -63,6 +64,7 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); /* @@ -100,7 +102,7 @@ if ($action == 'validatehistory') { $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - if ($db->type == 'pgsql') { + /*if ($db->type == 'pgsql') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; @@ -113,16 +115,85 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; - } + }*/ + + // Supplier Invoice Lines (must be same request than into page list.php for manual binding) + $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; + $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; + $sql.= " aa.rowid as aarowid,"; + $sql.= " co.code as country_code, co.label as country_label,"; + $sql.= " s.tva_intra"; + $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; + $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; + $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; + $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql.= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/supplier/index.php'); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); + $result = $db->query($sql); + if (! $result) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { + $num_lines = $db->num_rows($result); + + $isSellerInEEC = isInEEC($mysoc); + + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_p = $objp->code_buy; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + //$objp->code_buy_p = $objp->code_buy_intra; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_intra; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + //$objp->code_buy_p = $objp->code_buy_export; + $objp->code_buy_p = $objp->code_buy; + //$objp->aarowid_suggest = $objp->aarowid_export; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = 'export'; + } + } + + if ($objp->aarowid_suggest > 0) + { + $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + + $i++; + } + } + + if ($error) + { + $db->rollback(); + } + else { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index d7bfdcc5db3..879b708d32e 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -224,7 +224,7 @@ $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; +$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql.= " AND l.product_type <= 2"; // Add search filter like @@ -321,8 +321,8 @@ if ($result) { $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); if ($search_day) $param.='&search_day='.urlencode($search_day); if ($search_month) $param.='&search_month='.urlencode($search_month); @@ -477,7 +477,7 @@ if ($result) { print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''; if ($product_static->id > 0) print $product_static->getNomUrl(1); @@ -485,7 +485,7 @@ if ($result) { print ''; + print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description); From 6a55aedf594f8bd0a7e33a783805b07dd3c13937 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Mon, 21 Oct 2019 08:46:07 +0200 Subject: [PATCH 023/110] Create file. List of parcels details related to an expedition. --- .../mysql/tables/llx_expedition_package.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_expedition_package.sql diff --git a/htdocs/install/mysql/tables/llx_expedition_package.sql b/htdocs/install/mysql/tables/llx_expedition_package.sql new file mode 100644 index 00000000000..b897e2ab312 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_expedition_package.sql @@ -0,0 +1,18 @@ +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_parcel_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; From 16bd837dc7403c403cfcea671487a8165d6a70ae Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Mon, 21 Oct 2019 08:54:59 +0200 Subject: [PATCH 024/110] create file Dictionary of package type --- htdocs/install/mysql/tables/llx_c_shipment_package_type | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_c_shipment_package_type diff --git a/htdocs/install/mysql/tables/llx_c_shipment_package_type b/htdocs/install/mysql/tables/llx_c_shipment_package_type new file mode 100644 index 00000000000..e510352eba2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_shipment_package_type @@ -0,0 +1,9 @@ +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; From c2357405445977d00db6039fd080decf158ec797 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Mon, 21 Oct 2019 08:58:13 +0200 Subject: [PATCH 025/110] parcel to package --- htdocs/install/mysql/tables/llx_expedition_package.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_expedition_package.sql b/htdocs/install/mysql/tables/llx_expedition_package.sql index b897e2ab312..2f8d97a26a9 100644 --- a/htdocs/install/mysql/tables/llx_expedition_package.sql +++ b/htdocs/install/mysql/tables/llx_expedition_package.sql @@ -5,7 +5,7 @@ create table llx_expedition_package fk_expedition integer NOT NULL, description varchar(255), --Description of goods in the package (required by the custom) value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) - fk_parcel_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + fk_package_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) height float, -- height width float, -- width size float, -- depth From db22cdb8ea86bd6312ddbd7dfa042ee2704bd37b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 21 Oct 2019 09:43:34 +0200 Subject: [PATCH 026/110] internationalization --- .../core/modules/fichinter/doc/pdf_soleil.modules.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 623f67ddd72..ac59960cf59 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -25,7 +25,7 @@ /** * \file htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php * \ingroup ficheinter - * \brief Fichier de la classe permettant de generer les fiches d'intervention au modele Soleil + * \brief File of Class to build interventions documents with model Soleil */ require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -142,7 +142,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->option_condreg = 0; // Display payment terms $this->option_codeproduitservice = 0; // Display product-service code $this->option_multilang = 1; // Available in several languages - $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company $this->emetteur=$mysoc; @@ -266,7 +266,7 @@ class pdf_soleil extends ModelePDFFicheinter $tab_height = 130; $tab_height_newpage = 150; - // Affiche notes + // Display notes $notetoshow=empty($object->note_public)?'':$object->note_public; if ($notetoshow) { @@ -394,7 +394,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -573,7 +573,7 @@ class pdf_soleil extends ModelePDFFicheinter pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); From a0303e903a96799858858778b12fd0e859619a0c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 21 Oct 2019 09:53:42 +0200 Subject: [PATCH 027/110] internationalization --- htdocs/core/modules/fichinter/mod_arctic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 6ec78b1ac1a..4d8ea35e4d9 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -82,7 +82,7 @@ class mod_arctic extends ModeleNumRefFicheinter $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("InterventionCard"), $langs->transnoentities("InterventionCard")); $tooltip.=$langs->trans("GenericMaskCodes5"); - // Parametrage du prefix + // Setting the prefix $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("NetMeasure").''; - print ''; - print $formproduct->selectMeasuringUnits("net_measure_units", "net_measure", GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); - print '
'.$langs->trans("Weight").''; print ''; @@ -1108,6 +1114,15 @@ else print $formproduct->selectMeasuringUnits("volume_units", "volume", GETPOSTISSET('volume_units')?GETPOST('volume_units', 'alpha'):'0', 0, 2); print '
'.$langs->trans("NetMeasure").''; + print ''; + print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units')?GETPOST('net_measure_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), ''); + print '
'.$langs->trans("NetMeasure").''; - print ' '; - print $form->selectUnits($object->net_measure_units, 'units'); - //print $formproduct->selectMeasuringUnits("net_measure_units", "weight", $object->net_measure_units, 0, 2); - print '
'.$langs->trans("Weight").''; print ' '; print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print '
'.$langs->trans("NetMeasure").''; + print ' '; + print $formproduct->selectMeasuringUnits($object->net_measure_units, ''); + print '
'.$langs->trans("NetMeasure").''; - if ($object->net_measure != '') - { - print $object->net_measure." ".measuring_units_string(0, "weight", $object->net_measure_units); - } - else - { - print ' '; - } - // Brut Weight print '
'.$langs->trans("Weight").''; if ($object->weight != '') @@ -1885,6 +1892,7 @@ else print ' '; } print "
'.$langs->trans("NetMeasure").''; + if ($object->net_measure != '') + { + print $object->net_measure." ".measuring_units_string(0, "weight", $object->net_measure_units); + } + else + { + print ' '; + } + } } // Unit From e261d6329576421f1dde3b45e3b16863b05d0516 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 14:44:39 +0200 Subject: [PATCH 032/110] NEW Can add a button "Create" after combo of object with modulebuilder. --- htdocs/bom/bom_card.php | 15 +++--- htdocs/bom/class/bom.class.php | 2 +- htdocs/core/actions_addupdatedelete.inc.php | 5 +- htdocs/core/class/commonobject.class.php | 49 +++++++++++++------ htdocs/core/class/cunits.class.php | 3 +- htdocs/core/class/html.form.class.php | 12 +++-- .../template/class/myobject.class.php | 5 +- .../modulebuilder/template/myobject_card.php | 19 +++---- htdocs/mrp/class/mo.class.php | 8 +-- htdocs/mrp/mo_card.php | 15 +++--- .../product/class/html.formproduct.class.php | 16 +++--- htdocs/product/inventory/inventory.php | 7 +++ htdocs/projet/card.php | 8 +-- htdocs/societe/card.php | 7 +-- htdocs/theme/eldy/btn.inc.php | 1 + htdocs/theme/eldy/global.inc.php | 3 +- htdocs/theme/md/btn.inc.php | 1 + htdocs/theme/md/style.css.php | 3 +- 18 files changed, 110 insertions(+), 69 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0949fa1a334..17fae31ef7d 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -79,6 +79,7 @@ $permissionnote=$user->rights->bom->write; // Used by the include of actions_set $permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php $permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php $permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); /* @@ -93,11 +94,11 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->bom->write; - $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; - if (empty($backtopage)) { - if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record @@ -218,7 +219,7 @@ if ($action == 'create') dol_fiche_head(array(), ''); - print ''."\n"; + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; @@ -252,7 +253,9 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'."\n"; + //$object->fields['keyfield']['disabled'] = 1; + + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 07ae81e2994..02e39149364 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -91,7 +91,7 @@ class BOM extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), 'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), 'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index e87333e4c01..d618a0702c8 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -32,6 +32,8 @@ if ($cancel) { + /*var_dump($cancel); + var_dump($backtopage);exit;*/ if (! empty($backtopage)) { header("Location: ".$backtopage); @@ -80,7 +82,8 @@ if ($action == 'add' && ! empty($permissiontoadd)) if ($result > 0) { // Creation OK - $urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist; + $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; + $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation header("Location: ".$urltogo); exit; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cc8ae3238c0..95fa2c2fc59 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5556,16 +5556,20 @@ abstract class CommonObject $type=''; $param = array(); $param['options']=array(); - $size =$this->fields[$key]['size']; + $reg=array(); + $size = $this->fields[$key]['size']; // Because we work on extrafields - if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ - $param['options']=array($reg[1].':'.$reg[2]=>'N'); - $type ='link'; - } elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) { - $param['options']=array($reg[1].':'.$reg[2]=>'N'); + if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[2].':'.$reg[3].':'.$reg[4].':'.$reg[5] => 'N'); + $type ='link'; + } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[2].':'.$reg[3].':'.$reg[4] => 'N'); + $type ='link'; + } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[2].':'.$reg[3] => 'N'); $type ='link'; } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) { - $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N'); $type ='sellist'; } elseif(preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { $param['options']=array(); @@ -6078,16 +6082,26 @@ abstract class CommonObject } elseif ($type == 'link') { - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' + $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]' + $param_list_array = explode(':', $param_list[0]); $showempty=(($required && $default != '')?0:1); - $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty); - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + + $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', '', '', 0, empty($val['disabled'])?0:1); + + if (! empty($param_list_array[2])) // If we set to add a create button { - list($class,$classfile)=explode(':', $param_list[0]); - if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); - else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php', 1); - $out.=''; - // TODO Add Javascript code to add input fields contents to new elements urls + if (! GETPOSTISSET('backtopage') && empty($val['disabled'])) // To avoid to open several infinitely the 'Create Object' button and to avoid to have button if field is protected by a "disabled". + { + list($class,$classfile)=explode(':', $param_list[0]); + if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); + else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); + $paramforthenewlink = ''; + $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action','aZ09'):''); + $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id','int'):''); + $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; + // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page + $out.=''; + } } } elseif ($type == 'password') @@ -6167,6 +6181,7 @@ abstract class CommonObject $label = $val['label']; $type = $val['type']; $size = $val['css']; + $reg = array(); // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) @@ -6182,7 +6197,9 @@ abstract class CommonObject $computed=$val['computed']; $unique=$val['unique']; $required=$val['required']; - $param=$val['param']; + $param=array(); + $param['options']=array(); + if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 1837f82a2a4..07cd778d3a0 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -234,8 +234,6 @@ class CUnits // extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); - $records=array(); - $sql = 'SELECT'; $sql.= " t.rowid,"; $sql.= " t.code,"; @@ -273,6 +271,7 @@ class CUnits // extends CommonObject if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit, $offset); } + $resql = $this->db->query($sql); if ($resql) { $this->records=array(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6d26e585435..66646ee4c4f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5824,10 +5824,11 @@ class Form * @param string $morecss More CSS * @param string $moreparams More params provided to ajax call * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @param int $disabled 1=Html component is disabled * @return string Return HTML string * @see selectForFormsList() select_thirdparty */ - public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0) + public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0) { global $conf, $user; @@ -5868,12 +5869,12 @@ class Form $out.= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); $out.= ''; if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"'; - $out.= ''; + $out.= ''; } else { // Immediate load of all database - $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo); + $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled); } return $out; @@ -5893,10 +5894,11 @@ class Form * @param string $moreparams More params provided to ajax call * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param int $outputmode 0=HTML select string, 1=Array + * @param int $disabled 1=Html component is disabled * @return string Return HTML string * @see selectForForms() */ - public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0) + public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0) { global $conf, $langs, $user; @@ -5948,7 +5950,7 @@ class Form } // Construct $out and $outarray - $out.= ''."\n"; // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4 $textifempty=' '; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1f83308f1d7..d5c7c9d2e4e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -64,7 +64,7 @@ class MyObject extends CommonObject /** - * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'type' if the field format ('integer', 'integer:Class:pathtoclass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') * 'label' the translation key. * 'enabled' is a condition when the field must be managed. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) @@ -81,6 +81,7 @@ class MyObject extends CommonObject * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. */ // BEGIN MODULEBUILDER PROPERTIES @@ -94,7 +95,7 @@ class MyObject extends CommonObject 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'showoncombobox'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 5727d596a6d..e39022814e7 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -105,10 +105,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php -$permissionedit=$user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd=$user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->mymodule->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->mymodule->write; // Used by the include of actions_dellink.inc.php +$permissionedit = $user->rights->mymodule->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->mymodule->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); @@ -124,11 +125,11 @@ if (empty($reshook)) { $error=0; - $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); - if (empty($backtopage)) { - if (empty($id) && $action != 'add' && $action != 'create') $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record @@ -226,7 +227,7 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'."\n"; + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 5bac2320b24..8d356775a78 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -96,7 +96,7 @@ class Mo extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), @@ -104,11 +104,11 @@ class Mo extends CommonObject 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), - 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), ); public $rowid; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 15a1aeff0a1..03e32174207 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -108,7 +108,7 @@ $permissionnote=$user->rights->mrp->write; // Used by the include of actions_set $permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php $permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php $permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php - +$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); /* @@ -125,11 +125,12 @@ if (empty($reshook)) { $error=0; - $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); - if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/mrp/mo_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record @@ -257,7 +258,9 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); - print '
'."\n"; + $object->fields['fk_bom']['disabled'] = 1; + + print '
'."\n"; // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 33bf1240c92..8684c23511e 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -332,7 +332,7 @@ class FormProduct * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume, time * @param string $default Preselected value - * @param int $adddefault Add empty unit called "Default" + * @param int|string $adddefault 1=Add empty unit called "Default", ''=Add empty value * @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) * @return string */ @@ -346,24 +346,26 @@ class FormProduct // TODO Use a cache require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); + + $filter = array(); + $filter['t.active'] = 1; + if ($measuring_style) $filter['t.unit_type'] = $measuring_style; + $result = $measuringUnits->fetchAll( '', '', 0, 0, - array( - 't.unit_type' => $measuring_style, - 't.active' => 1, - ) + $filter ); if ($result < 0) { dol_print_error($db); return -1; } else { $return .= '
'; - $coldisplay++; +if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { + print ''; + $coldisplay++; if (($line->info_bits & 2) == 2 || ! empty($disableedit)) { } else { print 'id.'#line_'.$line->id.'">'.img_edit().''; From 8e474701c1312501e8949fc3f45b7f2ac629d661 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Oct 2019 15:49:08 +0200 Subject: [PATCH 034/110] Fix missing token --- htdocs/core/class/html.formfile.class.php | 13 +++++++++---- htdocs/langs/en_US/mrp.lang | 1 + .../modulebuilder/template/class/myobject.class.php | 2 +- htdocs/mrp/class/mo.class.php | 4 ++-- htdocs/mrp/mo_agenda.php | 2 +- htdocs/mrp/mo_card.php | 2 +- htdocs/mrp/mo_document.php | 2 +- htdocs/mrp/mo_note.php | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8a0341135c7..82bfe17bf69 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -231,10 +231,10 @@ class FormFile if (empty($usewithoutform)) { - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; } $out .= '
'; @@ -1168,6 +1168,7 @@ class FormFile if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) { print ''; + print ''; print ''; print ''; print ''; @@ -1485,6 +1486,7 @@ class FormFile if (! empty($addfilterfields)) { print ''; + print ''; print ''; } @@ -1772,10 +1774,13 @@ class FormFile $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); $param .= (isset($object->id)?'&id=' . $object->id : ''); + print ''."\n"; + // Show list of associated links print load_fiche_titre($langs->trans("LinkedFiles")); print ''; + print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 9fbbe6a7161..5d51be56e56 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -1,4 +1,5 @@ Mrp=Manufacturing Orders +MO=Manufacturing Order MRPDescription=Module to manage Manufacturing Orders (MO). MRPArea=MRP Area MrpSetupPage=Setup of module MO diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d5c7c9d2e4e..0111bfa142e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -96,7 +96,7 @@ class MyObject extends CommonObject 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), - 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500), diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 8d356775a78..9a9dc00f316 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -97,8 +97,8 @@ class Mo extends CommonObject 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>62, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',), diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index aab1ff10581..be68bb26d35 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -142,7 +142,7 @@ if ($object->id > 0) $head = moPrepareHead($object); - dol_fiche_head($head, 'agenda', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'agenda', $langs->trans("MO"), -1, $object->picto); // Object card // ------------------------------------------------------------ diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 03e32174207..b12ee490fe7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -285,7 +285,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $res = $object->fetch_optionals(); $head = moPrepareHead($object); - dol_fiche_head($head, 'card', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'card', $langs->trans("MO"), -1, $object->picto); $formconfirm = ''; diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 351274de4b8..40b92c2371a 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -110,7 +110,7 @@ if ($object->id) */ $head = moPrepareHead($object); - dol_fiche_head($head, 'document', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'document', $langs->trans("MO"), -1, $object->picto); // Build file list diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index d7429a4da86..8cc5a9d50bd 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -95,7 +95,7 @@ if ($id > 0 || ! empty($ref)) $head = moPrepareHead($object); - dol_fiche_head($head, 'note', $langs->trans("Mo"), -1, $object->picto); + dol_fiche_head($head, 'note', $langs->trans("MO"), -1, $object->picto); // Object card // ------------------------------------------------------------ From 5e7d6152501dcd0685a56eba7acbeac71a69f500 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 21 Oct 2019 21:06:48 +0200 Subject: [PATCH 035/110] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3b0e0289c18..1d820e23b72 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5924,7 +5924,19 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = '__THIRDPARTY_CODE_CLIENT__'; + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = '__THIRDPARTY_CODE_FOURNISSEUR__'; $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; + $substitutionarray['__THIRDPARTY_PHONE__'] = '__THIRDPARTY_PHONE__'; + $substitutionarray['__THIRDPARTY_FAX__'] = '__THIRDPARTY_FAX__'; + $substitutionarray['__THIRDPARTY_ADRESSE__'] = '__THIRDPARTY_ADRESSE__'; + $substitutionarray['__THIRDPARTY_ZIP__'] = '__THIRDPARTY_ZIP__'; + $substitutionarray['__THIRDPARTY_TOWN__'] = '__THIRDPARTY_TOWN__'; + $substitutionarray['__THIRDPARTY_SIREN__'] = '__THIRDPARTY_SIREN__'; + $substitutionarray['__THIRDPARTY_SIRET__'] = '__THIRDPARTY_SIRET__'; + $substitutionarray['__THIRDPARTY_APE__'] = '__THIRDPARTY_APE__'; + $substitutionarray['__THIRDPARTY_RCSRM__'] = '__THIRDPARTY_RCSRM__'; + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; } if (! empty($conf->adherent->enabled)) { @@ -6013,14 +6025,38 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object)?$object->code_client:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->name_fax:''); + $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object)?$object->address:''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:''); + $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object)?$object->idprof1:''); + $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object)?$object->idprof2:''); + $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object)?$object->idprof3:''); + $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->phone:''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->name_fax:''); + $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object->thirdparty)?$object->address:''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->zip:''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->town:''); + $substitutionarray['__THIRDPARTY_SIREN__'] = (is_object($object->thirdparty)?$object->idprof1:''); + $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object->thirdparty)?$object->idprof2:''); + $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object->thirdparty)?$object->idprof3:''); + $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object->thirdparty)?$object->idprof4:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->tva_intra:''); } if (is_object($object->project) && $object->project->id > 0) From 6205913056c059094b210bd9c9e3c92918e4fa97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 02:31:47 +0200 Subject: [PATCH 036/110] FIX CVE-2019-17578 CVE-2019-17577 CVE-2019-17576 --- htdocs/admin/mails.php | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 997b0e97bdb..dd67b138da5 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -65,27 +65,27 @@ complete_substitutions_array($substitutionarrayfortest, $langs); if ($action == 'update' && empty($_POST["cancel"])) { - dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT", 'int'), 'chaine', 0, '', $conf->entity); // Send mode parameters - dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE", 'aZ09'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED", 'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", 'alphanohtml'), 'chaine', 0, '', $conf->entity); // Content parameters - dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE', 'alphanohtml'), 'chaine', 0, '', $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -101,8 +101,8 @@ $mode='emailfortest'; $trackid=(($action == 'testhtml')?"testhtml":"test"); include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -if ($action == 'presend' && GETPOST('trackid') == 'test') $action='test'; -if ($action == 'presend' && GETPOST('trackid') == 'testhtml') $action='testhtml'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action='test'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action='testhtml'; @@ -823,7 +823,7 @@ else $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromid=$user->id; $formmail->fromalsorobot=1; - $formmail->fromtype=(GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); + $formmail->fromtype=(GETPOSTISSET('fromtype')?GETPOST('fromtype', 'aZ09'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); $formmail->withfromreadonly=1; $formmail->withsubstit=1; $formmail->withfrom=1; @@ -849,7 +849,7 @@ else $formmail->param["returnurl"]=$_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode")=='init') + if (GETPOST("mode", "aZ09")=='init') { $formmail->clear_attached_files(); } From 2fb521667c3b2b3418f641595047c466ec093fed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 02:42:08 +0200 Subject: [PATCH 037/110] Doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index f2add251e28..c430b258cda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ FIX: #12041 FIX: #12054 FIX: #12083 FIX: #12088 +FIX: CVE-2019-17578 CVE-2019-17577 CVE-2019-17576 FIX: Clean the + of categories on the product view only in POS module FIX: access to public interface when origin email has an alias. FIX: Alias name is not into the email recipient label. From 6aa2ceac1ab1cf48a5e4f33b59d74d1da33e6f35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 02:53:29 +0200 Subject: [PATCH 038/110] Fix phpcs --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/mrp/ajax/ajax_bom.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 95fa2c2fc59..abd8e38ce97 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6096,8 +6096,8 @@ abstract class CommonObject if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php', 1); else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.strtolower($class).'_card.php', 1); $paramforthenewlink = ''; - $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action','aZ09'):''); - $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id','int'):''); + $paramforthenewlink .= (GETPOSTISSET('action')?'&action='.GETPOST('action', 'aZ09'):''); + $paramforthenewlink .= (GETPOSTISSET('id')?'&id='.GETPOST('id', 'int'):''); $paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; // TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page $out.=''; diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php index 761a54876ee..76f1572353b 100644 --- a/htdocs/mrp/ajax/ajax_bom.php +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -46,8 +46,8 @@ $result=$object->fetch($idbom); if ($result > 0) { // We remove properties we don't need in answer - unset ($object->fields); - unset ($object->db); + unset($object->fields); + unset($object->db); echo json_encode($object); } else From c5490e22d1bc4dfee0e2f5df696adffa59e178de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 02:58:55 +0200 Subject: [PATCH 039/110] Fiw trans --- htdocs/langs/en_US/boxes.lang | 1 + htdocs/mrp/class/mo.class.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b7f7037c94d..eee7d7dcfac 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -66,6 +66,7 @@ NoContractedProducts=No products/services contracted NoRecordedContracts=No recorded contracts NoRecordedInterventions=No recorded interventions BoxLatestSupplierOrders=Latest purchase orders +BoxLatestSupplierOrdersAwaitingReception=Latest Purchase Orders (with a pending reception) NoSupplierOrder=No recorded purchase order BoxCustomersInvoicesPerMonth=Customer Invoices per month BoxSuppliersInvoicesPerMonth=Vendor Invoices per month diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9a9dc00f316..18c8e1fa5dc 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -475,7 +475,7 @@ class Mo extends CommonObject $result = ''; - $label = '' . $langs->trans("Mo") . ''; + $label = '' . $langs->trans("MO") . ''; $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; From aa4afcfe8ab9e624b0c04ebd153fdf8d49cf2be1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 03:46:08 +0200 Subject: [PATCH 040/110] NEW Can set a filter on object linked in modulebuilder. --- htdocs/api/class/api.class.php | 1 + htdocs/core/class/html.form.class.php | 67 +++++++++++++++---- .../template/class/myobject.class.php | 3 +- htdocs/mrp/class/mo.class.php | 2 +- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 7660144f7ca..0247514b2a4 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -290,6 +290,7 @@ class DolibarrApi if (count($tmp) < 3) return ''; $tmpescaped=$tmp[2]; + $regbis = array(); if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) { $tmpescaped = "'".$db->escape($regbis[1])."'"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 66646ee4c4f..b4c52117ea9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5815,7 +5815,7 @@ class Form * Generic method to select a component from a combo list. * This is the generic method that will replace all specific existing methods. * - * @param string $objectdesc Objectclassname:Objectclasspath + * @param string $objectdesc ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]] * @param string $htmlname Name of HTML select component * @param int $preselectedvalue Preselected value (ID of element) * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) @@ -5837,12 +5837,16 @@ class Form $InfoFieldList = explode(":", $objectdesc); $classname=$InfoFieldList[0]; $classpath=$InfoFieldList[1]; + $addcreatebuttonornot=empty($InfoFieldList[2])?0:$InfoFieldList[2]; + $filter=empty($InfoFieldList[3])?'':$InfoFieldList[3]; + if (! empty($classpath)) { dol_include_once($classpath); if ($classname && class_exists($classname)) { $objecttmp = new $classname($this->db); + $objecttmp->filter = $filter; } } if (! is_object($objecttmp)) @@ -5855,12 +5859,12 @@ class Form if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT - dol_syslog(get_class($this)."::selectForForms", LOG_DEBUG); + dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG); $out=''; if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->$confkeyforautocompletemode) && ! $forcecombo) { - $objectdesc=$classname.':'.$classpath; + $objectdesc=$classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; // No immediate load of all database @@ -5873,18 +5877,46 @@ class Form } else { - // Immediate load of all database + // Immediate load of table record. Note: filter is inside $objecttmp->filter $out.=$this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled); } return $out; } + /** + * Function to forge a SQL criteria + * + * @param array $matches Array of found string by regex search. Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.nature:is:NULL" + * @return string Forged criteria. Example: "t.field like 'abc%'" + */ + protected static function forgeCriteriaCallback($matches) + { + global $db; + + //dol_syslog("Convert matches ".$matches[1]); + if (empty($matches[1])) return ''; + $tmp=explode(':', $matches[1]); + if (count($tmp) < 3) return ''; + + $tmpescaped=$tmp[2]; + $regbis = array(); + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) + { + $tmpescaped = "'".$db->escape($regbis[1])."'"; + } + else + { + $tmpescaped = $db->escape($tmpescaped); + } + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; + } + /** * Output html form to select an object. * Note, this function is called by selectForForms or by ajax selectobject.php * - * @param Object $objecttmp Object + * @param Object $objecttmp Object to knwo the table to scan for combo. * @param string $htmlname Name of HTML select component * @param int $preselectedvalue Preselected value (ID of element) * @param string $showempty ''=empty values not allowed, 'string'=value show if we allow empty values (for example 'All', ...) @@ -5902,6 +5934,8 @@ class Form { global $conf, $langs, $user; + //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled"; + $prefixforautocompletemode=$objecttmp->element; if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode='company'; $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT @@ -5925,19 +5959,28 @@ class Form // Search data $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; if ($objecttmp->ismultientitymanaged == 2) - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE 1=1"; if(! empty($objecttmp->ismultientitymanaged)) $sql.= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; - if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id)) - { - if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id; - else $sql.= " AND t.fk_soc = ".$user->societe_id; + if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->socid)) { + if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->socid; + else $sql.= " AND t.fk_soc = ".$user->socid; } if ($searchkey != '') $sql.=natural_search(explode(',', $fieldstoshow), $searchkey); - if ($objecttmp->ismultientitymanaged == 2) - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND t.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($objecttmp->ismultientitymanaged == 2) { + if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND t.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + } + if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + /*if (! DolibarrApi::_checkFilters($objecttmp->filter)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter); + }*/ + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")"; + } $sql.=$this->db->order($fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); + //print $sql; // Build output string $resql=$this->db->query($sql); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 0111bfa142e..1a6fa3915ae 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -64,7 +64,8 @@ class MyObject extends CommonObject /** - * 'type' if the field format ('integer', 'integer:Class:pathtoclass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'enabled' is a condition when the field must be managed. * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 18c8e1fa5dc..384893269ce 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -107,7 +107,7 @@ class Mo extends CommonObject 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce",), 'date_start_planned' => array('type'=>'datetime', 'label'=>'DateStartPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'notnull'=>-1, 'index'=>1, 'help'=>'KeepEmptyForAsap'), 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), - 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), + 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), ); From b5aab50194b42c91e5dec6c4bb068c5a1f253447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9onard?= Date: Tue, 22 Oct 2019 06:07:11 +0200 Subject: [PATCH 041/110] Add index on fk_origin_line column of llx_expeditiondet table --- htdocs/install/mysql/tables/llx_expeditiondet.key.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_expeditiondet.key.sql b/htdocs/install/mysql/tables/llx_expeditiondet.key.sql index 915602f51ae..b37ae457fe3 100644 --- a/htdocs/install/mysql/tables/llx_expeditiondet.key.sql +++ b/htdocs/install/mysql/tables/llx_expeditiondet.key.sql @@ -19,4 +19,5 @@ ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition); +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line); ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid); From 1ba9c31b375389c2a5dc2bad1e4c7811bb4b6401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 12:34:03 +0200 Subject: [PATCH 042/110] Add migration of index --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 6d9f7f7c97f..ddf16cc3d56 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -49,6 +49,8 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2'); -- For v11 +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_origin_line (fk_origin_line); + ALTER TABLE llx_rights_def ADD COLUMN module_position INTEGER NOT NULL DEFAULT 0; ALTER TABLE llx_rights_def ADD COLUMN family_position INTEGER NOT NULL DEFAULT 0; From b2bbee55f1d47db8d4c7d6afc526ea3789f1e4e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 12:37:36 +0200 Subject: [PATCH 043/110] Fix phpcs --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1d820e23b72..0f61cd5c3bb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5936,7 +5936,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_SIRET__'] = '__THIRDPARTY_SIRET__'; $substitutionarray['__THIRDPARTY_APE__'] = '__THIRDPARTY_APE__'; $substitutionarray['__THIRDPARTY_RCSRM__'] = '__THIRDPARTY_RCSRM__'; - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; } if (! empty($conf->adherent->enabled)) { @@ -6046,7 +6046,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->phone:''); $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->name_fax:''); $substitutionarray['__THIRDPARTY_ADRESSE__'] = (is_object($object->thirdparty)?$object->address:''); @@ -6056,7 +6056,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_SIRET__'] = (is_object($object->thirdparty)?$object->idprof2:''); $substitutionarray['__THIRDPARTY_APE__'] = (is_object($object->thirdparty)?$object->idprof3:''); $substitutionarray['__THIRDPARTY_RCSRM__'] = (is_object($object->thirdparty)?$object->idprof4:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->tva_intra:''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->tva_intra:''); } if (is_object($object->project) && $object->project->id > 0) From 6638b361d4e2bc419cb006dbad04398db066b50e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 12:44:19 +0200 Subject: [PATCH 044/110] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2068981c98d..2fcb9e0a6d8 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -203,7 +203,7 @@ if ($action == 'valid' && $user->rights->facture->creer) $payment->amounts[$invoice->id] = $amountofpayment; // If user has not used change control, add total invoice payment - if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $invoice->getRemainToPay(); + if ($amountofpayment == 0) $payment->amounts[$invoice->id] = $remaintopay; $payment->paiementid=$paiementid; $payment->num_payment=$invoice->ref; From d098efb8fe50b213eb5ab884e6b49e8c3f353275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 22 Oct 2019 12:52:08 +0200 Subject: [PATCH 045/110] getListOfShipmentMethods: Add rowid field in sql select --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 6223744955e..50102b76b93 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -390,7 +390,7 @@ class Setup extends DolibarrApi public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - $sql = "SELECT t.code, t.libelle, t.description, t.tracking"; + $sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql.= " WHERE t.active = ".$active; // Add sql filters From 5ad7ca5620fd8ad03608abf96e2d6dd1476cad08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 13:43:24 +0200 Subject: [PATCH 046/110] Code more generic around setting projet on a card --- htdocs/api/class/api.class.php | 1 + htdocs/core/class/commonobject.class.php | 10 +++++-- htdocs/don/list.php | 2 +- htdocs/expensereport/card.php | 14 +++++----- htdocs/fichinter/card-rec.php | 4 +-- .../template/class/myobject.class.php | 1 + .../modulebuilder/template/myobject_card.php | 16 +++++++++++- htdocs/mrp/lib/mrp_mo.lib.php | 7 ++++- htdocs/mrp/mo_card.php | 26 ++++++++++++++----- .../stock/class/mouvementstock.class.php | 3 ++- htdocs/product/stock/movement_list.php | 8 +++--- htdocs/theme/eldy/global.inc.php | 6 ++++- 12 files changed, 71 insertions(+), 27 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 0247514b2a4..074216dee3e 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -178,6 +178,7 @@ class DolibarrApi unset($object->lines[$i]->cond_reglement); unset($object->lines[$i]->fk_delivery_address); unset($object->lines[$i]->fk_projet); + unset($object->lines[$i]->fk_project); unset($object->lines[$i]->thirdparty); unset($object->lines[$i]->user); unset($object->lines[$i]->model_pdf); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index abd8e38ce97..838670b58c0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1882,13 +1882,19 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if ($this->table_element == 'actioncomm') + if (! empty($this->fields['fk_project'])) // Common case + { + if ($projectid) $sql.= ' SET fk_project = '.$projectid; + else $sql.= ' SET fk_project = NULL'; + $sql.= ' WHERE rowid = '.$this->id; + } + elseif ($this->table_element == 'actioncomm') // Special case for actioncomm { if ($projectid) $sql.= ' SET fk_project = '.$projectid; else $sql.= ' SET fk_project = NULL'; $sql.= ' WHERE id = '.$this->id; } - else + else // Special case for old architecture objects { if ($projectid) $sql.= ' SET fk_projet = '.$projectid; else $sql.= ' SET fk_projet = NULL'; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 5728e6fc2aa..bdc6c45168d 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -211,7 +211,7 @@ if ($resql) if (! empty($conf->projet->enabled)) { $langs->load("projects"); - print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "fk_projet", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 95b9e0cd1f5..7a62903dfe6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -57,7 +57,7 @@ $confirm = GETPOST('confirm', 'alpha'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); -$fk_projet=GETPOST('fk_projet', 'int'); +$fk_project=GETPOST('fk_project', 'int'); $vatrate=GETPOST('vatrate', 'alpha'); $ref=GETPOST("ref", 'alpha'); $comments=GETPOST('comments', 'none'); @@ -145,7 +145,7 @@ if (empty($reshook)) } $action=''; - $fk_projet=''; + $fk_project=''; $date_start=''; $date_end=''; $date=''; @@ -1232,7 +1232,7 @@ if (empty($reshook)) $type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees // Insert line - $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_projet, $fk_c_exp_tax_cat, $type, $fk_ecm_files); + $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files); if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records @@ -1257,7 +1257,7 @@ if (empty($reshook)) unset($vatrate); unset($comments); unset($fk_c_type_fees); - unset($fk_projet); + unset($fk_project); unset($date); } else { @@ -1334,7 +1334,7 @@ if (empty($reshook)) $rowid = $_POST['rowid']; $type_fees_id = GETPOST('fk_c_type_fees', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int'); - $projet_id = $fk_projet; + $projet_id = $fk_project; $comments = GETPOST('comments', 'none'); $qty = GETPOST('qty', 'int'); $vatrate = GETPOST('vatrate', 'alpha'); @@ -2372,7 +2372,7 @@ else if (! empty($conf->projet->enabled)) { print '
'; } @@ -2527,7 +2527,7 @@ else if (! empty($conf->projet->enabled)) { print ''; } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index fcdf155955d..caead930491 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -158,12 +158,10 @@ if ($action == 'add') { // on récupère les enregistrements $object->fetch($id); - // on transfert les données de l'un vers l'autre if ($object->socid > 0) { $newinter->socid=$object->socid; - $newinter->fk_projet=$object->fk_projet; - $newinter->fk_project=$object->fk_projet; + $newinter->fk_project=$object->fk_project; $newinter->fk_contrat=$object->fk_contrat; } else { $newinter->socid=GETPOST("socid"); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 1a6fa3915ae..f26f44f4837 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -97,6 +97,7 @@ class MyObject extends CommonObject 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'), 'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'), + 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index e39022814e7..c53fe528849 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -142,6 +142,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; @@ -310,7 +322,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project if (! empty($conf->projet->enabled)) { @@ -355,6 +367,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Common attributes //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes. Fields from hook formObjectOptions and Extrafields. diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php index 6189761269e..fe29c774f44 100644 --- a/htdocs/mrp/lib/mrp_mo.lib.php +++ b/htdocs/mrp/lib/mrp_mo.lib.php @@ -36,11 +36,16 @@ function moPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$object->id; + $head[$h][1] = $langs->trans("Production"); + $head[$h][2] = 'production'; + $h++; + if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index b12ee490fe7..5b67482502b 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -58,6 +58,7 @@ if (! $res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); @@ -143,6 +144,18 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + // Actions to send emails $trigger_name='MO_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; @@ -160,7 +173,7 @@ if (empty($reshook)) */ $form=new Form($db); -$formfile=new FormFile($db); +$formproject=new FormProjets($db); llxHeader('', $langs->trans('Mo'), ''); @@ -248,7 +261,7 @@ if ($action == 'create') // Part to edit record if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("Mo"), '', 'cubes'); + print load_fiche_titre($langs->trans("MO"), '', 'cubes'); print ''; print ''; @@ -341,9 +354,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* // Ref bis $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); // Project if (! empty($conf->projet->enabled)) { @@ -374,7 +387,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } } - */ $morehtmlref.=''; @@ -387,7 +399,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; - $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; - $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); print '
'."\n"; // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; + $keyforbreak='qty'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; // Other attributes diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 24d8e89e03b..a85b375b085 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -585,7 +585,7 @@ class MouvementStock extends CommonObject $sql .= " t.batch,"; $sql .= " t.eatby,"; $sql .= " t.sellby,"; - $sql .= " t.fk_projet"; + $sql .= " t.fk_projet as fk_project"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql.= ' WHERE 1 = 1'; //if (null !== $ref) { @@ -618,6 +618,7 @@ class MouvementStock extends CommonObject $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); + $this->fk_project = $obj->fk_project; } // Retreive all extrafield diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ef307842017..5303fa78a6c 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -429,7 +429,7 @@ $sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e. $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; $sql.= " m.type_mouvement,"; -$sql.= " m.fk_projet,"; +$sql.= " m.fk_projet as fk_project,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields @@ -859,7 +859,7 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; @@ -1115,9 +1115,9 @@ if ($resql) } if (! empty($arrayfields['m.fk_projet']['checked'])) { - // fk_projet + // fk_project print ''; } // Action column diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 89df0813ca4..277f6ca038e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5788,7 +5788,7 @@ div.tabsElem a.tab { } .dropdown dd ul { - max-width: 300px; + max-width: 350px; } } /* rule to reduce top menu - 2nd reduction: Reduce width of top menu icons again */ @@ -5817,6 +5817,10 @@ div.tabsElem a.tab { margin-top: 2px; left: 4px; } + + .dropdown dd ul { + max-width: 300px; + } } /* rule to reduce top menu - 3rd reduction: The menu for user is on left */ @media only screen and (max-width: global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3) ? round($nbtopmenuentries * 47, 0) + 130 : $conf->global->THEME_ELDY_WITDHOFFSET_FOR_REDUC3; ?>px) /* reduction 3 */ From f0844222ed845ce4c348f40848360175a15ae2f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 13:52:18 +0200 Subject: [PATCH 047/110] Work on MRP --- htdocs/mrp/mo_agenda.php | 14 +- htdocs/mrp/mo_card.php | 47 +--- htdocs/mrp/mo_document.php | 14 +- htdocs/mrp/mo_list.php | 1 + htdocs/mrp/mo_note.php | 14 +- htdocs/mrp/mo_production.php | 421 +++++++++++++++++++++++++++++++++++ 6 files changed, 426 insertions(+), 85 deletions(-) create mode 100644 htdocs/mrp/mo_production.php diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index be68bb26d35..a86d062c5e4 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -23,19 +23,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 5b67482502b..29003b3304f 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -42,19 +42,7 @@ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; @@ -168,8 +156,6 @@ if (empty($reshook)) /* * View - * - * Put here all code to build page */ $form=new Form($db); @@ -319,23 +305,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } - // Confirmation of action xxxx - if ($action == 'xxx') - { - $formquestion=array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -499,20 +468,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } - /* - if ($user->rights->mrp->write) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; - } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ - // Delete (need delete permission, or if draft, just need create/modify permission) if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) { diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 40b92c2371a..3732754a62f 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -22,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 81cb781ccff..96f19540a95 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -42,6 +42,7 @@ // Load Dolibarr environment require '../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 8cc5a9d50bd..f815dfbaef6 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -22,19 +22,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +require '../main.inc.php'; dol_include_once('/mrp/class/mo.class.php'); dol_include_once('/mrp/lib/mrp_mo.lib.php'); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php new file mode 100644 index 00000000000..70de7155f39 --- /dev/null +++ b/htdocs/mrp/mo_production.php @@ -0,0 +1,421 @@ + + * + * 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 mo_production.php + * \ingroup mrp + * \brief Page to make production on a MO + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies + + +// Load Dolibarr environment +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +dol_include_once('/mrp/class/mo.class.php'); +dol_include_once('/mrp/lib/mrp_mo.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("mrp", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'mocard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Initialize technical objects +$object=new Mo($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('mocard','globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + +if (empty($action) && empty($id) && empty($ref)) $action='view'; + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0); +//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); + +$permissionnote=$user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->mrp->write; // Used by the include of actions_dellink.inc.php +$permissionedit=$user->rights->mrp->write; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd=$user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0); + + +/* + * Actions + * + * Put here all code to do according to value of "action" parameter + */ + +$parameters=array(); +$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'); + +if (empty($reshook)) +{ + $error=0; + + $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + //var_dump($backurlforlist);exit; + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; + else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__'); + } + $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, delete or clone + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + + if ($action == 'set_thirdparty' && $permissiontoadd) + { + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY'); + } + if ($action == 'classin' && $permissiontoadd) + { + $object->setProject(GETPOST('projectid', 'int')); + } + + // Actions to send emails + $trigger_name='MO_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MO_TO'; + $trackid='mo'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + + +/* + * View + */ + +$form=new Form($db); +$formproject=new FormProjets($db); + +llxHeader('', $langs->trans('Mo'), ''); + +// Example : Adding jquery code +print ''; + + + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) +{ + $res = $object->fetch_optionals(); + + $head = moPrepareHead($object); + dol_fiche_head($head, 'production', $langs->trans("MO"), -1, $object->picto); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + } + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'xxx') + { + $formquestion=array(); + /* + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); + */ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/ + // Thirdparty + $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->mrp->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + print '
'; print '  '; print ''; - if ($objp->fk_projet != 0) print $movement->get_origin($objp->fk_projet, 'project'); + if ($objp->fk_project != 0) print $movement->get_origin($objp->fk_project, 'project'); print '
'."\n"; + + // Common attributes + $keyforbreak='qty'; + unset($object->fields['fk_project']); + unset($object->fields['fk_soc']); + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + print ''; + + print '
'; + + dol_fiche_end(); + + + /* + * Lines + */ + + if (! empty($object->table_element_line)) + { + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (! empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print ''; + } + + if (! empty($object->lines)) + { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine(1, $mysoc, $soc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (! empty($object->lines) && $object->status == 0 && $permissiontoadd && $action != 'selectlines' && $action != 'editline') + { + print '
'; + } + print '
'; + + print "
\n"; + } + + + // Buttons for actions + /* + if ($action != 'presend' && $action != 'editline') { + print '
'."\n"; + $parameters=array(); + $reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + + if (empty($reshook)) + { + // Send + print '' . $langs->trans('SendMail') . ''."\n"; + + // Modify + if (! empty($user->rights->mrp->write)) + { + print ''.$langs->trans("Modify").''."\n"; + } + else + { + print ''.$langs->trans('Modify').''."\n"; + } + + // Clone + if (! empty($user->rights->mrp->write)) + { + print ''; + } + + // Delete (need delete permission, or if draft, just need create/modify permission) + if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write))) + { + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; + } + } + print '
'."\n"; + }*/ + + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + + + print '
'; + + + + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); From af8f5948f0dd63520d5a372707ca06037a200f26 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Tue, 22 Oct 2019 13:54:50 +0200 Subject: [PATCH 048/110] Package tables llx_expedition_package and llx_c_shipment_package_type --- .../install/mysql/migration/10.0.0-11.0.0.sql | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 6d9f7f7c97f..ea818a1ab04 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -326,3 +326,33 @@ create table llx_fichinterdet_rec ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type; ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start; + +--List of parcels details related to an expedition +create table llx_expedition_package +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_expedition integer NOT NULL, + description varchar(255), --Description of goods in the package (required by the custom) + value double(24,8) DEFAULT 0,--Value (Price of the content, for insurance & custom) + fk_parcel_type integer, -- Type or package, linked to llx_c_shipment_parcel_type (eg: 1=enveloppe, 2=package, 3=palette, 4=other) + height float, -- height + width float, -- width + size float, -- depth + size_units integer, -- unit of all sizes (height, width, depth) + weight float, -- weight + weight_units integer, -- unit of weight + dangerous_goods smallint DEFAULT 0, -- 0 = no dangerous goods or 1 = Explosives, 2 = Flammable Gases, 3 = Flammable Liquids, 4 = Flammable solids, 5 = Oxidizing, 6 = Toxic & Infectious, 7 = Radioactive, 8 = Corrosives, 9 = Miscellaneous (see https://en.wikipedia.org/wiki/Dangerous_goods). I'm not sure if just register 0 (no) or 1 (yes) is enough. + tail_lift smallint DEFAULT 0, -- 0 = no tail lift required to load/unload package(s), 1 = a tail lift is required to load/unload package(s). Sometime tail lift load can be different than tail lift delivery so maybe adding a new table line. + rang integer DEFAULT 0 +)ENGINE=innodb; + +--Dictionary of package type +create table llx_c_shipment_package_type +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(50) NOT NULL, -- Short name + description varchar(255), -- Description + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id +)ENGINE=innodb; + From 8242281ef899dff325bf021c5cc8d20af2990769 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 14:39:33 +0200 Subject: [PATCH 049/110] Close #12096 --- htdocs/core/lib/functions.lib.php | 52 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0f61cd5c3bb..88c20a2aaa8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5917,6 +5917,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF__'] = '__REF__'; $substitutionarray['__REF_CLIENT__'] = '__REF_CLIENT__'; $substitutionarray['__REF_SUPPLIER__'] = '__REF_SUPPLIER__'; + $substitutionarray['__NOTE_PUBLIC__'] = '__NOTE_PUBLIC__'; + $substitutionarray['__NOTE_PRIVATE__'] = '__NOTE_PRIVATE__'; $substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__'; if (! empty($conf->societe->enabled)) @@ -5937,6 +5939,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__THIRDPARTY_APE__'] = '__THIRDPARTY_APE__'; $substitutionarray['__THIRDPARTY_RCSRM__'] = '__THIRDPARTY_RCSRM__'; $substitutionarray['__THIRDPARTY_TVAINTRA__'] = '__THIRDPARTY_TVAINTRA__'; + /*$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = '__THIRDPARTY_NOTE_PUBLIC__'; + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = '__THIRDPARTY_NOTE_PRIVATE__';*/ } if (! empty($conf->adherent->enabled)) { @@ -5944,12 +5948,16 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; + $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } if (! empty($conf->projet->enabled)) { $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; + /*$substitutionarray['__PROJECT_NOTE_PUBLIC__'] = '__PROJECT_NOTE_PUBLIC__'; + $substitutionarray['__PROJECT_NOTE_PRIVATE__'] = '__PROJECT_NOTE_PRIVATE__';*/ } if (! empty($conf->contrat->enabled)) { @@ -5982,13 +5990,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); + $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); + $substitutionarray['__NOTE_PRIVATE__'] = (isset($object->note_private) ? $object->note_private : null); + + $substitutionarray['__DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); + // For backward compatibility $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - - // TODO Remove this - $msgishtml = 0; + $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); + $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); $birthday = dol_print_date($object->birth, 'day'); @@ -5996,22 +6008,22 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, { $substitutionarray['__MEMBER_ID__']=$object->id; if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); - $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; - $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); - $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; - $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; - $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; - $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town; - $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country; - $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email; - $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday; - $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo; - $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login; - $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass; - $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; - $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; - $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; + $substitutionarray['__MEMBER_FIRSTNAME__']=$object->firstname; + $substitutionarray['__MEMBER_LASTNAME__']=$object->lastname; + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$object->getFullName($outputlangs); + $substitutionarray['__MEMBER_COMPANY__']=$object->societe; + $substitutionarray['__MEMBER_ADDRESS__']=$object->address; + $substitutionarray['__MEMBER_ZIP__']=$object->zip; + $substitutionarray['__MEMBER_TOWN__']=$object->town; + $substitutionarray['__MEMBER_COUNTRY__']=$object->country; + $substitutionarray['__MEMBER_EMAIL__']=$object->email; + $substitutionarray['__MEMBER_BIRTH__']=$birthday; + $substitutionarray['__MEMBER_PHOTO__']=$object->photo; + $substitutionarray['__MEMBER_LOGIN__']=$object->login; + $substitutionarray['__MEMBER_PASSWORD__']=$object->pass; + $substitutionarray['__MEMBER_PHONE__']=$object->phone; + $substitutionarray['__MEMBER_PHONEPRO__']=$object->phone_perso; + $substitutionarray['__MEMBER_PHONEMOBILE__']=$object->phone_mobile; $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); From f9c86256dcd52f0ba18cdf5e7d6b9b8126311b6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 15:21:41 +0200 Subject: [PATCH 050/110] FIX #12198 --- htdocs/contact/card.php | 49 ++++++++++++++++++- htdocs/contact/class/contact.class.php | 8 +-- .../public/emailing/mailing-unsubscribe.php | 2 +- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 123f9f91f5e..f0f18ffc672 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -191,6 +191,7 @@ if (empty($reshook)) $object->facebook = GETPOST("facebook", 'alpha'); $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); @@ -230,6 +231,22 @@ if (empty($reshook)) // Categories association $contcats = GETPOST('contcats', 'array'); $object->setCategories($contcats); + + // Add mass emailing flag into table mailing_unsubscribe + if (GETPOST('no_email', 'int') && $object->email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if (empty($obj->nb)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } } } @@ -360,6 +377,7 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id", 'int'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); @@ -387,6 +405,35 @@ if (empty($reshook)) $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); + $no_email = GETPOST('no_email', 'int'); + + // Update mass emailing flag into table mailing_unsubscribe + if (GETPOSTISSET('no_email') && $object->email) + { + if ($no_email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } + else + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); + $resql=$db->query($sql); + } + + $object->no_email = $no_email; + } + $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 3465b3478a0..77361c43263 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -80,7 +80,7 @@ class Contact extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; public $address; @@ -88,16 +88,17 @@ class Contact extends CommonObject public $town; public $state_id; // Id of department - public $state_code; // Code of department + public $state_code; // Code of department public $state; // Label of department public $poste; // Position public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $statut; // 0=inactif, 1=actif public $code; public $email; + public $no_email; // 1 = contact has globaly unsubscribe of all mass emailings public $skype; public $photo; public $jabberid; @@ -394,6 +395,7 @@ class Contact extends CommonObject if (! $error && $this->user_id > 0) { + // If contact is linked to a user $tmpobj = new User($this->db); $tmpobj->fetch($this->user_id); $usermustbemodified = 0; diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index adb6aa03c8d..48cdd1508e8 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -115,7 +115,7 @@ if (! empty($tag) && ($unsuscrib=='1')) */ // Update status communication of email (new usage) - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; $resql=$db->query($sql); //if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed From 84c8b6b5d1f6a9871ec79c610728807c9d1197f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 15:21:41 +0200 Subject: [PATCH 051/110] FIX #12198 --- htdocs/contact/card.php | 49 ++++++++++++++++++- htdocs/contact/class/contact.class.php | 8 +-- .../public/emailing/mailing-unsubscribe.php | 2 +- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 76d0e3911b5..aaf1cd0a2b9 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -191,6 +191,7 @@ if (empty($reshook)) $object->facebook = GETPOST("facebook", 'alpha'); $object->linkedin = GETPOST("linkedin", 'alpha'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->phone_pro = GETPOST("phone_pro", 'alpha'); $object->phone_perso = GETPOST("phone_perso", 'alpha'); $object->phone_mobile = GETPOST("phone_mobile", 'alpha'); @@ -230,6 +231,22 @@ if (empty($reshook)) // Categories association $contcats = GETPOST('contcats', 'array'); $object->setCategories($contcats); + + // Add mass emailing flag into table mailing_unsubscribe + if (GETPOST('no_email', 'int') && $object->email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if (empty($obj->nb)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } } } @@ -359,6 +376,7 @@ if (empty($reshook)) $object->country_id = GETPOST("country_id", 'int'); $object->email = GETPOST("email", 'alpha'); + $object->no_email = GETPOST("no_email", "int"); $object->skype = GETPOST("skype", 'alpha'); $object->twitter = GETPOST("twitter", 'alpha'); $object->facebook = GETPOST("facebook", 'alpha'); @@ -385,6 +403,35 @@ if (empty($reshook)) $categories = GETPOST('contcats', 'array'); $object->setCategories($categories); + $no_email = GETPOST('no_email', 'int'); + + // Update mass emailing flag into table mailing_unsubscribe + if (GETPOSTISSET('no_email') && $object->email) + { + if ($no_email) + { + $sql="SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE entity IN (".getEntity('mailing', 0).") AND email = '".$db->escape($object->email)."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + $noemail = $obj->nb; + if (empty($noemail)) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email)."', ".$db->escape(getEntity('mailing', 0)).", '".$db->idate(dol_now())."')"; + $resql=$db->query($sql); + } + } + } + else + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = '".$db->escape($object->email)."' AND entity = ".$db->escape(getEntity('mailing', 0)); + $resql=$db->query($sql); + } + + $object->no_email = $no_email; + } + $object->old_lastname=''; $object->old_firstname=''; $action = 'view'; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 18da6bf476d..eb25d0ad712 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -79,7 +79,7 @@ class Contact extends CommonObject 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; public $address; @@ -87,16 +87,17 @@ class Contact extends CommonObject public $town; public $state_id; // Id of department - public $state_code; // Code of department + public $state_code; // Code of department public $state; // Label of department public $poste; // Position public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $statut; // 0=inactif, 1=actif public $code; public $email; + public $no_email; // 1 = contact has globaly unsubscribe of all mass emailings public $skype; public $photo; public $jabberid; @@ -383,6 +384,7 @@ class Contact extends CommonObject if (! $error && $this->user_id > 0) { + // If contact is linked to a user $tmpobj = new User($this->db); $tmpobj->fetch($this->user_id); $usermustbemodified = 0; diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index a66281f7687..ce06237ee03 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -115,7 +115,7 @@ if (! empty($tag) && ($unsuscrib=='1')) */ // Update status communication of email (new usage) - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$obj->entity.", '".$obj->email."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; $resql=$db->query($sql); //if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed From 22a14e7bf7b881d4422f242e82f2684047333a4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 15:40:29 +0200 Subject: [PATCH 052/110] Fix closig tag --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index f4016dc4f5a..50b64e1d63d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2663,7 +2663,7 @@ else if ($user->rights->societe->creer) { - print ''.$langs->trans("Modify").''."\n"; + print ''.$langs->trans("Modify").''."\n"; } if (! empty($conf->adherent->enabled)) From 44ced0cbeb95f2a934c85569906931e261ec5bee Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 22 Oct 2019 16:11:59 +0200 Subject: [PATCH 053/110] FIX : if we search something with global search, and after with form fields, we want to stay on Products AND Services list --- htdocs/product/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 43188c5fe7c..6e870c05740 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -450,6 +450,7 @@ if ($resql) if($type == Product::TYPE_SERVICE) $rightskey='service'; if($user->rights->{$rightskey}->creer) { + $oldtype=$type; if ($type === "") { $newcardbutton.= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); $type = Product::TYPE_SERVICE; @@ -457,6 +458,7 @@ if ($resql) $label='NewProduct'; if($type == Product::TYPE_SERVICE) $label='NewService'; $newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); + $type=$oldtype; } print '
'; From 4dd5c00ec0c0a732f881990fd5a8be8ee539f995 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 22 Oct 2019 16:25:10 +0200 Subject: [PATCH 054/110] Internationalization --- htdocs/don/class/don.class.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 70fabfcdc29..9707229393e 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,8 +61,16 @@ class Don extends CommonObject * @var string String with name of icon for object don. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'generic'; - + + /** + * @var string Date of the donation + */ public $date; + + /** + * amount of donation + * @var double + */ public $amount; /** @@ -133,7 +141,7 @@ class Don extends CommonObject /** - * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * Returns the donation status label (draft, valid, abandoned, paid) * * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle @@ -145,7 +153,7 @@ class Don extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * * @param int $statut Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto From c17604437999e8a72bf63e560adc98b3555d29b1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 22 Oct 2019 14:26:26 +0000 Subject: [PATCH 055/110] Fixing style errors. --- htdocs/don/class/don.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 9707229393e..fc95009846b 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -61,12 +61,12 @@ class Don extends CommonObject * @var string String with name of icon for object don. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'generic'; - + /** * @var string Date of the donation */ public $date; - + /** * amount of donation * @var double From b88968520b09397eba46b3339ee733dbeaeab370 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 17:08:37 +0200 Subject: [PATCH 056/110] Move code of extrafields to the new architecture --- htdocs/asset/type.php | 2 +- htdocs/comm/action/list.php | 13 ++-- htdocs/compta/bank/bankentries_list.php | 13 ++-- htdocs/compta/bank/list.php | 13 ++-- htdocs/contact/list.php | 15 ++-- .../core/class/commondocgenerator.class.php | 34 ++++----- htdocs/fichinter/list.php | 13 ++-- htdocs/fourn/facture/list.php | 4 +- htdocs/product/stock/productlot_list.php | 9 ++- htdocs/projet/ganttview.php | 2 + htdocs/projet/list.php | 11 +-- htdocs/projet/tasks.php | 37 +++++----- htdocs/projet/tasks/time.php | 21 +++--- htdocs/reception/card.php | 10 ++- htdocs/reception/list.php | 72 +++++-------------- htdocs/resource/list.php | 20 +++--- htdocs/societe/list.php | 15 ++-- htdocs/user/list.php | 13 ++-- 18 files changed, 153 insertions(+), 164 deletions(-) diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 459bd2d8edc..916939b378e 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -615,7 +615,7 @@ if ($rowid > 0) if (empty($reshook)) { print '

'; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->element]['label'] as $key=>$label) { if (isset($_POST["options_" . $key])) { if (is_array($_POST["options_" . $key])) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index a7fe41a478c..194c9a2ae33 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -138,13 +138,16 @@ $arrayfields=array( 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 61278b9b9f5..71eb5faa6c9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -157,13 +157,16 @@ $arrayfields=array( 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile'?1:0), 'position'=>1020), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 6a143d4a8d1..1b06a0e222b 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -98,13 +98,16 @@ $arrayfields=array( 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9f3dc206447..c571b4938a0 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -181,15 +181,18 @@ $arrayfields=array( 'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + -$object=new Contact($db); if (($id > 0 || ! empty($ref)) && $action != 'add') { $result=$object->fetch($id, $ref); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index ee5b97c502a..0a31bb79408 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -224,15 +224,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); } @@ -298,15 +298,15 @@ abstract class CommonDocGenerator $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attribute_label as $key => $label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) { - if ($extrafields->attribute_type[$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; } $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); } @@ -765,30 +765,30 @@ abstract class CommonDocGenerator { // phpcs:enable global $conf; - foreach($extrafields->attribute_label as $key=>$label) + foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attribute_type[$key] == 'price') + if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); //Add value to store price with currency $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } - elseif($extrafields->attribute_type[$key] == 'select') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - elseif($extrafields->attribute_type[$key] == 'checkbox') { + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray=explode(',', $object->array_options['options_'.$key]); $output=array(); - foreach($extrafields->attribute_param[$key]['options'] as $keyopt=>$valopt) { + foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { if (in_array($keyopt, $valArray)) { $output[]=$valopt; } } $object->array_options['options_'.$key] = implode(', ', $output); } - elseif($extrafields->attribute_type[$key] == 'date') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { if (strlen($object->array_options['options_'.$key])>0) { @@ -806,7 +806,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'datetime') + elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') { $datetime = $object->array_options['options_'.$key]; $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language @@ -815,7 +815,7 @@ abstract class CommonDocGenerator $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); } - elseif($extrafields->attribute_type[$key] == 'link') + elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') { $id = $object->array_options['options_'.$key]; if ($id != "") diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 7df7eac69b0..d45dadf2589 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -116,13 +116,16 @@ $arrayfields=array( 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 367f360da37..c08178bc932 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -376,9 +376,9 @@ if (! $search_all) $sql.= ' country.code,'; $sql.= " p.rowid, p.ref, p.title"; - foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) //prevent error with sql_mode=only_full_group_by { - $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } else diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 9596c87c9d3..fbbec95f2df 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -105,13 +105,16 @@ $arrayfields=array( //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Load object if id or ref is provided as parameter if (($id > 0 || ! empty($ref)) && $action != 'add') diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 8b718f1d898..57be29b1bb2 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -377,6 +377,8 @@ if (count($tasksarray)>0) //var_dump($dateformatinput); //var_dump($dateformatinput2); + print '
'; + print '
'; print '
'."\n"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 8524e940f36..2c311de7792 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -76,7 +76,6 @@ $search_categ=GETPOST("search_categ", 'alpha'); $search_ref=GETPOST("search_ref", 'alpha'); $search_label=GETPOST("search_label", 'alpha'); $search_societe=GETPOST("search_societe", 'alpha'); -$search_year=GETPOST("search_year", 'int'); $search_status=GETPOST("search_status", 'int'); $search_opp_status=GETPOST("search_opp_status", 'alpha'); $search_opp_percent=GETPOST("search_opp_percent", 'alpha'); @@ -141,13 +140,16 @@ $arrayfields=array( 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); @@ -175,7 +177,6 @@ if (empty($reshook)) $search_ref=""; $search_label=""; $search_societe=""; - $search_year=""; $search_status=-1; $search_opp_status=-1; $search_opp_amount=''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 2abfea6e64e..2395f5f0bd1 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -66,8 +66,7 @@ $search_progressdeclare=GETPOST('search_progressdeclare'); $object = new Project($db); $taskstatic = new Task($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); +$extrafields = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); @@ -75,9 +74,9 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob if ($id > 0 || ! empty($ref)) { // fetch optionals attributes and labels - $extrafields_project->fetch_name_optionals_label($object->table_element); + $extrafields->fetch_name_optionals_label($object->table_element); } -$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); +$extrafields->fetch_name_optionals_label($taskstatic->table_element); // Security check $socid=0; @@ -115,14 +114,17 @@ $arrayfields=array( 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +// Extra fields project +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -260,8 +262,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) $task->progress = $progress; // Fill array 'array_options' with data from add form - $extrafields->fetch_name_optionals_label($task->table_element); - $ret = $extrafields_task->setOptionalsFromPost(null, $task); + $ret = $extrafields->setOptionalsFromPost(null, $task); $taskid = $task->create($user); @@ -604,9 +605,9 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields_task->attribute_label)) + if (empty($reshook) && ! empty($extrafields[$taskstatic->table_element]['label'])) { - print $taskstatic->showOptionals($extrafields_task, 'edit'); // Do not use $object here that is object of project + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } print '
'; @@ -635,13 +636,15 @@ elseif ($id > 0 || ! empty($ref)) $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); // Extra fields - if (is_array($extrafields_task->attribute_label) && count($extrafields_task->attribute_label)) + if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach($extrafields_task->attribute_label as $key => $val) + foreach($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields_task->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields_task->attribute_label[$key], 'checked'=>(($extrafields_task->attribute_list[$key]<0)?0:1), 'position'=>$extrafields_task->attribute_pos[$key], 'enabled'=>(abs($extrafields_task->attribute_list[$key])!=3 && $extrafields_task->attribute_perms[$key])); + if (! empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } + $arrayfields = dol_sort_array($arrayfields, 'position'); print '
'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2eb6697be82..3dc54cc2223 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -88,11 +88,9 @@ $hookmanager->initHooks(array('projecttasktime','globalcard')); $object = new Task($db); $projectstatic = new Project($db); -$extrafields_project = new ExtraFields($db); -$extrafields_task = new ExtraFields($db); - -$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); -$extrafields_task->fetch_name_optionals_label($object->table_element); +$extrafields = new ExtraFields($db); +$extrafields->fetch_name_optionals_label($projectstatic->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); /* @@ -761,7 +759,6 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('tasktimelist')); - $extrafields = new ExtraFields($db); // Definition of fields for list $arrayfields=array(); @@ -777,13 +774,15 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); $arrayfields['valuebilled'] =array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((! empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT))?0:1) && $projectstatic->usage_bill_time)); // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } + $arrayfields = dol_sort_array($arrayfields, 'position'); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 2c34cd55ee8..0a7ec02afd8 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -102,7 +102,6 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element_line); - // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -869,17 +868,16 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { + // Here $object can be of an object Order + $extrafields->fetch_name_optionals_label($object->table_element); + if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order - $orderExtrafields = new Extrafields($db); - $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); - if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); } print $object->showOptionals($extrafields, 'edit'); } - // Incoterms if (!empty($conf->incoterm->enabled)) { diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index f90f1f73df1..f5f605532b8 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -34,10 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->load("receptions"); -$langs->load("deliveries"); -$langs->load('companies'); -$langs->load('bills'); +$langs->loadLangs(array("sendings", "receptions", "deliveries", 'companies', 'bills')); $socid=GETPOST('socid', 'int'); $massaction=GETPOST('massaction', 'alpha'); @@ -79,12 +76,14 @@ $contextpage='receptionlist'; $viewstatut=GETPOST('viewstatut'); +$object = new Reception($db); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('receptionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label('reception'); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost(null, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -111,15 +110,17 @@ $arrayfields=array( 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_RECEPTION))) ); - // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* @@ -145,7 +146,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_town=''; $search_zip=""; $search_state=""; - $search_type=''; $search_country=''; $search_type_thirdparty=''; $search_billed=''; @@ -628,8 +628,9 @@ if ($resql) print '
'; print ''."\n"; - // Fields title search - print ''; + // Fields title search + // -------------------------------------------------------------------- + print ''; // Ref if (! empty($arrayfields['e.ref']['checked'])) { @@ -694,28 +695,8 @@ if ($resql) print ''; } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -902,23 +883,8 @@ if ($resql) } // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index ee1ec735086..0f003f05eb6 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -113,19 +113,17 @@ $arrayfields = array( ), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach ($extrafields->attribute_label as $key => $val) { - $typeofextrafield=$extrafields->attribute_type[$key]; - if ($typeofextrafield!='separate') { - $arrayfields["ef." . $key] = array( - 'label' => $extrafields->attribute_label[$key], - 'checked' => $extrafields->attribute_list[$key], - 'position' => $extrafields->attribute_pos[$key], - 'enabled' => $extrafields->attribute_perms[$key] - ); - } +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7420c417aae..fe363496213 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -210,15 +210,16 @@ $arrayfields=array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } - -$object = new Societe($db); +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); /* diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 5520465a75d..95b9529017c 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -108,13 +108,16 @@ $arrayfields=array( 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } } +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); // Init search fields $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); From 9b2905fb434595339d71d2ea1c40269fe1fab258 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 22 Oct 2019 17:10:52 +0200 Subject: [PATCH 057/110] Typo and comment --- htdocs/don/class/donstats.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index dc12f5a1d68..039a85e6c26 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/don/class/dontats.class.php + * \file htdocs/don/class/donstats.class.php * \ingroup donations * \brief File of class to manage donations statistics */ @@ -39,11 +39,22 @@ class DonationStats extends Stats */ public $table_element; - public $socid; + public $socid; public $userid; - + + /** + * @var string FROM + */ public $from; + + /** + * @var string field + */ public $field; + + /** + * @var string WHERE + */ public $where; From 5ab6228adbf75168a506ecbc1812cb96c879f568 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 22 Oct 2019 15:12:42 +0000 Subject: [PATCH 058/110] Fixing style errors. --- htdocs/don/class/donstats.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 039a85e6c26..607d6555337 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -41,17 +41,17 @@ class DonationStats extends Stats public $socid; public $userid; - + /** - * @var string FROM + * @var string FROM */ public $from; - + /** * @var string field */ public $field; - + /** * @var string WHERE */ From e7e9898e0db31bf27dddde6d4ff071c7c0d4340c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Oct 2019 18:36:36 +0200 Subject: [PATCH 059/110] FIX Better compatible fix for the trouble of weight / size units --- .../core/class/commondocgenerator.class.php | 18 ++++++++-------- htdocs/core/class/commonobject.class.php | 21 ++++++++++--------- htdocs/core/class/cunits.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/lib/product.lib.php | 18 +++++++++++++++- .../expedition/doc/pdf_espadon.modules.php | 4 ++-- .../expedition/doc/pdf_rouget.modules.php | 4 ++-- .../reception/doc/pdf_squille.modules.php | 4 ++-- htdocs/expedition/card.php | 21 +++++++------------ .../product/actions_card_product.class.php | 8 +++---- htdocs/product/card.php | 10 ++++----- .../product/class/html.formproduct.class.php | 2 +- htdocs/product/class/product.class.php | 12 +++++------ htdocs/reception/card.php | 18 +++++++--------- htdocs/variants/combinations.php | 4 ++-- htdocs/variants/generator.php | 2 +- 17 files changed, 82 insertions(+), 74 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 0a31bb79408..20889e1a742 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -643,11 +643,11 @@ abstract class CommonDocGenerator $array_key.'_tracking_number'=>$object->tracking_number, $array_key.'_tracking_url'=>$object->tracking_url, $array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], - $array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), - $array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), - $array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), - $array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), - $array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), + $array_key.'_weight'=>$object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), + $array_key.'_width'=>$object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), + $array_key.'_height'=>$object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), + $array_key.'_depth'=>$object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), + $array_key.'_size'=>$calculatedVolume.' '.measuringUnitString(0, 'volume'), ); // Add vat by rates @@ -701,10 +701,10 @@ abstract class CommonDocGenerator 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), + 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 838670b58c0..b331c479670 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3823,17 +3823,18 @@ abstract class CommonObject $totalWeight += $weight * $qty * $trueWeightUnit; } else { - if ($weight_units == 99) { - // conversion 1 Pound = 0.45359237 KG - $trueWeightUnit = 0.45359237; - $totalWeight += $weight * $qty * $trueWeightUnit; - } elseif ($weight_units == 98) { - // conversion 1 Ounce = 0.0283495 KG - $trueWeightUnit = 0.0283495; - $totalWeight += $weight * $qty * $trueWeightUnit; - } - else + if ($weight_units == 99) { + // conversion 1 Pound = 0.45359237 KG + $trueWeightUnit = 0.45359237; + $totalWeight += $weight * $qty * $trueWeightUnit; + } elseif ($weight_units == 98) { + // conversion 1 Ounce = 0.0283495 KG + $trueWeightUnit = 0.0283495; + $totalWeight += $weight * $qty * $trueWeightUnit; + } + else { $totalWeight += $weight * $qty; // This may be wrong if we mix different units + } } if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 07cd778d3a0..e37849ff99a 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -247,8 +247,8 @@ class CUnits // extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key=='t.rowid' || $key=='t.active') { - $sqlwhere[] = $key . '='. $value; + if ($key=='t.rowid' || $key=='t.active' || $key=='t.scale') { + $sqlwhere[] = $key . '='. (int) $value; } elseif (strpos($key, 'date') !== false) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b4c52117ea9..cc6cdb78790 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2425,7 +2425,7 @@ class Form $outvalUnits .= ' - ' . $unitToShow; } if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { - $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuringUnitString(0, 'size', $objp->length_units); $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->surface) && $objp->surface_units!==null) { @@ -2802,7 +2802,7 @@ class Form $outvalUnits .= ' - ' . $unitToShow; } if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units!==null) { - $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuring_units_string($objp->length_units, 'size'); + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuringUnitString(0, 'size', $objp->length_units); $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->surface) && $objp->surface_units!==null) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 88c20a2aaa8..09b184ad349 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4624,7 +4624,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round $unit = $forceunitoutput; }*/ - $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string(0, $type, $unit); + $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuringUnitString(0, $type, $unit); return $ret; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 170421cecfd..2a2ee90493b 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -479,6 +479,22 @@ function show_stats_for_company($product, $socid) return $nblines++; } +/** + * Return translation label of a unit key. + * Function kept for backward compatibility. + * + * @param string $scale Scale of unit: '0', '-3', '6', ... + * @param string $measuring_style Style of unit: weight, volume,... + * @param int $unit ID of unit (rowid in llx_c_units table) + * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. + * @return string Unit string + * @see formproduct->selectMeasuringUnits + */ +function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $use_short_label = 0) +{ + return measuringUnitString($unit, $measuring_style, $scale, $use_short_label); +} + /** * Return translation label of a unit key * @@ -489,7 +505,7 @@ function show_stats_for_company($product, $socid) * @return string Unit string * @see formproduct->selectMeasuringUnits */ -function measuring_units_string($unit, $measuring_style = '', $scale = '', $use_short_label = 0) +function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0) { global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 21658ed32d0..9235cddc90f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -509,12 +509,12 @@ class pdf_espadon extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index b180994b7e5..7757e3c9b56 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -525,12 +525,12 @@ class pdf_rouget extends ModelePdfExpedition $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 3a8b1a78a3e..a84b86e908b 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -450,12 +450,12 @@ class pdf_squille extends ModelePdfReception $weighttxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) { - $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->weight_units, "weight"); + $weighttxt=round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units); } $voltxt=''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) { - $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuring_units_string($object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0, "volume"); + $voltxt=round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units?$object->lines[$i]->product->volume_units:0); } $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d1dbb129a19..5ca83e9ebae 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1707,7 +1707,6 @@ elseif ($id || $ref) // Print form confirm print $formconfirm; - // Calculate totalWeight and totalVolume for all products // by adding weight and volume of each product line. $tmparray=$object->getTotalWeightVolume(); @@ -1850,16 +1849,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string(0, "weight", $object->weight_units):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0, "weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print '
'; @@ -1867,7 +1864,7 @@ elseif ($id || $ref) // Width print ''; // Height @@ -1887,7 +1884,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string(0, "size", $object->height_units):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print ''; @@ -1895,7 +1892,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1915,15 +1912,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0, "volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -2409,18 +2404,18 @@ elseif ($id || $ref) // Weight print ''; // Volume print ''; // Size - //print ''; + //print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index a5365545f62..5ac2464995a 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -211,25 +211,25 @@ class ActionsCardProduct // Weight if ($this->object->weight != '') { - $this->tpl['weight'] = $this->object->weight." ".measuring_units_string($this->object->weight_units, "weight"); + $this->tpl['weight'] = $this->object->weight." ".measuringUnitString(0, "weight", $this->object->weight_units); } // Length if ($this->object->length != '') { - $this->tpl['length'] = $this->object->length." ".measuring_units_string($this->object->length_units, "size"); + $this->tpl['length'] = $this->object->length." ".measuringUnitString(0, "size", $this->object->length_units); } // Surface if ($this->object->surface != '') { - $this->tpl['surface'] = $this->object->surface." ".measuring_units_string($this->object->surface_units, "surface"); + $this->tpl['surface'] = $this->object->surface." ".measuringUnitString(0, "surface", $this->object->surface_units); } // Volume if ($this->object->volume != '') { - $this->tpl['volume'] = $this->object->volume." ".measuring_units_string($this->object->volume_units, "volume"); + $this->tpl['volume'] = $this->object->volume." ".measuringUnitString(0, "volume", $this->object->volume_units); } $this->tpl['fiche_end']=dol_get_fiche_end(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f8f64decbfa..abee5f8a678 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1885,7 +1885,7 @@ else print ''; @@ -1469,7 +1467,7 @@ elseif ($id || $ref) // Width print ''; // Height @@ -1489,7 +1487,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units, "size"):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuringUnitString(0, "size", $object->height_units):''; } print ''; @@ -1497,7 +1495,7 @@ elseif ($id || $ref) // Depth print ''; // Volume @@ -1517,15 +1515,13 @@ elseif ($id || $ref) { if ($volumeUnit < 50) { - //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); } - else print $calculatedVolume.' '.measuring_units_string($volumeUnit, "volume"); + else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } if ($totalVolume > 0) { if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; - //print $totalVolume.' '.measuring_units_string(0,"volume"); print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; if ($calculatedVolume) print ')'; @@ -1957,13 +1953,13 @@ elseif ($id || $ref) // Weight print ''; // Volume print ''; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 080242d3137..e5f1d17b8aa 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -350,7 +350,7 @@ if (! empty($id) || ! empty($ref)) print ' - isProduct()) print ''; ?> + isProduct()) print ''; ?>
 '; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string(0, "size", $object->width_units):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string(0, "size", $object->depth_units):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "weight", $lines[$i]->weight_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "volume", $lines[$i]->volume_units); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); else print ' '; print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume").''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).'
'.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string(0, "weight", $object->weight_units); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { @@ -1902,7 +1902,7 @@ else print $object->length; if ($object->width) print " x ".$object->width; if ($object->height) print " x ".$object->height; - print ' '.measuring_units_string(0, "size", $object->length_units); + print ' '.measuringUnitString(0, "size", $object->length_units); } else { @@ -1916,7 +1916,7 @@ else print '
'.$langs->trans("Surface").''; if ($object->surface != '') { - print $object->surface." ".measuring_units_string(0, "surface", $object->surface_units); + print $object->surface." ".measuringUnitString(0, "surface", $object->surface_units); } else { @@ -1930,7 +1930,7 @@ else print '
'.$langs->trans("Volume").''; if ($object->volume != '') { - print $object->volume." ".measuring_units_string(0, "volume", $object->volume_units); + print $object->volume." ".measuringUnitString(0, "volume", $object->volume_units); } else { @@ -1945,7 +1945,7 @@ else print '
'.$langs->trans("NetMeasure").''; if ($object->net_measure != '') { - print $object->net_measure." ".measuring_units_string(0, "weight", $object->net_measure_units); + print $object->net_measure." ".measuringUnitString(0, "weight", $object->net_measure_units); } else { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 8684c23511e..7b63fbd3c8c 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -327,7 +327,7 @@ class FormProduct /** * Return a combo box with list of units - * For the moment, units labels are defined in measuring_units_string + * Units labels are defined in llx_c_units * * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume, time diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f526c5e3c52..8545036b0b9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4197,22 +4197,22 @@ class Product extends CommonObject if ($this->type == Product::TYPE_PRODUCT) { if ($this->weight) { - $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuring_units_string($this->weight_units, "weight"); + $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); } if ($this->length) { - $label.="
".$langs->trans("Length").': '.$this->length.' '.measuring_units_string($this->length_units, 'size'); + $label.="
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); } if ($this->width) { - $label.="
".$langs->trans("Width").': '.$this->width.' '.measuring_units_string($this->width_units, 'size'); + $label.="
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); } if ($this->height) { - $label.="
".$langs->trans("Height").': '.$this->height.' '.measuring_units_string($this->height_units, 'size'); + $label.="
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } if ($this->surface) { - $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuring_units_string($this->surface_units, 'surface'); + $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); } if ($this->volume) { - $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuring_units_string($this->volume_units, 'volume'); + $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 0a7ec02afd8..9d2ae9b8c17 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1452,16 +1452,14 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units, "weight"):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):''; } // Calculated if ($totalWeight > 0) { if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; - //print $totalWeight.' '.measuring_units_string(0,"weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string($object->width_units, "size"):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuringUnitString(0, "size", $object->width_units):''; print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string($object->depth_units, "size"):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuringUnitString(0, "size", $object->depth_units):''; print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->weight_units, "weight"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight*$lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); else print ' '; print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuring_units_string($lines[$i]->product->volume_units, "volume"); + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume*$lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); else print ' '; print '
'.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string($object->weight_units, "weight"); + print $object->weight." ".measuringUnitString(0, "weight", $object->weight_units); } else { @@ -776,7 +776,7 @@ if (! empty($id) || ! empty($ref)) } ?> variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?>'.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight').''.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuringUnitString(0, 'weight', $prodstatic->weight_units).'getLibStatut(2, 0) ?> getLibStatut(2, 1) ?> diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index 57b9963d9b4..6012ddd511c 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -179,7 +179,7 @@ if (! empty($id) || ! empty($ref)) {