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