diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 46b7a532a35..d945513f952 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -32,6 +32,8 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + /** * Manage the different format accountancy export @@ -742,10 +744,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/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 ''; } diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 07697ffd2d9..7d1f529bf82 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array('bills', 'compta', 'admin', 'other', 'products')); +$langs->loadLangs(array('bills', 'compta', 'admin', 'other', 'products', 'banks')); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); @@ -1030,6 +1030,8 @@ if ($action == 'create') // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')'; + $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $langs->trans("Count"); + $substitutionarray['__INVOICE_COUNTER_MAX__'] = $langs->trans("MaxPeriodNumber"); $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach ($substitutionarray as $key => $val) @@ -1446,8 +1448,6 @@ else print ''; // Bank Account - $langs->load('banks'); - print ''; print ''; // Model pdf - $langs->load('banks'); - print '
'; print $langs->trans('BankAccount'); @@ -1468,8 +1468,6 @@ else print '
'; print ''; print ''; - // Date end period + // Date print ''; print ''; - print ''; - print ''; - - // Date due - print ''; - print ''; print ''; print "\n"; + // Date end period + print ''; + print ''; + print ''; + print ''; + // Amount print ''; print '
'; print $langs->trans('Model'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 421e6b2e7d6..83f9706bcee 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -448,10 +448,12 @@ class Facture extends CommonInvoice $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, -1, 'y'), '%Y'); $substitutionarray['__INVOICE_YEAR__'] = dol_print_date($this->date, '%Y'); $substitutionarray['__INVOICE_NEXT_YEAR__'] = dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'); - // Only for tempalte invoice + // Only for template invoice $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = dol_print_date($originaldatewhen, 'dayhour'); $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($nextdatewhen, 'dayhour'); $substitutionarray['__INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__'] = dol_print_date($previousdaynextdatewhen, 'dayhour'); + $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $_facrec->nb_gen_done; + $substitutionarray['__INVOICE_COUNTER_MAX__'] = $_facrec->nb_gen_max; //var_dump($substitutionarray);exit; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index ff2cb84dbce..29c7a1f2aab 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2016-2018 Frédéric France * Copyright (C) 2017 Alexandre Spangaro @@ -141,7 +141,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) if (!$dateech) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'create'; } elseif (!$dateperiod) @@ -193,7 +193,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr if (! $dateech) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; } elseif (! $dateperiod) @@ -337,26 +337,26 @@ if ($action == 'create') print '
'; - print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")); - print ''; - print $form->selectDate(!empty($dateperiod) ? $dateperiod : '-1', 'period', 0, 0, 0, 'charge', 1); - print '
'; - print $langs->trans("DateDue"); + print $langs->trans("Date"); print ''; print $form->selectDate(!empty($dateech) ? $dateech : '-1', 'ech', 0, 0, 0, 'charge', 1); print '
'; + print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")); + print ''; + print $form->selectDate(!empty($dateperiod) ? $dateperiod : '-1', 'period', 0, 0, 0, 'charge', 1); + print '
'; @@ -434,11 +434,11 @@ if ($id > 0) } else { + $formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); - $formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("DateDue"), 'value' => -1); } - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneTax', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } @@ -515,9 +515,20 @@ if ($id > 0) print ''; // Type - print '"; + print '"; print ""; + // Date + if ($action == 'edit') + { + print '"; + } else { + print ""; + } + // Period end date print ""; print ""; - // Due date - if ($action == 'edit') - { - print '"; - } else { - print ""; - } - // Amount if ($action == 'edit') { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 5bb218d46cd..bf2d04515bf 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -499,16 +499,20 @@ class ChargeSociales extends CommonObject // Load translation files required by the page $langs->loadLangs(array("customers","bills")); + // We reinit status array to force to redefine them because label may change according to properties values. + $this->labelStatus = array(); + $this->labelStatusShort = array(); + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); - $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); - if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Paid'); + if ($status == self::STATUS_UNPAID && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } $statusType = 'status1'; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index e25d43209eb..d259fb362fd 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -217,7 +217,9 @@ if ($resql) print ''; - // Period end date + // Date + print ''; + // Period end date print ''; - print ''; // Status print '\n"; @@ -276,6 +277,10 @@ if ($resql) print "\n"; if (!$i) $totalarray['nbfield']++; + // Date + print ''; + if (!$i) $totalarray['nbfield']++; + // Date end period print ''; - if (!$i) $totalarray['nbfield']++; - print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index bb6eb95b32f..883dec19981 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -109,7 +109,7 @@ 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.= " ORDER BY f.datef DESC, f.ref DESC "; $sql.= " ORDER BY datelimite ASC, f.ref ASC "; 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); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0fe8c72220c..cba66729d8c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2361,6 +2361,7 @@ class Form $objp->price_ttc = price2num($objp->price_ttc, 'MU'); } } + $this->constructProductListOption($objp, $opt, $optJson, $price_level, $selected, $hidepriceinlabel, $filterkey); // Add new entry // "key" value of json key array is used by jQuery automatically as selected value @@ -2511,7 +2512,7 @@ class Form $sql .= " ORDER BY date_price DESC, rowid DESC"; // Warning DESC must be both on date_price and rowid. $sql .= " LIMIT 1"; - dol_syslog(get_class($this).'::constructProductListOption search price for level '.$price_level.'', LOG_DEBUG); + dol_syslog(get_class($this).'::constructProductListOption search price for product '.$objp->rowid.' AND level '.$price_level.'', LOG_DEBUG); $result2 = $this->db->query($sql); if ($result2) { @@ -2639,7 +2640,7 @@ class Form $langs->load("stocks"); $tmpproduct = new Product($this->db); - $tmpproduct->fetch($objp->rowid); + $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) $tmpproduct->load_virtual_stock(); $virtualstock = $tmpproduct->stock_theorique; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 9eebf9091b2..f80d2f1547a 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -508,7 +508,7 @@ class SMTPs // The error here just means the ID/password combo doesn't work. $_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235'); break; - case 'LOGIN': + case 'LOGIN': // most common case default: $this->socket_send_str('AUTH LOGIN', '334'); // User name will not return any error, server will take anything we give it. @@ -588,7 +588,11 @@ 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 @@ -1792,6 +1796,7 @@ class SMTPs $_retVal = false; break; } + $this->log .= $server_response; $limit++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index add0dba599d..c5e4dfb0d6d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4605,7 +4605,6 @@ function price2num($amount, $rounding = '', $alreadysqlnb = 0) return $amount; } - /** * Output a dimension with best unit * diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2eebf38ad56..d4b4016a564 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2613,3 +2613,32 @@ function convertBackOfficeMediasLinksToPublicLinks($notetoshow) $notetoshow=preg_replace('/src="[a-zA-Z0-9_\/\-\.]*(viewimage\.php\?modulepart=medias[^"]*)"/', 'src="'.$urlwithroot.'/\1"', $notetoshow); return $notetoshow; } + +/** + * 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() Format a numeric into a price for FEC files + */ +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 + $nbdecimal = (empty($conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH) ? 2 : $conf->global->ACCOUNTING_FEC_DECIMAL_LENGTH); + + // 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); + + return $output; +} diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0749d0a7645..6de51cfe7ba 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 @@ -2153,6 +2154,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")); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 664388797fc..3e92772738f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2051,9 +2051,11 @@ class Product extends CommonObject * @param string $ref_ext Ref ext of product/service to load * @param string $barcode Barcode of product/service to load * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $ignore_price_load Load product without loading prices arrays (when we are sure we don't need them) + * @param int $ignore_lang_load Load product without loading language arrays (when we are sure we don't need them) + * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0) + public function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0, $ignore_price_load = 0, $ignore_lang_load = 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -2182,12 +2184,12 @@ class Product extends CommonObject $this->fetch_optionals(); // multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS) && empty($ignore_lang_load)) { $this->getMultiLangs(); } // Load multiprices array - if (!empty($conf->global->PRODUIT_MULTIPRICES)) // prices per segment + if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($ignore_price_load)) // prices per segment { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { @@ -2255,11 +2257,11 @@ class Product extends CommonObject } } } - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // prices per customers + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && empty($ignore_price_load)) // prices per customers { // Nothing loaded by default. List may be very long. } - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // prices per quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) && empty($ignore_price_load)) // prices per quantity { $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; @@ -2310,7 +2312,7 @@ class Product extends CommonObject return -1; } } - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity { for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { @@ -2770,7 +2772,7 @@ class Product extends CommonObject // phpcs:enable global $conf, $user; - $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; + $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_suppliers, COUNT(DISTINCT cf.rowid) as nb,"; $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; @@ -2791,7 +2793,7 @@ class Product extends CommonObject $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - $this->stats_reception['suppliers'] = $obj->nb_customers; + $this->stats_reception['suppliers'] = $obj->nb_suppliers; $this->stats_reception['nb'] = $obj->nb; $this->stats_reception['rows'] = $obj->nb_rows; $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; @@ -4674,6 +4676,7 @@ class Product extends CommonObject $stock_commande_fournisseur = 0; $stock_sending_client = 0; $stock_reception_fournisseur = 0; + $stock_inproduction = 0; if (!empty($conf->commande->enabled)) { @@ -4699,34 +4702,49 @@ class Product extends CommonObject $result = $this->load_stats_commande_fournisseur(0, '1,2,3,4', 1); if ($result < 0) dol_print_error($this->db, $this->error); $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; - + } + if (!empty($conf->fournisseur->enabled) && empty($conf->reception->enabled)) + { $result = $this->load_stats_reception(0, '4', 1); if ($result < 0) dol_print_error($this->db, $this->error); $stock_reception_fournisseur = $this->stats_reception['qty']; } + if (!empty($conf->fournisseur->enabled) && !empty($conf->reception->enabled)) + { + $result = $this->load_stats_reception(0, '4', 1); // Use same tables than when module reception is not used. + if ($result < 0) dol_print_error($this->db, $this->error); + $stock_reception_fournisseur = $this->stats_reception['qty']; + } + if (!empty($conf->mrp->enabled)) + { + // TODO + $stock_inproduction = 0; + } + + $this->stock_theorique = $this->stock_reel + $stock_inproduction; // Stock decrease mode if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $this->stock_theorique = $this->stock_reel - $stock_commande_client + $stock_sending_client; + $this->stock_theorique -= ($stock_commande_client - $stock_sending_client); } - if (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { - $this->stock_theorique = $this->stock_reel; + elseif (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)) { + $this->stock_theorique += 0; } - if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) { - $this->stock_theorique = $this->stock_reel - $stock_commande_client; + elseif (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) { + $this->stock_theorique -= $stock_commande_client; } // Stock Increase mode if (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; + $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } - if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; + elseif (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } - if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { + elseif (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) { $this->stock_theorique -= $stock_reception_fournisseur; } - if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { - $this->stock_theorique += $stock_commande_fournisseur - $stock_reception_fournisseur; + elseif (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { + $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } if (!is_object($hookmanager)) { diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 9951c05d323..b8b0d0d2301 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -186,11 +186,19 @@ 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) { - throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error); + 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) { + $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; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c4a0ab64afa..6f9b9ad26b8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -920,7 +920,7 @@ class Societe extends CommonObject } } - // Check for unicity + // Check for unicity on profid if (!$error && $vallabel && $this->id_prof_verifiable($i)) { if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
'.$langs->trans("Type")."".$object->type_label."
'; + print $langs->trans("Type")."".$object->type_label."
'.$langs->trans("Date").""; + print $form->selectDate($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); + print "
".$langs->trans("Date")."".dol_print_date($object->date_ech, 'day')."
".$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).""; @@ -531,16 +542,6 @@ if ($id > 0) } print "
'.$langs->trans("DateDue").""; - print $form->selectDate($object->date_ech, 'ech', 0, 0, 0, 'charge', 1); - print "
".$langs->trans("DateDue")."".dol_print_date($object->date_ech, 'day')."
'; $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); print ' '; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; @@ -227,7 +229,6 @@ if ($resql) print ''; print ''; print ' '; $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); @@ -244,9 +245,9 @@ if ($resql) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre("DateDue", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cs.paye", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "
".$obj->type_label."'.dol_print_date($db->jdate($obj->date_ech), 'day').''; if ($obj->periode) @@ -295,10 +300,6 @@ if ($resql) if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; - // Due date - print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'