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/product.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
39$langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies"));
40 if (isModEnabled(
'incoterm')) $langs->load(
'incoterm');
46$action =
GETPOST(
'action',
'aZ09');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'aZ09');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'stocktransfercard';
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
53$fk_product =
GETPOST(
'fk_product',
'int');
54$fk_warehouse_source =
GETPOST(
'fk_warehouse_source',
'int');
55$fk_warehouse_destination =
GETPOST(
'fk_warehouse_destination',
'int');
56$lineid =
GETPOST(
'lineid',
'int');
57$label =
GETPOST(
'label',
'alpha');
58$batch =
GETPOST(
'batch',
'alpha');
59$code_inv =
GETPOST(
'inventorycode',
'alphanohtml');
64$diroutputmassaction = $conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
65$hookmanager->initHooks(array(
'stocktransfercard',
'globalcard'));
68$extrafields->fetch_name_optionals_label($object->table_element);
70$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
73$search_all = trim(
GETPOST(
"search_all",
'alpha'));
75foreach ($object->fields as $key => $val) {
76 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
79if (empty($action) && empty($id) && empty($ref)) $action =
'view';
82include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
85$permissiontoread = $user->rights->stocktransfer->stocktransfer->read;
86$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write;
87$permissionnote = $user->rights->stocktransfer->stocktransfer->write;
88$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
89$permissiondellink = $user->rights->stocktransfer->stocktransfer->write;
90$upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
98if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd))
accessforbidden();
105$form =
new Form($db);
109$parameters = array();
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
111if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
113if (empty($reshook)) {
116 $backurlforlist =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1);
118 if (empty($backtopage) || ($cancel && empty($id))) {
119 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
120 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) $backtopage = $backurlforlist;
121 else $backtopage =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
124 $triggermodname =
'STOCKTRANSFER_STOCKTRANSFER_MODIFY';
127 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
130 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
133 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
136 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
142 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
144 if ($action ==
'set_thirdparty' && $permissiontoadd) {
145 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user,
'STOCKTRANSFER_MODIFY');
147 if ($action ==
'classin' && $permissiontoadd) {
148 $object->setProject(
GETPOST(
'projectid',
'int'));
151 if ($action ==
'addline' && $permissiontoadd) {
154 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
158 if ($fk_warehouse_source <= 0) {
160 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
164 if ($fk_warehouse_destination <= 0) {
166 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
171 $prod->fetch($fk_product);
172 if ($prod->hasbatch()) {
175 $langs->load(
"errors");
176 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref),
null,
'errors');
179 if (!empty($batch)) {
181 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
187 $records = $line->fetchAll(
'',
'', 0, 0, array(
'customsql'=>
' fk_stocktransfer = '.((
int) $id).
' AND fk_product = '.((
int) $fk_product).
' AND fk_warehouse_source = '.((
int) $fk_warehouse_source).
' AND fk_warehouse_destination = '.((
int) $fk_warehouse_destination).
' AND ('.(empty($batch) ?
'batch = "" or batch IS NULL' :
"batch = '".$db->escape($batch).
"'" ).
')'));
188 if (!empty($records[key($records)])) $line = $records[key($records)];
189 $line->fk_stocktransfer = $id;
191 $line->fk_warehouse_source = $fk_warehouse_source;
192 $line->fk_warehouse_destination = $fk_warehouse_destination;
193 $line->fk_product = $fk_product;
194 $line->batch = $batch;
196 $line->pmp = $prod->pmp;
197 if ($line->id > 0) $line->update($user);
199 $line->rang = count($object->lines) + 1;
200 $line->create($user);
202 $object->fetchLines();
204 } elseif ($action ===
'updateline' && $permissiontoadd) {
207 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
208 $action =
'editline';
211 if ($fk_warehouse_source <= 0) {
213 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
214 $action =
'editline';
217 if ($fk_warehouse_destination <= 0) {
219 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
220 $action =
'editline';
224 $prod->fetch($fk_product);
225 if ($prod->hasbatch()) {
228 $langs->load(
"errors");
229 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
230 $action =
'editline';
233 if (!empty($batch)) {
235 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
236 $action =
'editline';
242 $line->fetch($lineid);
244 $line->fk_warehouse_source = $fk_warehouse_source;
245 $line->fk_warehouse_destination = $fk_warehouse_destination;
246 $line->fk_product = $fk_product;
247 $line->batch = $batch;
248 $line->pmp = $prod->pmp;
249 $line->update($user);
253 if ($permissiontoadd) {
255 if ($action ==
'confirm_destock' && $confirm ==
'yes' && $object->status == $object::STATUS_VALIDATED) {
256 $lines = $object->getLinesArray();
257 if (!empty($lines)) {
259 foreach ($lines as $line) {
260 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
261 if ($res <= 0) $error++;
263 if (empty($error)) $db->commit();
264 else $db->rollback();
267 $object->setStatut($object::STATUS_TRANSFERED, $id);
268 $object->status = $object::STATUS_TRANSFERED;
269 $object->date_reelle_depart = date(
'Y-m-d');
270 $object->update($user);
276 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
277 $lines = $object->getLinesArray();
278 if (!empty($lines)) {
280 foreach ($lines as $line) {
281 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
282 if ($res <= 0) $error++;
284 if (empty($error)) $db->commit();
285 else $db->rollback();
288 $object->setStatut($object::STATUS_VALIDATED, $id);
289 $object->status = $object::STATUS_VALIDATED;
290 $object->date_reelle_depart =
null;
291 $object->update($user);
297 if ($action ==
'confirm_addstock' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
298 $lines = $object->getLinesArray();
299 if (!empty($lines)) {
301 foreach ($lines as $line) {
302 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
303 if ($res <= 0) $error++;
305 if (empty($error)) $db->commit();
306 else $db->rollback();
309 $object->setStatut($object::STATUS_CLOSED, $id);
310 $object->status = $object::STATUS_CLOSED;
311 $object->date_reelle_arrivee = date(
'Y-m-d');
312 $object->update($user);
318 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_CLOSED) {
319 $lines = $object->getLinesArray();
320 if (!empty($lines)) {
322 foreach ($lines as $line) {
323 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
324 if ($res <= 0) $error++;
326 if (empty($error)) $db->commit();
327 else $db->rollback();
330 $object->setStatut($object::STATUS_TRANSFERED, $id);
331 $object->status = $object::STATUS_TRANSFERED;
332 $object->date_reelle_arrivee =
null;
333 $object->update($user);
340 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $permissiontoadd) {
341 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
344 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
345 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
346 $trackid =
'stocktransfer'.$object->id;
347 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
359$title = $langs->trans(
"StockTransfer");
366print
'<script type="text/javascript" language="javascript">
367jQuery(document).ready(function() {';
370$date_prevue_depart = $object->date_prevue_depart;
371$date_prevue_depart_plus_delai = $date_prevue_depart;
372if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date(
'Y-m-d', $date_prevue_depart) .
' + '.$object->lead_time_for_warning.
' day');
373if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date(
'Y-m-d'))) {
374 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
375 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
384if ($action ==
'create') {
385 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"StockTransfer")),
'',
'object_'.$object->picto);
387 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
388 print
'<input type="hidden" name="token" value="'.newToken().
'">';
389 print
'<input type="hidden" name="action" value="add">';
390 if ($backtopage) print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
391 if ($backtopageforcancel) print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
398 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
401 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
403 if (isModEnabled(
'incoterm')) {
405 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
406 print
'<td class="maxwidthonsmartphone">';
407 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
411 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
413 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
414 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
416 $preselected = $conf->global->STOCKTRANSFER_ADDON_PDF;
417 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
421 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
423 print
'</table>'.
"\n";
427 print
'<div class="center">';
428 print
'<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
430 print
'<input type="'.($backtopage ?
"submit" :
"button").
'" class="button" name="cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'"'.($backtopage ?
'' :
' onclick="history.go(-1)"').
'>';
439if (($id || $ref) && $action ==
'edit') {
441 print
load_fiche_titre($langs->trans(
"StockTransfer"),
'',
'object_' . $object->picto);
443 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
444 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
445 print
'<input type="hidden" name="action" value="update">';
446 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
447 if ($backtopage) print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
448 if ($backtopageforcancel) print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
452 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
455 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
458 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
464 print
'<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans(
"Save") .
'">';
465 print
' <input type="submit" class="button" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
473if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
474 $res = $object->fetch_optionals();
477 print
dol_get_fiche_head($head,
'card', $langs->trans(
"StockTransfer"), -1, $object->picto);
482 if ($action ==
'delete') {
483 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
486 if ($action ==
'deleteline') {
487 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
490 if ($action ==
'clone') {
492 $formquestion = array();
493 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
494 } elseif ($action ==
'destock') {
496 $formquestion = array(
'text' =>
'',
497 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock', $object->ref),
'size'=>40),
498 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
500 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
501 } elseif ($action ==
'destockcancel') {
503 $formquestion = array(
'text' =>
'',
504 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel', $object->ref),
'size'=>40),
505 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
507 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
508 } elseif ($action ==
'addstock') {
510 $formquestion = array(
'text' =>
'',
511 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock', $object->ref),
'size'=>40),
512 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
514 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
515 } elseif ($action ==
'addstockcancel') {
517 $formquestion = array(
'text' =>
'',
518 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel', $object->ref),
'size'=>40),
519 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
521 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
525 if ($action ==
'xxx') {
526 $formquestion = array();
537 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
541 if ($action ==
'valid' && $permissiontoadd) {
542 $nextref=$object->getNextNumRef();
543 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
547 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
548 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
549 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
550 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
558 $linkback = '<a href="'.
dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
560 $morehtmlref = '<div class="refidno">';
563 if (isModEnabled('societe')) {
564 $morehtmlref .= $langs->trans(
'ThirdParty') .
' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) :
'').
'<br>';
567 if (isModEnabled(
'project')) {
568 $langs->load(
"projects");
569 $morehtmlref.=$langs->trans(
'Project') .
' ';
570 if ($permissiontoadd) {
573 if ($action ==
'classify') {
575 $morehtmlref.=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
576 $morehtmlref.=
'<input type="hidden" name="action" value="classin">';
577 $morehtmlref.=
'<input type="hidden" name="token" value="'.newToken().
'">';
578 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
579 $morehtmlref.=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
580 $morehtmlref.=
'</form>';
582 $morehtmlref.=$form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' . $object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
585 if (!empty($object->fk_project)) {
587 $proj->fetch($object->fk_project);
588 $morehtmlref .=
': '.$proj->getNomUrl();
594 $morehtmlref .=
'</div>';
597 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
600 print
'<div class="fichecenter">';
601 print
'<div class="fichehalfleft">';
602 print
'<div class="underbanner clearboth"></div>';
603 print
'<table class="border centpercent tableforfield">'.
"\n";
610 $object->fields[
'fk_soc'][
'visible']=0;
611 $object->fields[
'fk_project'][
'visible']=0;
612 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
615 if (isModEnabled(
'incoterm')) {
617 print
'<table width="100%" class="nobordernopadding"><tr><td>';
618 print $langs->trans(
'IncotermLabel');
619 print
'<td><td class="right">';
620 if ($permissiontoadd && $action !=
'editincoterm') print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
622 print
'</td></tr></table>';
625 if ($action !=
'editincoterm') {
626 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
628 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
634 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
635 echo
'<td>'.price($object->getValorisationTotale(), 0,
'', 1, -1, -1, $conf->currency).
'</td>';
638 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
644 print
'<div class="clearboth"></div>';
653 if (!empty($object->table_element_line)) {
664 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
665 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
703 print
'<div class="div-table-responsive-no-min">';
704 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
705 <input type="hidden" name="token" value="' . newToken().
'">
706 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
707 <input type="hidden" name="mode" value="">
708 <input type="hidden" name="id" value="' . $object->id.
'">
710 if ($lineid > 0) print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
711 print
'<table id="tablelines" class="liste centpercent">';
716 $conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE=
true;
718 print
'<tr class="liste_titre">';
719 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
720 if (isModEnabled(
'productbatch')) {
721 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
723 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
724 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
725 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
726 if ($conf->global->PRODUCT_USE_UNITS) {
727 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
729 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
730 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
731 if (empty($object->status) && $permissiontoadd) {
739 $listofdata = $object->getLinesArray();
740 $productstatic =
new Product($db);
741 $warehousestatics =
new Entrepot($db);
742 $warehousestatict =
new Entrepot($db);
744 foreach ($listofdata as $key => $line) {
745 $productstatic->fetch($line->fk_product);
746 $warehousestatics->fetch($line->fk_warehouse_source);
747 $warehousestatict->fetch($line->fk_warehouse_destination);
750 $domData =
' data-element="'.$line->element.
'"';
751 $domData .=
' data-id="'.$line->id.
'"';
752 $domData .=
' data-qty="'.$line->qty.
'"';
755 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
756 print
'<td class="titlefield">';
757 if ($action ===
'editline' && $line->id == $lineid) $form->select_produits($line->fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
758 else print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
760 if (isModEnabled(
'productbatch')) {
762 if ($action ===
'editline' && $line->id == $lineid) print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
765 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
766 print $productlot->getNomUrl(1);
767 } elseif (!empty($line->batch)) print $line->batch.' '.
img_warning($langs->trans('BatchNotFound'));
774 if ($action === 'editline' && $line->
id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
775 else print $warehousestatics->getNomUrl(1);
778 if ($action === 'editline' && $line->
id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
779 else print $warehousestatict->getNomUrl(1);
781 if ($action === 'editline' && $line->
id == $lineid) print '<td class="center"><input
type="text" class="flat maxwidth50"
name="qty" value="'.$line->qty.'"></td>';
782 else print '<td class="center">'.$line->qty.'</td>';
784 if ($conf->global->PRODUCT_USE_UNITS) {
785 print
'<td class="linecoluseunit nowrap left">';
786 $label = $productstatic->getLabelOfUnit(
'short');
788 print $langs->trans($label);
793 print
'<td class="center">';
794 print
price($line->pmp, 0,
'', 1, -1, -1, $conf->currency);
796 print
'<td class="center">';
797 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1, $conf->currency);
799 if (empty($object->status) && $permissiontoadd) {
800 if ($action ===
'editline' && $line->id == $lineid) {
802 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
803 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
805 print
'<td class="right">';
806 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=editline&lineid=' . $line->id .
'#line_' . $line->id .
'">';
809 print
'<td class="right">';
810 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id .
'&action=deleteline&lineid=' . $line->id .
'">' .
img_delete($langs->trans(
"Remove")) .
'</a>';
814 $num = count($object->lines);
816 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
817 print
'<td class="linecolmove tdlineupdown center">';
820 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
821 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
824 if ($i < $num - 1) { ?>
825 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&rowid='.$line->id; ?>">
826 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
831 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
839 if (empty($object->status) && $action !==
'editline' && $permissiontoadd) {
840 print
'<tr class="oddeven">';
842 print
'<td class="titlefield">';
844 if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype =
'';
845 if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) {
848 $limit = $conf->global->PRODUIT_LIMIT_SIZE;
851 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
854 if (isModEnabled(
'productbatch')) {
856 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
860 $formproduct->loadWarehouses();
863 $TExcludedWarehouseSource=array();
864 if (!empty($object->fk_warehouse_source)) {
866 $source_ent->fetch($object->fk_warehouse_source);
867 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
868 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
873 $TExcludedWarehouseDestination=array();
874 if (!empty($object->fk_warehouse_destination)) {
876 $dest_ent->fetch($object->fk_warehouse_destination);
877 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
878 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
883 $formproduct->cache_warehouses=array();
886 print $formproduct->selectWarehouses(empty($fk_warehouse_source) ? $object->fk_warehouse_source : $fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
890 $formproduct->cache_warehouses=array();
893 print $formproduct->selectWarehouses(empty($fk_warehouse_destination) ? $object->fk_warehouse_destination : $fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
897 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.$qty.
'"' :
'').
'></td>';
900 if ($conf->global->PRODUCT_USE_UNITS) {
907 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
919 if ($action !=
'presend' && $action !=
'editline') {
920 print
'<div class="tabsAction">'.
"\n";
921 $parameters = array();
922 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
923 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
925 if (empty($reshook)) {
927 if (empty($user->socid)) {
928 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
932 if ($object->status == $object::STATUS_VALIDATED) {
933 if ($permissiontoadd) {
934 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes">'.$langs->trans(
"SetToDraft").
'</a>';
939 if ($permissiontoadd) {
940 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit">'.$langs->trans(
"Modify").
'</a>'.
"\n";
948 if ($object->status == $object::STATUS_DRAFT) {
949 if ($permissiontoadd) {
950 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
951 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=valid">'.$langs->trans(
"Validate").
'</a>';
953 $langs->load(
"errors");
954 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
957 } elseif ($object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
958 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destock&token='.newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
959 } elseif ($object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
960 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destockcancel&token='.newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
961 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstock&token='.newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
962 } elseif ($object->status == $object::STATUS_CLOSED && $permissiontoadd) {
963 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstockcancel&token='.newToken().
'">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
967 if ($permissiontoadd) {
968 print
dolGetButtonAction($langs->trans(
"ToClone"),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=stocktransfer',
'clone', $permissiontoadd);
997 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
1004 if (
GETPOST(
'modelselected')) {
1005 $action =
'presend';
1008 if ($action !=
'presend') {
1009 print
'<div class="fichecenter"><div class="fichehalfleft">';
1010 print
'<a name="builddoc"></a>';
1012 $includedocgeneration = 1;
1015 if ($includedocgeneration) {
1017 $relativepath = $objref .
'/' . $objref .
'.pdf';
1018 $filedir = $conf->stocktransfer->dir_output.
'/'.$object->element.
'/'.$objref;
1019 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" . $object->id;
1020 $genallowed = $user->rights->stocktransfer->stocktransfer->read;
1021 $delallowed = $user->rights->stocktransfer->stocktransfer->write;
1022 print $formfile->showdocuments(
'stocktransfer:StockTransfer', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1026 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'stocktransfer'));
1027 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1030 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1034 $morehtmlright =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_agenda.php', 1).
'?id='.$object->id.
'">';
1035 $morehtmlright .= $langs->trans(
"SeeAll");
1036 $morehtmlright .=
'</a>';
1039 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1041 $somethingshown =
$formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'', $morehtmlright);
1043 print
'</div></div></div>';
1047 if (
GETPOST(
'modelselected')) $action =
'presend';
1050 $modelmail =
'stocktransfer';
1051 $defaulttopic =
'InformationMessage';
1052 $diroutput = $conf->stocktransfer->dir_output;
1053 $trackid =
'stocktransfer'.$object->id;
1055 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage products or services.
Class with list of lots and properties.
Class to manage projects.
Class for StockTransferLine.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
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...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stocktransferPrepareHead($object)
Prepare array of tabs for StockTransfer.