From 02e022ebfa06e11bba29316abebad0242ba23f62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Jun 2020 19:59:06 +0200 Subject: [PATCH 01/10] Fix class not found for supplier credit. Class must be into commoninvoice --- htdocs/compta/bank/class/account.class.php | 2 + htdocs/compta/facture/class/facture.class.php | 155 ------------------ htdocs/compta/facture/prelevement.php | 20 ++- htdocs/core/class/commoninvoice.class.php | 154 +++++++++++++++++ htdocs/langs/en_US/bills.lang | 2 + htdocs/langs/en_US/withdrawals.lang | 2 +- 6 files changed, 173 insertions(+), 162 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index ca6a2e8d589..07e4abb0197 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1389,6 +1389,8 @@ class Account extends CommonObject $label = ''.$langs->trans("BankAccount").''; $label .= '
'.$langs->trans('Label').': '.$this->label; $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; + $label .= '
'.$langs->trans('IBAN').': '.$this->iban; + $label .= '
'.$langs->trans('BIC').': '.$this->bic; $label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; if (empty($user->rights->banque->lire) || !empty($user->socid)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9a80ad91d24..8957da7b9db 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4078,161 +4078,6 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Create a withdrawal request for a direct debit order or a credit transfer order. - * Use the remain to pay excluding all existing open direct debit requests. - * - * @param User $fuser User asking the direct debit transfer - * @param float $amount Amount we request direct debit for - * @param string $type 'direct-debit' or 'bank-transfer' - * @param string $sourcetype Source ('facture' or 'supplier_invoice') - * @return int <0 if KO, >0 if OK - */ - public function demande_prelevement($fuser, $amount = 0, $type = 'direct-debit', $sourcetype = 'facture') - { - // phpcs:enable - global $conf; - - $error = 0; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - - if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) - { - require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; - $bac = new CompanyBankAccount($this->db); - $bac->fetch(0, $this->socid); - - $sql = 'SELECT count(*)'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - if ($type == 'bank-transfer') { - $sql .= ' WHERE fk_facture_fourn = '.$this->id; - } else { - $sql .= ' WHERE fk_facture = '.$this->id; - } - $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments - $sql .= ' AND traite = 0'; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $row = $this->db->fetch_row($resql); - if ($row[0] == 0) - { - $now = dol_now(); - - $totalpaye = $this->getSommePaiement(); - $totalcreditnotes = $this->getSumCreditNotesUsed(); - $totaldeposits = $this->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; - - // We can also use bcadd to avoid pb with floating points - // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); - //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - - if (is_numeric($amount) && $amount != 0) - { - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande('; - if ($type == 'bank-transfer') { - $sql .= 'fk_facture_fourn, '; - } else { - $sql .= 'fk_facture, '; - } - $sql .= ' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, entity)'; - $sql .= ' VALUES ('.$this->id; - $sql .= ",'".price2num($amount)."'"; - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",".$fuser->id; - $sql .= ",'".$this->db->escape($bac->code_banque)."'"; - $sql .= ",'".$this->db->escape($bac->code_guichet)."'"; - $sql .= ",'".$this->db->escape($bac->number)."'"; - $sql .= ",'".$this->db->escape($bac->cle_rib)."'"; - $sql .= ",'".$this->db->escape($sourcetype)."'"; - $sql .= ",".$conf->entity; - $sql .= ")"; - - dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::demandeprelevement Erreur'); - $error++; - } - } - else - { - $this->error = 'WithdrawRequestErrorNilAmount'; - dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); - $error++; - } - - if (!$error) - { - // Force payment mode of invoice to withdraw - $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); - if ($payment_mode_id > 0) - { - $result = $this->setPaymentMethods($payment_mode_id); - } - } - - if ($error) return -1; - return 1; - } - else - { - $this->error = "A request already exists"; - dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); - return 0; - } - } - else - { - $this->error = $this->db->error(); - dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); - return -2; - } - } - else - { - $this->error = "Status of invoice does not allow this"; - dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); - return -3; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Supprime une demande de prelevement - * - * @param User $fuser User making delete - * @param int $did id de la demande a supprimer - * @return int <0 if OK, >0 if KO - */ - public function demande_prelevement_delete($fuser, $did) - { - // phpcs:enable - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; - $sql .= ' WHERE rowid = '.$did; - $sql .= ' AND traite = 0'; - if ($this->db->query($sql)) - { - return 0; - } - else - { - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); - return -1; - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 2b181e52078..dd9c1394563 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -114,12 +114,12 @@ if (empty($reshook)) if ($action == "delete") { - if ($object->id > 0) + if ($object->id > 0) { $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int')); if ($result == 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&mode='.$mode); exit; } } @@ -487,13 +487,21 @@ if ($object->id > 0) print ""; print ''; - print ''.$langs->trans("RIB").''; + $title = 'CustomerIBAN'; + if ($mode == 'bank-transfer') { + $title = 'SupplierIBAN'; + } + print ''.$langs->trans($title).''; $bac = new CompanyBankAccount($db); $bac->fetch(0, $object->thirdparty->id); print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; - if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + if (!empty($bac->iban)) { + if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + } else { + print img_warning($langs->trans("NoDefaultIBANFound")); + } print ''; @@ -741,7 +749,7 @@ if ($object->id > 0) $obj = $db->fetch_object($result_sql); print ''; - print ''.dol_print_date($db->jdate($obj->date_demande), 'day')."\n"; + print ''.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."\n"; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; print ''.price($obj->amount).''; print '-'; @@ -750,7 +758,7 @@ if ($object->id > 0) print ''.$langs->trans("OrderWaiting").''; print ''; - print ''; + print ''; print img_delete(); print ''; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c37ece437d4..cb7ce67d923 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -687,6 +687,160 @@ abstract class CommonInvoice extends CommonObject return $datelim; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Create a withdrawal request for a direct debit order or a credit transfer order. + * Use the remain to pay excluding all existing open direct debit requests. + * + * @param User $fuser User asking the direct debit transfer + * @param float $amount Amount we request direct debit for + * @param string $type 'direct-debit' or 'bank-transfer' + * @param string $sourcetype Source ('facture' or 'supplier_invoice') + * @return int <0 if KO, >0 if OK + */ + public function demande_prelevement($fuser, $amount = 0, $type = 'direct-debit', $sourcetype = 'facture') + { + // phpcs:enable + global $conf; + + $error = 0; + + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + + if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) + { + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; + $bac = new CompanyBankAccount($this->db); + $bac->fetch(0, $this->socid); + + $sql = 'SELECT count(*)'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + if ($type == 'bank-transfer') { + $sql .= ' WHERE fk_facture_fourn = '.$this->id; + } else { + $sql .= ' WHERE fk_facture = '.$this->id; + } + $sql .= ' AND ext_payment_id IS NULL'; // To exclude record done for some online payments + $sql .= ' AND traite = 0'; + + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $row = $this->db->fetch_row($resql); + if ($row[0] == 0) + { + $now = dol_now(); + + $totalpaye = $this->getSommePaiement(); + $totalcreditnotes = $this->getSumCreditNotesUsed(); + $totaldeposits = $this->getSumDepositsUsed(); + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + + // We can also use bcadd to avoid pb with floating points + // For example print 239.2 - 229.3 - 9.9; does not return 0. + //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + + if (is_numeric($amount) && $amount != 0) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande('; + if ($type == 'bank-transfer') { + $sql .= 'fk_facture_fourn, '; + } else { + $sql .= 'fk_facture, '; + } + $sql .= ' amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib, sourcetype, entity)'; + $sql .= ' VALUES ('.$this->id; + $sql .= ",'".price2num($amount)."'"; + $sql .= ",'".$this->db->idate($now)."'"; + $sql .= ",".$fuser->id; + $sql .= ",'".$this->db->escape($bac->code_banque)."'"; + $sql .= ",'".$this->db->escape($bac->code_guichet)."'"; + $sql .= ",'".$this->db->escape($bac->number)."'"; + $sql .= ",'".$this->db->escape($bac->cle_rib)."'"; + $sql .= ",'".$this->db->escape($sourcetype)."'"; + $sql .= ",".$conf->entity; + $sql .= ")"; + + dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::demandeprelevement Erreur'); + $error++; + } + } + else + { + $this->error = 'WithdrawRequestErrorNilAmount'; + dol_syslog(get_class($this).'::demandeprelevement WithdrawRequestErrorNilAmount'); + $error++; + } + + if (!$error) + { + // Force payment mode of invoice to withdraw + $payment_mode_id = dol_getIdFromCode($this->db, 'PRE', 'c_paiement', 'code', 'id', 1); + if ($payment_mode_id > 0) + { + $result = $this->setPaymentMethods($payment_mode_id); + } + } + + if ($error) return -1; + return 1; + } + else + { + $this->error = "A request already exists"; + dol_syslog(get_class($this).'::demandeprelevement Impossible de creer une demande, demande deja en cours'); + return 0; + } + } + else + { + $this->error = $this->db->error(); + dol_syslog(get_class($this).'::demandeprelevement Erreur -2'); + return -2; + } + } + else + { + $this->error = "Status of invoice does not allow this"; + dol_syslog(get_class($this)."::demandeprelevement ".$this->error." $this->statut, $this->paye, $this->mode_reglement_id"); + return -3; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Remove a direct debit request or a credit transfer request + * + * @param User $fuser User making delete + * @param int $did ID of request to delete + * @return int <0 if OK, >0 if KO + */ + public function demande_prelevement_delete($fuser, $did) + { + // phpcs:enable + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; + $sql .= ' WHERE rowid = '.$did; + $sql .= ' AND traite = 0'; + if ($this->db->query($sql)) + { + return 0; + } + else + { + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this).'::demande_prelevement_delete Error '.$this->error); + return -1; + } + } } diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 1e562909360..dccc80b1918 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -440,6 +440,8 @@ BankAccountNumberKey=Checksum Residence=Address IBANNumber=IBAN account number IBAN=IBAN +CustomerIBAN=IBAN of customer +SupplierIBAN=IBAN of vendor BIC=BIC/SWIFT BICNumber=BIC/SWIFT code ExtraInfos=Extra infos diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index bea89f1d5d0..49c9f8b5921 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -131,7 +131,7 @@ ICS=Creditor Identifier CI END_TO_END="EndToEndId" SEPA XML tag - Unique id assigned per transaction USTRD="Unstructured" SEPA XML tag ADDDAYS=Add days to Execution Date - +NoDefaultIBANFound=No default IBAN found for this third party ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank InfoCreditMessage=The direct debit payment order %s has been paid by the bank
Data of payment: %s From bbb8c9418e09888d2b955468b47165fc49bae256 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jun 2020 11:49:20 +0200 Subject: [PATCH 02/10] Fix bad property --- htdocs/core/boxes/box_shipments.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 8908f52640c..61942d03f45 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -103,10 +103,10 @@ class box_shipments extends ModeleBoxes $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; $sql .= " WHERE e.entity = ".$conf->entity; if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sc.fk_user = ".$user->id; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; $sql .= $this->db->plimit($max, 0); From 18c23680f7822387735e27141e82444677dcf571 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jun 2020 12:17:06 +0200 Subject: [PATCH 03/10] Fix bad object --- htdocs/comm/action/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 5b3ddefa0f5..f35c17d375d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1704,7 +1704,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type_code == 'ICALEVENT') print '
('.dol_trunc($event->icalname, $maxnbofchar).')'; $thirdparty_id = ($event->thirdparty_id > 0 ? $event->thirdparty_id : ((is_object($event->societe) && $event->societe->id > 0) ? $event->societe->id : 0)); - $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->cotact->id > 0) ? $event->contact->id : 0)); + $contact_id = ($event->contact_id > 0 ? $event->contact_id : ((is_object($event->contact) && $event->contact->id > 0) ? $event->contact->id : 0)); // If action related to company / contact $linerelatedto = ''; From e99ab329fd04eb50fb4cca199dbee79f28b9441a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jun 2020 22:22:54 +0200 Subject: [PATCH 04/10] Remove bans --- build/doxygen/doxygen_footer.html | 28 +--------------------------- build/doxygen/doxygen_header.html | 24 ------------------------ 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/build/doxygen/doxygen_footer.html b/build/doxygen/doxygen_footer.html index 1426885a565..2615af0b485 100644 --- a/build/doxygen/doxygen_footer.html +++ b/build/doxygen/doxygen_footer.html @@ -5,7 +5,7 @@ File added into doxygen generated documentation - +
@@ -22,31 +22,5 @@ File added into doxygen generated documentation gtag('config', 'UA-9049390-16'); - - - - - - - - - - - - - \ No newline at end of file diff --git a/build/doxygen/doxygen_header.html b/build/doxygen/doxygen_header.html index 5810182050f..235797bb6c9 100644 --- a/build/doxygen/doxygen_header.html +++ b/build/doxygen/doxygen_header.html @@ -12,21 +12,6 @@ - - - - - @@ -48,15 +33,6 @@ src="https://www.facebook.com/tr?id=1998533953704960&ev=PageView&noscript=1"
- - - -
From 1bc07994f6d5af3acc88029b0b88add4467d2961 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 02:53:01 +0200 Subject: [PATCH 05/10] Update doc --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f611f333e6a..fa5326079ec 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,15 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Products and/or Services catalog - Commercial proposals management - Customer & Supplier Orders management +- Invoices and payment management - Shipping management - Warehouse/Stock management -- Invoices and payment management -- Standing orders management (European SEPA) +- Manufacturing Orders - Bank accounts management +- Direct debit orders management (European SEPA) - Accounting management - Shared calendar/agenda (with ical and vcal export for third party tools integration) -- Opportunities and/or project management +- Opportunities or Leads management - Projects & Tasks management - Contracts management - Interventions management From 29ba9c82c3f8bc5a4e9e186dc02b52aff64b969f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 17:17:13 +0200 Subject: [PATCH 06/10] Fix #14120 --- htdocs/comm/action/card.php | 11 ++++------- htdocs/core/class/html.form.class.php | 7 +++++++ htdocs/langs/cs_CZ/admin.lang | 4 ++-- htdocs/langs/cs_CZ/agenda.lang | 1 + htdocs/langs/cs_CZ/main.lang | 22 +++++++++++----------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 716e02ae678..d733cb61ba3 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -815,6 +815,7 @@ if ($action == 'create') } setdatefields(); $("#fullday").change(function() { + console.log("setdatefields"); setdatefields(); }); $("#selectcomplete").change(function() { @@ -869,9 +870,7 @@ if ($action == 'create') if (GETPOST('datep', 'int', 1)) $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 0); print ''.$langs->trans("DateActionStart").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldayend'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart'); // Empty value not allowed for start date and hours if "todo" } else { print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart'); } @@ -886,11 +885,9 @@ if ($action == 'create') } print ''.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); - } elseif (GETPOST("afaire") == 2) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); } print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 447f9569517..587040ac53f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5784,10 +5784,17 @@ class Form } elseif ($addnowlink == 2) { + /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix. + * This break application for foreign languages. $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));'; $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());'; $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);'; $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());'; + */ + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');'; + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');'; } /*if ($usecalendar == "eldy") { diff --git a/htdocs/langs/cs_CZ/admin.lang b/htdocs/langs/cs_CZ/admin.lang index 66e491723a3..e0e91baaff7 100644 --- a/htdocs/langs/cs_CZ/admin.lang +++ b/htdocs/langs/cs_CZ/admin.lang @@ -543,7 +543,7 @@ Module54Desc=Správa smluv (služby nebo opakované předplatné) Module55Name=Čárové kódy Module55Desc=Správa čárových kódů Module56Name=Platba převodem -Module56Desc=Správa plateb prostřednictvím příkazů k úhradě. Zahrnuje vytvoření souboru SEPA pro evropské země. +Module56Desc=Management of payment of suppliers by credit transfer orders. It includes generation of SEPA file for European countries. Module57Name=Bank Direct Debit platby Module57Desc=Správa platebních příkazů inkasních příkazů. Zahrnuje generování souboru SEPA pro evropské země. Module58Name=ClickToDial @@ -1983,7 +1983,7 @@ SmallerThan=Menší než LargerThan=Větší než IfTrackingIDFoundEventWillBeLinked=Všimněte si, že je-li ID ID nalezeno v příchozím e-mailu, bude událost automaticky propojena s příslušnými objekty. WithGMailYouCanCreateADedicatedPassword=Pokud jste s účtem GMail povolili ověření ve 2 - dvou krocích, doporučuje se pro aplikaci vytvořit vyhrazené druhé heslo namísto použití hesla pro vlastní účet z adresy https://myaccount.google.com/. -EmailCollectorTargetDir=Po úspěšném zpracování může být žádoucí chování při přesunu e-mailu do jiné značky / adresáře. Chcete-li tuto funkci použít, nastavte zde hodnotu. Musíte také použít přihlašovací účet pro čtení a zápis. +EmailCollectorTargetDir=It may be a desired behaviour to move the email into another tag/directory when it was processed successfully. Just set name of directory here to use this feature (Do NOT use special characters in name). Note that you must also use a read/write login account. EmailCollectorLoadThirdPartyHelp=Pomocí této akce můžete pomocí obsahu e-mailu najít a načíst existující třetí stranu ve vaší databázi. Nalezená (nebo vytvořená) třetí strana bude použita pro následující akce, které ji potřebují. V poli parametrů můžete použít například 'EXTRACT: BODY: Name: \\ s ([^ \\ s] *)', pokud chcete extrahovat jméno třetí strany z řetězce 'Name: name to find' nalezeného do tělo. EndPointFor=Koncový bod pro %s: %s DeleteEmailCollector=Smazat sběratele e-mailu diff --git a/htdocs/langs/cs_CZ/agenda.lang b/htdocs/langs/cs_CZ/agenda.lang index 0c590afa4ae..62ba1fc0337 100644 --- a/htdocs/langs/cs_CZ/agenda.lang +++ b/htdocs/langs/cs_CZ/agenda.lang @@ -63,6 +63,7 @@ ShipmentClassifyClosedInDolibarr=Zásilka %s klasifikováno účtoval ShipmentUnClassifyCloseddInDolibarr=Zásilka %s byla znovu otevřena ShipmentBackToDraftInDolibarr=Doprava %s se vrátí zpět na stav konceptu ShipmentDeletedInDolibarr=Doprava %s odstraněna +ReceptionValidatedInDolibarr=Reception %s validated OrderCreatedInDolibarr=Objednat %s vytvořil OrderValidatedInDolibarr=Objednávka %s ověřena OrderDeliveredInDolibarr=Objednávka %s označena jako dodaná diff --git a/htdocs/langs/cs_CZ/main.lang b/htdocs/langs/cs_CZ/main.lang index 55be67bde38..880f21e416b 100644 --- a/htdocs/langs/cs_CZ/main.lang +++ b/htdocs/langs/cs_CZ/main.lang @@ -8,21 +8,21 @@ FONTFORPDF=helvetica FONTSIZEFORPDF=10 SeparatorDecimal=, SeparatorThousand=Space -FormatDateShort=%m/%d/%Y -FormatDateShortInput=%m/%d/%Yr -FormatDateShortJava=MM/dd/yyyy -FormatDateShortJavaInput=MM/dd/yyyy -FormatDateShortJQuery=mm/dd/yy -FormatDateShortJQueryInput=mm/dd/yy +FormatDateShort=%d.%m.%Y +FormatDateShortInput=%d.%m.%Y +FormatDateShortJava=dd.MM.yyyy +FormatDateShortJavaInput=dd.MM.yyyy +FormatDateShortJQuery=dd.mm.yy +FormatDateShortJQueryInput=dd.mm.yy FormatHourShortJQuery=HH:MI -FormatHourShort=%I:%M %p +FormatHourShort=%H:%M FormatHourShortDuration=%H:%M FormatDateTextShort=%b %d, %Y FormatDateText=%B %d, %Y -FormatDateHourShort=%m/%d/%Y %I:%M %p -FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p -FormatDateHourTextShort=%b %d, %Y, %I:%M %p -FormatDateHourText=%B %d, %Y, %I:%M %p +FormatDateHourShort=%d.%m.%Y %H.%M +FormatDateHourSecShort=%d.%m.%Y %H.%M.%S +FormatDateHourTextShort=%b %d, %Y, %H.%M +FormatDateHourText=%B %d, %Y, %H.%M DatabaseConnection=Připojení k databázi NoTemplateDefined=Pro tento typ e-mailu není k dispozici žádná šablona AvailableVariables=K dispozici substituční proměnné From d6346522b868aafe5ab8b96b45442d755f9e2e62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 18:56:05 +0200 Subject: [PATCH 07/10] Code comment --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 587040ac53f..9c4e2526249 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5482,7 +5482,7 @@ class Form * @param int $d 1=Show days, month, years * @param int $addnowlink Add a link "Now", 1 with server time, 2 with local computer time * @param int $disabled Disable input fields - * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 + * @param int $fullday When a checkbox with id #fullday is cheked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. * @param datetime $adddateof Add a link "Date of ..." using the following date. See also $labeladddateof for the label used. * @param string $openinghours Specify hour start and hour end for the select ex 8,20 From ee0bdde8c184a36d9b37ff6ad1d4ad7c5dd522ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 19:35:09 +0200 Subject: [PATCH 08/10] FIX Filter on status, closing opening status --- htdocs/core/actions_massactions.inc.php | 2 - htdocs/ticket/card.php | 2 +- htdocs/ticket/class/ticket.class.php | 10 +- htdocs/ticket/list.php | 126 +++++++++++++++++++++--- 4 files changed, 123 insertions(+), 17 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 40e6849d494..77fbea3c36a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1153,8 +1153,6 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) $result = $objecttmp->fetch($toselectid); if ($result > 0) { - //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - //else $result = $objecttmp->validate($user); if ($result == 0) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index b4a82ae660c..076c42867ca 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -491,7 +491,7 @@ if (empty($reshook)) { if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { // prevent browser refresh from reopening ticket several times - if ($object->fk_statut == Ticket::STATUS_CLOSED) { + if ($object->fk_statut == Ticket::STATUS_CLOSED || $object->fk_statut == Ticket::STATUS_CANCELED) { $res = $object->setStatut(Ticket::STATUS_ASSIGNED); if ($res) { // Log action in ticket logs table diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 5dab31b790d..dbd81128d49 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -108,7 +108,8 @@ class Ticket extends CommonObject /** * @var int Ticket statut */ - public $fk_statut; + public $fk_statut; // deprecated + public $status; /** * @var string State resolution @@ -463,7 +464,7 @@ class Ticket extends CommonObject $sql .= " t.fk_user_assign,"; $sql .= " t.subject,"; $sql .= " t.message,"; - $sql .= " t.fk_statut,"; + $sql .= " t.fk_statut as status,"; $sql .= " t.resolution,"; $sql .= " t.progress,"; $sql .= " t.timing,"; @@ -509,7 +510,10 @@ class Ticket extends CommonObject $this->fk_user_assign = $obj->fk_user_assign; $this->subject = $obj->subject; $this->message = $obj->message; - $this->fk_statut = $obj->fk_statut; + + $this->status = $obj->status; + $this->fk_statut = $this->status; // For backward compatibility + $this->resolution = $obj->resolution; $this->progress = $obj->progress; $this->timing = $obj->timing; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 72b398c8281..8d523d88632 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -3,7 +3,7 @@ * Copyright (C) 2016 Christophe Battarel * Copyright (C) 2018 Regis Houssin * Copyright (C) 2019 Juanjo Menent - * Copyright (C) 2019 Laurent Destailleur + * Copyright (C) 2019-2020 Laurent Destailleur * * 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 @@ -38,7 +38,6 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; // Load translation files required by the page $langs->loadLangs(array("ticket", "companies", "other", "projects")); - // Get parameters $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -145,6 +144,12 @@ if ($project_ref) $search_fk_project = $projectid; } +$permissiontoread = $user->rights->ticket->read; +$permissiontoadd = $user->rights->ticket->write; +$permissiontodelete = $user->rights->ticket->delete; + +$error = 0; + /* * Actions @@ -183,10 +188,95 @@ if (empty($reshook)) // Mass actions $objectclass = 'Ticket'; $objectlabel = 'Ticket'; - $permissiontoread = $user->rights->ticket->read; - $permissiontodelete = $user->rights->ticket->delete; $uploaddir = $conf->ticket->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // Close records + if (!$error && $massaction == 'close' && $permissiontoadd) + { + $objecttmp = new $objectclass($db); + if (!$error) + { + $db->begin(); + + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $result = $objecttmp->close($user); + if ($result < 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } + //var_dump($listofobjectthirdparties);exit; + } + } + + // Reopen records + if (!$error && $massaction == 'reopen' && $permissiontoadd) + { + $objecttmp = new $objectclass($db); + if (!$error) + { + $db->begin(); + + $nbok = 0; + foreach ($toselect as $toselectid) + { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) { + $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED); + if ($result < 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } else { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors'); + $error++; + break; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } else { + $db->rollback(); + } + //var_dump($listofobjectthirdparties);exit; + } + } } @@ -236,11 +326,23 @@ foreach ($search as $key => $val) { if ($key == 'fk_statut') { - $tmpstatus = ''; - if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus .= ($tmpstatus ? ',' : '')."'".Ticket::STATUS_NOT_READ."', '".Ticket::STATUS_READ."', '".Ticket::STATUS_ASSIGNED."', '".Ticket::STATUS_IN_PROGRESS."', '".Ticket::STATUS_NEED_MORE_INFO."', '".Ticket::STATUS_WAITING."'"; - if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) $tmpstatus .= ($tmpstatus ? ',' : '')."'".Ticket::STATUS_CLOSED."', '".Ticket::STATUS_CANCELED."'"; - if ($tmpstatus) $sql .= " AND fk_statut IN (".$tmpstatus.")"; - elseif (is_array($search[$key]) && count($search[$key])) $sql .= natural_search($key, join(',', $search[$key]), 2); + $newarrayofstatus = array(); + foreach($search['fk_statut'] as $key2 => $val2) { + if (in_array($val2, array('openall', 'closeall'))) continue; + $newarrayofstatus[] = $val2; + } + if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) { + $newarrayofstatus[] = Ticket::STATUS_NOT_READ; + $newarrayofstatus[] = Ticket::STATUS_ASSIGNED; + $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS; + $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO; + $newarrayofstatus[] = Ticket::STATUS_WAITING; + } + if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) { + $newarrayofstatus[] = Ticket::STATUS_CLOSED; + $newarrayofstatus[] = Ticket::STATUS_CANCELED; + } + if (count($newarrayofstatus)) $sql .= natural_search($key, join(',', $newarrayofstatus), 2); continue; } if ($key == 'fk_user_assign') @@ -452,6 +554,8 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); +if ($user->rights->ticket->write) $arrayofmassactions['close'] = $langs->trans("Close"); +if ($user->rights->ticket->write) $arrayofmassactions['reopen'] = $langs->trans("ReOpen"); if ($user->rights->ticket->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -549,8 +653,8 @@ foreach ($object->fields as $key => $val) $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; foreach ($object->statuts_short as $key2 => $val2) { - $arrayofstatus[$key2] = $val2; - if ($key2 == '6') $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; + if ($key2 == Ticket::STATUS_CLOSED) $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; + $arrayofstatus[$key2] = $val2; } print ''; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); From 6df049e05c95eaf8db10c652f551c1897a60552a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 20:35:06 +0200 Subject: [PATCH 09/10] FIX #14112 --- htdocs/core/class/dolgraph.class.php | 2 +- htdocs/product/index.php | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 551fe2b82c0..0f823984fa2 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1144,7 +1144,7 @@ class DolGraph foreach ($legends as $val) // Loop on each serie { if ($i > 0) $this->stringtoshow .= ', '; - $this->stringtoshow .= "'".$val."'"; + $this->stringtoshow .= "'".dol_trunc($val,32)."'"; $i++; } diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 3067cc63733..6c5d1603168 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -166,17 +166,16 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us $dataseries = array(); if (!empty($conf->product->enabled)) { - $dataseries[] = array($langs->trans("ProductsOnSale"), round($SommeA)); - $dataseries[] = array($langs->trans("ProductsOnPurchase"), round($SommeB)); - $dataseries[] = array($langs->trans("ProductsNotOnSell"), round($SommeC)); + $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnSale"), round($SommeA)); + $dataseries[] = array($langs->transnoentitiesnoconv("ProductsOnPurchase"), round($SommeB)); + $dataseries[] = array($langs->transnoentitiesnoconv("ProductsNotOnSell"), round($SommeC)); } if (!empty($conf->service->enabled)) { - $dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD)); - $dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE)); - $dataseries[] = array(dol_trunc($langs->trans("ServicesNotOnSell"), 24), round($SommeF)); + $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnSale"), round($SommeD)); + $dataseries[] = array($langs->transnoentitiesnoconv("ServicesOnPurchase"), round($SommeE)); + $dataseries[] = array($langs->transnoentitiesnoconv("ServicesNotOnSell"), round($SommeF)); } - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); From 3655f6f407ed504b8e42048a96dd2a8b82c59f35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jun 2020 20:38:41 +0200 Subject: [PATCH 10/10] FIX #14109 --- htdocs/core/class/dolgraph.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 0f823984fa2..141ac1e0e85 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1144,7 +1144,7 @@ class DolGraph foreach ($legends as $val) // Loop on each serie { if ($i > 0) $this->stringtoshow .= ', '; - $this->stringtoshow .= "'".dol_trunc($val,32)."'"; + $this->stringtoshow .= "'".dol_escape_js(dol_trunc($val,32))."'"; $i++; } @@ -1207,7 +1207,7 @@ class DolGraph foreach ($legends as $val) // Loop on each serie { if ($i > 0) $this->stringtoshow .= ', '; - $this->stringtoshow .= "'".$val."'"; + $this->stringtoshow .= "'".dol_escape_js(dol_trunc($val,32))."'"; $i++; }