';
+ $label.= '
' . $langs->trans('Ref') . ': ' . $this->ref;
+
+ $link = '
';
+ $linkend='';
+
+ if ($withpicto)
+ {
+ $result.=($link.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
+ if ($withpicto != 2) $result.=' ';
+ }
+ $result.= $link . $this->ref . $linkend;
+ return $result;
+ }
+
+ /**
+ * Retourne le libelle du status d'un user (actif, inactif)
+ *
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function getLibStatut($mode=0)
+ {
+ return $this->LibStatut($this->status,$mode);
+ }
+
+ /**
+ * Renvoi le libelle d'un status donne
+ *
+ * @param int $status Id status
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @return string Label of status
+ */
+ function LibStatut($status,$mode=0)
+ {
+ global $langs;
+
+ if ($mode == 0)
+ {
+ $prefix='';
+ if ($status == 1) return $langs->trans('Enabled');
+ if ($status == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 1)
+ {
+ if ($status == 1) return $langs->trans('Enabled');
+ if ($status == 0) return $langs->trans('Disabled');
+ }
+ if ($mode == 2)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 3)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
+ }
+ if ($mode == 4)
+ {
+ if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
+ if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
+ }
+ if ($mode == 5)
+ {
+ if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
+ if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
+ }
+ }
+
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ $this->id = 0;
+
+ $this->tms = '';
+ $this->fk_product = '';
+ $this->batch = '';
+ $this->eatby = '';
+ $this->sellby = '';
+ $this->note_public = '';
+ $this->note_private = '';
+ $this->qty = '';
+ $this->import_key = '';
+
+
+ }
+
+}
+
+/**
+ * Class ProductlotLine
+ */
+class ProductlotLine
+{
+ /**
+ * @var int ID
+ */
+ public $id;
+ /**
+ * @var mixed Sample line property 1
+ */
+
+ public $tms = '';
+ public $fk_product;
+ public $batch;
+ public $eatby = '';
+ public $sellby = '';
+ public $note_public;
+ public $note_private;
+ public $qty;
+ public $import_key;
+
+ /**
+ * @var mixed Sample line property 2
+ */
+
+}
diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php
new file mode 100644
index 00000000000..2e8620797c7
--- /dev/null
+++ b/htdocs/product/stock/productlot_card.php
@@ -0,0 +1,376 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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
.
+ */
+
+/**
+ * \file 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 10:33
+ */
+
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
+//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res) die("Include of main fails");
+// Change this following line to use the correct relative path from htdocs
+include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+dol_include_once('/stock/class/productlot.class.php');
+
+// Load traductions files requiredby by page
+$langs->load("stock");
+$langs->load("other");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+$backtopage = GETPOST('backtopage');
+$myparam = GETPOST('myparam','alpha');
+
+
+$search_fk_product=GETPOST('search_fk_product','int');
+$search_batch=GETPOST('search_batch','alpha');
+$search_note_public=GETPOST('search_note_public','alpha');
+$search_note_private=GETPOST('search_note_private','alpha');
+$search_qty=GETPOST('search_qty','alpha');
+$search_import_key=GETPOST('search_import_key','alpha');
+
+
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ //accessforbidden();
+}
+
+if (empty($action) && empty($id) && empty($ref)) $action='list';
+
+// 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);
+}
+
+// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
+$hookmanager->initHooks(array('productlot'));
+$extrafields = new ExtraFields($db);
+
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
+{
+ // Action to add record
+ if ($action == 'add')
+ {
+ if (GETPOST('cancel'))
+ {
+ $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php',1);
+ header("Location: ".$urltogo);
+ exit;
+ }
+
+ $error=0;
+
+ /* object_prop_getpost_prop */
+
+ $object->fk_product=GETPOST('fk_product','int');
+ $object->batch=GETPOST('batch','alpha');
+ $object->note_public=GETPOST('note_public','alpha');
+ $object->note_private=GETPOST('note_private','alpha');
+ $object->qty=GETPOST('qty','alpha');
+ $object->import_key=GETPOST('import_key','alpha');
+
+
+
+ if (empty($object->ref))
+ {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
+ }
+
+ if (! $error)
+ {
+ $result=$object->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $urltogo=$backtopage?$backtopage:dol_buildpath('/stock/list.php',1);
+ header("Location: ".$urltogo);
+ exit;
+ }
+ {
+ // Creation KO
+ if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ else setEventMessages($object->error, null, 'errors');
+ $action='create';
+ }
+ }
+ else
+ {
+ $action='create';
+ }
+ }
+
+ // Cancel
+ if ($action == 'update' && GETPOST('cancel')) $action='view';
+
+ // Action to update record
+ if ($action == 'update' && ! GETPOST('cancel'))
+ {
+ $error=0;
+
+
+ $object->fk_product=GETPOST('fk_product','int');
+ $object->batch=GETPOST('batch','alpha');
+ $object->note_public=GETPOST('note_public','alpha');
+ $object->note_private=GETPOST('note_private','alpha');
+ $object->qty=GETPOST('qty','alpha');
+ $object->import_key=GETPOST('import_key','alpha');
+
+
+
+ if (empty($object->ref))
+ {
+ $error++;
+ setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
+ }
+
+ if (! $error)
+ {
+ $result=$object->update($user);
+ if ($result > 0)
+ {
+ $action='view';
+ }
+ else
+ {
+ // Creation KO
+ if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ else setEventMessages($object->error, null, 'errors');
+ $action='edit';
+ }
+ }
+ else
+ {
+ $action='edit';
+ }
+ }
+
+ // 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');
+ }
+ }
+}
+
+
+
+
+/***************************************************
+* VIEW
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader('','MyPageName','');
+
+$form=new Form($db);
+
+
+// Put here content of your page
+
+// Example : Adding jquery code
+print '';
+
+
+// Part to create
+if ($action == 'create')
+{
+ print load_fiche_titre($langs->trans("NewMyModule"));
+
+ print '
';
+}
+
+
+
+// Part to edit record
+if (($id || $ref) && $action == 'edit')
+{
+ print load_fiche_titre($langs->trans("MyModule"));
+
+ print '
';
+}
+
+
+
+// Part to show record
+if ($id && (empty($action) || $action == 'view' || $action == 'delete'))
+{
+ print load_fiche_titre($langs->trans("MyModule"));
+
+ dol_fiche_head();
+
+ if ($action == 'delete') {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
+ print $formconfirm;
+ }
+
+ print '
';
+
+ dol_fiche_end();
+
+
+ // Buttons
+ print '
'."\n";
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ if (empty($reshook))
+ {
+ if ($user->rights->stock->write)
+ {
+ print '
'."\n";
+ }
+
+ if ($user->rights->stock->delete)
+ {
+ print '
'."\n";
+ }
+ }
+ print '
'."\n";
+
+
+ // Example 2 : Adding links to objects
+ //$somethingshown=$form->showLinkedObjectBlock($object);
+ //$linktoelem = $form->showLinkToObjectBlock($object);
+ //if ($linktoelem) print '
'.$linktoelem;
+
+}
+
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
new file mode 100644
index 00000000000..ded98827e31
--- /dev/null
+++ b/htdocs/product/stock/productlot_list.php
@@ -0,0 +1,549 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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
.
+ */
+
+/**
+ * \file 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 10:33
+ */
+
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
+//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
+if (! $res) die("Include of main fails");
+// Change this following line to use the correct relative path from htdocs
+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');
+
+// Load traductions files requiredby by page
+$langs->load("stock");
+$langs->load("other");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+$backtopage = GETPOST('backtopage');
+$myparam = GETPOST('myparam','alpha');
+
+
+$search_fk_product=GETPOST('search_fk_product','int');
+$search_batch=GETPOST('search_batch','alpha');
+$search_note_public=GETPOST('search_note_public','alpha');
+$search_note_private=GETPOST('search_note_private','alpha');
+$search_qty=GETPOST('search_qty','alpha');
+$search_import_key=GETPOST('search_import_key','alpha');
+
+
+$search_myfield=GETPOST('search_myfield');
+$optioncss = GETPOST('optioncss','alpha');
+
+// Load variable for pagination
+$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
+$sortfield = GETPOST('sortfield','alpha');
+$sortorder = GETPOST('sortorder','alpha');
+$page = GETPOST('page','int');
+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 (! $sortorder) $sortorder="ASC";
+
+// Protection if external user
+$socid=0;
+if ($user->societe_id > 0)
+{
+ $socid = $user->societe_id;
+ //accessforbidden();
+}
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array('productlotlist'));
+$extrafields = new ExtraFields($db);
+
+// fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('stock');
+$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);
+}
+
+// Definition of fields for list
+$arrayfields=array(
+
+'t.fk_product'=>array('label'=>$langs->trans("Fieldfk_product"), 'checked'=>1),
+'t.batch'=>array('label'=>$langs->trans("Fieldbatch"), 'checked'=>1),
+'t.note_public'=>array('label'=>$langs->trans("Fieldnote_public"), 'checked'=>1),
+'t.note_private'=>array('label'=>$langs->trans("Fieldnote_private"), 'checked'=>1),
+'t.qty'=>array('label'=>$langs->trans("Fieldqty"), 'checked'=>1),
+'t.import_key'=>array('label'=>$langs->trans("Fieldimport_key"), '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.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
+ //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+);
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+ foreach($extrafields->attribute_label as $key => $val)
+ {
+ $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
+ }
+}
+
+
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+if (GETPOST('cancel')) { $action='list'; $massaction=''; }
+if (! GETPOST('confirmmassaction')) { $massaction=''; }
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
+{
+
+$search_fk_product='';
+$search_batch='';
+$search_note_public='';
+$search_note_private='';
+$search_qty='';
+$search_import_key='';
+
+
+ $search_date_creation='';
+ $search_date_update='';
+ $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');
+ }
+ }
+}
+
+
+
+
+/***************************************************
+* VIEW
+*
+* Put here all code to build page
+****************************************************/
+
+llxHeader('','MyPageName','');
+
+$form=new Form($db);
+
+// Put here content of your page
+$title = $langs->trans('MyModuleListTitle');
+
+// Example : Adding jquery code
+print '';
+
+
+$sql = "SELECT";
+$sql.= " t.rowid,";
+
+ $sql .= " t.tms,";
+ $sql .= " t.fk_product,";
+ $sql .= " t.batch,";
+ $sql .= " t.eatby,";
+ $sql .= " t.sellby,";
+ $sql .= " t.note_public,";
+ $sql .= " t.note_private,";
+ $sql .= " t.qty,";
+ $sql .= " t.import_key";
+
+
+// Add fields for extrafields
+foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
+// Add fields from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t";
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot_extrafields as ef on (u.rowid = ef.fk_object)";
+$sql.= " WHERE 1 = 1";
+//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
+
+if ($search_fk_product) $sql.= natural_search("fk_product",$search_fk_product);
+if ($search_batch) $sql.= natural_search("batch",$search_batch);
+if ($search_note_public) $sql.= natural_search("note_public",$search_note_public);
+if ($search_note_private) $sql.= natural_search("note_private",$search_note_private);
+if ($search_qty) $sql.= natural_search("qty",$search_qty);
+if ($search_import_key) $sql.= natural_search("import_key",$search_import_key);
+
+
+if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall);
+// Add where from extra fields
+foreach ($search_array_options as $key => $val)
+{
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ $typ=$extrafields->attribute_type[$tmpkey];
+ $mode=0;
+ if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
+ if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
+ {
+ $sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
+ }
+}
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+$sql.=$db->order($sortfield,$sortorder);
+//$sql.= $db->plimit($conf->liste_limit+1, $offset);
+
+// Count total nb of records
+$nbtotalofrecords = 0;
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+}
+
+$sql.= $db->plimit($limit+1, $offset);
+
+
+dol_syslog($script_file, LOG_DEBUG);
+$resql=$db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+
+ $params='';
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
+
+if ($search_fk_product != '') $params.= '&search_fk_product='.urlencode($search_fk_product);
+if ($search_batch != '') $params.= '&search_batch='.urlencode($search_batch);
+if ($search_note_public != '') $params.= '&search_note_public='.urlencode($search_note_public);
+if ($search_note_private != '') $params.= '&search_note_private='.urlencode($search_note_private);
+if ($search_qty != '') $params.= '&search_qty='.urlencode($search_qty);
+if ($search_import_key != '') $params.= '&search_import_key='.urlencode($search_import_key);
+
+
+ if ($optioncss != '') $param.='&optioncss='.$optioncss;
+ // Add $param from extra fields
+ foreach ($search_array_options as $key => $val)
+ {
+ $crit=$val;
+ $tmpkey=preg_replace('/search_options_/','',$key);
+ if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
+ }
+
+ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit);
+
+
+ print '
\n";
+
+ $db->free($result);
+}
+else
+{
+ $error++;
+ dol_print_error($db);
+}
+
+
+// End of page
+llxFooter();
+$db->close();