From c460cff01c63df7ab8af295d109917195adc6bc0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 01:17:01 +0200 Subject: [PATCH 1/5] Fix calculation and add tooltip to understand it. --- htdocs/bom/bom_card.php | 2 +- htdocs/bom/class/bom.class.php | 11 ++++++++++- htdocs/langs/en_US/mrp.lang | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 48e9c9d965a..c98dee97f51 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -523,7 +523,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $keyforbreak = 'duration'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - print ''.$langs->trans("TotalCost").''.price($object->total_cost).''; + print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).''; print ''.$langs->trans("UnitCost").''.price($object->unit_cost).''; // Other attributes diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 3e522b3c11f..86e0b84b655 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1013,11 +1013,20 @@ class BOM extends CommonObject $this->unit_cost = 0; $this->total_cost = 0; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + foreach ($this->lines as &$line) { $tmpproduct = new Product($this->db); $tmpproduct->fetch($line->fk_product); + $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); + if (empty($line->unit_cost)) { + if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) + { + $line->unit_cost = $productFournisseur->fourn_unitprice; + } + } - $line->unit_cost = (!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp; // TODO : add option to work with cost_price or pmp $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); $this->total_cost += $line->total_cost; } diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index d3c4d3253c6..faa8eb60cf4 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -74,3 +74,4 @@ ProductsToConsume=Products to consume ProductsToProduce=Products to produce UnitCost=Unit cost TotalCost=Total cost +BOMTotalCost=The cost to produce this BOM based on cost of each quantity and product to consume (use Cost price if defined, else Average Weighted Price if defined, else the Best purchase price) \ No newline at end of file From f2c02f5559b931b2288929f4bd1686114c791aed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 12:41:06 +0200 Subject: [PATCH 2/5] FIX Language for RSS --- htdocs/core/lib/xcal.lib.php | 7 +++++-- htdocs/website/samples/wrapper.php | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 440f1147cbf..3d8120a6d29 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -334,9 +334,10 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $outputfile Output file * @param string $filter (optional) Filter * @param string $url Url (If empty, forge URL for agenda RSS export) + * @param string $langcode Language code to show in header * @return int < 0 if ko, Nb of events in file if ok */ -function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '') +function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '') { global $user, $conf, $langs; global $dolibarr_main_url_root; @@ -362,7 +363,9 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, ''); fwrite($fichier, "\n"); - fwrite($fichier, "\n".$title."\n"); + fwrite($fichier, "\n"); + fwrite($fichier, "".$title."\n"); + if ($langcode) fwrite($fichier, "".$langcode."\n"); /* fwrite($fichier, ""."\n". diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 25483a36f53..bb761c5f894 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -12,6 +12,7 @@ $hashp = GETPOST('hashp', 'aZ09'); $modulepart = GETPOST('modulepart', 'aZ09'); $entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; $original_file = GETPOST("file", "alpha"); +$l = GETPOST('l', 'aZ09'); // Parameters for RSS $rss = GETPOST('rss', 'aZ09'); @@ -90,8 +91,8 @@ if ($rss) { $type = ''; $cachedelay = 0; $filename = $original_file; - $filters = array('type_container'=>'blogpost', 'lang'=>'en_US'); $dir_temp = $conf->website->dir_temp; + include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; $website = new Website($db); @@ -99,6 +100,9 @@ if ($rss) { $website->fetch('', $websitekey); + $filters = array('type_container'=>'blogpost'); + if ($l) $filters['lang'] = $l; + $MAXNEWS = 20; $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); $eventarray = array(); @@ -151,7 +155,7 @@ if ($rss) { @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); // Write file - $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'); + $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); if ($result >= 0) { From e947ddba10be56526118e82ebae5f19f5a4b20ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 12:51:44 +0200 Subject: [PATCH 3/5] Fix RSS feed --- htdocs/website/index.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8a6aa296efb..06c072dc86d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2977,6 +2977,19 @@ if ($action == 'editcss') print ''; + // RSS + print ''; + //$htmlhelp = $langs->trans("Example").' :
'; + //$htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); + $htmlhelp = ''; + print $form->textwithpicto($langs->trans('RSSFeed'), $htmlhelp, 1, 'help', '', 0, 2, 'rsstooltip'); + print ''; + //print $langs->trans("RSS").': '.$form->selectyesno('WEBSITE_ENBALE_RSS', $website->use_rss, 1).'
'; + //$doleditor = new DolEditor('WEBSITE_ENBALE_RSS', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + //print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); + print '/wrapper.php?rss=1[&lang=XX]'; + print ''; + print ''; dol_fiche_end(); From 50d063256e7171363892dd77411d89be7954e782 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 12:54:06 +0200 Subject: [PATCH 4/5] NEW Povide a RSS Feed for blogposts --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 06c072dc86d..7cd0660cdb1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2987,7 +2987,7 @@ if ($action == 'editcss') //print $langs->trans("RSS").': '.$form->selectyesno('WEBSITE_ENBALE_RSS', $website->use_rss, 1).'
'; //$doleditor = new DolEditor('WEBSITE_ENBALE_RSS', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); //print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); - print '/wrapper.php?rss=1[&lang=XX]'; + print '/wrapper.php?rss=1[&l=XX]'; print ''; print ''; From aff2872fc11453f8d635a681f251dfdca4e1ca7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 12:57:58 +0200 Subject: [PATCH 5/5] Fix RSS --- htdocs/langs/en_US/website.lang | 4 +++- htdocs/website/index.php | 11 +++-------- htdocs/website/samples/wrapper.php | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 2c555b40c20..6109f3ca879 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -127,4 +127,6 @@ OtherLanguages=Other languages UseManifest=Provide a manifest.json file PublicAuthorAlias=Public author alias AvailableLanguagesAreDefinedIntoWebsiteProperties=Available languages are defined into website properties -ReplacementDoneInXPages=Replacement done in %s pages or containers \ No newline at end of file +ReplacementDoneInXPages=Replacement done in %s pages or containers +RSSFeed=RSS Feed +RSSFeedDesc=You can get a RSS feed of latest articles with type 'blogpost' using this URL \ No newline at end of file diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 7cd0660cdb1..b6d2404de6f 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2979,15 +2979,10 @@ if ($action == 'editcss') // RSS print ''; - //$htmlhelp = $langs->trans("Example").' :
'; - //$htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); - $htmlhelp = ''; - print $form->textwithpicto($langs->trans('RSSFeed'), $htmlhelp, 1, 'help', '', 0, 2, 'rsstooltip'); + $htmlhelp = $langs->trans('RSSFeedDesc'); + print $form->textwithpicto($langs->trans('RSSFeed'), $htmlhelp, 1, 'help', '', 0, 2, ''); print ''; - //print $langs->trans("RSS").': '.$form->selectyesno('WEBSITE_ENBALE_RSS', $website->use_rss, 1).'
'; - //$doleditor = new DolEditor('WEBSITE_ENBALE_RSS', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); - //print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); - print '/wrapper.php?rss=1[&l=XX]'; + print '/wrapper.php?rss=1[&l=XX][&limit=123]'; print ''; print ''; diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index bb761c5f894..abb2bea0179 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -13,6 +13,7 @@ $modulepart = GETPOST('modulepart', 'aZ09'); $entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; $original_file = GETPOST("file", "alpha"); $l = GETPOST('l', 'aZ09'); +$limit = GETPOST('limit', 'int'); // Parameters for RSS $rss = GETPOST('rss', 'aZ09'); @@ -103,7 +104,7 @@ if ($rss) { $filters = array('type_container'=>'blogpost'); if ($l) $filters['lang'] = $l; - $MAXNEWS = 20; + $MAXNEWS = ($limit ? $limit : 20); $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); $eventarray = array(); if (is_array($arrayofblogs)) {