dolibarr 20.0.0
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 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$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
268
269llxHeader('', $langs->trans('Mo'), $help_url);
270
271// Part to show record
272if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
273 $res = $object->fetch_thirdparty();
274 $res = $object->fetch_optionals();
275
276 $head = moPrepareHead($object);
277
278 print dol_get_fiche_head($head, 'stockmovement', $langs->trans("ManufacturingOrder"), -1, $object->picto);
279
280 $formconfirm = '';
281
282 // Confirmation to delete
283 if ($action == 'delete') {
284 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMo'), $langs->trans('ConfirmDeleteMo'), 'confirm_delete', '', 0, 1);
285 }
286 // Confirmation to delete line
287 if ($action == 'deleteline') {
288 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
289 }
290 // Clone confirmation
291 if ($action == 'clone') {
292 // Create an array for form
293 $formquestion = array();
294 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMo', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
295 }
296
297 // Confirmation of action xxxx
298 if ($action == 'xxx') {
299 $formquestion = array();
300 /*
301 $forcecombo=0;
302 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
303 $formquestion = array(
304 // 'text' => $langs->trans("ConfirmClone"),
305 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
306 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
307 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
308 );
309 */
310 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
311 }
312
313 // Call Hook formConfirm
314 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
315 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
316 if (empty($reshook)) {
317 $formconfirm .= $hookmanager->resPrint;
318 } elseif ($reshook > 0) {
319 $formconfirm = $hookmanager->resPrint;
320 }
321
322 // Print form confirm
323 print $formconfirm;
324
325
326 // Object card
327 // ------------------------------------------------------------
328 $linkback = '<a href="'.dol_buildpath('/mrp/mo_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
329
330 $morehtmlref = '<div class="refidno">';
331 /*
332 // Ref bis
333 $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1);
334 $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/
335 // Thirdparty
336 if (is_object($object->thirdparty)) {
337 $morehtmlref .= $object->thirdparty->getNomUrl(1, 'customer');
338 if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
339 $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
340 }
341 }
342 // Project
343 if (isModEnabled('project')) {
344 $langs->load("projects");
345 if (is_object($object->thirdparty)) {
346 $morehtmlref .= '<br>';
347 }
348 if ($permissiontoadd) {
349 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
350 if ($action != 'classify') {
351 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
352 }
353 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
354 } else {
355 if (!empty($object->fk_project)) {
356 $proj = new Project($db);
357 $proj->fetch($object->fk_project);
358 $morehtmlref .= $proj->getNomUrl(1);
359 if ($proj->title) {
360 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
361 }
362 }
363 }
364 }
365 $morehtmlref .= '</div>';
366
367
368 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
369
370
371 print '<div class="fichecenter">';
372 print '<div class="fichehalfleft">';
373 print '<div class="underbanner clearboth"></div>';
374 print '<table class="border centpercent tableforfield">'."\n";
375
376 // Common attributes
377 $keyforbreak = 'fk_warehouse';
378 unset($object->fields['fk_project']);
379 unset($object->fields['fk_soc']);
380 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
381
382 // Other attributes
383 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
384
385 print '</table>';
386 print '</div>';
387 print '</div>';
388
389 print '<div class="clearboth"></div>';
390
391 print dol_get_fiche_end();
392
393 /*
394 print '<div class="tabsAction">';
395
396 $parameters = array();
397 // Note that $action and $object may be modified by hook
398 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
399 if (empty($reshook)) {
400 // Cancel - Reopen
401 if ($permissiontoadd)
402 {
403 if ($object->status == $object::STATUS_VALIDATED || $object->status == $object::STATUS_INPROGRESS)
404 {
405 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes">'.$langs->trans("Cancel").'</a>'."\n";
406 }
407
408 if ($object->status == $object::STATUS_CANCELED)
409 {
410 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes">'.$langs->trans("Re-Open").'</a>'."\n";
411 }
412
413 if ($object->status == $object::STATUS_PRODUCED) {
414 if ($permissiontoproduce) {
415 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen">'.$langs->trans('ReOpen').'</a>';
416 } else {
417 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ReOpen').'</a>';
418 }
419 }
420 }
421 }
422
423 print '</div>';
424 */
425
426
427 $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
428 $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
429 $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
430 $sql .= " m.batch, m.price,";
431 $sql .= " m.type_mouvement,";
432 $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
433 $sql .= " u.login, u.photo, u.lastname, u.firstname";
434 // Add fields from extrafields
435 if (!empty($extrafields->attributes[$objectlist->table_element]['label'])) {
436 foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) {
437 $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
438 }
439 }
440 // Add fields from hooks
441 $parameters = array();
442 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $objectlist may have been modified by hook
443 $sql .= $hookmanager->resPrint;
444 $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
445 $sql .= " ".MAIN_DB_PREFIX."product as p,";
446 $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
447 if (!empty($extrafields->attributes[$objectlist->table_element]) && is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) {
448 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
449 }
450 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
451 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
452 $sql .= " WHERE m.fk_product = p.rowid";
453 $sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id;
454 if ($msid > 0) {
455 $sql .= " AND m.rowid = ".((int) $msid);
456 }
457 $sql .= " AND m.fk_entrepot = e.rowid";
458 $sql .= " AND e.entity IN (".getEntity('stock').")";
459 if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
460 $sql .= " AND p.fk_product_type = 0";
461 }
462 $sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
463 if (!empty($search_ref)) {
464 $sql .= natural_search('m.rowid', $search_ref, 1);
465 }
466 if (!empty($search_movement)) {
467 $sql .= natural_search('m.label', $search_movement);
468 }
469 if (!empty($search_inventorycode)) {
470 $sql .= natural_search('m.inventorycode', $search_inventorycode);
471 }
472 if (!empty($search_product_ref)) {
473 $sql .= natural_search('p.ref', $search_product_ref);
474 }
475 if (!empty($search_product)) {
476 $sql .= natural_search('p.label', $search_product);
477 }
478 if ($search_warehouse != '' && $search_warehouse != '-1') {
479 $sql .= natural_search('e.rowid', $search_warehouse, 2);
480 }
481 if (!empty($search_user)) {
482 $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user);
483 }
484 if (!empty($search_batch)) {
485 $sql .= natural_search('m.batch', $search_batch);
486 }
487 if ($search_qty != '') {
488 $sql .= natural_search('m.value', $search_qty, 1);
489 }
490 if ($search_type_mouvement != '' && $search_type_mouvement != '-1') {
491 $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
492 }
493 // Add where from extra fields
494 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
495 // Add where from hooks
496 $parameters = array();
497 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $objectlist may have been modified by hook
498 $sql .= $hookmanager->resPrint;
499 $sql .= $db->order($sortfield, $sortorder);
500
501 $nbtotalofrecords = '';
502 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
503 $result = $db->query($sql);
504 $nbtotalofrecords = $db->num_rows($result);
505 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
506 $page = 0;
507 $offset = 0;
508 }
509 }
510 $sql .= $db->plimit($limit + 1, $offset);
511
512 $resql = $db->query($sql);
513 if (!$resql) {
514 dol_print_error($db);
515 }
516 $num = $db->num_rows($resql);
517
518 $param = '';
519 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
520 $param .= '&contextpage='.urlencode($contextpage);
521 }
522 if ($limit > 0 && $limit != $conf->liste_limit) {
523 $param .= '&limit='.((int) $limit);
524 }
525 if ($id > 0) {
526 $param .= '&id='.urlencode((string) ($id));
527 }
528 if ($search_movement) {
529 $param .= '&search_movement='.urlencode($search_movement);
530 }
531 if ($search_inventorycode) {
532 $param .= '&search_inventorycode='.urlencode($search_inventorycode);
533 }
534 if ($search_type_mouvement) {
535 $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
536 }
537 if ($search_product_ref) {
538 $param .= '&search_product_ref='.urlencode($search_product_ref);
539 }
540 if ($search_product) {
541 $param .= '&search_product='.urlencode($search_product);
542 }
543 if ($search_batch) {
544 $param .= '&search_batch='.urlencode($search_batch);
545 }
546 if ($search_warehouse > 0) {
547 $param .= '&search_warehouse='.urlencode($search_warehouse);
548 }
549 if ($search_user) {
550 $param .= '&search_user='.urlencode($search_user);
551 }
552
553 // Add $param from extra fields
554 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
555
556 // List of mass actions available
557 $arrayofmassactions = array(
558 // 'presend'=>$langs->trans("SendByMail"),
559 // 'builddoc'=>$langs->trans("PDFMerge"),
560 );
561 //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
562 if (in_array($massaction, array('presend', 'predelete'))) {
563 $arrayofmassactions = array();
564 }
565 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
566
567 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
568 if ($optioncss != '') {
569 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
570 }
571 print '<input type="hidden" name="token" value="'.newToken().'">';
572 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
573 print '<input type="hidden" name="action" value="list">';
574 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
575 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
576 print '<input type="hidden" name="page" value="'.$page.'">';
577 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
578 if ($id > 0) {
579 print '<input type="hidden" name="id" value="'.$id.'">';
580 }
581
582 if ($id > 0) {
583 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
584 } else {
585 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
586 }
587
588 $moreforfilter = '';
589
590 $parameters = array();
591 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
592 if (empty($reshook)) {
593 $moreforfilter .= $hookmanager->resPrint;
594 } else {
595 $moreforfilter = $hookmanager->resPrint;
596 }
597
598 if (!empty($moreforfilter)) {
599 print '<div class="liste_titre liste_titre_bydiv centpercent">';
600 print $moreforfilter;
601 print '</div>';
602 }
603
604 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
605 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
606 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
607
608 print '<div class="div-table-responsive">';
609 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
610
611 // Fields title search
612 print '<tr class="liste_titre_filter">';
613 // Actions
614 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
615 print '<td class="liste_titre maxwidthsearch">';
616 $searchpicto = $form->showFilterAndCheckAddButtons(0);
617 print $searchpicto;
618 print '</td>';
619 }
620 if (!empty($arrayfields['m.rowid']['checked'])) {
621 // Ref
622 print '<td class="liste_titre left">';
623 print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
624 print '</td>';
625 }
626 if (!empty($arrayfields['m.datem']['checked'])) {
627 print '<td class="liste_titre nowraponall">';
628 print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">';
629 if (!isModEnabled('productbatch')) {
630 print '&nbsp;';
631 }
632 //else print '<br>';
633 $syear = $year ? $year : -1;
634 print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">';
635 //print $formother->selectyear($syear,'year',1, 20, 5);
636 print '</td>';
637 }
638 if (!empty($arrayfields['p.ref']['checked'])) {
639 // Product Ref
640 print '<td class="liste_titre left">';
641 print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($search_product_ref).'">';
642 print '</td>';
643 }
644 if (!empty($arrayfields['p.label']['checked'])) {
645 // Product label
646 print '<td class="liste_titre left">';
647 print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($search_product).'">';
648 print '</td>';
649 }
650 // Batch
651 if (!empty($arrayfields['m.batch']['checked'])) {
652 print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
653 }
654 if (!empty($arrayfields['pl.eatby']['checked'])) {
655 print '<td class="liste_titre left">';
656 print '</td>';
657 }
658 if (!empty($arrayfields['pl.sellby']['checked'])) {
659 print '<td class="liste_titre left">';
660 print '</td>';
661 }
662 // Warehouse
663 if (!empty($arrayfields['e.ref']['checked'])) {
664 print '<td class="liste_titre maxwidthonsmartphone left">';
665 //print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
666 print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
667 print '</td>';
668 }
669 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
670 // Author
671 print '<td class="liste_titre left">';
672 print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
673 print '</td>';
674 }
675 if (!empty($arrayfields['m.inventorycode']['checked'])) {
676 // Inventory code
677 print '<td class="liste_titre left">';
678 print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
679 print '</td>';
680 }
681 if (!empty($arrayfields['m.label']['checked'])) {
682 // Label of movement
683 print '<td class="liste_titre left">';
684 print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
685 print '</td>';
686 }
687 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
688 // Type of movement
689 print '<td class="liste_titre center">';
690 //print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
691 print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
692 print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'>&nbsp;</option>';
693 print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>';
694 print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>';
695 print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>';
696 print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>';
697 print '</select>';
698 print ajax_combobox('search_type_mouvement');
699 // TODO: add new function $formentrepot->selectTypeOfMovement(...) like
700 // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
701 print '</td>';
702 }
703 if (!empty($arrayfields['origin']['checked'])) {
704 // Origin of movement
705 print '<td class="liste_titre left">';
706 print '&nbsp; ';
707 print '</td>';
708 }
709 if (!empty($arrayfields['m.fk_projet']['checked'])) {
710 // fk_project
711 print '<td class="liste_titre" align="left">';
712 print '&nbsp; ';
713 print '</td>';
714 }
715 if (!empty($arrayfields['m.value']['checked'])) {
716 // Qty
717 print '<td class="liste_titre right">';
718 print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
719 print '</td>';
720 }
721 if (!empty($arrayfields['m.price']['checked'])) {
722 // Price
723 print '<td class="liste_titre left">';
724 print '&nbsp; ';
725 print '</td>';
726 }
727
728
729 // Extra fields
730 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
731
732 // Fields from hook
733 $parameters = array('arrayfields' => $arrayfields);
734 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
735 print $hookmanager->resPrint;
736 // Date creation
737 if (!empty($arrayfields['m.datec']['checked'])) {
738 print '<td class="liste_titre">';
739 print '</td>';
740 }
741 // Date modification
742 if (!empty($arrayfields['m.tms']['checked'])) {
743 print '<td class="liste_titre">';
744 print '</td>';
745 }
746 // Actions
747 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
748 print '<td class="liste_titre maxwidthsearch">';
749 $searchpicto = $form->showFilterAndCheckAddButtons(0);
750 print $searchpicto;
751 print '</td>';
752 }
753 print "</tr>\n";
754
755 $totalarray = array();
756 $totalarray['nbfield'] = 0;
757
758 print '<tr class="liste_titre">';
759 // Action column
760 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
761 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
762 $totalarray['nbfield']++;
763 }
764 if (!empty($arrayfields['m.rowid']['checked'])) {
765 print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
766 $totalarray['nbfield']++;
767 }
768 if (!empty($arrayfields['m.datem']['checked'])) {
769 print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
770 $totalarray['nbfield']++;
771 }
772 if (!empty($arrayfields['p.ref']['checked'])) {
773 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
774 $totalarray['nbfield']++;
775 }
776 if (!empty($arrayfields['p.label']['checked'])) {
777 print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
778 $totalarray['nbfield']++;
779 }
780 if (!empty($arrayfields['m.batch']['checked'])) {
781 print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center ');
782 $totalarray['nbfield']++;
783 }
784 if (!empty($arrayfields['pl.eatby']['checked'])) {
785 print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center ');
786 $totalarray['nbfield']++;
787 }
788 if (!empty($arrayfields['pl.sellby']['checked'])) {
789 print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center ');
790 $totalarray['nbfield']++;
791 }
792 if (!empty($arrayfields['e.ref']['checked'])) {
793 // We are on a specific warehouse card, no filter on other should be possible
794 print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
795 $totalarray['nbfield']++;
796 }
797 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
798 print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
799 $totalarray['nbfield']++;
800 }
801 if (!empty($arrayfields['m.inventorycode']['checked'])) {
802 print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
803 $totalarray['nbfield']++;
804 }
805 if (!empty($arrayfields['m.label']['checked'])) {
806 print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
807 $totalarray['nbfield']++;
808 }
809 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
810 print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center ');
811 $totalarray['nbfield']++;
812 }
813 if (!empty($arrayfields['origin']['checked'])) {
814 print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
815 $totalarray['nbfield']++;
816 }
817 if (!empty($arrayfields['m.fk_projet']['checked'])) {
818 print_liste_field_titre($arrayfields['m.fk_projet']['label'], $_SERVER["PHP_SELF"], "m.fk_projet", "", $param, '', $sortfield, $sortorder);
819 $totalarray['nbfield']++;
820 }
821 if (!empty($arrayfields['m.value']['checked'])) {
822 print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right ');
823 $totalarray['nbfield']++;
824 }
825 if (!empty($arrayfields['m.price']['checked'])) {
826 print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
827 $totalarray['nbfield']++;
828 }
829
830 // Extra fields
831 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
832
833 // Hook fields
834 $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
835 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
836 print $hookmanager->resPrint;
837 if (!empty($arrayfields['m.datec']['checked'])) {
838 print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
839 $totalarray['nbfield']++;
840 }
841 if (!empty($arrayfields['m.tms']['checked'])) {
842 print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
843 $totalarray['nbfield']++;
844 }
845 // Action column
846 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
847 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
848 $totalarray['nbfield']++;
849 }
850 print "</tr>\n";
851
852 $i = 0;
853 $savnbfield = $totalarray['nbfield'];
854 $totalarray = array();
855 $totalarray['nbfield'] = 0;
856 $imaxinloop = ($limit ? min($num, $limit) : $num);
857 while ($i < $imaxinloop) {
858 $objp = $db->fetch_object($resql);
859
860 // Multilangs
861 if (getDolGlobalInt('MAIN_MULTILANGS')) { // If multilang is enabled
862 // TODO Use a cache here
863 $sql = "SELECT label";
864 $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
865 $sql .= " WHERE fk_product = ".((int) $objp->rowid);
866 $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'";
867 $sql .= " LIMIT 1";
868
869 $result = $db->query($sql);
870 if ($result) {
871 $objtp = $db->fetch_object($result);
872 if (!empty($objtp->label)) {
873 $objp->produit = $objtp->label;
874 }
875 }
876 }
877
878 $userstatic->id = $objp->fk_user_author;
879 $userstatic->login = $objp->login;
880 $userstatic->lastname = $objp->lastname;
881 $userstatic->firstname = $objp->firstname;
882 $userstatic->photo = $objp->photo;
883
884 $productstatic->id = $objp->rowid;
885 $productstatic->ref = $objp->product_ref;
886 $productstatic->label = $objp->produit;
887 $productstatic->type = $objp->type;
888 $productstatic->entity = $objp->entity;
889 $productstatic->status_batch = $objp->tobatch;
890
891 $productlot->id = $objp->lotid;
892 $productlot->batch = $objp->batch;
893 $productlot->eatby = $objp->eatby;
894 $productlot->sellby = $objp->sellby;
895
896 $warehousestatic->id = $objp->entrepot_id;
897 $warehousestatic->libelle = $objp->warehouse_ref; // deprecated
898 $warehousestatic->label = $objp->warehouse_ref;
899 $warehousestatic->lieu = $objp->lieu;
900
901 if (!empty($objp->fk_origin)) {
902 $origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype);
903 } else {
904 $origin = '';
905 }
906
907 print '<tr class="oddeven">';
908 // Action column
909 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
910 print '<td class="nowrap center">';
911 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
912 $selected = 0;
913 if (in_array($objp->rowid, $arrayofselected)) {
914 $selected = 1;
915 }
916 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
917 }
918 print '</td>';
919 if (!$i) {
920 $totalarray['nbfield']++;
921 }
922 }
923 // Id movement
924 if (!empty($arrayfields['m.rowid']['checked'])) {
925 // This is primary not movement id
926 print '<td>'.dol_escape_htmltag($objp->mid).'</td>';
927 }
928 if (!empty($arrayfields['m.datem']['checked'])) {
929 // Date
930 print '<td>'.dol_print_date($db->jdate($objp->datem), 'dayhour').'</td>';
931 }
932 if (!empty($arrayfields['p.ref']['checked'])) {
933 // Product ref
934 print '<td class="nowraponall">';
935 print $productstatic->getNomUrl(1, 'stock', 16);
936 print "</td>\n";
937 }
938 if (!empty($arrayfields['p.label']['checked'])) {
939 // Product label
940 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($productstatic->label).'">';
941 print $productstatic->label;
942 print "</td>\n";
943 }
944 if (!empty($arrayfields['m.batch']['checked'])) {
945 print '<td class="center nowraponall">';
946 if ($productlot->id > 0) {
947 print $productlot->getNomUrl(1);
948 } else {
949 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.
950 }
951 print '</td>';
952 }
953 if (!empty($arrayfields['pl.eatby']['checked'])) {
954 print '<td class="center">'.dol_print_date($objp->eatby, 'day').'</td>';
955 }
956 if (!empty($arrayfields['pl.sellby']['checked'])) {
957 print '<td class="center">'.dol_print_date($objp->sellby, 'day').'</td>';
958 }
959 // Warehouse
960 if (!empty($arrayfields['e.ref']['checked'])) {
961 print '<td>';
962 print $warehousestatic->getNomUrl(1);
963 print "</td>\n";
964 }
965 // Author
966 if (!empty($arrayfields['m.fk_user_author']['checked'])) {
967 print '<td class="tdoverflowmax100">';
968 print $userstatic->getNomUrl(-1);
969 print "</td>\n";
970 }
971 // Inventory code
972 if (!empty($arrayfields['m.inventorycode']['checked'])) {
973 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objp->inventorycode).'">';
974 //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 . '">';
975 print dol_escape_htmltag($objp->inventorycode);
976 //print '</a>';
977 print '</td>';
978 }
979 // Label of movement
980 if (!empty($arrayfields['m.label']['checked'])) {
981 print '<td class="tdoverflowmax300" title="'.dol_escape_htmltag($objp->label).'">'.dol_escape_htmltag($objp->label).'</td>';
982 }
983 // Type of movement
984 if (!empty($arrayfields['m.type_mouvement']['checked'])) {
985 switch ($objp->type_mouvement) {
986 case "0":
987 print '<td class="center">'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</td>';
988 break;
989 case "1":
990 print '<td class="center">'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</td>';
991 break;
992 case "2":
993 print '<td class="center">'.$langs->trans('StockDecrease').'</td>';
994 break;
995 case "3":
996 print '<td class="center">'.$langs->trans('StockIncrease').'</td>';
997 break;
998 }
999 }
1000 if (!empty($arrayfields['origin']['checked'])) {
1001 // Origin of movement
1002 print '<td class="nowraponall">'.$origin.'</td>';
1003 }
1004 if (!empty($arrayfields['m.fk_projet']['checked'])) {
1005 // fk_project
1006 print '<td>';
1007 if ($objp->fk_project != 0) {
1008 print $movement->get_origin($objp->fk_project, 'project');
1009 }
1010 print '</td>';
1011 }
1012 if (!empty($arrayfields['m.value']['checked'])) {
1013 // Qty
1014 print '<td class="right">';
1015 if ($objp->qty > 0) {
1016 print '<span class="stockmovemententry">+'.$objp->qty.'</span>';
1017 } else {
1018 print '<span class="stockmovementexit">'.$objp->qty.'<span>';
1019 }
1020 print '</td>';
1021 }
1022 if (!empty($arrayfields['m.price']['checked'])) {
1023 // Price
1024 print '<td class="right">';
1025 if ($objp->price != 0) {
1026 print '<span class="opacitymedium">'.price($objp->price).'</span>';
1027 }
1028 print '</td>';
1029 }
1030 // Action column
1031 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1032 print '<td class="nowrap center">';
1033 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1034 $selected = 0;
1035 if (in_array($objp->rowid, $arrayofselected)) {
1036 $selected = 1;
1037 }
1038 print '<input id="cb'.$objp->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$objp->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
1039 }
1040 print '</td>';
1041 if (!$i) {
1042 $totalarray['nbfield']++;
1043 }
1044 }
1045
1046 print "</tr>\n";
1047 $i++;
1048 }
1049 if (empty($num)) {
1050 print '<tr><td colspan="'.$savnbfield.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1051 }
1052
1053 $db->free($resql);
1054
1055 print "</table>";
1056 print '</div>';
1057 print "</form>";
1058}
1059
1060// End of page
1061llxFooter();
1062$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()
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: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
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.