27require
'../../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
48$langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies"));
49if (isModEnabled(
'incoterm')) {
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->rights->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);
131if (empty($reshook)) {
134 $backurlforlist =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1);
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 =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
146 $triggermodname =
'STOCKTRANSFER_STOCKTRANSFER_MODIFY';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
152 $permissiontodelete = $user->rights->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 $line->update($user);
229 $line->rang = (is_array(
$object->lines) ||
$object->lines instanceof Countable) ? count(
$object->lines) + 1 : 1;
230 $line->create($user);
234 } elseif ($action ===
'updateline' && $permissiontoadd) {
237 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
238 $action =
'editline';
241 if ($fk_warehouse_source <= 0) {
243 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
244 $action =
'editline';
247 if ($fk_warehouse_destination <= 0) {
249 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
250 $action =
'editline';
254 $prod->fetch($fk_product);
255 if ($prod->hasbatch()) {
258 $langs->load(
"errors");
259 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
260 $action =
'editline';
263 if (!empty($batch)) {
265 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
null,
'errors');
266 $action =
'editline';
270 if ($prod->status_batch == 2 && abs($qty) > 1) {
272 setEventMessages($langs->transnoentities(
'TooManyQtyForSerialNumber', $prod->ref),
null,
'errors');
273 $action =
'editline';
278 $line->fetch($lineid);
280 $line->fk_warehouse_source = $fk_warehouse_source;
281 $line->fk_warehouse_destination = $fk_warehouse_destination;
282 $line->fk_product = $fk_product;
283 $line->batch = $batch;
284 $line->pmp = $prod->pmp;
285 $line->update($user);
290 if ($action ==
'confirm_destock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
291 $lines =
$object->getLinesArray();
292 if (!empty($lines)) {
294 foreach ($lines as $line) {
295 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
308 $object->setStatut($object::STATUS_TRANSFERED, $id);
309 $object->status = $object::STATUS_TRANSFERED;
317 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
318 $lines =
$object->getLinesArray();
319 if (!empty($lines)) {
321 foreach ($lines as $line) {
322 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
335 $object->setStatut($object::STATUS_VALIDATED, $id);
336 $object->status = $object::STATUS_VALIDATED;
337 $object->date_reelle_depart =
null;
344 if ($action ==
'confirm_addstock' && $confirm ==
'yes' &&
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
345 $lines =
$object->getLinesArray();
346 if (!empty($lines)) {
348 foreach ($lines as $line) {
349 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
362 $object->setStatut($object::STATUS_CLOSED, $id);
363 $object->status = $object::STATUS_CLOSED;
371 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' &&
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
372 $lines =
$object->getLinesArray();
373 if (!empty($lines)) {
375 foreach ($lines as $line) {
376 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
389 $object->setStatut($object::STATUS_TRANSFERED, $id);
390 $object->status = $object::STATUS_TRANSFERED;
391 $object->date_reelle_arrivee =
null;
398 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $permissiontoadd) {
402 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
403 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
404 $trackid =
'stocktransfer'.$object->id;
405 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
415$form =
new Form($db);
419$title = $langs->trans(
"StockTransfer");
422llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stocktransfer_stocktransfer_card');
427print
'<script type="text/javascript" language="javascript">
428jQuery(document).ready(function() {';
431$date_prevue_depart =
$object->date_prevue_depart;
432$date_prevue_depart_plus_delai = $date_prevue_depart;
433if (
$object->lead_time_for_warning > 0) {
434 $date_prevue_depart_plus_delai = strtotime(date(
'Y-m-d', $date_prevue_depart) .
' + '.
$object->lead_time_for_warning.
' day');
436if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date(
'Y-m-d'))) {
437 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
438 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
447if ($action ==
'create') {
448 if (empty($permissiontoadd)) {
454 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
455 print
'<input type="hidden" name="token" value="'.newToken().
'">';
456 print
'<input type="hidden" name="action" value="add">';
458 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
460 if ($backtopageforcancel) {
461 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
467 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
470 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
472 if (isModEnabled(
'incoterm')) {
478 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
479 print
'<td class="maxwidthonsmartphone">';
480 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
484 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
486 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
487 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
490 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
494 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
496 print
'</table>'.
"\n";
500 print $form->buttonsSaveCancel(
"Create");
508if (($id || $ref) && $action ==
'edit') {
511 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
512 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
513 print
'<input type="hidden" name="action" value="update">';
514 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
516 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
518 if ($backtopageforcancel) {
519 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
524 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
527 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
530 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
536 print $form->buttonsSaveCancel();
542if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
543 $res =
$object->fetch_optionals();
552 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
553 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
556 if ($action ==
'deleteline') {
557 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
559 $formquestion = array();
561 if ($action ==
'clone') {
563 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
564 } elseif ($action ==
'destock') {
566 $formquestion = array(
'text' =>
'',
567 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock',
$object->ref),
'size' => 40),
568 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
570 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
571 } elseif ($action ==
'destockcancel') {
573 $formquestion = array(
'text' =>
'',
574 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel',
$object->ref),
'size' => 40),
575 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
577 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
578 } elseif ($action ==
'addstock') {
580 $formquestion = array(
'text' =>
'',
581 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock',
$object->ref),
'size' => 40),
582 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
584 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
585 } elseif ($action ==
'addstockcancel') {
587 $formquestion = array(
'text' =>
'',
588 0 => array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel',
$object->ref),
'size' => 40),
589 1 => array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size' => 25)
591 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
594 if ($action ==
'valid' && $permissiontoadd) {
595 $nextref =
$object->getNextNumRef();
596 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
600 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
601 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
602 if (empty($reshook)) {
603 $formconfirm .= $hookmanager->resPrint;
604 } elseif ($reshook > 0) {
605 $formconfirm = $hookmanager->resPrint;
614 $linkback =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
616 $morehtmlref =
'<div class="refidno">';
618 $morehtmlref .= empty(
$object->thirdparty) ?
'' :
$object->thirdparty->getNomUrl(1,
'customer');
620 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
623 if (isModEnabled(
'project')) {
624 $langs->load(
"projects");
625 $morehtmlref .= (empty(
$object->thirdparty) ?
'' :
'<br>');
626 if ($permissiontoadd) {
627 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
628 if ($action !=
'classify') {
629 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
631 $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');
633 if (!empty(
$object->fk_project)) {
635 $proj->fetch(
$object->fk_project);
636 $morehtmlref .= $proj->getNomUrl(1);
638 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
643 $morehtmlref .=
'</div>';
646 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
649 print
'<div class="fichecenter">';
650 print
'<div class="fichehalfleft">';
651 print
'<div class="underbanner clearboth"></div>';
652 print
'<table class="border centpercent tableforfield">'.
"\n";
659 $object->fields[
'fk_soc'][
'visible'] = 0;
660 $object->fields[
'fk_project'][
'visible'] = 0;
661 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
664 if (isModEnabled(
'incoterm')) {
666 print
'<table width="100%" class="nobordernopadding"><tr><td>';
667 print $langs->trans(
'IncotermLabel');
668 print
'<td><td class="right">';
669 if ($permissiontoadd && $action !=
'editincoterm') {
670 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
674 print
'</td></tr></table>';
677 if ($action !=
'editincoterm') {
678 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
680 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
686 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
687 echo
'<td>'.price(
$object->getValorisationTotale(), 0,
'', 1, -1, -1,
$conf->currency).
'</td>';
691 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
697 print
'<div class="clearboth"></div>';
706 if (!empty(
$object->table_element_line)) {
720 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
722 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
762 print
'<div class="div-table-responsive-no-min">';
763 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
764 <input type="hidden" name="token" value="' .
newToken().
'">
765 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
766 <input type="hidden" name="mode" value="">
767 <input type="hidden" name="id" value="' .
$object->id.
'">
770 print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
772 print
'<table id="tablelines" class="liste centpercent">';
777 print
'<tr class="liste_titre">';
778 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
779 if (isModEnabled(
'productbatch')) {
780 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
782 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
783 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
784 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
786 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
788 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
789 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
790 if (empty(
$object->status) && $permissiontoadd) {
798 $listofdata =
$object->getLinesArray();
799 $productstatic =
new Product($db);
800 $warehousestatics =
new Entrepot($db);
801 $warehousestatict =
new Entrepot($db);
803 foreach ($listofdata as $key => $line) {
804 $productstatic->fetch($line->fk_product);
805 $warehousestatics->fetch($line->fk_warehouse_source);
806 $warehousestatict->fetch($line->fk_warehouse_destination);
809 $domData =
' data-element="'.$line->element.
'"';
810 $domData .=
' data-id="'.$line->id.
'"';
811 $domData .=
' data-qty="'.$line->qty.
'"';
814 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
815 print
'<td class="titlefield">';
816 if ($action ===
'editline' && $line->id == $lineid) {
817 $form->select_produits($line->fk_product,
'fk_product',
'', 0, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
819 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
822 if (isModEnabled(
'productbatch')) {
824 if ($action ===
'editline' && $line->id == $lineid) {
825 print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
828 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
829 print $productlot->getNomUrl(1);
830 } elseif (!empty($line->batch)) {
831 print $line->batch.
' '.
img_warning($langs->trans(
'BatchNotFound'));
838 print
'<td class="tdoverflowmax150">';
839 if ($action ===
'editline' && $line->id == $lineid) {
840 print $formproduct->selectWarehouses($line->fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
842 print $warehousestatics->getNomUrl(1);
847 print
'<td class="tdoverflowmax150">';
848 if ($action ===
'editline' && $line->id == $lineid) {
849 print $formproduct->selectWarehouses($line->fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200');
851 print $warehousestatict->getNomUrl(1);
855 if ($action ===
'editline' && $line->id == $lineid) {
856 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.
'"></td>';
858 print
'<td class="center">'.$line->qty.
'</td>';
862 print
'<td class="linecoluseunit nowrap left">';
863 $label = $productstatic->getLabelOfUnit(
'short');
868 print
'<td class="center">';
869 print
price($line->pmp, 0,
'', 1, -1, -1,
$conf->currency);
872 print
'<td class="center">';
873 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1,
$conf->currency);
876 if (empty(
$object->status) && $permissiontoadd) {
877 if ($action ===
'editline' && $line->id == $lineid) {
879 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
880 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
882 print
'<td class="right">';
883 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=editline&lineid=' . $line->id .
'#line_' . $line->id .
'">';
886 print
'<td class="right">';
887 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$id .
'&action=deleteline&lineid=' . $line->id .
'">' .
img_delete($langs->trans(
"Remove")) .
'</a>';
893 if ($num > 1 &&
$conf->browser->layout !=
'phone' && empty($disablemove)) {
894 print
'<td class="linecolmove tdlineupdown center">';
896 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
897 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
900 if ($i < $num - 1) { ?>
901 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&rowid='.$line->id; ?>">
902 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
907 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
914 if (empty(
$object->status) && $action !==
'editline' && $permissiontoadd) {
915 print
'<tr class="oddeven">';
917 print
'<td class="titlefield">';
928 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
931 if (isModEnabled(
'productbatch')) {
933 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
937 $formproduct->loadWarehouses();
940 $TExcludedWarehouseSource = array();
941 if (!empty(
$object->fk_warehouse_source)) {
943 $source_ent->fetch(
$object->fk_warehouse_source);
944 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
945 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) {
946 $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
952 $TExcludedWarehouseDestination = array();
953 if (!empty(
$object->fk_warehouse_destination)) {
955 $dest_ent->fetch(
$object->fk_warehouse_destination);
956 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
957 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) {
958 $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
964 $formproduct->cache_warehouses = array();
967 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);
971 $formproduct->cache_warehouses = array();
974 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);
978 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.$qty.
'"' :
'').
'></td>';
991 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
1005 if ($action !=
'presend' && $action !=
'editline') {
1006 print
'<div class="tabsAction">'.
"\n";
1007 $parameters = array();
1008 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1013 if (empty($reshook)) {
1015 if (empty($user->socid)) {
1016 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
1020 if (
$object->status == $object::STATUS_VALIDATED) {
1021 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
1025 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
1028 if (
$object->status == $object::STATUS_DRAFT) {
1029 if (empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) {
1030 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
1032 $langs->load(
"errors");
1033 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
1035 } elseif (
$object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
1036 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destock&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
1037 } elseif (
$object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
1038 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=destockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
1039 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstock&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
1040 } elseif (
$object->status == $object::STATUS_CLOSED && $permissiontoadd) {
1041 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=addstockcancel&token='.
newToken().
'">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
1045 if ($permissiontoadd) {
1046 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
1068 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
1069 $buttonId =
'action-delete-no-ajax';
1070 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
1072 $buttonId =
'action-delete';
1075 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
1077 print
'</div>'.
"\n";
1082 if (
GETPOST(
'modelselected')) {
1083 $action =
'presend';
1086 if ($action !=
'presend') {
1087 print
'<div class="fichecenter"><div class="fichehalfleft">';
1088 print
'<a name="builddoc"></a>';
1090 $includedocgeneration = 1;
1093 if ($includedocgeneration) {
1095 $relativepath = $objref .
'/' . $objref .
'.pdf';
1096 $filedir =
$conf->stocktransfer->dir_output.
'/'.
$object->element.
'/'.$objref;
1097 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
1098 $genallowed = $permissiontoread;
1099 $delallowed = $permissiontoadd;
1100 print $formfile->showdocuments(
'stocktransfer:StockTransfer',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1104 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'stocktransfer'), 1);
1105 $linktoelem = $tmparray[
'linktoelem'];
1106 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1107 print $htmltoenteralink;
1109 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1112 print
'</div><div class="fichehalfright">';
1119 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1121 $somethingshown = $formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'');
1123 print
'</div></div>';
1127 if (
GETPOST(
'modelselected')) {
1128 $action =
'presend';
1132 $modelmail =
'stocktransfer';
1133 $defaulttopic =
'InformationMessage';
1134 $diroutput =
$conf->stocktransfer->dir_output;
1135 $trackid =
'stocktransfer'.$object->id;
1137 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.