26require
'../../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
39$langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies"));
40if (isModEnabled(
'incoterm')) {
41 $langs->load(
'incoterm');
48$action =
GETPOST(
'action',
'aZ09');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$cancel =
GETPOST(
'cancel',
'aZ09');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
52$backtopage =
GETPOST(
'backtopage',
'alpha');
53$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
55$fk_product =
GETPOST(
'fk_product',
'int');
56$fk_warehouse_source =
GETPOST(
'fk_warehouse_source',
'int');
57$fk_warehouse_destination =
GETPOST(
'fk_warehouse_destination',
'int');
58$lineid =
GETPOST(
'lineid',
'int');
59$label =
GETPOST(
'label',
'alpha');
60$batch =
GETPOST(
'batch',
'alpha');
61$code_inv =
GETPOST(
'inventorycode',
'alphanohtml');
66$diroutputmassaction = $conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
67$hookmanager->initHooks(array($object->element.
'card',
'globalcard'));
70$extrafields->fetch_name_optionals_label($object->table_element);
72$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
75$search_all = trim(
GETPOST(
"search_all",
'alpha'));
77foreach ($object->fields as $key => $val) {
78 if (
GETPOST(
'search_'.$key,
'alpha')) {
79 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
83if (empty($action) && empty($id) && empty($ref)) {
88include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
91$permissiontoread = $user->rights->stocktransfer->stocktransfer->read;
92$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write;
93$permissionnote = $user->rights->stocktransfer->stocktransfer->write;
94$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
95$permissiondellink = $user->rights->stocktransfer->stocktransfer->write;
96$upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
104if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd)) {
113$parameters = array();
114$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
119if (empty($reshook)) {
122 $backurlforlist =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1);
124 if (empty($backtopage) || ($cancel && empty($id))) {
125 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
126 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
127 $backtopage = $backurlforlist;
129 $backtopage =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
134 $triggermodname =
'STOCKTRANSFER_STOCKTRANSFER_MODIFY';
137 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
140 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
143 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
146 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
152 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
154 if ($action ==
'set_thirdparty' && $permissiontoadd) {
155 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
157 if ($action ==
'classin' && $permissiontoadd) {
158 $object->setProject(
GETPOST(
'projectid',
'int'));
161 if ($action ==
'addline' && $permissiontoadd) {
164 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
168 if ($fk_warehouse_source <= 0) {
170 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
174 if ($fk_warehouse_destination <= 0) {
176 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
181 $prod->fetch($fk_product);
182 if ($prod->hasbatch()) {
185 $langs->load(
"errors");
186 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref),
null,
'errors');
189 if (!empty($batch)) {
191 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
197 $records = $line->fetchAll(
'',
'', 0, 0, array(
'customsql'=>
' fk_stocktransfer = '.((
int) $id).
' AND fk_product = '.((
int) $fk_product).
' AND fk_warehouse_source = '.((
int) $fk_warehouse_source).
' AND fk_warehouse_destination = '.((
int) $fk_warehouse_destination).
' AND ('.(empty($batch) ?
'batch = "" or batch IS NULL' :
"batch = '".$db->escape($batch).
"'").
')'));
198 if (!empty($records[key($records)])) {
199 $line = $records[key($records)];
201 $line->fk_stocktransfer = $id;
203 $line->fk_warehouse_source = $fk_warehouse_source;
204 $line->fk_warehouse_destination = $fk_warehouse_destination;
205 $line->fk_product = $fk_product;
206 $line->batch = $batch;
208 $line->pmp = $prod->pmp;
210 $line->update($user);
212 $line->rang = (is_array($object->lines) || $object->lines instanceof Countable) ? count($object->lines) + 1 : 1;
213 $line->create($user);
215 $object->fetchLines();
217 } elseif ($action ===
'updateline' && $permissiontoadd) {
220 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
221 $action =
'editline';
224 if ($fk_warehouse_source <= 0) {
226 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
227 $action =
'editline';
230 if ($fk_warehouse_destination <= 0) {
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
233 $action =
'editline';
237 $prod->fetch($fk_product);
238 if ($prod->hasbatch()) {
241 $langs->load(
"errors");
242 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
243 $action =
'editline';
246 if (!empty($batch)) {
248 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
249 $action =
'editline';
255 $line->fetch($lineid);
257 $line->fk_warehouse_source = $fk_warehouse_source;
258 $line->fk_warehouse_destination = $fk_warehouse_destination;
259 $line->fk_product = $fk_product;
260 $line->batch = $batch;
261 $line->pmp = $prod->pmp;
262 $line->update($user);
266 if ($permissiontoadd) {
268 if ($action ==
'confirm_destock' && $confirm ==
'yes' && $object->status == $object::STATUS_VALIDATED) {
269 $lines = $object->getLinesArray();
270 if (!empty($lines)) {
272 foreach ($lines as $line) {
273 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
285 $object->setStatut($object::STATUS_TRANSFERED, $id);
286 $object->status = $object::STATUS_TRANSFERED;
287 $object->date_reelle_depart = date(
'Y-m-d');
288 $object->update($user);
294 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
295 $lines = $object->getLinesArray();
296 if (!empty($lines)) {
298 foreach ($lines as $line) {
299 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
311 $object->setStatut($object::STATUS_VALIDATED, $id);
312 $object->status = $object::STATUS_VALIDATED;
313 $object->date_reelle_depart =
null;
314 $object->update($user);
320 if ($action ==
'confirm_addstock' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
321 $lines = $object->getLinesArray();
322 if (!empty($lines)) {
324 foreach ($lines as $line) {
325 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
337 $object->setStatut($object::STATUS_CLOSED, $id);
338 $object->status = $object::STATUS_CLOSED;
339 $object->date_reelle_arrivee = date(
'Y-m-d');
340 $object->update($user);
346 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_CLOSED) {
347 $lines = $object->getLinesArray();
348 if (!empty($lines)) {
350 foreach ($lines as $line) {
351 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
363 $object->setStatut($object::STATUS_TRANSFERED, $id);
364 $object->status = $object::STATUS_TRANSFERED;
365 $object->date_reelle_arrivee =
null;
366 $object->update($user);
373 if ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $permissiontoadd) {
374 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
377 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
378 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
379 $trackid =
'stocktransfer'.$object->id;
380 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
390$form =
new Form($db);
394$title = $langs->trans(
"StockTransfer");
402print
'<script type="text/javascript" language="javascript">
403jQuery(document).ready(function() {';
406$date_prevue_depart = $object->date_prevue_depart;
407$date_prevue_depart_plus_delai = $date_prevue_depart;
408if ($object->lead_time_for_warning > 0) {
409 $date_prevue_depart_plus_delai = strtotime(date(
'Y-m-d', $date_prevue_depart) .
' + '.$object->lead_time_for_warning.
' day');
411if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date(
'Y-m-d'))) {
412 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
413 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
422if ($action ==
'create') {
423 if (empty($permissiontoadd)) {
429 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
430 print
'<input type="hidden" name="token" value="'.newToken().
'">';
431 print
'<input type="hidden" name="action" value="add">';
433 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
435 if ($backtopageforcancel) {
436 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
444 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
447 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
449 if (isModEnabled(
'incoterm')) {
451 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
452 print
'<td class="maxwidthonsmartphone">';
453 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
457 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
459 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
460 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
463 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
467 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
469 print
'</table>'.
"\n";
473 print $form->buttonsSaveCancel(
"Create");
481if (($id || $ref) && $action ==
'edit') {
482 print
load_fiche_titre($langs->trans(
"StockTransfer"),
'',
'object_' . $object->picto);
484 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
485 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
486 print
'<input type="hidden" name="action" value="update">';
487 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
489 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
491 if ($backtopageforcancel) {
492 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
497 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
500 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
503 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
509 print $form->buttonsSaveCancel();
515if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
516 $res = $object->fetch_optionals();
520 print
dol_get_fiche_head($head,
'card', $langs->trans(
"StockTransfer"), -1, $object->picto);
525 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
526 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0,
'action-delete');
529 if ($action ==
'deleteline') {
530 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
533 if ($action ==
'clone') {
535 $formquestion = array();
536 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
537 } elseif ($action ==
'destock') {
539 $formquestion = array(
'text' =>
'',
540 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock', $object->ref),
'size'=>40),
541 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
543 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
544 } elseif ($action ==
'destockcancel') {
546 $formquestion = array(
'text' =>
'',
547 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel', $object->ref),
'size'=>40),
548 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
550 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
551 } elseif ($action ==
'addstock') {
553 $formquestion = array(
'text' =>
'',
554 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock', $object->ref),
'size'=>40),
555 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
557 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
558 } elseif ($action ==
'addstockcancel') {
560 $formquestion = array(
'text' =>
'',
561 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel', $object->ref),
'size'=>40),
562 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
564 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
568 if ($action ==
'xxx') {
569 $formquestion = array();
580 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
584 if ($action ==
'valid' && $permissiontoadd) {
585 $nextref=$object->getNextNumRef();
586 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
590 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
591 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
592 if (empty($reshook)) {
593 $formconfirm .= $hookmanager->resPrint;
594 } elseif ($reshook > 0) {
595 $formconfirm = $hookmanager->resPrint;
604 $linkback =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
606 $morehtmlref =
'<div class="refidno">';
608 $morehtmlref .= empty($object->thirdparty) ?
'' : $object->thirdparty->getNomUrl(1,
'customer');
609 if (!
getDolGlobalInt(
'MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
610 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/commande/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherOrders").
'</a>)';
613 if (isModEnabled(
'project')) {
614 $langs->load(
"projects");
615 $morehtmlref .=
'<br>';
616 if ($permissiontoadd) {
617 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
618 if ($action !=
'classify') {
619 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
621 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
623 if (!empty($object->fk_project)) {
625 $proj->fetch($object->fk_project);
626 $morehtmlref .= $proj->getNomUrl(1);
628 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
633 $morehtmlref .=
'</div>';
636 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
639 print
'<div class="fichecenter">';
640 print
'<div class="fichehalfleft">';
641 print
'<div class="underbanner clearboth"></div>';
642 print
'<table class="border centpercent tableforfield">'.
"\n";
649 $object->fields[
'fk_soc'][
'visible']=0;
650 $object->fields[
'fk_project'][
'visible']=0;
651 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
654 if (isModEnabled(
'incoterm')) {
656 print
'<table width="100%" class="nobordernopadding"><tr><td>';
657 print $langs->trans(
'IncotermLabel');
658 print
'<td><td class="right">';
659 if ($permissiontoadd && $action !=
'editincoterm') {
660 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
664 print
'</td></tr></table>';
667 if ($action !=
'editincoterm') {
668 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
670 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
676 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
677 echo
'<td>'.price($object->getValorisationTotale(), 0,
'', 1, -1, -1, $conf->currency).
'</td>';
681 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
687 print
'<div class="clearboth"></div>';
696 if (!empty($object->table_element_line)) {
710 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
711 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
751 print
'<div class="div-table-responsive-no-min">';
752 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
753 <input type="hidden" name="token" value="' . newToken().
'">
754 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
755 <input type="hidden" name="mode" value="">
756 <input type="hidden" name="id" value="' . $object->id.
'">
759 print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
761 print
'<table id="tablelines" class="liste centpercent">';
766 $conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE=
true;
768 print
'<tr class="liste_titre">';
769 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
770 if (isModEnabled(
'productbatch')) {
771 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
773 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
774 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
775 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
776 if ($conf->global->PRODUCT_USE_UNITS) {
777 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
779 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
780 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
781 if (empty($object->status) && $permissiontoadd) {
789 $listofdata = $object->getLinesArray();
790 $productstatic =
new Product($db);
791 $warehousestatics =
new Entrepot($db);
792 $warehousestatict =
new Entrepot($db);
794 foreach ($listofdata as $key => $line) {
795 $productstatic->fetch($line->fk_product);
796 $warehousestatics->fetch($line->fk_warehouse_source);
797 $warehousestatict->fetch($line->fk_warehouse_destination);
800 $domData =
' data-element="'.$line->element.
'"';
801 $domData .=
' data-id="'.$line->id.
'"';
802 $domData .=
' data-qty="'.$line->qty.
'"';
805 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
806 print
'<td class="titlefield">';
807 if ($action ===
'editline' && $line->id == $lineid) {
808 $form->select_produits($line->fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
810 print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
813 if (isModEnabled(
'productbatch')) {
815 if ($action ===
'editline' && $line->id == $lineid) {
816 print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
819 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
820 print $productlot->getNomUrl(1);
821 } elseif (!empty($line->batch)) {
822 print $line->batch.
' '.
img_warning($langs->trans(
'BatchNotFound'));
830 if ($action ===
'editline' && $line->id == $lineid) {
831 print $formproduct->selectWarehouses($line->fk_warehouse_source,
'fk_warehouse_source',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
833 print $warehousestatics->getNomUrl(1);
837 if ($action ===
'editline' && $line->id == $lineid) {
838 print $formproduct->selectWarehouses($line->fk_warehouse_destination,
'fk_warehouse_destination',
'warehouseopen,warehouseinternal', 1, 0, 0,
'', 0, 0, array(),
'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
840 print $warehousestatict->getNomUrl(1);
843 if ($action ===
'editline' && $line->id == $lineid) {
844 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.
'"></td>';
846 print
'<td class="center">'.$line->qty.
'</td>';
849 if ($conf->global->PRODUCT_USE_UNITS) {
850 print
'<td class="linecoluseunit nowrap left">';
851 $label = $productstatic->getLabelOfUnit(
'short');
853 print $langs->trans($label);
858 print
'<td class="center">';
859 print
price($line->pmp, 0,
'', 1, -1, -1, $conf->currency);
861 print
'<td class="center">';
862 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1, $conf->currency);
864 if (empty($object->status) && $permissiontoadd) {
865 if ($action ===
'editline' && $line->id == $lineid) {
867 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
868 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
870 print
'<td class="right">';
871 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=editline&lineid=' . $line->id .
'#line_' . $line->id .
'">';
874 print
'<td class="right">';
875 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id .
'&action=deleteline&lineid=' . $line->id .
'">' .
img_delete($langs->trans(
"Remove")) .
'</a>';
879 $num = count($object->lines);
881 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
882 print
'<td class="linecolmove tdlineupdown center">';
885 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
886 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
889 if ($i < $num - 1) { ?>
890 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&rowid='.$line->id; ?>">
891 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
896 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
904 if (empty($object->status) && $action !==
'editline' && $permissiontoadd) {
905 print
'<tr class="oddeven">';
907 print
'<td class="titlefield">';
915 $limit = $conf->global->PRODUIT_LIMIT_SIZE;
918 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
921 if (isModEnabled(
'productbatch')) {
923 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
927 $formproduct->loadWarehouses();
930 $TExcludedWarehouseSource=array();
931 if (!empty($object->fk_warehouse_source)) {
933 $source_ent->fetch($object->fk_warehouse_source);
934 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
935 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) {
936 $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
942 $TExcludedWarehouseDestination=array();
943 if (!empty($object->fk_warehouse_destination)) {
945 $dest_ent->fetch($object->fk_warehouse_destination);
946 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
947 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) {
948 $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
954 $formproduct->cache_warehouses=array();
957 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);
961 $formproduct->cache_warehouses=array();
964 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);
968 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.$qty.
'"' :
'').
'></td>';
971 if ($conf->global->PRODUCT_USE_UNITS) {
978 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
990 if ($action !=
'presend' && $action !=
'editline') {
991 print
'<div class="tabsAction">'.
"\n";
992 $parameters = array();
993 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
998 if (empty($reshook)) {
1000 if (empty($user->socid)) {
1001 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
1005 if ($object->status == $object::STATUS_VALIDATED) {
1006 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
1010 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
1013 if ($object->status == $object::STATUS_DRAFT) {
1014 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
1015 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
1017 $langs->load(
"errors");
1018 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
1020 } elseif ($object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
1021 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destock&token='.newToken().
'">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
1022 } elseif ($object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
1023 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destockcancel&token='.newToken().
'">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
1024 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstock&token='.newToken().
'">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
1025 } elseif ($object->status == $object::STATUS_CLOSED && $permissiontoadd) {
1026 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstockcancel&token='.newToken().
'">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
1030 if ($permissiontoadd) {
1031 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.(!empty($object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.newToken(),
'', $permissiontoadd);
1053 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken();
1054 $buttonId =
'action-delete-no-ajax';
1055 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
1057 $buttonId =
'action-delete';
1060 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
1062 print
'</div>'.
"\n";
1067 if (
GETPOST(
'modelselected')) {
1068 $action =
'presend';
1071 if ($action !=
'presend') {
1072 print
'<div class="fichecenter"><div class="fichehalfleft">';
1073 print
'<a name="builddoc"></a>';
1075 $includedocgeneration = 1;
1078 if ($includedocgeneration) {
1080 $relativepath = $objref .
'/' . $objref .
'.pdf';
1081 $filedir = $conf->stocktransfer->dir_output.
'/'.$object->element.
'/'.$objref;
1082 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" . $object->id;
1083 $genallowed = $permissiontoread;
1084 $delallowed = $permissiontoadd;
1085 print $formfile->showdocuments(
'stocktransfer:StockTransfer', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1089 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'stocktransfer'));
1090 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1093 print
'</div><div class="fichehalfright">';
1097 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
1100 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1102 $somethingshown =
$formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'', $morehtmlright);
1104 print
'</div></div>';
1108 if (
GETPOST(
'modelselected')) {
1109 $action =
'presend';
1113 $modelmail =
'stocktransfer';
1114 $defaulttopic =
'InformationMessage';
1115 $diroutput = $conf->stocktransfer->dir_output;
1116 $trackid =
'stocktransfer'.$object->id;
1118 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage products or services.
Class with list of lots and properties.
Class to manage projects.
Class for StockTransferLine.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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)
Set event message in dol_events session object.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.