diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 183ee457c32..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; @@ -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; @@ -5469,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); @@ -5527,30 +5528,37 @@ 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 = $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 +5568,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 +5578,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 */ 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/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/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 '