From 09810395730dd121f6d7ece94756875d2b8bb2ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 10:57:18 +0200 Subject: [PATCH 1/8] FIX If stock module not enabled, it was not possible to make shipments --- htdocs/expedition/card.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 4c71256baf3..df79fd358c9 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -150,6 +150,7 @@ if (empty($reshook)) $action = 'edit_extras'; } + // Create shipment if ($action == 'add' && $user->rights->expedition->creer) { $error=0; @@ -251,7 +252,7 @@ if (empty($reshook)) } else { - //var_dump($_POST); var_dump($batch); + //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; //shipment line for product with no batch management and no multiple stock location if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); } @@ -283,7 +284,8 @@ if (empty($reshook)) if (isset($stockLine[$i])) { //shipment from multiple stock locations - for($j = 0; $j < count($stockLine[$i]); $j++) + $nbstockline = count($stockLine[$i]); + for($j = 0; $j < $nbstockline; $j++) { if ($stockLine[$i][$j]['qty']>0) { @@ -721,6 +723,7 @@ if ($action == 'create') dol_fiche_end(); + // Shipment lines $numAsked = count($object->lines); @@ -873,8 +876,9 @@ if ($action == 'create') $warehouse_id = GETPOST('entrepot_id','int'); $warehouseObject = null; - if ($warehouse_id > 0 || ! ($line->fk_product > 0)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection + if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection { + print ''; //ship from preselected location $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number $deliverableQty=min($quantityToBeDelivered, $stock); @@ -984,7 +988,8 @@ if ($action == 'create') } else { - print ''; + print ''; + print ''; print ' '; print ''; @@ -1000,10 +1005,11 @@ if ($action == 'create') if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { print ''; // end line and start a new one for each warehouse - + print ''; + print ''; $subj=0; - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock { $warehouseObject=new Entrepot($db); $warehouseObject->fetch($warehouse_id); @@ -1049,7 +1055,7 @@ if ($action == 'create') print "\n"; } } - // Show subproducts of product + // Show subproducts of product (not recommanded) if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0) { $product->get_sousproduits_arbo(); @@ -1116,7 +1122,8 @@ if ($action == 'create') } if ($subj == 0) // Line not shown yet, we show it { - print ''; + print ''; + print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { //$disabled='disabled="disabled"'; @@ -1152,7 +1159,8 @@ if ($action == 'create') //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) { + if (is_array($extralabelslines) && count($extralabelslines)>0) + { $colspan=5; $line = new ExpeditionLigne($db); $line->fetch_optionals($object->id,$extralabelslines); From c340745b789248201a9c6b2981bce59f915f7a1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 11:05:15 +0200 Subject: [PATCH 2/8] FIX Option "showstock" was not effective into warehouse list --- htdocs/expedition/card.php | 3 ++- htdocs/product/class/html.formproduct.class.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index df79fd358c9..b3b889f7822 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -907,7 +907,8 @@ if ($action == 'create') $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id; if ($line->fk_product > 0) { - print $formproduct->selectWarehouses($tmpentrepot_id,'entl'.$indiceAsked,'',1,0,$line->fk_product); + print ''; + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1); if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id) { //print $stock.' '.$quantityToBeDelivered; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 6b64b625e53..24a7506882b 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -165,7 +165,7 @@ class FormProduct if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out.=' selected'; $out.='>'; $out.=$arraytypes['label']; - if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0)) $out.='('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; + if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) $out.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')'; $out.=''; } $out.=''; From 9eb19258255a7154b01b655525ee37aec6d5293d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 11:12:49 +0200 Subject: [PATCH 3/8] FIX No need to ask doc template when only one is defined --- htdocs/expedition/card.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b3b889f7822..2e15e926ce4 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -712,13 +712,16 @@ if ($action == 'create') } // Document model - print "".$langs->trans("Model").""; - print ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/expedition/modules_expedition.php'; $liste = ModelePdfExpedition::liste_modeles($db); - print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); - print "\n"; - + if (count($liste) > 1) + { + print "".$langs->trans("Model").""; + print ''; + print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); + print "\n"; + } + print ""; dol_fiche_end(); From 063905ea036f7e4a7f456e1caf36ea4f8f2edeb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 11:43:11 +0200 Subject: [PATCH 4/8] Save space again (another line won) --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 2e15e926ce4..6915594dd92 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -608,7 +608,7 @@ if ($action == 'create') print ''; // Ref - print ''; print ''; From 8a1358d539464d212e5280876195775bbb7c3cf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 12:26:42 +0200 Subject: [PATCH 6/8] FIX Some records were lost into margin per product report --- htdocs/langs/en_US/products.lang | 1 + htdocs/margin/productMargins.php | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 33b536d3ab3..4b4031b497d 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -171,6 +171,7 @@ PredefinedProductsAndServicesToSell=Predefined products/services to sell PredefinedProductsToPurchase=Predefined product to purchase PredefinedServicesToPurchase=Predefined services to purchase PredefinedProductsAndServicesToPurchase=Predefined products/services to puchase +NotPredefinedProducts=Not predefined products/services GenerateThumb=Generate thumb ProductCanvasAbility=Use special "canvas" addons ServiceNb=Service #%s diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 2e550a74720..789932320e5 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -165,16 +165,15 @@ print ''; $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; -$sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; +$sql.= " SUM(d.total_ht) as selling_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_soc = s.rowid"; -$sql.= " AND d.fk_product = p.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) @@ -186,8 +185,8 @@ if (!empty($enddate)) $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; -else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref"; +if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; $sql.=$db->order($sortfield,$sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -260,13 +259,20 @@ if ($result) } else { print '\n"; //print "\n"; } From 9c394b58b534f43142b79fb2cbd682b525110fa9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 12:40:34 +0200 Subject: [PATCH 7/8] Move help text at better place. --- htdocs/admin/confexped.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index 85682960df9..bf4a09c0ada 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -131,7 +131,10 @@ print ''; // Bon de livraison activation/desactivation $var=!$var; print ''; -print ''; +print ''; print ''; print '
'; + print '
'; if ($origin == 'commande' && ! empty($conf->commande->enabled)) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; From 27ed9ba3dad3c34d9c08ba02fca22014448132d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 12:13:43 +0200 Subject: [PATCH 5/8] Remove now link useless here --- htdocs/compta/bank/account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index b1bf6cd4270..67af1a773a0 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -521,9 +521,9 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - $period_filter .= $langs->trans('From').' '.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,1,1); + $period_filter .= $langs->trans('From').' '.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,0,1); $period_filter .= ' '; - $period_filter .= $langs->trans('to').' '.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,1,1); + $period_filter .= $langs->trans('to').' '.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,0,1); print '
'.$period_filter.''; - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->rowid; - $product_static->ref=$objp->ref; - $product_static->label=$objp->label; - $product_static->entity=$objp->pentity; - $text=$product_static->getNomUrl(1); - print $text.= ' - '.$objp->label; + if ($objp->rowid > 0) + { + $product_static->type=$objp->fk_product_type; + $product_static->id=$objp->rowid; + $product_static->ref=$objp->ref; + $product_static->label=$objp->label; + $product_static->entity=$objp->pentity; + $text=$product_static->getNomUrl(1); + print $text.= ' - '.$objp->label; + } + else + { + print $langs->trans("NotPredefinedProducts"); + } print "".$product_static->getNomUrl(1)."
'.$langs->trans("DeliveriesOrderAbility").''; +print $langs->trans("DeliveriesOrderAbility"); +print '
'.info_admin($langs->trans("NoNeedForDeliveryReceipts"), 0, 1); +print '
'; print ''; @@ -151,7 +154,5 @@ print '
'; print ''; -print info_admin($langs->trans("NoNeedForDeliveryReceipts")); - llxFooter(); $db->close(); From 081c7824d2aceae106ce56524b4fb4e7af78dd2a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 1 Apr 2016 13:59:09 +0200 Subject: [PATCH 8/8] FIX : range is MySQL reserved word, cannot be used as column names --- htdocs/admin/dict.php | 8 ++++---- htdocs/core/class/html.formaccounting.class.php | 8 ++++---- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_c_accounting_category.sql | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d88df512b8c..f839ff3e49d 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -189,7 +189,7 @@ $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.new $tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; $tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, c.code as country_code, c.label as country, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_pays=c.rowid and c.active=1"; -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; +$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.ranges, a.position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hrm_department"; $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; @@ -644,7 +644,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); } - + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 @@ -1064,7 +1064,7 @@ if ($id) } print ''; print ""; - + if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates') { print '* '.$langs->trans("AvailableVariables").": "; @@ -1407,7 +1407,7 @@ if ($id) if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } $canbemodified=$iserasable; if ($obj->code == 'RECEP') $canbemodified=1; - + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e8664e3166d..37edb6a7239 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -64,7 +64,7 @@ class FormAccounting if (! empty($mysoc->country_id)) { - $sql = "SELECT c.rowid, c.label as type, c.range"; + $sql = "SELECT c.rowid, c.label as type, c.ranges"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; $sql.= " WHERE c.active = 1"; $sql.= " AND c.fk_country = ".$mysoc->country_id; @@ -72,14 +72,14 @@ class FormAccounting } else { - $sql = "SELECT c.rowid, c.label as type, c.range"; + $sql = "SELECT c.rowid, c.label as type, c.ranges"; $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co"; $sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid"; $sql.= " AND co.code = '".$mysoc->country_code."'"; $sql.= " ORDER BY c.label ASC"; } - dol_syslog("Form::select_accounting_category", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql=$db->query($sql); if ($resql) { @@ -96,7 +96,7 @@ class FormAccounting print '