From 5c1a84746cbb5c8045ef62bbec132b3c5ea11db2 Mon Sep 17 00:00:00 2001 From: Lenin Rivas <53640168+leninrivas@users.noreply.github.com> Date: Mon, 12 Aug 2019 15:21:41 -0500 Subject: [PATCH 01/15] Add Linked objects Fichinter Ref. in PDF formats --- htdocs/core/lib/pdf.lib.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 56ca215e118..22bccb4462e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -10,6 +10,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * Copyright (C) 2015-2016 Marcos GarcĂ­a + * Copyright (C) 2019 Lenin Rivas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2129,6 +2130,17 @@ function pdf_getLinkedObjects($object, $outputlangs) $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs); } } + else if ($objecttype == 'fichinter') + { + $outputlangs->load('interventions'); + foreach($objects as $elementobject) + { + $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef"); + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); + $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate"); + $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec,'day','',$outputlangs); + } + } elseif ($objecttype == 'shipping') { $outputlangs->loadLangs(array("orders", "sendings")); From 25665daa40439467765813cd1634a6343beddd67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 14:53:40 +0100 Subject: [PATCH 02/15] FIX #11957 --- htdocs/comm/action/class/actioncomm.class.php | 8 ++++---- htdocs/comm/action/list.php | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 01f38eb531f..41cdd5caf5c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -791,16 +791,16 @@ class ActionComm extends CommonObject */ public function fetchResources() { - $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; + $this->userassigned = array(); + $this->socpeopleassigned = array(); + + $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; $sql .= ' WHERE fk_actioncomm = '.$this->id; $sql .= " AND element_type IN ('user', 'socpeople')"; $resql = $this->db->query($sql); if ($resql) { - $this->userassigned = array(); - $this->socpeopleassigned = array(); - // If owner is known, we must but id first into list if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 8288db9d90b..6df7aaa55ba 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -554,7 +554,10 @@ if ($resql) $actionstatic->type_picto = $obj->type_picto; $actionstatic->label = $obj->label; $actionstatic->location = $obj->location; - $actionstatic->note = dol_htmlentitiesbr($obj->note); + $actionstatic->note = dol_htmlentitiesbr($obj->note); // deprecated + $actionstatic->note_public = dol_htmlentitiesbr($obj->note); + + $actionstatic->fetchResources(); print ''; @@ -656,7 +659,6 @@ if ($resql) if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; - $actionstatic->fetchResources(); if (!empty($actionstatic->socpeopleassigned)) { $contactList = array(); From 28d0b85b84e15299a576fa0ac4674f33efaf2a63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 14:56:19 +0100 Subject: [PATCH 03/15] Fix phpcs --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 56b7f54d609..c1489a1b751 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2143,7 +2143,7 @@ function pdf_getLinkedObjects($object, $outputlangs) $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("InterDate"); - $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec,'day','',$outputlangs); + $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->datec, 'day', '', $outputlangs); } } elseif ($objecttype == 'shipping') From 7964699674f0e92cd859f873ac0dec512d4e94ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 16:22:53 +0100 Subject: [PATCH 04/15] FIX Check on unicity on prof id was not triggered sometimes --- htdocs/societe/class/societe.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f1d489751ac..793cbbbb97e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3284,6 +3284,12 @@ class Societe extends CommonObject // Define if third party is treated as company (or not) when nature is unknown $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default if (! empty($this->tva_intra)) $isacompany=1; + elseif (! empty($this->idprof1)) $isacompany=1; + elseif (! empty($this->idprof2)) $isacompany=1; + elseif (! empty($this->idprof3)) $isacompany=1; + elseif (! empty($this->idprof4)) $isacompany=1; + elseif (! empty($this->idprof5)) $isacompany=1; + elseif (! empty($this->idprof6)) $isacompany=1; elseif (! empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') { // TODO Add a field is_a_company into dictionary From 381f2d5eee3e41c896e608e9ea3ebb21c5cd334d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 16:24:16 +0100 Subject: [PATCH 05/15] Fix typo --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 793cbbbb97e..dd6765e34f5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -769,7 +769,7 @@ class Societe extends CommonObject } } - // Check for mandatory prof id (but only if country is other than ours) + // Check for mandatory prof id (but only if country is same than ours) if ($mysoc->country_id > 0 && $this->country_id == $mysoc->country_id) { $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; From 553107258e2763dd114b61918a61bdc81ac9b2b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Jan 2020 17:00:54 +0100 Subject: [PATCH 06/15] Fix alignement --- htdocs/admin/dict.php | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e5a525a62c9..af07dc9bfc6 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1298,7 +1298,6 @@ if ($id) // Determines the name of the field in relation to the possible names // in data dictionaries $showfield = 1; // By defaut - $align = "left"; $cssprefix = ''; $sortable = 1; $valuetoshow = ucfirst($fieldlist[$field]); // By defaut @@ -1310,23 +1309,23 @@ if ($id) if ($fieldlist[$field] == 'taux') { if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow = $langs->trans("Rate"); else $valuetoshow = $langs->trans("Amount"); - $align = 'center'; + $cssprefix = 'center '; } - if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $align = "center"; $sortable = 0; } - if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $align = "center"; $sortable = 0; } - if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $align = "center"; $sortable = 0; } - if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $align = "center"; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1_type') { $valuetoshow = $langs->trans("UseLocalTax")." 2"; $cssprefix = "center "; $sortable = 0; } + if ($fieldlist[$field] == 'localtax1') { $valuetoshow = $langs->trans("Rate")." 2"; $cssprefix = "center "; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2_type') { $valuetoshow = $langs->trans("UseLocalTax")." 3"; $cssprefix = "center "; $sortable = 0; } + if ($fieldlist[$field] == 'localtax2') { $valuetoshow = $langs->trans("Rate")." 3"; $cssprefix = "center "; $sortable = 0; } if ($fieldlist[$field] == 'organization') { $valuetoshow = $langs->trans("Organization"); } if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'position') { $align = 'right'; } + if ($fieldlist[$field] == 'position') { $cssprefix = 'right '; } if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { $valuetoshow = $langs->trans("Label"); } if ($fieldlist[$field] == 'libelle_facture') { $valuetoshow = $langs->trans("LabelOnDocuments"); } if ($fieldlist[$field] == 'country') { $valuetoshow = $langs->trans("Country"); } - if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $align = "center"; } + if ($fieldlist[$field] == 'recuperableonly') { $valuetoshow = $langs->trans("NPR"); $cssprefix = "center "; } if ($fieldlist[$field] == 'nbjour') { $valuetoshow = $langs->trans("NbOfDays"); } - if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $align = "center"; } + if ($fieldlist[$field] == 'type_cdr') { $valuetoshow = $langs->trans("AtEndOfMonth"); $cssprefix = "center "; } if ($fieldlist[$field] == 'decalage') { $valuetoshow = $langs->trans("Offset"); } if ($fieldlist[$field] == 'width' || $fieldlist[$field] == 'nx') { $valuetoshow = $langs->trans("Width"); } if ($fieldlist[$field] == 'height' || $fieldlist[$field] == 'ny') { $valuetoshow = $langs->trans("Height"); } @@ -1368,7 +1367,7 @@ if ($id) // Show field title if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $cssprefix); } } // Favorite - Only activated on country dictionary @@ -1424,8 +1423,8 @@ if ($id) foreach ($fieldlist as $field => $value) { //var_dump($fieldlist); + $class = ''; $showfield = 1; - $align = "left"; $valuetoshow = $obj->{$fieldlist[$field]}; if ($fieldlist[$field] == 'entity') { @@ -1457,13 +1456,13 @@ if ($id) } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { $valuetoshow = yn($valuetoshow); - $align = "center"; + $class = "center"; } elseif ($fieldlist[$field] == 'type_cdr') { if (empty($valuetoshow)) $valuetoshow = $langs->trans('None'); elseif ($valuetoshow == 1) $valuetoshow = $langs->trans('AtEndOfMonth'); elseif ($valuetoshow == 2) $valuetoshow = $langs->trans('CurrentNext'); - $align = "center"; + $class = "center"; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { $valuetoshow = price($valuetoshow); } @@ -1577,20 +1576,20 @@ if ($id) $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align = "center"; + $class = "center"; } elseif ($fieldlist[$field] == 'localtax2_type') { if ($obj->localtax2 != 0) $valuetoshow = $localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align = "center"; + $class = "center"; } elseif ($fieldlist[$field] == 'taux') { $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align = "center"; + $class = "center"; } elseif (in_array($fieldlist[$field], array('recuperableonly'))) { - $align = "center"; + $class = "center"; } elseif ($fieldlist[$field] == 'accountancy_code' || $fieldlist[$field] == 'accountancy_code_sell' || $fieldlist[$field] == 'accountancy_code_buy') { $valuetoshow = length_accountg($valuetoshow); @@ -1622,14 +1621,14 @@ if ($id) $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); } - $class = 'tddict'; + $class .= ($class ? ' ' : '').'tddict'; if ($fieldlist[$field] == 'note' && $id == 10) $class .= ' tdoverflowmax200'; if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; if ($fieldlist[$field] == 'position') $class .= ' right'; if ($fieldlist[$field] == 'localtax1_type') $class .= ' nowrap'; if ($fieldlist[$field] == 'localtax2_type') $class .= ' nowrap'; // Show value for field - if ($showfield) print ''.$valuetoshow.''; + if ($showfield) print ''.$valuetoshow.''; } } @@ -1908,9 +1907,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) { - $align = "left"; - if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $align = "center"; // Fields aligned on right - print ''; + $class = "left"; + if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) $class = "center"; // Fields aligned on right + print ''; print ''; print ''; } From 5eeef771fac4fa5e81ddec1e31d0a7e01800b156 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 23 Jan 2020 06:20:31 +0100 Subject: [PATCH 07/15] FIX: FEC export format --- .../class/accountancyexport.class.php | 10 +++---- htdocs/core/lib/functions.lib.php | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index dcf59be27f3..df120e90d09 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -658,9 +658,9 @@ class AccountancyExport print $end_line; foreach ( $objectLines as $line ) { - $date_creation = dol_print_date($line->date_creation, '%d%m%Y'); - $date_doc = dol_print_date($line->doc_date, '%d%m%Y'); - $date_valid = dol_print_date($line->date_validated, '%d%m%Y'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_doc = dol_print_date($line->doc_date, '%Y%m%d'); + $date_valid = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal . $separator; @@ -696,10 +696,10 @@ class AccountancyExport print $line->label_operation . $separator; // FEC:Debit - print price2num($line->debit) . $separator; + print price2fec($line->debit) . $separator; // FEC:Credit - print price2num($line->credit) . $separator; + print price2fec($line->credit) . $separator; // FEC:EcritureLet print $line->lettering_code . $separator; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 89bd0622f5f..0ec230d1b87 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4523,6 +4523,35 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) return $amount; } +/** + * Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) + * Function used into accountancy FEC export + * + * @param float $amount Amount to format + * @return string Chain with formatted upright + * + * @see price2num() Revert function of price2fec + */ +function price2fec($amount) +{ + global $conf; + + // Clean parameters + if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' + $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) + + // Output decimal number by default (french) + $nbdecimal= 2; + + // Output separators by default (french) + $dec=','; $thousand=''; + + // Format number + $output=number_format($amount, $nbdecimal, $dec, $thousand); + + return $output; +} + /** * Output a dimension with best unit From 7ec17f17d555b93c0715ee9a3ebeb61a72d59dee Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Thu, 23 Jan 2020 09:41:22 +0100 Subject: [PATCH 08/15] FIX - API - DLC/DLUO date for stock movement Instead of giving a string to the creation of a stock movement, we have to give an integer. This PR fixes that. [see: X] --- .../product/stock/class/api_stockmovements.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 9951c05d323..c4f6ee56b5a 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -186,10 +186,15 @@ class StockMovements extends DolibarrApi } // Type increase or decrease - if ($qty >= 0) $type = 3; - else $type = 2; + $type = 2; + if ($qty >= 0){ + $type = 3; + } - if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $dlc, $dluo, $lot) <= 0) { + $eatBy = empty($dluo) ? '' : (new DateTime($dluo))->getTimestamp(); + $sellBy = empty($dlc) ? '' : (new DateTime($dlc))->getTimestamp();; + + if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error); } From cc96da274140985a09935f299a1993dcbbb801f6 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Thu, 23 Jan 2020 10:47:52 +0100 Subject: [PATCH 09/15] Fix: strict mode mysql compatibility --- htdocs/core/boxes/box_factures_imp.php | 1 + htdocs/core/boxes/box_services_expired.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index bb6eb95b32f..881c3a295cb 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -111,6 +111,7 @@ class box_factures_imp extends ModeleBoxes if($user->socid) $sql.= " AND s.rowid = ".$user->socid; $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; + $sql.= ", s.email"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql.= " ORDER BY datelimite ASC, f.ref ASC "; $sql.= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index e80c2a57214..295c358caf0 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -94,6 +94,7 @@ class box_services_expired extends ModeleBoxes if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql.= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " ORDER BY date_line ASC"; $sql .= $this->db->plimit($max, 0); From fa305a14717efd511ba11cfe1373daa61b56e287 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Jan 2020 11:14:27 +0100 Subject: [PATCH 10/15] Update box_factures_imp.php --- htdocs/core/boxes/box_factures_imp.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 881c3a295cb..883dec19981 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -109,9 +109,8 @@ class box_factures_imp extends ModeleBoxes $sql.= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; + $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; - $sql.= ", s.email"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql.= " ORDER BY datelimite ASC, f.ref ASC "; $sql.= $this->db->plimit($max, 0); From 7f47b48559f1f3aa0cf27e0e556d10523e6e26be Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 23 Jan 2020 11:47:30 +0100 Subject: [PATCH 11/15] Move function to functions2.lib.php --- .../class/accountancyexport.class.php | 1 + htdocs/core/lib/functions.lib.php | 30 ------------------- htdocs/core/lib/functions2.lib.php | 29 ++++++++++++++++++ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index df120e90d09..742c3ac721c 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -38,6 +38,7 @@ */ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; class AccountancyExport { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0ec230d1b87..a16faa50f46 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4523,36 +4523,6 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) return $amount; } -/** - * Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) - * Function used into accountancy FEC export - * - * @param float $amount Amount to format - * @return string Chain with formatted upright - * - * @see price2num() Revert function of price2fec - */ -function price2fec($amount) -{ - global $conf; - - // Clean parameters - if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' - $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) - - // Output decimal number by default (french) - $nbdecimal= 2; - - // Output separators by default (french) - $dec=','; $thousand=''; - - // Format number - $output=number_format($amount, $nbdecimal, $dec, $thousand); - - return $output; -} - - /** * Output a dimension with best unit * diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 41d8758cca0..b271a092c90 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2340,3 +2340,32 @@ function random_color($min=0, $max=255) { return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max); } + +/** + * Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) + * Function used into accountancy FEC export + * + * @param float $amount Amount to format + * @return string Chain with formatted upright + * + * @see price2num() Revert function of price2fec + */ +function price2fec($amount) +{ + global $conf; + + // Clean parameters + if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' + $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) + + // Output decimal number by default (french) + $nbdecimal= 2; + + // Output separators by default (french) + $dec=','; $thousand=''; + + // Format number + $output=number_format($amount, $nbdecimal, $dec, $thousand); + + return $output; +} From 646ccc1354a9b5627146c170a63d2a520e32031c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Jan 2020 11:46:40 +0100 Subject: [PATCH 12/15] Fix error management --- htdocs/product/stock/class/api_stockmovements.class.php | 9 ++++++--- htdocs/product/stock/class/mouvementstock.class.php | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index c4f6ee56b5a..b8b0d0d2301 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -191,11 +191,14 @@ class StockMovements extends DolibarrApi $type = 3; } - $eatBy = empty($dluo) ? '' : (new DateTime($dluo))->getTimestamp(); - $sellBy = empty($dlc) ? '' : (new DateTime($dlc))->getTimestamp();; + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + $eatBy = empty($dluo) ? '' : dol_stringtotime($dluo); + $sellBy = empty($dlc) ? '' : dol_stringtotime($dlc); if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { - throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error); + $errormessage = $this->stockmovement->error; + if (empty($errormessage)) $errormessage = join(',', $this->stockmovement->errors); + throw new RestException(503, 'Error when create stock movement : '.$errormessage); } return $this->stockmovement->id; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 93c3d316be6..9e8dcc3184e 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -172,7 +172,7 @@ class MouvementStock extends CommonObject { if (empty($batch)) { - $this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref); + $this->errors[]=$langs->transnoentitiesnoconv("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref); dol_syslog("Try to make a movement of a product with status_batch on without any batch data"); $this->db->rollback(); @@ -207,7 +207,8 @@ class MouvementStock extends CommonObject if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility { // If found and eatby/sellby defined into table and provided and differs, return error - $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour')); + $langs->load("stocks"); + $this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatbywithouthour, 'dayhour')); dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR); $this->db->rollback(); return -3; @@ -244,7 +245,7 @@ class MouvementStock extends CommonObject if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility { // If found and eatby/sellby defined into table and provided and differs, return error - $this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)); + $this->errors[]=$langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)); dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR); $this->db->rollback(); return -3; From 1487158082e499ac844e5d0b1613a09a6d3d17e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Jan 2020 12:02:29 +0100 Subject: [PATCH 13/15] Update functions2.lib.php --- htdocs/core/lib/functions2.lib.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index b271a092c90..f9678c2f569 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2356,16 +2356,17 @@ function price2fec($amount) // Clean parameters if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' - $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) + $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) - // Output decimal number by default (french) - $nbdecimal= 2; + // Output decimal number by default + $nbdecimal = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH) ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH); - // Output separators by default (french) - $dec=','; $thousand=''; + // Output separators by default + $dec = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR) ? ',' : $conf->global->ACCOUNTING_FEC_DECIMAL_SEPARATOR); + $thousand = (empty($conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR) ? '' : $conf->global->ACCOUNTING_FEC_THOUSAND_SEPARATOR); // Format number - $output=number_format($amount, $nbdecimal, $dec, $thousand); + $output = number_format($amount, $nbdecimal, $dec, $thousand); return $output; } From cbe396b97c0596af8a958c990e3af5f2c523ab54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Jan 2020 12:04:14 +0100 Subject: [PATCH 14/15] Update functions2.lib.php --- htdocs/core/lib/functions2.lib.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index f9678c2f569..37bc6c1cd5e 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2320,9 +2320,9 @@ function getModuleDirForApiClass($module) /* * Return 2 hexa code randomly * - * @param $min int Between 0 and 255 - * @param $max int Between 0 and 255 - * @return String + * @param int $min Between 0 and 255 + * @param int $max Between 0 and 255 + * @return String Color string */ function random_color_part($min=0,$max=255) { @@ -2332,9 +2332,9 @@ function random_color_part($min=0,$max=255) /* * Return hexadecimal color randomly * - * @param $min int Between 0 and 255 - * @param $max int Between 0 and 255 - * @return String + * @param int $min Between 0 and 255 + * @param int $max Between 0 and 255 + * @return String Color string */ function random_color($min=0, $max=255) { @@ -2346,9 +2346,8 @@ function random_color($min=0, $max=255) * Function used into accountancy FEC export * * @param float $amount Amount to format - * @return string Chain with formatted upright - * - * @see price2num() Revert function of price2fec + * @return string Chain with formatted upright + * @see price2num() Format a numeric into a price for FEC files */ function price2fec($amount) { From 7ee37ddd3ff7871e6d58b7bc90edaa74a661a78d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Jan 2020 17:30:05 +0100 Subject: [PATCH 15/15] FIX Error in log for email sending with smtps was not complete --- htdocs/core/class/smtps.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 1ade95098fa..4415aad3b9a 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -506,8 +506,9 @@ class SMTPs // The error here just means the ID/password combo doesn't work. // There is not a method to determine which is the problem, ID or password - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) - $this->_setErr(130, 'Invalid Authentication Credentials.'); + if (! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) { + $this->_setErr(130, 'Invalid Authentication Credentials.'); + } } else { @@ -575,8 +576,12 @@ class SMTPs // From this point onward most server response codes should be 250 // Specify who the mail is from.... // This has to be the raw email address, strip the "name" off - $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); - + $resultmailfrom = $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); + if (! $resultmailfrom) { + fclose($this->socket); + return false; + } + // 'RCPT TO:' must be given a single address, so this has to loop // through the list of addresses, regardless of TO, CC or BCC // and send it out "single file" @@ -1786,6 +1791,7 @@ class SMTPs $_retVal = false; break; } + $this->log .= $server_response; $limit++; }