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