From ac7f1035e1c33f0525caae04e266febf80e65023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 3 Sep 2017 12:25:27 +0200 Subject: [PATCH 01/52] FIX #7325 Default VAT rate when editing template invoices is 0% Close #7325 --- htdocs/compta/facture/fiche-rec.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index a6b238ba3c7..5af3d71f3af 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -896,7 +896,7 @@ if ($action == 'create') $langs->load('projects'); print '' . $langs->trans('Project') . ''; $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   thirdparty->id).'">' . $langs->trans("AddProject") . ''; print ''; } @@ -963,7 +963,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid); // No date selector for template invoice } print "\n"; @@ -1307,7 +1307,7 @@ else { //$disableedit=1; //$disablemove=1; - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line @@ -1318,7 +1318,7 @@ else $var = true; // Add free products/services - $object->formAddObjectLine(0, $mysoc, $soc); // No date selector for template invoice + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From eb9e8c9dfcb9f94e8c1f06d8b4ecfc881c265d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 3 Sep 2017 12:42:05 +0200 Subject: [PATCH 02/52] FIX #7000 Dashboard link for late pending payment supplier invoices do not work Close #7000 --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/list.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bb3d303b32e..3aa9051a5c6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1507,7 +1507,7 @@ class FactureFournisseur extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=f.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 66411dc8422..706a78ccb1e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -84,9 +84,12 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); +$filter = GETPOST('filtre'); $option = GETPOST('option'); -if ($option == 'late') $filter = 'paye:0'; +if ($option == 'late') { + $filter = 'paye:0'; +} $search_all = GETPOST('sall'); $search_label = GETPOST("search_label","alpha"); From 1154f871f13bbcf9bcf931c94eb3175d16cf39b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:52:49 +0200 Subject: [PATCH 03/52] Update fiche-rec.php --- htdocs/compta/facture/fiche-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 5af3d71f3af..9e118a460a5 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -963,7 +963,7 @@ if ($action == 'create') $disableedit=1; $disablemove=1; $disableremove=1; - $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid); // No date selector for template invoice + $ret = $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "\n"; From 4dd58a94f3303cde838bb49066f39c137b8dd768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:54:50 +0200 Subject: [PATCH 04/52] Update list.php --- htdocs/fourn/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 706a78ccb1e..6a0606dce86 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -84,7 +84,7 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); -$filter = GETPOST('filtre'); +$filter = GETPOST('filtre','alpha'); $option = GETPOST('option'); if ($option == 'late') { From 237270a27eb52c60bc8898700c98a5e5ae997da1 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 21:40:04 +0200 Subject: [PATCH 05/52] Add missing transfer of line extrafields in create invoice from supplier order --- htdocs/fourn/facture/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ac94d1b0e62..f1d684261d9 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -456,7 +456,13 @@ if (empty($reshook)) $date_end=$lines[$i]->date_fin_prevue; if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($db); + $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + } // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( $desc, From f5e14c9d7060882595021306b42584c877e0db23 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 21:41:49 +0200 Subject: [PATCH 06/52] Transfer of customer order line extrafield should only transfer fields available in target --- htdocs/compta/facture.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8a35fd7583d..33462e6370a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1153,7 +1153,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $extrafields = new ExtraFields($db); + $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); $array_options = $lines[$i]->array_options; } From 5a75e14a8ab3541a82ed8ca731e3d6874b570b3a Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 5 Sep 2017 22:50:34 +0200 Subject: [PATCH 07/52] Add supplier qty and supplier discount for export --- htdocs/core/modules/modProduct.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 154639f848d..6edcb0e2708 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -151,14 +151,14 @@ class modProduct extends DolibarrModules if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'SuppliersPrices')); + if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.unitprice'=>'BuyingPrice','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); - if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric')); + if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.url'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product"); From 7c743eb7da87046c1416c6a3d04ed9d810e8539c Mon Sep 17 00:00:00 2001 From: fappels Date: Thu, 7 Sep 2017 21:04:15 +0200 Subject: [PATCH 08/52] Rename $extrafields because already used --- htdocs/compta/facture.php | 6 +++--- htdocs/fourn/facture/card.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 33462e6370a..f229b3d999c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1153,9 +1153,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $extrafields = new ExtraFields($db); - $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); - $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + $targetExtraFields = new ExtraFields($db); + $targetExtraFieldLabels = $targetExtraFields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraFieldLabels); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index f1d684261d9..224a1443a4f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -459,9 +459,9 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($db); - $targetExtraLabels = $extrafields->fetch_name_optionals_label($object->table_element_line); - $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraLabels); + $targetExtraFields = new ExtraFields($db); + $targetExtraFieldLabels = $targetExtraFields->fetch_name_optionals_label($object->table_element_line); + $lines[$i]->fetch_optionals($lines[$i]->rowid, $targetExtraFieldLabels); } // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( From dbb50d7b169422cebe5838f2d9df8ad430751310 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 11:56:43 +0200 Subject: [PATCH 09/52] Fix PHP 7.2 --- htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 83306b95adb..0ee7c37e622 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -294,7 +294,7 @@ class pdf_soleil extends ModelePDFFicheinter $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt.'
'.$desc, LR, 1, 0); + $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; From f0983353f23fd147ebc31f118cc191d9ed84664e Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Thu, 14 Sep 2017 12:01:35 +0200 Subject: [PATCH 10/52] Fix #7387 : filter clsed company when create new documents --- htdocs/commande/card.php | 2 +- htdocs/fourn/card.php | 29 +++++++++++++++++++++++++---- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c4bb0ace2f2..1826426bc21 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1513,7 +1513,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print ''; - print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index b1a17f0a1e8..c8e31e78b4f 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -629,19 +629,40 @@ if ($object->id > 0) if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); - print ''.$langs->trans("AddSupplierProposal").''; + if ($object->status == 1) + { + print ''.$langs->trans("AddSupplierProposal").''; + } + else + { + print ''.$langs->trans("AddSupplierProposal").''; + } } - if ($user->rights->fournisseur->commande->creer) + if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; + if ($object->status == 1) + { + print ''.$langs->trans("AddOrder").''; + } + else + { + print ''.$langs->trans("AddOrder").''; + } } if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); - print ''.$langs->trans("AddBill").''; + if ($object->status == 1) + { + print ''.$langs->trans("AddBill").''; + } + else + { + print ''.$langs->trans("AddBill").''; + } } if ($user->rights->fournisseur->facture->creer) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 74d96158f65..239e3e7a579 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1427,7 +1427,7 @@ if ($action=='create') } else { - print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1', 'SelectThirdParty'); + print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); } print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 8402b298f93..a17049d1128 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1480,7 +1480,7 @@ if ($action == 'create') } else { - print $form->select_company($societe->id, 'socid', 's.fournisseur = 1', 'SelectThirdParty'); + print $form->select_company($societe->id, 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); } print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 26729ecf866..b5cbf772136 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1079,7 +1079,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty'); + print $form->select_company('', 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); print ''; } print '' . "\n"; From f16d88fd53f8e3250ecea3236287cc3106234b1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 13:17:31 +0200 Subject: [PATCH 11/52] FIX #7391 --- htdocs/core/lib/functions.lib.php | 54 ++++++++++++++++++------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 57e4f612840..2c89bb6598b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5809,29 +5809,39 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) $i3 = 0; foreach($tmpcrits as $tmpcrit) { - $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '') . $field . " LIKE '"; + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + + if (preg_match('/\.(id|rowid)$/', $field)) // Special cas for rowid that is sometimes a ref so used as a search field + { + $newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0'); + } + else + { + $newres .= $field . " LIKE '"; + + $tmpcrit=trim($tmpcrit); + $tmpcrit2=$tmpcrit; + $tmpbefore='%'; $tmpafter='%'; + if (preg_match('/^[\^\$]/', $tmpcrit)) + { + $tmpbefore=''; + $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); + } + if (preg_match('/[\^\$]$/', $tmpcrit)) + { + $tmpafter=''; + $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); + } + $newres .= $tmpbefore; + $newres .= $db->escape($tmpcrit2); + $newres .= $tmpafter; + $newres .= "'"; + if (empty($tmpcrit2)) + { + $newres .= ' OR ' . $field . " IS NULL"; + } + } - $tmpcrit=trim($tmpcrit); - $tmpcrit2=$tmpcrit; - $tmpbefore='%'; $tmpafter='%'; - if (preg_match('/^[\^\$]/', $tmpcrit)) - { - $tmpbefore=''; - $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); - } - if (preg_match('/[\^\$]$/', $tmpcrit)) - { - $tmpafter=''; - $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); - } - $newres .= $tmpbefore; - $newres .= $db->escape($tmpcrit2); - $newres .= $tmpafter; - $newres .= "'"; - if (empty($tmpcrit2)) - { - $newres .= ' OR ' . $field . " IS NULL"; - } $i3++; } $i2++; // a criteria was added to string From 2798726dbae8677b0ddf0bf35fb418c6f1c4c091 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 13:23:28 +0200 Subject: [PATCH 12/52] Update card.php --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1826426bc21..4d8bc4335e5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1513,7 +1513,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty'); + print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { From 2de76d733b2b969128dc9e60f782313decdbb866 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 13:24:01 +0200 Subject: [PATCH 13/52] Update card.php --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 239e3e7a579..74d96158f65 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1427,7 +1427,7 @@ if ($action=='create') } else { - print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); + print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1', 'SelectThirdParty'); } print ''; From d9947f237455b632ef9f2ab0a07ff904276142da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 13:24:24 +0200 Subject: [PATCH 14/52] Update card.php --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a17049d1128..8402b298f93 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1480,7 +1480,7 @@ if ($action == 'create') } else { - print $form->select_company($societe->id, 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); + print $form->select_company($societe->id, 'socid', 's.fournisseur = 1', 'SelectThirdParty'); } print ''; From 22b2446c05a9b03a8f48dfc07325e25c06ec358a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 13:25:01 +0200 Subject: [PATCH 15/52] Update card.php --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b5cbf772136..26729ecf866 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1079,7 +1079,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', 's.fournisseur = 1 AND status=1', 'SelectThirdParty'); + print $form->select_company('', 'socid', 's.fournisseur = 1', 'SelectThirdParty'); print ''; } print '' . "\n"; From 4bc8773417ed65ca93d2ea4001e3128fe78392a4 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Thu, 14 Sep 2017 13:52:39 +0200 Subject: [PATCH 16/52] decode db password if need --- htdocs/install/check.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index adbe7759f4e..5157d4a9e0a 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -306,7 +306,20 @@ else } else { - require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; + require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; + + // If password is encoded, we decode it + if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + { + require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; + if (preg_match('/crypted:/i',$dolibarr_main_db_pass)) + { + $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + } + else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } // $conf is already instancied inside inc.php $conf->db->type = $dolibarr_main_db_type; @@ -315,12 +328,12 @@ else $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); + $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->connected && $db->database_selected) { $ok=true; } - } + } } } From 42399952ea17b958401365a8295f73aac556e905 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 14:48:44 +0200 Subject: [PATCH 17/52] Update check.php --- htdocs/install/check.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 5157d4a9e0a..c96e83ea1d4 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -314,9 +314,8 @@ else require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i',$dolibarr_main_db_pass)) { - $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); - $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } From 84359a0078bcd92515d74e42238319dab331dc6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 16:42:04 +0200 Subject: [PATCH 18/52] Fix maxlength of fields --- htdocs/public/members/new.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 03f24c3ec80..160d66491a1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -500,13 +500,13 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) print ''; } // EMail -print ''.$langs->trans("Email").' *'."\n"; +print ''.$langs->trans("Email").' *'."\n"; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Login").' *'."\n"; - print ''.$langs->trans("Password").' *'."\n"; - print ''.$langs->trans("PasswordAgain").' *'."\n"; + print ''.$langs->trans("Login").' *'."\n"; + print ''.$langs->trans("Password").' *'."\n"; + print ''.$langs->trans("PasswordAgain").' *'."\n"; } // Birthday print ''.$langs->trans("DateToBirth").''; From 5d920be880d1505416d6bfc2eaf24b7bb2b3c0b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 16:51:41 +0200 Subject: [PATCH 19/52] FIX Upgrade missing on field --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 76c8f6df672..cd535c5c119 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -60,6 +60,8 @@ ALTER TABLE llx_user DROP COLUMN phenix_login; ALTER TABLE llx_user DROP COLUMN phenix_pass; ALTER TABLE llx_user ADD COLUMN dateemployment datetime; +ALTER TABLE llx_user MODIFY login varchar(50) NOT NULL; + ALTER TABLE llx_societe ADD COLUMN fk_account integer; ALTER TABLE llx_commandedet ADD COLUMN fk_commandefourndet integer DEFAULT NULL after import_key; -- link to detail line of commande fourn (resplenish) From c52e593ea85c5afda0989515b1440d7dc16ce1c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 21:27:14 +0200 Subject: [PATCH 20/52] Fix this->db --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ea2569b863e..8e8941c23fb 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -658,7 +658,7 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]= " (t.datec >= '".$this->db->idate($arrayquery['contact_create_st_dt'])."' AND t.datec <= '".$this->db->idate($arrayquery['contact_create_end_dt'])."')"; } if (!empty($arrayquery['contact_categ']) && count($arrayquery['contact_categ'])>0) { - $sqlwhere[]= " (contactcateg.fk_categorie IN (".$db->escape(implode(",",$arrayquery['contact_categ']))."))"; + $sqlwhere[]= " (contactcateg.fk_categorie IN (".$this->db->escape(implode(",",$arrayquery['contact_categ']))."))"; } //Standard Extrafield feature diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a296fc9079a..44acfaaac6b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1918,7 +1918,7 @@ class Form $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; if (count($warehouseStatusArray)) { - $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$db->escape(implode(',',$warehouseStatusArray)).'))'; + $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$this->db->escape(implode(',',$warehouseStatusArray)).'))'; } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { From affaec2a6fa408aa898c48275330e6e29b46e1c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 21:35:14 +0200 Subject: [PATCH 21/52] Fix count into loop --- htdocs/categories/class/categorie.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 05d9049ff03..95a5629fb14 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1542,7 +1542,8 @@ class Categorie extends CommonObject if (file_exists($dir)) { if (is_array($file['name']) && count($file['name']) > 0) { - for($i = 0; $i <= count($file['name']); $i ++) { + $nbfile = count($file['name']); + for ($i = 0; $i <= $nbfile; $i ++) { $originImage = $dir . $file['name'][$i]; From 8b9b99ac408239cd81f35aa24ce4d0d6b81f5d21 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 15 Sep 2017 13:02:49 +0200 Subject: [PATCH 22/52] fix : advance target emailing --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 453d1f75319..5307237919b 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -474,7 +474,7 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=t.rowid "; } if (array_key_exists('cust_categ', $arrayquery)) { - $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_societe=t.rowid "; + $sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_soc=t.rowid "; } if (!empty($arrayquery['cust_name'])) { From ff7b542bfad145d7485d920c34b77594d358b556 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 15 Sep 2017 13:25:54 +0200 Subject: [PATCH 23/52] fix : Avoid warning --- .../class/expensereport.class.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f999a93c57f..0ac2ce64062 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -187,20 +187,22 @@ class ExpenseReport extends CommonObject $resql=$this->db->query($sql); if (!$resql) $error++; - foreach ($this->lines as $i => $val) - { - $newndfline=new ExpenseReportLine($this->db); - $newndfline=$this->lines[$i]; - $newndfline->fk_expensereport=$this->id; - if ($result >= 0) - { - $result=$newndfline->insert(); - } - if ($result < 0) - { - $error++; - break; - } + if (is_array($this->lines) && count($this->lines)>0) { + foreach ($this->lines as $i => $val) + { + $newndfline=new ExpenseReportLine($this->db); + $newndfline=$this->lines[$i]; + $newndfline->fk_expensereport=$this->id; + if ($result >= 0) + { + $result=$newndfline->insert(); + } + if ($result < 0) + { + $error++; + break; + } + } } if (! $error) From 9dfd4bb430b9701bf04d29729c0c1b6b9bf3e624 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Fri, 15 Sep 2017 14:40:51 +0200 Subject: [PATCH 24/52] Accept the custom folder #7408 --- build/makepack-dolibarrmodule.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build/makepack-dolibarrmodule.pl b/build/makepack-dolibarrmodule.pl index 62002fd063b..4a9a217b570 100755 --- a/build/makepack-dolibarrmodule.pl +++ b/build/makepack-dolibarrmodule.pl @@ -3,6 +3,7 @@ # \file build/makepack-dolibarrmodule.pl # \brief Package builder (tgz, zip, rpm, deb, exe) # \author (c)2005-2014 Laurent Destailleur +# \contributor (c)2017 Nicolas ZABOURI #---------------------------------------------------------------------------- use Cwd; @@ -134,7 +135,15 @@ foreach my $PROJECT (@PROJECTLIST) { # Get version $MAJOR, $MINOR and $BUILD print "Version detected for module ".$PROJECT.": "; $result=open(IN,"<".$SOURCE."/htdocs/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php"); - if (! $result) { die "Error: Can't open descriptor file ".$SOURCE."/htdocs/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php for reading.\n"; } + $custom=false; + if (! $result) { + $result=open(IN,"<".$SOURCE."/htdocs/custom/".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php"); + if (! $result) { + die "Error: Can't open descriptor file ".$SOURCE."/htdocs/(or /htdocs/custom/)".$PROJECTLC."/core/modules/mod".$PROJECT.".class.php for reading.\n"; + }else{ + $custom = true; + } + } while() { if ($_ =~ /this->version\s*=\s*'([\d\.]+)'/) { $PROJVERSION=$1; break; } @@ -294,8 +303,11 @@ foreach my $PROJECT (@PROJECTLIST) { $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.old`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf.php.postgres`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/conf/conf*sav*`; + if($custom){ + $ret=`cp -r $BUILDROOT/$PROJECTLC/htdocs/custom/* $BUILDROOT/$PROJECTLC/htdocs/.`; + } $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom`; - $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom2`; + $ret=`rm -fr $BUILDROOT/$PROJECTLC/htdocs/custom2`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/test`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/Thumbs.db $BUILDROOT/$PROJECTLC/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/Thumbs.db $BUILDROOT/$PROJECTLC/*/*/*/*/Thumbs.db`; $ret=`rm -fr $BUILDROOT/$PROJECTLC/CVS* $BUILDROOT/$PROJECTLC/*/CVS* $BUILDROOT/$PROJECTLC/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/CVS* $BUILDROOT/$PROJECTLC/*/*/*/*/*/CVS*`; From 17eec5f9e931ca97b3e8acd570125dc67c25afbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 16:40:52 +0200 Subject: [PATCH 25/52] Fix look and field for direct debit notes --- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/compta/prelevement/bons.php | 30 ++-- htdocs/compta/prelevement/card.php | 141 +++++++++++------- .../class/bonprelevement.class.php | 60 +++++--- htdocs/compta/prelevement/create.php | 6 +- htdocs/compta/prelevement/factures.php | 64 +++++--- htdocs/compta/prelevement/fiche-rejet.php | 107 +++++++++---- htdocs/compta/prelevement/fiche-stat.php | 76 +++++++--- 8 files changed, 334 insertions(+), 152 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f4e61380a9c..b64940bd68a 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -493,7 +493,7 @@ class Paiement extends CommonObject * * @param User $user Object of user making payment * @param string $mode 'payment', 'payment_supplier' - * @param string $label Label to use in bank record + * @param string $label Label to use in bank record. Note: If label is '(WithdrawalPayment)', a third entry 'widthdraw' is added into bank_url. * @param int $accountid Id of bank account to do link with * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 2a91ae13bfc..32c7b638a46 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -51,6 +51,9 @@ if (! $sortfield) $sortfield="p.datec"; // Get supervariables $statut = GETPOST('statut','int'); $search_ref = GETPOST('search_ref','alpha'); +$search_amount = GETPOST('search_amount','alpha'); + +$bon=new BonPrelevement($db,""); /* @@ -60,6 +63,7 @@ $search_ref = GETPOST('search_ref','alpha'); if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; + $search_amount=""; } @@ -69,13 +73,12 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', llxHeader('',$langs->trans("WithdrawalsReceipts")); -$bon=new BonPrelevement($db,""); - $sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; $sql.= ", p.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " WHERE p.entity = ".$conf->entity; if ($search_ref) $sql.=natural_search("p.ref", $search_ref); +if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); @@ -97,6 +100,8 @@ if ($result) $urladd= "&statut=".$statut; + $selectedfields=''; + // Lines of title fields print '
'; if ($optioncss != '') print ''; @@ -116,7 +121,9 @@ if ($result) print ''."\n"; print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; - print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"'); - print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"'); - print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"","","",'align="center"'); + print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder); + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder); + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; while ($i < min($num,$limit)) @@ -136,15 +145,18 @@ if ($result) print '\n"; print '\n"; print '\n"; + print ''; + + print ''."\n"; + print "\n"; $i++; } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 20d7b0232e9..bdd0b47b0ac 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -20,7 +20,7 @@ /** * \file htdocs/compta/prelevement/card.php * \ingroup prelevement - * \brief Fiche prelevement + * \brief Card of a direct debit */ require('../../main.inc.php'); @@ -47,18 +47,21 @@ $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); $socid = GETPOST('socid','int'); - +// Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; + if (! $sortfield) $sortfield='pl.fk_soc'; if (! $sortorder) $sortorder='DESC'; +$object = new BonPrelevement($db,""); + /* * Actions @@ -66,10 +69,9 @@ if (! $sortorder) $sortorder='DESC'; if ( $action == 'confirm_delete' ) { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); - $res=$bon->delete(); + $res=$object->delete(); if ($res > 0) { header("Location: index.php"); @@ -77,16 +79,16 @@ if ( $action == 'confirm_delete' ) } } +// Seems to no be used and replaced with $action == 'infocredit if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes') { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); - $res=$bon->set_credite(); + $res=$object->set_credite(); if ($res >= 0) { header("Location: card.php?id=".$id); - exit; + exit; } } @@ -94,19 +96,18 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); /* - if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) + if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0) { - $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); + $object->set_infotrans($user, $dt, GETPOST('methode','alpha')); } header("Location: card.php?id=".$id); @@ -118,7 +119,7 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) $mesg='BadFile'; }*/ - $error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); + $error = $object->set_infotrans($user, $dt, GETPOST('methode','alpha')); if ($error) { @@ -127,13 +128,13 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) } } +// Set direct debit order to credited, create payment and close invoices if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { - $bon = new BonPrelevement($db,""); - $bon->fetch($id); + $object->fetch($id, $ref); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); - $error = $bon->set_infocredit($user, $dt); + $error = $object->set_infocredit($user, $dt); if ($error) { @@ -143,61 +144,66 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) } + /* * View */ -$bon = new BonPrelevement($db,""); $form = new Form($db); llxHeader('',$langs->trans("WithdrawalsReceipts")); - -if ($id > 0) +if ($id > 0 || $ref) { - $bon->fetch($id); + $object->fetch($id, $ref); - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); if (GETPOST('error','alpha')!='') { - print '
'.$bon->getErrorString(GETPOST('error','alpha')).'
'; + print '
'.$object->getErrorString(GETPOST('error','alpha')).'
'; } /*if ($action == 'credite') { - print $form->formconfirm("card.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); + print $form->formconfirm("card.php?id=".$object->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); }*/ + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); + + print '
'; + print '
'; print '
  '; $searchpicto=$form->showFilterButtons(); @@ -125,9 +132,11 @@ if ($result) print '
'; - print $bon->LibStatut($obj->statut,2); - print " "; - print ''.$obj->ref."'.dol_print_date($db->jdate($obj->datec),'day')."'.price($obj->amount)."'; + print $bon->LibStatut($obj->statut, 3); + print '
'; - print ''; - print ''; - print ''; + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -205,19 +211,36 @@ if ($id > 0) print '
'; - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); - if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') { - print ''; + print ''; print ''; print ''; print ''; @@ -227,7 +250,7 @@ if ($id > 0) print $form->select_date('','','','','',"userfile",1,1); print ''; print ''; /* print ''; } - + print "
'.$langs->trans("TransMetod").''; - print $form->selectarray("methode",$bon->methodes_trans); + print $form->selectarray("methode",$object->methodes_trans); print '
'.$langs->trans("File").''; print ''; @@ -238,9 +261,9 @@ if ($id > 0) print ''; } - if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') + if (! empty($object->date_trans) && $object->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') { - print '
'; + print ''; print ''; print ''; print ''; @@ -261,17 +284,17 @@ if ($id > 0) { print "\n
\n"; - if (empty($bon->date_trans) && $user->rights->prelevement->bons->send) + if (empty($object->date_trans) && $user->rights->prelevement->bons->send) { - print "id."\">".$langs->trans("SetToStatusSent").""; + print "id."\">".$langs->trans("SetToStatusSent").""; } - if (! empty($bon->date_trans) && $bon->date_credit == 0) + if (! empty($object->date_trans) && $object->date_credit == 0) { - print "id."\">".$langs->trans("ClassCredited").""; + print "id."\">".$langs->trans("ClassCredited").""; } - print "id."\">".$langs->trans("Delete").""; + print "id."\">".$langs->trans("Delete").""; print "
"; } @@ -293,7 +316,16 @@ if ($id > 0) $sql.= " AND pl.fk_soc = s.rowid"; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit+1, $offset); + + // Count total nb of records + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + } + + $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); @@ -304,8 +336,9 @@ if ($id > 0) $urladd = "&id=".$id; - print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); - print"\n\n"; + print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print ''; print_liste_field_titre("Lines",$_SERVER["PHP_SELF"],"pl.rowid",'',$urladd); @@ -369,6 +402,8 @@ if ($id > 0) } print "
"; + print ''; + $db->free($result); } else diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ab04278ea84..a35e4e50af8 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -38,6 +38,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; */ class BonPrelevement extends CommonObject { + public $element='widthdraw'; + public $table_element='prelevement_bons'; + public $picto = 'payment'; + var $date_echeance; var $raison_sociale; var $reference_remise; @@ -263,10 +267,11 @@ class BonPrelevement extends CommonObject /** * Get object and lines from database * - * @param int $rowid id of object to load + * @param int $rowid Id of object to load + * @param string $ref Ref of direct debit * @return int >0 if OK, <0 if KO */ - function fetch($rowid) + function fetch($rowid, $ref='') { global $conf; @@ -278,8 +283,9 @@ class BonPrelevement extends CommonObject $sql.= ", p.fk_user_credit"; $sql.= ", p.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql.= " WHERE p.rowid = ".$rowid; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " WHERE p.entity = ".$conf->entity; + if ($rowid > 0) $sql.= " AND p.rowid = ".$rowid; + else $sql.= " AND p.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result=$this->db->query($sql); @@ -345,7 +351,7 @@ class BonPrelevement extends CommonObject $error++; } - if ($error == 0) + if (! $error) { $facs = array(); $facs = $this->getListInvoices(); @@ -361,9 +367,8 @@ class BonPrelevement extends CommonObject } } - if ($error == 0) + if (! $error) { - $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql.= " SET statut = 2"; $sql.= " WHERE fk_prelevement_bons = ".$this->id; @@ -378,7 +383,7 @@ class BonPrelevement extends CommonObject /* * End of procedure */ - if ($error == 0) + if (! $error) { $this->db->commit(); return 0; @@ -399,10 +404,10 @@ class BonPrelevement extends CommonObject } /** - * Set withdrawal to credited status + * Set direct debit order to "credited" status. * - * @param User $user id of user - * @param int $date date of action + * @param User $user Id of user + * @param int $date date of action * @return int >0 if OK, <0 if KO */ function set_infocredit($user, $date) @@ -466,7 +471,7 @@ class BonPrelevement extends CommonObject $paiement_id = $paiement->create($user); if ($paiement_id < 0) { - dol_syslog(get_class($this)."::set_credite AddPayment Error"); + dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); $error++; } else @@ -474,7 +479,7 @@ class BonPrelevement extends CommonObject $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); if ($result < 0) { - dol_syslog(get_class($this)."::set_credite AddPaymentToBank Error"); + dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); $error++; } } @@ -486,7 +491,7 @@ class BonPrelevement extends CommonObject if (! $this->db->query($sql)) { - dol_syslog(get_class($this)."::set_credite Update lines Error"); + dol_syslog(get_class($this)."::set_infocredit Update lines Error"); $error++; } @@ -1819,11 +1824,11 @@ class BonPrelevement extends CommonObject } /** - * Return status label for a status + * Return status label for a status * - * @param int $statut id statut - * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto - * @return string Label + * @param int $statut id statut + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label */ function LibStatut($statut,$mode=0) { @@ -1846,8 +1851,25 @@ class BonPrelevement extends CommonObject if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); } - if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); + if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + } + if ($mode == 4) + { + if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + } + if ($mode == 5) + { + if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); + if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); + if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + } + if ($mode == 6) { if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 0834b3500a7..6743ea3098b 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -67,7 +67,7 @@ if ($action == 'create') { setEventMessages($bprev->error, $bprev->errors, 'errors'); } - if ($result == 0) + elseif ($result == 0) { $mesg=''; $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed"); @@ -78,6 +78,10 @@ if ($action == 'create') $mesg.=$val."
\n"; } } + else + { + setEventMessages($langs->trans("DirectDebitOrderCreated"), null); + } } diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 437af529ad9..27c70f993b5 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -55,6 +55,9 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='p.ref'; if (! $sortorder) $sortorder='DESC'; +$object = new BonPrelevement($db,""); + + /* * View @@ -65,39 +68,41 @@ $thirdpartytmp = new Societe($db); llxHeader('',$langs->trans("WithdrawalsReceipts")); -if ($prev_id) +if ($prev_id > 0 || $ref) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id, $ref) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); + + print '
'; + print '
'; print ''; - print ''; - print ''; - print ''; + //print ''; + print ''; + print ''; // Status - print ''; + //print ''; - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -105,12 +110,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).'
'.$langs->trans('Status').''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; print ''; if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) @@ -408,14 +408,14 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; } else print ''; print ''; - + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; @@ -427,7 +427,7 @@ if ($socid > 0) else { print ''; - } + } $db->free($resql); print "
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -137,7 +159,6 @@ $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; if ($prev_id) $sql.= " AND p.rowid=".$prev_id; if ($socid) $sql.= " AND s.rowid = ".$socid; - $sql.= $db->order($sortfield,$sortorder); // Count total nb of records @@ -172,9 +193,10 @@ if ($result) $massactionbutton=''; - print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + print_barre_liste($langs->trans("Invoices"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); print"\n\n"; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder); @@ -250,6 +272,8 @@ if ($result) } print "
"; + print '
'; + $db->free($result); } else diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index f2240a070e6..25fe9255858 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -41,49 +41,68 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +$object = new BonPrelevement($db,""); + + + /* * View */ + llxHeader('',$langs->trans("WithdrawalsReceipts")); -if ($prev_id) +if ($prev_id > 0 || $ref) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id, $ref) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - print ''; + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); - print ''; - print ''; - print ''; + print '
'; + print '
'; + print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'."\n"; + + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -91,12 +110,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'."\n"; // AGENDA_DEFAULT_FILTER_STATUS +// TODO Remove to use the default generic feature print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; // AGENDA_DEFAULT_VIEW diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 5ac0982a3a0..bdb0a50e4e6 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -142,7 +142,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } From 196c5c1267a00a4d389c3f0b128b41a861d6eb2d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 20:51:06 +0200 Subject: [PATCH 40/52] Missing translation --- htdocs/langs/en_US/agenda.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index a62db9c7158..a5857503c30 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -83,6 +83,9 @@ EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved EXPENSE_REPORT_DELETEInDolibarr=Expense report %s deleted EXPENSE_REPORT_REFUSEDInDolibarr=Expense report %s refused +PROJECT_CREATEInDolibarr=Project %s created +PROJECT_MODIFYInDolibarr=Project %s modified +PROJECT_DELETEInDolibarr=Project %s deleted ##### End agenda events ##### AgendaModelModule=Document templates for event DateActionStart=Start date From 99149b5cfeada8c2062ae969841ef9629c01335c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:21:12 +0200 Subject: [PATCH 41/52] Fix box activity again --- htdocs/core/boxes/box_activity.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index a05fcf761b6..7aa5974efbd 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -438,11 +438,6 @@ class box_activity extends ModeleBoxes 'td' => 'align="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, 'text' => ($db->error().' sql='.$sql), - ); } } From f76b675e092ba5053ac3dbffe8f4b1ab5d977bea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:24:30 +0200 Subject: [PATCH 42/52] Fix box activity again --- htdocs/core/boxes/box_activity.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 7aa5974efbd..2f923855dbb 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -147,7 +147,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -230,7 +230,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) { + while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -315,7 +315,7 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; - while ($line < count($data)) { + while ($j < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -400,7 +400,7 @@ class box_activity extends ModeleBoxes $alreadypaid=-1; - while ($line < count($data)) { + while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', From eaee8ee5864c0e2b1481adc6530d2a166f885186 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 21:29:25 +0200 Subject: [PATCH 43/52] Fix box activity again --- htdocs/core/boxes/box_activity.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 2f923855dbb..71a9a4e3125 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -77,7 +77,6 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $totalMnt = 0; $totalnb = 0; $line = 0; $cachetime = 3600; @@ -173,7 +172,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut,3), @@ -255,7 +253,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $data[$j]->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut,0,3), @@ -342,10 +339,8 @@ class box_activity extends ModeleBoxes ); // We add only for the current year - if ($data[$j]->annee == date("Y")) { - $totalnb += $data[$j]->nb; - $totalMnt += $data[$j]->Mnttot; - } + $totalnb += $data[$j]->nb; + $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$data[$j]->fk_statut,3), @@ -396,10 +391,9 @@ class box_activity extends ModeleBoxes } if (! empty($data)) { - $j=0; - $alreadypaid=-1; + $j=0; while ($j < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( @@ -425,7 +419,6 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => price($data[$j]->Mnttot,1,$langs,0,0,-1,$conf->currency), ); - $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid), From 0536d6cbed522893ddbfd3ce7c69847a8eac8fee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:46:17 +0200 Subject: [PATCH 44/52] FIX #7330 --- htdocs/contrat/list.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 17246751600..221a4233f5a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Juanjo Menent @@ -271,11 +271,8 @@ $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.re $sql.= ' s.rowid, s.nom, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom"; -// Add where from extra fields -foreach ($extrafields->attribute_label as $key => $val) -{ - $sql .= ', ef.'.$key; -} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook From 6ac1b6e82eed373a7a0d061a3961268f6dd2689d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:48:04 +0200 Subject: [PATCH 45/52] Fix template --- htdocs/modulebuilder/template/myobject_list.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 96b7d7ca733..c4e7875e89a 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -237,6 +237,21 @@ foreach ($search_array_options as $key => $val) $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; + +/* If a group by is required +$sql.= " GROUP BY " +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +*/ + $sql.=$db->order($sortfield,$sortorder); // Count total nb of records From aba907d1a8805e1133f8fe337593674d177a7b93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:49:21 +0200 Subject: [PATCH 46/52] FIX #7420 --- htdocs/includes/odtphp/Segment.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 40668215647..525cd5b4f3f 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -24,7 +24,7 @@ class Segment implements IteratorAggregate, Countable protected $images = array(); protected $odf; protected $file; - + /** * Constructor * @@ -86,15 +86,15 @@ class Segment implements IteratorAggregate, Countable */ public function merge() { - // To provide debug information on line number processed + // To provide debug information on line number processed global $count; if (empty($count)) $count=1; else $count++; - + if (empty($this->savxml)) $this->savxml = $this->xml; // Sav content of line at first line merged, so we will reuse original for next steps $this->xml = $this->savxml; $tmpvars = $this->vars; // Store into $tmpvars so we won't modify this->vars when completing data with empty values - + // Search all tags fou into condition to complete $tmpvars, so we will proceed all tests even if not defined $reg='@\[!--\sIF\s([{}a-zA-Z0-9\.\,_]+)\s--\]@smU'; preg_match_all($reg, $this->xml, $matches, PREG_SET_ORDER); @@ -106,7 +106,7 @@ class Segment implements IteratorAggregate, Countable $tmpvars[$match[1]] = ''; // Not defined, so we set it to '', we just need entry into this->vars for next loop } } - + // Conditionals substitution // Note: must be done before static substitution, else the variable will be replaced by its value and the conditional won't work anymore foreach($tmpvars as $key => $value) @@ -133,7 +133,7 @@ class Segment implements IteratorAggregate, Countable $this->xml = preg_replace($reg, '', $this->xml); } } - + $this->xmlParsed .= str_replace(array_keys($tmpvars), array_values($tmpvars), $this->xml); if ($this->hasChildren()) { foreach ($this->children as $child) { @@ -143,7 +143,7 @@ class Segment implements IteratorAggregate, Countable } $reg = "/\[!--\sBEGIN\s$this->name\s--\](.*)\[!--\sEND\s$this->name\s--\]/sm"; $this->xmlParsed = preg_replace($reg, '$1', $this->xmlParsed); - // Miguel Erill 09704/2017 - Add macro replacement to invoice lines + // Miguel Erill 09704/2017 - Add macro replacement to invoice lines $this->xmlParsed = $this->macroReplace($this->xmlParsed); $this->file->open($this->odf->getTmpfile()); foreach ($this->images as $imageKey => $imageValue) { @@ -155,28 +155,28 @@ class Segment implements IteratorAggregate, Countable } } $this->file->close(); - + return $this->xmlParsed; } /** * Function to replace macros for invoice short and long month, invoice year - * + * * Substitution occur when the invoice is generated, not considering the invoice date * so do not (re)generate in a diferent date than the one that the invoice belongs to * Perhaps it would be better to use the invoice issued date but I still do not know * how to get it here * * Miguel Erill 09/04/2017 - * + * * @param string $value String to convert */ public function macroReplace($text) { global $langs; - $patterns=array( '__CURRENTDAY__','__CURRENTDAYTEXT__','__CURRENTMONTHSHORT__','__CURRENTMONTH__','__CURRENTYEAR__' ); - $values=array( date('j'), $langs->trans(date('l')), $langs->trans(date('M')), $langs->trans(date('F')), date('Y') ); + $patterns=array('/__CURRENTDAY__/','/__CURRENTDAYTEXT__/','/__CURRENTMONTHSHORT__/','/__CURRENTMONTH__/','/__CURRENTYEAR__/'); + $values=array(date('j'), $langs->trans(date('l')), $langs->trans(date('M')), $langs->trans(date('F')), date('Y')); $text=preg_replace($patterns, $values, $text); @@ -203,7 +203,7 @@ class Segment implements IteratorAggregate, Countable } return $this; } - + /** * Assign a template variable to replace * From c11ff4a18c7f488b3588793451165370f28beb4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 15:55:25 +0200 Subject: [PATCH 47/52] FIX #7368 --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 1 + htdocs/install/mysql/migration/repair.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 14990f1bfdc..3a5810d19e4 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -510,6 +510,7 @@ ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user; ALTER TABLE llx_user_rights DROP INDEX uk_user_rights; ALTER TABLE llx_user_rights DROP INDEX fk_user; ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id); +DELETE FROM llx_user_rights WHERE fk_user NOT IN (select rowid from llx_user); ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); ALTER TABLE llx_usergroup_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 59be09bcb8b..3a61ef4b216 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -89,6 +89,7 @@ delete from llx_livraison where ref = ''; delete from llx_expeditiondet where fk_expedition in (select rowid from llx_expedition where ref = ''); delete from llx_expedition where ref = ''; delete from llx_holiday_logs where fk_user_update not IN (select rowid from llx_user); +delete from llx_user_rights where fk_user not IN (select rowid from llx_user); update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01'; From 70b11f18b51fac1f679080f832c3931e825468f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 16:06:58 +0200 Subject: [PATCH 48/52] FIX #7367 --- htdocs/core/lib/files.lib.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9ff9ec0df63..b1031153507 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1559,7 +1559,7 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= } /** - * Convert an image file into anoher format. + * Convert an image file into another format. * This need Imagick php extension. * * @param string $fileinput Input file name @@ -1567,14 +1567,19 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= * @param string $fileoutput Output filename * @return int <0 if KO, 0=Nothing done, >0 if OK */ -function dol_convert_file($fileinput,$ext='png',$fileoutput='') +function dol_convert_file($fileinput, $ext='png', $fileoutput='') { global $langs; if (class_exists('Imagick')) { $image=new Imagick(); - $ret = $image->readImage($fileinput); + try { + $ret = $image->readImage($fileinput); + } catch(Exception $e) { + dol_syslog("Failed to read image using Imagick. Try to install package 'apt-get install ghostscript'.", LOG_WARNING); + return 0; + } if ($ret) { $ret = $image->setImageFormat($ext); From 9838199de148579753f5602dadf6c5924c6827ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 Sep 2017 23:31:07 +0200 Subject: [PATCH 49/52] FIX Sign of amount in origin currency on credit note created from lines --- htdocs/compta/facture/card.php | 17 +++++++++++------ htdocs/compta/facture/class/facture.class.php | 7 ++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 82eeb3d49c0..c66285ae0c8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -841,13 +841,18 @@ if (empty($reshook)) $line->fk_facture = $object->id; $line->fk_parent_line = $fk_parent_line; - $line->subprice =-$line->subprice; // invert price for object + $line->subprice = -$line->subprice; // invert price for object $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here - $line->total_ht=-$line->total_ht; - $line->total_tva=-$line->total_tva; - $line->total_ttc=-$line->total_ttc; - $line->total_localtax1=-$line->total_localtax1; - $line->total_localtax2=-$line->total_localtax2; + $line->total_ht = -$line->total_ht; + $line->total_tva = -$line->total_tva; + $line->total_ttc = -$line->total_ttc; + $line->total_localtax1 = -$line->total_localtax1; + $line->total_localtax2 = -$line->total_localtax2; + + $line->multicurrency_subprice = -$line->multicurrency_subprice; + $line->multicurrency_total_ht = -$line->multicurrency_total_ht; + $line->multicurrency_total_tva = -$line->multicurrency_total_tva; + $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9cc9a63f313..c3b58117dd7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1568,7 +1568,7 @@ class Facture extends CommonInvoice $facligne->desc=$remise->description; // Description ligne $facligne->vat_src_code=$remise->vat_src_code; $facligne->tva_tx=$remise->tva_tx; - $facligne->subprice=-$remise->amount_ht; + $facligne->subprice = -$remise->amount_ht; $facligne->fk_product=0; // Id produit predefini $facligne->qty=1; $facligne->remise_percent=0; @@ -1591,6 +1591,11 @@ class Facture extends CommonInvoice $facligne->total_tva = -$remise->amount_tva; $facligne->total_ttc = -$remise->amount_ttc; + $facligne->multicurrency_subprice = -$remise->multicurrency_subprice; + $facligne->multicurrency_total_ht = -$remise->multicurrency_total_ht; + $facligne->multicurrency_total_tva = -$remise->multicurrency_total_tva; + $facligne->multicurrency_total_ttc = -$remise->multicurrency_total_ttc; + $lineid=$facligne->insert(); if ($lineid > 0) { From f936b17d68928caf7c8af9131a2276e837f1faa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 00:24:52 +0200 Subject: [PATCH 50/52] FIX Protection to avoid to apply credit note discount > remain to pay --- htdocs/comm/remx.php | 24 +++++++++--------- htdocs/compta/facture/card.php | 37 ++++++++++++++++++++-------- htdocs/core/class/discount.class.php | 7 ++++++ htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/en_US/errors.lang | 2 +- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 9964db9ecde..94142b6ec54 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -125,7 +125,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') if ($res > 0 && $newid1 > 0 && $newid2 > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id.($backtopage?'&backtopage='.urlencode($backtopage):'')); // To avoid pb whith back exit; } else @@ -275,13 +275,13 @@ if ($socid > 0) print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -109,7 +145,7 @@ if ($prev_id) $rej = new RejetPrelevement($db, $user); /* - * Liste des factures + * List errors */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; $sql.= " , s.rowid as socid, s.nom as name"; @@ -127,12 +163,25 @@ $sql.= " AND pr.fk_prelevement_lignes = pl.rowid"; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY pl.amount DESC"; +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1, $offset); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print"\n\n"; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -146,32 +195,32 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print '\n"; - + print '\n"; print ''; - + print ''; print ''; print "\n"; - + $total += $obj->amount; - + $i++; } } else { - print ''; + print ''; } - + if ($num > 0) { print ''; @@ -181,6 +230,8 @@ if ($resql) print "\n"; } print "
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").'
'; - + print ''; print img_picto('', 'statut'.$obj->statut).' '; print substr('000000'.$obj->rowid, -6); print ''.$obj->name."'.price($obj->amount)."'.$rej->motifs[$obj->motif].''.yn($obj->afacturer).''.$obj->fk_facture.'
'.$langs->trans("None").'
'.$langs->trans("None").'
 
\n"; + print '
'; + $db->free($resql); } else diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 7e0c4f81e4b..99965672c2e 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -38,7 +38,20 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); + +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +$object = new BonPrelevement($db,""); + /* * View @@ -48,40 +61,44 @@ llxHeader('',$langs->trans("WithdrawalsReceipts")); if ($prev_id) { - $bon = new BonPrelevement($db,""); - - if ($bon->fetch($prev_id) == 0) + if ($object->fetch($prev_id) == 0) { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), '', 'payment'); + $head = prelevement_prepare_head($object); + dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); - print ''; + dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref'); - print ''; - print ''; - print ''; + print '
'; + print '
'; + print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'."\n"; + + //print ''; + print ''; + print ''; // Status + /* print ''; - print ''; + print ''; print ''; + */ - if($bon->date_trans <> 0) + if($object->date_trans <> 0) { $muser = new User($db); - $muser->fetch($bon->user_trans); + $muser->fetch($object->user_trans); print ''; print ''; } - if($bon->date_credit <> 0) + if($object->date_credit <> 0) { print ''; } @@ -89,12 +106,29 @@ if ($prev_id) print '
'; - print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); + print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; + print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); + print dol_print_date($object->date_credit,'day'); print '
'; + print '
'; + print ''; + + $acc = new Account($db); + $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + + print ''; + print ''; + print ''; + + print '
'; + print $langs->trans("BankToReceiveWithdraw"); + print ''; + if ($acc->id > 0) + print $acc->getNomUrl(1); + print '
'; print $langs->trans("WithdrawalFile").''; - $relativepath = 'receipts/'.$bon->ref.'.xml'; + $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; + print ''; + dol_fiche_end(); } @@ -121,7 +155,7 @@ if ($prev_id) $i = 0; print load_fiche_titre($langs->trans("StatisticsByLineStatus"),'',''); - + print"\n\n"; print ''; print ''; @@ -139,12 +173,12 @@ if ($prev_id) print price($row[0]); print ''; print "\n"; - + $i++; } From 59f644a3e2bca811f1592623d6342132826d1c26 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 18:39:10 +0200 Subject: [PATCH 26/52] FIX SEPA recording payment must save one payment in bank per customer --- .../compta/paiement/class/paiement.class.php | 7 +- htdocs/compta/prelevement/card.php | 6 +- .../class/bonprelevement.class.php | 90 +++++++++++-------- htdocs/compta/prelevement/factures.php | 6 +- htdocs/compta/prelevement/fiche-rejet.php | 1 + htdocs/compta/prelevement/fiche-stat.php | 1 + 6 files changed, 67 insertions(+), 44 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index b64940bd68a..7c5b99e2945 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -488,7 +488,7 @@ class Paiement extends CommonObject /** - * Add a record into bank for payment with links between this bank record and invoices of payment. + * Add a record into bank for payment + links between this bank record and sources of payment. * All payment properties (this->amount, this->amounts, ...) must have been set first like after a call to create(). * * @param User $user Object of user making payment @@ -577,10 +577,11 @@ class Paiement extends CommonObject } // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) - if (! $error && $label != '(WithdrawalPayment)') + //if (! $error && $label != '(WithdrawalPayment)') + if (! $error) { $linkaddedforthirdparty=array(); - foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of. + foreach ($this->amounts as $key => $value) // We should have invoices always for same third party but we loop in case of. { if ($mode == 'payment') { diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index bdd0b47b0ac..97f5d96903f 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -45,6 +45,7 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid','int'); // Load variable for pagination @@ -396,7 +397,10 @@ if ($id > 0 || $ref) print ''; print ''; print ''; - print '\n"; + print '\n"; print ''; print "\n"; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a35e4e50af8..0278d97d724 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -327,7 +327,7 @@ class BonPrelevement extends CommonObject } /** - * Set credite and set status of linked invoices + * Set credite and set status of linked invoices. Still used ?? * * @return int <0 if KO, >=0 if OK */ @@ -441,49 +441,60 @@ class BonPrelevement extends CommonObject $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; $facs = array(); $amounts = array(); + $amountsperthirdparty = array(); $facs = $this->getListInvoices(1); + // Loop on each invoice. $facs=array(0=>id, 1=>amount requested) $num=count($facs); for ($i = 0; $i < $num; $i++) { $fac = new Facture($this->db); $fac->fetch($facs[$i][0]); $amounts[$fac->id] = $facs[$i][1]; + $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; $totalpaye = $fac->getSommePaiement(); $totalcreditnotes = $fac->getSumCreditNotesUsed(); $totaldeposits = $fac->getSumDepositsUsed(); $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits; - if ($alreadypayed + $facs[$i][1] >= $fac->total_ttc) { + if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { $result = $fac->set_paid($user); } } - $paiement = new Paiement($this->db); - $paiement->datepaye = $date ; - $paiement->amounts = $amounts; - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref ; - $paiement->id_prelevement = $this->id ; + // Make one payment per customer + foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) + { + $paiement = new Paiement($this->db); + $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->id_prelevement = $this->id; - $paiement_id = $paiement->create($user); - if ($paiement_id < 0) - { - dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); - $error++; + $paiement_id = $paiement->create($user); + if ($paiement_id < 0) + { + dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); + $error++; + } + else + { + $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); + if ($result < 0) + { + dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); + $error++; + } + } + //var_dump($paiement->amounts); + //var_dump($thirdpartyid); + //var_dump($cursoramounts); } - else - { - $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); - if ($result < 0) - { - dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); - $error++; - } - } - // Update withdrawal line + + // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; $sql.= " SET statut = 2"; @@ -956,14 +967,14 @@ class BonPrelevement extends CommonObject } } - /* - * Create withdrawal receipt - */ if (!$error) { - if (count($factures_prev) > 0) + /* + * Create withdrawal receipt in database + */ + if (count($factures_prev) > 0) { - foreach ($factures_prev as $fac) + foreach ($factures_prev as $fac) // Add a link in database for each invoice { // Fetch invoice $fact = new Facture($this->db); @@ -1003,7 +1014,6 @@ class BonPrelevement extends CommonObject } } - } } @@ -1011,11 +1021,12 @@ class BonPrelevement extends CommonObject if (!$error) { /* - * Withdraw receipt + * Create direct debit order in a XML file */ dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG); + if (count($factures_prev) > 0) { $this->date_echeance = $datetimeprev; @@ -1039,11 +1050,12 @@ class BonPrelevement extends CommonObject $this->factures = $factures_prev_id; - // Generation of SEPA file + // Generation of SEPA file $this->filename $this->generate(); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } + //var_dump($factures_prev);exit; /* * Update total @@ -1294,8 +1306,9 @@ class BonPrelevement extends CommonObject $sql.= " AND soc.rowid = f.fk_soc"; $sql.= " AND rib.fk_soc = f.fk_soc"; $sql.= " AND rib.default_rib = 1"; + //print $sql; - //echo $sql; + // Define $fileDebiteurSection. One section DrctDbtTxInf per invoice. $resql=$this->db->query($sql); if ($resql) { @@ -1307,27 +1320,26 @@ class BonPrelevement extends CommonObject $this->total = $this->total + $obj->somme; $i++; } + $nbtotalDrctDbtTxInf = $i; } else { - fputs($this->file, 'ERREUR DEBITEUR '.$sql.$CrLf); + fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers $result = -2; } - /* - * section Emetteur(sepa Emetteur bloc lines) - */ + // Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf if ($result != -2) { - $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $i, $this->total, $CrLf); + $fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf); } else { - fputs($this->file, 'ERREUR EMETTEUR'.$CrLf); + fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company } /** - * SECTION CREATION FICHIER SEPA + * SECTION CREATION SEPA FILE */ // SEPA File Header fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 27c70f993b5..f7e41bdc997 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -43,6 +43,7 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); $socid = GETPOST('socid','int'); +$ref = GETPOST('ref', 'alpha'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -265,7 +266,10 @@ if ($result) print ''; print ''; print ''; - print '\n"; + print '\n"; print ''; print ''; print "\n"; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 25fe9255858..b3b9898659d 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -41,6 +41,7 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 99965672c2e..ac2c1e4da9b 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -38,6 +38,7 @@ if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; From 48ae76e295040c6eb5f335a29c0b4b4eea26b7d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Sep 2017 19:13:40 +0200 Subject: [PATCH 27/52] Fix picto on service --- htdocs/product/composition/card.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 8fe496ca5ee..fc8ae32fb38 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -142,7 +142,7 @@ if ($action == 'search') { $current_lang = $langs->getDefaultLang(); - $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.tms as datem'; if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ', pl.label as labelm, pl.description as descriptionm'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; @@ -220,7 +220,7 @@ if ($id > 0 || ! empty($ref)) // Nature if ($object->type!=Product::TYPE_SERVICE) { - print ''; } @@ -228,7 +228,7 @@ if ($id > 0 || ! empty($ref)) if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price - print '"; + print "\n".''; + $productstatic->id=$objp->rowid; $productstatic->ref=$objp->ref; $productstatic->label=$objp->label; From 087e22ab945211a85ce641025315d9861757c2e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:14:39 +0200 Subject: [PATCH 28/52] Fix bad status picto --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index fe36e0e02f4..a694891cc82 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1446,7 +1446,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } // Status - $out.=''; + $out.=''; // Actions $out.=''; From bb6b3db0ac8016e47ee1a104e3b8d952349c8a91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 00:49:00 +0200 Subject: [PATCH 29/52] FIX Position of signature on strato template Conflicts: htdocs/core/modules/contract/doc/pdf_strato.modules.php --- .../contract/doc/pdf_strato.modules.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c06882fa121..77904beac0b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -463,17 +463,20 @@ class pdf_strato extends ModelePDFContract if (empty($hidebottom)) { - $pdf->SetXY(20,230); - $pdf->MultiCell(66,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); + $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); + $posy = $tab_top + $tab_height + 3 + 3; - $pdf->SetXY(20,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->emetteur->name),0,'L',0); - $pdf->SetXY(110,230); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + $pdf->SetXY($this->marge_gauche, $posy + 5); + $pdf->MultiCell($posmiddle - $this->marge_gauche - 5, 20, '', 1); - $pdf->SetXY(110,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY($posmiddle + 5, $posy); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 5, $outputlangs->transnoentities("ContactNameAndSignature", $this->recipient->name),0,'L',0); + + $pdf->SetXY($posmiddle + 5, $posy + 5); + $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); } } From 5e4b500b5d48266fb520b8b5e7dfe850b1031176 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 02:22:55 +0200 Subject: [PATCH 30/52] Fix signature was changed during insert --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index f18827bdd67..2b6cbb22e92 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -351,7 +351,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO '__EMAIL__' => $sendto, '__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', '__REF__' => (is_object($object)?$object->ref:''), - '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?dol_string_nohtmltag($user->signature):'') + '__SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:'') /* not available on all object /'__FIRSTNAME__'=>(is_object($object)?$object->firstname:''), '__LASTNAME__'=>(is_object($object)?$object->lastname:''), From 8986640a10e0a7c132a4dbc53d096d33908e4fd2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:13:57 +0200 Subject: [PATCH 31/52] FIX Responsive --- htdocs/core/class/html.form.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 44acfaaac6b..a684cff7165 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5500,6 +5500,8 @@ class Form print '
'; print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, ''); + + print '
'; print '
'; - if ($bon->amount) print round($row[0]/$bon->amount*100,2)." %"; + if ($object->amount) print round($row[0]/$object->amount*100,2)." %"; print '
'.$langs->trans("Total").' '.price($total)."'; + if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + print price($total); + print " 
'.$langs->trans("Total").' '.price($total)."'; + if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + print price($total); + print "  
'.$langs->trans("Nature").''; + print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); print '
'.$langs->trans("SellingPrice").''; + print '
'.$langs->trans("SellingPrice").''; if ($object->price_base_type == 'TTC') { print price($object->price_ttc).' '.$langs->trans($object->price_base_type); @@ -575,7 +575,8 @@ if ($id > 0 || ! empty($ref)) } } - print "\n
'.$actionstatic->LibStatut($histo[$key]['percent'],3,1,$histo[$key]['datestart']).''.$actionstatic->LibStatut($histo[$key]['percent'],3,0,$histo[$key]['datestart']).'
'; print ''; @@ -5593,6 +5595,7 @@ class Form } print '
'; + print ''; return $nbofdifferenttypes; } From 058b690e25672f5346f70742ea3a1a9d970ff999 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 09:22:52 +0200 Subject: [PATCH 32/52] FIX menu enty when url is external link --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f3d89ec514e..e9876b31ece 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -266,7 +266,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode { // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; - if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) + if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) // Do not change url content for external links { $tmp=explode('?',$newTabMenu[$i]['url'],2); $url = $shorturl = $tmp[0]; @@ -301,7 +301,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode foreach($menu->liste as $menkey => $menuval) { if (empty($noout)) print_start_menu_entry($menuval['idsel'],$menuval['classname'],$menuval['enabled']); - if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], ($menuval['url']!='#'?DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); + if (empty($noout)) print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url']!='#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT:'').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target']?$menuval['target']:$atarget)); if (empty($noout)) print_end_menu_entry($menuval['enabled']); } From 97e8974fdf94c30d229438ab7e03d73c73093bcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 13:26:43 +0200 Subject: [PATCH 33/52] FIX Better protection to no send email when we change limit --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 68258025098..2d1d234f812 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -51,7 +51,7 @@ if (! $error && count($toselect) > $maxformassaction) $error++; } -if (! $error && $massaction == 'confirm_presend' && GETPOST('modelselected')) // If we change the template, we must not send email, but keep on send email form +if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { $massaction='presend'; } From 9e29ea8011f6402d308d48f4322b35acd407d501 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2017 15:36:04 +0200 Subject: [PATCH 34/52] FIX Must use pdf format page as default for merging PDF. --- htdocs/core/actions_massactions.inc.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2d1d234f812..d03fb5df214 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -407,6 +407,12 @@ if (! $error && $massaction == 'confirm_presend') if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { + if (empty($diroutputmassaction)) + { + dol_print_error(null, 'include of actions_massactions.inc.php is done but var $diroutputmassaction was not defined'); + exit; + } + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -502,7 +508,13 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se } else { // Create empty PDF - $pdf=pdf_getInstance(); + $formatarray=pdf_getFormat(); + $page_largeur = $formatarray['width']; + $page_hauteur = $formatarray['height']; + $format = array($page_largeur,$page_hauteur); + + $pdf=pdf_getInstance($format); + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); From 39acb46139cb95b093114669c7927e705f1140ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 19:44:59 +0200 Subject: [PATCH 35/52] Fix multicompany --- htdocs/adherents/cartes/carte.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index db4c631c0c9..be11b08c9ee 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -68,6 +68,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; + $sql.= " AND d.entity IN (".getEntity('adherent').")"; if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid; if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'"; $sql.= " ORDER BY d.rowid ASC"; @@ -123,7 +124,7 @@ if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg { $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; if ($nb <= 0) $nb=1; // Protection to avoid empty page - + for($j=0;$j<$nb;$j++) { $arrayofmembers[]=array( From bb73da4c5e4b049e67c15f0efd417e000b639865 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 20:05:36 +0200 Subject: [PATCH 36/52] Cherry pick --- htdocs/projet/tasks/contact.php | 5 ++++- htdocs/projet/tasks/document.php | 5 ++++- htdocs/projet/tasks/note.php | 4 +++- htdocs/projet/tasks/task.php | 28 +++++++++++++++++++++------- htdocs/projet/tasks/time.php | 14 +++++++++----- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index d4029847534..3d834fe28b6 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -187,7 +187,7 @@ if ($id > 0 || ! empty($ref)) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); @@ -272,8 +272,11 @@ if ($id > 0 || ! empty($ref)) print '
'; dol_fiche_end(); + + print '
'; } + // To verify role of users //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project //$arrayofuseridoftask=$object->getListContactId('internal'); diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 649e1efd575..f6f206f90ec 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -130,7 +130,8 @@ if ($object->id > 0) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"),0,($projectstatic->public?'projectpub':'project')); + + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); @@ -215,6 +216,8 @@ if ($object->id > 0) print '
'; dol_fiche_end(); + + print '
'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 13a8979ae91..87d949eb645 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -110,7 +110,7 @@ if ($object->id > 0) // Tabs for project $tab='tasks'; $head=project_prepare_head($projectstatic); - dol_fiche_head($head, $tab, $langs->trans("Project"), 0, ($projectstatic->public?'projectpub':'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); $param=($mode=='mine'?'&mode=mine':''); // Project card @@ -194,6 +194,8 @@ if ($object->id > 0) print '
'; dol_fiche_end(); + + print '
'; } $head = task_prepare_head($object); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 1b43940029f..db56534f851 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -279,6 +279,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; + print '
'; print '
'; print '
'; @@ -468,6 +469,7 @@ if ($id > 0 || ! empty($ref)) dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); print '
'; + print '
'; print '
'; print ''; @@ -490,8 +492,21 @@ if ($id > 0 || ! empty($ref)) } print ''; + // Description + print ''; + + print '
'.$langs->trans("Description").''; + print nl2br($object->description); + print '
'; + print '
'; + + print '
'; + + print '
'; + print ''; + // Progress declared - print ''; - - // Description - print ''; // Other attributes @@ -522,6 +532,10 @@ if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("ProgressDeclared").''; + print '
'.$langs->trans("ProgressDeclared").''; if ($object->progress != '') { print $object->progress.' %'; @@ -506,12 +521,7 @@ if ($id > 0 || ! empty($ref)) if ($tmparray['total_duration'] > 0 && ! empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; else print '0 %'; } - else print ''; - print '
'.$langs->trans("Description").''; - print nl2br($object->description); + else print ''.$langs->trans("WorkloadNotDefined").''; print '
'; print '
'; + print '
'; + + print '
'; + print '
'; dol_fiche_end(); } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 4f27ce5af5f..9a513a4bce6 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -418,6 +418,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; } + else + { + print '
'; + } } } @@ -442,7 +446,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -450,7 +454,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; if (is_object($projectstatic->thirdparty)) { @@ -464,7 +468,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - print '
'; + print '
'; print ''; // Date start - Date end @@ -491,7 +495,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; // Progress declared - print ''; @@ -503,7 +507,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration']/$object->planned_workload*100, 2).' %'; else print '0 %'; } - else print ''; + else print ''.$langs->trans("WorkloadNotDefined").''; print ''; print '
'.$langs->trans("ProgressDeclared").''; + print '
'.$langs->trans("ProgressDeclared").''; print $object->progress.' %'; print '
'; From ee774f1bf92f25d93197c87dcbcdb03a97adb814 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 20:17:51 +0200 Subject: [PATCH 37/52] FIX Calculation in the activity box --- htdocs/core/boxes/box_activity.php | 6 +++-- htdocs/core/class/commoninvoice.class.php | 28 +++++++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 02b1d1880c8..7c6308e29e6 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -376,7 +376,7 @@ class box_activity extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND paye=0"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -403,6 +403,8 @@ class box_activity extends ModeleBoxes if (! empty($data)) { $j=0; + $alreadypaid=-1; + while ($line < count($cumuldata)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( @@ -431,7 +433,7 @@ class box_activity extends ModeleBoxes $totalMnt += $objp->Mnttot; $this->info_box_contents[$line][4] = array( 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3), + 'text' => $facturestatic->LibStatut(0,$data[$j]->fk_statut,3, $alreadypaid), ); $line++; $j++; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 4b6d70b1366..6bbde52cb58 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -51,7 +51,7 @@ abstract class CommonInvoice extends CommonObject const TYPE_DEPOSIT = 3; /** - * Proforma invoice. + * Proforma invoice. * @deprectad Remove this. A "proforma invoice" is an order with a look of invoice, not an invoice ! */ const TYPE_PROFORMA = 4; @@ -89,7 +89,7 @@ abstract class CommonInvoice extends CommonObject */ const STATUS_ABANDONED = 3; - + /** * Return remain amount to pay. Property ->id and ->total_ttc must be set. * This does not include open direct debit requests. @@ -141,7 +141,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Return amount (with tax) of all deposits invoices used by invoice. * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). @@ -154,11 +154,11 @@ abstract class CommonInvoice extends CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // TODO - return 0; + return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); if ($result >= 0) @@ -185,9 +185,9 @@ abstract class CommonInvoice extends CommonObject // TODO return 0; } - + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - + $discountstatic=new DiscountAbsolute($this->db); $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); if ($result >= 0) @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject return -1; } } - + /** * Renvoie tableau des ids de facture avoir issus de la facture * @@ -309,7 +309,7 @@ abstract class CommonInvoice extends CommonObject * @param int $paye Status field paye * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) * @param int $type Type invoice * @return string Libelle du statut */ @@ -418,7 +418,7 @@ abstract class CommonInvoice extends CommonObject if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); - if ($alreadypaid <= 0) + if ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); @@ -497,13 +497,13 @@ abstract class CommonInvoice extends CommonObject } elseif($cdr_type == 2 && !empty($cdr_nbjour)) // Application de la règle, le N du mois courant ou suivant { - + $date_piece = dol_mktime(0,0,0,date('m', $this->date),date('d', $this->date),date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_current = dol_mktime(0,0,0,date('m', $this->date),$cdr_nbjour,date('Y', $this->date)); // Sans les heures minutes et secondes $date_lim_next = strtotime(date('Y-m-d', $date_lim_current).' +1month'); - + $diff = $date_piece - $date_lim_current; - + if($diff < 0) $datelim = $date_lim_current; else $datelim = $date_lim_next; From 94368accc1de75a862cea2863a6daba6b8ed5f0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 20:36:45 +0200 Subject: [PATCH 38/52] Fix activity box --- htdocs/core/boxes/box_activity.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 7c6308e29e6..a05fcf761b6 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -95,8 +95,6 @@ class box_activity extends ModeleBoxes // compute the year limit to show $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); - $cumuldata = array(); - // list the summary of the propals if (! empty($conf->propal->enabled) && $user->rights->propale->lire) @@ -146,11 +144,10 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) + while ($line < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -231,10 +228,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT."/commande/list.php?mainmenu=commercial&leftmenu=orders&viewstatut=".$data[$j]->fk_statut, @@ -290,11 +286,11 @@ class box_activity extends ModeleBoxes $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=1"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -317,10 +313,9 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $billurl="search_status=2&paye=1&year=".$data[$j]->annee; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', @@ -371,12 +366,13 @@ class box_activity extends ModeleBoxes $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); + $data = array(); if ($refresh) { $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE f.entity = ".$conf->entity; + $sql.= " WHERE f.entity IN (".getEntity('facture').')'; $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=0"; + $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND f.paye=0"; $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; @@ -399,13 +395,12 @@ class box_activity extends ModeleBoxes $data = dol_readcachefile($cachedir, $filename); } - $cumuldata=array_merge($cumuldata, $data); if (! empty($data)) { $j=0; $alreadypaid=-1; - while ($line < count($cumuldata)) { + while ($line < count($data)) { $billurl="search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'align="left" width="16"', From 2c3428a1bff099c62c36e018570e7b2b2d07f228 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Sep 2017 20:48:09 +0200 Subject: [PATCH 39/52] Fix css --- htdocs/admin/agenda_other.php | 3 ++- htdocs/core/lib/agenda.lib.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index dd03d477c6f..ee9253057e8 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -373,11 +373,12 @@ $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AG print '
'.$langs->trans("AGENDA_DEFAULT_FILTER_STATUS").' '."\n"; -$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2); +$formactions->form_select_status_action('agenda', $conf->global->AGENDA_DEFAULT_FILTER_STATUS, 1, 'AGENDA_DEFAULT_FILTER_STATUS', 1, 2, 'minwidth100'); print '
'; print $langs->trans("Status"); print '  '; - $formactions->form_select_status_action('formaction',$status,1,'status',1,2); + $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2, 'minwidth100'); print '
'; print ''; - + if ($user->rights->societe->creer) { print '
'; - + print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); - + print '
'; print ''; print ''; @@ -293,7 +293,7 @@ if ($socid > 0) print ''; print ''; print ''; - + print "
'.$langs->trans("AmountHT").'
'.$langs->trans("NoteReason").'
"; } @@ -362,7 +362,7 @@ if ($socid > 0) while ($i < $num) { $obj = $db->fetch_object($resql); - + print '
'.dol_print_date($db->jdate($obj->dc),'dayhour').''; - print 'rowid.'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_split($langs->trans("SplitDiscount")).''; print '   '; - print 'rowid.'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage?'&backtopage='.urlencode($backtopage):'').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ' 
'.$langs->trans("None").'
"; @@ -441,7 +441,7 @@ if ($socid > 0) array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'], $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage?'&backtopage='.urlencode($backtopage):''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($showconfirminfo['amount_ttc']),$langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); } } else @@ -590,7 +590,7 @@ if ($socid > 0) { print '
'.$langs->trans("None").'
"; } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c66285ae0c8..6cfed39a02f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -378,7 +378,9 @@ if (empty($reshook)) else if ($action == "setabsolutediscount" && $user->rights->facture->creer) { - // POST[remise_id] ou POST[remise_id_for_payment] + // POST[remise_id] or POST[remise_id_for_payment] + + // We use the credit to reduce amount of invoice if (! empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { @@ -390,14 +392,28 @@ if (empty($reshook)) dol_print_error($db, $object->error); } } - if (! empty($_POST["remise_id_for_payment"])) { + // We use the credit to reduce remain to pay + if (! empty($_POST["remise_id_for_payment"])) + { require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); - $result = $discount->link_to_invoice(0, $id); - if ($result < 0) { - setEventMessages($discount->error, $discount->errors, 'errors'); + //var_dump($object->getRemainToPay(0)); + //var_dump($discount->amount_ttc);exit; + if ($discount->amount_ttc > $object->getRemainToPay(0)) + { + // TODO Split the discount in 2 automatically + $error++; + setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); + } + + if (! $error) + { + $result = $discount->link_to_invoice(0, $id); + if ($result < 0) { + setEventMessages($discount->error, $discount->errors, 'errors'); + } } } } @@ -3175,6 +3191,7 @@ else if ($id > 0 || ! empty($ref)) $addrelativediscount = '' . $langs->trans("EditRelativeDiscounts") . ''; $addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; + $viewabsolutediscount = '' . $langs->trans("ViewAvailableGlobalDiscounts") . ''; print '
' . $langs->trans('Discounts'); print ''; @@ -3184,7 +3201,7 @@ else if ($id > 0 || ! empty($ref)) print $langs->trans("CompanyHasNoRelativeDiscount"); // print ' ('.$addrelativediscount.')'; - // Is there commercial discount or down payment available ? + // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { print '. '; if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { @@ -3209,7 +3226,7 @@ else if ($id > 0 || ! empty($ref)) } else { if ($absolute_creditnote > 0) // If not, link will be added later { - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' (' . $addabsolutediscount . ')
'; else print '. '; @@ -3220,7 +3237,7 @@ else if ($id > 0 || ! empty($ref)) if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($object->statut != 1 || $object->type == Facture::TYPE_CREDIT_NOTE) { + if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE) { if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) { $text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)); print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse")); @@ -3231,13 +3248,13 @@ else if ($id > 0 || ! empty($ref)) // There is credit notes discounts available if (! $absolute_discount) print '
'; // $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer); - $more=' ('.$addcreditnote.')'; + $more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')'; $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher } } if (! $absolute_discount && ! $absolute_creditnote) { print $langs->trans("CompanyHasNoAbsoluteDiscount"); - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' (' . $addabsolutediscount . ')
'; else print '. '; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 443534eb1b3..89bb230d34f 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -78,6 +78,7 @@ class DiscountAbsolute $sql = "SELECT sr.rowid, sr.fk_soc,"; $sql.= " sr.fk_user,"; $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,"; + $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.description,"; $sql.= " sr.datec,"; $sql.= " f.facnumber as ref_facture_source"; @@ -97,9 +98,15 @@ class DiscountAbsolute $this->id = $obj->rowid; $this->fk_soc = $obj->fk_soc; + $this->amount_ht = $obj->amount_ht; $this->amount_tva = $obj->amount_tva; $this->amount_ttc = $obj->amount_ttc; + + $this->multicurrency_amount_ht = $obj->multicurrency_amount_ht; + $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->tva_tx = $obj->tva_tx; $this->fk_user = $obj->fk_user; $this->fk_facture_line = $obj->fk_facture_line; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 189ef5c1fe2..df00aec79fe 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -338,6 +338,7 @@ DateIsNotEnough=Date not reached yet InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s WarningInvoiceDateInFuture=Warning, the invoice date is higher than current date WarningInvoiceDateTooFarInFuture=Warning, the invoice date is too far from current date +ViewAvailableGlobalDiscounts=View available discounts # PaymentConditions Statut=Status PaymentConditionShortRECEP=Due Upon Receipt diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 8dfc02c49f1..e42e701bb3a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -196,7 +196,7 @@ ErrorBadLinkSourceSetButBadValueForRef=The link you use is not valid. A 'source' ErrorTooManyErrorsProcessStopped=Too many errors. Process was stopped. ErrorOnlyInvoiceValidatedCanBeSentInMassAction=Only validated invoices can be sent using the "Send by email" mass action. ErrorChooseBetweenFreeEntryOrPredefinedProduct=You must choose if article is a predefined product or not - +ErrorDiscountLargerThanRemainToPaySplitItBefore=The discount you try to apply is larger than remain to pay. Split the discount in 2 smaller discounts before. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined From 978702d04b3ded8ea709f41b45726d65eaa2d046 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Sep 2017 01:41:57 +0200 Subject: [PATCH 51/52] Fix false deprecated warning --- htdocs/core/lib/json.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 55bfcf96061..425b5713565 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -46,7 +46,7 @@ if (! function_exists('json_encode')) */ function dol_json_encode($elements) { - dol_syslog("For better permorfance, enable the native json in your PHP", LOG_WARNING); + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); $num=0; if (is_object($elements)) // Count number of properties for an object @@ -225,12 +225,11 @@ if (! function_exists('json_decode')) * @param string $json Json encoded to PHP Object or Array * @param bool $assoc False return an object, true return an array. Try to always use it with true ! * @return mixed Object or Array or false on error - * @deprecated PHP >= 5.3 supports native json_decode * @see json_decode() */ function dol_json_decode($json, $assoc=false) { - dol_syslog('dol_json_decode() is deprecated. Please update your code to use native json_decode().', LOG_WARNING); + dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); $comment = false; From 7375afca3ecd6e0916b2905fdd02da84f0b18c91 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 19 Sep 2017 09:03:25 +0200 Subject: [PATCH 52/52] fix : rest API URL --- htdocs/api/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 218ab58467e..f2c5160db38 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -128,7 +128,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain // Show message $message=''; -$url=$urlwithroot.'/api/index.php/login?login=auserlogin&userpassword=thepassword[&reset=1]'; +$url=$urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]'; $message.=$langs->trans("UrlToGetKeyToUseAPIs").':
'; $message.=img_picto('','object_globe.png').' '.$url; print $message;