From 5dabcec7671b75f4c978f657aaf1f60e4f4eb44f Mon Sep 17 00:00:00 2001 From: boudet jean pascal <68547382+atm-jpb@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:17:55 +0200 Subject: [PATCH 1/9] rank duplicate on mass action #### rank duplicate on mass action invoice from multiple orders we have to define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several order massaction request. --- htdocs/core/actions_massactions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b98ce37d8f1..5859760d955 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -791,7 +791,10 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. 'HT', 0, $product_type, - $lines[$i]->rang, + + //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders + //-1 will give us the right number + -1, // rank $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, From 244a3fc8199a8969da418aa351aaf9f373b673df Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 4 Jul 2022 15:22:40 +0000 Subject: [PATCH 2/9] Fixing style errors. --- 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 5859760d955..af0ad2a2eaa 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -791,7 +791,6 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. 'HT', 0, $product_type, - //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders //-1 will give us the right number -1, // rank From ea524033391c5fedc3021ddf3ba21df36d8db5dd Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 7 Jul 2022 11:08:01 +0200 Subject: [PATCH 3/9] rank change. if we only have one order we leave the origin rank otherwise we leave the -1 and let the class set the max rank. --- htdocs/core/actions_massactions.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index af0ad2a2eaa..2bebd1ada00 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -641,7 +641,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - + $nbOrders = is_array($orders) ? count($orders) : 1; foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { @@ -773,7 +773,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. } $objecttmp->context['createfromclone']; - + $rankedLine = ($nbOrders > 1) ? -1 : $lines[$i]->rang; $result = $objecttmp->addline( $desc, $lines[$i]->subprice, @@ -793,7 +793,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $product_type, //we have define the max rank for each line which makes it possible not to have a duplicate on the rank field in the case of several orders //-1 will give us the right number - -1, // rank + $rankedLine, // rank $lines[$i]->special_code, $objecttmp->origin, $lines[$i]->rowid, From 5afe1dbb84e190e6c17f1b2ab8bee157bb0e76ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 20:57:29 +0200 Subject: [PATCH 4/9] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2bebd1ada00..0d279a4ac3d 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -641,7 +641,9 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - $nbOrders = is_array($orders) ? count($orders) : 1; + + $nbOrders = is_array($orders) ? count($orders) : 1; + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { From 6e4d4b5b0d323e2345467365eeb7dc5eed9d25f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 21:42:32 +0200 Subject: [PATCH 5/9] css --- htdocs/projet/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 2ad89326e6a..1a14bbb2741 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -805,7 +805,7 @@ if ($action == 'create' && $user->rights->projet->creer) { if ($action == 'clone') { $formquestion = array( 'text' => $langs->trans("ConfirmClone"), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200')), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int') > 0 ?GETPOST('socid', 'int') : $object->socid, 'socid', '', "None", 0, 0, null, 0, 'minwidth200 maxwidth250')), array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), array('type' => 'checkbox', 'name' => 'clone_tasks', 'label' => $langs->trans("CloneTasks"), 'value' => true), array('type' => 'checkbox', 'name' => 'move_date', 'label' => $langs->trans("CloneMoveDate"), 'value' => true), @@ -814,7 +814,7 @@ if ($action == 'create' && $user->rights->projet->creer) { array('type' => 'checkbox', 'name' => 'clone_task_files', 'label' => $langs->trans("CloneTaskFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 300, 590); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 400, 590); } From a97b3e47d1b9dc8864fb3706a54dcab690e99330 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 22:05:17 +0200 Subject: [PATCH 6/9] Fix look and feel v16 --- htdocs/societe/admin/societe.php | 45 ++++++++++++-------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 2fb9285379f..c57f1ac00da 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -51,19 +51,15 @@ $formcompany = new FormCompany($db); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setcodeclient') { - if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } if ($action == 'setcodecompta') { - if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -273,10 +269,8 @@ if ($action == 'setprofid') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_UNIQUE"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -286,10 +280,8 @@ if ($action == 'setprofidmandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -299,10 +291,8 @@ if ($action == 'setprofidinvoicemandatory') { $status = GETPOST('status', 'alpha'); $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { - //header("Location: ".$_SERVER["PHP_SELF"]); - //exit; - } else { + $result = dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -311,10 +301,8 @@ if ($action == 'setprofidinvoicemandatory') { if ($action == 'sethideinactivethirdparty') { $status = GETPOST('status', 'alpha'); - if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { + $result = dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { dol_print_error($db); } } @@ -331,6 +319,7 @@ if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { } } + /* * View */ @@ -575,7 +564,7 @@ foreach ($dirsociete as $dirroot) { if ($modulequalified) { print ''; - print $module->name; + print dol_escape_htmltag($module->name); print "\n"; if (method_exists($module, 'info')) { print $module->info($langs); @@ -589,7 +578,7 @@ foreach ($dirsociete as $dirroot) { print "\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ - print 'scandir.'&label='.urlencode($module->name).'">'; + print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; //} @@ -605,7 +594,7 @@ foreach ($dirsociete as $dirroot) { print ""; } else { print ''."\n"; - print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; print ""; } } @@ -626,7 +615,7 @@ foreach ($dirsociete as $dirroot) { // Preview print ''; if ($module->type == 'pdf') { - $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; + $linkspec = ''.img_object($langs->trans("Preview"), 'pdf').''; } else { $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); } From ca42be7478553b07c782e2421338cb1abbc114b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 22:35:56 +0200 Subject: [PATCH 7/9] Fix error management --- htdocs/compta/facture/class/facture.class.php | 6 ++++-- htdocs/takepos/invoice.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 345ffd10acb..74595267a7c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3140,6 +3140,7 @@ class Facture extends CommonInvoice } else { $num = $this->ref; } + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -3147,7 +3148,7 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= " SET ref='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; + $sql .= " SET ref = '".$this->db->escape($num)."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".($user->id > 0 ? $user->id : "null").", date_valid = '".$this->db->idate($now)."'"; if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { // If option enabled, we force invoice date $sql .= ", datef='".$this->db->idate($this->date)."'"; $sql .= ", date_lim_reglement='".$this->db->idate($this->date_lim_reglement)."'"; @@ -4383,7 +4384,6 @@ class Facture extends CommonInvoice $mybool = false; - $file = $addon.'.php'; $classname = $addon; @@ -4421,8 +4421,10 @@ class Facture extends CommonInvoice } $obj = new $classname(); + $numref = $obj->getNextValue($soc, $this, $mode); + /** * $numref can be empty in case we ask for the last value because if there is no invoice created with the * set up mask. diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 35855b60e23..bdc11c79b2f 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -177,6 +177,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($_SESSION["takeposcustomercu } } + /* * Actions */ @@ -278,7 +279,8 @@ if (empty($reshook)) { $res = $invoice->validate($user); if ($res < 0) { $error++; - dol_htmloutput_errors($invoice->error, $invoice->errors, 1); + $langs->load("admin"); + dol_htmloutput_errors($invoice->error == 'NotConfigured' ? $langs->trans("NotConfigured").' (TakePos numbering module)': $invoice->error, $invoice->errors, 1); } } From 7741826d3409f45b9d69a42cc99366556ccde34c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2022 23:09:39 +0200 Subject: [PATCH 8/9] phpcs --- htdocs/core/actions_massactions.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4f738f68a97..d704d9974f9 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -642,9 +642,9 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders. $lastref = ''; $db->begin(); - + $nbOrders = is_array($orders) ? count($orders) : 1; - + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) { From 8360ea971136d0e2ec61fb7c20ec35b954eb85af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Jul 2022 00:20:33 +0200 Subject: [PATCH 9/9] Fix hide link to doc if doc never generated --- htdocs/comm/card.php | 49 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 1c63189db0e..4b51a519223 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1121,7 +1121,8 @@ if ($object->id > 0) { * Latest contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { - $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity"; + $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut as contract_status, c.datec as dc, c.date_contrat as dcon, c.ref_customer as refcus, c.ref_supplier as refsup, c.entity,"; + $sql .= " c.last_main_doc, c.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".((int) $object->id); @@ -1154,6 +1155,8 @@ if ($object->id > 0) { $contrat->ref_customer = $objp->refcus; $contrat->ref_supplier = $objp->refsup; $contrat->statut = $objp->contract_status; + $contrat->last_main_doc = $objp->last_main_doc; + $contrat->model_pdf = $objp->model_pdf; $contrat->fetch_lines(); $late = ''; @@ -1168,30 +1171,32 @@ if ($object->id > 0) { print ''; print ''; print $contrat->getNomUrl(1, 12); - // Preview - $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); - $file_list = null; - if (!empty($filedir)) { - $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); - } - if (is_array($file_list)) { - // Defined relative dir to DOL_DATA_ROOT - $relativedir = ''; - if ($filedir) { - $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir); - $relativedir = preg_replace('/^[\\/]/', '', $relativedir); + if (!empty($contrat->model_pdf)) { + // Preview + $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $file_list = null; + if (!empty($filedir)) { + $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); } - // Get list of files stored into database for same relative directory - if ($relativedir) { - completeFileArrayWithDatabaseInfo($file_list, $relativedir); - - //var_dump($sortfield.' - '.$sortorder); - if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) - $file_list = dol_sort_array($file_list, $sortfield, $sortorder); + if (is_array($file_list)) { + // Defined relative dir to DOL_DATA_ROOT + $relativedir = ''; + if ($filedir) { + $relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir); + $relativedir = preg_replace('/^[\\/]/', '', $relativedir); } + // Get list of files stored into database for same relative directory + if ($relativedir) { + completeFileArrayWithDatabaseInfo($file_list, $relativedir); + + //var_dump($sortfield.' - '.$sortorder); + if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) + $file_list = dol_sort_array($file_list, $sortfield, $sortorder); + } + } + $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; + print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0); } - $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);