26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
35 $langs->loadLangs(array(
'products',
'stocks',
'orders',
'productbatch'));
38 $hookmanager->initHooks(array(
'massstockmove'));
42 $socid = $user->socid;
48 $action =
GETPOST(
'action',
'aZ09');
49 $id_product =
GETPOST(
'productid',
'int');
50 $id_sw =
GETPOST(
'id_sw',
'int');
51 $id_tw =
GETPOST(
'id_tw',
'int');
56 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
59 if (empty($page) || $page == -1) { $page = 0; }
68 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
69 $offset = $limit * $page;
71 $listofdata = array();
72 if (!empty($_SESSION[
'massstockmove'])) $listofdata = json_decode($_SESSION[
'massstockmove'],
true);
79 if ($action ==
'addline')
81 if (!($id_product > 0))
84 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Product")), null,
'errors');
89 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")), null,
'errors');
94 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")), null,
'errors');
96 if ($id_sw > 0 && $id_tw == $id_sw)
99 $langs->load(
"errors");
100 setEventMessages($langs->trans(
"ErrorWarehouseMustDiffers"), null,
'errors');
105 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")), null,
'errors');
111 $producttmp =
new Product($db);
112 $producttmp->fetch($id_product);
113 if ($producttmp->hasbatch())
118 $langs->load(
"errors");
119 setEventMessages($langs->trans(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $producttmp->ref), null,
'errors');
129 if ($producttmp->hasbatch())
137 if (count(array_keys($listofdata)) > 0) $id = max(array_keys($listofdata)) + 1;
139 $listofdata[$id] = array(
'id'=>$id,
'id_product'=>$id_product,
'qty'=>$qty,
'id_sw'=>$id_sw,
'id_tw'=>$id_tw,
'batch'=>$batch);
140 $_SESSION[
'massstockmove'] = json_encode($listofdata);
150 if ($action ==
'delline' && $idline !=
'')
152 if (!empty($listofdata[$idline])) unset($listofdata[$idline]);
153 if (count($listofdata) > 0) $_SESSION[
'massstockmove'] = json_encode($listofdata);
154 else unset($_SESSION[
'massstockmove']);
157 if ($action ==
'createmovements')
164 setEventMessages($langs->trans(
"ErrorFieldRequired"), $langs->transnoentitiesnoconv(
"MovementLabel"), null,
'errors');
173 foreach ($listofdata as $key => $val)
176 $id_product = $val[
'id_product'];
177 $id_sw = $val[
'id_sw'];
178 $id_tw = $val[
'id_tw'];
180 $batch = $val[
'batch'];
184 if (!$error && $id_sw <> $id_tw && is_numeric($qty) && $id_product)
186 $result = $product->fetch($id_product);
188 $product->load_stock(
'novirtual');
192 if (!empty($product->pmp)) $pricesrc = $product->pmp;
193 $pricedest = $pricesrc;
197 if (empty($conf->productbatch->enabled) || !$product->hasbatch())
200 $result1 = $product->correct_stock(
216 $result2 = $product->correct_stock(
231 $arraybatchinfo = $product->loadBatchInfo($batch);
232 if (count($arraybatchinfo) > 0)
234 $firstrecord = array_shift($arraybatchinfo);
235 $dlc = $firstrecord[
'eatby'];
236 $dluo = $firstrecord[
'sellby'];
244 $result1 = $product->correct_stock_batch(
263 $result2 = $product->correct_stock_batch(
290 unset($_SESSION[
'massstockmove']);
294 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/index.php');
310 $form =
new Form($db);
312 $productstatic =
new Product($db);
313 $warehousestatics =
new Entrepot($db);
314 $warehousestatict =
new Entrepot($db);
316 $title = $langs->trans(
'MassMovement');
322 $titletoadd = $langs->trans(
"Select");
323 $buttonrecord = $langs->trans(
"RecordMovement");
324 $titletoaddnoent = $langs->transnoentitiesnoconv(
"Select");
325 $buttonrecordnoent = $langs->transnoentitiesnoconv(
"RecordMovement");
326 print '<span class="opacitymedium">'.$langs->trans(
"SelectProductInAndOutWareHouse", $titletoaddnoent, $buttonrecordnoent).
'</span><br>';
330 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">';
331 print '<input type="hidden" name="token" value="'.newToken().
'">';
332 print '<input type="hidden" name="action" value="addline">';
335 print '<div class="div-table-responsive-no-min">';
336 print '<table class="liste centpercent">';
341 print '<tr class="liste_titre">';
342 print getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0,
$_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
343 print getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0,
$_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
345 if ($conf->productbatch->enabled) {
353 print '<tr class="oddeven">';
356 print $formproduct->selectWarehouses($id_sw,
'id_sw',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
360 print $formproduct->selectWarehouses($id_tw,
'id_tw',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
363 print '<td class="titlefield">';
365 if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype =
'';
366 if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) {
369 $limit = $conf->global->PRODUIT_LIMIT_SIZE;
372 $form->select_produits($id_product,
'productid', $filtertype, $limit, 0, -1, 2,
'', 1, array(), 0,
'1', 0,
'minwidth200imp maxwidth300', 1);
375 if ($conf->productbatch->enabled)
378 print '<input type="text" name="batch" class="flat maxwidth50" value="'.$batch.
'">';
382 print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$qty.
'"></td>';
384 print '<td class="right"><input type="submit" class="button" name="addline" value="'.dol_escape_htmltag($titletoadd).
'"></td>';
389 foreach ($listofdata as $key => $val)
391 $productstatic->fetch($val[
'id_product']);
392 $warehousestatics->fetch($val[
'id_sw']);
393 $warehousestatict->fetch($val[
'id_tw']);
395 print '<tr class="oddeven">';
397 print $warehousestatics->getNomUrl(1);
400 print $warehousestatict->getNomUrl(1);
403 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
405 if ($conf->productbatch->enabled)
411 print '<td class="center">'.$val[
'qty'].
'</td>';
412 print '<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=delline&idline='.$val[
'id'].
'">'.
img_delete($langs->trans(
"Remove")).
'</a></td>';
426 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire2" class="formconsumeproduce">';
427 print '<input type="hidden" name="token" value="'.newToken().
'">';
428 print '<input type="hidden" name="action" value="createmovements">';
434 print '<div class="center">';
435 print '<span class="fieldrequired">'.$langs->trans(
"InventoryCode").
':</span> ';
436 print '<input type="text" name="codemove" class="maxwidth300" value="'.dol_escape_htmltag($codemove).
'"> ';
437 print '<span class="clearbothonsmartphone"></span>';
438 print $langs->trans(
"MovementLabel").
': ';
439 print '<input type="text" name="label" class="minwidth300" value="'.dol_escape_htmltag($labelmovement).
'"><br>';
442 print '<div class="center"><input class="button" type="submit" name="valid" value="'.dol_escape_htmltag($buttonrecord).
'"></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
Class to manage warehouses.