From 6574ebcbfff349edb806ce46aa1f1c17d95c614b Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 7 Sep 2016 12:40:15 +0200 Subject: [PATCH 01/22] Replace non existing ref parameter Replace non existing ref parameter with product_id and batch to fetch a specific batch from a product. Remove unused sceleton methods. --- .../product/stock/class/productlot.class.php | 104 +----------------- 1 file changed, 5 insertions(+), 99 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 9b15ed31fcc..9ed1e65dde4 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -189,11 +189,12 @@ class Productlot extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $ref Ref + * @param int $product_id Id of product, batch number parameter required + * @param string $batch batch number * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null) + public function fetch($id = 0, $product_id = null, $batch = null) { dol_syslog(__METHOD__, LOG_DEBUG); @@ -213,8 +214,8 @@ class Productlot extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + if ((null !== $product_id) && (null !== $batch)) { + $sql .= ' WHERE t.batch = ' . '\'' . $batch . '\' AND t.fk_product = ' . $product_id; } else { $sql .= ' WHERE t.rowid = ' . $id; } @@ -528,101 +529,6 @@ class Productlot extends CommonObject return - 1; } } - - /** - * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to - * @param integer $notooltip 1=Disable tooltip - * @param int $maxlen Max length of visible user name - * @param string $morecss Add more css on link - * @return string String with URL - */ - function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='') - { - global $langs, $conf, $db; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; - - - $result = ''; - $companylink = ''; - - $label = '' . $langs->trans("MyModule") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - - $link = 'ref . $linkend; - return $result; - } - - /** - * Retourne le libelle du status d'un user (actif, inactif) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->status,$mode); - } - - /** - * Renvoi le libelle d'un status donne - * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function LibStatut($status,$mode=0) - { - global $langs; - - if ($mode == 0) - { - $prefix=''; - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); - } - if ($mode == 2) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 3) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); - } - if ($mode == 4) - { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); - } - if ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); - } - } - /** * Initialise object with example values From 7c772b7608ef0f18c9286960612e4ecdf8ec95c1 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 7 Sep 2016 14:07:29 +0200 Subject: [PATCH 02/22] Fix insert expeditiondet_batch with extrafield Line id of extraflied was used iso expeditiondet --- htdocs/expedition/class/expedition.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index bb8cb9bcdda..93768dce5b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -365,12 +365,13 @@ class Expedition extends CommonObject * @param int $origin_line_id Id of source line * @param int $qty Quantity * @param array $array_options extrafields array - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, line_id if OK */ function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) { global $conf; $error = 0; + $line_id = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet ("; $sql.= "fk_expedition"; @@ -390,6 +391,8 @@ class Expedition extends CommonObject $error++; } + if (! $error) $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { $expeditionline = new ExpeditionLigne($this->db); @@ -403,7 +406,7 @@ class Expedition extends CommonObject } } - if (! $error) return 1; + if (! $error) return $line_id; else return -1; } @@ -432,14 +435,13 @@ class Expedition extends CommonObject // create shipment lines foreach ($stockLocationQty as $stockLocation => $qty) { - if ($this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options) < 0) + if (($line_id = $this->create_line($stockLocation,$line_ext->origin_line_id,$qty,$array_options)) < 0) { $error++; } else { // create shipment batch lines for stockLocation - $line_id= $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); foreach ($tab as $detbatch) { if ($detbatch->entrepot_id == $stockLocation){ From 5de88f6af1f1c74d4088bc816c53fefc4a05a2ed Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 8 Sep 2016 10:09:14 +0200 Subject: [PATCH 03/22] Fix: increase max-width when use externals modules --- htdocs/theme/eldy/style.css.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f474c4463d8..277cf5b9646 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -522,8 +522,8 @@ div.myavailability { } .checkallactions { vertical-align: top; - margin-top: 6px; - margin-left: 4px; + margin-top: 6px; + margin-left: 4px; } .selectlimit { margin-right: 10px !important; @@ -722,7 +722,7 @@ $minwidthtmenu=66; /* minimul widht for one top menu entry */ $heightmenu=46; /* height of top menu, part with image */ $heightmenu2=48; /* height of top menu, part with login */ $disableimages = 0; -$maxwidthloginblock = 110; +$maxwidthloginblock = 130; if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; } ?> From b5db70342bfd94a27c904f355d73b6e251e1b6a6 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 9 Sep 2016 13:58:41 +0200 Subject: [PATCH 04/22] Fix: Search all is lost on lists when pagination or when the columns are sorted --- htdocs/comm/propal/list.php | 2 ++ htdocs/commande/list.php | 1 + htdocs/compta/facture.php | 1 - htdocs/compta/facture/list.php | 1 + htdocs/contact/list.php | 1 + htdocs/contrat/list.php | 2 ++ htdocs/expedition/list.php | 2 ++ htdocs/expensereport/list.php | 1 + htdocs/fichinter/list.php | 1 + htdocs/fourn/commande/list.php | 2 ++ htdocs/product/reassort.php | 25 ++++++++++++++--------- htdocs/product/reassortlot.php | 34 ++++++++++++++++++++----------- htdocs/product/stock/list.php | 30 +++++++++++++++++++-------- htdocs/societe/list.php | 3 ++- htdocs/supplier_proposal/list.php | 4 +++- 15 files changed, 76 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 55d8b49fa46..688cc73f84e 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -255,6 +256,7 @@ if ($result) } $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($sall) $param.='&sall='.$sall; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 401be745957..f9653c06732 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -259,6 +259,7 @@ if ($resql) $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $param=''; + if ($sall) $param.='&sall='.$sall; if ($socid > 0) $param.='&socid='.$socid; if ($viewstatut != '') $param.='&viewstatut='.$viewstatut; if ($orderday) $param.='&orderday='.$orderday; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 659bcaae7c4..34ed1383e14 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -66,7 +66,6 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->margin->enabled)) $langs->load('margins'); -$sall = trim(GETPOST('sall')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fd0a61b638f..205f84c416f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -568,6 +568,7 @@ if ($resql) } $param='&socid='.$socid; + if ($sall) $param.='&sall='.$sall; if ($day) $param.='&day='.$day; if ($month) $param.='&month='.$month; if ($year) $param.='&year=' .$year; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d9fa371e443..8d9c3f0ae64 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -364,6 +364,7 @@ if ($result) $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); + if ($sall != '') $param.='&sall='.urlencode($sall); if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 23df8a06593..4f808e73be3 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -222,6 +223,7 @@ if ($resql) $param.='&search_name='.$search_name; $param.='&search_ref_supplier='.$search_ref_supplier; $param.='&search_sale=' .$search_sale; + if ($sall != '') $param.='&sall='.$sall; if ($optioncss != '') $param.='&optioncss='.$optioncss; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "c.rowid","","$param",'',$sortfield,$sortorder); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 36dfb1db55e..34b452985d5 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -124,6 +125,7 @@ if ($resql) $expedition = new Expedition($db); $param=""; + if ($sall) $param.= "&sall=".$sall; if ($search_ref_exp) $param.= "&search_ref_exp=".$search_ref_exp; if ($search_ref_liv) $param.= "&search_ref_liv=".$search_ref_liv; if ($search_company) $param.= "&search_company=".$search_company; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index efa6572dd10..b24f5fcfe01 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -193,6 +193,7 @@ if ($resql) $i = 0; $param=""; + if ($sall) $param.="&sall=".$sall; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_user) $param.="&search_user=".$search_user; if ($search_amount_ht) $param.="&search_amount_ht=".$search_amount_ht; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 74edaf72099..d01911df6ff 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -139,6 +139,7 @@ if ($result) $num = $db->num_rows($result); $urlparam=''; + if ($sall) $urlparam.="&sall=".$sall; if ($socid) $urlparam.="&socid=".$socid; if ($search_ref) $urlparam.="&search_ref=".urlencode($search_ref); if ($search_company) $urlparam.="&search_company=".urlencode($search_company); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 89060d9f913..1449bd3671b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -208,6 +209,7 @@ if ($resql) $i = 0; $param=""; + if ($sall) $param.="&search_all=".$sall; if ($search_ref) $param.="&search_ref=".$search_ref; if ($search_company) $param.="&search_company=".$search_company; if ($search_user) $param.="&search_user=".$search_user; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b8a52024dfc..436d2c024fa 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -239,24 +239,29 @@ if ($resql) print '
'; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; print ''; // Lignes des titres print ""; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("StockLimit"), $_SERVER["PHP_SELF"], "p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder); // TODO Add info of running suppliers/customers orders //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 87d6d4e46eb..17c0d5a0cfa 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -247,28 +248,37 @@ if ($resql) print $hookmanager->resPrint; print ''; } - - $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref&batch=$batch&eatby=$eatby&sellby=$sellby"; + + $param=''; + if ($tosell) $param.="&tosell=".$tosell; + if ($tobuy) $param.="&tobuy=".$tobuy; + if ($type) $param.="&type=".$type; + if ($fourn_id) $param.="&fourn_id=".$fourn_id; + if ($snom) $param.="&snom=".$snom; + if ($sref) $param.="&sref=".$sref; + if ($search_batch) $param.="&search_batch=".$search_batch; + /*if ($eatby) $param.="&eatby=".$eatby; + if ($sellby) $param.="&sellby=".$sellby;*/ print '
'; // Lignes des titres print ""; - print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "",$param,"",'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label","",$param,"",$sortfield,$sortorder); + if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre($langs->trans("Duration"), $_SERVER["PHP_SELF"], "p.duration","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Warehouse"), $_SERVER["PHP_SELF"], "","",$param,'',$sortfield,$sortorder); //print_liste_field_titre($langs->trans("DesiredStock"), $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Batch"), $_SERVER["PHP_SELF"], "pb.batch","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("l_eatby"), $_SERVER["PHP_SELF"], "pb.eatby","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("l_sellby"), $_SERVER["PHP_SELF"], "pb.sellby","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stock_physique","",$param,'align="right"',$sortfield,$sortorder); // TODO Add info of running suppliers/customers orders //print_liste_field_titre($langs->trans("TheoreticalStock"),$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre(''); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Sell").')',$_SERVER["PHP_SELF"], "p.tosell","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 6d487de21e3..edbc30a5e97 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -107,7 +107,13 @@ if ($result) $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("",$langs->trans("ListOfWarehouses"),$help_url); - print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $totalnboflines); + $param = ''; + if ($search_ref) $param.="&search_ref=".$search_ref; + if ($search_label) $param.="&search_label=".$search_label; + if ($search_status) $param.="&search_status=".$search_status; + if ($sall) $param.="&sall=".$sall; + + print_barre_liste($langs->trans("ListOfWarehouses"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines); print ''; print ''; @@ -122,17 +128,23 @@ if ($result) } $moreforfilter=''; - + + + if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref + if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label + if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; + if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); + print '
'; print ""; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'','','align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("LocationSummary"),$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"), $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValue"), $_SERVER["PHP_SELF"], "e.valo_pmp",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValueSell"), $_SERVER["PHP_SELF"], "",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"], "e.statut",'',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; // Lignes des champs de filtre diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e9b98ad7164..93e757278c6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -429,7 +430,7 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - if ($sall != '') $param = "&sall=".urlencode($sall); + if ($search_all != '') $param = "&sall=".urlencode($search_all); if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ); if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 31589bad334..663b1bb512f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -9,7 +9,8 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador -* + * Copyright (C) 2016 Ferran Marcet + * * 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 * the Free Software Foundation; either version 3 of the License, or @@ -238,6 +239,7 @@ if ($result) } $param='&socid='.$socid.'&viewstatut='.$viewstatut; + if ($sall) $param.='&sall='.$sall; if ($month) $param.='&month='.$month; if ($year) $param.='&year='.$year; if ($search_ref) $param.='&search_ref=' .$search_ref; From 4777faf49bdd70df9f99a3ffd0ce33825b0a420f Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 9 Sep 2016 14:02:27 +0200 Subject: [PATCH 05/22] Fix: Search all is lost on lists when pagination or when the columns are sorted --- htdocs/product/stock/list.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index edbc30a5e97..e46ef0026d6 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -129,12 +129,6 @@ if ($result) $moreforfilter=''; - - if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref - if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label - if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; - if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); - print '
'; print ""; From 66cf9e333ec3b70834a21f9f3aed588fb17497e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 02:58:32 +0200 Subject: [PATCH 06/22] Fix option MAIN_BUTTON_HIDE_UNAUTHORIZED --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/theme/eldy/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index acfc668b879..7cb41b1d708 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -331,7 +331,7 @@ UrlGenerationParameters=Parameters to secure URLs SecurityTokenIsUnique=Use a unique securekey parameter for each URL EnterRefToBuildUrl=Enter reference for object %s GetSecuredUrl=Get calculated URL -ButtonHideUnauthorized=Hide buttons for unauthorized actions instead of showing disabled buttons +ButtonHideUnauthorized=Hide buttons to non admin users for unauthorized actions instead of showing greyed disabled buttons OldVATRates=Old VAT rate NewVATRates=New VAT rate PriceBaseTypeToChange=Modify on prices with base reference value defined on diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6a2a9b80e14..749039a2c92 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2206,7 +2206,7 @@ a.butAction:link, a.butAction:visited, a.butAction:hover, a.butAction:active { } End bootstrap */ -global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?> +global->MAIN_BUTTON_HIDE_UNAUTHORIZED) && (! $user->admin)) { ?> .butActionRefused { display: none; } From d821df070b0a81e10184c1b34a6b237d65113871 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 04:33:23 +0200 Subject: [PATCH 07/22] Fix multicompany: recurring invoice must be in same env than template. --- .../compta/facture/class/facture-rec.class.php | 11 ++++++----- htdocs/compta/facture/class/facture.class.php | 10 ++++++---- htdocs/cron/class/cronjob.class.php | 5 +++++ scripts/cron/cron_run_jobs.php | 18 +++++++++--------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1d75be61f6c..5697c3b7255 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -241,7 +241,7 @@ class FactureRec extends CommonInvoice */ function fetch($rowid, $ref='', $ref_ext='', $ref_int='') { - $sql = 'SELECT f.rowid, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; + $sql = 'SELECT f.rowid, f.entity, f.titre, f.fk_soc, f.amount, f.tva, f.total, f.total_ttc, f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; @@ -269,6 +269,7 @@ class FactureRec extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->titre = $obj->titre; $this->ref = $obj->titre; $this->ref_client = $obj->ref_client; @@ -754,7 +755,7 @@ class FactureRec extends CommonInvoice if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); - while ($i < $num) + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); @@ -774,7 +775,7 @@ class FactureRec extends CommonInvoice $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - $invoiceidgenerated = $facture->create($user); // This will also update fields of recurring invoice + $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { $this->errors = $facture->errors; @@ -794,14 +795,14 @@ class FactureRec extends CommonInvoice if (! $error && $invoiceidgenerated >= 0) { - $db->commit(); + $db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; $this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; } else { - $db->rollback(); + $db->rollback("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); } $i++; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ba4d05712a1..c6a6c298c62 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -239,7 +239,8 @@ class Facture extends CommonInvoice if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; - + if (empty($this->entity)) $this->entity = $conf->entity; + // 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); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); @@ -279,8 +280,9 @@ class Facture extends CommonInvoice $_facrec = new FactureRec($this->db); $result=$_facrec->fetch($this->fac_rec); - $this->socid = $_facrec->socid; - + $this->socid = $_facrec->socid; // Invoice created on same thirdparty than template + $this->entity = $_facrec->entity; // Invoice created in same entity than template + // Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI $this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project; $this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public; @@ -350,7 +352,7 @@ class Facture extends CommonInvoice $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; - $sql.= ", ".$conf->entity; + $sql.= ", ".$this->entity; $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$socid."'"; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 712f4e94234..bd1d74e35b8 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -368,6 +368,7 @@ class Cronjob extends CommonObject $sql = "SELECT"; $sql.= " t.rowid,"; + $sql.= " t.entity,"; $sql.= " t.tms,"; $sql.= " t.datec,"; $sql.= " t.jobtype,"; @@ -442,6 +443,7 @@ class Cronjob extends CommonObject $line->id = $obj->rowid; $line->ref = $obj->rowid; + $line->entity = $obj->entity; $line->tms = $this->db->jdate($obj->tms); $line->datec = $this->db->jdate($obj->datec); $line->label = $obj->label; @@ -896,6 +898,7 @@ class Cronjob extends CommonObject // Update last run date start (to track running jobs) $this->datelastrun=$now; + $this->datelastresult=null; $this->lastoutput=''; $this->lastresult=''; $this->nbrun=$this->nbrun + 1; @@ -1096,6 +1099,8 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); } + dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)"); + $this->datelastresult=dol_now(); $result = $this->update($user); // This include begin/commit if ($result < 0) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index a0f067b5d0c..96450c866a0 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -109,8 +109,8 @@ else { if (empty($user->id)) { - echo "User user login: ".$userlogin." does not exists"; - dol_syslog("User user login:".$userlogin." does not exists", LOG_ERR); + echo "User login: ".$userlogin." does not exists"; + dol_syslog("User login:".$userlogin." does not exists", LOG_ERR); exit(-1); } } @@ -152,22 +152,22 @@ if(is_array($object->lines) && (count($object->lines)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext')); + dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->fetch: ".$cronjob->error; + dol_syslog("cron_run_jobs.php::fetch Error ".$cronjob->error, LOG_ERR); exit(-1); } // Execute job $result=$cronjob->run_jobs($userlogin); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->run_job: ".$cronjob->error; + dol_syslog("cron_run_jobs.php::run_jobs Error ".$cronjob->error, LOG_ERR); exit(-1); } @@ -175,8 +175,8 @@ if(is_array($object->lines) && (count($object->lines)>0)) $result=$cronjob->reprogram_jobs($userlogin, $now); if ($result<0) { - echo "Error:".$cronjob->error; - dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); + echo "Error cronjob->reprogram_job: ".$cronjob->error; + dol_syslog("cron_run_jobs.php::reprogram_jobs Error ".$cronjob->error, LOG_ERR); exit(-1); } From 7c9996c840ee48b8b576e5cb6ff7eb2b74c24810 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 05:25:07 +0200 Subject: [PATCH 08/22] Fix when creating recurring invoice, date next gen was not set --- htdocs/compta/facture/class/facture.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c6a6c298c62..f15526f34ba 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -311,13 +311,15 @@ class Facture extends CommonInvoice $forceduedate = $this->calculate_date_lim_reglement(); - // For recurrn invoices, update date and number of last generation of recurring template invoice, before inserting new invoice + // For recurring invoices, update date and number of last generation of recurring template invoice, before inserting new invoice if ($_facrec->frequency > 0) { + dol_syslog("This is a recurring invoice so we set date_last_gen and next date_when"); + if (empty($_facrec->date_when)) $_facrec->date_when = $now; $next_date = $_facrec->getNextDate(); // Calculate next date - $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); + $result = $_facrec->setValueFrom('date_last_gen', $now, '', null, 'date'); //$_facrec->setValueFrom('nb_gen_done', $_facrec->nb_gen_done + 1); // Not required, +1 already included into setNextDate when second param is 1. - $_facrec->setNextDate($next_date,1); + $result = $_facrec->setNextDate($next_date,1); } } From 41545e0d606d8cbcc1aa2f4ede6ef12b7832db7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 05:26:31 +0200 Subject: [PATCH 09/22] Fix compatibility of recurring invoices with postgresql --- .../facture/class/facture-rec.class.php | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 5697c3b7255..ab797571c70 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -43,6 +43,7 @@ class FactureRec extends CommonInvoice public $table_element_line='facturedet_rec'; public $fk_element='fk_facture'; + var $entity; var $number; var $date; var $amount; @@ -520,6 +521,7 @@ class FactureRec extends CommonInvoice { // Clean parameters $remise_percent=price2num($remise_percent); + if (empty($remise_percent)) $remise_percent=0; $qty=price2num($qty); if (! $qty) $qty=1; if (! $info_bits) $info_bits=0; @@ -580,12 +582,12 @@ class FactureRec extends CommonInvoice $sql.= ", ".price2num($txtva); $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); $sql.= ", ".$product_type; - $sql.= ", '".price2num($remise_percent)."'"; - $sql.= ", '".price2num($pu_ht)."'"; + $sql.= ", ".price2num($remise_percent); + $sql.= ", ".price2num($pu_ht); $sql.= ", null"; - $sql.= ", '".price2num($total_ht)."'"; - $sql.= ", '".price2num($total_tva)."'"; - $sql.= ", '".price2num($total_ttc)."'"; + $sql.= ", ".price2num($total_ht); + $sql.= ", ".price2num($total_tva); + $sql.= ", ".price2num($total_ttc); $sql.= ", ".$rang; $sql.= ", ".$special_code; $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null").")"; @@ -722,14 +724,16 @@ class FactureRec extends CommonInvoice } /** - * Create all recurrents invoices. - * A result may also be provided into this->output + * Create all recurrents invoices (for all entities if multicompany is used). + * A result may also be provided into this->output. + * + * WARNING: This method change context $conf->entity to be in correct context for each recurring invoice found. * * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ function createRecurringInvoices() { - global $langs, $db, $user; + global $conf, $langs, $db, $user; $langs->load("bills"); @@ -744,6 +748,7 @@ class FactureRec extends CommonInvoice $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; + $sql.= $db->order('entity', 'ASC'); //print $sql;exit; $resql = $db->query($sql); @@ -755,6 +760,8 @@ class FactureRec extends CommonInvoice if ($num) $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + $saventity = $conf->entity; + while ($i < $num) // Loop on each template invoice { $line = $db->fetch_object($resql); @@ -764,7 +771,10 @@ class FactureRec extends CommonInvoice $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); - dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); + // Set entity context + $conf->entity = $facturerec->entity; + + dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $error=0; @@ -807,6 +817,8 @@ class FactureRec extends CommonInvoice $i++; } + + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); @@ -1061,7 +1073,7 @@ class FactureRec extends CommonInvoice return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET date_when = "'.$this->db->idate($date).'"'; + $sql.= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; $sql.= ' WHERE rowid = '.$this->id; From 8d3adfd1c9b17782de77156c622c7aa219703cb4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 12:22:23 +0200 Subject: [PATCH 10/22] Fix --- scripts/cron/cron_run_jobs.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 96450c866a0..290bc9ec74c 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -124,8 +124,7 @@ if (isset($argv[3]) || $argv[3]) $object = new Cronjob($db); $filter=array(); -if (empty($id)) { - $filter=array(); +if (! empty($id)) { $filter['t.rowid']=$id; } @@ -152,7 +151,7 @@ if(is_array($object->lines) && (count($object->lines)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); @@ -181,6 +180,10 @@ if(is_array($object->lines) && (count($object->lines)>0)) } } + else + { + dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + } } } From e10c89fba8b01b7845ce2036aa59d497efd0097d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 12:30:01 +0200 Subject: [PATCH 11/22] More log to help debug --- scripts/cron/cron_run_jobs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 290bc9ec74c..1d27f03cff9 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -151,7 +151,7 @@ if(is_array($object->lines) && (count($object->lines)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); @@ -182,7 +182,7 @@ if(is_array($object->lines) && (count($object->lines)>0)) } else { - dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); } } } From 3ecc82b770d3bb5075b3afaa6ce0bc79abee3688 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 13:00:31 +0200 Subject: [PATCH 12/22] Fix error message not reported --- htdocs/user/card.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 032628e4e67..1728b0b170b 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -263,10 +263,7 @@ if (empty($reshook)) { { $langs->load("errors"); $db->rollback(); - if (is_array($object->errors) && count($object->errors)) - { - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; // Go back to create page } } From 530ae91e82b14bd552b19a365fd609675a985c36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 17:35:08 +0200 Subject: [PATCH 13/22] Fix missing information on main supplier proposal card, not on note tab. --- htdocs/supplier_proposal/note.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index a3799c0eb29..981b654599d 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -92,6 +92,16 @@ if ($id > 0 || ! empty($ref)) print ""; print ''; + // Payment term + print ''; + print ''; print ''; From 399addebfbca5513f0eaca345db86cdba12229ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 17:38:26 +0200 Subject: [PATCH 14/22] FIX alignement of intervention status --- htdocs/fichinter/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 5d88dd78977..6c74c12b3a4 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -274,7 +274,7 @@ if ($result) print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"f.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.fk_statut","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; From 926e3fc6f989b5a26756c5e83ab58d5618372d41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 17:43:28 +0200 Subject: [PATCH 15/22] Fix date must be with standard format --- htdocs/compta/facture.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 32333d2f1e1..17184207743 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3135,10 +3135,10 @@ else if ($id > 0 || ! empty($ref)) if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date, 'invoicedate'); } else { - print dol_print_date($object->date, 'daytext'); + print dol_print_date($object->date, 'day'); } } else { - print dol_print_date($object->date, 'daytext'); + print dol_print_date($object->date, 'day'); } print ''; @@ -3476,7 +3476,7 @@ else if ($id > 0 || ! empty($ref)) if ($action == 'editdate_pointoftax') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_pointoftax, 'date_pointoftax'); } else { - print dol_print_date($object->date_pointoftax, 'daytext'); + print dol_print_date($object->date_pointoftax, 'day'); } print ''; } @@ -3516,7 +3516,7 @@ else if ($id > 0 || ! empty($ref)) if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->date_lim_reglement, 'paymentterm'); } else { - print dol_print_date($object->date_lim_reglement, 'daytext'); + print dol_print_date($object->date_lim_reglement, 'day'); if ($object->hasDelay()) { print img_warning($langs->trans('Late')); } From 79f19f5c66349880c26c77a25f3605c86fa13db6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Sep 2016 17:48:57 +0200 Subject: [PATCH 16/22] Fix missing a filter billed=0 into link of billable orders --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a844cbfed3b..94361d60da6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -838,7 +838,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->commande->enabled)) { $langs->load("orders"); - if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); + if (! empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3&billed=0", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); // if (empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); } From 9709c8bbbf0cb572cc6509fcc59af9701230aeab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Sep 2016 13:48:05 +0200 Subject: [PATCH 17/22] FIX inversion customer/supplier price --- htdocs/fourn/card.php | 5 ++++- htdocs/supplier_proposal/card.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index f03e511f8d0..8e74648500b 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -334,7 +334,10 @@ if ($object->id > 0) print ''; - print ''; + print ''; print ''; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 75e3ab23110..f99a961055f 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1659,7 +1659,7 @@ if ($action == 'create') print '
".$langs->trans("Supplier")."'.$object->thirdparty->getNomUrl(1).'
'; + print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print '
'; + print '
'; + $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); + print '
'.$langs->trans('SupplierProposalDate').''; print dol_print_date($object->date_livraison,'daytext'); print '
'; print $productstatic->getNomUrl(1); print ''; + print ''; + print $productstatic->ref; + print ''; print dol_trunc(dol_htmlentities($objp->label), 30); print ''.dol_print_date($objp->tms).'
'; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); // Form to add new line if ($object->statut == 0 && $user->rights->supplier_proposal->creer) @@ -1669,7 +1669,7 @@ if ($action == 'create') $var = true; // Add products/services form - $object->formAddObjectLine(1, $mysoc, $soc); + $object->formAddObjectLine(1, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From 08dc7ade3b7840d594638e4e36f78de8af407ea1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Sep 2016 14:04:03 +0200 Subject: [PATCH 18/22] Fix list of supplier price must show price compared to quantity. --- htdocs/fourn/card.php | 28 ++++++++++++++++++++-------- htdocs/fourn/product/list.php | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 8e74648500b..71f86cf0fe5 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -298,22 +298,22 @@ if ($object->id > 0) $langs->load("products"); print '
'; print ''; - print ''; //Query from product/liste.php - $sql = 'SELECT p.rowid, p.ref, p.label, pfp.tms,'; - $sql.= ' p.fk_product_type, p.entity'; + $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,'; + $sql.= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= ' AND pfp.fk_soc = '.$object->id; $sql .= $db->order('pfp.tms', 'desc'); $sql.= $db->plimit($MAXLIST); - $query = $db->query($sql); - + if (! $query) dol_print_error($db); + $return = array(); if ($db->num_rows($query)) { @@ -335,12 +335,24 @@ if ($object->id > 0) print $productstatic->getNomUrl(1); print ''; print ''; - print ''; - print ''; + //print ''; + print ''; print ''; } } diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 6a4f2255f6b..95ff1620691 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -23,7 +23,7 @@ /** * \file htdocs/fourn/product/list.php * \ingroup produit - * \brief Page liste des produits ou services + * \brief Page to list supplier products and services */ require '../../main.inc.php'; From 1bb278a5872a8a6a03318c31d321788f681bf41e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Sep 2016 16:05:38 +0200 Subject: [PATCH 19/22] Fix #5712 --- htdocs/core/class/html.form.class.php | 37 ++- htdocs/core/tpl/objectline_create.tpl.php | 25 +- .../class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 186 +---------- htdocs/product/ajax/products.php | 10 +- htdocs/product/class/product.class.php | 24 +- htdocs/supplier_proposal/card.php | 310 +++++++++--------- 7 files changed, 227 insertions(+), 367 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 40b03f2286a..152cc0502dd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2060,9 +2060,10 @@ class Form * @param string $filtre For a SQL filter * @param array $ajaxoptions Options for ajax_autocompleter * @param int $hidelabel Hide label (0=no, 1=yes) + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices * @return void */ - function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0) + function select_produits_fournisseurs($socid, $selected='', $htmlname='productid', $filtertype='', $filtre='', $ajaxoptions=array(), $hidelabel=0, $alsoproductwithnosupplierprice=0) { global $langs,$conf; global $price_level, $status, $finished; @@ -2084,7 +2085,7 @@ class Form print ''; } // mode=2 means suppliers products - $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished; + $urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); print ($hidelabel?'':$langs->trans("RefOrLabel").' : ').''; } @@ -2095,7 +2096,7 @@ class Form print ''; print ''; } - print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0); + print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice); } } @@ -2111,9 +2112,10 @@ class Form * @param int $statut -1=Return all products, 0=Products not on sell, 1=Products on sell (not used here, a filter on tobuy is already hard coded in request) * @param int $outputmode 0=HTML select string, 1=Array * @param int $limit Limit of line number + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices * @return array Array of keys for json */ - function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100) + function select_produits_fournisseurs_list($socid,$selected='',$htmlname='productid',$filtertype='',$filtre='',$filterkey='',$statut=-1,$outputmode=0,$limit=100,$alsoproductwithnosupplierprice=0) { global $langs,$conf,$db; @@ -2167,7 +2169,7 @@ class Form $num = $this->db->num_rows($result); //$out.=''; + $out.=' + '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $line = $object->lines[$i]; - $var=!$var; - - // Show product and description - $type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0)); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - $date_start=''; - $date_end=''; - if (! empty($line->date_start)) - { - $date_start=$line->date_start; - $type=1; - } - if (! empty($line->date_end)) - { - $date_end=$line->date_end; - $type=1; - } - - // Edit line - if ($action != 'editline' || $_GET['rowid'] != $line->id) - { - print ''; - - // Show product and description - print ''; - - print ''; - - print '\n"; - - print ''; - - if ($line->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - - print ''; - - if (is_object($hookmanager)) - { - $parameters=array('line'=>$line,'num'=>$num,'i'=>$i); - $reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$object,$action); - } - - if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) - { - print ''; - - $actiondelete='delete_product_line'; - print ''; - } - else - { - print ''; - } - print ""; - } - - // Edit line - if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id)) - { - print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - } - $i++; - } -*/ // Form to add new line if ($object->statut == 0 && $user->rights->fournisseur->commande->creer) { diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 85990fe1bd4..c399d222177 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -49,6 +49,8 @@ $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); $price_by_qty_rowid = GETPOST('pbq', 'int'); $finished = GETPOST('finished', 'int'); +$alsoproductwithnosupplierprice = GETPOST('alsoproductwithnosupplierprice', 'int'); + /* * View @@ -157,7 +159,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } echo json_encode($outjson); -} else { +} +else +{ require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; $langs->load("products"); @@ -181,9 +185,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $form = new Form($db); if (empty($mode) || $mode == 1) { // mode=1: customer - $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); + $arrayresult = $form->select_produits_list("", $htmlname, $type, 0, $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { // mode=2: supplier - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, 0, $alsoproductwithnosupplierprice); } $db->close(); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1b94b00d1bf..b68193a2078 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1309,16 +1309,17 @@ class Product extends CommonObject /** - * Read price used by a provider - * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref + * Read price used by a provider. + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. + * This also set some properties on product like ->buyprice, ->fourn_pu, ... * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param double $qty Quantity asked * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier ref + * @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search. * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ - function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) + function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='') { global $conf; $result = 0; @@ -1328,8 +1329,9 @@ class Product extends CommonObject $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$prodfournprice; - if ($qty) $sql.= " AND pfp.quantity <= ".$qty; - + if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; + $sql.= " ORDER BY pfp.quantity DESC"; + dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -1362,13 +1364,13 @@ class Product extends CommonObject } else // If not found { - // We do a second search by doing a select again but searching with qty, ref and id product + // We do a second search by doing a select again but searching with qty and id product $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; - $sql.= " AND pfp.fk_product = ".$product_id; - $sql.= " AND pfp.quantity <= ".$qty; + $sql.= " WHERE pfp.fk_product = ".$product_id; + if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; + if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; $sql.= " LIMIT 1"; @@ -1405,7 +1407,7 @@ class Product extends CommonObject } else { - return -1; // Ce produit n'existe pas avec cette ref fournisseur ou existe mais qte insuffisante + return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. } } else diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index f99a961055f..4bd141da1a7 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -25,6 +25,12 @@ * along with this program. If not, see . */ +/** + * \file htdocs/supplier_proposal/card.php + * \ingroup supplier_proposal + * \brief Card supplier proposal + */ + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; @@ -96,6 +102,8 @@ if ($id > 0 || ! empty($ref)) { $hookmanager->initHooks(array('supplier_proposalcard','globalcard')); $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink=$user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit=$user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php /* @@ -354,10 +362,10 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); - $array_option = $lines[$i]->array_options; + $array_options = $lines[$i]->array_options; } - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_option); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options); if ($result > 0) { $lineid = $result; @@ -511,22 +519,28 @@ if (empty($reshook)) } } - // Add line - else if ($action == 'addline' && $user->rights->supplier_proposal->creer) { + // Add a product line + if ($action == 'addline' && $user->rights->supplier_proposal->creer) + { + $langs->load('errors'); + $error = 0; // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $price_ht = GETPOST('price_ht'); - + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; + $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod=GETPOST('idprod', 'int'); + $price_ht = ''; $tva_tx = ''; } @@ -536,7 +550,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -559,8 +573,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error ++; } - - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (! $error && ($qty >= 0)) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -571,150 +584,140 @@ if (empty($reshook)) // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit - if (! empty($idprod)) { - $prod = new Product($db); - $prod->fetch($idprod); + if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + { + $productsupplier = new ProductFournisseur($db); + + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) + { + $idprod=0; + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + } + if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg)) + { + $idprod=$reg[1]; + // Call to init properties of $productsupplier + // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price + $productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist + } + elseif (GETPOST('idprodfournprice') > 0) + { + //$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat. + $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist + } + + + if ($idprod > 0) + { + $res=$productsupplier->fetch($idprod); + + $label = $productsupplier->label; + + $desc = $productsupplier->description; + if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); + + $type = $productsupplier->type; + + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); + if (empty($tva_tx)) $tva_npr=0; + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + + $result=$object->addline( + $desc, + $productsupplier->fourn_pu, + $qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $productsupplier->id, + $remise_percent, + $type, + $productsupplier->price_ttc, + $tva_npr, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label, + $array_options, + $ref_fourn + ); + } + if ($idprod == -99 || $idprod == 0) + { + // Product not selected + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), null, 'errors'); + } + if ($idprod == -1) + { + // Quantity too low + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'errors'); + } + } + else if((GETPOST('price_ht')!=='' || GETPOST('price_ttc')!=='') && empty($error)) // Free product + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + $desc = $product_desc; + $type = GETPOST('type'); - $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); - - // If prices fields are update - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); - $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; - - //On garde le prix indiqué dans l'input pour la demande de prix fournisseur - //$pu_ht = $prod->price; - $pu_ht = price2num($price_ht, 'MU'); - //$pu_ttc = $prod->price_ttc; - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) - { - $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; - $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; - } - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - - $prodcustprice = new Productcustomerprice($db); - - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - - $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); - if ($result) { - if (count($prodcustprice->lines) > 0) { - $pu_ht = price($prodcustprice->lines [0]->price); - $pu_ttc = price($prodcustprice->lines [0]->price_ttc); - $price_base_type = $prodcustprice->lines [0]->price_base_type; - $prod->tva_tx = $prodcustprice->lines [0]->tva_tx; - } - } - } - - // if price ht is forced (ie: calculated by margin rate and cost price) - if (! empty($price_ht)) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tva_tx != $prod->tva_tx) { - if ($price_base_type != 'HT') { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); - } else { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU'); - } - } - - $desc = ''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); - if (empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; - } else { - $desc = $prod->description; - } - - $desc = dol_concatdesc($desc, $product_desc); - - // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); - $tmptxt .= ')'; - $desc = dol_concatdesc($desc, $tmptxt); - } - - $type = $prod->type; - } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - $desc = $product_desc; - $type = GETPOST('type'); + $fk_unit= GETPOST('units', 'alpha'); + + $tva_tx = price2num($tva_tx); // When vat is text input field + + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + + if (GETPOST('price_ht')!=='') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + $ttc = 0; + } + else + { + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($tva_tx / 100)); + $price_base_type = 'HT'; + } + + $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn); + //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } - // Margin - $fournprice = (GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = (GETPOST('buying_price' . $predef) ? GETPOST('buying_price' . $predef) : ''); - // Local Taxes - $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - - $info_bits = 0; - if ($tva_npr) - $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessages($mesg, null, 'errors'); - } else { - // Insert line - $ref_fourn = GETPOST('fourn_ref'); - $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_option, $ref_fourn); - - if ($result > 0) { + if (! $error && $result > 0) + { $db->commit(); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id') ? GETPOST('lang_id') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } + $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db,$result); } unset($_POST['prod_entry_mode']); @@ -722,18 +725,23 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); + unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); unset($_POST['tva_tx']); + unset($_POST['label']); unset($_POST['product_ref']); unset($_POST['product_label']); unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + unset($localtax1_tx); + unset($localtax2_tx); unset($_POST['np_marginRate']); unset($_POST['np_markRate']); unset($_POST['dp_desc']); + unset($_POST['idprodfournprice']); unset($_POST['idprod']); unset($_POST['date_starthour']); @@ -748,12 +756,14 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } else { - $db->rollback(); + } + else + { + $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - } + setEventMessages($object->error, $object->errors, 'errors'); } + //} } } @@ -781,7 +791,7 @@ if (empty($reshook)) // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_option = $extrafieldsline->getOptionalsFromPost($extralabelsline); + $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -826,7 +836,7 @@ if (empty($reshook)) if (! $error) { $db->begin(); $ref_fourn = GETPOST('fourn_ref'); - $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_option, $ref_fourn); + $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_options, $ref_fourn); if ($result >= 0) { $db->commit(); @@ -1658,6 +1668,10 @@ if ($action == 'create') print '
'.$langs->trans("ProductsAndServices").''; + print ''.$langs->trans("ProductsAndServices").''; print ''.$langs->trans("All").' '.$object->nbOfProductRefs().''; print '
'; - print $productstatic->ref; + print $objp->supplier_ref; print ''; + print ''; print dol_trunc(dol_htmlentities($objp->label), 30); print ''.dol_print_date($objp->tms).''.dol_print_date($objp->tms, 'day').''; + //print (isset($objp->unitprice) ? price($objp->unitprice) : ''); + if (isset($objp->price)) + { + print price($objp->price); + if ($objp->quantity > 1) + { + print ' / '; + print $objp->quantity; + } + } + print '
rights->fournisseur->commande->creer) { $langs->load('errors'); @@ -426,8 +424,8 @@ if (empty($reshook)) $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1,$mysoc,$object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2,$mysoc,$object->thirdparty); + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if (GETPOST('price_ht')!=='') { @@ -2080,184 +2078,6 @@ elseif (! empty($object->id)) $num = count($object->lines); -/* - $i = 0; $total = 0; - if ($num) - { - print '
'.$langs->trans('Label').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('Qty').''.$langs->trans('ReductionShort').''.$langs->trans('TotalHTShort').' 
'; - if ($line->fk_product > 0) - { - print ''; // ancre pour retourner sur la ligne - - $product_static=new ProductFournisseur($db); - $product_static->fetch($line->fk_product); - $text=$product_static->getNomUrl(1,'supplier'); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($date_start,$date_end); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($line->description && $line->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($line->description):''; - } - - // Description - Editor wysiwyg - if (! $line->fk_product) - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($line->description); - - // Show range - print_date_range($date_start,$date_end); - } - - print '
'.vatrate($line->tva_tx).'%'.price($line->subprice)."'.$line->qty.''.dol_print_reduction($line->remise_percent,$langs)." '.price($line->total_ht).'id.'#'.$line->id.'">'; - print img_edit(); - print ''; - print img_delete(); - print '  
'; - - print ''; - - print ''; // ancre pour retourner sur la ligne - if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && $line->fk_product > 0) - { - $product_static=new ProductFournisseur($db); - $product_static->fetch($line->fk_product); - $text=$product_static->getNomUrl(1,'supplier'); - $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($date_start,$date_end); - print '
'; - } - else - { - $forceall=1; // For suppliers, we always show all types - print $form->select_type_of_lines($line->product_type,'type',1,0,$forceall); - if ($forceall || (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) - || (empty($conf->product->enabled) && empty($conf->service->enabled))) print '
'; - } - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>$line->fk_parent_line, 'line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i); - $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action); - } - - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - - print '
'; - print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); - print ' '.$langs->trans('to').' '; - print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,'',1,0,1); - - print '
'; - print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc); - print '%'; - print '
'; + // Add free products/services form + global $forceall, $senderissupplier, $dateSelector; + $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. + if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); From 828fe984e88cbbe29adb1d48a35f496b63a3c870 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2016 00:09:46 +0200 Subject: [PATCH 20/22] FIX #5734 --- .../restler/framework/Luracast/Restler/CommentParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php index 666c2e57fd4..e8248a385fa 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php @@ -482,7 +482,7 @@ class CommentParser $r['name'] = substr($data, 1); } } - if (isset($r['type']) && Text::endsWith($r['type'], '[]')) { + if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) { $r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2); $r['type'] = 'array'; } From 4ea50689665194669359230461e511299a815e46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2016 00:15:27 +0200 Subject: [PATCH 21/22] FIX Clean of search fields --- htdocs/product/stock/list.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index a1f19958cc9..c7fe0324327 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent * @@ -59,6 +59,21 @@ $fieldstosearchall = array( ); +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=""; + $sall=""; + $search_label=""; + $search_status=""; + $search_array_options=array(); +} + /* * View From da41c3ffa7935c8c7de108f9838d9003eb93e454 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Sep 2016 01:10:58 +0200 Subject: [PATCH 22/22] Fix better fix to increase size of login_block to allow external icon. --- htdocs/theme/eldy/style.css.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 277cf5b9646..414d7af4fcd 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -718,7 +718,7 @@ img.photoref { /* ============================================================================== */ , fontsize= */ /* rule to reduce top menu - 1st reduction */ -@media only screen and (max-width: px) +@media only screen and (max-width: px) { div.tmenucenter { max-width: px; /* size of viewport */ @@ -4084,10 +4085,16 @@ img.demothumb { padding-: 78px; } + div.login_block_user { + min-width: 0; + } div.login_block { top: 4px; max-width: 82px; } + .login_block_elem { + padding: 0 !important; + } li.tmenu, li.tmenusel { min-width: 30px; }