diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 2530454d056..4841b8bf171 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -117,7 +117,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; +$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_currency, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,"; $sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,"; $sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -142,7 +142,7 @@ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal); -$sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= ' AND b.amount <> 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) { $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; } @@ -282,6 +282,7 @@ if ($result) { $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref; $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account; + $reg = array(); if (preg_match('/^\((.*)\)$/i', $obj->label, $reg)) { $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]); } else { @@ -296,6 +297,12 @@ if ($result) { $tabtype[$obj->rowid] = 'unknown'; $tabmoreinfo[$obj->rowid] = array(); + $amounttouse = $obj->amount; + if (!empty($obj->amount_main_currency)) { + // If $obj->amount_main_currency is set, it means that $obj->amount is not in same currency, we must use $obj->amount_main_currency + $amounttouse = $obj->amount_main_currency; + } + // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { // Now loop on each link of record in bank (code similar to bankentries_list.php) @@ -334,7 +341,7 @@ if ($result) { $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); if ($compta_soc) { - $tabtp[$obj->rowid][$compta_soc] += $obj->amount; + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; @@ -350,7 +357,7 @@ if ($result) { $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. } if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; } } elseif ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; @@ -383,7 +390,7 @@ if ($result) { $resultmid = $db->query($sqlmid); if ($resultmid) { $objmid = $db->fetch_object($resultmid); - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; + $tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse; } } elseif ($links[$key]['type'] == 'payment_donation') { $paymentdonstatic->id = $links[$key]['url_id']; @@ -391,7 +398,7 @@ if ($result) { $paymentdonstatic->fk_donation = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; - $tabtp[$obj->rowid][$account_pay_donation] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; } elseif ($links[$key]['type'] == 'member') { $paymentsubscriptionstatic->id = $links[$key]['url_id']; $paymentsubscriptionstatic->ref = $links[$key]['url_id']; @@ -399,14 +406,14 @@ if ($result) { $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); - $tabtp[$obj->rowid][$account_pay_subscription] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; - $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; + $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; @@ -438,7 +445,7 @@ if ($result) { if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. $compta_user = $userstatic->accountancy_code; if ($compta_user) { - $tabtp[$obj->rowid][$compta_user] += $obj->amount; + $tabtp[$obj->rowid][$compta_user] += $amounttouse; $tabuser[$obj->rowid] = array( 'id' => $userstatic->id, 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), @@ -465,14 +472,14 @@ if ($result) { $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $tabpay[$obj->rowid]["account_various"] = $account_various; - $tabtp[$obj->rowid][$account_subledger] += $obj->amount; + $tabtp[$obj->rowid][$account_subledger] += $amounttouse; } elseif ($links[$key]['type'] == 'payment_loan') { $paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->fk_loan = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; - //$tabtp[$obj->rowid][$account_pay_loan] += $obj->amount; + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); @@ -488,14 +495,14 @@ if ($result) { } elseif ($links[$key]['type'] == 'banktransfert') { $accountLinestatic->fetch($links[$key]['url_id']); $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); - $tabtp[$obj->rowid][$account_transfer] += $obj->amount; + $tabtp[$obj->rowid][$account_transfer] += $amounttouse; $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); } } } - $tabbq[$obj->rowid][$compta_bank] += $obj->amount; + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. @@ -542,7 +549,7 @@ if ($result) { } }*/ - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; $i++; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 1b4340276f8..9f6ee0c539f 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1033,8 +1033,8 @@ if ($resql) { $event->type = 'holiday'; $event->type_picto = 'holiday'; - $event->datep = $db->jdate($obj->date_start); - $event->datef = $db->jdate($obj->date_end); + $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 3d2dee9a286..603627ee91e 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -45,8 +45,14 @@ if ($mode == 'customer' && !$user->rights->commande->lire) { if ($mode == 'supplier' && empty($user->rights->fournisseur->commande->lire)) { accessforbidden(); } +if ($mode == 'supplier') { + $object_status = GETPOST('object_status', 'array:int'); + $object_status = implode(',', $object_status); +} else { + $object_status = GETPOST('object_status', 'intcomma'); +} + -$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 3cf7da7820e..4d133c50dda 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -276,6 +276,9 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($limit) { + $param .= '&limit='.urlencode($limit); + } if ($search_conciliated != '' && $search_conciliated != '-1') { $param .= '&search_conciliated='.urlencode($search_conciliated); } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f01e74a0cf4..429d7c704c8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -519,9 +519,10 @@ class Account extends CommonObject * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @param int $datev Date value * @param string $num_releve Label of bank receipt for reconciliation + * @param float $amount_main_currency Amount * @return int Rowid of added entry, <0 if KO */ - public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '') + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '', $amount_main_currency = null) { // Deprecation warning if (is_numeric($oper)) { @@ -579,6 +580,7 @@ class Account extends CommonObject $accline->datev = $datev; $accline->label = $label; $accline->amount = $amount; + $accline->amount_main_currency = $amount_main_currency; $accline->fk_user_author = $user->id; $accline->fk_account = $this->id; $accline->fk_type = $oper; @@ -1801,7 +1803,8 @@ class AccountLine extends CommonObject */ public $datev; - public $amount; + public $amount; /* Amount of payment in the bank account currency */ + public $amount_main_currency; /* Amount in the currency of company if bank account use another currency */ /** * @var int ID @@ -1962,6 +1965,7 @@ class AccountLine extends CommonObject $sql .= ", datev"; $sql .= ", label"; $sql .= ", amount"; + $sql .= ", amount_main_currency"; $sql .= ", fk_user_author"; $sql .= ", num_chq"; $sql .= ", fk_account"; @@ -1976,7 +1980,8 @@ class AccountLine extends CommonObject $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", ".price2num($this->amount); - $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null"); + $sql .= ", ".(empty($this->amount_main_currency) ? "NULL" : price2num($this->amount_main_currency)); + $sql .= ", ".($this->fk_user_author > 0 ? ((int) $this->fk_user_author) : "null"); $sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null"); $sql .= ", '".$this->db->escape($this->fk_account)."'"; $sql .= ", '".$this->db->escape($this->fk_type)."'"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f91b776c0aa..87a59c2c960 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -811,6 +811,10 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $newinvoiceline->tva_tx; + if ($newinvoiceline->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$newinvoiceline->vat_src_code.')'; + $newinvoiceline->fk_parent_line = $fk_parent_line; if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { @@ -821,7 +825,37 @@ class Facture extends CommonInvoice $newinvoiceline->fk_remise_except = $discountId; } - $result = $newinvoiceline->insert(); + $result = $this->addline( + $newinvoiceline->desc, + $newinvoiceline->subprice, + $newinvoiceline->qty, + $vatrate, + $newinvoiceline->localtax1_tx, + $newinvoiceline->localtax2_tx, + $newinvoiceline->fk_product, + $newinvoiceline->remise_percent, + $newinvoiceline->date_start, + $newinvoiceline->date_end, + $newinvoiceline->fk_code_ventilation, + $newinvoiceline->info_bits, + $newinvoiceline->fk_remise_except, + 'HT', + 0, + $newinvoiceline->product_type, + $newinvoiceline->rang, + $newinvoiceline->special_code, + $newinvoiceline->element, + $newinvoiceline->id, + $fk_parent_line, + $newinvoiceline->fk_fournprice, + $newinvoiceline->pa_ht, + $newinvoiceline->label, + $newinvoiceline->array_options, + $newinvoiceline->situation_percent, + $newinvoiceline->fk_prev_id, + $newinvoiceline->fk_unit, + $newinvoiceline->multicurrency_subprice + ); // Defined the new fk_parent_line if ($result > 0) { diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 774495091a5..aea9f917dab 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -266,6 +266,7 @@ if (empty($reshook)) { if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. + // This also set ->amount and ->multicurrency_amount $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 86dcbdeff39..c5f40896a18 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -636,17 +636,22 @@ class Paiement extends CommonObject $this->db->begin(); $totalamount = $this->amount; + $totalamount_main_currency = null; if (empty($totalamount)) { $totalamount = $this->total; // For backward compatibility } // if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me) if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) { - $totalamount = $this->multicurrency_amount; + $totalamount = $this->multicurrency_amount; // We will insert into llx_bank.amount in foreign currency + $totalamount_main_currency = $this->amount; // We will also save the amount in main currency into column llx_bank.amount_main_currency } if ($mode == 'payment_supplier') { $totalamount = -$totalamount; + if (isset($totalamount_main_currency)) { + $totalamount_main_currency = -$totalamount_main_currency; + } } // Insert payment into llx_bank @@ -660,8 +665,11 @@ class Paiement extends CommonObject $user, $emetteur_nom, $emetteur_banque, - $accountancycode - ); + $accountancycode, + null, + '', + $totalamount_main_currency + ); // Mise a jour fk_bank dans llx_paiement // On connait ainsi le paiement qui a genere l'ecriture bancaire @@ -706,7 +714,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/comm/card.php?socid=', $fac->thirdparty->name, 'company' - ); + ); if ($result <= 0) { dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); } @@ -724,7 +732,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/fourn/card.php?socid=', $fac->thirdparty->name, 'company' - ); + ); if ($result <= 0) { dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); } @@ -742,7 +750,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/compta/prelevement/card.php?id=', $this->num_payment, 'withdraw' - ); + ); } // Add link 'InvoiceRefused' in bank_url @@ -753,7 +761,7 @@ class Paiement extends CommonObject DOL_URL_ROOT.'/compta/prelevement/card.php?id=', $this->num_prelevement, 'withdraw' - ); + ); } if (!$error && !$notrigger) { @@ -1291,40 +1299,40 @@ class Paiement extends CommonObject $langs->load('compta'); /*if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - }*/ + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ return ''; } diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 41e51eee45e..9462c810393 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -119,7 +119,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day", 'gmt').' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f95cb37b9bb..09c0e591ac7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4951,18 +4951,18 @@ abstract class CommonObject global $langs, $hookmanager, $conf, $form, $action; print ''; - print ''.$langs->trans('Ref').''; - print ''.$langs->trans('Description').''; - print ''.$langs->trans('VATRate').''; - print ''.$langs->trans('PriceUHT').''; + print ''.$langs->trans('Ref').''; + print ''.$langs->trans('Description').''; + print ''.$langs->trans('VATRate').''; + print ''.$langs->trans('PriceUHT').''; if (!empty($conf->multicurrency->enabled)) { - print ''.$langs->trans('PriceUHTCurrency').''; + print ''.$langs->trans('PriceUHTCurrency').''; } - print ''.$langs->trans('Qty').''; + print ''.$langs->trans('Qty').''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''.$langs->trans('Unit').''; + print ''.$langs->trans('Unit').''; } - print ''.$langs->trans('ReductionShort').''; + print ''.$langs->trans('ReductionShort').''; print ''.$langs->trans('TotalHT').''; print ''.$form->showCheckAddButtons('checkforselect', 1).''; print ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index ce94d6128dc..28e3a4a22f8 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -675,7 +675,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl $checkonentitydone = 0; // Array to define rules of checks to do - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 55d385fcd50..25c799ffbfd 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -28,20 +28,20 @@ if (empty($conf) || !is_object($conf)) { tpl['id'].'" class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">'; -print ''.$this->tpl['label'].''; -print ''.$this->tpl['description'].''; -print ''.$this->tpl['vat_rate'].''; -print ''.$this->tpl['price'].''; +print ''.$this->tpl['label'].''; +print ''.$this->tpl['description'].''; +print ''.$this->tpl['vat_rate'].''; +print ''.$this->tpl['price'].''; if (!empty($conf->multicurrency->enabled)) { - print ''.$this->tpl['multicurrency_price'].''; + print ''.$this->tpl['multicurrency_price'].''; } -print ''.$this->tpl['qty'].''; +print ''.$this->tpl['qty'].''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''.$langs->trans($this->tpl['unit']).''; + print ''.$langs->trans($this->tpl['unit']).''; } -print ''.$this->tpl['remise_percent'].''; +print ''.$this->tpl['remise_percent'].''; print ''.$this->tpl['total_ht'].''; $selected = 1; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index b85b373f81f..bf3d7052a86 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -160,11 +160,12 @@ class PaiementFourn extends Paiement $error = 0; $way = $this->getWay(); + $now = dol_now(); + // Clean parameters $totalamount = 0; $totalamount_converted = 0; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); + $atleastonepaymentnotnull = 0; if ($way == 'dolibarr') { $amounts = &$this->amounts; @@ -174,23 +175,62 @@ class PaiementFourn extends Paiement $amounts_to_update = &$this->amounts; } + $currencyofpayment = ''; + foreach ($amounts as $key => $value) { + if (empty($value)) { + continue; + } + // $key is id of invoice, $value is amount, $way is a 'dolibarr' if amount is in main currency, 'customer' if in foreign currency $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value ? $value : 0, $way, 'facture_fourn'); + // Add controls of input validity + if ($value_converted === false) { + // We failed to find the conversion for one invoice + $this->error = 'FailedToFoundTheConversionRateForInvoice'; + return -1; + } + if (empty($currencyofpayment)) { + $currencyofpayment = $this->multicurrency_code[$key]; + } + if ($currencyofpayment != $this->multicurrency_code[$key]) { + // If we have invoices with different currencies in the payment, we stop here + $this->error = 'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment'; + return -1; + } + $totalamount_converted += $value_converted; $amounts_to_update[$key] = price2num($value_converted, 'MT'); $newvalue = price2num($value, 'MT'); $amounts[$key] = $newvalue; $totalamount += $newvalue; + if (!empty($newvalue)) { + $atleastonepaymentnotnull++; + } } + + if (!empty($currencyofpayment)) { + // We must check that the currency of invoices is the same than the currency of the bank + $bankaccount = new Account($this->db); + $bankaccount->fetch($this->fk_account); + $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code; + if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode); + return -1; + } + } + + $totalamount = price2num($totalamount); $totalamount_converted = price2num($totalamount_converted); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $this->db->begin(); if ($totalamount <> 0) { // On accepte les montants negatifs $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : ''); - $now = dol_now(); if ($way == 'dolibarr') { $total = $totalamount; @@ -346,7 +386,7 @@ class PaiementFourn extends Paiement $this->total = $total; $this->multicurrency_amount = $mtotal; $this->db->commit(); - dol_syslog('PaiementFourn::Create Ok Total = '.$this->total); + dol_syslog('PaiementFourn::Create Ok Total = '.$this->amount.', Total currency = '.$this->multicurrency_amount); return $this->id; } else { $this->db->rollback(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c545762e5a4..7e5746bf9bb 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3192,7 +3192,7 @@ if ($action == 'create') { } // Show link for "recalculate" if ($object->getVentilExportCompta() == 0) { - $s = ''.$langs->trans("ReCalculate").' '; + $s = ''.$langs->trans("ReCalculate").' '; $s .= ''.$langs->trans("Mode1").''; $s .= ' / '; $s .= ''.$langs->trans("Mode2").''; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 2662e38951d..6e9e73c8d27 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -268,6 +268,8 @@ if (empty($reshook)) { $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $multicurrency_code = array(); + // Clean parameters amount if payment is for a credit note foreach ($amounts as $key => $value) { // How payment is dispatched $tmpinvoice = new FactureFournisseur($db); @@ -276,6 +278,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched @@ -285,6 +288,7 @@ if (empty($reshook)) { $newvalue = price2num($value, 'MT'); $multicurrency_amounts[$key] = - abs($newvalue); } + $multicurrency_code[$key] = $tmpinvoice->multicurrency_code; } //var_dump($amounts); @@ -304,12 +308,16 @@ if (empty($reshook)) { $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts $paiement->multicurrency_amounts = $multicurrency_amounts; + $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->paiementid = GETPOST('paiementid', 'int'); - $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->fk_account = GETPOST('accountid', 'int'); if (!$error) { + // Create payment and update this->multicurrency_amounts if this->amounts filled or + // this->amounts if this->multicurrency_amounts filled. + // This also set ->amount and ->multicurrency_amount $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -318,7 +326,7 @@ if (empty($reshook)) { } if (!$error) { - $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', ''); + $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index a9bfe8ab4f2..942cbf2b482 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -471,10 +471,9 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysToValidateBody")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateBody")."

\n"; // option to warn the validator in case of too short delay @@ -484,8 +483,7 @@ if (empty($reshook)) { $nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd'); if ($object->date_debut < $nowplusdelay) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."\n"; + $message = "

".$langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."

\n"; } } } @@ -495,20 +493,21 @@ if (empty($reshook)) { $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateAlertSolde")."

\n"; } } - $message .= "\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; + + $message .= "\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Sending the email $result = $mail->sendfile(); @@ -617,19 +616,20 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + $message .= "

".$langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= "\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Sending email $result = $mail->sendfile(); @@ -697,20 +697,21 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= GETPOST('detail_refuse', 'alpha')."\n\n"; + $message .= "

".$langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; + $message .= "

".GETPOST('detail_refuse', 'alpha')."

"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= ""; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // sending email $result = $mail->sendfile(); @@ -842,18 +843,20 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $message .= "

".$langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; + + $message .= "\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // sending email $result = $mail->sendfile(); diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index e2d490d5556..ba4ee14bbf2 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -537,3 +537,7 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, -- VMYSQL4.3 ALTER TABLE llx_user MODIFY COLUMN fk_soc integer NULL; -- VPGSQL8.2 ALTER TABLE llx_user ALTER COLUMN fk_soc DROP NOT NULL; +-- Add column to help to fix a very critical bug when transferring into accounting bank record of a bank account into another currency. +-- Idea is to update this column manually in v15 with value in currency of company for bank that are not into the main currency and the transfer +-- into accounting will use it in priority if value is not null. +ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 4935577cbf8..070f3a2c5da 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -557,3 +557,8 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; + +-- Sequence to fix the content of llx_bank.amount_main_currency +-- DROP TABLE tmp_bank; +-- CREATE TABLE tmp_bank SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment' INNER JOIN llx_paiement as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; +-- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; diff --git a/htdocs/install/mysql/tables/llx_bank.sql b/htdocs/install/mysql/tables/llx_bank.sql index 0e1dbc403da..d0a8e34790b 100644 --- a/htdocs/install/mysql/tables/llx_bank.sql +++ b/htdocs/install/mysql/tables/llx_bank.sql @@ -24,7 +24,8 @@ create table llx_bank tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, datev date, -- date de valeur dateo date, -- date operation - amount double(24,8) NOT NULL default 0, + amount double(24,8) NOT NULL default 0, -- amount in the currency of the bank account + amount_main_currency double(24,8) NULL, -- amount in the main currency of the company label varchar(255), fk_account integer, fk_user_author integer, diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index b7c4321dfd1..1937b99b871 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -272,6 +272,7 @@ if ($id > 0 || !empty($ref)) { } print '
'."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index d9d81ad70dc..5a236334b5e 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 0c569d3530c..03bb1828f66 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -183,7 +183,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; - + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 13c6329b34f..c62c421d6e4 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -214,6 +214,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 9db71e92148..59ca77d5937 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -197,6 +197,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 693f1fbae03..38bebc562ed 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -176,6 +176,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 068184feb7e..2f6faca07a7 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -199,6 +199,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index ab02e51fa57..2136b9b26cf 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 23e93aba785..51836c75715 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -909,10 +909,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } // Desired stock - print ''.($fk_entrepot > 0 ? $desiredstockwarehouse : $desiredstock).''; + print ''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock).''; // Limit stock for alert - print ''.($fk_entrepot > 0 ? $alertstockwarehouse : $alertstock).''; + print ''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock).''; // Current stock (all warehouses) print ''.$warning.$stock; @@ -928,7 +928,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''.$ordered.' '.$picto.''; // To order - print ''; + print ''; // Supplier print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 669f0b445db..4862bcbd422 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1277,7 +1277,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Date birth print ''.$langs->trans("DateOfBirth").''; print ''; - print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0); + print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0, 0, '', 0, '', '', 1, '', '', 'tzserver'); print ''; print "\n"; @@ -1568,6 +1568,13 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print "\n"; + // Date of birth + print ''.$langs->trans("DateOfBirth").''; + print ''; + print dol_print_date($object->birth, 'day', 'tzserver'); + print ''; + print "\n"; + // Default warehouse if (!empty($conf->stock->enabled) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -1846,7 +1853,7 @@ if ($action == 'create' || $action == 'adduserldap') { print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle', '', $canSendMail, $params); } - if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { $params = array( 'attr' => array( 'title' => '', @@ -1860,7 +1867,7 @@ if ($action == 'create' || $action == 'adduserldap') { print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken(), '', true, $params); } } elseif ($caneditpassword && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { $params = array( 'attr' => array( 'title' => '', @@ -1882,7 +1889,7 @@ if ($action == 'create' || $action == 'adduserldap') { $params['attr']['title'] = $langs->trans('UserDisabled'); print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password&token='.newToken(), '', true, $params); } @@ -1890,7 +1897,7 @@ if ($action == 'create' || $action == 'adduserldap') { $params['attr']['title'] = $langs->trans('UserDisabled'); print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($object->email) { print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend&token='.newToken(), '', true, $params); } else { @@ -1908,12 +1915,12 @@ if ($action == 'create' || $action == 'adduserldap') { ) ); if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken(), '', true, $params); } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=disable&token='.newToken(), '', true, $params); } else { if ($user->id == $id) { @@ -1923,7 +1930,7 @@ if ($action == 'create' || $action == 'adduserldap') { } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params); } else { @@ -2759,9 +2766,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("DateOfBirth").''; print ''; if ($caneditfield) { - echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0); + echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); } else { - print dol_print_date($object->birth, 'day'); + print dol_print_date($object->birth, 'day', 'tzserver'); } print ''; print "\n"; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 28542667dff..f01820f93e9 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1873,7 +1873,7 @@ class User extends CommonObject $sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' - $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth)."'" : 'null'); + $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth, 'tzserver')."'" : 'null'); if (!empty($user->admin)) { $sql .= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user }