Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
a93227ac2f
@ -57,7 +57,6 @@ NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT
|
||||
NEW: add option to define a default warehouse at user level
|
||||
NEW: add option to include products without alert in replenish
|
||||
NEW: add order by lastname and firstname by default in get sales representatives
|
||||
NEW: add param to not show links when output tags
|
||||
NEW: add PDF document templates for warehouses (list of stock)
|
||||
NEW: add a prospect status for the contact with managment of custom icon
|
||||
NEW: add public note on products ; this also partially fix the #14342
|
||||
@ -80,7 +79,7 @@ NEW: appearance tab in TakePOS with more visual parameters
|
||||
NEW: better currency rate editor
|
||||
NEW: can build vendor invoice from vendor orders
|
||||
NEW: can change a product in lines of a recurring invoice or contract
|
||||
NEW: can change size of logo on PDF documents
|
||||
NEW: can set the size of the logo on PDF documents
|
||||
NEW: can change VAT rate of all lines of a draft object in one step
|
||||
NEW: can define date range of validity of a login during creation
|
||||
NEW: can disable, from edit page, the whole web site
|
||||
@ -189,7 +188,7 @@ NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
|
||||
NEW: Add some fields to link website page to an other object
|
||||
NEW: fill ECM src object fields in dol_add_file_process
|
||||
NEW: conf to allow to show the full tree in warehouse popup
|
||||
NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: can use parameter ?THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: can force the antivirus from conf file or autoprepend ini setup
|
||||
NEW: can add event to log into blockedlog module with a constant
|
||||
NEW: add property cssview when declaring fields of an object
|
||||
@ -208,6 +207,7 @@ NEW: add a message in error_log after detection of SQL or script injection
|
||||
NEW: add validation of MX domain for emails
|
||||
NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') )
|
||||
NEW: Graphics can be horizontal bars
|
||||
NEW: add param to not show links when output tags
|
||||
|
||||
APIs
|
||||
NEW: API get contacts list of a given order
|
||||
|
||||
@ -493,9 +493,10 @@ class Account extends CommonObject
|
||||
* @param string $banque Bank of cheque writer
|
||||
* @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
|
||||
* @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)
|
||||
public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null, $num_releve = '')
|
||||
{
|
||||
// Deprecation warning
|
||||
if (is_numeric($oper)) {
|
||||
@ -555,6 +556,7 @@ class Account extends CommonObject
|
||||
$accline->fk_account = $this->rowid;
|
||||
$accline->fk_type = $oper;
|
||||
$accline->numero_compte = $accountancycode;
|
||||
$accline->num_releve = $num_releve;
|
||||
|
||||
if ($num_chq) {
|
||||
$accline->num_chq = $num_chq;
|
||||
@ -1886,6 +1888,7 @@ class AccountLine extends CommonObject
|
||||
$sql .= ", emetteur,banque";
|
||||
$sql .= ", rappro";
|
||||
$sql .= ", numero_compte";
|
||||
$sql .= ", num_releve";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= "'".$this->db->idate($this->datec)."'";
|
||||
$sql .= ", '".$this->db->idate($this->dateo)."'";
|
||||
@ -1900,6 +1903,7 @@ class AccountLine extends CommonObject
|
||||
$sql .= ", ".($this->bank_chq ? "'".$this->db->escape($this->bank_chq)."'" : "null");
|
||||
$sql .= ", ".(int) $this->rappro;
|
||||
$sql .= ", ".($this->numero_compte ? "'".$this->db->escape($this->numero_compte)."'" : "''");
|
||||
$sql .= ", ".($this->num_releve ? "'".$this->db->escape($this->num_releve)."'" : "null");
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
||||
|
||||
@ -466,20 +466,23 @@ class BankAccounts extends DolibarrApi
|
||||
/**
|
||||
* Add a line to an account
|
||||
*
|
||||
* @param int $id ID of account
|
||||
* @param int $date Payment date (timestamp) {@from body} {@type timestamp}
|
||||
* @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body}
|
||||
* @param string $label Label {@from body}
|
||||
* @param float $amount Amount (may be 0) {@from body}
|
||||
* @param int $category Category
|
||||
* @param string $cheque_number Cheque numberl {@from body}
|
||||
* @param string $cheque_writer Name of cheque writer {@from body}
|
||||
* @param string $cheque_bank Bank of cheque writer {@from body}
|
||||
* @param int $id ID of account
|
||||
* @param int $date Payment date (timestamp) {@from body} {@type timestamp}
|
||||
* @param string $type Payment mode (TYP,VIR,PRE,LIQ,VAD,CB,CHQ...) {@from body}
|
||||
* @param string $label Label {@from body}
|
||||
* @param float $amount Amount (may be 0) {@from body}
|
||||
* @param int $category Category
|
||||
* @param string $cheque_number Cheque numero {@from body}
|
||||
* @param string $cheque_writer Name of cheque writer {@from body}
|
||||
* @param string $cheque_bank Bank of cheque writer {@from body}
|
||||
* @param string $accountancycode Accountancy code {@from body}
|
||||
* @param int $datev Payment date value (timestamp) {@from body} {@type timestamp}
|
||||
* @param string $num_releve Bank statement numero {@from body}
|
||||
* @return int ID of line
|
||||
*
|
||||
* @url POST {id}/lines
|
||||
*/
|
||||
public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '')
|
||||
public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '', $accountancycode = '', $datev = null, $num_releve = '')
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->banque->modifier) {
|
||||
throw new RestException(401);
|
||||
@ -499,7 +502,8 @@ class BankAccounts extends DolibarrApi
|
||||
$cheque_number,
|
||||
$category,
|
||||
DolibarrApiAccess::$user,
|
||||
$cheque_writer, $cheque_bank
|
||||
$cheque_writer, $cheque_bank, $accountancycode,
|
||||
$datev, $num_releve
|
||||
);
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when adding line to account: '.$account->error);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@ -950,15 +950,14 @@ class CMailFile
|
||||
* Read a file on disk and return encoded content for emails (mode = 'mail')
|
||||
*
|
||||
* @param string $sourcefile Path to file to encode
|
||||
* @return int <0 if KO, encoded string if OK
|
||||
* @return int|string <0 if KO, encoded string if OK
|
||||
*/
|
||||
private function _encode_file($sourcefile)
|
||||
{
|
||||
// phpcs:enable
|
||||
$newsourcefile = dol_osencode($sourcefile);
|
||||
|
||||
if (is_readable($newsourcefile))
|
||||
{
|
||||
if (is_readable($newsourcefile)) {
|
||||
$contents = file_get_contents($newsourcefile); // Need PHP 4.3
|
||||
$encoded = chunk_split(base64_encode($contents), 76, $this->eol); // 76 max is defined into http://tools.ietf.org/html/rfc2047
|
||||
return $encoded;
|
||||
@ -983,27 +982,24 @@ class CMailFile
|
||||
// phpcs:enable
|
||||
global $conf, $dolibarr_main_data_root;
|
||||
|
||||
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
|
||||
{
|
||||
if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir
|
||||
$outputfile = $dolibarr_main_data_root."/dolibarr_mail.log";
|
||||
$fp = fopen($outputfile, "w");
|
||||
|
||||
if ($this->sendmode == 'mail')
|
||||
{
|
||||
if ($this->sendmode == 'mail') {
|
||||
fputs($fp, $this->headers);
|
||||
fputs($fp, $this->eol); // This eol is added by the mail function, so we add it in log
|
||||
fputs($fp, $this->message);
|
||||
} elseif ($this->sendmode == 'smtps')
|
||||
{
|
||||
} elseif ($this->sendmode == 'smtps') {
|
||||
fputs($fp, $this->smtps->log); // this->smtps->log is filled only if MAIN_MAIL_DEBUG was set to on
|
||||
} elseif ($this->sendmode == 'swiftmailer')
|
||||
{
|
||||
} elseif ($this->sendmode == 'swiftmailer') {
|
||||
fputs($fp, $this->logger->dump()); // this->logger is filled only if MAIN_MAIL_DEBUG was set to on
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,8 +1012,7 @@ class CMailFile
|
||||
*/
|
||||
public function checkIfHTML($msg)
|
||||
{
|
||||
if (!preg_match('/^[\s\t]*<html/i', $msg))
|
||||
{
|
||||
if (!preg_match('/^[\s\t]*<html/i', $msg)) {
|
||||
$out = "<html><head><title></title>";
|
||||
if (!empty($this->styleCSS)) $out .= $this->styleCSS;
|
||||
$out .= "</head><body";
|
||||
@ -1039,19 +1034,16 @@ class CMailFile
|
||||
*/
|
||||
public function buildCSS()
|
||||
{
|
||||
if (!empty($this->css))
|
||||
{
|
||||
if (!empty($this->css)) {
|
||||
// Style CSS
|
||||
$this->styleCSS = '<style type="text/css">';
|
||||
$this->styleCSS .= 'body {';
|
||||
|
||||
if ($this->css['bgcolor'])
|
||||
{
|
||||
if ($this->css['bgcolor']) {
|
||||
$this->styleCSS .= ' background-color: '.$this->css['bgcolor'].';';
|
||||
$this->bodyCSS .= ' bgcolor="'.$this->css['bgcolor'].'"';
|
||||
}
|
||||
if ($this->css['bgimage'])
|
||||
{
|
||||
if ($this->css['bgimage']) {
|
||||
// TODO recuperer cid
|
||||
$this->styleCSS .= ' background-image: url("cid:'.$this->css['bgimage_cid'].'");';
|
||||
}
|
||||
|
||||
@ -116,7 +116,12 @@ class FormMail extends Form
|
||||
*/
|
||||
public $withto; // Show recipient emails
|
||||
|
||||
public $withtofree; // Show free text for recipient emails
|
||||
/**
|
||||
* @var int|string 0 = Do not Show free text for recipient emails
|
||||
* 1 = Show free text for recipient emails
|
||||
* or a free email
|
||||
*/
|
||||
public $withtofree;
|
||||
public $withtocc;
|
||||
public $withtoccc;
|
||||
public $withtopic;
|
||||
@ -354,14 +359,15 @@ class FormMail extends Form
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile = new Formfile($this->db);
|
||||
|
||||
if (!is_object($form)) $form = new Form($this->db);
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($this->db);
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('other', 'mails'));
|
||||
|
||||
// Clear temp files. Must be done at beginning, before call of triggers
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
|
||||
{
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
|
||||
$this->clear_attached_files();
|
||||
}
|
||||
|
||||
@ -375,8 +381,7 @@ class FormMail extends Form
|
||||
);
|
||||
$reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this);
|
||||
|
||||
if (!empty($reshook))
|
||||
{
|
||||
if (!empty($reshook)) {
|
||||
return $hookmanager->resPrint;
|
||||
} else {
|
||||
$out = '';
|
||||
@ -387,8 +392,7 @@ class FormMail extends Form
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
|
||||
if (!empty($newlang))
|
||||
{
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('other');
|
||||
@ -396,11 +400,9 @@ class FormMail extends Form
|
||||
|
||||
// Get message template for $this->param["models"] into c_email_templates
|
||||
$arraydefaultmessage = -1;
|
||||
if ($this->param['models'] != 'none')
|
||||
{
|
||||
if ($this->param['models'] != 'none') {
|
||||
$model_id = 0;
|
||||
if (array_key_exists('models_id', $this->param))
|
||||
{
|
||||
if (array_key_exists('models_id', $this->param)) {
|
||||
$model_id = $this->param["models_id"];
|
||||
}
|
||||
|
||||
@ -413,25 +415,27 @@ class FormMail extends Form
|
||||
$listofmimes = array();
|
||||
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
|
||||
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
|
||||
{
|
||||
if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
|
||||
{
|
||||
foreach ($this->param['fileinit'] as $file)
|
||||
{
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
|
||||
if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) {
|
||||
foreach ($this->param['fileinit'] as $file) {
|
||||
$this->add_attached_files($file, basename($file), dol_mimetype($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
}
|
||||
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
|
||||
|
||||
$out .= "\n".'<!-- Begin form mail type='.$this->param["models"].' --><div id="mailformdiv"></div>'."\n";
|
||||
if ($this->withform == 1)
|
||||
{
|
||||
if ($this->withform == 1) {
|
||||
$out .= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n";
|
||||
|
||||
$out .= '<a id="formmail" name="formmail"></a>';
|
||||
@ -439,16 +443,13 @@ class FormMail extends Form
|
||||
$out .= '<input type="hidden" name="token" value="'.newToken().'" />';
|
||||
$out .= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />';
|
||||
}
|
||||
if (!empty($this->withfrom))
|
||||
{
|
||||
if (!empty($this->withfromreadonly))
|
||||
{
|
||||
if (!empty($this->withfrom)) {
|
||||
if (!empty($this->withfromreadonly)) {
|
||||
$out .= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
|
||||
$out .= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
|
||||
}
|
||||
}
|
||||
foreach ($this->param as $key=>$value)
|
||||
{
|
||||
foreach ($this->param as $key=>$value) {
|
||||
if (is_array($value)) {
|
||||
$out .= "<!-- param key=".$key." is array, we do not output input filed for it -->\n";
|
||||
} else {
|
||||
@ -457,17 +458,14 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
$modelmail_array = array();
|
||||
if ($this->param['models'] != 'none')
|
||||
{
|
||||
if ($this->param['models'] != 'none') {
|
||||
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($this->error, $this->errors, 'errors');
|
||||
}
|
||||
$langs->trans("members");
|
||||
foreach ($this->lines_model as $line)
|
||||
{
|
||||
foreach ($this->lines_model as $line) {
|
||||
$reg = array();
|
||||
if (preg_match('/\((.*)\)/', $line->label, $reg)) {
|
||||
$labeltouse = $langs->trans($reg[1]); // langs->trans when label is __(xxx)__
|
||||
@ -483,8 +481,7 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// Zone to select email template
|
||||
if (count($modelmail_array) > 0)
|
||||
{
|
||||
if (count($modelmail_array) > 0) {
|
||||
// If list of template is filled
|
||||
$out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
|
||||
$out .= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> ';
|
||||
@ -498,8 +495,7 @@ class FormMail extends Form
|
||||
'propal_send', 'order_send', 'facture_send',
|
||||
'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send',
|
||||
'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all'
|
||||
)))
|
||||
{
|
||||
))) {
|
||||
// If list of template is empty
|
||||
$out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
|
||||
$out .= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy.
|
||||
@ -518,12 +514,10 @@ class FormMail extends Form
|
||||
// Substitution array/string
|
||||
$helpforsubstitution = '';
|
||||
if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :<br>'."\n";
|
||||
foreach ($this->substit as $key => $val)
|
||||
{
|
||||
foreach ($this->substit as $key => $val) {
|
||||
$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'<br>';
|
||||
}
|
||||
if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this.
|
||||
{
|
||||
if (!empty($this->withsubstit)) { // Unset or set ->withsubstit=0 to disable this.
|
||||
$out .= '<tr><td colspan="2" class="right">';
|
||||
//$out.='<div class="floatright">';
|
||||
if (is_numeric($this->withsubstit)) $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage
|
||||
@ -538,10 +532,8 @@ class FormMail extends Form
|
||||
var_dump($this->fromname);*/
|
||||
|
||||
// From
|
||||
if (!empty($this->withfrom))
|
||||
{
|
||||
if (!empty($this->withfromreadonly))
|
||||
{
|
||||
if (!empty($this->withfrom)) {
|
||||
if (!empty($this->withfromreadonly)) {
|
||||
$out .= '<tr><td class="fieldrequired minwidth200">'.$langs->trans("MailFrom").'</td><td>';
|
||||
|
||||
// $this->fromtype is the default value to use to select sender
|
||||
@ -551,16 +543,13 @@ class FormMail extends Form
|
||||
&& !preg_match('/user_aliases/', $this->fromtype)
|
||||
&& !preg_match('/global_aliases/', $this->fromtype)
|
||||
&& !preg_match('/senderprofile/', $this->fromtype)
|
||||
)
|
||||
{
|
||||
) {
|
||||
// Use this->fromname and this->frommail or error if not defined
|
||||
$out .= $this->fromname;
|
||||
if ($this->frommail)
|
||||
{
|
||||
if ($this->frommail) {
|
||||
$out .= ' <'.$this->frommail.'>';
|
||||
} else {
|
||||
if ($this->fromtype)
|
||||
{
|
||||
if ($this->fromtype) {
|
||||
$langs->load('errors');
|
||||
$out .= '<span class="warning"> <'.$langs->trans('ErrorNoMailDefinedForThisUser').'> </span>';
|
||||
}
|
||||
@ -569,8 +558,7 @@ class FormMail extends Form
|
||||
$liste = array();
|
||||
|
||||
// Add user email
|
||||
if (empty($user->email))
|
||||
{
|
||||
if (empty($user->email)) {
|
||||
$langs->load('errors');
|
||||
$liste['user'] = $user->getFullName($langs).' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>';
|
||||
} else {
|
||||
@ -584,13 +572,10 @@ class FormMail extends Form
|
||||
$listaliases = array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
|
||||
|
||||
// Also add robot email
|
||||
if (!empty($this->fromalsorobot))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL)
|
||||
{
|
||||
if (!empty($this->fromalsorobot)) {
|
||||
if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) {
|
||||
$liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM;
|
||||
if ($this->frommail)
|
||||
{
|
||||
if ($this->frommail) {
|
||||
$liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
|
||||
}
|
||||
}
|
||||
@ -601,31 +586,27 @@ class FormMail extends Form
|
||||
$sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
|
||||
$sql .= ' ORDER BY position';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$listaliases['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
foreach ($listaliases as $typealias => $listalias)
|
||||
{
|
||||
foreach ($listaliases as $typealias => $listalias) {
|
||||
$posalias = 0;
|
||||
$listaliasarray = explode(',', $listalias);
|
||||
foreach ($listaliasarray as $listaliasval)
|
||||
{
|
||||
foreach ($listaliasarray as $listaliasval) {
|
||||
$posalias++;
|
||||
$listaliasval = trim($listaliasval);
|
||||
if ($listaliasval)
|
||||
{
|
||||
if ($listaliasval) {
|
||||
$listaliasval = preg_replace('/</', '<', $listaliasval);
|
||||
$listaliasval = preg_replace('/>/', '>', $listaliasval);
|
||||
if (!preg_match('/</', $listaliasval)) $listaliasval = '<'.$listaliasval.'>';
|
||||
@ -637,8 +618,7 @@ class FormMail extends Form
|
||||
// Set the default "From"
|
||||
$defaultfrom = '';
|
||||
$reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this);
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$defaultfrom = $this->fromtype;
|
||||
}
|
||||
if (!empty($hookmanager->resArray['defaultfrom'])) $defaultfrom = $hookmanager->resArray['defaultfrom'];
|
||||
@ -665,19 +645,15 @@ class FormMail extends Form
|
||||
if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
|
||||
else $out .= $langs->trans("MailTo");
|
||||
$out .= '</td><td>';
|
||||
if ($this->withtoreadonly)
|
||||
{
|
||||
if (!empty($this->toname) && !empty($this->tomail))
|
||||
{
|
||||
if ($this->withtoreadonly) {
|
||||
if (!empty($this->toname) && !empty($this->tomail)) {
|
||||
$out .= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />';
|
||||
$out .= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />';
|
||||
if ($this->totype == 'thirdparty')
|
||||
{
|
||||
if ($this->totype == 'thirdparty') {
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->toid);
|
||||
$out .= $soc->getNomUrl(1);
|
||||
} elseif ($this->totype == 'contact')
|
||||
{
|
||||
} elseif ($this->totype == 'contact') {
|
||||
$contact = new Contact($this->db);
|
||||
$contact->fetch($this->toid);
|
||||
$out .= $contact->getNomUrl(1);
|
||||
@ -685,8 +661,7 @@ class FormMail extends Form
|
||||
$out .= $this->toname;
|
||||
}
|
||||
$out .= ' <'.$this->tomail.'>';
|
||||
if ($this->withtofree)
|
||||
{
|
||||
if ($this->withtofree) {
|
||||
$out .= '<br>'.$langs->trans("and").' <input class="minwidth200" id="sendto" name="sendto" value="'.(!is_array($this->withto) && !is_numeric($this->withto) ? (GETPOSTISSET("sendto") ? GETPOST("sendto") : $this->withto) : "").'" />';
|
||||
}
|
||||
} else {
|
||||
@ -695,25 +670,21 @@ class FormMail extends Form
|
||||
}
|
||||
} else {
|
||||
// The free input of email
|
||||
if (!empty($this->withtofree))
|
||||
{
|
||||
if (!empty($this->withtofree)) {
|
||||
$out .= '<input class="minwidth200" id="sendto" name="sendto" value="'.(($this->withtofree && !is_numeric($this->withtofree)) ? $this->withtofree : (!is_array($this->withto) && !is_numeric($this->withto) ? (GETPOSTISSET("sendto") ? GETPOST("sendto") : $this->withto) : "")).'" />';
|
||||
}
|
||||
// The select combo
|
||||
if (!empty($this->withto) && is_array($this->withto))
|
||||
{
|
||||
if (!empty($this->withto) && is_array($this->withto)) {
|
||||
if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withto;
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
foreach ($tmparray as $key => $val) {
|
||||
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
|
||||
$withtoselected = GETPOST("receiver", 'array'); // Array of selected value
|
||||
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
|
||||
{
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
|
||||
$withtoselected = array_keys($tmparray);
|
||||
}
|
||||
$out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
|
||||
@ -723,21 +694,18 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// To User
|
||||
if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
|
||||
{
|
||||
if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
|
||||
$out .= '<tr><td>';
|
||||
$out .= $langs->trans("MailToUsers");
|
||||
$out .= '</td><td>';
|
||||
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withtouser;
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
foreach ($tmparray as $key => $val) {
|
||||
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$withtoselected = GETPOST("receiveruser", 'array'); // Array of selected value
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
|
||||
{
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
|
||||
$withtoselected = array_keys($tmparray);
|
||||
}
|
||||
$out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
|
||||
@ -745,8 +713,7 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// With option one email per recipient
|
||||
if (!empty($this->withoptiononeemailperrecipient))
|
||||
{
|
||||
if (!empty($this->withoptiononeemailperrecipient)) {
|
||||
$out .= '<tr><td class="minwidth200">';
|
||||
$out .= $langs->trans("GroupEmails");
|
||||
$out .= '</td><td>';
|
||||
@ -760,23 +727,19 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// CC
|
||||
if (!empty($this->withtocc) || is_array($this->withtocc))
|
||||
{
|
||||
if (!empty($this->withtocc) || is_array($this->withtocc)) {
|
||||
$out .= '<tr><td>';
|
||||
$out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
|
||||
$out .= '</td><td>';
|
||||
if ($this->withtoccreadonly)
|
||||
{
|
||||
if ($this->withtoccreadonly) {
|
||||
$out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
|
||||
} else {
|
||||
$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
|
||||
if (!empty($this->withtocc) && is_array($this->withtocc))
|
||||
{
|
||||
if (!empty($this->withtocc) && is_array($this->withtocc)) {
|
||||
$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withtocc;
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
foreach ($tmparray as $key => $val) {
|
||||
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value
|
||||
@ -787,21 +750,18 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// To User cc
|
||||
if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
|
||||
{
|
||||
if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
|
||||
$out .= '<tr><td>';
|
||||
$out .= $langs->trans("MailToCCUsers");
|
||||
$out .= '</td><td>';
|
||||
|
||||
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
|
||||
$tmparray = $this->withtoccuser;
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
foreach ($tmparray as $key => $val) {
|
||||
$tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
|
||||
}
|
||||
$withtoselected = GETPOST("receiverccuser", 'array'); // Array of selected value
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend')
|
||||
{
|
||||
if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') {
|
||||
$withtoselected = array_keys($tmparray);
|
||||
}
|
||||
$out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, "");
|
||||
@ -814,10 +774,8 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// Replyto
|
||||
if (!empty($this->withreplyto))
|
||||
{
|
||||
if ($this->withreplytoreadonly)
|
||||
{
|
||||
if (!empty($this->withreplyto)) {
|
||||
if ($this->withreplytoreadonly) {
|
||||
$out .= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
|
||||
$out .= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
|
||||
$out .= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail ? (" <".$this->replytomail.">") : "");
|
||||
@ -841,41 +799,32 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// Attached files
|
||||
if (!empty($this->withfile))
|
||||
{
|
||||
if (!empty($this->withfile)) {
|
||||
$out .= '<tr>';
|
||||
$out .= '<td>'.$langs->trans("MailFile").'</td>';
|
||||
|
||||
$out .= '<td>';
|
||||
|
||||
if ($this->withmaindocfile) // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked)
|
||||
{
|
||||
if (GETPOSTISSET('sendmail'))
|
||||
{
|
||||
if ($this->withmaindocfile) { // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked)
|
||||
if (GETPOSTISSET('sendmail')) {
|
||||
$this->withmaindocfile = (GETPOST('addmaindocfile', 'alpha') ? -1 : 1);
|
||||
}
|
||||
// If a template was selected, we use setup of template to define if join file checkbox is selected or not.
|
||||
elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
|
||||
{
|
||||
} elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||
// If a template was selected, we use setup of template to define if join file checkbox is selected or not.
|
||||
$this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->withmaindocfile))
|
||||
{
|
||||
if ($this->withmaindocfile == 1)
|
||||
{
|
||||
if (!empty($this->withmaindocfile)) {
|
||||
if ($this->withmaindocfile == 1) {
|
||||
$out .= '<input type="checkbox" name="addmaindocfile" value="1" />';
|
||||
}
|
||||
if ($this->withmaindocfile == -1)
|
||||
{
|
||||
if ($this->withmaindocfile == -1) {
|
||||
$out .= '<input type="checkbox" name="addmaindocfile" value="1" checked="checked" />';
|
||||
}
|
||||
$out .= ' '.$langs->trans("JoinMainDoc").'.<br>';
|
||||
}
|
||||
|
||||
if (is_numeric($this->withfile))
|
||||
{
|
||||
if (is_numeric($this->withfile)) {
|
||||
// TODO Trick to have param removedfile containing nb of file to delete. But this does not works without javascript
|
||||
$out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
|
||||
$out .= '<script type="text/javascript" language="javascript">';
|
||||
@ -885,28 +834,23 @@ class FormMail extends Form
|
||||
$out .= ' });';
|
||||
$out .= '})';
|
||||
$out .= '</script>'."\n";
|
||||
if (count($listofpaths))
|
||||
{
|
||||
foreach ($listofpaths as $key => $val)
|
||||
{
|
||||
if (count($listofpaths)) {
|
||||
foreach ($listofpaths as $key => $val) {
|
||||
$out .= '<div id="attachfile_'.$key.'">';
|
||||
// Preview of attachment
|
||||
preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params);
|
||||
$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
|
||||
$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
|
||||
if (!$this->withfilereadonly)
|
||||
{
|
||||
if (!$this->withfilereadonly) {
|
||||
$out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
|
||||
//$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
|
||||
}
|
||||
$out .= '<br></div>';
|
||||
}
|
||||
} elseif (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox
|
||||
{
|
||||
} elseif (empty($this->withmaindocfile)) { // Do not show message if we asked to show the checkbox
|
||||
$out .= $langs->trans("NoAttachedFiles").'<br>';
|
||||
}
|
||||
if ($this->withfile == 2) // Can add other files
|
||||
{
|
||||
if ($this->withfile == 2) { // Can add other files
|
||||
if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= '<input type="file" class="flat" id="addedfile" name="addedfile[]" value="'.$langs->trans("Upload").'" multiple />';
|
||||
else $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
|
||||
$out .= ' ';
|
||||
@ -920,11 +864,9 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
// Message
|
||||
if (!empty($this->withbody))
|
||||
{
|
||||
if (!empty($this->withbody)) {
|
||||
$defaultmessage = GETPOST('message', 'restricthtml');
|
||||
if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1')
|
||||
{
|
||||
if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') {
|
||||
if ($arraydefaultmessage && $arraydefaultmessage->content) {
|
||||
$defaultmessage = $arraydefaultmessage->content;
|
||||
} elseif (!is_numeric($this->withbody)) {
|
||||
@ -934,25 +876,29 @@ class FormMail extends Form
|
||||
|
||||
// Complete substitution array with the url to make online payment
|
||||
$paymenturl = ''; $validpaymentmethod = array();
|
||||
if (empty($this->substit['__REF__']))
|
||||
{
|
||||
if (empty($this->substit['__REF__'])) {
|
||||
$paymenturl = '';
|
||||
} else {
|
||||
// Set the online payment url link into __ONLINE_PAYMENT_URL__ key
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
$langs->loadLangs(array('paypal', 'other'));
|
||||
$typeforonlinepayment = 'free';
|
||||
if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template
|
||||
if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template
|
||||
if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template
|
||||
if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') {
|
||||
$typeforonlinepayment = 'order'; // TODO use detection on something else than template
|
||||
}
|
||||
if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') {
|
||||
$typeforonlinepayment = 'invoice'; // TODO use detection on something else than template
|
||||
}
|
||||
if ($this->param["models"] == 'member') {
|
||||
$typeforonlinepayment = 'member'; // TODO use detection on something else than template
|
||||
}
|
||||
$url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']);
|
||||
$paymenturl = $url;
|
||||
|
||||
$validpaymentmethod = getValidOnlinePaymentMethods('');
|
||||
}
|
||||
|
||||
if (count($validpaymentmethod) > 0 && $paymenturl)
|
||||
{
|
||||
if (count($validpaymentmethod) > 0 && $paymenturl) {
|
||||
$langs->load('other');
|
||||
$this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl));
|
||||
$this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl;
|
||||
@ -966,10 +912,8 @@ class FormMail extends Form
|
||||
// Add lines substitution key from each line
|
||||
$lines = '';
|
||||
$defaultlines = $arraydefaultmessage->content_lines;
|
||||
if (isset($defaultlines))
|
||||
{
|
||||
foreach ($this->substit_lines as $substit_line)
|
||||
{
|
||||
if (isset($defaultlines)) {
|
||||
foreach ($this->substit_lines as $substit_line) {
|
||||
$lines .= make_substitutions($defaultlines, $substit_line)."\n";
|
||||
}
|
||||
}
|
||||
@ -1003,8 +947,9 @@ class FormMail extends Form
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOSTISSET("message") && !$_POST['modelselected']) $defaultmessage = $_POST["message"];
|
||||
else {
|
||||
if (GETPOSTISSET("message") && !$_POST['modelselected']) {
|
||||
$defaultmessage = $_POST["message"];
|
||||
} else {
|
||||
$defaultmessage = make_substitutions($defaultmessage, $this->substit);
|
||||
// Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
|
||||
$defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
|
||||
@ -1016,17 +961,17 @@ class FormMail extends Form
|
||||
$out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody');
|
||||
$out .= '</td>';
|
||||
$out .= '<td>';
|
||||
if ($this->withbodyreadonly)
|
||||
{
|
||||
if ($this->withbodyreadonly) {
|
||||
$out .= nl2br($defaultmessage);
|
||||
$out .= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
|
||||
} else {
|
||||
if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
|
||||
if (!isset($this->ckeditortoolbar)) {
|
||||
$this->ckeditortoolbar = 'dolibarr_notes';
|
||||
}
|
||||
|
||||
// Editor wysiwyg
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
if ($this->withfckeditor == -1)
|
||||
{
|
||||
if ($this->withfckeditor == -1) {
|
||||
if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1;
|
||||
else $this->withfckeditor = 0;
|
||||
}
|
||||
@ -1039,29 +984,27 @@ class FormMail extends Form
|
||||
|
||||
$out .= '</table>'."\n";
|
||||
|
||||
if ($this->withform == 1 || $this->withform == -1)
|
||||
{
|
||||
if ($this->withform == 1 || $this->withform == -1) {
|
||||
$out .= '<br><div class="center">';
|
||||
$out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
|
||||
// Add a javascript test to avoid to forget to submit file before sending email
|
||||
if ($this->withfile == 2 && $conf->use_javascript_ajax)
|
||||
{
|
||||
if ($this->withfile == 2 && $conf->use_javascript_ajax) {
|
||||
$out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
|
||||
}
|
||||
$out .= ' />';
|
||||
if ($this->withcancel)
|
||||
{
|
||||
if ($this->withcancel) {
|
||||
$out .= ' ';
|
||||
$out .= '<input class="button button-cancel" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
|
||||
}
|
||||
$out .= '</div>'."\n";
|
||||
}
|
||||
|
||||
if ($this->withform == 1) $out .= '</form>'."\n";
|
||||
if ($this->withform == 1) {
|
||||
$out .= '</form>'."\n";
|
||||
}
|
||||
|
||||
// Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
|
||||
if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY))
|
||||
{
|
||||
if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) {
|
||||
$out .= '<script type="text/javascript" language="javascript">';
|
||||
$out .= 'jQuery(document).ready(function () {';
|
||||
$out .= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is called at every key pressed ! */
|
||||
@ -1110,14 +1053,30 @@ class FormMail extends Form
|
||||
}
|
||||
|
||||
$showinfobcc = '';
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO;
|
||||
if ($showinfobcc) $out .= ' + '.$showinfobcc;
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO;
|
||||
}
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') {
|
||||
$showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO;
|
||||
}
|
||||
if ($showinfobcc) {
|
||||
$out .= ' + '.$showinfobcc;
|
||||
}
|
||||
$out .= "</td></tr>\n";
|
||||
return $out;
|
||||
}
|
||||
@ -1212,7 +1171,7 @@ class FormMail extends Form
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $type_template Get message for model/type=$type_template, type='all' also included.
|
||||
* @param string $user Get template public or limited to this user
|
||||
* @param User $user Get template public or limited to this user
|
||||
* @param Translate $outputlangs Output lang object
|
||||
* @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found)
|
||||
* @param int $active 1=Only active template, 0=Only disabled, -1=All
|
||||
@ -1232,7 +1191,9 @@ class FormMail extends Form
|
||||
// Define $languagetosearchmain to fall back on main language (for example to get 'es_ES' for 'es_MX')
|
||||
$tmparray = explode('_', $languagetosearch);
|
||||
$languagetosearchmain = $tmparray[0].'_'.strtoupper($tmparray[0]);
|
||||
if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = '';
|
||||
if ($languagetosearchmain == $languagetosearch) {
|
||||
$languagetosearchmain = '';
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
|
||||
@ -1244,14 +1205,16 @@ class FormMail extends Form
|
||||
if (!($id > 0) && $languagetosearch) $sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
|
||||
if ($id > 0) $sql .= " AND rowid=".$id;
|
||||
if ($id == -1) $sql .= " AND position=0";
|
||||
if ($languagetosearch) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
|
||||
else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined
|
||||
if ($languagetosearch) {
|
||||
$sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
|
||||
} else {
|
||||
$sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined
|
||||
}
|
||||
$sql .= $db->plimit(1);
|
||||
//print $sql;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
// Get first found
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
@ -1321,7 +1284,7 @@ class FormMail extends Form
|
||||
* Search into table c_email_templates
|
||||
*
|
||||
* @param string $type_template Get message for key module
|
||||
* @param string $user Use template public or limited to this user
|
||||
* @param User $user Use template public or limited to this user
|
||||
* @param Translate $outputlangs Output lang object
|
||||
* @return int <0 if KO,
|
||||
*/
|
||||
@ -1332,13 +1295,14 @@ class FormMail extends Form
|
||||
$sql .= " WHERE type_template='".$this->db->escape($type_template)."'";
|
||||
$sql .= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
|
||||
if (is_object($outputlangs)) $sql .= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')";
|
||||
if (is_object($outputlangs)) {
|
||||
$sql .= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')";
|
||||
}
|
||||
$sql .= $this->db->order("lang,label", "ASC");
|
||||
//print $sql;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$this->db->free($resql);
|
||||
return $num;
|
||||
@ -1353,7 +1317,7 @@ class FormMail extends Form
|
||||
* Search into table c_email_templates
|
||||
*
|
||||
* @param string $type_template Get message for key module
|
||||
* @param string $user Use template public or limited to this user
|
||||
* @param User $user Use template public or limited to this user
|
||||
* @param Translate $outputlangs Output lang object
|
||||
* @param int $active 1=Only active template, 0=Only disabled, -1=All
|
||||
* @return int <0 if KO, nb of records found if OK
|
||||
@ -1365,18 +1329,18 @@ class FormMail extends Form
|
||||
$sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')";
|
||||
$sql .= " AND entity IN (".getEntity('c_email_templates').")";
|
||||
$sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own.
|
||||
if ($active >= 0) $sql .= " AND active = ".$active;
|
||||
if ($active >= 0) {
|
||||
$sql .= " AND active = ".$active;
|
||||
}
|
||||
//if (is_object($outputlangs)) $sql.= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; // Return all languages
|
||||
$sql .= $this->db->order("position,lang,label", "ASC");
|
||||
//print $sql;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$this->lines_model = array();
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$line = new ModelMail();
|
||||
$line->id = $obj->rowid;
|
||||
$line->label = $obj->label;
|
||||
@ -1419,10 +1383,8 @@ class FormMail extends Form
|
||||
$this->substit = $tmparray;
|
||||
|
||||
// Fill substit_lines with each object lines content
|
||||
if (is_array($object->lines))
|
||||
{
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if (is_array($object->lines)) {
|
||||
foreach ($object->lines as $line) {
|
||||
$substit_line = array(
|
||||
'__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '',
|
||||
'__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '',
|
||||
@ -1438,15 +1400,13 @@ class FormMail extends Form
|
||||
);
|
||||
|
||||
// Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__
|
||||
if (!empty($line->fk_product))
|
||||
{
|
||||
if (!empty($line->fk_product)) {
|
||||
if (!is_object($extrafields)) $extrafields = new ExtraFields($this->db);
|
||||
$extrafields->fetch_name_optionals_label('product', true);
|
||||
$product = new Product($this->db);
|
||||
$product->fetch($line->fk_product, '', '', 1);
|
||||
$product->fetch_optionals();
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
|
||||
$substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key];
|
||||
}
|
||||
@ -1470,24 +1430,20 @@ class FormMail extends Form
|
||||
global $conf, $langs;
|
||||
|
||||
$tmparray = array();
|
||||
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines')
|
||||
{
|
||||
if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') {
|
||||
$parameters = array('mode'=>$mode);
|
||||
$tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects
|
||||
complete_substitutions_array($tmparray, $langs, null, $parameters);
|
||||
|
||||
if ($mode == 'formwithlines')
|
||||
{
|
||||
if ($mode == 'formwithlines') {
|
||||
$tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function
|
||||
}
|
||||
if ($mode == 'formforlines')
|
||||
{
|
||||
if ($mode == 'formforlines') {
|
||||
$tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == 'emailing')
|
||||
{
|
||||
if ($mode == 'emailing') {
|
||||
$parameters = array('mode'=>$mode);
|
||||
$tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects
|
||||
complete_substitutions_array($tmparray, $langs, null, $parameters);
|
||||
@ -1512,11 +1468,9 @@ class FormMail extends Form
|
||||
if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++;
|
||||
if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++;
|
||||
if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++;
|
||||
if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN))
|
||||
{
|
||||
if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
|
||||
$tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN;
|
||||
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
|
||||
{
|
||||
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
|
||||
if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember';
|
||||
if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice';
|
||||
if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder';
|
||||
@ -1533,8 +1487,7 @@ class FormMail extends Form
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tmparray as $key => $val)
|
||||
{
|
||||
foreach ($tmparray as $key => $val) {
|
||||
if (empty($val)) $tmparray[$key] = $key;
|
||||
}
|
||||
|
||||
|
||||
@ -182,11 +182,14 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php<br>Contact:con
|
||||
<!-- Language file -->
|
||||
<tr><td class="titlefield"><?php echo $langs->trans("LanguageFile"); ?></td><td class="valeur"><input type="text" id="langfile" name="langfile" class="minwidth200" value="<?php echo dol_escape_htmltag(GETPOST('langfile', 'alpha')); ?>"></td></tr>
|
||||
<!-- Computed Value -->
|
||||
<tr class="extra_computed_value">
|
||||
<?php if (empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
|
||||
<tr class="extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?></td><td class="valeur"><input id="computed_value" type="text" name="computed_value" class="quatrevingtpercent" value="<?php echo (GETPOSTISSET('computed_value') ? GETPOST('computed_value', 'none') : ''); ?>"></td></tr>
|
||||
<td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?></td>
|
||||
<?php } else { ?>
|
||||
<tr class="extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?></td><td class="valeur"><input id="computed_value" class="quatrevingtpercent" type="text" name="computed_value" value="<?php echo dol_escape_htmltag($computed); ?>"></td></tr>
|
||||
<td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?></td>
|
||||
<?php } ?>
|
||||
<td class="valeur"><textarea name="computed_value" id="computed_value" class="quatrevingtpercent" rows="<?php echo ROWS_4 ?>"><?php echo (GETPOST('computed_value', 'none') ?GETPOST('computed_value', 'none') : ''); ?></textarea></td>
|
||||
</tr>
|
||||
<!-- Default Value (at sql setup level) -->
|
||||
<tr class="extra_default_value"><td><?php echo $langs->trans("DefaultValue").' ('.$langs->trans("Database").')'; ?></td><td class="valeur"><input id="default_value" type="text" name="default_value" size="5" value="<?php echo (GETPOST('default_value', 'alpha') ?GETPOST('default_value', 'alpha') : ''); ?>"></td></tr>
|
||||
<!-- Unique -->
|
||||
|
||||
@ -265,11 +265,14 @@ if (in_array($type, array_keys($typewecanchangeinto)))
|
||||
<tr><td class="titlefield"><?php echo $langs->trans("LanguageFile"); ?></td><td class="valeur"><input type="text" name="langfile" class="minwidth200" value="<?php echo dol_escape_htmltag($langfile); ?>"></td></tr>
|
||||
|
||||
<!-- Computed value -->
|
||||
<tr class="extra_computed_value">
|
||||
<?php if (empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?>
|
||||
<tr class="extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?></td><td class="valeur"><input id="computed_value" class="quatrevingtpercent" type="text" name="computed_value" value="<?php echo dol_escape_htmltag($computed); ?>"></td></tr>
|
||||
<td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?></td>
|
||||
<?php } else { ?>
|
||||
<tr class="extra_computed_value"><td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?></td><td class="valeur"><input id="computed_value" class="quatrevingtpercent" type="text" name="computed_value" value="<?php echo dol_escape_htmltag($computed); ?>"></td></tr>
|
||||
<td><?php echo $form->textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?></td>
|
||||
<?php } ?>
|
||||
<td class="valeur"><textarea name="computed_value" id="computed_value" class="quatrevingtpercent" rows="<?php echo ROWS_4 ?>"><?php echo dol_htmlcleanlastbr($computed); ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
<!-- Default Value (at sql setup level) -->
|
||||
<tr class="extra_default_value"><td><?php echo $langs->trans("DefaultValue").' ('.$langs->trans("Database").')'; ?></td><td class="valeur"><input id="default_value" type="text" name="default_value" size="5" value="<?php echo dol_escape_htmltag($default); ?>"></td></tr>
|
||||
|
||||
@ -1028,7 +1028,7 @@ function showWeather($totallate, $text, $options, $morecss = '')
|
||||
* $conf->global->MAIN_METEO_LEVELx
|
||||
*
|
||||
* @param int $totallate Nb of element late
|
||||
* @return string Return img tag of weather
|
||||
* @return stdClass Return img tag of weather
|
||||
*/
|
||||
function getWeatherStatus($totallate)
|
||||
{
|
||||
@ -1063,20 +1063,16 @@ function getWeatherStatus($totallate)
|
||||
if ($totallate <= $level0) {
|
||||
$weather->picto = 'weather-clear.png';
|
||||
$weather->level = 0;
|
||||
}
|
||||
elseif ($totallate <= $level1) {
|
||||
} elseif ($totallate <= $level1) {
|
||||
$weather->picto = 'weather-few-clouds.png';
|
||||
$weather->level = 1;
|
||||
}
|
||||
elseif ($totallate <= $level2) {
|
||||
} elseif ($totallate <= $level2) {
|
||||
$weather->picto = 'weather-clouds.png';
|
||||
$weather->level = 2;
|
||||
}
|
||||
elseif ($totallate <= $level3) {
|
||||
} elseif ($totallate <= $level3) {
|
||||
$weather->picto = 'weather-many-clouds.png';
|
||||
$weather->level = 3;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$weather->picto = 'weather-storm.png';
|
||||
$weather->level = 4;
|
||||
}
|
||||
|
||||
@ -291,17 +291,40 @@ if ($result)
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<td>".$group_array['htmlname']."</td>\n";
|
||||
print "<td class=\"right\">".price(price2num($pv, 'MT'))."</td>\n";
|
||||
print "<td class=\"right\">".price(price2num($pa, 'MT'))."</td>\n";
|
||||
print "<td class=\"right\">".price(price2num($marge, 'MT'))."</td>\n";
|
||||
print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
$cumul_achat += $pa;
|
||||
$cumul_vente += $pv;
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
// Show total margin
|
||||
$totalMargin = $cumul_vente - $cumul_achat;
|
||||
|
||||
$marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : '';
|
||||
$markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : '';
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -310,9 +333,13 @@ $db->free($result);
|
||||
|
||||
print "\n".'<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#agentid").change(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
$("#agentid").change(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
|
||||
$("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'");
|
||||
$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'");
|
||||
$("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'");
|
||||
});
|
||||
</script>'."\n";
|
||||
|
||||
|
||||
@ -303,23 +303,23 @@ if ($result)
|
||||
$invoicestatic->id = $objp->facid;
|
||||
$invoicestatic->ref = $objp->ref;
|
||||
print $invoicestatic->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
print "<td class=\"center\">";
|
||||
print dol_print_date($db->jdate($objp->datef), 'day')."</td>";
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($objp->datef), 'day').'</td>';
|
||||
} else {
|
||||
$companystatic->id = $objp->socid;
|
||||
$companystatic->name = $objp->name;
|
||||
$companystatic->client = $objp->client;
|
||||
print "<td>".$companystatic->getNomUrl(1, 'margin')."</td>\n";
|
||||
print '<td>'.$companystatic->getNomUrl(1, 'margin').'</td>';
|
||||
}
|
||||
|
||||
print "<td class=\"right\">".price(price2num($pv, 'MT'))."</td>\n";
|
||||
print "<td class=\"right\">".price(price2num($pa, 'MT'))."</td>\n";
|
||||
print "<td class=\"right\">".price(price2num($marge, 'MT'))."</td>\n";
|
||||
print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
@ -347,16 +347,16 @@ if ($result)
|
||||
print '<td colspan=2>';
|
||||
else print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print "<td class=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
|
||||
print "<td class=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
|
||||
print "<td class=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -370,9 +370,9 @@ $(document).ready(function() {
|
||||
$("div.fiche form").submit();
|
||||
});*/
|
||||
|
||||
$("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'");
|
||||
$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'");
|
||||
$("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'");
|
||||
$("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'");
|
||||
$("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'");
|
||||
$("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'");
|
||||
});
|
||||
</script>
|
||||
';
|
||||
|
||||
@ -300,14 +300,14 @@ if ($result)
|
||||
print "</td>\n";
|
||||
//print "<td>".$product_static->getNomUrl(1)."</td>\n";
|
||||
}
|
||||
print "<td class=\"center\">".$qty."</td>\n";
|
||||
print "<td class=\"nowrap right\">".price(price2num($pv, 'MT'))."</td>\n";
|
||||
print "<td class=\"nowrap right\">".price(price2num($pa, 'MT'))."</td>\n";
|
||||
print "<td class=\"nowrap right\">".price(price2num($marge, 'MT'))."</td>\n";
|
||||
print '<td class="center">'.$qty.'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
@ -328,15 +328,15 @@ if ($result)
|
||||
if ($id > 0)
|
||||
print '<td colspan=2>';
|
||||
else print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print "<td class=\"center\">".$cumul_qty."</td>";
|
||||
print "<td class=\"nowrap right\">".price(price2num($cumul_vente, 'MT'))."</td>\n";
|
||||
print "<td class=\"nowrap right\">".price(price2num($cumul_achat, 'MT'))."</td>\n";
|
||||
print "<td class=\"nowrap right\">".price(price2num($totalMargin, 'MT'))."</td>\n";
|
||||
print $langs->trans('TotalMargin').'</td>';
|
||||
print '<td class="center">'.$cumul_qty.'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td class=\"right\">".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td class=\"right\">".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."</td>\n";
|
||||
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -25,7 +25,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
|
||||
.info-box.info-box-sm {
|
||||
min-height: 80px;
|
||||
margin-bottom: 10px;
|
||||
/* background: #fff; */
|
||||
/* background: #fff; */
|
||||
}
|
||||
.opened-dash-board-wrap .info-box.info-box-sm {
|
||||
border-radius: 0 0 0 20px;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user