diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6d8787b1677..09ee313e487 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -188,7 +188,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")"; +$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template',1).")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; @@ -262,7 +262,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -$tabfield[25]= "label,type_template,private,position,topic,content"; +$tabfield[25]= "label,type_template,private,position,topic,content_lines,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; @@ -299,7 +299,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; @@ -336,7 +336,7 @@ $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; $tabfieldinsert[23]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24]= "code,label"; -$tabfieldinsert[25]= "label,type_template,private,position,topic,content,entity"; +$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; @@ -449,7 +449,7 @@ $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array(); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); @@ -1063,6 +1063,7 @@ if ($id) if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); } + if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); } if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("Info"); } if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } @@ -1254,6 +1255,7 @@ if ($id) if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); } if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); } if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); } + if ($fieldlist[$field]=='content_lines') { $valuetoshow=$langs->trans("ContentLines"); } if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); } if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("Info"); } if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } @@ -1771,6 +1773,24 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print '
| ';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index cf42fe3c33f..2111886a517 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -824,7 +824,7 @@ class Propal extends CommonObject
if (empty($this->demand_reason_id)) $this->demand_reason_id=0;
// Multicurrency
- if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
+ if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
if (empty($this->fk_multicurrency))
{
$this->multicurrency_code = $conf->currency;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 1cd706c1863..50bb9e6a009 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -704,9 +704,12 @@ class Commande extends CommonOrder
// Clean parameters
$this->brouillon = 1; // set command as draft
-
+
+ // $date_commande is deprecated
+ $date = ($this->date_commande ? $this->date_commande : $this->date);
+
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
- if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
+ if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency))
{
@@ -745,9 +748,6 @@ class Commande extends CommonOrder
return -1;
}
- // $date_commande is deprecated
- $date = ($this->date_commande ? $this->date_commande : $this->date);
-
$now=dol_now();
$this->db->begin();
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 013b34699d7..10fb88bbe64 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -77,6 +77,7 @@ class FormMail extends Form
var $withfckeditor;
var $substit=array();
+ var $substit_lines=array();
var $param=array();
var $error;
@@ -712,6 +713,18 @@ class FormMail extends Form
$this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
}
}
+
+ //Add lines substitution key from each line
+ $lines = '';
+ $defaultlines = $arraydefaultmessage['content_lines'];
+ if (isset($defaultlines))
+ {
+ foreach ($this->substit_lines as $substit_line)
+ {
+ $lines .= make_substitutions($defaultlines,$substit_line)."\n";
+ }
+ }
+ $this->substit['__LINES__']=$lines;
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
@@ -820,7 +833,7 @@ class FormMail extends Form
{
$ret=array();
- $sql = "SELECT label, topic, content, lang";
+ $sql = "SELECT label, topic, content, content_lines, lang";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE type_template='".$db->escape($type_template)."'";
$sql.= " AND entity IN (".getEntity("c_email_templates").")";
@@ -840,6 +853,7 @@ class FormMail extends Form
$ret['label']=$obj->label;
$ret['topic']=$obj->topic;
$ret['content']=$obj->content;
+ $ret['content_lines']=$obj->content_lines;
$ret['lang']=$obj->lang;
}
else
@@ -859,6 +873,7 @@ class FormMail extends Form
$ret['label']='default';
$ret['topic']='';
$ret['content']=$defaultmessage;
+ $ret['content_lines']='';
$ret['lang']=$outputlangs->defaultlang;
}
@@ -922,7 +937,7 @@ class FormMail extends Form
{
$ret=array();
- $sql = "SELECT rowid, label, topic, content, lang, position";
+ $sql = "SELECT rowid, label, topic, content, content_lines, lang, position";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
$sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
$sql.= " AND entity IN (".getEntity("c_email_templates").")";
@@ -944,6 +959,7 @@ class FormMail extends Form
$line->label=$obj->label;
$line->topic=$obj->topic;
$line->content=$obj->content;
+ $line->content_lines=$obj->content_lines;
$line->lang=$obj->lang;
$this->lines_model[]=$line;
}
@@ -962,7 +978,7 @@ class FormMail extends Form
/**
* Set substit array from object
*
- * @param Object $object Object to use
+ * @param CommonObject $object Object to use
* @param Translate $outputlangs Object lang
* @return void
*/
@@ -970,11 +986,11 @@ class FormMail extends Form
{
global $user;
$this->substit['__REF__'] = $object->ref;
- $this->substit['__REFCLIENT__'] = $object->ref_client;
- $this->substit['__REFSUPPLIER__'] = $object->ref_supplier;
+ $this->substit['__REFCLIENT__'] = isset($object->ref_client) ? $object->ref_client : '';
+ $this->substit['__REFSUPPLIER__'] = isset($object->ref_supplier) ? $object->ref_supplier : '';
- $this->substit['__DATE_YMD__'] = dol_print_date($object->date, 'day', 0, $outputlangs);
- $this->substit['__DATE_DUE_YMD__'] = dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs);
+ $this->substit['__DATE_YMD__'] = isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '';
+ $this->substit['__DATE_DUE_YMD__'] = isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '';
$this->substit['__AMOUNT__'] = price($object->total_ttc);
$this->substit['__AMOUNT_WO_TAX__'] = price($object->total_ht);
@@ -988,6 +1004,42 @@ class FormMail extends Form
$this->substit['__SIGNATURE__'] = $user->signature;
$this->substit['__PERSONALIZED__'] = '';
$this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
+
+ //Fill substit_lines with each object lines content
+ 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 : '',
+ '__PRODUCT_DESCRIPTION__' => isset($line->product_desc) ? $line->product_desc : '',
+ '__LABEL__' => isset($line->label) ? $line->label : '',
+ '__DESCRIPTION__' => isset($line->desc) ? $line->desc : '',
+ '__DATE_START_YMD__' => dol_print_date($line->date_start, 'day', 0, $outputlangs),
+ '__DATE_END_YMD__' => dol_print_date($line->date_end, 'day', 0, $outputlangs),
+ '__QUANTITY__' => $line->qty,
+ '__SUBPRICE__' => price($line->subprice),
+ '__AMOUNT__' => price($line->total_ttc),
+ '__AMOUNT_WO_TAX__' => price($line->total_ht),
+ //'__PRODUCT_EXTRAFIELD_FIELD__' Done dinamically
+ );
+
+ // Create dinamic tags for __PRODUCT_EXTRAFIELD_FIELD__
+ if (!empty($line->fk_product))
+ {
+ $extrafields = new ExtraFields($this->db);
+ $extralabels = $extrafields->fetch_name_optionals_label('product', true);
+ $product = new Product($this->db);
+ $product->fetch($line->fk_product, '', '', 1);
+ $product->fetch_optionals($product->id, $extralabels);
+ foreach ($extrafields->attribute_label as $key => $label) {
+ $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key];
+ }
+ }
+ $this->substit_lines[] = $substit_line;
+ }
+ }
}
/**
@@ -1066,5 +1118,6 @@ class ModelMail
public $label;
public $topic;
public $content;
+ public $content_lines;
public $lang;
}
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 1d1f59a596e..d756bc2b72a 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -321,9 +321,20 @@ if (empty($reshook))
if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
else setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
}
+
$object->fetch($id);
+
$object->date=$newdate;
- if ($object->date_echeance && $object->date_echeance < $object->date) $object->date_echeance=$object->date;
+ $date_echence_calc=$object->calculate_date_lim_reglement();
+ if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc)
+ {
+ $object->date_echeance = $date_echence_calc;
+ }
+ if ($object->date_echeance && $object->date_echeance < $object->date)
+ {
+ $object->date_echeance=$object->date;
+ }
+
$result=$object->update($user);
if ($result < 0) dol_print_error($db,$object->error);
}
@@ -1001,7 +1012,7 @@ if (empty($reshook))
}
$price_base_type = 'HT';
$pu_ht_devise = price2num($price_ht_devise, 'MU');
-
+
$result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise);
}
@@ -1500,7 +1511,7 @@ if ($action == 'create')
if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid))))
{
// Deposit
- if (empty($conf->global->INVOICE_DISABLE_DEPOSIT))
+ if (empty($conf->global->INVOICE_DISABLE_DEPOSIT))
{
print ' ';
$tmp=' ';
@@ -1530,12 +1541,12 @@ if ($action == 'create')
}
}
*/
-
+
/* Not yet supporter for supplier
if ($societe->id > 0)
{
// Replacement
- if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
+ if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
{
print '';
print ' ';
@@ -1585,7 +1596,7 @@ if ($action == 'create')
if ($societe->id > 0)
{
// Credit note
- if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
+ if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
{
print ' ';
$tmp='textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
-
+
print ' ';
print ' 0 ? 'checked':'').' /> ";
print ' ';
-
+
print '0 ? 'checked':'').' /> "; print ' ';
print ' ';
@@ -2183,7 +2194,7 @@ else
}
print " | ";
print '