From 23916b37d3bc05b52739a2f2f8a2af0857ea1e2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Nov 2022 10:07:25 +0100 Subject: [PATCH 1/5] CSS --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/takepos/admin/terminal.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e963f8206be..a541df8e597 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1843,7 +1843,7 @@ StockDecreaseForPointOfSaleDisabledbyBatch=Stock decrease in POS is not compatib CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sale from Point of Sale. Hence a warehouse is required. CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced. CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates. -CashDeskReaderKeyCodeForEnter=Key code for "Enter" defined in barcode reader (Example: 13) +CashDeskReaderKeyCodeForEnter=Key ASCII code for "Enter" defined in barcode reader (Example: 13) ##### Bookmark ##### BookmarkSetup=Bookmark module setup BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu. diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index c511d3e0529..fe03139c8a3 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -338,7 +338,7 @@ if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlob print ''.$langs->trans('CashDeskReaderKeyCodeForEnter').''; print ''; -print ''; +print ''; print ''; // Numbering module From 506a9de384fc2e545a271d9bd6d12d31d911337b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Nov 2022 11:28:08 +0100 Subject: [PATCH 2/5] Trans --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/takepos/invoice.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 5332b8123e0..b575e7fcd4b 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -271,7 +271,7 @@ InventoryStartedShort=Started ErrorOnElementsInventory=Operation canceled for the following reason: ErrorCantFindCodeInInventory=Can't find the following code in inventory QtyWasAddedToTheScannedBarcode=Success !! The quantity was added to all the requested barcode. You can close the Scanner tool. -StockChangeDisabled=Change on stock disabled +StockChangeDisabled=Stock change disabled NoWarehouseDefinedForTerminal=No warehouse defined for terminal ClearQtys=Clear all quantities ModuleStockTransferName=Advanced Stock Transfer diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 83caf667db4..d1f99fc4ab0 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1586,7 +1586,8 @@ if ($placeid > 0) { $moreinfo .= '
'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva); $moreinfo .= '
'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1); $moreinfo .= '
'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); - $moreinfo .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); + $moreinfo .= '
'; + $moreinfo .= $langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; if ($line->date_start || $line->date_end) { $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end).'
'; From 055627e248a713de787e57c278473200b238c4eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Nov 2022 14:16:04 +0100 Subject: [PATCH 3/5] NEW scheduled job to send unpaid invoice reminder can use the cc and bcc of template. --- htdocs/compta/facture/class/facture.class.php | 20 +++++++++++++++++-- htdocs/core/class/html.formmail.class.php | 9 +++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 183ee457c32..1e770ccd08b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5550,7 +5550,10 @@ class Facture extends CommonInvoice } // Sender - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; + $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); + if (!empty($arraymessage->email_from)) { // If a sender is defined into template, we use it in priority + $from = $arraymessage->email_from; + } if (empty($from)) { $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; $error++; @@ -5560,6 +5563,9 @@ class Facture extends CommonInvoice $this->db->begin(); $to = implode(',', $to); + if (!empty($arraymessage->email_to)) { // If a recipient is defined into template, we add it + $to = $to.','.$arraymessage->email_to; + } // Errors Recipient $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; @@ -5567,8 +5573,18 @@ class Facture extends CommonInvoice $trackid = 'inv'.$tmpinvoice->id; $sendcontext = 'standard'; + $email_tocc = ''; + if (!empty($arraymessage->email_tocc)) { // If a CC is defined into template, we use it + $email_tocc = $arraymessage->email_tocc; + } + + $email_tobcc = ''; + if (!empty($arraymessage->email_tobcc)) { // If a BCC is defined into template, we use it + $email_tobcc = $arraymessage->email_tobcc; + } + // Mail Creation - $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', $sendcontext, ''); + $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), $email_tocc, $email_tobcc, 0, 1, $errors_to, '', $trackid, '', $sendcontext, ''); // Sending Mail if ($cMailFile->sendfile()) { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 41cf2482f9a..aa2ee4b3e6a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1305,9 +1305,9 @@ class FormMail extends Form $languagetosearchmain = ''; } - $sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang"; + $sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang, email_from, email_to, email_tocc, email_tobcc"; $sql .= " FROM ".$dbs->prefix().'c_email_templates'; - $sql .= " WHERE (type_template='".$dbs->escape($type_template)."' OR type_template='all')"; + $sql .= " WHERE (type_template = '".$dbs->escape($type_template)."' OR type_template = 'all')"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; $sql .= " AND (private = 0 OR fk_user = ".((int) $user->id).")"; // Get all public or private owned if ($active >= 0) { @@ -1728,6 +1728,11 @@ class ModelMail public $lang; public $joinfiles; + public $email_from; + public $email_to; + public $email_tocc; + public $email_tobcc; + /** * @var string Module the template is dedicated for */ From 7fae4d1b1c54c007406dc6d286f0e96f41e893fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Nov 2022 14:22:43 +0100 Subject: [PATCH 4/5] Can force recipient of unpaid invoice email reminder --- htdocs/compta/facture/class/facture.class.php | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1e770ccd08b..dd3c82a8578 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5421,12 +5421,13 @@ class Facture extends CommonInvoice * Send reminders by emails for ivoices that are due * CAN BE A CRON TASK * - * @param int $nbdays Delay after due date (or before if delay is negative) - * @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ... - * @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send') - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @param int $nbdays Delay after due date (or before if delay is negative) + * @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ... + * @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send') + * @param string $forcerecipient Force email of recipient (for example to send the email to an accountant supervisor instead of the customer) + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode = 'all', $template = '') + public function sendEmailsRemindersOnInvoiceDueDate($nbdays = 0, $paymentmode = 'all', $template = '', $forcerecipient = '') { global $conf, $langs, $user; @@ -5527,26 +5528,30 @@ class Facture extends CommonInvoice // Recipient $to = array(); - $res = $tmpinvoice->fetch_thirdparty(); - $recipient = $tmpinvoice->thirdparty; - if ($res > 0) { - $tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING'); - if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { - foreach ($tmparraycontact as $data_email) { - if (!empty($data_email['email'])) { - $to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email'); + if ($forcerecipient) { // If a recipient was forced + $to = array($forcerecipient); + } else { + $res = $tmpinvoice->fetch_thirdparty(); + $recipient = $tmpinvoice->thirdparty; + if ($res > 0) { + $tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING'); + if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { + foreach ($tmparraycontact as $data_email) { + if (!empty($data_email['email'])) { + $to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email'); + } } } - } - if (empty($to) && !empty($recipient->email)) { - $to[] = $recipient->email; + if (empty($to) && !empty($recipient->email)) { + $to[] = $recipient->email; + } else { + $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user."; + $error++; + } } else { - $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user."; + $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid; $error++; } - } else { - $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid; - $error++; } // Sender From 55c284ebb99012abd88f57f67441bd7b2391829f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Nov 2022 14:28:42 +0100 Subject: [PATCH 5/5] Fix filter on entity --- htdocs/compta/facture/class/facture.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index dd3c82a8578..4a4a02e87c4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -136,7 +136,7 @@ class Facture extends CommonInvoice /** * @var int Date expected for delivery * @deprecated - * @see delivery_date + * @see $delivery_date */ public $date_livraison; @@ -148,7 +148,7 @@ class Facture extends CommonInvoice /** * @var string customer ref * @deprecated - * @see ref_customer + * @see $ref_customer */ public $ref_client; @@ -5470,11 +5470,11 @@ class Facture extends CommonInvoice $sql .= " WHERE f.paye = 0"; $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; $sql .= " AND f.date_lim_reglement = '".$this->db->idate($tmpidate, 'gmt')."'"; - $sql .= " AND f.entity IN (".getEntity('facture').")"; + $sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // One batch process only one company (no sharing) if (!empty($paymentmode) && $paymentmode != 'all') { $sql .= " AND f.fk_mode_reglement = cp.id AND cp.code = '".$this->db->escape($paymentmode)."'"; } - // TODO Add filter to check there is no payment started + // TODO Add a filter to check there is no payment started yet $sql .= $this->db->order("date_lim_reglement", "ASC"); $resql = $this->db->query($sql);