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