dolibarr 19.0.4
stocktransfer_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) ---Put here your own copyright and developer email---
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
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';
37
38// Load translation files required by the page
39$langs->loadLangs(array("stocks", "other", "productbatch", "companies"));
40if (isModEnabled('incoterm')) {
41 $langs->load('incoterm');
42}
43
44
45// Get parameters
46$id = GETPOST('id', 'int');
47$ref = GETPOST('ref', 'alpha');
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')); // To manage different context of search
52$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used
53$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used
54$qty = GETPOST('qty', 'int');
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');
62
63// Initialize technical objects
64$object = new StockTransfer($db);
65$extrafields = new ExtraFields($db);
66$diroutputmassaction = $conf->stocktransfer->dir_output.'/temp/massgeneration/'.$user->id;
67$hookmanager->initHooks(array($object->element.'card', 'globalcard')); // Note that conf->hooks_modules contains array
68
69// Fetch optionals attributes and labels
70$extrafields->fetch_name_optionals_label($object->table_element);
71
72$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
73
74// Initialize array of search criterias
75$search_all = trim(GETPOST("search_all", 'alpha'));
76$search = array();
77foreach ($object->fields as $key => $val) {
78 if (GETPOST('search_'.$key, 'alpha')) {
79 $search[$key] = GETPOST('search_'.$key, 'alpha');
80 }
81}
82
83if (empty($action) && empty($id) && empty($ref)) {
84 $action = 'view';
85}
86
87// Load object
88include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
89
90
91$permissiontoread = $user->rights->stocktransfer->stocktransfer->read;
92$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
93$permissionnote = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_setnotes.inc.php
94$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
95$permissiondellink = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_dellink.inc.php
96$upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
97
98// Security check - Protection if external user
99//if ($user->socid > 0) accessforbidden();
100//if ($user->socid > 0) $socid = $user->socid;
101//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
102//$result = restrictedArea($user, 'stocktransfer', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
103
104if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
106}
107
108
109/*
110 * Actions
111 */
112
113$parameters = array();
114$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
115if ($reshook < 0) {
116 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
117}
118
119if (empty($reshook)) {
120 $error = 0;
121
122 $backurlforlist = dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1);
123
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;
128 } else {
129 $backtopage = dol_buildpath('/product/stock/stocktransfer/stocktransfer_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
130 }
131 }
132 }
133
134 $triggermodname = 'STOCKTRANSFER_STOCKTRANSFER_MODIFY'; // Name of trigger action code to execute when we modify record
135
136 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
137 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
138
139 // On remet cette lecture de permission ici car nécessaire d'avoir le nouveau statut de l'objet après toute action exécutée dessus (après incrémentation par exemple, le bouton supprimer doit disparaître)
140 $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
141
142 // Actions when linking object each other
143 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
144
145 // Actions when printing a doc from card
146 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
147
148 // Action to move up and down lines of object
149 include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
150
151 // Action to build doc
152 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
153
154 if ($action == 'set_thirdparty' && $permissiontoadd) {
155 $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
156 }
157 if ($action == 'classin' && $permissiontoadd) {
158 $object->setProject(GETPOST('projectid', 'int'));
159 }
160
161 if ($action == 'addline' && $permissiontoadd) {
162 if ($qty <= 0) {
163 $error++;
164 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
165 $action = 'view';
166 }
167
168 if ($fk_warehouse_source <= 0) {
169 $error++;
170 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
171 $action = 'view';
172 }
173
174 if ($fk_warehouse_destination <= 0) {
175 $error++;
176 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
177 $action = 'view';
178 }
179
180 $prod = new Product($db);
181 $prod->fetch($fk_product);
182 if ($prod->hasbatch()) {
183 if (empty($batch)) {
184 $error++;
185 $langs->load("errors");
186 setEventMessages($langs->transnoentities("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
187 }
188 } else {
189 if (!empty($batch)) {
190 $error++;
191 setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
192 }
193 }
194
195 if (empty($error)) {
196 $line = new StockTransferLine($db);
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)];
200 }
201 $line->fk_stocktransfer = $id;
202 $line->qty += $qty;
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;
207
208 $line->pmp = $prod->pmp;
209 if ($line->id > 0) {
210 $line->update($user);
211 } else {
212 $line->rang = (is_array($object->lines) || $object->lines instanceof Countable) ? count($object->lines) + 1 : 1;
213 $line->create($user);
214 }
215 $object->fetchLines();
216 }
217 } elseif ($action === 'updateline' && $permissiontoadd) {
218 if ($qty <= 0) {
219 $error++;
220 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
221 $action = 'editline';
222 }
223
224 if ($fk_warehouse_source <= 0) {
225 $error++;
226 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
227 $action = 'editline';
228 }
229
230 if ($fk_warehouse_destination <= 0) {
231 $error++;
232 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
233 $action = 'editline';
234 }
235
236 $prod = new Product($db);
237 $prod->fetch($fk_product);
238 if ($prod->hasbatch()) {
239 if (empty($batch)) {
240 $error++;
241 $langs->load("errors");
242 setEventMessages($langs->transnoentities("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()), null, 'errors');
243 $action = 'editline';
244 }
245 } else {
246 if (!empty($batch)) {
247 $error++;
248 setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
249 $action = 'editline';
250 }
251 }
252
253 if (empty($error)) {
254 $line = new StockTransferLine($db);
255 $line->fetch($lineid);
256 $line->qty = $qty;
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);
263 }
264 }
265
266 if ($permissiontoadd) {
267 // Décrémentation
268 if ($action == 'confirm_destock' && $confirm == 'yes' && $object->status == $object::STATUS_VALIDATED) {
269 $lines = $object->getLinesArray();
270 if (!empty($lines)) {
271 $db->begin();
272 foreach ($lines as $line) {
273 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source);
274 if ($res <= 0) {
275 $error++;
276 }
277 }
278 if (empty($error)) {
279 $db->commit();
280 } else {
281 $db->rollback();
282 }
283 }
284 if (empty($error)) {
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);
289 setEventMessage('StockStransferDecremented');
290 }
291 }
292
293 // Annulation décrémentation
294 if ($action == 'confirm_destockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
295 $lines = $object->getLinesArray();
296 if (!empty($lines)) {
297 $db->begin();
298 foreach ($lines as $line) {
299 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_source, 0);
300 if ($res <= 0) {
301 $error++;
302 }
303 }
304 if (empty($error)) {
305 $db->commit();
306 } else {
307 $db->rollback();
308 }
309 }
310 if (empty($error)) {
311 $object->setStatut($object::STATUS_VALIDATED, $id);
312 $object->status = $object::STATUS_VALIDATED;
313 $object->date_reelle_depart = null;
314 $object->update($user);
315 setEventMessage('StockStransferDecrementedCancel', 'warnings');
316 }
317 }
318
319 // Incrémentation
320 if ($action == 'confirm_addstock' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
321 $lines = $object->getLinesArray();
322 if (!empty($lines)) {
323 $db->begin();
324 foreach ($lines as $line) {
325 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination, 0);
326 if ($res <= 0) {
327 $error++;
328 }
329 }
330 if (empty($error)) {
331 $db->commit();
332 } else {
333 $db->rollback();
334 }
335 }
336 if (empty($error)) {
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);
341 setEventMessage('StockStransferIncrementedShort');
342 }
343 }
344
345 // Annulation incrémentation
346 if ($action == 'confirm_addstockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_CLOSED) {
347 $lines = $object->getLinesArray();
348 if (!empty($lines)) {
349 $db->begin();
350 foreach ($lines as $line) {
351 $res = $line->doStockMovement($label, $code_inv, $line->fk_warehouse_destination);
352 if ($res <= 0) {
353 $error++;
354 }
355 }
356 if (empty($error)) {
357 $db->commit();
358 } else {
359 $db->rollback();
360 }
361 }
362 if (empty($error)) {
363 $object->setStatut($object::STATUS_TRANSFERED, $id);
364 $object->status = $object::STATUS_TRANSFERED;
365 $object->date_reelle_arrivee = null;
366 $object->update($user);
367 setEventMessage('StockStransferIncrementedShortCancel', 'warnings');
368 }
369 }
370 }
371
372 // Set incoterm
373 if ($action == 'set_incoterms' && isModEnabled('incoterm') && $permissiontoadd) {
374 $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
375 }
376 // Actions to send emails
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';
381}
382
383
384
385
386/*
387 * View
388 */
389
390$form = new Form($db);
391$formfile = new FormFile($db);
392$formproject = new FormProjets($db);
393
394$title = $langs->trans("StockTransfer");
395$help_url = '';
396
397llxHeader('', $title, $help_url);
398
399
400
401// Example : Adding jquery code
402print '<script type="text/javascript" language="javascript">
403jQuery(document).ready(function() {';
404
405// Affichage alerte date prévue de départ si transfert concerné
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');
410}
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'));
414 print "');";
415}
416
417print '});
418</script>';
419
420
421// Part to create
422if ($action == 'create') {
423 if (empty($permissiontoadd)) {
424 accessforbidden('NotEnoughPermissions', 0, 1);
425 }
426
427 print load_fiche_titre($title, '', 'object_'.$object->picto);
428
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">';
432 if ($backtopage) {
433 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
434 }
435 if ($backtopageforcancel) {
436 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
437 }
438
439 print dol_get_fiche_head(array(), '');
440
441 // Set some default values
442 //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
443
444 print '<table class="border centpercent tableforfieldcreate">'."\n";
445
446 // Common attributes
447 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
448
449 if (isModEnabled('incoterm')) {
450 print '<tr>';
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');
454 print '</td></tr>';
455 }
456 // Template to use by default
457 print '<tr><td>'.$langs->trans('DefaultModel').'</td>';
458 print '<td>';
459 print img_picto('', 'pdf', 'class="pictofixedwidth"');
460 include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
462 $preselected = getDolGlobalString('STOCKTRANSFER_ADDON_PDF');
463 print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1);
464 print "</td></tr>";
465
466 // Other attributes
467 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
468
469 print '</table>'."\n";
470
471 print dol_get_fiche_end();
472
473 print $form->buttonsSaveCancel("Create");
474
475 print '</form>';
476
477 //dol_set_focus('input[name="ref"]');
478}
479
480// Part to edit record
481if (($id || $ref) && $action == 'edit') {
482 print load_fiche_titre($langs->trans("StockTransfer"), '', 'object_' . $object->picto);
483
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 . '">';
488 if ($backtopage) {
489 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
490 }
491 if ($backtopageforcancel) {
492 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
493 }
494
495 print dol_get_fiche_head();
496
497 print '<table class="border centpercent tableforfieldedit">' . "\n";
498
499 // Common attributes
500 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
501
502 // Other attributes
503 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
504
505 print '</table>';
506
507 print dol_get_fiche_end();
508
509 print $form->buttonsSaveCancel();
510
511 print '</form>';
512}
513
514// Part to show record
515if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
516 $res = $object->fetch_optionals();
517
518 $head = stocktransferPrepareHead($object);
519
520 print dol_get_fiche_head($head, 'card', $langs->trans("StockTransfer"), -1, $object->picto);
521
522 $formconfirm = '';
523
524 // Confirmation to delete (using preloaded confirm popup)
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');
527 }
528 // Confirmation to delete line
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);
531 }
532 // Clone confirmation
533 if ($action == 'clone') {
534 // Create an array for form
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') { // Destock confirmation
538 // Create an array for form
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)
542 );
543 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProduct'), '', 'confirm_destock', $formquestion, 'yes', 1);
544 } elseif ($action == 'destockcancel') { // Destock confirmation cancel
545 // Create an array for form
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)
549 );
550 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProductCancel'), '', 'confirm_destockcancel', $formquestion, 'yes', 1);
551 } elseif ($action == 'addstock') { // Addstock confirmation
552 // Create an array for form
553 $formquestion = array( 'text' => '',
554 array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', '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)
556 );
557 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProduct'), '', 'confirm_addstock', $formquestion, 'yes', 1);
558 } elseif ($action == 'addstockcancel') { // Addstock confirmation cancel
559 // Create an array for form
560 $formquestion = array( 'text' => '',
561 array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', '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)
563 );
564 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProductCancel'), '', 'confirm_addstockcancel', $formquestion, 'yes', 1);
565 }
566
567 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
568 if ($action == 'xxx') {
569 $formquestion = array();
570 /*
571 $forcecombo=0;
572 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
573 $formquestion = array(
574 // 'text' => $langs->trans("ConfirmClone"),
575 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
576 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
577 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
578 );
579 */
580 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
581 }
582
583
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);
587 }
588
589 // Call Hook formConfirm
590 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
591 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
592 if (empty($reshook)) {
593 $formconfirm .= $hookmanager->resPrint;
594 } elseif ($reshook > 0) {
595 $formconfirm = $hookmanager->resPrint;
596 }
597
598 // Print form confirm
599 print $formconfirm;
600
601
602 // Object card
603 // ------------------------------------------------------------
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>';
605
606 $morehtmlref = '<div class="refidno">';
607 // Thirdparty
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>)';
611 }
612 // Project
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> ';
620 }
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');
622 } else {
623 if (!empty($object->fk_project)) {
624 $proj = new Project($db);
625 $proj->fetch($object->fk_project);
626 $morehtmlref .= $proj->getNomUrl(1);
627 if ($proj->title) {
628 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
629 }
630 }
631 }
632 }
633 $morehtmlref .= '</div>';
634
635
636 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
637
638
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";
643
644 // Common attributes
645 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
646 //unset($object->fields['fk_project']); // Hide field already shown in banner
647 //unset($object->fields['fk_soc']); // Hide field already shown in banner
648
649 $object->fields['fk_soc']['visible']=0; // Already available in banner
650 $object->fields['fk_project']['visible']=0; // Already available in banner
651 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
652
653 // Incoterms
654 if (isModEnabled('incoterm')) {
655 print '<tr><td>';
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>';
661 } else {
662 print '&nbsp;';
663 }
664 print '</td></tr></table>';
665 print '</td>';
666 print '<td>';
667 if ($action != 'editincoterm') {
668 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
669 } else {
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);
671 }
672 print '</td></tr>';
673 }
674
675 echo '<tr>';
676 echo '<td>'.$langs->trans('EnhancedValue').'&nbsp;'.strtolower($langs->trans('TotalWoman'));
677 echo '<td>'.price($object->getValorisationTotale(), 0, '', 1, -1, -1, $conf->currency).'</td>';
678 echo '</tr>';
679
680 // Other attributes. Fields from hook formObjectOptions and Extrafields.
681 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
682
683 print '</table>';
684 print '</div>';
685 print '</div>';
686
687 print '<div class="clearboth"></div>';
688
689 print dol_get_fiche_end();
690
691
692 /*
693 * Lines
694 */
695
696 if (!empty($object->table_element_line)) {
697 // Show object lines
698 /*
699 $result = $object->getLinesArray();
700
701 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
702 <input type="hidden" name="token" value="' . newToken().'">
703 <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
704 <input type="hidden" name="mode" value="">
705 <input type="hidden" name="page_y" value="">
706 <input type="hidden" name="id" value="' . $object->id.'">
707 ';
708 */
709
710 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
711 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
712 }
713
714 /*
715 print '<div class="div-table-responsive-no-min">';
716 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
717 print '<table id="tablelines" class="noborder noshadow" width="100%">';
718 }
719
720 if (!empty($object->lines)) {
721 $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
722 }
723
724 // Form to add new line
725 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
726 if ($action != 'editline') {
727 // Add products/services form
728
729 $parameters = array();
730 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
731 if ($reshook < 0) {
732 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
733 }
734 if (empty($reshook)) {
735 $object->formAddObjectLine(1, $mysoc, $soc);
736 }
737 }
738 }
739
740 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
741 print '</table>';
742 }
743 print '</div>';
744
745 print "</form>\n";
746 */
747 }
748
749
750 $formproduct = new FormProduct($db);
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.'">
757 ';
758 if ($lineid > 0) {
759 print '<input type="hidden" name="lineid" value="'.$lineid.'" />';
760 }
761 print '<table id="tablelines" class="liste centpercent">';
762 //print '<div class="tagtable centpercent">';
763
764 $param = '';
765
766 $conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE=true; // Full display needed to see all column title details
767
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 ');
772 }
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 ');
778 }
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) {
782 print getTitleFieldOfList('', 0);
783 print getTitleFieldOfList('', 0);
784 print getTitleFieldOfList('', 0);
785 }
786
787 print '</tr>';
788
789 $listofdata = $object->getLinesArray();
790 $productstatic = new Product($db);
791 $warehousestatics = new Entrepot($db);
792 $warehousestatict = new Entrepot($db);
793
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);
798
799 // add html5 elements
800 $domData = ' data-element="'.$line->element.'"';
801 $domData .= ' data-id="'.$line->id.'"';
802 $domData .= ' data-qty="'.$line->qty.'"';
803 //$domData .= ' data-product_type="'.$line->product_type.'"';
804
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);
809 } else {
810 print $productstatic->getNomUrl(1).' - '.$productstatic->label;
811 }
812 print '</td>';
813 if (isModEnabled('productbatch')) {
814 print '<td>';
815 if ($action === 'editline' && $line->id == $lineid) {
816 print '<input type="text" value="'.$line->batch.'" name="batch" class="flat maxwidth50"/>';
817 } else {
818 $productlot = new Productlot($db);
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.'&nbsp;'.img_warning($langs->trans('BatchNotFound'));
823 }
824 }
825 print '</td>';
826 }
827
828 print '<td>';
829
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);
832 } else {
833 print $warehousestatics->getNomUrl(1);
834 }
835 print '</td>';
836 print '<td>';
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);
839 } else {
840 print $warehousestatict->getNomUrl(1);
841 }
842 print '</td>';
843 if ($action === 'editline' && $line->id == $lineid) {
844 print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>';
845 } else {
846 print '<td class="center">'.$line->qty.'</td>';
847 }
848
849 if ($conf->global->PRODUCT_USE_UNITS) {
850 print '<td class="linecoluseunit nowrap left">';
851 $label = $productstatic->getLabelOfUnit('short');
852 if ($label !== '') {
853 print $langs->trans($label);
854 }
855 print '</td>';
856 }
857
858 print '<td class="center">';
859 print price($line->pmp, 0, '', 1, -1, -1, $conf->currency);
860 print '</td>';
861 print '<td class="center">';
862 print price($line->pmp * $line->qty, 0, '', 1, -1, -1, $conf->currency);
863 print '</td>';
864 if (empty($object->status) && $permissiontoadd) {
865 if ($action === 'editline' && $line->id == $lineid) {
866 //print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Save')) . '"></td>';
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>';
869 } else {
870 print '<td class="right">';
871 print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=editline&amp;lineid=' . $line->id . '#line_' . $line->id . '">';
872 print img_edit() . '</a>';
873 print '</td>';
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>';
876 print '</td>';
877 }
878
879 $num = count($object->lines);
880
881 if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) {
882 print '<td class="linecolmove tdlineupdown center">';
883 $coldisplay++;
884 if ($i > 0) { ?>
885 <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$id.'&amp;action=up&amp;rowid='.$line->id; ?>">
886 <?php print img_up('default', 0, 'imgupforline'); ?>
887 </a>
888 <?php }
889 if ($i < $num - 1) { ?>
890 <a class="lineupdown" href="<?php print $_SERVER["PHP_SELF"].'?id='.$id.'&amp;action=down&amp;rowid='.$line->id; ?>">
891 <?php print img_down('default', 0, 'imgdownforline'); ?>
892 </a>
893 <?php }
894 print '</td>';
895 } else {
896 print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
897 $coldisplay++;
898 }
899 }
900
901 print '</tr>';
902 }
903
904 if (empty($object->status) && $action !== 'editline' && $permissiontoadd) {
905 print '<tr class="oddeven">';
906 // Product
907 print '<td class="titlefield">';
908 $filtertype = 0;
909 if (getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
910 $filtertype = '';
911 }
912 if (getDolGlobalInt('PRODUIT_LIMIT_SIZE') <= 0) {
913 $limit = '';
914 } else {
915 $limit = $conf->global->PRODUIT_LIMIT_SIZE;
916 }
917
918 $form->select_produits($fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
919 print '</td>';
920 // Batch number
921 if (isModEnabled('productbatch')) {
922 print '<td>';
923 print '<input type="text" name="batch" class="flat maxwidth50" '.(!empty($error) ? 'value="'.$batch.'"' : '').'>';
924 print '</td>';
925 }
926
927 $formproduct->loadWarehouses(); // Pour charger la totalité des entrepôts
928
929 // On stock ceux qui ne doivent pas être proposés dans la liste
930 $TExcludedWarehouseSource=array();
931 if (!empty($object->fk_warehouse_source)) {
932 $source_ent = new Entrepot($db);
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'];
937 }
938 }
939 }
940
941 // On stock ceux qui ne doivent pas être proposés dans la liste
942 $TExcludedWarehouseDestination=array();
943 if (!empty($object->fk_warehouse_destination)) {
944 $dest_ent = new Entrepot($db);
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'];
949 }
950 }
951 }
952
953 // On vide le tableau pour qu'il se charge tout seul lors de l'appel à la fonction select_warehouses
954 $formproduct->cache_warehouses=array();
955 // In warehouse
956 print '<td>';
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);
958 print '</td>';
959
960 // On vide le tableau pour qu'il se charge tout seul lors de l'appel à la fonction select_warehouses
961 $formproduct->cache_warehouses=array();
962 // Out warehouse
963 print '<td>';
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);
965 print '</td>';
966
967 // Qty
968 print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ? 'value="'.$qty.'"' : '').'></td>';
969 // PMP
970 print '<td></td>';
971 if ($conf->global->PRODUCT_USE_UNITS) {
972 // Unité
973 print '<td></td>';
974 }
975 // PMP * Qty
976 print '<td></td>';
977 // Button to add line
978 print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Add')) . '"></td>';
979 // Grad and drop lines
980 print '<td></td>';
981 print '</tr>';
982 }
983
984 print '</table>';
985 print '</form>';
986 print '</div>';
987
988 // Buttons for actions
989
990 if ($action != 'presend' && $action != 'editline') {
991 print '<div class="tabsAction">'."\n";
992 $parameters = array();
993 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
994 if ($reshook < 0) {
995 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
996 }
997
998 if (empty($reshook)) {
999 // Send
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');
1002 }
1003
1004 // Back to draft
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);
1007 }
1008
1009 // Modify
1010 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
1011
1012 // Validate
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);
1016 } else {
1017 $langs->load("errors");
1018 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
1019 }
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>';
1027 }
1028
1029 // Clone
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);
1032 }
1033
1034 /*
1035 if ($permissiontoadd) {
1036 if ($object->status == $object::STATUS_ENABLED) {
1037 print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd);
1038 } else {
1039 print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd);
1040 }
1041 }
1042 if ($permissiontoadd) {
1043 if ($object->status == $object::STATUS_VALIDATED) {
1044 print dolGetButtonAction('', $langs->trans('Cancel'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
1045 } else {
1046 print dolGetButtonAction('', $langs->trans('Re-Open'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd);
1047 }
1048 }
1049
1050 */
1051
1052 // Delete (with preloaded confirm popup)
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)) { // We can use preloaded confirm if not jmobile
1056 $deleteUrl = '';
1057 $buttonId = 'action-delete';
1058 }
1059 $params = array();
1060 print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $deleteUrl, $buttonId, $permissiontodelete, $params);
1061 }
1062 print '</div>'."\n";
1063 }
1064
1065
1066 // Select mail models is same action as presend
1067 if (GETPOST('modelselected')) {
1068 $action = 'presend';
1069 }
1070
1071 if ($action != 'presend') {
1072 print '<div class="fichecenter"><div class="fichehalfleft">';
1073 print '<a name="builddoc"></a>'; // ancre
1074
1075 $includedocgeneration = 1;
1076
1077 // Documents
1078 if ($includedocgeneration) {
1079 $objref = dol_sanitizeFileName($object->ref);
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; // If you can read, you can build the PDF to read content
1084 $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
1085 print $formfile->showdocuments('stocktransfer:StockTransfer', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
1086 }
1087
1088 // Show links to link elements
1089 $linktoelem = $form->showLinkToObjectBlock($object, null, array('stocktransfer'));
1090 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1091
1092
1093 print '</div><div class="fichehalfright">';
1094
1095 $MAXEVENT = 10;
1096
1097 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id);
1098
1099 // List of actions on element
1100 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1101 $formactions = new FormActions($db);
1102 $somethingshown = $formactions->showactions($object, 'stocktransfer', 0, 1, '', $MAXEVENT, '', $morehtmlright);
1103
1104 print '</div></div>';
1105 }
1106
1107 //Select mail models is same action as presend
1108 if (GETPOST('modelselected')) {
1109 $action = 'presend';
1110 }
1111
1112 // Presend form
1113 $modelmail = 'stocktransfer';
1114 $defaulttopic = 'InformationMessage';
1115 $diroutput = $conf->stocktransfer->dir_output;
1116 $trackid = 'stocktransfer'.$object->id;
1117
1118 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1119}
1120
1121// End of page
1122llxFooter();
1123$db->close();
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.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage warehouses.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage building of HTML components.
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 StockTransfer.
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.