From 74a2a4c257dd11948453d52b3f0b07dc2bdbb7e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 12:34:18 +0200 Subject: [PATCH 1/5] Better translation --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 7d96aba7d8f..3c10edc86ca 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1400,7 +1400,7 @@ CompressionOfResources=Compression of HTTP responses CompressionOfResourcesDesc=For exemple using the Apache directive "AddOutputFilterByType DEFLATE" TestNotPossibleWithCurrentBrowsers=Such an automatic detection is not possible with current browsers DefaultValuesDesc=You can define/force here the default value you want to get when your create a new record, and/or defaut filters or sort order when your list record. -DefaultCreateForm=Default values for new objects +DefaultCreateForm=Default values for creation form DefaultSearchFilters=Default search filters DefaultSortOrder=Default sort orders DefaultFocus=Default focus fields From e14087845883657bcf4e9469480d4c7ac9845fb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 13:00:09 +0200 Subject: [PATCH 2/5] NEW Can import local tax rates in prices --- htdocs/core/modules/modProduct.class.php | 9 +++++++-- htdocs/langs/en_US/main.lang | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index f51e69039e9..79541c10105 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -260,10 +260,12 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); + $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation'); if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type')); if (! empty($conf->barcode->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.barcode'=>'BarCode')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields @@ -300,9 +302,12 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r]=array('sp.fk_product'=>"ProductOrService*", 'sp.fk_soc'=>"Supplier*", 'sp.ref_fourn'=>'SupplierRef', 'sp.quantity'=>"QtyMin*", 'sp.tva_tx'=>'VATRate', 'sp.price'=>"PriceQtyMinHT*", - 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this file not required and calculate it from price and qty + 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' ); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.recuperableonly'=>'NPR')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_convertvalue_array[$r]=array( 'sp.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty'), diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 93d2542ea69..93616b6151c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -376,7 +376,9 @@ VATIN=IGST VATs=Sales taxes VATINs=IGST taxes LT1=Sales tax 2 +LT1Type=Sales tax 2 type LT2=Sales tax 3 +LT2Type=Sales tax 3 type LT1ES=RE LT2ES=IRPF LT1IN=CGST From d1bee67b40a1f1bcf2a56e0b47c7cb5636f590c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 13:09:19 +0200 Subject: [PATCH 3/5] FIX #3991 --- htdocs/core/class/html.formmail.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3e09c1a83e8..dab36ec250d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -907,8 +907,8 @@ class FormMail extends Form /** - * Return templates of email with type = $type_template or type = 'all' - * This search into table c_email_templates. + * Return templates of email with type = $type_template or type = 'all'. + * This search into table c_email_templates. Used by the get_form function. * * @param DoliDB $db Database handler * @param string $type_template Get message for type=$type_template, type='all' also included. @@ -918,7 +918,7 @@ class FormMail extends Form * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return array array('topic'=>,'content'=>,..) */ - private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) { $ret=array(); From d7dd6ed3344a79fa8ec10063f1d9f6f71404df1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 16:07:46 +0200 Subject: [PATCH 4/5] Fix undefined var --- htdocs/core/class/html.formmail.class.php | 7 ++++--- htdocs/core/lib/functions.lib.php | 4 +++- htdocs/expedition/card.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/user/card.php | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index dab36ec250d..e1df1156239 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -329,6 +329,7 @@ class FormMail extends Form $out.= ''."\n"; } + $modelmail_array=array(); if ($this->param['models'] != 'none') { $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); @@ -336,7 +337,6 @@ class FormMail extends Form { setEventMessages($this->error, $this->errors, 'errors'); } - $modelmail_array=array(); foreach($this->lines_model as $line) { $langs->trans("members"); @@ -1076,11 +1076,11 @@ class FormMail extends Form * @return void * @see getCommonSubstitutionArray */ - function setSubstitFromObject($object, $outputlangs=null) + function setSubstitFromObject($object, $outputlangs) { global $conf, $user; - $parameters=array('mode'=>$mode); + $parameters=array(); $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($tmparray, $outputlangs, null, $parameters); @@ -1135,6 +1135,7 @@ class FormMail extends Form { global $conf, $langs; + $tmparray=array(); if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { $parameters=array('mode'=>$mode); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c3c80a3c54a..ba8e9f4d085 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5280,10 +5280,12 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob // TODO USe this ? $msgishtml = 0; + $birthday = dol_print_date($object->birth,'day'); + if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($langs)):$object->getFullName($langs); + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 17777e6e228..ef4bf2a9a70 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2221,7 +2221,7 @@ else if ($id || $ref) $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__SHIPPINGREF__']=$object->ref; $formmail->substit['__SHIPPINGTRACKNUM__']=$object->tracking_number; $formmail->substit['__SHIPPINGTRACKNUMURL__']=$object->tracking_url; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 7ef847855e5..dae399a9907 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -542,7 +542,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit ['__ORDERREF__'] = $object->ref; $custcontact = ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3b56046e55f..236faaaa232 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2485,7 +2485,7 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Array of substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__THIRDPARTY_ID__']=$object->id; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__THIRDPARTY_NAME__']=$object->name; // substit in setSubstitFromObject was wrong for this one $formmail->substit['__PERSONALIZED__']=''; // deprecated diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 273c71d8e8c..40fa4db7a37 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1760,7 +1760,7 @@ else $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions - $formmail->setSubstitFromObject($object); + $formmail->setSubstitFromObject($object, $outputlangs); $formmail->substit['__LASTNAME__']=$object->lastname; $formmail->substit['__FIRSTNAME__']=$object->firstname; From 7178bf013271fcf374cb01c90b920a30a9bc0e7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2017 16:56:33 +0200 Subject: [PATCH 5/5] Work on direct external link for dolibarr objects --- htdocs/compta/facture/class/facture.class.php | 11 +++++++++-- htdocs/document.php | 2 +- .../modulebuilder/template/class/myobject.class.php | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b6d294c6e18..b7603400c61 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1059,13 +1059,20 @@ class Facture extends CommonInvoice */ function getDirectExternalLink($withpicto=0) { + global $dolibarr_main_url_root; + // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $url='eee'; - return ''.$this->ref.''; + // TODO Read into ecmfile table to get entry and hash exists (PS: If not found, add it) + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + //$result = $ecmfile->get(); + + $hashp='todo'; + return ''.$this->ref.''; } /** diff --git a/htdocs/document.php b/htdocs/document.php index 11017f52cc2..0b2db2323cd 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -25,7 +25,7 @@ * \file htdocs/document.php * \brief Wrapper to download data files * \remarks Call of this wrapper is made with URL: - * document.php?modulepart=repfichierconcerne&file=pathrelatifdufichier + * document.php?modulepart=repfichierconcerne&file=relativepathoffile * document.php?modulepart=logs&file=dolibarr.log */ diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 259db698024..4a5f349215b 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -324,6 +324,17 @@ class MyObject extends CommonObject return $result; } + /** + * Return link to download file from a direct external access + * + * @param int $withpicto Add download picto into link + * @return string HTML link to file + */ + function getDirectExternalLink($withpicto=0) + { + return 'todo'; + } + /** * Retourne le libelle du status d'un user (actif, inactif) *