Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into pr/bb2a/21596

This commit is contained in:
Anthony Berton 2022-11-07 14:33:03 +01:00
commit e8f3c1d6b5
6 changed files with 59 additions and 32 deletions

View File

@ -136,7 +136,7 @@ class Facture extends CommonInvoice
/** /**
* @var int Date expected for delivery * @var int Date expected for delivery
* @deprecated * @deprecated
* @see delivery_date * @see $delivery_date
*/ */
public $date_livraison; public $date_livraison;
@ -148,7 +148,7 @@ class Facture extends CommonInvoice
/** /**
* @var string customer ref * @var string customer ref
* @deprecated * @deprecated
* @see ref_customer * @see $ref_customer
*/ */
public $ref_client; public $ref_client;
@ -5424,9 +5424,10 @@ class Facture extends CommonInvoice
* @param int $nbdays Delay after due date (or before if delay is negative) * @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 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 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) * @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; global $conf, $langs, $user;
@ -5469,11 +5470,11 @@ class Facture extends CommonInvoice
$sql .= " WHERE f.paye = 0"; $sql .= " WHERE f.paye = 0";
$sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED; $sql .= " AND f.fk_statut = ".self::STATUS_VALIDATED;
$sql .= " AND f.date_lim_reglement = '".$this->db->idate($tmpidate, 'gmt')."'"; $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') { if (!empty($paymentmode) && $paymentmode != 'all') {
$sql .= " AND f.fk_mode_reglement = cp.id AND cp.code = '".$this->db->escape($paymentmode)."'"; $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"); $sql .= $this->db->order("date_lim_reglement", "ASC");
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -5527,6 +5528,9 @@ class Facture extends CommonInvoice
// Recipient // Recipient
$to = array(); $to = array();
if ($forcerecipient) { // If a recipient was forced
$to = array($forcerecipient);
} else {
$res = $tmpinvoice->fetch_thirdparty(); $res = $tmpinvoice->fetch_thirdparty();
$recipient = $tmpinvoice->thirdparty; $recipient = $tmpinvoice->thirdparty;
if ($res > 0) { if ($res > 0) {
@ -5548,9 +5552,13 @@ class Facture extends CommonInvoice
$errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid; $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid;
$error++; $error++;
} }
}
// Sender // 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)) { if (empty($from)) {
$errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM"; $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
$error++; $error++;
@ -5560,6 +5568,9 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
$to = implode(',', $to); $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 Recipient
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO; $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
@ -5567,8 +5578,18 @@ class Facture extends CommonInvoice
$trackid = 'inv'.$tmpinvoice->id; $trackid = 'inv'.$tmpinvoice->id;
$sendcontext = 'standard'; $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 // 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 // Sending Mail
if ($cMailFile->sendfile()) { if ($cMailFile->sendfile()) {

View File

@ -1305,9 +1305,9 @@ class FormMail extends Form
$languagetosearchmain = ''; $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 .= " 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 entity IN (".getEntity('c_email_templates').")";
$sql .= " AND (private = 0 OR fk_user = ".((int) $user->id).")"; // Get all public or private owned $sql .= " AND (private = 0 OR fk_user = ".((int) $user->id).")"; // Get all public or private owned
if ($active >= 0) { if ($active >= 0) {
@ -1728,6 +1728,11 @@ class ModelMail
public $lang; public $lang;
public $joinfiles; public $joinfiles;
public $email_from;
public $email_to;
public $email_tocc;
public $email_tobcc;
/** /**
* @var string Module the template is dedicated for * @var string Module the template is dedicated for
*/ */

View File

@ -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. 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. CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced.
CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates. 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 ##### ##### Bookmark #####
BookmarkSetup=Bookmark module setup 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. 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.

View File

@ -271,7 +271,7 @@ InventoryStartedShort=Started
ErrorOnElementsInventory=Operation canceled for the following reason: ErrorOnElementsInventory=Operation canceled for the following reason:
ErrorCantFindCodeInInventory=Can't find the following code in inventory 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. 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 NoWarehouseDefinedForTerminal=No warehouse defined for terminal
ClearQtys=Clear all quantities ClearQtys=Clear all quantities
ModuleStockTransferName=Advanced Stock Transfer ModuleStockTransferName=Advanced Stock Transfer

View File

@ -338,7 +338,7 @@ if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlob
print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>'; print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
print '<td>'; print '<td>';
print '<input type="text" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />'; print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
print '</td></tr>'; print '</td></tr>';
// Numbering module // Numbering module

View File

@ -1586,7 +1586,8 @@ if ($placeid > 0) {
$moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva); $moreinfo .= '<br>'.$langs->transcountry("TotalVAT", $mysoc->country_code).': '.price($line->total_tva);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1); $moreinfo .= '<br>'.$langs->transcountry("TotalLT1", $mysoc->country_code).': '.price($line->total_localtax1);
$moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); $moreinfo .= '<br>'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2);
$moreinfo .= '<br>'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); $moreinfo .= '<hr>';
$moreinfo .= $langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc);
//$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht;
if ($line->date_start || $line->date_end) { if ($line->date_start || $line->date_end) {
$htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>'; $htmlforlines .= '<br><div class="clearboth nowraponall">'.get_date_range($line->date_start, $line->date_end).'</div>';