From acbd8efa7d18e2bf2a3e9b00ac5db25f1e0c4159 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 8 Dec 2019 23:16:49 +0100 Subject: [PATCH 01/57] NEW: Takepos supplements --- htdocs/langs/en_US/cashdesk.lang | 2 ++ htdocs/takepos/admin/setup.php | 18 +++++++++++ htdocs/takepos/ajax/ajax.php | 1 + htdocs/takepos/invoice.php | 51 +++++++++++++++++++++++++++++++- htdocs/takepos/takepos.php | 18 +++++++---- 5 files changed, 84 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 0516de208fc..8bf34a3ae17 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -77,3 +77,5 @@ InvoiceIsAlreadyValidated=Invoice is already validated NoLinesToBill=No lines to bill CustomReceipt=Custom Receipt ReceiptName=Receipt Name +ProductSupplements=Product Supplements +SupplementCategory=Supplement category diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 2e82f0471bd..c78f744e1d2 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -75,6 +75,8 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PHONE_BASIC_LAYOUT", GETPOST('TAKEPOS_PHONE_BASIC_LAYOUT', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS", GETPOST('TAKEPOS_SUPPLEMENTS', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); @@ -222,6 +224,22 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) print ''; print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1); print ''; + + print ''; + print $langs->trans("ProductSupplements"); + print ''; + print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1); + print ''; + + if ($conf->global->TAKEPOS_SUPPLEMENTS) + { + print ''; + print $langs->trans("SupplementCategory"); + print ''; + print $form->select_all_categories(Categorie::TYPE_PRODUCT, $conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0); + print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY'); + print "\n"; + } } print ''; diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 7e3049f9f6e..74b24d78570 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -45,6 +45,7 @@ $id = GETPOST('id', 'int'); if ($action == 'getProducts') { $object = new Categorie($db); + if ($category=="supplements") $category=$conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY; $result = $object->fetch($category); if ($result > 0) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 23bc09a7268..0b7ebff8548 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -87,6 +87,7 @@ $placeid = 0; // $placeid is id of invoice $number = GETPOST('number', 'alpha'); $idline = GETPOST('idline', 'int'); +$selectedline = GETPOST('selectedline', 'int'); $desc = GETPOST('desc', 'alpha'); $pay = GETPOST('pay', 'alpha'); $amountofpayment = price2num(GETPOST('amount', 'alpha')); @@ -276,7 +277,23 @@ if ($action == "addline") $price_base_type = $prod->multiprices_base_type[$customer->price_level]; } - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + if ($conf->global->TAKEPOS_SUPPLEMENTS) + { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $cat = new Categorie($db); + $categories = $cat->containing($idproduct, 'product'); + $found = (array_search($conf->global->TAKEPOS_SUPPLEMENTS_CATEGORY, array_column($categories, 'id'))); + if ($found !== false) // If this product is a supplement + { + $sql = "SELECT fk_parent_line FROM ".MAIN_DB_PREFIX."facturedet where rowid=$selectedline"; + $resql = $db->query($sql); + $row = $db->fetch_array($resql); + if ($row[0]==null) $parent_line=$selectedline; + else $parent_line=$row[0]; //If the parent line is already a supplement, add the supplement to the main product + } + } + + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, $parent_line, null, 0, '', 0, 100, '', null, 0); $invoice->fetch($placeid); } @@ -689,6 +706,37 @@ if ($placeid > 0) $tmplines = array_reverse($invoice->lines); foreach ($tmplines as $line) { + if ($line->fk_parent_line!=false) + { + $htmlsupplements[$line->fk_parent_line].='fk_parent_line].=' order'; + $htmlsupplements[$line->fk_parent_line].= '" id="'.$line->id.'">'; + $htmlsupplements[$line->fk_parent_line].= ''; + $htmlsupplements[$line->fk_parent_line].= img_picto('', 'rightarrow'); + if ($line->product_label) $htmlsupplements[$line->fk_parent_line] .= $line->product_label; + if ($line->product_label && $line->desc) $htmlsupplements[$line->fk_parent_line] .= '
'; + if ($line->product_label != $line->desc) + { + $firstline = dolGetFirstLineOfText($line->desc); + if ($firstline != $line->desc) + { + $htmlsupplements[$line->fk_parent_line] .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + } + else + { + $htmlsupplements[$line->fk_parent_line] .= $line->desc; + } + } + $htmlsupplements[$line->fk_parent_line] .= ''; + if ($_SESSION["basiclayout"] != 1) + { + $htmlsupplements[$line->fk_parent_line] .= ''.vatrate($line->remise_percent, true).''; + $htmlsupplements[$line->fk_parent_line] .= ''.$line->qty.''; + $htmlsupplements[$line->fk_parent_line] .= ''.price($line->total_ttc).''; + } + $htmlsupplements[$line->fk_parent_line] .= ''."\n"; + continue; + } $htmlforlines = ''; $htmlforlines .= ''.price($line->total_ttc).''; } $htmlforlines .= ''."\n"; + $htmlforlines .= $htmlsupplements[$line->id]; print $htmlforlines; } diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index ef987c84d86..b4810b23595 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -233,10 +233,14 @@ function LoadProducts(position, issubcat) { console.log("LoadProducts"); var maxproduct = ; - $('#catimg'+position).animate({opacity: '0.5'}, 1); - $('#catimg'+position).animate({opacity: '1'}, 100); - if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); - else currentcat=$('#catdiv'+position).data('rowid'); + if (position=="supplements") currentcat="supplements"; + else + { + $('#catimg'+position).animate({opacity: '0.5'}, 1); + $('#catimg'+position).animate({opacity: '1'}, 100); + if (issubcat==true) currentcat=$('#prodiv'+position).data('rowid'); + else currentcat=$('#catdiv'+position).data('rowid'); + } if (currentcat == undefined) return; pageproducts=0; ishow=0; //product to show counter @@ -353,7 +357,7 @@ function ClickProduct(position) { console.log("Click on product at position "+position+" for idproduct "+idproduct); if (idproduct=="") return; // Call page invoice.php to generate the section with product lines - $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct, function() { + $("#poslines").load("invoice.php?action=addline&place="+place+"&idproduct="+idproduct+"&selectedline="+selectedline, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } @@ -723,6 +727,10 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) { $menus[$r++]=array('title'=>'
'.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();'); } + if ($conf->global->TAKEPOS_SUPPLEMENTS) + { + $menus[$r++]=array('title'=>'
'.$langs->trans("ProductSupplements").'
', 'action'=>'LoadProducts(\'supplements\');'); + } } if ($conf->global->TAKEPOSCONNECTOR) { From caaa95da6aaf691dd42c3e86284a3aeb91cf41af Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 11 Dec 2019 15:33:36 +0100 Subject: [PATCH 02/57] hook on ics generation to add more events in eventarray --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 69f748412a1..6f262076616 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1721,6 +1721,13 @@ class ActionComm extends CommonObject } $diff++; } + + $parameters=array('filters' => $filters, 'eventarray' => &$eventarray); + $reshook=$hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook + if ($reshook > 0) + { + $eventarray = $hookmanager->resArray; + } } else { From cc8000a25590a524688897cfd0c328c476f21b2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Dec 2019 20:39:36 +0100 Subject: [PATCH 03/57] Removed not used files --- htdocs/bom/admin/index.html | 0 htdocs/bom/admin/setup.php | 129 ------------------------------------ 2 files changed, 129 deletions(-) delete mode 100644 htdocs/bom/admin/index.html delete mode 100644 htdocs/bom/admin/setup.php diff --git a/htdocs/bom/admin/index.html b/htdocs/bom/admin/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php deleted file mode 100644 index 6abad8e3d58..00000000000 --- a/htdocs/bom/admin/setup.php +++ /dev/null @@ -1,129 +0,0 @@ - - * Copyright (C) 2019 Maxime Kohlhaas - * 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 - * 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 bom/admin/setup.php - * \ingroup bom - * \brief Bom setup page. - */ - -// Load Dolibarr environment -require '../../main.inc.php'; -// Libraries -require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; -require_once '../lib/bom.lib.php'; -//require_once "../class/myclass.class.php"; - -// Translations -$langs->loadLangs(array("admin", "mrp")); - -// Access control -if (!$user->admin) accessforbidden(); - -// Parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - -$arrayofparameters = array( - 'BILLOFMATERIALS_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1), - 'BILLOFMATERIALS_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1) -); - - -/* - * Actions - */ -include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; - -/* - * View - */ - -$page_name = "BomSetup"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_bom'); - -// Configuration header -$head = bomAdminPrepareHead(); -dol_fiche_head($head, 'settings', '', -1, "bom"); - -// Setup page goes here -echo $langs->trans("BomSetupPage").'

'; - - -if ($action == 'edit') -{ - print '
'; - print ''; - print ''; - - print ''; - print ''; - - foreach ($arrayofparameters as $key => $val) - { - print ''; - } - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print '
'; - - print '
'; - print ''; - print '
'; - - print '
'; - print '
'; -} -else -{ - if (!empty($arrayofparameters)) - { - print ''; - print ''; - - foreach ($arrayofparameters as $key => $val) - { - print ''; - } - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); - print ''.$conf->global->$key.'
'; - - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - } - else - { - print '
'.$langs->trans("NothingToSetup"); - } -} - - -// Page end -dol_fiche_end(); - -llxFooter(); -$db->close(); From fc45d7d249285292df5aa24e4e6a06bde83e0325 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Dec 2019 21:04:14 +0100 Subject: [PATCH 04/57] Comaptible php 7.4 --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index e3a5ef0cbbe..f1679bbdfab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -137,6 +137,7 @@ NEW: #4301 For Developers or integrators: +NEW: Compatible with PHP 7.4 NEW: Code for extrafields uses the new array $extrafields->attributes NEW: Can set a filter on object linked in modulebuilder. NEW: Can defined a position of numbering submodules for thirdparties From 8202a67e4ea4cb55081a7d7954b8728c4a4139d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Dec 2019 23:15:56 +0100 Subject: [PATCH 05/57] Fix look and feel v11 --- htdocs/compta/bank/transfer.php | 4 +- htdocs/compta/bank/various_payment/card.php | 2 +- .../compta/bank/various_payment/document.php | 2 +- .../sociales/class/chargesociales.class.php | 52 ++++++----------- htdocs/loan/class/loan.class.php | 58 +++++++------------ htdocs/loan/list.php | 27 +++++---- htdocs/loan/schedule.php | 32 +++++----- 7 files changed, 81 insertions(+), 96 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index dbceabf642e..2a32e173d3b 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry @@ -238,6 +238,7 @@ print ''; print ''; +print '
'; print ''; print ''; print ''; @@ -261,6 +262,7 @@ print ''; print "
'.$langs->trans("TransferFrom").''.$langs->trans("TransferTo").''.$langs->trans("Date").''.$langs->trans("Description").''.$langs->trans("Amount").'
"; +print '
'; print '
'; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index f4a88f8eba2..2db276ebbbe 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -456,7 +456,7 @@ if ($id) print '
'; print '
'; - print ''; + print '
'; // Label print ''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 2a56122d6f3..37ff26b0b4b 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -134,7 +134,7 @@ if ($object->id) print '
'.$langs->trans("Label").''.$object->label.'
'; - print ''; + print ''; print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index fecc5a96aa1..5bb218d46cd 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -108,6 +108,10 @@ class ChargeSociales extends CommonObject public $fk_project; + const STATUS_UNPAID = 0; + const STATUS_PAID = 1; + + /** * Constructor * @@ -495,43 +499,23 @@ class ChargeSociales extends CommonObject // Load translation files required by the page $langs->loadLangs(array("customers","bills")); - if ($mode == 0 || $mode == 1) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status == 0) return $langs->trans("Unpaid"); - elseif ($status == 1) return $langs->trans("Paid"); - } - elseif ($mode == 2) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 3) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 5) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } - else return "Error, mode/status not found"; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 427217bec10..6a724db9d87 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -105,6 +105,10 @@ class Loan extends CommonObject public $fk_project; + const STATUS_UNPAID = 0; + const STATUS_PAID = 1; + + /** * Constructor * @@ -425,47 +429,29 @@ class Loan extends CommonObject */ public function LibStatut($status, $mode = 0, $alreadypaid = -1) { - // phpcs:enable + // phpcs:enable global $langs; - $langs->loadLangs(array("customers", "bills")); - if ($mode == 0 || $mode == 1) + // Load translation files required by the page + $langs->loadLangs(array("customers","bills")); + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status == 0) return $langs->trans("Unpaid"); - elseif ($status == 1) return $langs->trans("Paid"); - } - elseif ($mode == 2) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 3) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 4) - { - if ($status == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - elseif ($status == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - elseif ($status == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - elseif ($mode == 5) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - elseif ($mode == 6) - { - if ($status == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - elseif ($status == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - elseif ($status == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); + if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } - else return "Error, mode/status not found"; + $statusType = 'status1'; + if ($status == 0 && $alreadypaid > 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index a8192155b63..d1a01cd11b1 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -49,7 +49,8 @@ if (!$sortorder) $sortorder = "DESC"; $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); -$filtre = GETPOST("filtre"); + +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); // Purge search criteria @@ -77,10 +78,6 @@ $sql .= " WHERE l.entity = ".$conf->entity; if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1); if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref); if ($search_label) $sql .= natural_search("l.label", $search_label); -if ($filtre) { - $filtre = str_replace(":", "=", $filtre); - $sql .= " AND ".$filtre; -} $sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql .= $db->order($sortfield, $sortorder); @@ -108,10 +105,10 @@ if ($resql) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_label) $param.="&search_label=".urlencode($search_user); - if ($search_amount) $param.="&search_amount=".urlencode($search_amount_ht); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_amount) $param.="&search_amount=".urlencode($search_amount); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); $newcardbutton=''; if ($user->rights->loan->write) @@ -130,6 +127,8 @@ if ($resql) print_barre_liste($langs->trans("Loans"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy.png', 0, $newcardbutton, '', $limit); + $moreforfilter = ''; + print '
'; print ''."\n"; @@ -157,7 +156,7 @@ if ($resql) print_liste_field_titre(''); print "\n"; - while ($i < min($num, $limit)) + while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); $loan_static->id = $obj->rowid; @@ -190,6 +189,14 @@ if ($resql) $i++; } + // If no record found + if ($num == 0) + { + $colspan = 7; + //foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''; + } + print "
'.$langs->trans("NoRecordFound").'
"; print '
'; print "\n"; diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 4410e598204..a951b9c9b0f 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -48,17 +48,17 @@ $linkback = ''; // Ref loan -$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); -$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); +$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); +$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); // Project if (!empty($conf->projet->enabled)) { $langs->loadLangs(array("projects")); - $morehtmlref .= '
'.$langs->trans('Project').' '; + $morehtmlref .= '
'.$langs->trans('Project').' : '; if ($user->rights->loan->write) { if ($action != 'classify') - $morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + //$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 .= '
'; @@ -83,6 +83,9 @@ if (!empty($conf->projet->enabled)) } } $morehtmlref .= '
'; + +$morehtmlright = ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); if ($action == 'createecheancier') { @@ -140,8 +143,6 @@ if ($action == 'updateecheancier') { $echeance = new LoanSchedule($db); $echeance->fetchAll($object->id); -$var = !$var; - ?> -

trans("ShowInvoice"); ?>

+

trans("ShowInvoice"); ?>


-

trans("PrintTicket"); ?>

+

trans("PrintTicket"); ?>

From 411f20c36097b184fc03dad71d7b27c1afff6a18 Mon Sep 17 00:00:00 2001 From: jerash Date: Tue, 31 Dec 2019 01:08:25 +0100 Subject: [PATCH 11/57] add credit notes and discounts to getListOfPayments --- htdocs/core/class/commoninvoice.class.php | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index b6381ccc7ca..fad07e2e7c3 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -336,6 +336,43 @@ abstract class CommonInvoice extends CommonObject $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); $i++; } + //look for credit notes and discounts + if ($this->element == 'facture' || $this->element == 'invoice') + { + $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id; + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or credit note + } + elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') + { + $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id; + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or credit note + } + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) { $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); } + else { $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); } + $i++; + } + $this->db->free($resql); + return $retarray; + } + else + { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + return array(); + } $this->db->free($resql); return $retarray; } From 73e0bca359e511d6cae8c1c27b2cef28bdf390e6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 31 Dec 2019 00:13:42 +0000 Subject: [PATCH 12/57] Fixing style errors. --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index fad07e2e7c3..9d3538bc5fe 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -351,7 +351,7 @@ abstract class CommonInvoice extends CommonObject $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id; $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or credit note } - + $resql=$this->db->query($sql); if ($resql) { From 77e3b011792233accb15b08abaacaa27e504f98a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 31 Dec 2019 08:00:20 +0100 Subject: [PATCH 13/57] Fix Accountancy - Set NULL when data is empty --- htdocs/accountancy/class/bookkeeping.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index ee3188da125..a72dfbe238e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -330,20 +330,20 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->db->escape($this->doc_ref) . "'"; $sql .= "," . $this->fk_doc; $sql .= "," . $this->fk_docdet; - $sql .= ",'" . $this->db->escape($this->thirdparty_code) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_account) . "'"; - $sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; + $sql .= "," . (!empty($this->thirdparty_code)?("'".$this->db->escape($this->thirdparty_code)."'"):"NULL"); + $sql .= "," . (!empty($this->subledger_account)?("'".$this->db->escape($this->subledger_account)."'"):"NULL"); + $sql .= "," . (!empty($this->subledger_label)?("'".$this->db->escape($this->subledger_label)."'"):"NULL"); $sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'"; - $sql .= ",'" . $this->db->escape($this->label_operation) . "'"; + $sql .= "," . (!empty($this->label_operation)?("'".$this->db->escape($this->label_operation)."'"):"NULL"); $sql .= "," . $this->debit; $sql .= "," . $this->credit; $sql .= "," . $this->montant; - $sql .= ",'" . $this->db->escape($this->sens) . "'"; + $sql .= "," . (!empty($this->sens)?("'".$this->db->escape($this->sens)."'"):"NULL"); $sql .= ",'" . $this->db->escape($this->fk_user_author) . "'"; - $sql .= ",'".$this->db->idate($now)."'"; + $sql .= ",'" . $this->db->idate($now)."'"; $sql .= ",'" . $this->db->escape($this->code_journal) . "'"; - $sql .= ",'" . $this->db->escape($this->journal_label) . "'"; + $sql .= "," . (!empty($this->journal_label)?("'".$this->db->escape($this->journal_label)."'"):"NULL"); $sql .= "," . $this->db->escape($this->piece_num); $sql .= ", " . (! isset($this->entity) ? $conf->entity : $this->entity); $sql .= ")"; From a7a474d03250c1b09de8f8a208baf0a47293a995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 31 Dec 2019 14:28:14 +0100 Subject: [PATCH 14/57] Update doc_generic_contract_odt.modules.php --- .../modules/contract/doc/doc_generic_contract_odt.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index e7770981d09..4594a9d63cd 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-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 @@ -162,7 +162,7 @@ class doc_generic_contract_odt extends ModelePDFContract $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; } - // Add select to upload a new template file. TODO Copy this feature on other admin pages. + // Add input to upload a new template file. $texte .= '
'.$langs->trans("UploadNewTemplate").' '; $texte .= ''; $texte .= ''; From 175894db264718f4b6b389fe2e25c1d32997c4ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 14:48:52 +0100 Subject: [PATCH 15/57] FIX Status of direct debit payment after setting to paid. --- .../class/bonprelevement.class.php | 229 +++++++++--------- 1 file changed, 115 insertions(+), 114 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a9eb9d52433..4050d081fe4 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -49,10 +49,10 @@ class BonPrelevement extends CommonObject */ public $table_element = 'prelevement_bons'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto = 'payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; public $date_echeance; public $raison_sociale; @@ -116,7 +116,7 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal * @@ -132,7 +132,7 @@ class BonPrelevement extends CommonObject */ public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { - // phpcs:enable + // phpcs:enable $result = 0; $line_id = 0; @@ -196,8 +196,8 @@ class BonPrelevement extends CommonObject if ($concat == 1) { /* - * We aggregate the lines - */ + * We aggregate the lines + */ $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes"; $sql .= " WHERE fk_prelevement_bons = ".$this->id; @@ -219,8 +219,8 @@ class BonPrelevement extends CommonObject else { /* - * No aggregate - */ + * No aggregate + */ $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_lignes ("; $sql .= "fk_prelevement_bons"; $sql .= ", fk_soc"; @@ -335,7 +335,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set credite and set status of linked invoices. Still used ?? * @@ -343,7 +343,7 @@ class BonPrelevement extends CommonObject */ public function set_credite() { - // phpcs:enable + // phpcs:enable global $user, $conf; $error = 0; @@ -351,7 +351,7 @@ class BonPrelevement extends CommonObject if ($this->db->begin()) { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; - $sql .= " SET statut = 1"; + $sql .= " SET statut = ".self::STATUS_TRANSFERED; $sql .= " WHERE rowid = ".$this->id; $sql .= " AND entity = ".$conf->entity; @@ -392,8 +392,8 @@ class BonPrelevement extends CommonObject } /* - * End of procedure - */ + * End of procedure + */ if (!$error) { $this->db->commit(); @@ -414,7 +414,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit order to "credited" status. * @@ -424,7 +424,7 @@ class BonPrelevement extends CommonObject */ public function set_infocredit($user, $date) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $error = 0; @@ -437,11 +437,11 @@ class BonPrelevement extends CommonObject { $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_bons "; $sql .= " SET fk_user_credit = ".$user->id; - $sql .= ", statut = 2"; + $sql .= ", statut = ".self::STATUS_CREDITED; $sql .= ", date_credit = '".$this->db->idate($date)."'"; $sql .= " WHERE rowid=".$this->id; $sql .= " AND entity = ".$conf->entity; - $sql .= " AND statut = 1"; + $sql .= " AND statut = ".self::STATUS_TRANSFERED; if ($this->db->query($sql)) { @@ -483,7 +483,8 @@ class BonPrelevement extends CommonObject $paiement->datepaye = $date; $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->num_payment = $this->ref; // Set ref of direct debit note + $paiement->num_paiement = $this->ref; // For bacward compatibility $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); @@ -525,12 +526,12 @@ class BonPrelevement extends CommonObject } /* - * End of procedure - */ + * End of procedure + */ if ($error == 0) { $this->date_credit = $date; - $this->statut = 1; + $this->statut = self::STATUS_CREDITED; $this->db->commit(); return 0; @@ -560,7 +561,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set withdrawal to transmited status * @@ -571,7 +572,7 @@ class BonPrelevement extends CommonObject */ public function set_infotrans($user, $date, $method) { - // phpcs:enable + // phpcs:enable global $conf, $langs; $error = 0; @@ -639,9 +640,9 @@ class BonPrelevement extends CommonObject $arr = array(); /* - * Returns all invoices presented - * within a withdrawal receipt - */ + * Returns all invoices presented + * within a withdrawal receipt + */ $sql = "SELECT fk_facture"; if ($amounts) $sql .= ", SUM(pl.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; @@ -685,7 +686,7 @@ class BonPrelevement extends CommonObject return $arr; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns amount of withdrawal * @@ -693,7 +694,7 @@ class BonPrelevement extends CommonObject */ public function SommeAPrelever() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT sum(pfd.amount) as nb"; @@ -724,7 +725,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get number of invoices to withdrawal * TODO delete params banque and agence when not necesary @@ -735,7 +736,7 @@ class BonPrelevement extends CommonObject */ public function NbFactureAPrelever($banque = 0, $agence = 0) { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT count(f.rowid) as nb"; @@ -769,7 +770,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a withdraw * TODO delete params banque and agence when not necesary @@ -784,7 +785,7 @@ class BonPrelevement extends CommonObject */ public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG); @@ -797,8 +798,8 @@ class BonPrelevement extends CommonObject $error = 0; $datetimeprev = time(); - //Choice the date of the execution direct debit - if (!empty($executiondate)) $datetimeprev = $executiondate; + //Choice the date of the execution direct debit + if (!empty($executiondate)) $datetimeprev = $executiondate; $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); @@ -929,12 +930,12 @@ class BonPrelevement extends CommonObject // Return warning /*$i=0; - foreach ($this->thirdparty_in_error as $key => $val) - { - if ($i < 10) setEventMessages($val, null, 'warnings'); - else setEventMessages('More error were discarded...', null, 'warnings'); - $i++; - }*/ + foreach ($this->thirdparty_in_error as $key => $val) + { + if ($i < 10) setEventMessages($val, null, 'warnings'); + else setEventMessages('More error were discarded...', null, 'warnings'); + $i++; + }*/ if (count($factures_prev) > 0) { @@ -952,16 +953,16 @@ class BonPrelevement extends CommonObject if ($ok) { /* - * We are in real mode. - * We create withdraw receipt and build withdraw into disk - */ + * We are in real mode. + * We create withdraw receipt and build withdraw into disk + */ $this->db->begin(); $now = dol_now(); /* - * Traitements - */ + * Traitements + */ if (!$error) { $ref = substr($year, -2).$month; @@ -1017,8 +1018,8 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Create withdrawal receipt in database - */ + * Create withdrawal receipt in database + */ if (count($factures_prev) > 0) { foreach ($factures_prev as $fac) // Add a link in database for each invoice @@ -1027,17 +1028,17 @@ class BonPrelevement extends CommonObject $fact = new Facture($this->db); $fact->fetch($fac[0]); /* - * Add standing order - * - * - * $fac[3] : banque - * $fac[4] : guichet - * $fac[5] : number - * $fac[6] : cle rib - * $fac[7] : amount - * $fac[8] : client nom - * $fac[2] : client id - */ + * Add standing order + * + * + * $fac[3] : banque + * $fac[4] : guichet + * $fac[5] : number + * $fac[6] : cle rib + * $fac[7] : amount + * $fac[8] : client nom + * $fac[2] : client id + */ $ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]); if ($ri <> 0) { @@ -1066,8 +1067,8 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Create direct debit order in a XML file - */ + * Create direct debit order in a XML file + */ dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); @@ -1104,8 +1105,8 @@ class BonPrelevement extends CommonObject //var_dump($factures_prev);exit; /* - * Update total - */ + * Update total + */ $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons"; $sql .= " SET amount = ".price2num($this->total); $sql .= " WHERE rowid = ".$this->id; @@ -1118,13 +1119,13 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__."::Error update total: ".$this->db->error(), LOG_ERR); } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } if (!$error) { @@ -1160,10 +1161,10 @@ class BonPrelevement extends CommonObject if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result = $this->call_trigger('DIRECT_DEBIT_ORDER_DELETE', $user); + if ($result < 0) $error++; + // End call triggers } if (!$error) @@ -1210,11 +1211,11 @@ class BonPrelevement extends CommonObject /** * Returns clickable name (with picto) * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string URL of target */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) @@ -1280,7 +1281,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification def by id * @@ -1289,7 +1290,7 @@ class BonPrelevement extends CommonObject */ public function DeleteNotificationById($rowid) { - // phpcs:enable + // phpcs:enable $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; @@ -1305,7 +1306,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification * @@ -1315,7 +1316,7 @@ class BonPrelevement extends CommonObject */ public function DeleteNotification($user, $action) { - // phpcs:enable + // phpcs:enable $result = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def"; @@ -1331,7 +1332,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a notification * @@ -1342,7 +1343,7 @@ class BonPrelevement extends CommonObject */ public function AddNotification($db, $user, $action) { - // phpcs:enable + // phpcs:enable $result = 0; if ($this->DeleteNotification($user, $action) == 0) @@ -1376,7 +1377,7 @@ class BonPrelevement extends CommonObject * File is generated with name this->filename * * @param string $format FRST, RCUR or ALL - * @param string $executiondate Date to execute transfer + * @param string $executiondate Date to execute transfer * @return int 0 if OK, <0 if KO */ public function generate($format = 'ALL', $executiondate = '') @@ -1414,7 +1415,7 @@ class BonPrelevement extends CommonObject $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; - if (!empty($executiondate)) $date_actu = $executiondate; + if (!empty($executiondate)) $date_actu = $executiondate; $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); @@ -1554,12 +1555,12 @@ class BonPrelevement extends CommonObject fclose($this->file); if (!empty($conf->global->MAIN_UMASK)) - @chmod($this->file, octdec($conf->global->MAIN_UMASK)); - return $result; + @chmod($this->file, octdec($conf->global->MAIN_UMASK)); + return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1576,7 +1577,7 @@ class BonPrelevement extends CommonObject */ public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') { - // phpcs:enable + // phpcs:enable fputs($this->file, "06"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1647,7 +1648,7 @@ class BonPrelevement extends CommonObject return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1667,15 +1668,15 @@ class BonPrelevement extends CommonObject * @param string $row_bic rib.bic AS bic, * @param string $row_datec rib.datec, * @param string $row_drum rib.rowid used to generate rum - * @param string $row_rum rib.rum Rum defined on company bank account + * @param string $row_rum rib.rum Rum defined on company bank account * @return string Return string with SEPA part DrctDbtTxInf */ public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum, $row_rum) { - // phpcs:enable - global $conf; + // phpcs:enable + global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $CrLf = "\n"; $Rowing = sprintf("%06d", $row_idfac); @@ -1690,7 +1691,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR = ''; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; @@ -1722,8 +1723,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; - // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; + // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1731,7 +1732,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me) * @@ -1739,7 +1740,7 @@ class BonPrelevement extends CommonObject */ public function EnregEmetteur() { - // phpcs:enable + // phpcs:enable fputs($this->file, "03"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1798,7 +1799,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me). * Note: The tag PmtInf is opened here but closed into caller @@ -1813,7 +1814,7 @@ class BonPrelevement extends CommonObject */ public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') { - // phpcs:enable + // phpcs:enable // SEPA INITIALISATION global $conf; @@ -1892,13 +1893,13 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; - $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf;*/ + $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf; + $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; + $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; + $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -1921,7 +1922,7 @@ class BonPrelevement extends CommonObject return $XML_SEPA_INFO; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write end * @@ -1930,7 +1931,7 @@ class BonPrelevement extends CommonObject */ public function EnregTotal($total) { - // phpcs:enable + // phpcs:enable fputs($this->file, "08"); fputs($this->file, "08"); // Prelevement ordinaire @@ -1995,7 +1996,7 @@ class BonPrelevement extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * From f11a119ab006671564b7c1e9807ff30340193557 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 16:50:21 +0100 Subject: [PATCH 16/57] Clean dead code --- .../compta/paiement/class/paiement.class.php | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index e4a4a275029..75dcb837df9 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -327,28 +327,6 @@ class Paiement extends CommonObject //var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit; - /* Why this ? We can remove i think. - // If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing. - $mustwait=0; - $sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande"; - $sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0"; - ... - - $listofpayments=$invoice->getListOfPayments(); - foreach($listofpayments as $paym) - { - // This payment on invoice $invoice might be the one we record or another one - if ($paym['type']=='PRE') - { - if (! empty($conf->prelevement->enabled)) - { - // if not, $mustwait++; // This will disable automatic close on invoice to allow to process - - } - } - } - */ - //Invoice types that are eligible for changing status to paid $affected_types = array( Facture::TYPE_STANDARD, From c341ad5e8db97457b103d63d76d75719b6b9dab3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:03:00 +0100 Subject: [PATCH 17/57] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 9d3538bc5fe..70200c794df 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -342,14 +342,14 @@ abstract class CommonInvoice extends CommonObject $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id; - $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or credit note + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id; - $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or credit note + $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } $resql=$this->db->query($sql); From b3373e8ba5c00aaa1a34215a7234e012adc97cc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:06:30 +0100 Subject: [PATCH 18/57] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 45 +++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 70200c794df..2772330c41c 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -336,7 +336,9 @@ abstract class CommonInvoice extends CommonObject $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); $i++; } - //look for credit notes and discounts + + //look for credit notes and discounts and deposits + $sql = 0; if ($this->element == 'facture' || $this->element == 'invoice') { $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; @@ -352,28 +354,33 @@ abstract class CommonInvoice extends CommonObject $sql.= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set) } - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - while ($i < $num) + if ($sql) { + $resql=$this->db->query($sql); + if ($resql) { - $obj = $this->db->fetch_object($resql); - if ($multicurrency) { $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); } - else { $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); } - $i++; + $num = $this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) { + $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); + } + else { + $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); + } + $i++; + } + } + else + { + $this->error = $this->db->lasterror(); + dol_print_error($this->db); + return array(); } $this->db->free($resql); - return $retarray; } - else - { - $this->error = $this->db->lasterror(); - dol_print_error($this->db); - return array(); - } - $this->db->free($resql); + return $retarray; } else From d3ec867df557d7a13f837130a724333698d19646 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 31 Dec 2019 16:07:07 +0000 Subject: [PATCH 19/57] Fixing style errors. --- htdocs/core/class/commoninvoice.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2772330c41c..94efdea4d3e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -336,7 +336,7 @@ abstract class CommonInvoice extends CommonObject $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); $i++; } - + //look for credit notes and discounts and deposits $sql = 0; if ($this->element == 'facture' || $this->element == 'invoice') @@ -363,11 +363,11 @@ abstract class CommonInvoice extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($multicurrency) { - $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); + if ($multicurrency) { + $retarray[]=array('amount'=>$obj->multicurrency_amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref); } - else { - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); + else { + $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'', 'ref'=>$obj->ref); } $i++; } @@ -380,7 +380,7 @@ abstract class CommonInvoice extends CommonObject } $this->db->free($resql); } - + return $retarray; } else From a369690e16f1e5edefc4b1dcc208111711b6bce6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:07:56 +0100 Subject: [PATCH 20/57] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 94efdea4d3e..531bf1a09ad 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -338,7 +338,7 @@ abstract class CommonInvoice extends CommonObject } //look for credit notes and discounts and deposits - $sql = 0; + $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') { $sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type'; From 9774b05f524da296c615835790f4a519f828f916 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:10:03 +0100 Subject: [PATCH 21/57] Update commoninvoice.class.php --- htdocs/core/class/commoninvoice.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 531bf1a09ad..03d0d25fcd7 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -336,7 +336,8 @@ abstract class CommonInvoice extends CommonObject $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); $i++; } - + $this->db->free($resql); + //look for credit notes and discounts and deposits $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') From 5a692cecfb2320c1aaa1892360dbd5f2ac3c2ddf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:10:36 +0100 Subject: [PATCH 22/57] Code comment --- htdocs/core/class/discount.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index d89db86aa10..ca40910aacd 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -546,7 +546,7 @@ class DiscountAbsolute * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ public function getSumDepositsUsed($invoice, $multicurrency = 0) @@ -578,7 +578,7 @@ class DiscountAbsolute if ($resql) { $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; + if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; } else @@ -592,7 +592,7 @@ class DiscountAbsolute * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency 1=Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ public function getSumCreditNotesUsed($invoice, $multicurrency = 0) @@ -624,7 +624,7 @@ class DiscountAbsolute if ($resql) { $obj = $this->db->fetch_object($resql); - if ($multicurrency) return $obj->multicurrency_amount; + if ($multicurrency == 1) return $obj->multicurrency_amount; else return $obj->amount; } else From 6142e42d83608cfab8c45ca604cd40d7942ca867 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 31 Dec 2019 16:10:36 +0000 Subject: [PATCH 23/57] Fixing style errors. --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 03d0d25fcd7..9def117ef21 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -337,7 +337,7 @@ abstract class CommonInvoice extends CommonObject $i++; } $this->db->free($resql); - + //look for credit notes and discounts and deposits $sql = ''; if ($this->element == 'facture' || $this->element == 'invoice') From 76052b8bb43705519ea5ef3890341050c3019fe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:19:49 +0100 Subject: [PATCH 24/57] FIX Avoid line feed when 100% --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ae34fd3f8e1..f39934a7f65 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -595,7 +595,7 @@ class pdf_crabe extends ModelePDFFactures { $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 3, $progress, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R'); } // Total HT line From 15f1153e820cd25138ccf420eccfda9d232ef314 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 17:19:49 +0100 Subject: [PATCH 25/57] FIX Avoid line feed when 100% --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index ae34fd3f8e1..f39934a7f65 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -595,7 +595,7 @@ class pdf_crabe extends ModelePDFFactures { $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); - $pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 3, $progress, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R'); } // Total HT line From 3b6936176a95795c6fdb20b89f842c03c8033e80 Mon Sep 17 00:00:00 2001 From: Jonathan Buyck Date: Mon, 30 Dec 2019 19:57:24 +0100 Subject: [PATCH 26/57] fix undefined facid --- htdocs/cashdesk/tpl/validation2.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/tpl/validation2.tpl.php b/htdocs/cashdesk/tpl/validation2.tpl.php index 624f4ef9701..eab69c6b35d 100644 --- a/htdocs/cashdesk/tpl/validation2.tpl.php +++ b/htdocs/cashdesk/tpl/validation2.tpl.php @@ -48,9 +48,9 @@ $langs->loadLangs(array("main","bills")); -

trans("ShowInvoice"); ?>

+

trans("ShowInvoice"); ?>


-

trans("PrintTicket"); ?>

+

trans("PrintTicket"); ?>

From 14d69c5a2cbeef1c44da433b7c72de30cbdd205c Mon Sep 17 00:00:00 2001 From: Manu Bryk Date: Fri, 27 Dec 2019 00:11:49 +0100 Subject: [PATCH 27/57] New Ref more visible when create a ticket When customers call support to trace a ticket, they don't have easily ref of the ticket. Add Ref to the subject of mail for customers and for TICKET_NOTIFICATION_EMAIL_TO. Add ref also to the notification message when customers create a new ticket. --- htdocs/langs/en_US/ticket.lang | 6 +++--- htdocs/public/ticket/create_ticket.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 79c4978b660..a565ecb59b8 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -251,9 +251,9 @@ ShowListTicketWithTrackId=Display ticket list from track ID ShowTicketWithTrackId=Display ticket from track ID TicketPublicDesc=You can create a support ticket or check from an existing ID. YourTicketSuccessfullySaved=Ticket has been successfully saved! -MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s. +MesgInfosPublicTicketCreatedWithTrackId=A new ticket has been created with ID %s and Ref %s. PleaseRememberThisId=Please keep the tracking number that we might ask you later. -TicketNewEmailSubject=Ticket creation confirmation +TicketNewEmailSubject=Ticket creation confirmation - Ref %s TicketNewEmailSubjectCustomer=New support ticket TicketNewEmailBody=This is an automatic email to confirm you have registered a new ticket. TicketNewEmailBodyCustomer=This is an automatic email to confirm a new ticket has just been created into your account. @@ -272,7 +272,7 @@ Subject=Subject ViewTicket=View ticket ViewMyTicketList=View my ticket list ErrorEmailMustExistToCreateTicket=Error: email address not found in our database -TicketNewEmailSubjectAdmin=New ticket created +TicketNewEmailSubjectAdmin=New ticket created - Ref %s TicketNewEmailBodyAdmin=

Ticket has just been created with ID #%s, see information:

SeeThisTicketIntomanagementInterface=See ticket in management interface TicketPublicInterfaceForbidden=The public interface for the tickets was not enabled diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index b69d28f0cb0..c4a3b71e6ad 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -203,7 +203,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { // Send email to customer - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject'); + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref); $message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n"; $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n"; @@ -245,7 +245,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { if ($sendto) { - $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin'); + $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref); $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n"; $message_admin .= '
  • '.$langs->trans('Title').' : '.$object->subject.'
  • '; $message_admin .= '
  • '.$langs->trans('Type').' : '.$object->type_label.'
  • '; @@ -314,7 +314,7 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs'); // Make a redirect to avoid to have ticket submitted twice if we make back - setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', ''.$object->track_id.''), null, 'warnings'); + setEventMessages($langs->trans('MesgInfosPublicTicketCreatedWithTrackId', ''.$object->track_id.'', '' . $object->ref . ''), null, 'warnings'); setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); header("Location: index.php"); exit; From 4e2bc6a7418cb01536c6c4a85ab558b00f2529bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 18:23:56 +0100 Subject: [PATCH 28/57] Fix alignment --- htdocs/adherents/subscription.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 20854f57279..bc38ce3307b 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -691,11 +691,11 @@ if ($rowid > 0) print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($conf->banque->enabled)) { print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); From c0c413b219c267d05773d1b1634553ccd9ad1a37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 18:32:57 +0100 Subject: [PATCH 29/57] Alignement --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index bc38ce3307b..30ecafcf3e4 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -698,7 +698,7 @@ if ($rowid > 0) print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($conf->banque->enabled)) { - print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); } print "\n"; From f8c15a14cfc173d10297753c478bced7a352234e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Dec 2019 19:11:36 +0100 Subject: [PATCH 30/57] Add try catch --- htdocs/public/payment/paymentok.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 0efb3fad571..39208170213 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -471,18 +471,26 @@ if ($ispaymentok) if (! $customer && $TRANSACTIONID) // Not linked to a stripe customer, we make the link { - dol_syslog("No stripe profile found, so we add it", LOG_DEBUG, 0, '_payment'); + dol_syslog("No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0, '_payment'); - $ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id - $stripecu = $ch->customer; // value 'cus_....' + try { + $ch = \Stripe\Charge::retrieve($TRANSACTIONID); // contains the charge id + $stripecu = $ch->customer; // value 'cus_....' - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_account (fk_soc, login, key_account, site, status, entity, date_creation, fk_user_creat)"; - $sql .= " VALUES (".$object->fk_soc.", '', '".$db->escape($stripecu)."', 'stripe', " . $servicestatus . ", " . $conf->entity . ", '".$db->idate(dol_now())."', 0)"; - $resql = $db->query($sql); - if (! $resql) - { + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_account (fk_soc, login, key_account, site, status, entity, date_creation, fk_user_creat)"; + $sql .= " VALUES (".$object->fk_soc.", '', '".$db->escape($stripecu)."', 'stripe', " . $servicestatus . ", " . $conf->entity . ", '".$db->idate(dol_now())."', 0)"; + $resql = $db->query($sql); + if (! $resql) + { + $error++; + $errmsg='Failed to save customer stripe id in database ; '.$db->lasterror(); + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + } + } + catch(Exception $e) { $error++; - $errmsg='Failed to save customer stripe id in database ; '.$db->lasterror(); + $errmsg='Failed to save customer stripe id in database ; '.$e->getMessage(); $postactionmessages[] = $errmsg; $ispostactionok = -1; } From 3825e9af06bc7c65a2feb0cbefa6abab857eb44f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 03:00:10 +0100 Subject: [PATCH 31/57] FIX logo not found in some cases --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 6 ++++-- .../core/modules/commande/doc/pdf_eratosthene.modules.php | 6 ++++-- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 6 ++++-- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 6 ++++-- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 6 ++++-- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 6 ++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 994b71a416d..075ba0efb84 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1260,12 +1260,14 @@ class pdf_einstein extends ModelePDFCommandes { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 68fa5f179e7..6342cd6ce74 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1393,12 +1393,14 @@ class pdf_eratosthene extends ModelePDFCommandes { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index f39934a7f65..64aa3c52e25 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1618,12 +1618,14 @@ class pdf_crabe extends ModelePDFFactures { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index ecaa4ba14a0..3e00e2cab68 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1834,12 +1834,14 @@ class pdf_sponge extends ModelePDFFactures { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 4391c52d482..9219de5863c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1467,12 +1467,14 @@ class pdf_azur extends ModelePDFPropales { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index b26b8831f32..1e67ac6485c 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1503,12 +1503,14 @@ class pdf_cyan extends ModelePDFPropales { if ($this->emetteur->logo) { + $logodir = $conf->mycompany->dir_output; + if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small; + $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $logodir.'/logos/'.$this->emetteur->logo; } if (is_readable($logo)) { From e4a03e98b71b15690884440dc66252886cf7b709 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 12:47:01 +0100 Subject: [PATCH 32/57] FIX Do not record resource owner of event when not defined. More log to track payment errors. --- htdocs/adherents/admin/website.php | 8 ++--- htdocs/comm/action/class/actioncomm.class.php | 30 +++++++++++-------- ...terface_50_modAgenda_ActionsAuto.class.php | 3 +- htdocs/public/payment/paymentok.php | 22 +++++++++----- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index cfbeb29c7c3..a2eead267af 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -142,14 +142,14 @@ $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' '; if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } @@ -174,8 +174,8 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) $adht = new AdherentType($db); print ''; print $langs->trans("ForceMemberType"); - print ''; - $listofval = array(-1 => $langs->trans("Undefined")); + print ''; + $listofval = array(); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2de1b00c683..95cbd6beb7a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -514,9 +514,10 @@ class ActionComm extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); - // Now insert assignedusers + // Now insert assigned users if (!$error) { + //dol_syslog(var_export($this->userassigned, true)); foreach ($this->userassigned as $key => $val) { if (!is_array($val)) // For backward compatibility when val=id @@ -524,16 +525,20 @@ class ActionComm extends CommonObject $val = array('id'=>$val); } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; + if ($val['id'] > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; - $resql = $this->db->query($sql); - if (!$resql) - { - $error++; - $this->errors[] = $this->db->lasterror(); - } - //var_dump($sql);exit; + $resql = $this->db->query($sql); + if (!$resql) + { + $error++; + dol_syslog('Error to process userassigned: '.$this->db->lasterror(), LOG_ERR); + $this->errors[] = $this->db->lasterror(); + } + //var_dump($sql);exit; + } } } @@ -541,7 +546,7 @@ class ActionComm extends CommonObject { if (!empty($this->socpeopleassigned)) { - foreach ($this->socpeopleassigned as $id => $Tab) + foreach ($this->socpeopleassigned as $id => $val) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; @@ -550,6 +555,7 @@ class ActionComm extends CommonObject if (!$resql) { $error++; + dol_syslog('Error to process socpeopleassigned: '.$this->db->lasterror(), LOG_ERR); $this->errors[] = $this->db->lasterror(); } } @@ -558,8 +564,6 @@ class ActionComm extends CommonObject if (!$error) { - $action = 'create'; - // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e72da40d6b0..26958aed875 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -954,8 +954,7 @@ class InterfaceActionsAuto extends DolibarrTriggers } else { - $error ="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); - $this->error=$error; + $this->error="Failed to insert event : ".$actioncomm->error." ".join(',', $actioncomm->errors); $this->errors=$actioncomm->errors; dol_syslog("interface_modAgenda_ActionsAuto.class.php: ".$this->error, LOG_ERR); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 39208170213..4661067b78e 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -109,7 +109,7 @@ $ErrorCode=$ErrorShortMsg=$ErrorLongMsg=$ErrorSeverityCode=''; $object = new stdClass(); // For triggers - +$error = 0; /* @@ -205,11 +205,11 @@ if (! empty($conf->paypal->enabled)) if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") { // Nothing to do - dol_syslog("Call to GetExpressCheckoutDetails return ".$ack); + dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment'); } else { - dol_syslog("Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING); + dol_syslog("Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, '_payment'); } dol_syslog("We call DoExpressCheckoutPayment token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment'); @@ -219,7 +219,7 @@ if (! empty($conf->paypal->enabled)) $ack = strtoupper($resArray2["ACK"]); if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") { - dol_syslog("Call to GetExpressCheckoutDetails return ".$ack); + dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment'); $object->source = $source; $object->ref = $ref; @@ -238,7 +238,7 @@ if (! empty($conf->paypal->enabled)) } else { - dol_syslog("Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING); + dol_syslog("Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0, '_payment'); //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray2["L_ERRORCODE0"]); @@ -316,6 +316,8 @@ if ($ispaymentok) $result1 = $object->fetch($tmptag['MEM']); $result2 = $adht->fetch($object->typeid); + dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment'); + if ($result1 > 0 && $result2 > 0) { $paymentTypeId = 0; @@ -329,7 +331,9 @@ if ($ispaymentok) $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; + $currencyCodeType = $_SESSION['currencyCodeType']; + + dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId, LOG_DEBUG, 0, '_payment'); // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) @@ -342,6 +346,7 @@ if ($ispaymentok) $postactionmessages[] = $errmsg; $postactionmessages = array_merge($postactionmessages, $object->errors); $ispostactionok = -1; + dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment'); } // Subscription informations @@ -366,9 +371,10 @@ if ($ispaymentok) if ($accountid < 0) { $error++; - $errmsg='Setup of bank accout to use for payment is not correctly done for payment method '.$paymentmethod; + $errmsg='Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod; $postactionmessages[] = $errmsg; $ispostactionok = -1; + dol_syslog("Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0, '_payment'); } $operation=$paymentType; // Payment mode code @@ -844,10 +850,12 @@ if ($ispaymentok) if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); + //dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0); } else { dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + //dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0); } } } From 6fdb5d8e33b16e8d8889b0ca807b367f6d46c5d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 13:14:00 +0100 Subject: [PATCH 33/57] FIX ref --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dfe8535b3bc..498fa314315 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7494,7 +7494,7 @@ abstract class CommonObject if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); @@ -7729,6 +7729,7 @@ abstract class CommonObject if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); From 821ff375b0bf39c52179b947aeb25668b853eea9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 13:15:42 +0100 Subject: [PATCH 34/57] Fix update ref --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dfe8535b3bc..498fa314315 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7494,7 +7494,7 @@ abstract class CommonObject if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. - if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); @@ -7729,6 +7729,7 @@ abstract class CommonObject if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. + if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data $keys = array(); $values = array(); From d175b3432397227a349d4ab931be56463113f373 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 13:22:20 +0100 Subject: [PATCH 35/57] Fix log --- htdocs/core/class/translate.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index e54de5a91d2..4f6d6750040 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -221,7 +221,7 @@ class Translate if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { - dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: ".get_class($this)."::load was called for domain=".$domain." but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } @@ -428,7 +428,7 @@ class Translate if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir { - dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + dol_syslog("Error: ".get_class($this)."::loadFromDatabase was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); return -1; } From bf9f9df50fbce234eb028a8518bf2bc6ae11b45c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 13:46:09 +0100 Subject: [PATCH 36/57] Fix var not defined --- htdocs/core/class/interfaces.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 304a7a248a3..460dbe6e90c 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -109,8 +109,10 @@ class Interfaces $handle = opendir($newdir); if (is_resource($handle)) { + $fullpathfiles = array(); while (($file = readdir($handle)) !== false) { + $reg=array(); if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { $part1 = $reg[1]; @@ -274,6 +276,7 @@ class Interfaces { while (($file = readdir($handle)) !== false) { + $reg = array(); if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) { if (preg_match('/\.back$/', $file)) continue; From 3d9886309222745c9a379a6767f96ba7b1756bea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 13:51:14 +0100 Subject: [PATCH 37/57] Fix bad position of lang loading --- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 16d5a3659a5..5744a29db48 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -118,9 +118,6 @@ class InterfaceStripe // Data and type of action are stored into $object and $action global $langs, $db, $conf; - // Load translation files required by the page - $langs->loadLangs(array("members","other","users","mails")); - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); From 2ac6a8a3db7f06b6cfebc6749ef4588e8da2c2d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 14:30:16 +0100 Subject: [PATCH 38/57] Fix ping after update --- htdocs/install/upgrade2.php | 7 ++++++- htdocs/main.inc.php | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 2ef48bc9f0b..4d29f03003e 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -180,7 +180,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ /*************************************************************************************** * - * Migration des donnees + * Migration of data * ***************************************************************************************/ $db->begin(); @@ -553,6 +553,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ print ''; + + $sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'"; + $db->query($sql, 1); + + // We always commit. // Process is designed so we can run it several times whatever is situation. $db->commit(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f117dce2509..b5edc0c919d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2552,7 +2552,7 @@ if (!function_exists("llxFooter")) print ''."\n"; // Add code for the asynchronous anonymous first ping (for telemetry) - // You can use &forceping=1 in parameters to force the ping. + // You can use &forceping=1 in parameters to force the ping if the ping was already sent. if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha')) { //print ''; @@ -2562,14 +2562,14 @@ if (!function_exists("llxFooter")) || GETPOST('forceping', 'alpha')) { if (strpos('alpha', DOL_VERSION) > 0) { - print "\n\n"; + print "\n\n"; } - elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) + elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) // Cookie is set when we uncheck the checkbox in the installation wizard. { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print "\n".''."\n"; - print "\n\n"; + print "\n\n"; $url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING); ?> '; - print ''; - print "\n"; + ?> + + +\n"; -if (!empty($usemargins) && $user->rights->margins->creer) -{ - ?> - - /* Some js test when we click on button "Add" */ - jQuery(document).ready(function() { - global->DISPLAY_MARGIN_RATES)) { ?> - $("input[name='np_marginRate']:first").blur(function(e) { - return checkFreeLine(e, "np_marginRate"); - }); - global->DISPLAY_MARK_RATES)) { ?> - $("input[name='np_markRate']:first").blur(function(e) { - return checkFreeLine(e, "np_markRate"); - }); - - }); - - /* TODO This does not work for number with thousand separator that is , */ - function checkFreeLine(e, npRate) - { - var buying_price = $("input[name='buying_price']:first"); - var remise = $("input[name='remise_percent']:first"); - - var rate = $("input[name='"+npRate+"']:first"); - if (rate.val() == '') - return true; - - if (! $.isNumeric(rate.val().replace(',','.'))) - { - alert('trans("rateMustBeNumeric")); ?>'); - e.stopPropagation(); - setTimeout(function () { rate.focus() }, 50); - return false; - } - if (npRate == "np_markRate" && rate.val() >= 100) - { - alert('trans("markRateShouldBeLesserThan100")); ?>'); - e.stopPropagation(); - setTimeout(function () { rate.focus() }, 50); - return false; - } - - var price = 0; - remisejs=price2numjs(remise.val()); - - if (remisejs != 100) // If a discount not 100 or no discount - { - if (remisejs == '') remisejs=0; - - bpjs=price2numjs(buying_price.val()); - ratejs=price2numjs(rate.val()); - - if (npRate == "np_marginRate") - price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); - else if (npRate == "np_markRate") - price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); - } - $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value - - return true; - } + if (!empty($usemargins) && $user->rights->margins->creer) + { + ?> + /* Some js test when we click on button "Add" */ + jQuery(document).ready(function() { + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { ?> + $("input[name='np_marginRate']:first").blur(function(e) { + return checkFreeLine(e, "np_marginRate"); + }); + global->DISPLAY_MARK_RATES)) { ?> + $("input[name='np_markRate']:first").blur(function(e) { + return checkFreeLine(e, "np_markRate"); + }); + + }); + + /* TODO This does not work for number with thousand separator that is , */ + function checkFreeLine(e, npRate) + { + var buying_price = $("input[name='buying_price']:first"); + var remise = $("input[name='remise_percent']:first"); + + var rate = $("input[name='"+npRate+"']:first"); + if (rate.val() == '') + return true; + + if (! $.isNumeric(rate.val().replace(',','.'))) + { + alert('trans("rateMustBeNumeric")); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + if (npRate == "np_markRate" && rate.val() >= 100) + { + alert('trans("markRateShouldBeLesserThan100")); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + + var price = 0; + remisejs=price2numjs(remise.val()); + + if (remisejs != 100) // If a discount not 100 or no discount + { + if (remisejs == '') remisejs=0; + + bpjs=price2numjs(buying_price.val()); + ratejs=price2numjs(rate.val()); + + if (npRate == "np_marginRate") + price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); + else if (npRate == "np_markRate") + price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + } + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value + + return true; + } + + /* JQuery for product free or predefined select */ jQuery(document).ready(function() { @@ -621,199 +623,200 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* When changing predefined product, we reload list of supplier prices required for margin combo */ $("#idprod, #idprodfournprice").change(function() { - console.log("#idprod, #idprodfournprice change triggered"); + console.log("#idprod, #idprodfournprice change triggered this.val = "+$(this).val()); - setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva + setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva - jQuery('#trlinefordates').show(); - global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) - { - ?> - // get the HT price for the product and display it - $.post('/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : socid; ?> }, function(data) { - jQuery("#price_ht").val(data.price_ht); - }, - 'json'); + jQuery('#trlinefordates').show(); rights->margins->creer) - { - $langs->load('stocks'); + if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier)) + { + ?> + // Get the HT price for the product and display it + $.post('/product/ajax/products.php?action=fetch', + { 'id': $(this).val(), 'socid' : socid; ?> }, + function(data) { jQuery("#price_ht").val(data.price_ht); }, + 'json' + ); + rights->margins->creer) + { + $langs->load('stocks'); + ?> + + /* Code for margin */ + $("#fournprice_predef").find("option").remove(); + $("#fournprice_predef").hide(); + $("#buying_price").val("").show(); + /* Call post to load content of combo list fournprice_predef */ + $.post('/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) { + if (data && data.length > 0) + { + var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0; + + var bestpriceid = 0; var bestpricevalue = 0; + var pmppriceid = 0; var pmppricevalue = 0; + var costpriceid = 0; var costpricevalue = 0; + + /* setup of margin calculation */ + var defaultbuyprice = 'global->MARGIN_TYPE)) + { + if ($conf->global->MARGIN_TYPE == '1') print 'bestsupplierprice'; + if ($conf->global->MARGIN_TYPE == 'pmp') print 'pmp'; + if ($conf->global->MARGIN_TYPE == 'costprice') print 'costprice'; + } ?>'; + console.log("we will set the field for margin. defaultbuyprice="+defaultbuyprice); + + var i = 0; + $(data).each(function() { + if (this.id != 'pmpprice' && this.id != 'costprice') + { + i++; + this.price = parseFloat(this.price); // to fix when this.price >0 + // If margin is calculated on best supplier price, we set it by defaut (but only if value is not 0) + //console.log("id="+this.id+"-price="+this.price+"-"+(this.price > 0)); + if (bestpricefound == 0 && this.price > 0) { defaultkey = this.id; defaultprice = this.price; bestpriceid = this.id; bestpricevalue = this.price; bestpricefound=1; } // bestpricefound is used to take the first price > 0 + } + if (this.id == 'pmpprice') + { + // If margin is calculated on PMP, we set it by defaut (but only if value is not 0) + //console.log("id="+this.id+"-price="+this.price); + if ('pmp' == defaultbuyprice || 'costprice' == defaultbuyprice) + { + if (this.price > 0) { + defaultkey = this.id; defaultprice = this.price; pmppriceid = this.id; pmppricevalue = this.price; + //console.log("pmppricevalue="+pmppricevalue); + } + } + } + if (this.id == 'costprice') + { + // If margin is calculated on Cost price, we set it by defaut (but only if value is not 0) + //console.log("id="+this.id+"-price="+this.price+"-pmppricevalue="+pmppricevalue); + if ('costprice' == defaultbuyprice) + { + if (this.price > 0) { defaultkey = this.id; defaultprice = this.price; costpriceid = this.id; costpricevalue = this.price; } + else if (pmppricevalue > 0) { defaultkey = pmppriceid; defaultprice = pmppricevalue; } + } + } + options += ''; + }); + options += ''; + + console.log("finally selected defaultkey="+defaultkey+" defaultprice="+defaultprice); + + $("#fournprice_predef").html(options).show(); + if (defaultkey != '') + { + $("#fournprice_predef").val(defaultkey); + } + + /* At loading, no product are yet selected, so we hide field of buying_price */ + $("#buying_price").hide(); + + /* Define default price at loading */ + var defaultprice = $("#fournprice_predef").find('option:selected').attr("price"); + $("#buying_price").val(defaultprice); + + $("#fournprice_predef").change(function() { + console.log("change on fournprice_predef"); + /* Hide field buying_price according to choice into list (if 'inputprice' or not) */ + var linevalue=$(this).find('option:selected').val(); + var pricevalue = $(this).find('option:selected').attr("price"); + if (linevalue != 'inputprice' && linevalue != 'pmpprice') { + $("#buying_price").val(pricevalue).hide(); /* We set value then hide field */ + } + if (linevalue == 'inputprice') { + $('#buying_price').show(); + } + if (linevalue == 'pmpprice') { + $("#buying_price").val(pricevalue); + $('#buying_price').hide(); + } + }); + } + }, + 'json'); + + - /* Code for margin */ - $("#fournprice_predef").find("option").remove(); - $("#fournprice_predef").hide(); - $("#buying_price").val("").show(); - /* Call post to load content of combo list fournprice_predef */ - $.post('/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) { - if (data && data.length > 0) + /* To process customer price per quantity */ + var pbq = parseInt($('option:selected', this).attr('data-pbq')); + var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); + var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); + + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") { - var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0; - - var bestpriceid = 0; var bestpricevalue = 0; - var pmppriceid = 0; var pmppricevalue = 0; - var costpriceid = 0; var costpricevalue = 0; - - /* setup of margin calculation */ - var defaultbuyprice = 'global->MARGIN_TYPE)) + console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); + jQuery("#pbq").val(pbq); + if (jQuery("#qty").val() < pbqqty) + { + jQuery("#qty").val(pbqqty); + } + if (jQuery("#remise_percent").val() < pbqpercent) + { + jQuery("#remise_percent").val(pbqpercent); + } + } + else { - if ($conf->global->MARGIN_TYPE == '1') print 'bestsupplierprice'; - if ($conf->global->MARGIN_TYPE == 'pmp') print 'pmp'; - if ($conf->global->MARGIN_TYPE == 'costprice') print 'costprice'; - } ?>'; - console.log("we will set the field for margin. defaultbuyprice="+defaultbuyprice); + jQuery("#pbq").val(''); + } - var i = 0; - $(data).each(function() { - if (this.id != 'pmpprice' && this.id != 'costprice') + /* To set focus */ + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { - i++; - this.price = parseFloat(this.price); // to fix when this.price >0 - // If margin is calculated on best supplier price, we set it by defaut (but only if value is not 0) - //console.log("id="+this.id+"-price="+this.price+"-"+(this.price > 0)); - if (bestpricefound == 0 && this.price > 0) { defaultkey = this.id; defaultprice = this.price; bestpriceid = this.id; bestpricevalue = this.price; bestpricefound=1; } // bestpricefound is used to take the first price > 0 + /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + jQuery('#dp_desc').focus(); + /* focus if CKEDITOR */ + if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { editor.focus(); } + } } - if (this.id == 'pmpprice') - { - // If margin is calculated on PMP, we set it by defaut (but only if value is not 0) - //console.log("id="+this.id+"-price="+this.price); - if ('pmp' == defaultbuyprice || 'costprice' == defaultbuyprice) - { - if (this.price > 0) { - defaultkey = this.id; defaultprice = this.price; pmppriceid = this.id; pmppricevalue = this.price; - //console.log("pmppricevalue="+pmppricevalue); - } - } - } - if (this.id == 'costprice') - { - // If margin is calculated on Cost price, we set it by defaut (but only if value is not 0) - //console.log("id="+this.id+"-price="+this.price+"-pmppricevalue="+pmppricevalue); - if ('costprice' == defaultbuyprice) - { - if (this.price > 0) { defaultkey = this.id; defaultprice = this.price; costpriceid = this.id; costpricevalue = this.price; } - else if (pmppricevalue > 0) { defaultkey = pmppriceid; defaultprice = pmppricevalue; } - } - } - options += ''; - }); - options += ''; - - console.log("finally selected defaultkey="+defaultkey+" defaultprice="+defaultprice); - - $("#fournprice_predef").html(options).show(); - if (defaultkey != '') - { - $("#fournprice_predef").val(defaultkey); - } - - /* At loading, no product are yet selected, so we hide field of buying_price */ - $("#buying_price").hide(); - - /* Define default price at loading */ - var defaultprice = $("#fournprice_predef").find('option:selected').attr("price"); - $("#buying_price").val(defaultprice); - - $("#fournprice_predef").change(function() { - console.log("change on fournprice_predef"); - /* Hide field buying_price according to choice into list (if 'inputprice' or not) */ - var linevalue=$(this).find('option:selected').val(); - var pricevalue = $(this).find('option:selected').attr("price"); - if (linevalue != 'inputprice' && linevalue != 'pmpprice') { - $("#buying_price").val(pricevalue).hide(); /* We set value then hide field */ - } - if (linevalue == 'inputprice') { - $('#buying_price').show(); - } - if (linevalue == 'pmpprice') { - $("#buying_price").val(pricevalue); - $('#buying_price').hide(); - } - }); - } - }, - 'json'); - - - - /* To process customer price per quantity */ - var pbq = parseInt($('option:selected', this).attr('data-pbq')); - var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); - var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); - - if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") - { - console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); - jQuery("#pbq").val(pbq); - if (jQuery("#qty").val() < pbqqty) - { - jQuery("#qty").val(pbqqty); - } - if (jQuery("#remise_percent").val() < pbqpercent) - { - jQuery("#remise_percent").val(pbqpercent); - } - } - else - { - jQuery("#pbq").val(''); - } - - /* To set focus */ - if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) - { - /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ - jQuery('#dp_desc').focus(); - /* focus if CKEDITOR */ - if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") - { - var editor = CKEDITOR.instances['dp_desc']; - if (editor) { editor.focus(); } - } - } }); - + setforpredef(); - + }); /* Function to set fields from choice */ function setforfree() { - console.log("Call setforfree. We show most fields"); - jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product - jQuery("#prod_entry_mode_free").prop('checked',true).change(); - jQuery("#prod_entry_mode_predef").prop('checked',false).change(); - jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); - jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); - jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); - jQuery("#fournprice_predef").hide(); + console.log("Call setforfree. We show most fields"); + jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product + jQuery("#prod_entry_mode_free").prop('checked',true).change(); + jQuery("#prod_entry_mode_predef").prop('checked',false).change(); + jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); + jQuery("#fournprice_predef").hide(); } function setforpredef() { - console.log("Call setforpredef. We hide some fields and show dates"); - jQuery("#select_type").val(-1); - jQuery("#prod_entry_mode_free").prop('checked',false).change(); - jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> - jQuery("#price_ht").val('').show(); - jQuery("#multicurrency_price_ht").val('').show(); - - jQuery("#price_ht").val('').hide(); - jQuery("#multicurrency_price_ht").val('').hide(); - - jQuery("#price_ht").val(''); - jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); - jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); - jQuery("#buying_price").show(); - jQuery('#trlinefordates, .divlinefordates').show(); + console.log("Call setforpredef. We hide some fields and show dates"); + jQuery("#select_type").val(-1); + jQuery("#prod_entry_mode_free").prop('checked',false).change(); + jQuery("#prod_entry_mode_predef").prop('checked',true).change(); + global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> + jQuery("#price_ht").val('').show(); + jQuery("#multicurrency_price_ht").val('').show(); + + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").val('').hide(); + + jQuery("#price_ht").val(''); + jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); + jQuery("#buying_price").show(); + jQuery('#trlinefordates, .divlinefordates').show(); } - - - + +\n"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 957561466c7..4e6523ff6cb 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -361,7 +361,7 @@ if (empty($reshook)) else { $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -420,15 +420,14 @@ if (empty($reshook)) } } - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (($prod_entry_mode != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); $idprod = 0; if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + + $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; @@ -470,7 +469,22 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if ($price_ht != '' || $price_ht_devise != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; + /*var_dump($pu); + var_dump($pu_ht_devise);exit;*/ + } + } $ref_supplier = $productsupplier->ref_supplier; @@ -480,7 +494,6 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu = $productsupplier->fourn_pu; if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value $result = $object->addline( @@ -503,7 +516,9 @@ if (empty($reshook)) $date_end, $array_options, $productsupplier->fk_unit, - $productsupplier->fourn_multicurrency_unitprice + $pu_ht_devise, + '', + 0 ); } if ($idprod == -99 || $idprod == 0) @@ -2200,7 +2215,7 @@ elseif (!empty($object->id)) print ''; - if (!empty($conf->multicurrency->enabled)) + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { // Multicurrency Amount HT print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 9f08e944ee0..fab706b7221 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -101,6 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php $permissiontoadd = $user->rights->fournisseur->facture->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -1143,7 +1144,7 @@ if (empty($reshook)) else { $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -1209,6 +1210,7 @@ if (empty($reshook)) $idprod = 0; if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $reg = array(); if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { $idprod = $reg[1]; @@ -1250,7 +1252,20 @@ if (empty($reshook)) if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if ($price_ht != '' || $price_ht_devise != '') { + $price_base_type = 'HT'; + $pu = price2num($price_ht, 'MU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + } else { + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); + if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = 0; + } else { + $pu = $productsupplier->fourn_pu; + $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; + } + } $ref_supplier = $productsupplier->ref_supplier; @@ -1260,7 +1275,6 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu = $productsupplier->fourn_pu; if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value $result = $object->addline( @@ -1283,8 +1297,9 @@ if (empty($reshook)) $array_options, $productsupplier->fk_unit, 0, - $productsupplier->fourn_multicurrency_unitprice, - $ref_supplier + $pu_ht_devise, + $ref_supplier, + '' ); } if ($idprod == -99 || $idprod == 0) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 8a2d643189b..19fd7926453 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -18,8 +18,8 @@ */ /** - * \file htdocs/product/ajax/products.php - * \brief File to return Ajax response on product list request + * \file htdocs/product/ajax/products.php + * \brief File to return Ajax response on product list request. */ if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal @@ -59,6 +59,7 @@ dol_syslog(join(',', $_GET)); if (!empty($action) && $action == 'fetch' && !empty($id)) { + // When action='fetch', id must be the product id. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $outjson = array(); From 90a78267c5913795ccb788f24327b172a1fbcee6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 17:31:29 +0100 Subject: [PATCH 41/57] Trans --- htdocs/langs/en_US/bills.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 902790cc23a..e6ea4390fd8 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -61,7 +61,7 @@ Payment=Payment PaymentBack=Payment back CustomerInvoicePaymentBack=Payment back Payments=Payments -PaymentsBack=Payments back +PaymentsBack=Refunds paymentInInvoiceCurrency=in invoices currency PaidBack=Paid back DeletePayment=Delete payment @@ -78,7 +78,7 @@ ReceivedCustomersPaymentsToValid=Received customers payments to validate PaymentsReportsForYear=Payments reports for %s PaymentsReports=Payments reports PaymentsAlreadyDone=Payments already done -PaymentsBackAlreadyDone=Payments back already done +PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule PaymentMode=Payment Type PaymentTypeDC=Debit/Credit Card From 84d0ae7ac58023e6e338e26fd594b9d3d8a17c97 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 17:31:29 +0100 Subject: [PATCH 42/57] Trans --- htdocs/langs/en_US/bills.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 902790cc23a..e6ea4390fd8 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -61,7 +61,7 @@ Payment=Payment PaymentBack=Payment back CustomerInvoicePaymentBack=Payment back Payments=Payments -PaymentsBack=Payments back +PaymentsBack=Refunds paymentInInvoiceCurrency=in invoices currency PaidBack=Paid back DeletePayment=Delete payment @@ -78,7 +78,7 @@ ReceivedCustomersPaymentsToValid=Received customers payments to validate PaymentsReportsForYear=Payments reports for %s PaymentsReports=Payments reports PaymentsAlreadyDone=Payments already done -PaymentsBackAlreadyDone=Payments back already done +PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule PaymentMode=Payment Type PaymentTypeDC=Debit/Credit Card From ce7360ced3754ca885c4d184efe3054700495b45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 18:43:46 +0100 Subject: [PATCH 43/57] Code comment --- htdocs/core/class/commoninvoice.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index b6381ccc7ca..eb2e55d6279 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -107,7 +107,8 @@ abstract class CommonInvoice extends CommonObject } /** - * Return amount of payments already done + * Return amount of payments already done. This must include ONLY the record into the payment table. + * Payments dones using discounts, credit notes, etc are not included. * * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Amount of payment already done, <0 if KO From b50cb2a65d3cdd1de8e4d6da362b3c06ac10f9ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 19:04:14 +0100 Subject: [PATCH 44/57] Fix solution to solve a blocking situation (credit note both refunded and consumed) --- htdocs/compta/facture/card.php | 21 ++++++++++++++- htdocs/fourn/facture/card.php | 49 ++++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2cacb885fa9..4f9229bf839 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -780,6 +780,23 @@ if (empty($reshook)) } } + // If some payments were already done, we change the amount to pay using same prorate + if (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. + if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { + $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); + foreach($amount_ht as $vatrate => $val) { + $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); + $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); + $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); + } + } + } + //var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit; + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); if ($object->type == Facture::TYPE_CREDIT_NOTE) @@ -5014,7 +5031,9 @@ elseif ($id > 0 || !empty($ref)) print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) { + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate + && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + ) { print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index fab706b7221..1e0ea5ba92a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -99,6 +99,8 @@ if (!empty($user->socid)) $socid = $user->socid; $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft); +$usercancreate = $user->rights->fournisseur->facture->creer; + $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->fournisseur->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->fournisseur->facture->creer; // Used by the include of actions_lineupdown.inc.php @@ -403,7 +405,7 @@ if (empty($reshook)) $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } - elseif ($action == "setabsolutediscount" && $user->rights->fournisseur->facture->creer) + elseif ($action == "setabsolutediscount" && $usercancreate) { // POST[remise_id] or POST[remise_id_for_payment] @@ -461,7 +463,7 @@ if (empty($reshook)) } } // Convertir en reduc - elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->fournisseur->facture->creer) + elseif ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate) { $object->fetch($id); $object->fetch_thirdparty(); @@ -473,13 +475,14 @@ if (empty($reshook)) $canconvert = 0; if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc) if ($canconvert) { $db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); - + $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); + // Loop on each vat rate $i = 0; foreach ($object->lines as $line) @@ -493,6 +496,20 @@ if (empty($reshook)) } } + // If some payments were already done, we change the amount to pay using same prorate + if (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. + if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { + $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); + foreach($amount_ht as $vatrate => $val) { + $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); + $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); + $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); + } + } + } + //var_dump($amount_ht);var_dump($amount_tva);var_dump($amount_ttc);exit; + // Insert one discount by VAT rate category $discount = new DiscountAbsolute($db); if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) @@ -514,6 +531,7 @@ if (empty($reshook)) { // If we're on a standard invoice, we have to get excess paid to create a discount in TTC without VAT + // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.getEntity('c_paiement').')'; @@ -527,7 +545,20 @@ if (empty($reshook)) $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; - $discount->amount_ht = $discount->amount_ttc = $total_paiements - $object->total_ttc; + // Total credit note and deposit + $total_creditnote_and_deposit = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_invoice_supplier_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_invoice_supplier = ".$object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); + + $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; @@ -601,7 +632,7 @@ if (empty($reshook)) } // Create - elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) + elseif ($action == 'add' && $usercancreate) { if ($socid > 0) $object->socid = GETPOST('socid', 'int'); @@ -633,7 +664,7 @@ if (empty($reshook)) if (!$error) { // This is a replacement invoice - $result = $object->fetch(GETPOST('fac_replacement'), 'int'); + $result = $object->fetch(GETPOST('fac_replacement', 'int')); $object->fetch_thirdparty(); $object->ref = GETPOST('ref', 'nohtml'); @@ -3144,7 +3175,9 @@ else print ''; } // For credit note - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() == 0) { + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->fournisseur->facture->creer + && (! empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + ) { print ''; } // For deposit invoice From e005416189841b0e9aeb831253c746adcce10d24 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 1 Jan 2020 21:19:23 +0100 Subject: [PATCH 45/57] If press enter add automatically the product. Widely used with barcodes. --- htdocs/takepos/takepos.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index ba9f2318508..b059885d64a 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -426,6 +426,7 @@ function New() { function Search2() { console.log("Search2 Call ajax search to replace products"); + if(window.event.keyCode == 13) ClickProduct(0); pageproducts=0; jQuery(".wrapper2 .catwatermark").hide(); $.getJSON('/takepos/ajax/ajax.php?action=search&term='+$('#search').val(), function(data) { From 2e8fd25299c7f7d10b0c1a067f03cfb6e839b77e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 21:54:47 +0100 Subject: [PATCH 46/57] FIX Local taxes was not correctly supported in TakePOS. --- htdocs/compta/facture/card.php | 2 +- htdocs/core/lib/functions.lib.php | 1 + htdocs/product/class/product.class.php | 38 +++++++------- htdocs/takepos/invoice.php | 70 +++++++++++++++++--------- htdocs/takepos/takepos.php | 10 +++- 5 files changed, 74 insertions(+), 47 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4f9229bf839..3f3bffc6cd2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1537,7 +1537,7 @@ if (empty($reshook)) if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; // View third's localtaxes for NOW and do not use value from origin. - // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? + // TODO Is this really what we want ? Yes if source is template invoice but what if proposal or order ? $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7d82336dd16..eb58b94c7c2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4677,6 +4677,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); $vatratecleaned = $vatrate; + $reg = array(); if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" { $vatratecleaned = trim($reg[1]); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9e100871537..ca0f8112fc1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1597,26 +1597,25 @@ class Product extends CommonObject * @param Societe $thirdparty_seller Seller * @param Societe $thirdparty_buyer Buyer * @param int $pqp Id of product per price if a selection was done of such a price - * @return array Array of price information + * @return array Array of price information array('pu_ht'=> , 'pu_ttc'=> , 'tva_tx'=>'X.Y (code)', ...), 'tva_npr'=>0, ...) * @see get_buyprice(), find_min_price_product_fournisseur() */ public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0) { global $conf, $db; - // Update if prices fields are defined - $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); - $tva_npr = get_default_npr($thirdparty_seller, $thirdparty_buyer, $this->id); - if (empty($tva_tx)) $tva_npr = 0; + // Update if prices fields are defined + $tva_tx = get_default_tva($thirdparty_seller, $thirdparty_buyer, $this->id); + $tva_npr = get_default_npr($thirdparty_seller, $thirdparty_buyer, $this->id); + if (empty($tva_tx)) $tva_npr = 0; - $pu_ht = $this->price; - $pu_ttc = $this->price_ttc; - $price_min = $this->price_min; - $price_base_type = $this->price_base_type; + $pu_ht = $this->price; + $pu_ttc = $this->price_ttc; + $price_min = $this->price_min; + $price_base_type = $this->price_base_type; - // If price per segment - if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) - { + // If price per segment + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) { $pu_ht = $this->multiprices[$thirdparty_buyer->price_level]; $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level]; $price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; @@ -1628,9 +1627,8 @@ class Product extends CommonObject if (empty($tva_tx)) $tva_npr = 0; } } - // If price per customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { + // If price per customer + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -1650,9 +1648,8 @@ class Product extends CommonObject } } } - // If price per quantity - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) - { + // If price per quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id @@ -1672,9 +1669,8 @@ class Product extends CommonObject } } } - // If price per quantity and customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) - { + // If price per quantity and customer + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 23bc09a7268..f684d18741d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -43,6 +43,7 @@ $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $idproduct = GETPOST('idproduct', 'int'); $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant +$placeid = 0; // $placeid is ID of invoice if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone') { @@ -83,8 +84,6 @@ function fail($message) -$placeid = 0; // $placeid is id of invoice - $number = GETPOST('number', 'alpha'); $idline = GETPOST('idline', 'int'); $desc = GETPOST('desc', 'alpha'); @@ -121,6 +120,12 @@ if ($ret > 0) $placeid = $invoice->id; } +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + +$soc = new Societe($db); +if ($invoice->socid > 0) $soc->fetch($invoice->socid); +else $soc->fetch($conf->global->$constforcompanyid); + /* * Actions @@ -233,7 +238,7 @@ if ($action == 'history') if (($action == "addline" || $action == "freezone") && $placeid == 0) { - $invoice->socid = $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}; + $invoice->socid = $conf->global->$constforcompanyid; $invoice->date = dol_now(); $invoice->module_source = 'takepos'; $invoice->pos_source = $_SESSION["takeposterminal"]; @@ -263,27 +268,34 @@ if ($action == "addline") $customer = new Societe($db); $customer->fetch($invoice->socid); - $price = $prod->price; - $tva_tx = $prod->tva_tx; - $price_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; + $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); - if (!empty($conf->global->PRODUIT_MULTIPRICES)) - { - $price = $prod->multiprices[$customer->price_level]; - $tva_tx = $prod->multiprices_tva_tx[$customer->price_level]; - $price_ttc = $prod->multiprices_ttc[$customer->price_level]; - $price_base_type = $prod->multiprices_base_type[$customer->price_level]; - } + $price = $datapriceofproduct['pu_ht']; + $price_ttc = $datapriceofproduct['pu_ttc']; + //$price_min = $datapriceofproduct['price_min']; + $price_base_type = $datapriceofproduct['price_base_type']; + $tva_tx = $datapriceofproduct['tva_tx']; + $tva_npr = $datapriceofproduct['tva_npr']; - $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $prod->localtax1_tx, $prod->localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $idoflineadded = $invoice->addline($prod->description, $price, 1, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); $invoice->fetch($placeid); } if ($action == "freezone") { $customer = new Societe($db); $customer->fetch($invoice->socid); - $invoice->addline($desc, $number, 1, get_default_tva($mysoc, $customer), 0, 0, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); + + $tva_tx = get_default_tva($mysoc, $customer); + + // Local Taxes + $localtax1_tx = get_localtax($tva_tx, 1, $customer, $mysoc, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $customer, $mysoc, $tva_npr); + + $invoice->addline($desc, $number, 1, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', 0, 0, 0, '', 'TTC', $number, 0, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', null, 0); $invoice->fetch($placeid); } @@ -392,7 +404,8 @@ if ($action == "order" and $placeid != 0) $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { continue; + if ($line->special_code == "4") { + continue; } $c = new Categorie($db); $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); @@ -409,7 +422,8 @@ if ($action == "order" and $placeid != 0) foreach ($invoice->lines as $line) { - if ($line->special_code == "4") { continue; + if ($line->special_code == "4") { + continue; } $c = new Categorie($db); $existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id'); @@ -618,6 +632,7 @@ if ($_SESSION["basiclayout"] != 1) } print "\n"; + if ($_SESSION["basiclayout"] == 1) { if ($mobilepage == "cats") @@ -720,10 +735,20 @@ if ($placeid > 0) if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
    (".$line->array_options['options_order_notes'].")"; if ($_SESSION["basiclayout"] != 1) { + $moreinfo = ''; + $moreinfo .= $langs->transcountry("TotalHT", $mysoc->country_code).': '.price($line->total_ht); + if ($line->vat_src_code) $moreinfo .= '
    '.$langs->trans("VATCode").': '.$line->vat_src_code; + $moreinfo .= '
    '.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_vat); + //$moreinfo .= '
    '.$langs->transcountry("VATRate", $mysoc->country_code).': '.price($line->); + $moreinfo .= '
    '.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1); + $moreinfo .= '
    '.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); + $moreinfo .= '
    '.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); + //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; + $htmlforlines .= ''; $htmlforlines .= ''; $htmlforlines .= ''; - $htmlforlines .= ''; + $htmlforlines .= ''; } $htmlforlines .= ''."\n"; @@ -741,12 +766,9 @@ else { // No invoice generated yet print '
    '.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'
    '.vatrate($line->remise_percent, true).''.$line->qty.''.price($line->total_ttc).''.price($line->total_ttc).'
    '; -if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) + +if ($invoice->socid != $conf->global->$constforcompanyid) { - $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; - $soc = new Societe($db); - if ($invoice->socid > 0) $soc->fetch($invoice->socid); - else $soc->fetch($conf->global->$constforcompanyid); print ''; print '

    '; print $langs->trans("Customer").': '.$soc->name; diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index fed82019d62..4662681217e 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -34,11 +34,12 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant $action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); @@ -70,6 +71,13 @@ if ($conf->browser->layout == 'phone') $MAXCATEG = (empty($conf->global->TAKEPOS_NB_MAXCATEG) ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (empty($conf->global->TAKEPOS_NB_MAXPRODUCT) ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); +/* +$constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; +$soc = new Societe($db); +if ($invoice->socid > 0) $soc->fetch($invoice->socid); +else $soc->fetch($conf->global->$constforcompanyid); +*/ + /* * View From d3d75920723747d27aa2c9956b3b050ea8610e11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 22:26:47 +0100 Subject: [PATCH 47/57] FIX Warning for some country must appears if company is in this country. --- htdocs/admin/modules.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 1dfb49a6c05..0364b829b2c 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -825,10 +825,13 @@ if ($mode == 'common') $warningmessage = ''; if (!empty($arrayofwarnings[$modName])) { - print ''."\n"; + print ''."\n"; foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) { - $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); + if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) + { + $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code); + } } } if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) From 85d3b424f77f80b78227a1d9db3f14cfc3d39e0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 22:27:08 +0100 Subject: [PATCH 48/57] FIX: Substitution of login into link is wrong. --- htdocs/core/modules/modCashDesk.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 83752de24e7..83495ca1af6 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -99,7 +99,7 @@ class modCashDesk extends DolibarrModules 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'cashdesk', - 'url'=>'/cashdesk/index.php?user=__LOGIN__', + 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, 'enabled'=>'$conf->cashdesk->enabled', From e7ac01e1bde53b04f09e319b954fb341116f96d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 22:27:47 +0100 Subject: [PATCH 49/57] FIX localtax info were not returned correctly when call done with id. --- htdocs/core/lib/functions.lib.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index eb58b94c7c2..909d16d39e6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4922,13 +4922,14 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); // Search local taxes - $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; + $sql = "SELECT t.taux as rate, t.code, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; if ($firstparamisid) $sql .= " WHERE t.rowid = ".(int) $vatrate; else { $vatratecleaned = $vatrate; $vatratecode = ''; + $reg = array(); if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)" { $vatratecleaned = $reg[1]; @@ -4946,17 +4947,20 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi if ($resql) { $obj = $db->fetch_object($resql); + + $vateratestring = $obj->rate.($obj->code ? ' ('.$obj->code.')' : ''); + if ($local == 1) { - return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } elseif ($local == 2) { - return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax2_type, get_localtax($vateratestring, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } else { - return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + return array($obj->localtax1_type, get_localtax($vateratestring, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vateratestring, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); } } From b90dbb585a4f438c9d2f7859f3437949f27becf1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 22:45:47 +0100 Subject: [PATCH 50/57] Fix ident --- htdocs/core/tpl/objectline_create.tpl.php | 711 +++++++++++----------- 1 file changed, 355 insertions(+), 356 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 3e42e18e3f3..78364aa706a 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -434,389 +434,388 @@ if ($nolinesbefore) { if (is_object($objectline)) { print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); } + if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { -?> - -> - global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - - element) && $object->element == 'contrat') - { - print $langs->trans("DateStartPlanned").' '; - print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); - print '   '.$langs->trans("DateEndPlanned").' '; - print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct"); + print ''."\n"; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } + print ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + if (!empty($object->element) && $object->element == 'contrat') + { + print $langs->trans("DateStartPlanned").' '; + print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); + print '   '.$langs->trans("DateEndPlanned").' '; + print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct"); + } + else + { + print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); + print ' '.$langs->trans('to').' '; + print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); + }; + print ''; - ?> - - -global->MAIN_DEFAULT_DATE_END_MIN)) { + print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; + } + } + print ''; + print ''; + print ''."\n"; } - print " + /* To set focus */ + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + { + /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + jQuery('#dp_desc').focus(); + /* focus if CKEDITOR */ + if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { editor.focus(); } + } + } + }); + + + setforpredef(); + + }); + + /* Function to set fields from choice */ + function setforfree() { + console.log("Call setforfree. We show most fields"); + jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product + jQuery("#prod_entry_mode_free").prop('checked',true).change(); + jQuery("#prod_entry_mode_predef").prop('checked',false).change(); + jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); + jQuery("#fournprice_predef").hide(); + } + function setforpredef() { + console.log("Call setforpredef. We hide some fields and show dates"); + jQuery("#select_type").val(-1); + jQuery("#prod_entry_mode_free").prop('checked',false).change(); + jQuery("#prod_entry_mode_predef").prop('checked',true).change(); + global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> + jQuery("#price_ht").val('').show(); + jQuery("#multicurrency_price_ht").val('').show(); + + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").val('').hide(); + + jQuery("#price_ht").val(''); + jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); + jQuery("#buying_price").show(); + jQuery('#trlinefordates, .divlinefordates').show(); + } + '; + print "\n"; From 607d013a9da69c4ea398c73198989d0b066ad99e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 22:58:26 +0100 Subject: [PATCH 51/57] Fix phpcs --- htdocs/core/tpl/objectline_create.tpl.php | 44 +++++++++++------------ htdocs/fourn/facture/card.php | 4 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 78364aa706a..29570ec379c 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -356,35 +356,36 @@ if ($nolinesbefore) { "> - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $coldisplay++; ?> "> - "> - "> global->PRODUCT_USE_UNITS) - { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; print $form->selectUnits($line->fk_unit, "units"); print ''; } $remise_percent = $buyer->remise_percent; - if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') - { + if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') { $remise_percent = $seller->remise_supplier_percent; } $coldisplay++; @@ -397,8 +398,7 @@ if ($nolinesbefore) { $coldisplay++; print ''; } - if (!empty($usemargins)) - { + if (!empty($usemargins)) { if (!empty($user->rights->margins->creer)) { $coldisplay++; ?> @@ -486,19 +486,19 @@ if (!empty($usemargins) && $user->rights->margins->creer) /* Some js test when we click on button "Add" */ jQuery(document).ready(function() { global->DISPLAY_MARGIN_RATES)) { ?> - $("input[name='np_marginRate']:first").blur(function(e) { - return checkFreeLine(e, "np_marginRate"); - }); - global->DISPLAY_MARK_RATES)) { ?> - $("input[name='np_markRate']:first").blur(function(e) { - return checkFreeLine(e, "np_markRate"); - }); - + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { ?> + $("input[name='np_marginRate']:first").blur(function(e) { + return checkFreeLine(e, "np_marginRate"); + }); + global->DISPLAY_MARK_RATES)) { ?> + $("input[name='np_markRate']:first").blur(function(e) { + return checkFreeLine(e, "np_markRate"); + }); + }); /* TODO This does not work for number with thousand separator that is , */ diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 1e0ea5ba92a..9872874a1d0 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -482,7 +482,7 @@ if (empty($reshook)) $amount_ht = $amount_tva = $amount_ttc = array(); $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); - + // Loop on each vat rate $i = 0; foreach ($object->lines as $line) @@ -557,7 +557,7 @@ if (empty($reshook)) $total_creditnote_and_deposit += $obj->amount_ttc; } } else dol_print_error($db); - + $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; From b98251f7b05f438bcd98ea6f2a4ab48146a4b400 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Jan 2020 23:14:13 +0100 Subject: [PATCH 52/57] Fix phpcs --- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 29570ec379c..374e740ea40 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -363,7 +363,7 @@ if ($nolinesbefore) { "> - "> - From 52767c4324351d5b89c77ff21055d2face34fe5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jan 2020 15:45:25 +0100 Subject: [PATCH 53/57] NEW Can enter and edit stripe credit card using the Stripe card ID --- .../class/companypaymentmode.class.php | 1 + htdocs/societe/paymentmodes.php | 38 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 781a25ac8c0..441dac5bd37 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -162,6 +162,7 @@ class CompanyPaymentMode extends CommonObject public $preapproval_key; public $total_amount_of_all_payments; public $stripe_card_ref; + public $stripe_account; /** * @var int Status diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 52af815827f..08165909bea 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -194,13 +194,13 @@ if (empty($reshook)) if ($action == 'updatecard') { // Modification - if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) { if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + //if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + //if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); $action = 'createcard'; $error++; } @@ -220,6 +220,10 @@ if (empty($reshook)) $companypaymentmode->cvn = GETPOST('cvn', 'alpha'); $companypaymentmode->country_code = $object->country_code; + if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { + // If we set a stripe value that is different than previous one, we also set the stripe account + $companypaymentmode->stripe_account = $site_account; + } $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); $result = $companypaymentmode->update($user); @@ -346,13 +350,13 @@ if (empty($reshook)) { $error = 0; - if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) { if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); + //if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); + //if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); $action = 'createcard'; $error++; } @@ -377,6 +381,10 @@ if (empty($reshook)) $companypaymentmode->country_code = $object->country_code; $companypaymentmode->status = $servicestatus; + if (GETPOST('stripe_card_ref', 'alpha')) { + // If we set a stripe value, we also set the stripe account + $companypaymentmode->stripe_account = $site_account; + } $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); $db->begin(); @@ -1615,7 +1623,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // Edit BAN if ($socid && $action == 'edit' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1721,7 +1729,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Edit Card if ($socid && $action == 'editcard' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1738,7 +1746,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) print ''.$langs->trans("NameOnCard").''; print ''; - print ''.$langs->trans("CardNumber").''; + print ''.$langs->trans("CardNumber").''; print ''; print ''.$langs->trans("ExpiryDate").''; @@ -1747,7 +1755,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print ''; - print ''.$langs->trans("CVN").''; + print ''.$langs->trans("CVN").''; print ''; print ''.$langs->trans("StripeID")." ('card_....')"; @@ -1769,7 +1777,7 @@ if ($socid && $action == 'editcard' && $user->rights->societe->creer) // Create BAN if ($socid && $action == 'create' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1869,7 +1877,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer) // Create Card if ($socid && $action == 'createcard' && $user->rights->societe->creer) { - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1886,7 +1894,7 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) print ''.$langs->trans("NameOnCard").''; print ''; - print ''.$langs->trans("CardNumber").''; + print ''.$langs->trans("CardNumber").''; print ''; print ''.$langs->trans("ExpiryDate").''; @@ -1895,8 +1903,8 @@ if ($socid && $action == 'createcard' && $user->rights->societe->creer) print $formother->select_year(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); print ''; - print ''.$langs->trans("CVN").''; - print ''; + print ''.$langs->trans("CVN").''; + print ''; print ''.$langs->trans("StripeID")." ('card_....')"; print ''; From b7bf12819ab243ea6617619997810e79b0b07da7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jan 2020 17:19:42 +0100 Subject: [PATCH 54/57] Add label in list of Stripe payments --- htdocs/societe/paymentmodes.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 08165909bea..c70150f8bc0 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1010,6 +1010,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { print ''.$langs->trans('LocalID').''; } + print ''.$langs->trans('Label').''; print ''.$langs->trans('StripeID').''; print ''.$langs->trans('Type').''; print ''.$langs->trans('Informations').''; @@ -1063,6 +1064,9 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $companypaymentmodetemp->id; print ''; print ''; + print $companypaymentmodetemp->label; + print ''; + print ''; print $companypaymentmodetemp->stripe_card_ref; if ($companypaymentmodetemp->stripe_card_ref) { From dbb65d864ede580cc4dc102b34cb709aac887095 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jan 2020 19:05:03 +0100 Subject: [PATCH 55/57] fix missing column --- htdocs/societe/paymentmodes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index c70150f8bc0..7e940583824 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1160,6 +1160,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; } + print ''; + print ''; // Src ID print ''; $connect = ''; From 5cb8cceb8202f58752d5ae5b47b464e822c78a3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jan 2020 20:29:19 +0100 Subject: [PATCH 56/57] FIX Do not update timestamp when we set the "default" to another record --- htdocs/societe/class/companypaymentmode.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 441dac5bd37..55b5b865dee 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -444,7 +444,7 @@ class CompanyPaymentMode extends CommonObject $this->db->begin(); - $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; + $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms"; $sql2.= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc; if ($type) $sql2.= " AND type = '".$this->db->escape($type)."'"; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); From 991bb5a2eb78aeb186d09b289e2365aa167d5c18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Jan 2020 21:02:05 +0100 Subject: [PATCH 57/57] Update issue templates --- .github/ISSUE_TEMPLATE/custom.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/custom.md diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 00000000000..48d5f81fa42 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + +