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