From 29fdebe0d9b225af802bfab01559a5c24620b8fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Aug 2016 13:21:30 +0200 Subject: [PATCH] Fix list of lot --- htdocs/product/stock/productlot_card.php | 8 +- htdocs/product/stock/productlot_list.php | 343 ++++++++++++++--------- 2 files changed, 215 insertions(+), 136 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 4af5b8a4d59..b750db87234 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -17,7 +17,7 @@ */ /** - * \file stock/productlot_card.php + * \file product/stock/productlot_card.php * \ingroup stock * \brief This file is an example of a php page * Initialy built by build_class_from_table on 2016-05-17 12:22 @@ -362,12 +362,6 @@ print ''.$langs->trans("Fieldimport_key").''."\n"; - - // Example 2 : Adding links to objects - //$somethingshown=$form->showLinkedObjectBlock($object); - //$linktoelem = $form->showLinkToObjectBlock($object); - //if ($linktoelem) print '
'.$linktoelem; - } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 65bd340fa85..2d01c95520b 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -1,6 +1,5 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2007-2016 Laurent Destailleur * * 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 @@ -17,7 +16,7 @@ */ /** - * \file stock/productlot_list.php + * \file product/stock/productlot_list.php * \ingroup stock * \brief This file is an example of a php page * Initialy built by build_class_from_table on 2016-05-17 12:22 @@ -46,11 +45,14 @@ if (! $res) die("Include of main fails"); require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/stock/class/productlot.class.php'); +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +dol_include_once('/product/stock/class/productlot.class.php'); // Load traductions files requiredby by page -$langs->load("stock"); +$langs->load("stocks"); +$langs->load("productbatch"); $langs->load("other"); +$langs->load("users"); // Get parameters $id = GETPOST('id','int'); @@ -60,7 +62,7 @@ $myparam = GETPOST('myparam','alpha'); $search_entity=GETPOST('search_entity','int'); -$search_fk_product=GETPOST('search_fk_product','int'); +$search_product=GETPOST('search_product','alpha'); $search_batch=GETPOST('search_batch','alpha'); $search_fk_user_creat=GETPOST('search_fk_user_creat','int'); $search_fk_user_modif=GETPOST('search_fk_user_modif','int'); @@ -79,7 +81,7 @@ if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="t.rowid"; // Set here default search field +if (! $sortfield) $sortfield="t.batch"; // Set here default search field if (! $sortorder) $sortorder="ASC"; // Protection if external user @@ -91,34 +93,31 @@ if ($user->societe_id > 0) } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('productlotlist')); +$hookmanager->initHooks(array('productbatchlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('stock'); +$extralabels = $extrafields->fetch_name_optionals_label('productbatch'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); -// Load object if id or ref is provided as parameter -$object=new Productlot($db); -if (($id > 0 || ! empty($ref)) && $action != 'add') -{ - $result=$object->fetch($id,$ref); - if ($result < 0) dol_print_error($db); -} +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 't.ref'=>'Ref', + 't.note_public'=>'NotePublic', +); // Definition of fields for list $arrayfields=array( - -'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), -'t.fk_product'=>array('label'=>$langs->trans("Fieldfk_product"), 'checked'=>1), -'t.batch'=>array('label'=>$langs->trans("Fieldbatch"), 'checked'=>1), -'t.fk_user_creat'=>array('label'=>$langs->trans("Fieldfk_user_creat"), 'checked'=>1), -'t.fk_user_modif'=>array('label'=>$langs->trans("Fieldfk_user_modif"), 'checked'=>1), -'t.import_key'=>array('label'=>$langs->trans("Fieldimport_key"), 'checked'=>1), - - + //'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), + 't.batch'=>array('label'=>$langs->trans("Batch"), 'checked'=>1), + 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), + 't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1), + 't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1), + //'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1), //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), - 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), + //'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500), + 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); @@ -131,17 +130,22 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } +// Load object if id or ref is provided as parameter +$object=new Productlot($db); +if (($id > 0 || ! empty($ref)) && $action != 'add') +{ + $result=$object->fetch($id,$ref); + if ($result < 0) dol_print_error($db); +} -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ +/* + * Actions + */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction')) { $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -149,72 +153,50 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +// Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { - -$search_entity=''; -$search_fk_product=''; -$search_batch=''; -$search_fk_user_creat=''; -$search_fk_user_modif=''; -$search_import_key=''; - - + $search_entity=''; + $search_product=''; + $search_batch=''; + $search_fk_user_creat=''; + $search_fk_user_modif=''; + $search_import_key=''; $search_date_creation=''; $search_date_update=''; + $toselect=''; $search_array_options=array(); } if (empty($reshook)) { - // Mass actions. Controls on number of lines checked - $maxformassaction=1000; - if (! empty($massaction) && count($toselect) < 1) - { - $error++; - setEventMessages($langs->trans("NoLineChecked"), null, "warnings"); - } - if (! $error && count($toselect) > $maxformassaction) - { - setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); - $error++; - } - - // Action to delete - if ($action == 'confirm_delete') - { - $result=$object->delete($user); - if ($result > 0) - { - // Delete OK - setEventMessages("RecordDeleted", null, 'mesgs'); - header("Location: ".dol_buildpath('/stock/list.php',1)); - exit; - } - else - { - if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors'); - else setEventMessages($object->error,null,'errors'); - } - } + $objectclass='ProductLot'; + $objectlabel='LotSerial'; + $permtoread = $user->rights->stock->read; + $permtodelete = $user->rights->stock->delete; + $uploaddir = $conf->stock->dir_output; + //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * VIEW + */ -llxHeader('','MyPageName',''); +$now=dol_now(); $form=new Form($db); +$productstatic=new Product($db); + +//$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$help_url=''; +$title = $langs->trans('LotSerialList'); +llxHeader('', $title, $help_url); // Put here content of your page -$title = $langs->trans('MyModuleListTitle'); // Example : Adding jquery code print '