From f5bffeb535b97bd5a62dda75037a4fcc58377b15 Mon Sep 17 00:00:00 2001 From: phf Date: Sun, 11 Dec 2016 16:30:01 +0100 Subject: [PATCH 1/5] New get multicurrency rate from document date (propal, order) --- htdocs/admin/multicurrency.php | 9 +++--- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/class/commande.class.php | 10 +++--- .../class/multicurrency.class.php | 31 ++++++++++++++----- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index de3c2f3965a..f280b7c1735 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -183,20 +183,19 @@ print ''.$langs->trans("Parameters").''."\n"; print ' '; print ''.$langs->trans("Value").''."\n"; -/* TODO uncomment when the functionality will integrated $var=!$var; print ''; -print ''.$langs->transnoentitiesnoconv("multicurrency_useRateOnInvoiceDate").''; +print ''.$langs->transnoentitiesnoconv("multicurrency_useRateOnDocumentDate").''; print ' '; print ''; print '
'; print ''; -print ''; -print $form->selectyesno("MULTICURRENCY_USE_RATE_ON_INVOICE_DATE",$conf->global->MULTICURRENCY_USE_RATE_ON_INVOICE_DATE,1); +print ''; +print $form->selectyesno("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE",$conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE,1); print ''; print '
'; print ''; -*/ + $var=!$var; print ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f10d82fdbfa..017a540e453 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 1f75e6caf74..f8bf39721ab 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/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 97d29e3885b..c42b4fc3796 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -508,22 +508,37 @@ class MultiCurrency extends CommonObject * * @param DoliDB $db object db * @param string $code code value search + * @param date $date_document date from document (propal, order, invoice, ...) * * @return array [0] => id currency * [1] => rate */ - public static function getIdAndTxFromCode(&$db, $code) + public static function getIdAndTxFromCode(&$db, $code, $date_document) { - $sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; - $sql.= ' WHERE m.code = \''.$db->escape($code).'\''; - $sql.= " AND m.entity IN (".getEntity('multicurrency', 1).")"; - $sql.= ' ORDER BY mc.date_sync DESC LIMIT 1'; + global $conf; + + $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; + $sql1.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; + $sql1.= ' WHERE m.code = \''.$db->escape($code).'\''; + $sql1.= " AND m.entity IN (".getEntity('multicurrency', 1).")"; + $sql2= ''; + if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) $sql2.= ' AND DATE_FORMAT(mc.date_sync, "%Y-%m-%d") = "'.date('Y-m-d', $date_document).'"'; + $sql3.= ' ORDER BY mc.date_sync DESC LIMIT 1'; dol_syslog(__METHOD__,LOG_DEBUG); - $resql = $db->query($sql); + $resql = $db->query($sql1.$sql2.$sql3); + if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); - else return array(0, 1); + else + { + if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE)) + { + $resql = $db->query($sql1.$sql3); + if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); + } + + return array(0, 1); + } } /** From 1db907e2afebb6403502ff3c0eb7eedb13f15b77 Mon Sep 17 00:00:00 2001 From: phf Date: Sun, 11 Dec 2016 21:15:24 +0100 Subject: [PATCH 2/5] Fix missing default value for new parameter --- htdocs/multicurrency/class/multicurrency.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index c42b4fc3796..b8ce1995b5a 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -513,7 +513,7 @@ class MultiCurrency extends CommonObject * @return array [0] => id currency * [1] => rate */ - public static function getIdAndTxFromCode(&$db, $code, $date_document) + public static function getIdAndTxFromCode(&$db, $code, $date_document='') { global $conf; From 522fb4cf7a3bf50fdf2b38236bd77a6f1fb4430a Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Mon, 26 Dec 2016 05:18:40 +0100 Subject: [PATCH 3/5] Add email template for each line in object --- htdocs/admin/dict.php | 32 +++++++-- htdocs/core/class/html.formmail.class.php | 67 +++++++++++++++++-- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 + .../mysql/tables/llx_c_email_templates.sql | 3 +- 4 files changed, 90 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 2ca1337736e..afde36018a5 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")); @@ -1062,6 +1062,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"); } @@ -1253,6 +1254,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"); } @@ -1770,6 +1772,24 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') elseif (in_array($fieldlist[$field], array('libelle_facture'))) { print ''; } + elseif (in_array($fieldlist[$field], array('content_lines'))) + { + if ($tabname == MAIN_DB_PREFIX.'c_email_templates') + { + print ''; // To create an artificial CR for the current tr we are on + } + else print ''; + if ($context != 'hide') + { + //print ''; + $okforextended=true; + if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 100, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_1, '90%'); + print $doleditor->Create(1); + } + else print ' '; + print ''; + } elseif (in_array($fieldlist[$field], array('content'))) { if ($tabname == MAIN_DB_PREFIX.'c_email_templates') @@ -1782,7 +1802,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') //print ''; $okforextended=true; if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; - $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); + $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_8, '90%'); print $doleditor->Create(1); } else print ' '; 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/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 7ba91298545..55eec47a1da 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -40,3 +40,5 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',30); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_DELETE','Product or service deleted','Executed when a product or sevice is deleted','product',30); +ALTER TABLE llx_c_email_templates ADD COLUMN content_lines text; + diff --git a/htdocs/install/mysql/tables/llx_c_email_templates.sql b/htdocs/install/mysql/tables/llx_c_email_templates.sql index b4d2f9a96cb..6c97ea180a1 100644 --- a/htdocs/install/mysql/tables/llx_c_email_templates.sql +++ b/htdocs/install/mysql/tables/llx_c_email_templates.sql @@ -32,5 +32,6 @@ create table llx_c_email_templates position smallint, -- Position active tinyint DEFAULT 1 NOT NULL, topic text, -- Predefined topic - content text -- Predefined text + content text, -- Predefined text + content_lines text -- Predefined lines )ENGINE=innodb; From c4f04338052a999453b1b2a68ee72f77422032bd Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 6 Jan 2017 14:47:57 +0100 Subject: [PATCH 4/5] fix date echance --- htdocs/fourn/facture/card.php | 52 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 8b7409f8bc5..40bc4289b4a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -317,7 +317,15 @@ if (empty($reshook)) { $object->fetch($id); $object->date=dol_mktime(12,0,0,$_POST['datefmonth'],$_POST['datefday'],$_POST['datefyear']); - 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); } @@ -995,7 +1003,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); } @@ -1494,7 +1502,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=' '; @@ -1524,12 +1532,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 '
'; @@ -1579,7 +1587,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 '
    0 ? 'checked':'').' /> "; print '
'; - + print '
'; } } @@ -2008,7 +2016,7 @@ else $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; @@ -2152,7 +2160,7 @@ else $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == 0) { + if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; print '
'; @@ -2213,7 +2221,7 @@ else print ''; } */ - + // Incoterms if (!empty($conf->incoterm->enabled)) { @@ -2240,9 +2248,9 @@ else // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print ''; - + print '
'; print '
'; print '
'; @@ -2256,12 +2264,12 @@ else print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount VAT print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount TTC print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; @@ -2269,7 +2277,7 @@ else } // Amount - print ''.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).''; + print ''.$langs->trans('AmountHT').''.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).''; print ''.$langs->trans('AmountVAT').''.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'
        '; if (GETPOST('calculationrule')) $calculationrule=GETPOST('calculationrule','alpha'); else $calculationrule=(empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)?'totalofround':'roundoftotal'); @@ -2299,7 +2307,7 @@ else print ''.$langs->trans('AmountTTC').''.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).''; print ''; - + /* * List of payments */ @@ -2395,9 +2403,9 @@ else { print ''.$langs->trans('AlreadyPaid').' :'.price($totalpaye).''; print ''.$langs->trans("Billed").' :'.price($object->total_ttc).''; - + $resteapayer = $object->total_ttc - $totalpaye; - + print ''.$langs->trans('RemainderToPay').' :'; print ''.price($resteapayer).''; } @@ -2506,7 +2514,7 @@ else print ' :'; print '' . price($resteapayeraffiche) . ''; print ' '; - } + } else // Credit note { // Total already paid back @@ -2538,9 +2546,9 @@ else print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; From 06d9f99d05e4120a2cf5efa4b5773bf221bd0fed Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 25 Jan 2017 11:01:35 +0100 Subject: [PATCH 5/5] fix travis --- htdocs/bookmarks/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php index b89dbf291b7..0924f7d8a9b 100644 --- a/htdocs/bookmarks/card.php +++ b/htdocs/bookmarks/card.php @@ -220,7 +220,7 @@ if ($id > 0 && ! preg_match('/^add/i',$action)) $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '' , '', 0, '', '', 0); - + print '
'; print '';