dolibarr 21.0.0-beta
mo_movements.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
33require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
34require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
36require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
37require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
38
39require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
40require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
41
50// Load translation files required by the page
51$langs->loadLangs(array("mrp", "stocks", "other"));
52
53// Get parameters
54$id = GETPOSTINT('id');
55$ref = GETPOST('ref', 'alpha');
56$action = GETPOST('action', 'aZ09');
57$confirm = GETPOST('confirm', 'alpha');
58$cancel = GETPOST('cancel', 'aZ09');
59$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'mostockmovement'; // To manage different context of search
60$backtopage = GETPOST('backtopage', 'alpha');
61$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
62$massaction = GETPOST('massaction', 'aZ09');
63$lineid = GETPOSTINT('lineid');
64
65$msid = GETPOSTINT('msid');
66
67$year = GETPOST("year"); // TODO Rename into search_year
68$month = GETPOST("month"); // TODO Rename into search_month
69
70$search_ref = GETPOST('search_ref', 'alpha');
71$search_movement = GETPOST("search_movement", 'alpha');
72$search_product_ref = trim(GETPOST("search_product_ref", 'alpha'));
73$search_product = trim(GETPOST("search_product", 'alpha'));
74$search_warehouse = trim(GETPOST("search_warehouse", 'alpha'));
75$search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha'));
76$search_user = trim(GETPOST("search_user", 'alpha'));
77$search_batch = trim(GETPOST("search_batch", 'alpha'));
78$search_qty = trim(GETPOST("search_qty", 'alpha'));
79$search_type_mouvement = GETPOST('search_type_mouvement', "intcomma");
80
81$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
82$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
83$sortfield = GETPOST('sortfield', 'aZ09comma');
84$sortorder = GETPOST('sortorder', 'aZ09comma');
85if (empty($page) || $page == -1) {
86 $page = 0;
87} // If $page is not defined, or '' or -1
88$offset = $limit * $page;
89if (!$sortfield) {
90 $sortfield = "m.datem";
91}
92if (!$sortorder) {
93 $sortorder = "DESC";
94}
95
96// Initialize a technical objects
97$object = new Mo($db);
98$extrafields = new ExtraFields($db);
99$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
100$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array
101
102// Fetch optionals attributes and labels
103$extrafields->fetch_name_optionals_label($object->table_element);
104
105$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
106
107// Initialize array of search criteria
108$search_all = trim(GETPOST("search_all", 'alpha'));
109$search = array();
110foreach ($object->fields as $key => $val) {
111 if (GETPOST('search_'.$key, 'alpha')) {
112 $search[$key] = GETPOST('search_'.$key, 'alpha');
113 }
114}
115
116if (empty($action) && empty($id) && empty($ref)) {
117 $action = 'view';
118}
119
120// Load object
121include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
122
123// Security check - Protection if external user
124//if ($user->socid > 0) accessforbidden();
125//if ($user->socid > 0) $socid = $user->socid;
126$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
127$result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft);
128
129$objectlist = new MouvementStock($db);
130
131// Definition of fields for list
132$arrayfields = array(
133 'm.rowid' => array('label' => "Ref", 'checked' => 1, 'position' => 1),
134 'm.datem' => array('label' => "Date", 'checked' => 1, 'position' => 2),
135 'p.ref' => array('label' => "ProductRef", 'checked' => 1, 'css' => 'maxwidth100', 'position' => 3),
136 'p.label' => array('label' => "ProductLabel", 'checked' => 0, 'position' => 5),
137 'm.batch' => array('label' => "BatchNumberShort", 'checked' => 1, 'position' => 8, 'enabled' => (isModEnabled('productbatch'))),
138 'pl.eatby' => array('label' => "EatByDate", 'checked' => 0, 'position' => 9, 'enabled' => (isModEnabled('productbatch'))),
139 'pl.sellby' => array('label' => "SellByDate", 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))),
140 'e.ref' => array('label' => "Warehouse", 'checked' => 1, 'position' => 100, 'enabled' => (!($id > 0))), // If we are on specific warehouse, we hide it
141 'm.fk_user_author' => array('label' => "Author", 'checked' => 0, 'position' => 120),
142 'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => 1, 'position' => 130),
143 'm.label' => array('label' => "MovementLabel", 'checked' => 1, 'position' => 140),
144 'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => 0, 'position' => 150),
145 'origin' => array('label' => "Origin", 'checked' => 1, 'position' => 155),
146 'm.fk_projet' => array('label' => 'Project', 'checked' => 0, 'position' => 180),
147 'm.value' => array('label' => "Qty", 'checked' => 1, 'position' => 200),
148 'm.price' => array('label' => "UnitPurchaseValue", 'checked' => 0, 'position' => 210)
149 //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
150 //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500)
151);
152if (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
153 unset($arrayfields['pl.sellby']);
154}
155if (getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
156 unset($arrayfields['pl.eatby']);
157}
158$objectlist->fields = dol_sort_array($objectlist->fields, 'position');
159$arrayfields = dol_sort_array($arrayfields, 'position');
160
161// Permissions
162$permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php
163$permissiondellink = $user->hasRight('mrp', 'write'); // Used by the include of actions_dellink.inc.php
164$permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
165$permissiontodelete = $user->hasRight('mrp', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
166$upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
167
168$permissiontoproduce = $permissiontoadd;
169$permissiontoupdatecost = $user->hasRight('bom', 'write'); // User who can define cost must have knowledge of pricing
170
171if ($permissiontoupdatecost) {
172 $arrayfields['m.price']['enabled'] = 1;
173}
174
175$arrayofselected = array();
176
177
178/*
179 * Actions
180 */
181
182if (GETPOST('cancel', 'alpha')) {
183 $action = 'list';
184 $massaction = '';
185}
186if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
187 $massaction = '';
188}
189
190$parameters = array();
191$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
192if ($reshook < 0) {
193 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
194}
195
196include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
197
198// Do we click on purge search criteria ?
199if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
200 $year = '';
201 $month = '';
202 $search_ref = '';
203 $search_movement = "";
204 $search_type_mouvement = "";
205 $search_inventorycode = "";
206 $search_product_ref = "";
207 $search_product = "";
208 $search_warehouse = "";
209 $search_user = "";
210 $search_batch = "";
211 $search_qty = '';
212 $search_all = "";
213 $toselect = array();
214 $search_array_options = array();
215}
216
217if (empty($reshook)) {
218 $error = 0;
219
220 $backurlforlist = dol_buildpath('/mrp/mo_list.php', 1);
221
222 if (empty($backtopage) || ($cancel && empty($id))) {
223 //var_dump($backurlforlist);exit;
224 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
225 $backtopage = $backurlforlist;
226 } else {
227 $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__');
228 }
229 }
230 $triggermodname = 'MO_MODIFY'; // Name of trigger action code to execute when we modify record
231
232 // Actions cancel, add, update, delete or clone
233 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
234
235 // Actions when linking object each other
236 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
237
238 // Actions when printing a doc from card
239 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
240
241 // Actions to send emails
242 $triggersendname = 'MO_SENTBYMAIL';
243 $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO';
244 $trackid = 'mo'.$object->id;
245 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
246
247 // Action to move up and down lines of object
248 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be 'include', not 'include_once'
249
250 if ($action == 'set_thirdparty' && $permissiontoadd) {
251 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
252 }
253 if ($action == 'classin' && $permissiontoadd) {
254 $object->setProject(GETPOSTINT('projectid'));
255 }
256
257 if ($action == 'confirm_reopen') {
258 $result = $object->setStatut($object::STATUS_INPROGRESS, 0, '', 'MRP_REOPEN');
259 }
260}
261
262
263
264/*
265 * View
266 */
267
268$form = new Form($db);
269$formproject = new FormProjets($db);
270$formproduct = new FormProduct($db);
271$productstatic = new Product($db);
272$productlot = new Productlot($db);
273$warehousestatic = new Entrepot($db);
274$userstatic = new User($db);
275
276$title = $langs->trans('Mo');
277$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
278
279llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-card_movements');
280
281// Part to show record
282if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
283 $res = $object->fetch_thirdparty();
284 $res = $object->fetch_optionals();
285
286 $head = moPrepareHead($object);
287
288 print dol_get_fiche_head($head, 'stockmovement', $langs->trans("ManufacturingOrder"), -1, $object->picto);
289
290 $formconfirm = '';
291
292 // Confirmation to delete
293 if ($action == 'delete') {
294 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1);
295 }
296 // Confirmation to delete line
297 if ($action == 'deleteline') {
298 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
299 }
300 // Clone confirmation
301 if ($action == 'clone') {
302 // Create an array for form
303 $formquestion = array();
304 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
305 }
306
307 // Confirmation of action xxxx
308 if ($action == 'xxx') {
309 $formquestion = array();
310 /*
311 $forcecombo=0;
312 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
313 $formquestion = array(
314 // 'text' => $langs->trans("ConfirmClone"),
315 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
316 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
317 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
318 );
319 */
320 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
321 }
322
323 // Call Hook formConfirm
324 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
325 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
326 if (empty($reshook)) {
327 $formconfirm .= $hookmanager->resPrint;
328 } elseif ($reshook > 0) {
329 $formconfirm = $hookmanager->resPrint;
330 }
331
332 // Print form confirm
333 print $formconfirm;
334
335
336 // Object card
337 // ------------------------------------------------------------
338 $linkback = '<a href="'.dol_buildpath('/mrp/mo_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
339
340 $morehtmlref = '<div class="refidno">';
341 /*
342 // Ref bis
343 $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1);
344 $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/
345 // Thirdparty
346 if (is_object($object->thirdparty)) {
347 $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer');
348 if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
349 $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
350 }
351 }
352 // Project
353 if (isModEnabled('project')) {
354 $langs->load("projects");
355 if (is_object($object->thirdparty)) {
356 $morehtmlref .= '<br>';
357 }
358 if ($permissiontoadd) {
359 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
360 if ($action != 'classify') {
361 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
362 }
363 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
364 } else {
365 if (!empty($object->fk_project)) {
366 $proj = new Project($db);
367 $proj->fetch($object->fk_project);
368 $morehtmlref .= $proj->getNomUrl(1);
369 if ($proj->title) {
370 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
371 }
372 }
373 }
374 }
375 $morehtmlref .= '</div>';
376
377
378 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
379
380
381 print '<div class="fichecenter">';
382 print '<div class="fichehalfleft">';
383 print '<div class="underbanner clearboth"></div>';
384 print '<table class="border centpercent tableforfield">'."\n";
385
386 // Common attributes
387 $keyforbreak = 'fk_warehouse';
388 unset($object->fields['fk_project']);
389 unset($object->fields['fk_soc']);
390 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
391
392 // Other attributes
393 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
394
395 print '</table>';
396 print '</div>';
397 print '</div>';
398
399 print '<div class="clearboth"></div>';
400
401 print dol_get_fiche_end();
402
403 /*
404 print '<div class="tabsAction">';
405
406 $parameters = array();
407 // Note that $action and $object may be modified by hook
408 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
409 if (empty($reshook)) {
410 // Cancel - Reopen
411 if ($permissiontoadd)
412 {
413 if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
414 {
415 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
416 }
417
418 if ($object->status == $object::STATUS_CANCELED)
419 {
420 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
421 }
422
423 if ($object->status == $object::STATUS_PRODUCED) {
424 if ($permissiontoproduce) {
425 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen">'.$langs->trans('ReOpen').'</a>';
426 } else {
427 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ReOpen').'</a>';
428 }
429 }
430 }
431 }
432
433 print '</div>';
434 */
435
436
437 $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
438 $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
439 $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
440 $sql .= " m.batch, m.price,";
441 $sql .= " m.type_mouvement,";
442 $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
443 $sql .= " u.login, u.photo, u.lastname, u.firstname";
444 // Add fields from extrafields
445 if (!empty($extrafields->attributes[$objectlist->table_element]['label'])) {
446 foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) {
447 $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
448 }
449 }
450 // Add fields from hooks
451 $parameters = array();
452 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $objectlist may have been modified by hook
453 $sql .= $hookmanager->resPrint;
454 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
455 $sql .= " ".MAIN_DB_PREFIX."product as p,";
456 $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
457 if (!empty($extrafields->attributes[$objectlist->table_element]) && is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) {
458 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
459 }
460 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
461 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
462 $sql .= " WHERE m.fk_product = p.rowid";
463 $sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id;
464 if ($msid > 0) {
465 $sql .= " AND m.rowid = ".((int) $msid);
466 }
467 $sql .= " AND m.fk_entrepot = e.rowid";
468 $sql .= " AND e.entity IN (".getEntity('stock').")";
469 if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
470 $sql .= " AND p.fk_product_type = 0";
471 }
472 $sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
473 if (!empty($search_ref)) {
474 $sql .= natural_search('m.rowid', $search_ref, 1);
475 }
476 if (!empty($search_movement)) {
477 $sql .= natural_search('m.label', $search_movement);
478 }
479 if (!empty($search_inventorycode)) {
480 $sql .= natural_search('m.inventorycode', $search_inventorycode);
481 }
482 if (!empty($search_product_ref)) {
483 $sql .= natural_search('p.ref', $search_product_ref);
484 }
485 if (!empty($search_product)) {
486 $sql .= natural_search('p.label', $search_product);
487 }
488 if ($search_warehouse != '' && $search_warehouse != '-1') {
489 $sql .= natural_search('e.rowid', $search_warehouse, 2);
490 }
491 if (!empty($search_user)) {
492 $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
493 }
494 if (!empty($search_batch)) {
495 $sql .= natural_search('m.batch', $search_batch);
496 }
497 if ($search_qty != '') {
498 $sql .= natural_search('m.value', $search_qty, 1);
499 }
500 if ($search_type_mouvement != '' && $search_type_mouvement != '-1') {
501 $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
502 }
503 // Add where from extra fields
504 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
505 // Add where from hooks
506 $parameters = array();
507 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $objectlist may have been modified by hook
508 $sql .= $hookmanager->resPrint;
509 $sql .= $db->order($sortfield, $sortorder);
510
511 $nbtotalofrecords = '';
512 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
513 $result = $db->query($sql);
514 $nbtotalofrecords = $db->num_rows($result);
515 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
516 $page = 0;
517 $offset = 0;
518 }
519 }
520 $sql .= $db->plimit($limit + 1, $offset);
521
522 $resql = $db->query($sql);
523 if (!$resql) {
524 dol_print_error($db);
525 }
526 $num = $db->num_rows($resql);
527
528 $param = '';
529 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
530 $param .= '&contextpage='.urlencode($contextpage);
531 }
532 if ($limit > 0 && $limit != $conf->liste_limit) {
533 $param .= '&limit='.((int) $limit);
534 }
535 if ($id > 0) {
536 $param .= '&id='.urlencode((string) ($id));
537 }
538 if ($search_movement) {
539 $param .= '&search_movement='.urlencode($search_movement);
540 }
541 if ($search_inventorycode) {
542 $param .= '&search_inventorycode='.urlencode($search_inventorycode);
543 }
544 if ($search_type_mouvement) {
545 $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
546 }
547 if ($search_product_ref) {
548 $param .= '&search_product_ref='.urlencode($search_product_ref);
549 }
550 if ($search_product) {
551 $param .= '&search_product='.urlencode($search_product);
552 }
553 if ($search_batch) {
554 $param .= '&search_batch='.urlencode($search_batch);
555 }
556 if ($search_warehouse > 0) {
557 $param .= '&search_warehouse='.urlencode($search_warehouse);
558 }
559 if ($search_user) {
560 $param .= '&search_user='.urlencode($search_user);
561 }
562
563 // Add $param from extra fields
564 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
565
566 // List of mass actions available
567 $arrayofmassactions = array(
568 // 'presend'=>$langs->trans("SendByMail"),
569 // 'builddoc'=>$langs->trans("PDFMerge"),
570 );
571 //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
572 if (in_array($massaction, array('presend', 'predelete'))) {
573 $arrayofmassactions = array();
574 }
575 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
576
577 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
578 if ($optioncss != '') {
579 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
580 }
581 print '<input type="hidden" name="token" value="'.newToken().'">';
582 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
583 print '<input type="hidden" name="action" value="list">';
584 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
585 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
586 print '<input type="hidden" name="page" value="'.$page.'">';
587 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
588 if ($id > 0) {
589 print '<input type="hidden" name="id" value="'.$id.'">';
590 }
591
592 if ($id > 0) {
593 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
594 } else {
595 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
596 }
597
598 $moreforfilter = '';
599
600 $parameters = array();
601 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
602 if (empty($reshook)) {
603 $moreforfilter .= $hookmanager->resPrint;
604 } else {
605 $moreforfilter = $hookmanager->resPrint;
606 }
607
608 if (!empty($moreforfilter)) {
609 print '<div class="liste_titre liste_titre_bydiv centpercent">';
610 print $moreforfilter;
611 print '</div>';
612 }
613
614 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
615 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
616 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
617
618 print '<div class="div-table-responsive">';
619 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
620
621 // Fields title search
622 print '<tr class="liste_titre_filter">';
623 // Actions
624 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
625 print '<td class="liste_titre maxwidthsearch">';
626 $searchpicto = $form->showFilterAndCheckAddButtons(0);
627 print $searchpicto;
628 print '</td>';
629 }
630 if (!empty($arrayfields['m.rowid']['checked'])) {
631 // Ref
632 print '<td class="liste_titre left">';
633 print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
634 print '</td>';
635 }
636 if (!empty($arrayfields['m.datem']['checked'])) {
637 print '<td class="liste_titre nowraponall">';
638 print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">';
639 if (!isModEnabled('productbatch')) {
640 print '&nbsp;';
641 }
642 //else print '<br>';
643 $syear = $year ? $year : -1;
644 print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">';
645 //print $formother->selectyear($syear,'year',1, 20, 5);
646 print '</td>';
647 }
648 if (!empty($arrayfields['p.ref']['checked'])) {
649 // Product Ref
650 print '<td class="liste_titre left">';
651 print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($search_product_ref).'">';
652 print '</td>';
653 }
654 if (!empty($arrayfields['p.label']['checked'])) {
655 // Product label
656 print '<td class="liste_titre left">';
657 print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($search_product).'">';
658 print '</td>';
659 }
660 // Batch
661 if (!empty($arrayfields['m.batch']['checked'])) {
662 print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
663 }
664 if (!empty($arrayfields['pl.eatby']['checked'])) {
665 print '<td class="liste_titre left">';
666 print '</td>';
667 }
668 if (!empty($arrayfields['pl.sellby']['checked'])) {
669 print '<td class="liste_titre left">';
670 print '</td>';
671 }
672 // Warehouse
673 if (!empty($arrayfields['e.ref']['checked'])) {
674 print '<td class="liste_titre maxwidthonsmartphone left">';
675 //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
676 print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'maxwidth200');
677 print '</td>';
678 }
679 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
680 // Author
681 print '<td class="liste_titre left">';
682 print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
683 print '</td>';
684 }
685 if (!empty($arrayfields['m.inventorycode']['checked'])) {
686 // Inventory code
687 print '<td class="liste_titre left">';
688 print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
689 print '</td>';
690 }
691 if (!empty($arrayfields['m.label']['checked'])) {
692 // Label of movement
693 print '<td class="liste_titre left">';
694 print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
695 print '</td>';
696 }
697 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
698 // Type of movement
699 print '<td class="liste_titre center">';
700 //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
701 print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
702 print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'>&nbsp;</option>';
703 print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>';
704 print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>';
705 print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>';
706 print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>';
707 print '</select>';
708 print ajax_combobox('search_type_mouvement');
709 // TODO: add new function $formentrepot->selectTypeOfMovement(...) like
710 // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
711 print '</td>';
712 }
713 if (!empty($arrayfields['origin']['checked'])) {
714 // Origin of movement
715 print '<td class="liste_titre left">';
716 print '&nbsp; ';
717 print '</td>';
718 }
719 if (!empty($arrayfields['m.fk_projet']['checked'])) {
720 // fk_project
721 print '<td class="liste_titre" align="left">';
722 print '&nbsp; ';
723 print '</td>';
724 }
725 if (!empty($arrayfields['m.value']['checked'])) {
726 // Qty
727 print '<td class="liste_titre right">';
728 print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
729 print '</td>';
730 }
731 if (!empty($arrayfields['m.price']['checked'])) {
732 // Price
733 print '<td class="liste_titre left">';
734 print '&nbsp; ';
735 print '</td>';
736 }
737
738
739 // Extra fields
740 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
741
742 // Fields from hook
743 $parameters = array('arrayfields' => $arrayfields);
744 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
745 print $hookmanager->resPrint;
746 // Date creation
747 if (!empty($arrayfields['m.datec']['checked'])) {
748 print '<td class="liste_titre">';
749 print '</td>';
750 }
751 // Date modification
752 if (!empty($arrayfields['m.tms']['checked'])) {
753 print '<td class="liste_titre">';
754 print '</td>';
755 }
756 // Actions
757 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
758 print '<td class="liste_titre maxwidthsearch">';
759 $searchpicto = $form->showFilterAndCheckAddButtons(0);
760 print $searchpicto;
761 print '</td>';
762 }
763 print "</tr>\n";
764
765 $totalarray = array();
766 $totalarray['nbfield'] = 0;
767
768 print '<tr class="liste_titre">';
769 // Action column
770 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
771 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
772 $totalarray['nbfield']++;
773 }
774 if (!empty($arrayfields['m.rowid']['checked'])) {
775 print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
776 $totalarray['nbfield']++;
777 }
778 if (!empty($arrayfields['m.datem']['checked'])) {
779 print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
780 $totalarray['nbfield']++;
781 }
782 if (!empty($arrayfields['p.ref']['checked'])) {
783 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
784 $totalarray['nbfield']++;
785 }
786 if (!empty($arrayfields['p.label']['checked'])) {
787 print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
788 $totalarray['nbfield']++;
789 }
790 if (!empty($arrayfields['m.batch']['checked'])) {
791 print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center ');
792 $totalarray['nbfield']++;
793 }
794 if (!empty($arrayfields['pl.eatby']['checked'])) {
795 print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center ');
796 $totalarray['nbfield']++;
797 }
798 if (!empty($arrayfields['pl.sellby']['checked'])) {
799 print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center ');
800 $totalarray['nbfield']++;
801 }
802 if (!empty($arrayfields['e.ref']['checked'])) {
803 // We are on a specific warehouse card, no filter on other should be possible
804 print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
805 $totalarray['nbfield']++;
806 }
807 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
808 print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
809 $totalarray['nbfield']++;
810 }
811 if (!empty($arrayfields['m.inventorycode']['checked'])) {
812 print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
813 $totalarray['nbfield']++;
814 }
815 if (!empty($arrayfields['m.label']['checked'])) {
816 print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
817 $totalarray['nbfield']++;
818 }
819 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
820 print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center ');
821 $totalarray['nbfield']++;
822 }
823 if (!empty($arrayfields['origin']['checked'])) {
824 print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
825 $totalarray['nbfield']++;
826 }
827 if (!empty($arrayfields['m.fk_projet']['checked'])) {
828 print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder);
829 $totalarray['nbfield']++;
830 }
831 if (!empty($arrayfields['m.value']['checked'])) {
832 print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right ');
833 $totalarray['nbfield']++;
834 }
835 if (!empty($arrayfields['m.price']['checked'])) {
836 // @phan-suppress-next-line PhanTypeInvalidDimOffset
837 print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
838 $totalarray['nbfield']++;
839 }
840
841 // Extra fields
842 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
843
844 // Hook fields
845 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
846 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
847 print $hookmanager->resPrint;
848 if (!empty($arrayfields['m.datec']['checked'])) {
849 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
850 $totalarray['nbfield']++;
851 }
852 if (!empty($arrayfields['m.tms']['checked'])) {
853 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
854 $totalarray['nbfield']++;
855 }
856 // Action column
857 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
858 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
859 $totalarray['nbfield']++;
860 }
861 print "</tr>\n";
862
863 $i = 0;
864 $savnbfield = $totalarray['nbfield'];
865 $totalarray = array();
866 $totalarray['nbfield'] = 0;
867 $imaxinloop = ($limit ? min($num, $limit) : $num);
868 while ($i < $imaxinloop) {
869 $objp = $db->fetch_object($resql);
870
871 // Multilangs
872 if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled
873 // TODO Use a cache here
874 $sql = "SELECT label";
875 $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
876 $sql .= " WHERE fk_product = ".((int) $objp->rowid);
877 $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
878 $sql .= " LIMIT 1";
879
880 $result = $db->query($sql);
881 if ($result) {
882 $objtp = $db->fetch_object($result);
883 if (!empty($objtp->label)) {
884 $objp->produit = $objtp->label;
885 }
886 }
887 }
888
889 $userstatic->id = $objp->fk_user_author;
890 $userstatic->login = $objp->login;
891 $userstatic->lastname = $objp->lastname;
892 $userstatic->firstname = $objp->firstname;
893 $userstatic->photo = $objp->photo;
894
895 $productstatic->id = $objp->rowid;
896 $productstatic->ref = $objp->product_ref;
897 $productstatic->label = $objp->produit;
898 $productstatic->type = $objp->type;
899 $productstatic->entity = $objp->entity;
900 $productstatic->status_batch = $objp->tobatch;
901
902 $productlot->id = $objp->lotid;
903 $productlot->batch = $objp->batch;
904 $productlot->eatby = $objp->eatby;
905 $productlot->sellby = $objp->sellby;
906
907 $warehousestatic->id = $objp->entrepot_id;
908 $warehousestatic->libelle = $objp->warehouse_ref; // deprecated
909 $warehousestatic->label = $objp->warehouse_ref;
910 $warehousestatic->lieu = $objp->lieu;
911
912 if (!empty($objp->fk_origin)) {
913 $origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype);
914 } else {
915 $origin = '';
916 }
917
918 print '<tr class="oddeven">';
919 // Action column
920 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
921 print '<td class="nowrap center">';
922 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
923 $selected = 0;
924 if (in_array($objp->rowid, $arrayofselected)) {
925 $selected = 1;
926 }
927 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
928 }
929 print '</td>';
930 if (!$i) {
931 $totalarray['nbfield']++;
932 }
933 }
934 // Id movement
935 if (!empty($arrayfields['m.rowid']['checked'])) {
936 // This is primary not movement id
937 print '<td>'.dol_escape_htmltag($objp->mid).'</td>';
938 }
939 if (!empty($arrayfields['m.datem']['checked'])) {
940 // Date
941 print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>';
942 }
943 if (!empty($arrayfields['p.ref']['checked'])) {
944 // Product ref
945 print '<td class="nowraponall">';
946 print $productstatic->getNomUrl(1, 'stock', 16);
947 print "</td>\n";
948 }
949 if (!empty($arrayfields['p.label']['checked'])) {
950 // Product label
951 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">';
952 print $productstatic->label;
953 print "</td>\n";
954 }
955 if (!empty($arrayfields['m.batch']['checked'])) {
956 print '<td class="center nowraponall">';
957 if ($productlot->id > 0) {
958 print $productlot->getNomUrl(1);
959 } else {
960 print dol_escape_htmltag($productlot->batch); // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement.
961 }
962 print '</td>';
963 }
964 if (!empty($arrayfields['pl.eatby']['checked'])) {
965 print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>';
966 }
967 if (!empty($arrayfields['pl.sellby']['checked'])) {
968 print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>';
969 }
970 // Warehouse
971 if (!empty($arrayfields['e.ref']['checked'])) {
972 print '<td>';
973 print $warehousestatic->getNomUrl(1);
974 print "</td>\n";
975 }
976 // Author
977 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
978 print '<td class="tdoverflowmax100">';
979 print $userstatic->getNomUrl(-1);
980 print "</td>\n";
981 }
982 // Inventory code
983 if (!empty($arrayfields['m.inventorycode']['checked'])) {
984 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objp->inventorycode).'">';
985 //print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_card.php' . '?id=' . $objp->entrepot_id . '&amp;search_inventorycode=' . $objp->inventorycode . '&amp;search_type_mouvement=' . $objp->type_mouvement . '">';
986 print dol_escape_htmltag($objp->inventorycode);
987 //print '</a>';
988 print '</td>';
989 }
990 // Label of movement
991 if (!empty($arrayfields['m.label']['checked'])) {
992 print '<td class="tdoverflowmax300" title="'.dol_escape_htmltag($objp->label).'">'.dol_escape_htmltag($objp->label).'</td>';
993 }
994 // Type of movement
995 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
996 switch ($objp->type_mouvement) {
997 case "0":
998 print '<td class="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
999 break;
1000 case "1":
1001 print '<td class="center">'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</td>';
1002 break;
1003 case "2":
1004 print '<td class="center">'.$langs->trans('StockDecrease').'</td>';
1005 break;
1006 case "3":
1007 print '<td class="center">'.$langs->trans('StockIncrease').'</td>';
1008 break;
1009 }
1010 }
1011 if (!empty($arrayfields['origin']['checked'])) {
1012 // Origin of movement
1013 print '<td class="nowraponall">'.$origin.'</td>';
1014 }
1015 if (!empty($arrayfields['m.fk_projet']['checked'])) {
1016 // fk_project
1017 print '<td>';
1018 if ($objp->fk_project != 0) {
1019 print $movement->get_origin($objp->fk_project, 'project');
1020 }
1021 print '</td>';
1022 }
1023 if (!empty($arrayfields['m.value']['checked'])) {
1024 // Qty
1025 print '<td class="right">';
1026 if ($objp->qty > 0) {
1027 print '<span class="stockmovemententry">+'.$objp->qty.'</span>';
1028 } else {
1029 print '<span class="stockmovementexit">'.$objp->qty.'<span>';
1030 }
1031 print '</td>';
1032 }
1033 if (!empty($arrayfields['m.price']['checked'])) {
1034 // Price
1035 print '<td class="right">';
1036 if ($objp->price != 0) {
1037 print '<span class="opacitymedium">'.price($objp->price).'</span>';
1038 }
1039 print '</td>';
1040 }
1041 // Action column
1042 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1043 print '<td class="nowrap center">';
1044 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1045 $selected = 0;
1046 if (in_array($objp->rowid, $arrayofselected)) {
1047 $selected = 1;
1048 }
1049 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1050 }
1051 print '</td>';
1052 if (!$i) {
1053 $totalarray['nbfield']++;
1054 }
1055 }
1056
1057 print "</tr>\n";
1058 $i++;
1059 }
1060 if (empty($num)) {
1061 print '<tr><td colspan="'.$savnbfield.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1062 }
1063
1064 $db->free($resql);
1065
1066 print "</table>";
1067 print '</div>';
1068 print "</form>";
1069}
1070
1071// End of page
1072llxFooter();
1073$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition ajax.lib.php:459
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage building of HTML components.
Class for Mo.
Definition mo.class.php:34
Class to manage stock movements.
Class to manage products or services.
Class with list of lots and properties.
Class to manage projects.
Class to manage Dolibarr users.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition date.lib.php:382
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
moPrepareHead($object)
Prepare array of tabs for Mo.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.