28require
'../../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
48$langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies",
"products"));
50 $langs->load(
'incoterm');
58$action =
GETPOST(
'action',
'aZ09');
59$confirm =
GETPOST(
'confirm',
'alpha');
61$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
62$backtopage =
GETPOST(
'backtopage',
'alpha');
63$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
66$fk_warehouse_source =
GETPOSTINT(
'fk_warehouse_source');
67$fk_warehouse_destination =
GETPOSTINT(
'fk_warehouse_destination');
69$label =
GETPOST(
'label',
'alpha');
70$batch =
GETPOST(
'batch',
'alpha');
71$code_inv =
GETPOST(
'inventorycode',
'alphanohtml');
72$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
78$diroutputmassaction =
$conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
79$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
82$extrafields->fetch_name_optionals_label(
$object->table_element);
84$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
87$search_all = trim(
GETPOST(
"search_all",
'alpha'));
89foreach (
$object->fields as $key => $val) {
90 if (
GETPOST(
'search_'.$key,
'alpha')) {
91 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
95if (empty($action) && empty($id) && empty($ref)) {
100include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
103$permissiontoread = $user->hasRight(
'stocktransfer',
'stocktransfer',
'read');
104$permissiontoadd = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
105$permissionnote = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
106$permissiontodelete = $user->hasRight(
'stocktransfer',
'stocktransfer',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status < $object::STATUS_TRANSFERED);
107$permissiondellink = $user->hasRight(
'stocktransfer',
'stocktransfer',
'write');
108$upload_dir =
$conf->stocktransfer->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
111restrictedArea($user,
'stocktransfer',
$object->id,
'stocktransfer_stocktransfer',
'stocktransfer',
'fk_soc',
'rowid');
113if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
122$parameters = array();
123$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
125 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
128if (empty($reshook)) {
131 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_list.php');
133 if (empty($backtopage) || ($cancel && empty($id))) {
134 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
135 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
136 $backtopage = $backurlforlist;
138 $backtopage =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_card.php', [
'id' => ($id > 0 ? $id :
'__ID__')]);
143 $triggermodname =
'STOCKTRANSFER_MODIFY';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
149 $permissiontodelete = $user->hasRight(
'stocktransfer',
'stocktransfer',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
152 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
155 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
161 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
163 if ($action ==
'set_thirdparty' && $permissiontoadd) {
164 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
166 if ($action ==
'classin' && $permissiontoadd) {
170 if ($action ==
'addline' && $permissiontoadd &&
$object->status == $object::STATUS_DRAFT) {
173 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
177 if ($fk_warehouse_source <= 0) {
179 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
183 if ($fk_warehouse_destination <= 0) {
185 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
190 $prod->fetch($fk_product);
191 if ($prod->hasbatch()) {
194 $langs->load(
"errors");
195 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref),
null,
'errors');
198 if (!empty($batch)) {
200 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
null,
'errors');
204 if ($prod->status_batch == 2 && abs($qty) > 1) {
206 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref),
null,
'errors');
210 if (!$error && $prod->status_batch == 2) {
211 foreach (
$object->lines as $tmpline) {
214 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref, $batch),
null,
'errors');
222 $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).
"'").
')');
223 if (!empty($records[key($records)])) {
224 $line = $records[key($records)];
226 $line->fk_stocktransfer =
$id;
228 $line->fk_warehouse_source = $fk_warehouse_source;
229 $line->fk_warehouse_destination = $fk_warehouse_destination;
230 $line->fk_product = $fk_product;
231 $line->batch = $batch;
233 $line->pmp = $prod->pmp;
235 $result = $line->update($user);
237 $line->rang = (is_array(
$object->lines) ||
$object->lines instanceof Countable) ? count(
$object->lines) + 1 : 1;
238 $result = $line->create($user);
241 setEventMessages($line->error, $line->errors,
'errors');
245 } elseif ($action ===
'updateline' && $permissiontoadd &&
$object->status == $object::STATUS_DRAFT) {
247 if ($line->fetch($lineid) <= 0 || $line->fk_stocktransfer !=
$object->id) {
249 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
255 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
256 $action =
'editline';
259 if ($fk_warehouse_source <= 0) {
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
262 $action =
'editline';
265 if ($fk_warehouse_destination <= 0) {
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
268 $action =
'editline';
272 $prod->fetch($fk_product);
273 if ($prod->hasbatch()) {
276 $langs->load(
"errors");
277 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
278 $action =
'editline';
281 if (!empty($batch)) {
283 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
null,
'errors');
284 $action =
'editline';
288 if ($prod->status_batch == 2 && abs($qty) > 1) {
290 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref),
null,
'errors');
291 $action =
'editline';
295 if (!$error && $prod->status_batch == 2) {
296 foreach (
$object->lines as $tmpline) {
297 if ($tmpline->id != $lineid && $tmpline->fk_product == $fk_product &&
dol_strtolower((
string) $tmpline->batch) ==
dol_strtolower($batch)) {
299 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref, $batch),
null,
'errors');
300 $action =
'editline';
308 $line->fetch($lineid);
310 $line->fk_warehouse_source = $fk_warehouse_source;
311 $line->fk_warehouse_destination = $fk_warehouse_destination;
312 $line->fk_product = $fk_product;
313 $line->batch = $batch;
314 $line->pmp = $prod->pmp;
315 $line->update($user);
320 if ($action ==
'confirm_destock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
321 $lines =
$object->getLinesArray();
322 if (!empty($lines)) {
324 foreach ($lines as $line) {
325 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
328 setEventMessages($line->error, $line->errors,
'errors');
338 $object->setStatut($object::STATUS_TRANSFERED, $id);
339 $object->status = $object::STATUS_TRANSFERED;
341 $result =
$object->update($user);
345 setEventMessage(
'StockStransferDecremented');
351 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
352 $lines =
$object->getLinesArray();
353 if (!empty($lines)) {
355 foreach ($lines as $line) {
356 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
359 setEventMessages($line->error, $line->errors,
'errors');
369 $object->setStatut($object::STATUS_VALIDATED, $id);
370 $object->status = $object::STATUS_VALIDATED;
371 $object->date_reelle_depart =
null;
372 $result =
$object->update($user);
376 setEventMessage(
'StockStransferDecrementedCancel',
'warnings');
382 if ($action ==
'confirm_addstock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
383 $lines =
$object->getLinesArray();
384 if (!empty($lines)) {
386 foreach ($lines as $line) {
387 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
390 setEventMessages($line->error, $line->errors,
'errors');
400 $object->setStatut($object::STATUS_CLOSED, $id);
401 $object->status = $object::STATUS_CLOSED;
403 $result =
$object->update($user);
409 $result =
$object->call_trigger(
'STOCKTRANSFER_CLOSE', $user);
416 setEventMessage(
'StockStransferIncrementedShort');
422 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
423 $lines =
$object->getLinesArray();
424 if (!empty($lines)) {
426 foreach ($lines as $line) {
427 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
430 setEventMessages($line->error, $line->errors,
'errors');
440 $object->setStatut($object::STATUS_TRANSFERED, $id);
441 $object->status = $object::STATUS_TRANSFERED;
442 $object->date_reelle_arrivee =
null;
443 $result =
$object->update($user);
447 setEventMessage(
'StockStransferIncrementedShortCancel',
'warnings');
453 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
457 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
458 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
459 $trackid =
'stocktransfer'.$object->id;
460 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
470$form =
new Form($db);
474$title = $langs->trans(
"StockTransfer");
477llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stocktransfer_stocktransfer_card');
481print
'<script type="text/javascript">
482jQuery(document).ready(function() {';
485$date_prevue_depart =
$object->date_prevue_depart;
486$date_prevue_depart_plus_delai = $date_prevue_depart;
487if (
$object->lead_time_for_warning > 0) {
488 $date_prevue_depart_plus_delai = strtotime(
date(
'Y-m-d', $date_prevue_depart) .
' + '.
$object->lead_time_for_warning.
' day');
490if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(
date(
'Y-m-d'))) {
491 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
492 print img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
501if ($action ==
'create') {
502 if (empty($permissiontoadd)) {
508 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
509 print
'<input type="hidden" name="token" value="'.newToken().
'">';
510 print
'<input type="hidden" name="action" value="add">';
512 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
514 if ($backtopageforcancel) {
515 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
521 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
524 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
532 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
533 print
'<td class="maxwidthonsmartphone">';
534 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
538 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
540 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
541 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
544 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
548 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
550 print
'</table>'.
"\n";
554 print $form->buttonsSaveCancel(
"Create");
562if (($id || $ref) && $action ==
'edit') {
565 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
566 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
567 print
'<input type="hidden" name="action" value="update">';
568 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
570 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
572 if ($backtopageforcancel) {
573 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
578 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
581 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
584 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
590 print $form->buttonsSaveCancel();
596if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
597 $res =
$object->fetch_optionals();
601 print
dol_get_fiche_head($head,
'card', $langs->trans(
"StockTransfer"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
606 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
607 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
610 if ($action ==
'deleteline') {
611 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
613 $formquestion = array();
615 if ($action ==
'clone') {
617 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
618 } elseif ($action ==
'destock') {
620 $formquestion = array(
'text' =>
'',
621 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock',
$object->ref),
'morecss' =>
'minwidth300'),
622 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
624 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
625 } elseif ($action ==
'destockcancel') {
627 $formquestion = array(
'text' =>
'',
628 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel',
$object->ref),
'morecss' =>
'minwidth300'),
629 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
631 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
632 } elseif ($action ==
'addstock') {
634 $formquestion = array(
'text' =>
'',
635 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock',
$object->ref),
'morecss' =>
'minwidth300'),
636 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
638 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
639 } elseif ($action ==
'addstockcancel') {
641 $formquestion = array(
'text' =>
'',
642 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel',
$object->ref),
'morecss' =>
'minwidth300'),
643 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
645 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
648 if ($action ==
'valid' && $permissiontoadd) {
649 $nextref =
$object->getNextNumRef();
650 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
654 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
655 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
656 if (empty($reshook)) {
657 $formconfirm .= $hookmanager->resPrint;
658 } elseif ($reshook > 0) {
659 $formconfirm = $hookmanager->resPrint;
668 $linkback =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
670 $morehtmlref =
'<div class="refidno">';
672 $morehtmlref .= empty(
$object->thirdparty) ?
'' :
$object->thirdparty->getNomUrl(1,
'customer');
674 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
678 $langs->load(
"projects");
679 $morehtmlref .= (empty(
$object->thirdparty) ?
'' :
'<br>');
680 if ($permissiontoadd) {
681 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
682 if ($action !=
'classify') {
683 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
685 $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');
687 if (!empty(
$object->fk_project)) {
689 $proj->fetch((
int)
$object->fk_project);
690 $morehtmlref .= $proj->getNomUrl(1);
692 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
697 $morehtmlref .=
'</div>';
700 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
703 print
'<div class="fichecenter">';
704 print
'<div class="fichehalfleft">';
705 print
'<div class="underbanner clearboth"></div>';
706 print
'<table class="border centpercent tableforfield">'.
"\n";
713 $object->fields[
'fk_soc'][
'visible'] = 0;
714 $object->fields[
'fk_project'][
'visible'] = 0;
715 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
720 print
'<table width="100%" class="nobordernopadding"><tr><td>';
721 print $langs->trans(
'IncotermLabel');
722 print
'<td><td class="right">';
723 if ($permissiontoadd && $action !=
'editincoterm') {
724 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.img_edit().
'</a>';
728 print
'</td></tr></table>';
731 if ($action !=
'editincoterm') {
732 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
734 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
740 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
741 echo
'<td>'.price(
$object->getValorisationTotale(), 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
745 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
751 print
'<div class="clearboth"></div>';
759 if (!empty(
$object->table_element_line)) {
773 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
775 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
815 print
'<div class="div-table-responsive-no-min">';
816 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
817 <input type="hidden" name="token" value="' .
newToken().
'">
818 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
819 <input type="hidden" name="mode" value="">
820 <input type="hidden" name="id" value="' .
$object->id.
'">
823 print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
825 print
'<table id="tablelines" class="noborder noshadow centpercent nomarginbottom">';
830 print
'<tr class="liste_titre">';
831 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
833 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
835 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
836 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
837 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
839 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
841 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
842 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
843 if (empty(
$object->status) && $permissiontoadd) {
851 $listofdata =
$object->getLinesArray();
852 $productstatic =
new Product($db);
853 $warehousestatics =
new Entrepot($db);
854 $warehousestatict =
new Entrepot($db);
857 foreach ($listofdata as $key => $line) {
858 $productstatic->fetch($line->fk_product);
859 $warehousestatics->fetch($line->fk_warehouse_source);
860 $warehousestatict->fetch($line->fk_warehouse_destination);
863 $domData =
' data-element="'.$line->element.
'"';
864 $domData .=
' data-id="'.$line->id.
'"';
865 $domData .=
' data-qty="'.$line->qty.
'"';
868 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
869 print
'<td class="titlefield">';
870 if ($action ===
'editline' && $line->id == $lineid) {
871 $form->select_produits($line->fk_product,
'fk_product',
'', 0, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
873 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
878 if ($action ===
'editline' && $line->id == $lineid) {
879 print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
882 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
883 print $productlot->getNomUrl(1);
884 } elseif (!empty($line->batch)) {
885 print $line->batch.
' '.img_warning($langs->trans(
'BatchNotFound'));
892 print
'<td class="tdoverflowmax150">';
893 if ($action ===
'editline' && $line->id == $lineid) {
894 print $formproduct->selectWarehouses($line->fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
896 print $warehousestatics->getNomUrl(1);
901 print
'<td class="tdoverflowmax150">';
902 if ($action ===
'editline' && $line->id == $lineid) {
903 print $formproduct->selectWarehouses($line->fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
905 print $warehousestatict->getNomUrl(1);
909 if ($action ===
'editline' && $line->id == $lineid) {
910 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.
'"></td>';
912 print
'<td class="center">'.$line->qty.
'</td>';
916 print
'<td class="linecoluseunit nowrap left">';
917 $label = $productstatic->getLabelOfUnit(
'short');
922 print
'<td class="center">';
923 print
price($line->pmp, 0,
'', 1, -1, -1,
$conf->currency);
926 print
'<td class="center">';
927 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1,
$conf->currency);
930 if (empty(
$object->status) && $permissiontoadd) {
931 if ($action ===
'editline' && $line->id == $lineid) {
933 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
934 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
936 print
'<td class="right">';
937 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token='.newToken().
'&lineid=' . $line->id .
'#line_' . $line->id .
'">';
938 print img_edit() .
'</a>';
940 print
'<td class="right">';
942 $deleteLineUrl = $_SERVER[
"PHP_SELF"] .
'?id=' .
$id .
'&action=deleteline&lineid=' . $line->id .
'&token=' .
newToken();
943 print
'<a href="' . $deleteLineUrl .
'">' . img_delete($langs->trans(
"Remove")) .
'</a>';
949 if ($num > 1 &&
$conf->browser->layout !=
'phone' && empty($disablemove)) {
950 print
'<td class="linecolmove tdlineupdown center">';
952 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&token='.newToken().'&rowid='.$line->id; ?>">
953 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
956 if ($i < $num - 1) { ?>
957 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&token='.newToken().'&rowid='.$line->id; ?>">
958 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
963 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
972 if (empty(
$object->status) && $action !==
'editline' && $permissiontoadd) {
973 print
'<tr class="oddeven">';
975 print
'<td class="titlefield">';
986 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
991 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
995 $formproduct->loadWarehouses();
998 $TExcludedWarehouseSource = array();
999 if (!empty(
$object->fk_warehouse_source)) {
1001 $source_ent->fetch(
$object->fk_warehouse_source);
1002 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
1003 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) {
1004 $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
1010 $TExcludedWarehouseDestination = array();
1011 if (!empty(
$object->fk_warehouse_destination)) {
1013 $dest_ent->fetch(
$object->fk_warehouse_destination);
1014 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
1015 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) {
1016 $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
1022 $formproduct->cache_warehouses = array();
1025 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);
1029 $formproduct->cache_warehouses = array();
1032 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);
1036 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.(GETPOSTISSET(
'qty') ?
GETPOST(
'qty') : $qty).
'"' :
'').
'></td>';
1049 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
1066 if ($action !=
'presend' && $action !=
'editline') {
1067 print
'<div class="tabsAction">'.
"\n";
1068 $parameters = array();
1069 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1071 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1074 if (empty($reshook)) {
1076 if (empty($user->socid)) {
1077 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle');
1081 if (
$object->status == $object::STATUS_VALIDATED) {
1082 print dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'confirm_setdraft',
'confirm' =>
'yes'],
true),
'', $permissiontoadd);
1086 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'edit'],
true),
'', $permissiontoadd);
1089 if (
$object->status == $object::STATUS_DRAFT) {
1090 if (empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) {
1091 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'confirm_validate',
'confirm' =>
'yes'],
true),
'', $permissiontoadd);
1093 $langs->load(
"errors");
1094 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
1099 if (
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
1100 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destock&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
1101 } elseif (
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
1102 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
1103 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstock&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
1104 } elseif (
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
1105 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstockcancel&token='.
newToken().
'" title="Only stock increase of destination warehouse will be canceled. You will be able to cancel the decrease of source warehouse just after.">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
1109 if ($permissiontoadd) {
1110 print dolGetButtonAction($langs->trans(
'ToClone'), $langs->trans(
'ToClone'),
'clone',
dolBuildUrl($_SERVER[
'PHP_SELF'], array_merge([
'id' =>
$object->id], (!empty(
$object->socid) ? [
'socid' =>
$object->socid] : []), [
'action' =>
'clone']), true),
'', $permissiontoadd, array(
'attr' => array(
'class' =>
'reposition')));
1132 $deleteUrl =
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'delete'],
true);
1133 $buttonId =
'action-delete-no-ajax';
1134 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
1135 $buttonId =
'action-delete';
1138 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
1140 print
'</div>'.
"\n";
1145 if (
GETPOST(
'modelselected')) {
1146 $action =
'presend';
1149 if ($action !=
'presend') {
1150 print
'<div class="fichecenter"><div class="fichehalfleft">';
1151 print
'<a name="builddoc"></a>';
1153 $includedocgeneration = 1;
1156 if ($includedocgeneration) {
1158 $relativepath = $objref .
'/' . $objref .
'.pdf';
1159 $filedir =
$conf->stocktransfer->dir_output.
'/'.
$object->element.
'/'.$objref;
1160 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
1161 $genallowed = $permissiontoread;
1162 $delallowed = $permissiontoadd;
1163 print $formfile->showdocuments(
'stocktransfer:StockTransfer',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1167 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'stocktransfer'), 1);
1168 $linktoelem = $tmparray[
'linktoelem'];
1169 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1170 print $htmltoenteralink;
1172 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1175 print
'</div><div class="fichehalfright">';
1182 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1184 $somethingshown = $formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'');
1186 print
'</div></div>';
1190 if (
GETPOST(
'modelselected')) {
1191 $action =
'presend';
1195 $modelmail =
'stocktransfer_send';
1196 $defaulttopic =
'InformationMessage';
1197 $diroutput =
$conf->stocktransfer->dir_output.
'/'.
$object->element;
1198 $trackid =
'stocktransfer'.$object->id;
1200 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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
print $langs trans('Date')." left Ref 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 Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
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.