26 require
'../../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransfer.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/class/stocktransferline.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/modules/stocktransfer/modules_stocktransfer.php';
39 $langs->loadLangs(array(
"stocks",
"other",
"productbatch",
"companies"));
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
47 $cancel =
GETPOST(
'cancel',
'aZ09');
48 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'stocktransfercard';
49 $backtopage =
GETPOST(
'backtopage',
'alpha');
50 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
52 $fk_product =
GETPOST(
'fk_product',
'int');
53 $fk_warehouse_source =
GETPOST(
'fk_warehouse_source',
'int');
54 $fk_warehouse_destination =
GETPOST(
'fk_warehouse_destination',
'int');
55 $lineid =
GETPOST(
'lineid',
'int');
56 $label =
GETPOST(
'label',
'alpha');
57 $batch =
GETPOST(
'batch',
'alpha');
58 $code_inv =
GETPOST(
'inventorycode',
'alphanohtml');
63 $diroutputmassaction = $conf->stocktransfer->dir_output.
'/temp/massgeneration/'.$user->id;
64 $hookmanager->initHooks(array(
'stocktransfercard',
'globalcard'));
67 $extrafields->fetch_name_optionals_label($object->table_element);
69 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
72 $search_all = trim(
GETPOST(
"search_all",
'alpha'));
74 foreach ($object->fields as $key => $val) {
75 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
78 if (empty($action) && empty($id) && empty($ref)) $action =
'view';
81 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
84 $permissiontoread = $user->rights->stocktransfer->stocktransfer->read;
85 $permissiontoadd = $user->rights->stocktransfer->stocktransfer->write;
86 $permissionnote = $user->rights->stocktransfer->stocktransfer->write;
87 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
88 $permissiondellink = $user->rights->stocktransfer->stocktransfer->write;
89 $upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
97 if (!$permissiontoread || ($action ===
'create' && !$permissiontoadd))
accessforbidden();
108 $parameters = array();
109 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
112 if (empty($reshook)) {
115 $backurlforlist =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_list.php', 1);
117 if (empty($backtopage) || ($cancel && empty($id))) {
118 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
119 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) $backtopage = $backurlforlist;
120 else $backtopage =
dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
123 $triggermodname =
'STOCKTRANSFER_STOCKTRANSFER_MODIFY';
126 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
129 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
132 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
135 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
138 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
141 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
143 if ($action ==
'set_thirdparty' && $permissiontoadd) {
144 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user,
'STOCKTRANSFER_MODIFY');
146 if ($action ==
'classin' && $permissiontoadd) {
147 $object->setProject(
GETPOST(
'projectid',
'int'));
150 if ($action ==
'addline' && $permissiontoadd) {
153 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
157 if ($fk_warehouse_source <= 0) {
159 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
163 if ($fk_warehouse_destination <= 0) {
165 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
170 $prod->fetch($fk_product);
171 if ($prod->hasbatch()) {
174 $langs->load(
"errors");
175 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref),
null,
'errors');
178 if (!empty($batch)) {
180 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
186 $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).
"'" ).
')'));
187 if (!empty($records[key($records)])) $line = $records[key($records)];
188 $line->fk_stocktransfer = $id;
190 $line->fk_warehouse_source = $fk_warehouse_source;
191 $line->fk_warehouse_destination = $fk_warehouse_destination;
192 $line->fk_product = $fk_product;
193 $line->batch = $batch;
195 $line->pmp = $prod->pmp;
196 if ($line->id > 0) $line->update($user);
198 $line->rang = count($object->lines) + 1;
199 $line->create($user);
201 $object->fetchLines();
203 } elseif ($action ===
'updateline' && $permissiontoadd) {
206 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
207 $action =
'editline';
210 if ($fk_warehouse_source <= 0) {
212 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseSource")),
null,
'errors');
213 $action =
'editline';
216 if ($fk_warehouse_destination <= 0) {
218 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WarehouseTarget")),
null,
'errors');
219 $action =
'editline';
223 $prod->fetch($fk_product);
224 if ($prod->hasbatch()) {
227 $langs->load(
"errors");
228 setEventMessages($langs->transnoentities(
"ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()),
null,
'errors');
229 $action =
'editline';
232 if (!empty($batch)) {
234 setEventMessages($langs->transnoentities(
'StockTransferNoBatchForProduct', $prod->getNomUrl()),
'',
'errors');
235 $action =
'editline';
241 $line->fetch($lineid);
243 $line->fk_warehouse_source = $fk_warehouse_source;
244 $line->fk_warehouse_destination = $fk_warehouse_destination;
245 $line->fk_product = $fk_product;
246 $line->batch = $batch;
247 $line->pmp = $prod->pmp;
248 $line->update($user);
252 if ($permissiontoadd) {
254 if ($action ==
'confirm_destock' && $confirm ==
'yes' && $object->status == $object::STATUS_VALIDATED) {
255 $lines = $object->getLinesArray();
256 if (!empty($lines)) {
258 foreach ($lines as $line) {
259 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
260 if ($res <= 0) $error++;
262 if (empty($error)) $db->commit();
263 else $db->rollback();
266 $object->setStatut($object::STATUS_TRANSFERED, $id);
267 $object->status = $object::STATUS_TRANSFERED;
268 $object->date_reelle_depart = date(
'Y-m-d');
269 $object->update($user);
275 if ($action ==
'confirm_destockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
276 $lines = $object->getLinesArray();
277 if (!empty($lines)) {
279 foreach ($lines as $line) {
280 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
281 if ($res <= 0) $error++;
283 if (empty($error)) $db->commit();
284 else $db->rollback();
287 $object->setStatut($object::STATUS_VALIDATED, $id);
288 $object->status = $object::STATUS_VALIDATED;
289 $object->date_reelle_depart =
null;
290 $object->update($user);
296 if ($action ==
'confirm_addstock' && $confirm ==
'yes' && $object->status == $object::STATUS_TRANSFERED) {
297 $lines = $object->getLinesArray();
298 if (!empty($lines)) {
300 foreach ($lines as $line) {
301 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
302 if ($res <= 0) $error++;
304 if (empty($error)) $db->commit();
305 else $db->rollback();
308 $object->setStatut($object::STATUS_CLOSED, $id);
309 $object->status = $object::STATUS_CLOSED;
310 $object->date_reelle_arrivee = date(
'Y-m-d');
311 $object->update($user);
317 if ($action ==
'confirm_addstockcancel' && $confirm ==
'yes' && $object->status == $object::STATUS_CLOSED) {
318 $lines = $object->getLinesArray();
319 if (!empty($lines)) {
321 foreach ($lines as $line) {
322 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
323 if ($res <= 0) $error++;
325 if (empty($error)) $db->commit();
326 else $db->rollback();
329 $object->setStatut($object::STATUS_TRANSFERED, $id);
330 $object->status = $object::STATUS_TRANSFERED;
331 $object->date_reelle_arrivee =
null;
332 $object->update($user);
339 if ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $permissiontoadd) {
340 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
343 $triggersendname =
'STOCKTRANSFER_SENTBYMAIL';
344 $autocopy =
'MAIN_MAIL_AUTOCOPY_STOCKTRANSFER_TO';
345 $trackid =
'stocktransfer'.$object->id;
346 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
358 $title = $langs->trans(
"StockTransfer");
365 print
'<script type="text/javascript" language="javascript">
366 jQuery(document).ready(function() {';
369 $date_prevue_depart = $object->date_prevue_depart;
370 $date_prevue_depart_plus_delai = $date_prevue_depart;
371 if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date(
'Y-m-d', $date_prevue_depart) .
' + '.$object->lead_time_for_warning.
' day');
372 if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date(
'Y-m-d'))) {
373 print
"$('.valuefield.fieldname_date_prevue_depart').append('";
374 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
383 if ($action ==
'create') {
384 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"StockTransfer")),
'',
'object_'.$object->picto);
386 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
387 print
'<input type="hidden" name="token" value="'.newToken().
'">';
388 print
'<input type="hidden" name="action" value="add">';
389 if ($backtopage) print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
390 if ($backtopageforcancel) print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
397 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
400 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
404 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
405 print
'<td class="maxwidthonsmartphone">';
406 print
$form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''),
'',
'fk_incoterms');
410 print
'<tr><td>'.$langs->trans(
'DefaultModel').
'</td>';
412 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
413 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
415 $preselected = $conf->global->STOCKTRANSFER_ADDON_PDF;
416 print
$form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
422 print
'</table>'.
"\n";
426 print
'<div class="center">';
427 print
'<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'">';
429 print
'<input type="'.($backtopage ?
"submit" :
"button").
'" class="button" name="cancel" value="'.
dol_escape_htmltag($langs->trans(
"Cancel")).
'"'.($backtopage ?
'' :
' onclick="javascript:history.go(-1)"').
'>';
438 if (($id || $ref) && $action ==
'edit') {
440 print
load_fiche_titre($langs->trans(
"StockTransfer"),
'',
'object_' . $object->picto);
442 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
443 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
444 print
'<input type="hidden" name="action" value="update">';
445 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
446 if ($backtopage) print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
447 if ($backtopageforcancel) print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
451 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
454 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
457 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_edit.tpl.php';
463 print
'<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans(
"Save") .
'">';
464 print
' <input type="submit" class="button" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
472 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
473 $res = $object->fetch_optionals();
476 print
dol_get_fiche_head($head,
'card', $langs->trans(
"StockTransfer"), -1, $object->picto);
481 if ($action ==
'delete') {
482 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
485 if ($action ==
'deleteline') {
486 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
489 if ($action ==
'clone') {
491 $formquestion = array();
492 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
493 } elseif ($action ==
'destock') {
495 $formquestion = array(
'text' =>
'',
496 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestock', $object->ref),
'size'=>40),
497 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
499 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProduct'),
'',
'confirm_destock', $formquestion,
'yes', 1);
500 } elseif ($action ==
'destockcancel') {
502 $formquestion = array(
'text' =>
'',
503 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
'ConfirmDestockCancel', $object->ref),
'size'=>40),
504 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
506 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DestockAllProductCancel'),
'',
'confirm_destockcancel', $formquestion,
'yes', 1);
507 } elseif ($action ==
'addstock') {
509 $formquestion = array(
'text' =>
'',
510 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStock', $object->ref),
'size'=>40),
511 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
513 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProduct'),
'',
'confirm_addstock', $formquestion,
'yes', 1);
514 } elseif ($action ==
'addstockcancel') {
516 $formquestion = array(
'text' =>
'',
517 array(
'type' =>
'text',
'name' =>
'label',
'label' => $langs->trans(
"Label").
' :',
'value' => $langs->trans(
'ConfirmAddStockCancel', $object->ref),
'size'=>40),
518 array(
'type' =>
'text',
'name' =>
'inventorycode',
'label' => $langs->trans(
"InventoryCode"),
'value' =>
dol_print_date(
dol_now(),
'%y%m%d%H%M%S'),
'size'=>25)
520 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'AddStockAllProductCancel'),
'',
'confirm_addstockcancel', $formquestion,
'yes', 1);
524 if ($action ==
'xxx') {
525 $formquestion = array();
536 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'XXX'), $text,
'confirm_xxx', $formquestion, 0, 1, 220);
540 if ($action ==
'valid' && $permissiontoadd) {
541 $nextref=$object->getNextNumRef();
542 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'Validate'), $langs->transnoentities(
'ConfirmValidateStockTransfer', $nextref),
'confirm_validate', $formquestion, 0, 2);
546 $parameters = array(
'formConfirm' =>
$formconfirm,
'lineid' => $lineid);
547 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
548 if (empty($reshook))
$formconfirm .= $hookmanager->resPrint;
549 elseif ($reshook > 0)
$formconfirm = $hookmanager->resPrint;
557 $linkback = '<a href="'.
dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
559 $morehtmlref = '<div class="refidno">';
563 $morehtmlref .= $langs->trans(
'ThirdParty') .
' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) :
'').
'<br>';
566 if (!empty($conf->project->enabled)) {
567 $langs->load(
"projects");
568 $morehtmlref.=$langs->trans(
'Project') .
' ';
569 if ($permissiontoadd) {
572 if ($action ==
'classify') {
574 $morehtmlref.=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
575 $morehtmlref.=
'<input type="hidden" name="action" value="classin">';
576 $morehtmlref.=
'<input type="hidden" name="token" value="'.newToken().
'">';
577 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
578 $morehtmlref.=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
579 $morehtmlref.=
'</form>';
581 $morehtmlref.=
$form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' . $object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
584 if (!empty($object->fk_project)) {
586 $proj->fetch($object->fk_project);
587 $morehtmlref .=
': '.$proj->getNomUrl();
593 $morehtmlref .=
'</div>';
596 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
599 print
'<div class="fichecenter">';
600 print
'<div class="fichehalfleft">';
601 print
'<div class="underbanner clearboth"></div>';
602 print
'<table class="border centpercent tableforfield">'.
"\n";
609 $object->fields[
'fk_soc'][
'visible']=0;
610 $object->fields[
'fk_project'][
'visible']=0;
611 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
616 print
'<table width="100%" class="nobordernopadding"><tr><td>';
617 print $langs->trans(
'IncotermLabel');
618 print
'<td><td class="right">';
619 if ($permissiontoadd && $action !=
'editincoterm') print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
621 print
'</td></tr></table>';
624 if ($action !=
'editincoterm') {
625 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
627 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
633 echo
'<td>'.$langs->trans(
'EnhancedValue').
' '.strtolower($langs->trans(
'TotalWoman'));
634 echo
'<td>'.price($object->getValorisationTotale(), 0,
'', 1, -1, -1, $conf->currency).
'</td>';
637 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
643 print
'<div class="clearboth"></div>';
652 if (!empty($object->table_element_line)) {
663 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
664 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
702 print
'<div class="div-table-responsive-no-min">';
703 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
704 <input type="hidden" name="token" value="' .
newToken().
'">
705 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
706 <input type="hidden" name="mode" value="">
707 <input type="hidden" name="id" value="' . $object->id.
'">
709 if ($lineid > 0) print
'<input type="hidden" name="lineid" value="'.$lineid.
'" />';
710 print
'<table id="tablelines" class="liste centpercent">';
715 $conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE=
true;
717 print
'<tr class="liste_titre">';
718 print
getTitleFieldOfList($langs->trans(
'ProductRef'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
720 print
getTitleFieldOfList($langs->trans(
'Batch'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
722 print
getTitleFieldOfList($langs->trans(
'WarehouseSource'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
723 print
getTitleFieldOfList($langs->trans(
'WarehouseTarget'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
724 print
getTitleFieldOfList($langs->trans(
'Qty'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
725 if ($conf->global->PRODUCT_USE_UNITS) {
726 print
getTitleFieldOfList($langs->trans(
'Unit'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'tagtd maxwidthonsmartphone ');
728 print
getTitleFieldOfList($langs->trans(
'AverageUnitPricePMPShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
729 print
getTitleFieldOfList($langs->trans(
'EstimatedStockValueShort'), 0, $_SERVER[
"PHP_SELF"],
'', $param,
'',
'', $sortfield, $sortorder,
'center tagtd maxwidthonsmartphone ');
730 if (empty($object->status) && $permissiontoadd) {
738 $listofdata = $object->getLinesArray();
739 $productstatic =
new Product($db);
740 $warehousestatics =
new Entrepot($db);
741 $warehousestatict =
new Entrepot($db);
743 foreach ($listofdata as $key => $line) {
744 $productstatic->fetch($line->fk_product);
745 $warehousestatics->fetch($line->fk_warehouse_source);
746 $warehousestatict->fetch($line->fk_warehouse_destination);
749 $domData =
' data-element="'.$line->element.
'"';
750 $domData .=
' data-id="'.$line->id.
'"';
751 $domData .=
' data-qty="'.$line->qty.
'"';
754 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
'>';
755 print
'<td class="titlefield">';
756 if ($action ===
'editline' && $line->id == $lineid)
$form->select_produits($line->fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
757 else print $productstatic->getNomUrl(1).
' - '.$productstatic->label;
761 if ($action ===
'editline' && $line->id == $lineid) print
'<input type="text" value="'.$line->batch.
'" name="batch" class="flat maxwidth50"/>';
764 if ($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
765 print $productlot->getNomUrl(1);
766 } elseif (!empty($line->batch)) print $line->batch.' '.
img_warning($langs->trans('BatchNotFound'));
773 if ($action === 'editline' && $line->
id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
774 else print $warehousestatics->getNomUrl(1);
777 if ($action === 'editline' && $line->
id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
778 else print $warehousestatict->getNomUrl(1);
780 if ($action === 'editline' && $line->
id == $lineid) print '<td class="center"><input
type="text" class="flat maxwidth50"
name="qty" value="'.$line->qty.'"></td>';
781 else print '<td class="center">'.$line->qty.'</td>';
783 if ($conf->global->PRODUCT_USE_UNITS) {
784 print
'<td class="linecoluseunit nowrap left">';
785 $label = $productstatic->getLabelOfUnit(
'short');
787 print $langs->trans($label);
792 print
'<td class="center">';
793 print
price($line->pmp, 0,
'', 1, -1, -1, $conf->currency);
795 print
'<td class="center">';
796 print
price($line->pmp * $line->qty, 0,
'', 1, -1, -1, $conf->currency);
798 if (empty($object->status) && $permissiontoadd) {
799 if ($action ===
'editline' && $line->id == $lineid) {
801 print
'<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans(
"Save").
'"><br>';
802 print
'<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans(
"Cancel").
'"></td>';
804 print
'<td class="right">';
805 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=editline&lineid=' . $line->id .
'#line_' . $line->id .
'">';
808 print
'<td class="right">';
809 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id .
'&action=deleteline&lineid=' . $line->id .
'">' .
img_delete($langs->trans(
"Remove")) .
'</a>';
813 $num = count($object->lines);
815 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
816 print
'<td class="linecolmove tdlineupdown center">';
819 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=up&rowid='.$line->id; ?>">
820 <?php print
img_up(
'default', 0,
'imgupforline'); ?>
823 if ($i < $num - 1) { ?>
824 <a
class=
"lineupdown" href=
"<?php print $_SERVER["PHP_SELF
"].'?id='.$id.'&action=down&rowid='.$line->id; ?>">
825 <?php print
img_down(
'default', 0,
'imgdownforline'); ?>
830 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
838 if (empty($object->status) && $action !==
'editline' && $permissiontoadd) {
839 print
'<tr class="oddeven">';
841 print
'<td class="titlefield">';
843 if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype =
'';
844 if ($conf->global->PRODUIT_LIMIT_SIZE <= 0) {
847 $limit = $conf->global->PRODUIT_LIMIT_SIZE;
850 $form->select_produits($fk_product,
'fk_product', $filtertype, $limit, 0, -1, 2,
'', 0, array(), 0, 0, 0,
'minwidth200imp maxwidth300', 1);
855 print
'<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ?
'value="'.$batch.
'"' :
'').
'>';
859 $formproduct->loadWarehouses();
862 $TExcludedWarehouseSource=array();
863 if (!empty($object->fk_warehouse_source)) {
865 $source_ent->fetch($object->fk_warehouse_source);
866 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
867 if (strpos($TDataCacheWarehouse[
'full_label'], $source_ent->label) ===
false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse[
'id'];
872 $TExcludedWarehouseDestination=array();
873 if (!empty($object->fk_warehouse_destination)) {
875 $dest_ent->fetch($object->fk_warehouse_destination);
876 foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
877 if (strpos($TDataCacheWarehouse[
'full_label'], $dest_ent->label) ===
false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse[
'id'];
882 $formproduct->cache_warehouses=array();
885 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);
889 $formproduct->cache_warehouses=array();
892 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);
896 print
'<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ?
'value="'.$qty.
'"' :
'').
'></td>';
899 if ($conf->global->PRODUCT_USE_UNITS) {
906 print
'<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' .
dol_escape_htmltag($langs->trans(
'Add')) .
'"></td>';
918 if ($action !=
'presend' && $action !=
'editline') {
919 print
'<div class="tabsAction">'.
"\n";
920 $parameters = array();
921 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
922 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
924 if (empty($reshook)) {
926 if (empty($user->socid)) {
927 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>'.
"\n";
931 if ($object->status == $object::STATUS_VALIDATED) {
932 if ($permissiontoadd) {
933 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes">'.$langs->trans(
"SetToDraft").
'</a>';
938 if ($permissiontoadd) {
939 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit">'.$langs->trans(
"Modify").
'</a>'.
"\n";
947 if ($object->status == $object::STATUS_DRAFT) {
948 if ($permissiontoadd) {
949 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
950 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=valid">'.$langs->trans(
"Validate").
'</a>';
952 $langs->load(
"errors");
953 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Validate").
'</a>';
956 } elseif ($object->status == $object::STATUS_VALIDATED && $permissiontoadd) {
957 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destock">'.$langs->trans(
"StockTransferDecrementation").
'</a>';
958 } elseif ($object->status == $object::STATUS_TRANSFERED && $permissiontoadd) {
959 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=destockcancel">'.$langs->trans(
"StockTransferDecrementationCancel").
'</a>';
960 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstock">'.$langs->trans(
"StockTransferIncrementation").
'</a>';
961 } elseif ($object->status == $object::STATUS_CLOSED && $permissiontoadd) {
962 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=addstockcancel">'.$langs->trans(
"StockTransferIncrementationCancel").
'</a>';
966 if ($permissiontoadd) {
967 print
dolGetButtonAction($langs->trans(
"ToClone"),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object=stocktransfer',
'clone', $permissiontoadd);
996 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
1003 if (
GETPOST(
'modelselected')) {
1004 $action =
'presend';
1007 if ($action !=
'presend') {
1008 print
'<div class="fichecenter"><div class="fichehalfleft">';
1009 print
'<a name="builddoc"></a>';
1011 $includedocgeneration = 1;
1014 if ($includedocgeneration) {
1016 $relativepath = $objref .
'/' . $objref .
'.pdf';
1017 $filedir = $conf->stocktransfer->dir_output.
'/'.$object->element.
'/'.$objref;
1018 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" . $object->id;
1019 $genallowed = $user->rights->stocktransfer->stocktransfer->read;
1020 $delallowed = $user->rights->stocktransfer->stocktransfer->write;
1021 print $formfile->showdocuments(
'stocktransfer:StockTransfer', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1025 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'stocktransfer'));
1026 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
1029 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1033 $morehtmlright =
'<a href="'.dol_buildpath(
'/product/stock/stocktransfer/stocktransfer_agenda.php', 1).
'?id='.$object->id.
'">';
1034 $morehtmlright .= $langs->trans(
"SeeAll");
1035 $morehtmlright .=
'</a>';
1038 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1040 $somethingshown =
$formactions->showactions($object,
'stocktransfer', 0, 1,
'', $MAXEVENT,
'', $morehtmlright);
1042 print
'</div></div></div>';
1046 if (
GETPOST(
'modelselected')) $action =
'presend';
1049 $modelmail =
'stocktransfer';
1050 $defaulttopic =
'InformationMessage';
1051 $diroutput = $conf->stocktransfer->dir_output;
1052 $trackid =
'stocktransfer'.$object->id;
1054 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessage($mesgs, $style='mesgs')
Set event message 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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$formconfirm
if ($action == 'delbookkeepingyear') {
if(!GETPOST('transkey', 'alphanohtml') &&!GETPOST('transphrase', 'alphanohtml')) else
View.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
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.