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/product.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
49$langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies"));
51 $langs->load(
'incoterm');
59$action =
GETPOST(
'action',
'aZ09');
60$confirm =
GETPOST(
'confirm',
'alpha');
62$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
63$backtopage =
GETPOST(
'backtopage',
'alpha');
64$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
67$fk_warehouse_source =
GETPOSTINT(
'fk_warehouse_source');
68$fk_warehouse_destination =
GETPOSTINT(
'fk_warehouse_destination');
70$label =
GETPOST(
'label',
'alpha');
71$batch =
GETPOST(
'batch',
'alpha');
72$code_inv =
GETPOST(
'inventorycode',
'alphanohtml');
73$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
79$diroutputmassaction = $conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
80$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
83$extrafields->fetch_name_optionals_label(
$object->table_element);
85$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
88$search_all = trim(
GETPOST(
"search_all",
'alpha'));
90foreach (
$object->fields as $key => $val) {
91 if (
GETPOST(
'search_'.$key,
'alpha')) {
92 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
96if (empty($action) && empty($id) && empty($ref)) {
101include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
104$permissiontoread = $user->hasRight(
'stocktransfer',
'stocktransfer',
'read');
105$permissiontoadd = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
106$permissionnote = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
107$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset(
$object->status) &&
$object->status < $object::STATUS_TRANSFERED);
108$permissiondellink = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
109$upload_dir = $conf->stocktransfer->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
117if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
126$parameters = array();
127$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
132if (empty($reshook)) {
135 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_list.php');
137 if (empty($backtopage) || ($cancel && empty($id))) {
138 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
139 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
140 $backtopage = $backurlforlist;
142 $backtopage =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_card.php', [
'id' => ($id > 0 ? $id :
'__ID__')]);
147 $triggermodname =
'STOCKTRANSFER_MODIFY';
150 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
153 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
156 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
159 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
162 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
165 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
167 if ($action ==
'set_thirdparty' && $permissiontoadd) {
168 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
170 if ($action ==
'classin' && $permissiontoadd) {
174 if ($action ==
'addline' && $permissiontoadd &&
$object->status == $object::STATUS_DRAFT) {
177 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
181 if ($fk_warehouse_source <= 0) {
183 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
187 if ($fk_warehouse_destination <= 0) {
189 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
194 $prod->fetch($fk_product);
195 if ($prod->hasbatch()) {
198 $langs->load(
"errors");
199 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref),
null,
'errors');
202 if (!empty($batch)) {
204 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
null,
'errors');
208 if ($prod->status_batch == 2 && abs($qty) > 1) {
210 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref),
null,
'errors');
214 if (!$error && $prod->status_batch == 2) {
215 foreach (
$object->lines as $tmpline) {
218 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref, $batch),
null,
'errors');
226 $records = $line->fetchAll(
'',
'', 0, 0,
'(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).
"'").
')');
227 if (!empty($records[key($records)])) {
228 $line = $records[key($records)];
230 $line->fk_stocktransfer =
$id;
232 $line->fk_warehouse_source = $fk_warehouse_source;
233 $line->fk_warehouse_destination = $fk_warehouse_destination;
234 $line->fk_product = $fk_product;
235 $line->batch = $batch;
237 $line->pmp = $prod->pmp;
239 $line->update($user);
241 $line->rang = (is_array(
$object->lines) ||
$object->lines instanceof Countable) ? count(
$object->lines) + 1 : 1;
242 $line->create($user);
246 } elseif ($action ===
'updateline' && $permissiontoadd &&
$object->status == $object::STATUS_DRAFT) {
248 if ($line->fetch($lineid) <= 0 || $line->fk_stocktransfer !=
$object->id) {
256 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
257 $action =
'editline';
260 if ($fk_warehouse_source <= 0) {
262 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
263 $action =
'editline';
266 if ($fk_warehouse_destination <= 0) {
268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
269 $action =
'editline';
273 $prod->fetch($fk_product);
274 if ($prod->hasbatch()) {
277 $langs->load(
"errors");
278 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
279 $action =
'editline';
282 if (!empty($batch)) {
284 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
null,
'errors');
285 $action =
'editline';
289 if ($prod->status_batch == 2 && abs($qty) > 1) {
291 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref),
null,
'errors');
292 $action =
'editline';
296 if (!$error && $prod->status_batch == 2) {
297 foreach (
$object->lines as $tmpline) {
298 if ($tmpline->id != $lineid && $tmpline->fk_product == $fk_product &&
dol_strtolower((
string) $tmpline->batch) ==
dol_strtolower($batch)) {
300 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref, $batch),
null,
'errors');
301 $action =
'editline';
309 $line->fetch($lineid);
311 $line->fk_warehouse_source = $fk_warehouse_source;
312 $line->fk_warehouse_destination = $fk_warehouse_destination;
313 $line->fk_product = $fk_product;
314 $line->batch = $batch;
315 $line->pmp = $prod->pmp;
316 $line->update($user);
321 if ($action ==
'confirm_destock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
322 $lines =
$object->getLinesArray();
323 if (!empty($lines)) {
325 foreach ($lines as $line) {
326 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
339 $object->setStatut($object::STATUS_TRANSFERED, $id);
340 $object->status = $object::STATUS_TRANSFERED;
348 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
349 $lines =
$object->getLinesArray();
350 if (!empty($lines)) {
352 foreach ($lines as $line) {
353 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
366 $object->setStatut($object::STATUS_VALIDATED, $id);
367 $object->status = $object::STATUS_VALIDATED;
368 $object->date_reelle_depart =
null;
375 if ($action ==
'confirm_addstock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
376 $lines =
$object->getLinesArray();
377 if (!empty($lines)) {
379 foreach ($lines as $line) {
380 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
393 $object->setStatut($object::STATUS_CLOSED, $id);
394 $object->status = $object::STATUS_CLOSED;
402 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
403 $lines =
$object->getLinesArray();
404 if (!empty($lines)) {
406 foreach ($lines as $line) {
407 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
420 $object->setStatut($object::STATUS_TRANSFERED, $id);
421 $object->status = $object::STATUS_TRANSFERED;
422 $object->date_reelle_arrivee =
null;
429 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
433 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
434 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
435 $trackid =
'stocktransfer'.$object->id;
436 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
446$form =
new Form($db);
450$title = $langs->trans(
"StockTransfer");
453llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stocktransfer_stocktransfer_card');
458print
'<script type="text/javascript" language="javascript">
459jQuery(document).ready(function() {';
462$date_prevue_depart =
$object->date_prevue_depart;
463$date_prevue_depart_plus_delai = $date_prevue_depart;
464if (
$object->lead_time_for_warning > 0) {
465 $date_prevue_depart_plus_delai = strtotime(
date(
'Y-m-d', $date_prevue_depart) .
' + '.
$object->lead_time_for_warning.
' day');
467if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(
date(
'Y-m-d'))) {
468 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
469 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
478if ($action ==
'create') {
479 if (empty($permissiontoadd)) {
485 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
486 print
'<input type="hidden" name="token" value="'.newToken().
'">';
487 print
'<input type="hidden" name="action" value="add">';
489 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
491 if ($backtopageforcancel) {
492 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
498 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
501 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
509 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
510 print
'<td class="maxwidthonsmartphone">';
511 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
515 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
517 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
518 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
521 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
525 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
527 print
'</table>'.
"\n";
531 print $form->buttonsSaveCancel(
"Create");
539if (($id || $ref) && $action ==
'edit') {
542 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
543 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
544 print
'<input type="hidden" name="action" value="update">';
545 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
547 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
549 if ($backtopageforcancel) {
550 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
555 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
558 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
561 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
567 print $form->buttonsSaveCancel();
573if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
574 $res =
$object->fetch_optionals();
583 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
584 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
587 if ($action ==
'deleteline') {
588 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
590 $formquestion = array();
592 if ($action ==
'clone') {
594 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
595 } elseif ($action ==
'destock') {
597 $formquestion = array(
'text' =>
'',
598 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock',
$object->ref),
'size' => 40),
599 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
601 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
602 } elseif ($action ==
'destockcancel') {
604 $formquestion = array(
'text' =>
'',
605 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel',
$object->ref),
'size' => 40),
606 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
608 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
609 } elseif ($action ==
'addstock') {
611 $formquestion = array(
'text' =>
'',
612 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock',
$object->ref),
'size' => 40),
613 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
615 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
616 } elseif ($action ==
'addstockcancel') {
618 $formquestion = array(
'text' =>
'',
619 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel',
$object->ref),
'size' => 40),
620 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
622 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
625 if ($action ==
'valid' && $permissiontoadd) {
626 $nextref =
$object->getNextNumRef();
627 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
631 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
632 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
633 if (empty($reshook)) {
634 $formconfirm .= $hookmanager->resPrint;
635 } elseif ($reshook > 0) {
636 $formconfirm = $hookmanager->resPrint;
645 $linkback =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
647 $morehtmlref =
'<div class="refidno">';
649 $morehtmlref .= empty(
$object->thirdparty) ?
'' :
$object->thirdparty->getNomUrl(1,
'customer');
651 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
655 $langs->load(
"projects");
656 $morehtmlref .= (empty(
$object->thirdparty) ?
'' :
'<br>');
657 if ($permissiontoadd) {
658 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
659 if ($action !=
'classify') {
660 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
662 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
664 if (!empty(
$object->fk_project)) {
666 $proj->fetch(
$object->fk_project);
667 $morehtmlref .= $proj->getNomUrl(1);
669 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
674 $morehtmlref .=
'</div>';
677 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
680 print
'<div class="fichecenter">';
681 print
'<div class="fichehalfleft">';
682 print
'<div class="underbanner clearboth"></div>';
683 print
'<table class="border centpercent tableforfield">'.
"\n";
690 $object->fields[
'fk_soc'][
'visible'] = 0;
691 $object->fields[
'fk_project'][
'visible'] = 0;
692 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
697 print
'<table width="100%" class="nobordernopadding"><tr><td>';
698 print $langs->trans(
'IncotermLabel');
699 print
'<td><td class="right">';
700 if ($permissiontoadd && $action !=
'editincoterm') {
701 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
705 print
'</td></tr></table>';
708 if ($action !=
'editincoterm') {
709 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
711 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
717 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
718 echo
'<td>'.price(
$object->getValorisationTotale(), 0,
'', 1, -1, -1, $conf->currency).
'</td>';
722 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
728 print
'<div class="clearboth"></div>';
737 if (!empty(
$object->table_element_line)) {
751 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
753 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
793 print
'<div class="div-table-responsive-no-min">';
794 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
795 <input type="hidden" name="token" value="' .
newToken().
'">
796 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
797 <input type="hidden" name="mode" value="">
798 <input type="hidden" name="id" value="' .
$object->id.
'">
801 print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
803 print
'<table id="tablelines" class="liste centpercent">';
808 print
'<tr class="liste_titre">';
809 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
811 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
813 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
814 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
815 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
817 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
819 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
820 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
821 if (empty(
$object->status) && $permissiontoadd) {
829 $listofdata =
$object->getLinesArray();
830 $productstatic =
new Product($db);
831 $warehousestatics =
new Entrepot($db);
832 $warehousestatict =
new Entrepot($db);
835 foreach ($listofdata as $key => $line) {
836 $productstatic->fetch($line->fk_product);
837 $warehousestatics->fetch($line->fk_warehouse_source);
838 $warehousestatict->fetch($line->fk_warehouse_destination);
841 $domData =
' data-element="'.$line->element.
'"';
842 $domData .=
' data-id="'.$line->id.
'"';
843 $domData .=
' data-qty="'.$line->qty.
'"';
846 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
847 print
'<td class="titlefield">';
848 if ($action ===
'editline' && $line->id == $lineid) {
849 $form->select_produits($line->fk_product,
'fk_product',
'', 0, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
851 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
856 if ($action ===
'editline' && $line->id == $lineid) {
857 print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
860 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
861 print $productlot->getNomUrl(1);
862 } elseif (!empty($line->batch)) {
863 print $line->batch.
' '.
img_warning($langs->trans(
'BatchNotFound'));
870 print
'<td class="tdoverflowmax150">';
871 if ($action ===
'editline' && $line->id == $lineid) {
872 print $formproduct->selectWarehouses($line->fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
874 print $warehousestatics->getNomUrl(1);
879 print
'<td class="tdoverflowmax150">';
880 if ($action ===
'editline' && $line->id == $lineid) {
881 print $formproduct->selectWarehouses($line->fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
883 print $warehousestatict->getNomUrl(1);
887 if ($action ===
'editline' && $line->id == $lineid) {
888 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.
'"></td>';
890 print
'<td class="center">'.$line->qty.
'</td>';
894 print
'<td class="linecoluseunit nowrap left">';
895 $label = $productstatic->getLabelOfUnit(
'short');
900 print
'<td class="center">';
901 print
price($line->pmp, 0,
'', 1, -1, -1, $conf->currency);
904 print
'<td class="center">';
905 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1, $conf->currency);
908 if (empty(
$object->status) && $permissiontoadd) {
909 if ($action ===
'editline' && $line->id == $lineid) {
911 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
912 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
914 print
'<td class="right">';
915 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&lineid=' . $line->id .
'#line_' . $line->id .
'">';
918 print
'<td class="right">';
920 $deleteLineUrl = $_SERVER[
"PHP_SELF"] .
'?id=' .
$id .
'&action=deleteline&lineid=' . $line->id .
'&token=' .
newToken();
921 print
'<a href="' . $deleteLineUrl .
'">' .
img_delete($langs->trans(
"Remove")) .
'</a>';
927 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
928 print
'<td class="linecolmove tdlineupdown center">';
930 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
931 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
934 if ($i < $num - 1) { ?>
935 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&rowid='.$line->id; ?>">
936 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
941 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
949 if (empty(
$object->status) && $action !==
'editline' && $permissiontoadd) {
950 print
'<tr class="oddeven">';
952 print
'<td class="titlefield">';
963 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
968 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
972 $formproduct->loadWarehouses();
975 $TExcludedWarehouseSource = array();
976 if (!empty(
$object->fk_warehouse_source)) {
978 $source_ent->fetch(
$object->fk_warehouse_source);
979 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
980 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) {
981 $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
987 $TExcludedWarehouseDestination = array();
988 if (!empty(
$object->fk_warehouse_destination)) {
990 $dest_ent->fetch(
$object->fk_warehouse_destination);
991 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
992 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) {
993 $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
999 $formproduct->cache_warehouses = array();
1002 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);
1006 $formproduct->cache_warehouses = array();
1009 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);
1013 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.$qty.
'"' :
'').
'></td>';
1026 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
1040 if ($action !=
'presend' && $action !=
'editline') {
1041 print
'<div class="tabsAction">'.
"\n";
1042 $parameters = array();
1043 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1048 if (empty($reshook)) {
1050 if (empty($user->socid)) {
1051 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
1055 if (
$object->status == $object::STATUS_VALIDATED) {
1056 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
1060 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
1063 if (
$object->status == $object::STATUS_DRAFT) {
1064 if (empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) {
1065 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
1067 $langs->load(
"errors");
1068 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
1070 } elseif (
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
1071 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destock&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
1072 } elseif (
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
1073 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
1074 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstock&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
1075 } elseif (
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
1076 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
1080 if ($permissiontoadd) {
1081 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
1103 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
1104 $buttonId =
'action-delete-no-ajax';
1105 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
1107 $buttonId =
'action-delete';
1110 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
1112 print
'</div>'.
"\n";
1117 if (
GETPOST(
'modelselected')) {
1118 $action =
'presend';
1121 if ($action !=
'presend') {
1122 print
'<div class="fichecenter"><div class="fichehalfleft">';
1123 print
'<a name="builddoc"></a>';
1125 $includedocgeneration = 1;
1128 if ($includedocgeneration) {
1130 $relativepath = $objref .
'/' . $objref .
'.pdf';
1131 $filedir = $conf->stocktransfer->dir_output.
'/'.
$object->element.
'/'.$objref;
1132 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
1133 $genallowed = $permissiontoread;
1134 $delallowed = $permissiontoadd;
1135 print $formfile->showdocuments(
'stocktransfer:StockTransfer',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1139 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'stocktransfer'), 1);
1140 $linktoelem = $tmparray[
'linktoelem'];
1141 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1142 print $htmltoenteralink;
1144 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1147 print
'</div><div class="fichehalfright">';
1154 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1156 $somethingshown = $formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'');
1158 print
'</div></div>';
1162 if (
GETPOST(
'modelselected')) {
1163 $action =
'presend';
1167 $modelmail =
'stocktransfer';
1168 $defaulttopic =
'InformationMessage';
1169 $diroutput = $conf->stocktransfer->dir_output;
1170 $trackid =
'stocktransfer'.$object->id;
1172 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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 to manage third parties objects (customers, suppliers, prospects...)
Class for StockTransferLine.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
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.