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"));
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];
116if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
125$parameters = array();
126$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
128 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
131if (empty($reshook)) {
134 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_list.php');
136 if (empty($backtopage) || ($cancel && empty($id))) {
137 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
138 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
139 $backtopage = $backurlforlist;
141 $backtopage =
dolBuildUrl(DOL_URL_ROOT.
'/product/stock/stocktransfer/stocktransfer_card.php', [
'id' => ($id > 0 ? $id :
'__ID__')]);
146 $triggermodname =
'STOCKTRANSFER_MODIFY';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
152 $permissiontodelete = $user->hasRight(
'stocktransfer',
'stocktransfer',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
155 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
158 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
161 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
164 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
166 if ($action ==
'set_thirdparty' && $permissiontoadd) {
167 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
169 if ($action ==
'classin' && $permissiontoadd) {
173 if ($action ==
'addline' && $permissiontoadd) {
176 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
180 if ($fk_warehouse_source <= 0) {
182 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
186 if ($fk_warehouse_destination <= 0) {
188 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
193 $prod->fetch($fk_product);
194 if (
$prod->hasbatch()) {
197 $langs->load(
"errors");
198 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData",
$prod->ref),
null,
'errors');
201 if (!empty($batch)) {
203 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct',
$prod->getNomUrl()),
null,
'errors');
207 if (
$prod->status_batch == 2 && abs($qty) > 1) {
209 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber',
$prod->ref),
null,
'errors');
214 $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).
"'").
')');
215 if (!empty($records[key($records)])) {
216 $line = $records[key($records)];
218 $line->fk_stocktransfer =
$id;
220 $line->fk_warehouse_source = $fk_warehouse_source;
221 $line->fk_warehouse_destination = $fk_warehouse_destination;
222 $line->fk_product = $fk_product;
223 $line->batch = $batch;
225 $line->pmp =
$prod->pmp;
227 $result = $line->update($user);
229 $line->rang = (is_array(
$object->lines) ||
$object->lines instanceof Countable) ? count(
$object->lines) + 1 : 1;
230 $result = $line->create($user);
233 setEventMessages($line->error, $line->errors,
'errors');
237 } elseif ($action ===
'updateline' && $permissiontoadd) {
240 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
241 $action =
'editline';
244 if ($fk_warehouse_source <= 0) {
246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
247 $action =
'editline';
250 if ($fk_warehouse_destination <= 0) {
252 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
253 $action =
'editline';
257 $prod->fetch($fk_product);
258 if (
$prod->hasbatch()) {
261 $langs->load(
"errors");
262 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData",
$prod->getNomUrl()),
null,
'errors');
263 $action =
'editline';
266 if (!empty($batch)) {
268 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct',
$prod->getNomUrl()),
null,
'errors');
269 $action =
'editline';
273 if (
$prod->status_batch == 2 && abs($qty) > 1) {
275 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber',
$prod->ref),
null,
'errors');
276 $action =
'editline';
281 $line->fetch($lineid);
283 $line->fk_warehouse_source = $fk_warehouse_source;
284 $line->fk_warehouse_destination = $fk_warehouse_destination;
285 $line->fk_product = $fk_product;
286 $line->batch = $batch;
287 $line->pmp =
$prod->pmp;
288 $line->update($user);
293 if ($action ==
'confirm_destock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
294 $lines =
$object->getLinesArray();
295 if (!empty($lines)) {
297 foreach ($lines as $line) {
298 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
301 setEventMessages($line->error, $line->errors,
'errors');
311 $object->setStatut($object::STATUS_TRANSFERED, $id);
312 $object->status = $object::STATUS_TRANSFERED;
314 $result =
$object->update($user);
318 setEventMessage(
'StockStransferDecremented');
324 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
325 $lines =
$object->getLinesArray();
326 if (!empty($lines)) {
328 foreach ($lines as $line) {
329 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
332 setEventMessages($line->error, $line->errors,
'errors');
342 $object->setStatut($object::STATUS_VALIDATED, $id);
343 $object->status = $object::STATUS_VALIDATED;
344 $object->date_reelle_depart =
null;
345 $result =
$object->update($user);
349 setEventMessage(
'StockStransferDecrementedCancel',
'warnings');
355 if ($action ==
'confirm_addstock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
356 $lines =
$object->getLinesArray();
357 if (!empty($lines)) {
359 foreach ($lines as $line) {
360 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
363 setEventMessages($line->error, $line->errors,
'errors');
373 $object->setStatut($object::STATUS_CLOSED, $id);
374 $object->status = $object::STATUS_CLOSED;
376 $result =
$object->update($user);
382 $result =
$object->call_trigger(
'STOCKTRANSFER_CLOSE', $user);
389 setEventMessage(
'StockStransferIncrementedShort');
395 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
396 $lines =
$object->getLinesArray();
397 if (!empty($lines)) {
399 foreach ($lines as $line) {
400 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
403 setEventMessages($line->error, $line->errors,
'errors');
413 $object->setStatut($object::STATUS_TRANSFERED, $id);
414 $object->status = $object::STATUS_TRANSFERED;
415 $object->date_reelle_arrivee =
null;
416 $result =
$object->update($user);
420 setEventMessage(
'StockStransferIncrementedShortCancel',
'warnings');
426 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
430 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
431 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
432 $trackid =
'stocktransfer'.$object->id;
433 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
443$form =
new Form($db);
447$title = $langs->trans(
"StockTransfer");
450llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stocktransfer_stocktransfer_card');
454print
'<script type="text/javascript">
455jQuery(document).ready(function() {';
458$date_prevue_depart =
$object->date_prevue_depart;
459$date_prevue_depart_plus_delai = $date_prevue_depart;
460if (
$object->lead_time_for_warning > 0) {
461 $date_prevue_depart_plus_delai = strtotime(
date(
'Y-m-d', $date_prevue_depart) .
' + '.
$object->lead_time_for_warning.
' day');
463if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(
date(
'Y-m-d'))) {
464 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
465 print img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
474if ($action ==
'create') {
475 if (empty($permissiontoadd)) {
481 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
482 print
'<input type="hidden" name="token" value="'.newToken().
'">';
483 print
'<input type="hidden" name="action" value="add">';
485 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
487 if ($backtopageforcancel) {
488 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
494 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
497 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
505 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
506 print
'<td class="maxwidthonsmartphone">';
507 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
511 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
513 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
514 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
517 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
521 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
523 print
'</table>'.
"\n";
527 print $form->buttonsSaveCancel(
"Create");
535if (($id || $ref) && $action ==
'edit') {
538 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
539 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
540 print
'<input type="hidden" name="action" value="update">';
541 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
543 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
545 if ($backtopageforcancel) {
546 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
551 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
554 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
557 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
563 print $form->buttonsSaveCancel();
569if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
570 $res =
$object->fetch_optionals();
574 print
dol_get_fiche_head($head,
'card', $langs->trans(
"StockTransfer"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
579 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
580 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
583 if ($action ==
'deleteline') {
584 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
586 $formquestion = array();
588 if ($action ==
'clone') {
590 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
591 } elseif ($action ==
'destock') {
593 $formquestion = array(
'text' =>
'',
594 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock',
$object->ref),
'morecss' =>
'minwidth300'),
595 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
597 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
598 } elseif ($action ==
'destockcancel') {
600 $formquestion = array(
'text' =>
'',
601 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel',
$object->ref),
'morecss' =>
'minwidth300'),
602 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
604 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
605 } elseif ($action ==
'addstock') {
607 $formquestion = array(
'text' =>
'',
608 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock',
$object->ref),
'morecss' =>
'minwidth300'),
609 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
611 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
612 } elseif ($action ==
'addstockcancel') {
614 $formquestion = array(
'text' =>
'',
615 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel',
$object->ref),
'morecss' =>
'minwidth300'),
616 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'morecss' =>
'minwidth200')
618 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
621 if ($action ==
'valid' && $permissiontoadd) {
622 $nextref =
$object->getNextNumRef();
623 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
627 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
628 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
629 if (empty($reshook)) {
630 $formconfirm .= $hookmanager->resPrint;
631 } elseif ($reshook > 0) {
632 $formconfirm = $hookmanager->resPrint;
641 $linkback =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
643 $morehtmlref =
'<div class="refidno">';
645 $morehtmlref .= empty(
$object->thirdparty) ?
'' :
$object->thirdparty->getNomUrl(1,
'customer');
647 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherOrders").
'</a>)';
651 $langs->load(
"projects");
652 $morehtmlref .= (empty(
$object->thirdparty) ?
'' :
'<br>');
653 if ($permissiontoadd) {
654 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
655 if ($action !=
'classify') {
656 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
658 $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');
660 if (!empty(
$object->fk_project)) {
662 $proj->fetch(
$object->fk_project);
663 $morehtmlref .= $proj->getNomUrl(1);
665 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
670 $morehtmlref .=
'</div>';
673 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
676 print
'<div class="fichecenter">';
677 print
'<div class="fichehalfleft">';
678 print
'<div class="underbanner clearboth"></div>';
679 print
'<table class="border centpercent tableforfield">'.
"\n";
686 $object->fields[
'fk_soc'][
'visible'] = 0;
687 $object->fields[
'fk_project'][
'visible'] = 0;
688 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
693 print
'<table width="100%" class="nobordernopadding"><tr><td>';
694 print $langs->trans(
'IncotermLabel');
695 print
'<td><td class="right">';
696 if ($permissiontoadd && $action !=
'editincoterm') {
697 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.img_edit().
'</a>';
701 print
'</td></tr></table>';
704 if ($action !=
'editincoterm') {
705 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
707 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
713 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
714 echo
'<td>'.price(
$object->getValorisationTotale(), 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
718 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
724 print
'<div class="clearboth"></div>';
732 if (!empty(
$object->table_element_line)) {
746 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
748 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
788 print
'<div class="div-table-responsive-no-min">';
789 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
790 <input type="hidden" name="token" value="' .
newToken().
'">
791 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
792 <input type="hidden" name="mode" value="">
793 <input type="hidden" name="id" value="' .
$object->id.
'">
796 print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
798 print
'<table id="tablelines" class="noborder noshadow centpercent nomarginbottom">';
803 print
'<tr class="liste_titre">';
804 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
806 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
808 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
809 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
810 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
812 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
814 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
815 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
816 if (empty(
$object->status) && $permissiontoadd) {
824 $listofdata =
$object->getLinesArray();
825 $productstatic =
new Product($db);
826 $warehousestatics =
new Entrepot($db);
827 $warehousestatict =
new Entrepot($db);
830 foreach ($listofdata as $key => $line) {
831 $productstatic->fetch($line->fk_product);
832 $warehousestatics->fetch($line->fk_warehouse_source);
833 $warehousestatict->fetch($line->fk_warehouse_destination);
836 $domData =
' data-element="'.$line->element.
'"';
837 $domData .=
' data-id="'.$line->id.
'"';
838 $domData .=
' data-qty="'.$line->qty.
'"';
841 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
842 print
'<td class="titlefield">';
843 if ($action ===
'editline' && $line->id == $lineid) {
844 $form->select_produits($line->fk_product,
'fk_product',
'', 0, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
846 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
851 if ($action ===
'editline' && $line->id == $lineid) {
852 print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
855 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
856 print $productlot->getNomUrl(1);
857 } elseif (!empty($line->batch)) {
858 print $line->batch.
' '.img_warning($langs->trans(
'BatchNotFound'));
865 print
'<td class="tdoverflowmax150">';
866 if ($action ===
'editline' && $line->id == $lineid) {
867 print $formproduct->selectWarehouses($line->fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
869 print $warehousestatics->getNomUrl(1);
874 print
'<td class="tdoverflowmax150">';
875 if ($action ===
'editline' && $line->id == $lineid) {
876 print $formproduct->selectWarehouses($line->fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
878 print $warehousestatict->getNomUrl(1);
882 if ($action ===
'editline' && $line->id == $lineid) {
883 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.
'"></td>';
885 print
'<td class="center">'.$line->qty.
'</td>';
889 print
'<td class="linecoluseunit nowrap left">';
890 $label = $productstatic->getLabelOfUnit(
'short');
895 print
'<td class="center">';
896 print
price($line->pmp, 0,
'', 1, -1, -1,
$conf->currency);
899 print
'<td class="center">';
900 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1,
$conf->currency);
903 if (empty(
$object->status) && $permissiontoadd) {
904 if ($action ===
'editline' && $line->id == $lineid) {
906 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
907 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
909 print
'<td class="right">';
910 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&token='.newToken().
'&lineid=' . $line->id .
'#line_' . $line->id .
'">';
911 print img_edit() .
'</a>';
913 print
'<td class="right">';
915 $deleteLineUrl = $_SERVER[
"PHP_SELF"] .
'?id=' .
$id .
'&action=deleteline&lineid=' . $line->id .
'&token=' .
newToken();
916 print
'<a href="' . $deleteLineUrl .
'">' . img_delete($langs->trans(
"Remove")) .
'</a>';
922 if ($num > 1 &&
$conf->browser->layout !=
'phone' && empty($disablemove)) {
923 print
'<td class="linecolmove tdlineupdown center">';
925 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&token='.newToken().'&rowid='.$line->id; ?>">
926 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
929 if ($i < $num - 1) { ?>
930 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&token='.newToken().'&rowid='.$line->id; ?>">
931 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
936 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
945 if (empty(
$object->status) && $action !==
'editline' && $permissiontoadd) {
946 print
'<tr class="oddeven">';
948 print
'<td class="titlefield">';
959 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
964 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
968 $formproduct->loadWarehouses();
971 $TExcludedWarehouseSource = array();
972 if (!empty(
$object->fk_warehouse_source)) {
974 $source_ent->fetch(
$object->fk_warehouse_source);
975 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
976 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) {
977 $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
983 $TExcludedWarehouseDestination = array();
984 if (!empty(
$object->fk_warehouse_destination)) {
986 $dest_ent->fetch(
$object->fk_warehouse_destination);
987 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
988 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) {
989 $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
995 $formproduct->cache_warehouses = array();
998 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);
1002 $formproduct->cache_warehouses = array();
1005 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);
1009 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.(GETPOSTISSET(
'qty') ?
GETPOST(
'qty') : $qty).
'"' :
'').
'></td>';
1022 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
1039 if ($action !=
'presend' && $action !=
'editline') {
1040 print
'<div class="tabsAction">'.
"\n";
1041 $parameters = array();
1042 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1044 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1047 if (empty($reshook)) {
1049 if (empty($user->socid)) {
1050 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle');
1054 if (
$object->status == $object::STATUS_VALIDATED) {
1055 print dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'confirm_setdraft',
'confirm' =>
'yes'],
true),
'', $permissiontoadd);
1059 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'edit'],
true),
'', $permissiontoadd);
1062 if (
$object->status == $object::STATUS_DRAFT) {
1063 if (empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) {
1064 print dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'confirm_validate',
'confirm' =>
'yes'],
true),
'', $permissiontoadd);
1066 $langs->load(
"errors");
1067 print dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
1072 if (
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
1073 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destock&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
1074 } elseif (
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
1075 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
1076 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstock&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
1077 } elseif (
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
1078 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>';
1082 if ($permissiontoadd) {
1083 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')));
1105 $deleteUrl =
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'delete'],
true);
1106 $buttonId =
'action-delete-no-ajax';
1107 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
1109 $buttonId =
'action-delete';
1112 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
1114 print
'</div>'.
"\n";
1119 if (
GETPOST(
'modelselected')) {
1120 $action =
'presend';
1123 if ($action !=
'presend') {
1124 print
'<div class="fichecenter"><div class="fichehalfleft">';
1125 print
'<a name="builddoc"></a>';
1127 $includedocgeneration = 1;
1130 if ($includedocgeneration) {
1132 $relativepath = $objref .
'/' . $objref .
'.pdf';
1133 $filedir =
$conf->stocktransfer->dir_output.
'/'.
$object->element.
'/'.$objref;
1134 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
1135 $genallowed = $permissiontoread;
1136 $delallowed = $permissiontoadd;
1137 print $formfile->showdocuments(
'stocktransfer:StockTransfer',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1141 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'stocktransfer'), 1);
1142 $linktoelem = $tmparray[
'linktoelem'];
1143 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1144 print $htmltoenteralink;
1146 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1149 print
'</div><div class="fichehalfright">';
1156 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1158 $somethingshown = $formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'');
1160 print
'</div></div>';
1164 if (
GETPOST(
'modelselected')) {
1165 $action =
'presend';
1169 $modelmail =
'stocktransfer_send';
1170 $defaulttopic =
'InformationMessage';
1171 $diroutput =
$conf->stocktransfer->dir_output.
'/'.
$object->element;
1172 $trackid =
'stocktransfer'.$object->id;
1174 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.
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
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.