From f998f64db0c7934a83f26ba333dd9309bbc8fba4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 18 Jun 2018 15:48:51 +0200 Subject: [PATCH 01/11] Works on use new list engine instead template for canvas Conflicts: htdocs/product/list.php --- htdocs/core/lib/security.lib.php | 3 +-- htdocs/product/card.php | 2 +- htdocs/product/list.php | 12 ++++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d157cafd5f8..f7ce5712c76 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -174,11 +174,10 @@ function dol_verifyHash($chain, $hash, $type='0') * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @param Canvas $objcanvas Object canvas * @return int Always 1, die process if not allowed * @see dol_check_secure_access_document */ -function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) +function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') { global $db, $conf; global $hookmanager; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 39a5697ad72..b01aa8bc3f1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -112,7 +112,7 @@ if (! empty($canvas)) // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($id) ? 'rowid' : 'ref'); -$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); +$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productcard','globalcard')); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d1ea3d08a4c..884034453f7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013-2015 Raphaël Doursenaud @@ -104,19 +104,19 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (empty($action)) $action='list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); +/*$canvas=GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('product','list',$canvas); -} +}*/ // Security check -if ($search_type=='0') $result=restrictedArea($user,'produit','','','','','',$objcanvas); -else if ($search_type=='1') $result=restrictedArea($user,'service','','','','','',$objcanvas); -else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); +if ($search_type=='0') $result=restrictedArea($user,'produit'); +else if ($search_type=='1') $result=restrictedArea($user,'service'); +else $result=restrictedArea($user,'produit|service'); // Define virtualdiffersfromphysical $virtualdiffersfromphysical=0; From e392610f46793186d87fa57420bce3cb00282a54 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 18:55:05 +0200 Subject: [PATCH 02/11] Fix: missing banner --- .../canvas/product/tpl/card_view.tpl.php | 17 +++++++++++++++-- .../canvas/service/tpl/card_view.tpl.php | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 44b1f96203b..921cef87200 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -27,7 +27,20 @@ $object=$GLOBALS['object']; ?> -trans("Product"); ?> +trans("CardProduct".$object->type); + +dol_fiche_head($head, 'card', $titre, -1, 'product'); + +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter=" fk_product_type = ".$object->type; + +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); +?> error,$object->errors); ?> diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index fc129132dee..0ce5252b053 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -27,7 +27,20 @@ $object=$GLOBALS['object']; ?> -trans("Service"); ?> +trans("CardProduct".$object->type); + +dol_fiche_head($head, 'card', $titre, -1, 'service'); + +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter=" fk_product_type = ".$object->type; + +$shownav = 1; +if ($user->societe_id && ! in_array('product', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + +dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); +?> error,$object->errors); ?> From 3a26443546d7a62cfd79f472a84f8f0e8f8b0ade Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 19:24:40 +0200 Subject: [PATCH 03/11] Fix: remove unused code Conflicts: htdocs/product/list.php --- htdocs/core/class/canvas.class.php | 6 +- htdocs/product/list.php | 352 ++++++++++++++++++++++++++++- 2 files changed, 353 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 6851c124743..942123966fa 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * Copyright (C) 2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -145,7 +145,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -161,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 884034453f7..63713846614 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -104,14 +104,14 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (empty($action)) $action='list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -/*$canvas=GETPOST("canvas"); +$canvas=GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('product','list',$canvas); -}*/ +} // Security check if ($search_type=='0') $result=restrictedArea($user,'produit'); @@ -693,6 +693,7 @@ if ($resql) $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; $sql.= " LIMIT 1"; +<<<<<<< 8.0_canvas $result = $db->query($sql); if ($result) { @@ -716,6 +717,341 @@ if ($resql) $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock +======= + llxHeader('',$title,$helpurl,''); + + // Displays product removal confirmation + if (GETPOST('delprod')) { + setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); + } + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sall) $param.="&sall=".urlencode($sall); + if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); + if ($search_ref) $param="&search_ref=".urlencode($search_ref); + if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); + if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); + if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); + if ($type != '') $param.='&type='.urlencode($type); + if ($search_type != '') $param.='&search_type='.urlencode($search_type); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); + if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + $newcardbutton=''; + $rightskey='produit'; + if($type == Product::TYPE_SERVICE) $rightskey='service'; + if($user->rights->{$rightskey}->creer) + { + $label='NewProduct'; + if($type == Product::TYPE_SERVICE) $label='NewService'; + $newcardbutton=''.$langs->trans($label).''; + $newcardbutton.= ''; + $newcardbutton.= ''; + } + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; + + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); + + $topicmail="Information"; + $modelmail="product"; + $objecttmp=new Product($db); + $trackid='prod'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if (! empty($catid)) + { + print "
"; + $c = new Categorie($db); + $ways = $c->print_all_ways(' > ','product/list.php'); + print " > ".$ways[0]."
\n"; + print "

"; + } + + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } + + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) + { + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && $search_type === 0) { + $moreforfilter.='
'; + $moreforfilter.= ''; + $moreforfilter.= ' '; + $moreforfilter.='
'; + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; + else $moreforfilter=$hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; + } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; + } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + } + // Duration + if (! empty($arrayfields['p.duration']['checked'])) + { + print ''; + } + // Sell price + if (! empty($arrayfields['p.sellprice']['checked'])) + { + print ''; + } + // Minimum buying Price + if (! empty($arrayfields['p.minbuyprice']['checked'])) + { + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + } + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + } + // Limit for alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } + // Desired stock + if (! empty($arrayfields['p.desiredstock']['checked'])) + { + print ''; + } + // Stock + if (! empty($arrayfields['p.stock']['checked'])) print ''; + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) print ''; + // To batch + if (! empty($arrayfields['p.tobatch']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + } + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + + $product_static=new Product($db); + $product_fourn =new ProductFournisseur($db); + + $i = 0; + $totalarray=array(); + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active +>>>>>>> edae0b4 Fix: remove unused code + { +<<<<<<< 8.0_canvas + if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() +======= + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$obj->rowid; + $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $obj->label = $objtp->label; +>>>>>>> edae0b4 Fix: remove unused code + } + } + +<<<<<<< 8.0_canvas +======= + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service @@ -723,10 +1059,18 @@ if ($resql) $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() } } +>>>>>>> edae0b4 Fix: remove unused code +<<<<<<< 8.0_canvas + print ''; +======= +>>>>>>> edae0b4 Fix: remove unused code +<<<<<<< 8.0_canvas +======= print ''; +>>>>>>> edae0b4 Fix: remove unused code // Ref if (! empty($arrayfields['p.ref']['checked'])) { @@ -973,6 +1317,10 @@ if ($resql) print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + print $form->selectarray('search_type', $array, $search_type); + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; + print ''; + print ''; + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); + print ''; + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
"; print "
"; +<<<<<<< 8.0_canvas +======= + print '
'; +>>>>>>> edae0b4 Fix: remove unused code } print ''; } From 4c90ff9917433bc06271a06f2982edc05b4a7f51 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 19:47:53 +0200 Subject: [PATCH 04/11] NEW add "checked" field for new list engine compatibility --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_c_field_list.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 7ca1d16d67e..6fda9998bed 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -102,6 +102,8 @@ ALTER TABLE llx_c_type_fees ADD COLUMN type integer DEFAULT 0; ALTER TABLE llx_c_ecotaxe CHANGE COLUMN libelle label varchar(255); +ALTER TABLE llx_c_field_list ADD COLUMN checked tinyint DEFAULT 0 NOT NULL AFTER search; + ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_c_field_list.sql b/htdocs/install/mysql/tables/llx_c_field_list.sql index b22f98b52ec..17f8ef7356c 100644 --- a/htdocs/install/mysql/tables/llx_c_field_list.sql +++ b/htdocs/install/mysql/tables/llx_c_field_list.sql @@ -1,5 +1,5 @@ -- ======================================================================== --- Copyright (C) 2010 Regis Houssin +-- Copyright (C) 2010-2018 Regis Houssin -- -- 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 @@ -33,6 +33,7 @@ create table llx_c_field_list align varchar(6) DEFAULT 'left', -- align (left,center,right) sort tinyint DEFAULT 1 NOT NULL, -- add sort field search tinyint DEFAULT 0 NOT NULL, -- add search field + checked tinyint DEFAULT 0 NOT NULL, -- show or hide field by default enabled varchar(255) DEFAULT 1, -- Condition to show or hide rang integer DEFAULT 0 From ebfd1846a3473b743cd862c0b36b0f018f85f29b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Jun 2018 20:07:00 +0200 Subject: [PATCH 05/11] Fix: add new field "checked" --- htdocs/product/canvas/product/actions_card_product.class.php | 5 +++-- htdocs/product/canvas/service/actions_card_service.class.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 3c0fc4d2b2f..379b80fd1eb 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -268,7 +268,7 @@ class ActionsCardProduct $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -293,6 +293,7 @@ class ActionsCardProduct $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; + $fieldlist["checked"] = $obj->checked; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index af227e54b0b..4758f0de08a 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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,7 +247,7 @@ class ActionsCardService $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -272,6 +272,7 @@ class ActionsCardService $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; + $fieldlist["checked"] = $obj->checked; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; From 5b491a4d57f89b072b21246b6e99d558df846cd8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Jun 2018 10:59:46 +0200 Subject: [PATCH 06/11] Fix: remove duplicate code --- .../product/actions_card_product.class.php | 25 ++++--------------- .../canvas/product/tpl/card_create.tpl.php | 4 +-- .../canvas/product/tpl/card_edit.tpl.php | 4 +-- .../canvas/product/tpl/card_view.tpl.php | 10 -------- .../service/actions_card_service.class.php | 25 ++++--------------- .../canvas/service/tpl/card_create.tpl.php | 4 +-- .../canvas/service/tpl/card_edit.tpl.php | 4 +-- .../canvas/service/tpl/card_view.tpl.php | 10 -------- 8 files changed, 18 insertions(+), 68 deletions(-) diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 379b80fd1eb..1ea02816043 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -123,20 +123,6 @@ class ActionsCardProduct $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); } - if ($action == 'create' || $action == 'edit') - { - // Status - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status); - - //To Buy - $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); - $this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy); - - $this->tpl['description'] = $this->description; - $this->tpl['note'] = $this->note; - } - if ($action == 'view') { $head = product_prepare_head($this->object); @@ -180,10 +166,13 @@ class ActionsCardProduct { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]); + $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->object->status); $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$this->object->status_buy); + + $this->tpl['description'] = $this->description; + $this->tpl['note'] = $this->note; // Finished $statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); @@ -208,10 +197,6 @@ class ActionsCardProduct if ($action == 'view') { - // Status - $this->tpl['status'] = $this->object->getLibStatut(2,0); - $this->tpl['status_buy'] = $this->object->getLibStatut(2,1); - // Photo $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity])) diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index bc4b5409688..d3c29f32e2e 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -65,7 +65,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Status").' ('.$langs->trans("Buy").')'; ?> -selectarray('statut_buy',$statutarray,$object->status_tobuy); ?> +selectarray('statut_buy',$statutarray,$object->status_buy); ?> stock->enabled)) { ?> diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 6c13bddb6a1..8210cde95f3 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -65,7 +65,7 @@ dol_htmloutput_errors($object->error,$object->errors); trans("Status").' ('.$langs->trans("Buy").')'; ?> -selectarray('statut_buy',$statutarray,$object->status_tobuy); ?> +selectarray('statut_buy',$statutarray,$object->status_buy); ?> stock->enabled)) { ?> diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 921cef87200..61964399e1c 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -63,16 +63,6 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - -trans("Status").' ('.$langs->trans("Sell").')'; ?> -status; ?> - - - -trans("Status").' ('.$langs->trans("Buy").')'; ?> -status_buy; ?> - - trans("Description"); ?> description; ?> diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 4758f0de08a..827360a7e9d 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -122,20 +122,6 @@ class ActionsCardService $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); } - if ($action == 'create' || $action == 'edit') - { - // Status - $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status); - - //To Buy - $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); - $this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy); - - $this->tpl['description'] = $this->description; - $this->tpl['note'] = $this->note; - } - if ($action == 'view') { $head = product_prepare_head($this->object); @@ -182,10 +168,13 @@ class ActionsCardService { // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); - $this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]); + $this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->object->status); $statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy")); - $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]); + $this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$this->object->status_buy); + + $this->tpl['description'] = $this->description; + $this->tpl['note'] = $this->note; // Duration unit // TODO creer fonction @@ -203,10 +192,6 @@ class ActionsCardService if ($action == 'view') { - // Status - $this->tpl['status'] = $this->object->getLibStatut(2,0); - $this->tpl['status_buy'] = $this->object->getLibStatut(2,1); - // Photo $this->tpl['nblignes'] = 4; if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity])) diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index b9dc10fd5dc..443e9ee7401 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -62,7 +62,7 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Status").' ('.$langs->trans("Buy").')'; ?> -selectarray('statut_buy',$statutarray,$object->status_tobuy); ?> +selectarray('statut_buy',$statutarray,$object->status_buy); ?> trans("Duration"); ?> diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index 6fc3bf3273a..ccbe1131120 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * * 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 @@ -62,7 +62,7 @@ dol_htmloutput_errors($object->error,$object->errors); trans("Status").' ('.$langs->trans("Buy").')'; ?> -selectarray('statut_buy',$statutarray,$object->status_tobuy); ?> +selectarray('statut_buy',$statutarray,$object->status_buy); ?> trans("Duration"); ?> diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index 0ce5252b053..5826d78583f 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -63,16 +63,6 @@ dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - -trans("Status").' ('.$langs->trans("Sell").')'; ?> -status; ?> - - - -trans("Status").' ('.$langs->trans("Buy").')'; ?> -status_buy; ?> - - trans("Description"); ?> description; ?> From 96faf7cb0f1a139a73b59f48d4f53875605a60c3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Jun 2018 11:23:33 +0200 Subject: [PATCH 07/11] Fix: use the new title --- htdocs/product/canvas/product/tpl/card_create.tpl.php | 5 ++++- htdocs/product/canvas/product/tpl/card_edit.tpl.php | 4 +++- htdocs/product/canvas/service/tpl/card_create.tpl.php | 5 ++++- htdocs/product/canvas/service/tpl/card_edit.tpl.php | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index d3c29f32e2e..dbaaed35319 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -30,7 +30,10 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe -trans("Product")); ?> +trans("NewProduct"),'','title_products.png'); +dol_fiche_head(''); +?> error)?'':$object->error),$object->errors); ?> diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 8210cde95f3..f114020a4bc 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -31,7 +31,9 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Product")); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +dol_fiche_head($head, 'card', $titre, 0, 'product'); dol_htmloutput_errors($object->error,$object->errors); ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 443e9ee7401..f748edc03e6 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -30,7 +30,10 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe -trans("Service")); ?> +trans("NewService"),'','title_products.png'); +dol_fiche_head(''); +?> control->tpl['error'],$this->control->tpl['errors']); ?> diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index ccbe1131120..969ce3de2da 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -31,7 +31,9 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe trans("Service")); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +dol_fiche_head($head, 'card', $titre, 0, 'service'); dol_htmloutput_errors($object->error,$object->errors); ?> From 718cbce8eb3e3971790ea29f0d898e5624a91b47 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:05:23 +0200 Subject: [PATCH 08/11] Fix: use "visible" field name instead "checked" --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_c_field_list.sql | 2 +- htdocs/product/canvas/product/actions_card_product.class.php | 4 ++-- htdocs/product/canvas/service/actions_card_service.class.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 6fda9998bed..ec6940e1441 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -102,7 +102,7 @@ ALTER TABLE llx_c_type_fees ADD COLUMN type integer DEFAULT 0; ALTER TABLE llx_c_ecotaxe CHANGE COLUMN libelle label varchar(255); -ALTER TABLE llx_c_field_list ADD COLUMN checked tinyint DEFAULT 0 NOT NULL AFTER search; +ALTER TABLE llx_c_field_list ADD COLUMN visible tinyint DEFAULT 1 NOT NULL AFTER search; ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; diff --git a/htdocs/install/mysql/tables/llx_c_field_list.sql b/htdocs/install/mysql/tables/llx_c_field_list.sql index 17f8ef7356c..21adba42cfa 100644 --- a/htdocs/install/mysql/tables/llx_c_field_list.sql +++ b/htdocs/install/mysql/tables/llx_c_field_list.sql @@ -33,7 +33,7 @@ create table llx_c_field_list align varchar(6) DEFAULT 'left', -- align (left,center,right) sort tinyint DEFAULT 1 NOT NULL, -- add sort field search tinyint DEFAULT 0 NOT NULL, -- add search field - checked tinyint DEFAULT 0 NOT NULL, -- show or hide field by default + visible tinyint DEFAULT 1 NOT NULL, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only enabled varchar(255) DEFAULT 1, -- Condition to show or hide rang integer DEFAULT 0 diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 1ea02816043..a6a182fc64f 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -253,7 +253,7 @@ class ActionsCardProduct $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -278,7 +278,7 @@ class ActionsCardProduct $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; - $fieldlist["checked"] = $obj->checked; + $fieldlist["visible"] = $obj->visible; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 827360a7e9d..108c6ccb748 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -232,7 +232,7 @@ class ActionsCardService $this->field_list = array(); - $sql = "SELECT rowid, name, alias, title, align, sort, search, checked, enabled, rang"; + $sql = "SELECT rowid, name, alias, title, align, sort, search, visible, enabled, rang"; $sql.= " FROM ".MAIN_DB_PREFIX."c_field_list"; $sql.= " WHERE element = '".$this->db->escape($this->fieldListName)."'"; $sql.= " AND entity = ".$conf->entity; @@ -257,7 +257,7 @@ class ActionsCardService $fieldlist["align"] = $obj->align; $fieldlist["sort"] = $obj->sort; $fieldlist["search"] = $obj->search; - $fieldlist["checked"] = $obj->checked; + $fieldlist["visible"] = $obj->visible; $fieldlist["enabled"] = verifCond($obj->enabled); $fieldlist["order"] = $obj->rang; From 62a55e10b7c818ea431470eec8cecbd564917117 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:26:07 +0200 Subject: [PATCH 09/11] Fix: remove not used list template --- htdocs/core/class/canvas.class.php | 4 +- .../product/canvas/product/tpl/list.tpl.php | 108 ------------------ .../product/canvas/service/tpl/list.tpl.php | 107 ----------------- 3 files changed, 2 insertions(+), 217 deletions(-) delete mode 100644 htdocs/product/canvas/product/tpl/list.tpl.php delete mode 100644 htdocs/product/canvas/service/tpl/list.tpl.php diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 942123966fa..d9c496add4f 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -145,7 +145,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -161,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.((!empty($this->card) && $this->card != 'list')?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/product/canvas/product/tpl/list.tpl.php b/htdocs/product/canvas/product/tpl/list.tpl.php deleted file mode 100644 index e5c315e8148..00000000000 --- a/htdocs/product/canvas/product/tpl/list.tpl.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; -} - -?> - - - - - - - - -
- - -
-
- -
" method="post" name="formulaire"> - - - - - - - - - - - - - - - - - - - - - - - $searchfield) { - if ($searchfield['enabled']) { - if ($searchfield['search']) { ?> - - '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - } else { ?> - - - - - - - - > - $value) { - foreach($fieldlist as $field) { - if ($field['alias'] == $key) { ?> - - - - - -
- ?sortfield=&sortorder=asc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - A-Z - - ?sortfield=&sortorder=desc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - Z-A - -
 
-
- - \ No newline at end of file diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php deleted file mode 100644 index ef6d461fc5c..00000000000 --- a/htdocs/product/canvas/service/tpl/list.tpl.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * 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 - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -// Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; -} - -?> - - - - - - - - -
- - -
-
- -
" method="post" name="formulaire"> - - - - - - - - - - - - - - - - - - - - - - - $searchfield) { - if ($searchfield['enabled']) { - if ($searchfield['search']) { ?> - - '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print ''; - } else { ?> - - - - - - - - - $value) { - foreach($fieldlist as $field) { - if ($field['alias'] == $key) { ?> - - - - - -
- ?sortfield=&sortorder=asc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - A-Z - - ?sortfield=&sortorder=desc&begin=&tosell=&canvas=default&fourn_id=&snom=&sref="> - Z-A - -
 
-
- - \ No newline at end of file From debec3d17585dd8fcc0b62056610e81d281e5b3b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Jun 2018 15:43:22 +0200 Subject: [PATCH 10/11] Fix: remove old code of canvas Conflicts: htdocs/product/list.php --- htdocs/product/list.php | 528 ++++++++++++++++++++++++++++++++-------- 1 file changed, 426 insertions(+), 102 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 63713846614..43dcb82b366 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -450,182 +450,470 @@ if ($resql) print "
"; } - if (! empty($canvas) && file_exists(DOL_DOCUMENT_ROOT.'/product/canvas/'.$canvas.'/actions_card_'.$canvas.'.class.php')) + if ($sall) { - $fieldlist = $object->field_list; - $datas = $object->list_datas; - $picto='title.png'; - $title_picto = img_picto('',$picto); - $title_text = $title; - - // Default templates directory - $template_dir = DOL_DOCUMENT_ROOT . '/product/canvas/'.$canvas.'/tpl/'; - // Check if a custom template is present - if (file_exists(DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/list.tpl.php')) - { - $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$canvas.'/'; - } - - include $template_dir.'list.tpl.php'; // Include native PHP templates + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - else + + // Filter on categories + $moreforfilter=''; + if (! empty($conf->categorie->enabled)) { - if ($sall) + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + + //Show/hide child products. Hidden by default + if (!empty($conf->variants->enabled) && $search_type === 0) { + $moreforfilter.='
'; + $moreforfilter.= ''; + $moreforfilter.= ' '; + $moreforfilter.='
'; + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; + else $moreforfilter=$hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.label']['checked'])) + { + print ''; + } + // Type + if (! empty($arrayfields['p.fk_product_type']['checked'])) + { + print ''; + } + // Barcode + if (! empty($arrayfields['p.barcode']['checked'])) + { + print ''; + } + // Duration + if (! empty($arrayfields['p.duration']['checked'])) + { + print ''; + } + // Sell price + if (! empty($arrayfields['p.sellprice']['checked'])) + { + print ''; + } + // Minimum buying Price + if (! empty($arrayfields['p.minbuyprice']['checked'])) + { + print ''; + } + // Number buying Price + if (! empty($arrayfields['p.numbuyprice']['checked'])) + { + print ''; + } + // WAP + if (! empty($arrayfields['p.pmp']['checked'])) + { + print ''; + } + // Limit for alert + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + { + print ''; + } + // Desired stock + if (! empty($arrayfields['p.desiredstock']['checked'])) + { + print ''; + } + // Stock + if (! empty($arrayfields['p.stock']['checked'])) print ''; + // Stock + if (! empty($arrayfields['stock_virtual']['checked'])) print ''; + // To batch + if (! empty($arrayfields['p.tobatch']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tosell']['checked'])) + { + print ''; + } + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + } + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); + if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + + $product_static=new Product($db); + $product_fourn =new ProductFournisseur($db); + + $i = 0; + $totalarray=array(); + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$obj->rowid; + $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if (! empty($objtp->label)) $obj->label = $objtp->label; + } } - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + + if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); - $moreforfilter.='
'; + if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + { + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + } } - //Show/hide child products. Hidden by default - if (!empty($conf->variants->enabled) && $search_type === 0) { - $moreforfilter.='
'; - $moreforfilter.= ''; - $moreforfilter.= ' '; - $moreforfilter.='
'; - } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; + print ''; - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - - print '
'; - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + print $form->selectarray('search_type', $array, $search_type); + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print ''; + print ' '; + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; + print ''; + print ''; + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); + print ''; + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'."\n"; - - // Lines with input filters - print ''; + // Ref if (! empty($arrayfields['p.ref']['checked'])) { - print ''; + print '\n"; + if (! $i) $totalarray['nbfield']++; } + // Ref supplier if (! empty($arrayfields['pfp.ref_fourn']['checked'])) { - print ''; + print '\n"; + if (! $i) $totalarray['nbfield']++; } + // Label if (! empty($arrayfields['p.label']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Type if (! empty($arrayfields['p.fk_product_type']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Barcode if (! empty($arrayfields['p.barcode']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } + // Duration if (! empty($arrayfields['p.duration']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } + // Sell price if (! empty($arrayfields['p.sellprice']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } - // Minimum buying Price + + // Better buy price if (! empty($arrayfields['p.minbuyprice']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } - // Number buying Price + + // Number of buy prices if (! empty($arrayfields['p.numbuyprice']['checked'])) { - print ''; } + // WAP if (! empty($arrayfields['p.pmp']['checked'])) { - print ''; } - // Limit for alert + + // Limit alert if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Desired stock if (! empty($arrayfields['p.desiredstock']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; + } + // Stock real + if (! empty($arrayfields['p.stock']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Stock virtual + if (! empty($arrayfields['stock_virtual']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Lot/Serial + if (! empty($arrayfields['p.tobatch']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; } - // Stock - if (! empty($arrayfields['p.stock']['checked'])) print ''; - // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print ''; - // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print ''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['p.datec']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['p.tms']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } + + // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { +<<<<<<< 8.0_canvas print ''; @@ -1305,14 +1593,41 @@ if ($resql) $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; print ''; +======= + print ''; if (! $i) $totalarray['nbfield']++; - - print "\n"; - $i++; } + // Status (to buy) + if (! empty($arrayfields['p.tobuy']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action + print ''; + if (! $i) $totalarray['nbfield']++; +<<<<<<< 8.0_canvas $db->free($resql); print "
'; - print ''; - print ''; + print $product_static->getNomUrl(1); + print "'; - print ''; - print ''; + print $product_static->getNomUrl(1); + print "'; - print ''; - print ''.dol_trunc($obj->label,40).''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('search_type', $array, $search_type); - print ''.$obj->fk_product_type.''; - print ''; - print ''.$obj->barcode.''; - print ' '; + print ''; + if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) + { + if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + else print $obj->duration; + } print ''; + print ''; + if ($obj->tosell) + { + if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); + else print price($obj->price).' '.$langs->trans("HT"); + } print ''; - print ' '; + print ''; + if ($obj->tobuy && $obj->minsellprice != '') + { + //print price($obj->minsellprice).' '.$langs->trans("HT"); + if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) + { + if ($product_fourn->product_fourn_price_id > 0) + { + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); + } + else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); + } + } + } print ''; - print ' '; + print ''; + if ($obj->tobuy) + { + if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) + { + $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + print $form->textwithpicto(count($productFournList),$htmltext); + } + } print ''; - print ' '; + print ''; + print price($product_static->pmp, 1, $langs); print ''; - print ' '; + print ''; + if ($obj->fk_product_type != 1) + { + print $obj->seuil_stock_alerte; + } print ''; - print ' '; + print ''; + if ($obj->fk_product_type != 1) + { + print $obj->desiredstock; + } print ''; + if ($obj->fk_product_type != 1) + { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + print $product_static->stock_reel; + } + print ''; + if ($obj->fk_product_type != 1) + { + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; + print $product_static->stock_theorique; + } + print ''; + print yn($obj->tobatch); + print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; + print ''; + print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); print ''; + print ''; + print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); print ''; print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); print ''; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + print $product_static->LibStatut($obj->tosell,5,0); +>>>>>>> 1d08002 Fix: remove old code of canvas } print '
'; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + print $product_static->LibStatut($obj->tobuy,5,1); + } + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; @@ -1321,7 +1636,16 @@ if ($resql) ======= print ''; >>>>>>> edae0b4 Fix: remove unused code +======= + print "\n"; + $i++; +>>>>>>> 1d08002 Fix: remove old code of canvas } + + $db->free($resql); + + print ""; + print "
"; print ''; } else From f3d213bab8f149b3a05aa0cbac5336beadcd83ba Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 30 Jun 2018 11:05:00 +0200 Subject: [PATCH 11/11] Fix: remove old code --- htdocs/product/list.php | 703 +--------------------------------------- 1 file changed, 5 insertions(+), 698 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 43dcb82b366..47135d22a15 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2018 Laurent Destailleur - * Copyright (C) 2005-2018 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013-2015 Raphaël Doursenaud @@ -114,9 +114,9 @@ if (! empty($canvas)) } // Security check -if ($search_type=='0') $result=restrictedArea($user,'produit'); -else if ($search_type=='1') $result=restrictedArea($user,'service'); -else $result=restrictedArea($user,'produit|service'); +if ($search_type=='0') $result=restrictedArea($user,'produit','','','','','',$objcanvas); +else if ($search_type=='1') $result=restrictedArea($user,'service','','','','','',$objcanvas); +else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas); // Define virtualdiffersfromphysical $virtualdiffersfromphysical=0; @@ -453,7 +453,7 @@ if ($resql) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; } // Filter on categories @@ -913,693 +913,11 @@ if ($resql) // Status (to sell) if (! empty($arrayfields['p.tosell']['checked'])) { -<<<<<<< 8.0_canvas - print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); - print ''; - } - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); - print ''; - } - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print ''; - - print ''; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - - $product_static=new Product($db); - $product_fourn =new ProductFournisseur($db); - - $i = 0; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active - { - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; - -<<<<<<< 8.0_canvas - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; - } - } - - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock -======= - llxHeader('',$title,$helpurl,''); - - // Displays product removal confirmation - if (GETPOST('delprod')) { - setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); - } - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); - if ($search_ref) $param="&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); - if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); - if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($type != '') $param.='&type='.urlencode($type); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - - // List of mass actions available - $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - - $newcardbutton=''; - $rightskey='produit'; - if($type == Product::TYPE_SERVICE) $rightskey='service'; - if($user->rights->{$rightskey}->creer) - { - $label='NewProduct'; - if($type == Product::TYPE_SERVICE) $label='NewService'; - $newcardbutton=''.$langs->trans($label).''; - $newcardbutton.= ''; - $newcardbutton.= ''; - } - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; - - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); - - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - - if (! empty($catid)) - { - print "
"; - $c = new Categorie($db); - $ways = $c->print_all_ways(' > ','product/list.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } - - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); - } - - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - - //Show/hide child products. Hidden by default - if (!empty($conf->variants->enabled) && $search_type === 0) { - $moreforfilter.='
'; - $moreforfilter.= ''; - $moreforfilter.= ' '; - $moreforfilter.='
'; - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; - - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - - print '
'; - print ''."\n"; - - // Lines with input filters - print ''; - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; - } - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; - } - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - } - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - } - // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - } - // Minimum buying Price - if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - } - // Number buying Price - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - } - // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - } - // Limit for alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - } - // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - } - // Stock - if (! empty($arrayfields['p.stock']['checked'])) print ''; - // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print ''; - // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print ''; - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - } - print ''; - - print ''; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"],"pfp.ref_fourn","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_product_type']['checked'])) print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"],"p.fk_product_type","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.barcode']['checked'])) print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"],"p.barcode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['stock_virtual']['checked'])) print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_buy","",$param,'',$sortfield,$sortorder); - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tosell']['checked'])) print_liste_field_titre($arrayfields['p.tosell']['label'],$_SERVER["PHP_SELF"],"p.tosell","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($arrayfields['p.tobuy']['label'],$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - - $product_static=new Product($db); - $product_fourn =new ProductFournisseur($db); - - $i = 0; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active ->>>>>>> edae0b4 Fix: remove unused code - { -<<<<<<< 8.0_canvas - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() -======= - $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) - { - $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; ->>>>>>> edae0b4 Fix: remove unused code - } - } - -<<<<<<< 8.0_canvas -======= - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock - { - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service - { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() - } - } ->>>>>>> edae0b4 Fix: remove unused code - -<<<<<<< 8.0_canvas - print ''; -======= ->>>>>>> edae0b4 Fix: remove unused code - -<<<<<<< 8.0_canvas -======= - print ''; - ->>>>>>> edae0b4 Fix: remove unused code - // Ref - if (! empty($arrayfields['p.ref']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Ref supplier - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) - { - print '\n"; - if (! $i) $totalarray['nbfield']++; - } - // Label - if (! empty($arrayfields['p.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Duration - if (! empty($arrayfields['p.duration']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Better buy price - if (! empty($arrayfields['p.minbuyprice']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) - { - print ''; - } - - // WAP - if (! empty($arrayfields['p.pmp']['checked'])) - { - print ''; - } - - // Limit alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Stock real - if (! empty($arrayfields['p.stock']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Stock virtual - if (! empty($arrayfields['stock_virtual']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Lot/Serial - if (! empty($arrayfields['p.tobatch']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Status (to sell) - if (! empty($arrayfields['p.tosell']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status (to buy) - if (! empty($arrayfields['p.tobuy']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action - print ''; if (! $i) $totalarray['nbfield']++; @@ -1627,19 +945,8 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; -<<<<<<< 8.0_canvas - $db->free($resql); - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('search_type', $array, $search_type); - print ''; - print ''; - print ''; - print ' '; - print ''; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ' '; - print '  '.$form->selectyesno($search_tobatch, '', '', '', 1).''; - print ''; - print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')),$search_tosell,1); - print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$search_tobuy,1); - print ''; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print '
'; - print $product_static->getNomUrl(1); - print "'; - print $product_static->getNomUrl(1); - print "'.dol_trunc($obj->label,40).''.$obj->fk_product_type.''.$obj->barcode.''; - if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) - { - if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); - else print $obj->duration; - } - print ''; - if ($obj->tosell) - { - if ($obj->price_base_type == 'TTC') print price($obj->price_ttc).' '.$langs->trans("TTC"); - else print price($obj->price).' '.$langs->trans("HT"); - } - print ''; - if ($obj->tobuy && $obj->minsellprice != '') - { - //print price($obj->minsellprice).' '.$langs->trans("HT"); - if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) - { - if ($product_fourn->product_fourn_price_id > 0) - { - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); - } - else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); - } - } - } - print ''; - if ($obj->tobuy) - { - if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) - { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); - print $form->textwithpicto(count($productFournList),$htmltext); - } - } - print ''; - print price($product_static->pmp, 1, $langs); - print ''; - if ($obj->fk_product_type != 1) - { - print $obj->seuil_stock_alerte; - } - print ''; - if ($obj->fk_product_type != 1) - { - print $obj->desiredstock; - } - print ''; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_reel; - } - print ''; - if ($obj->fk_product_type != 1) - { - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; - print $product_static->stock_theorique; - } - print ''; - print yn($obj->tobatch); - print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_buy.''; - print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); - print ''; - print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); - print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product_static->LibStatut($obj->tosell,5,0); - } - print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product_static->LibStatut($obj->tobuy,5,1); - } - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; -======= print ''; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($obj->tosell,5,0); ->>>>>>> 1d08002 Fix: remove old code of canvas } print '
"; - print "
"; -<<<<<<< 8.0_canvas -======= - print '
'; ->>>>>>> edae0b4 Fix: remove unused code -======= print "\n"; $i++; ->>>>>>> 1d08002 Fix: remove old code of canvas } $db->free($resql);