diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 0652424d919..1b723cf716d 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -46,9 +46,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
-if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
+if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+}
+if (!empty($conf->propal->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+}
+if (!empty($conf->productbatch->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
+}
if (!empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@@ -57,25 +63,38 @@ if (!empty($conf->projet->enabled)) {
// Load translation files required by the page
$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal'));
-if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
-if (!empty($conf->productbatch->enabled)) $langs->load('productbatch');
+if (!empty($conf->incoterm->enabled)) {
+ $langs->load('incoterm');
+}
+if (!empty($conf->productbatch->enabled)) {
+ $langs->load('productbatch');
+}
$origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'expedition'; // Example: commande, propal
$origin_id = GETPOST('id', 'int') ?GETPOST('id', 'int') : '';
$id = $origin_id;
-if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal
-if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal
+if (empty($origin_id)) {
+ $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal
+}
+if (empty($origin_id)) {
+ $origin_id = GETPOST('object_id', 'int'); // Id of order or propal
+}
$ref = GETPOST('ref', 'alpha');
$line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : '';
// Security check
$socid = '';
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
-if ($origin == 'expedition') $result = restrictedArea($user, $origin, $id);
-else {
+if ($origin == 'expedition') {
+ $result = restrictedArea($user, $origin, $id);
+} else {
$result = restrictedArea($user, 'expedition');
- if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden();
+ if (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) {
+ accessforbidden();
+ }
}
$action = GETPOST('action', 'alpha');
@@ -114,12 +133,12 @@ $date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_d
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
-if (empty($reshook))
-{
- if ($cancel)
- {
+if (empty($reshook)) {
+ if ($cancel) {
$action = '';
$object->fetch($id); // show shipment also after canceling modification
}
@@ -132,20 +151,17 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Reopen
- if ($action == 'reopen' && $user->rights->expedition->creer)
- {
+ if ($action == 'reopen' && $user->rights->expedition->creer) {
$object->fetch($id);
$result = $object->reOpen();
}
// Set incoterm
- if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
- {
+ if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) {
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
- if ($action == 'setref_customer')
- {
+ if ($action == 'setref_customer') {
$result = $object->fetch($id);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -161,32 +177,31 @@ if (empty($reshook))
}
}
- if ($action == 'update_extras')
- {
+ if ($action == 'update_extras') {
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields('SHIPMENT_MODIFY');
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
- if ($error)
+ if ($error) {
$action = 'edit_extras';
+ }
}
// Create shipment
- if ($action == 'add' && $user->rights->expedition->creer)
- {
+ if ($action == 'add' && $user->rights->expedition->creer) {
$error = 0;
$db->begin();
@@ -226,8 +241,7 @@ if (empty($reshook))
$num = count($objectsrc->lines);
$totalqty = 0;
- for ($i = 0; $i < $num; $i++)
- {
+ for ($i = 0; $i < $num; $i++) {
$idl = "idl".$i;
$sub_qty = array();
@@ -238,14 +252,11 @@ if (empty($reshook))
$stockLocation = "ent1".$i."_0";
$qty = "qtyl".$i;
- if (!empty($conf->productbatch->enabled) && $objectsrc->lines[$i]->product_tobatch) // If product need a batch number
- {
- if (GETPOSTISSET($batch))
- {
+ if (!empty($conf->productbatch->enabled) && $objectsrc->lines[$i]->product_tobatch) { // If product need a batch number
+ if (GETPOSTISSET($batch)) {
//shipment line with batch-enable product
$qty .= '_'.$j;
- while (GETPOSTISSET($batch))
- {
+ while (GETPOSTISSET($batch)) {
// save line of detail into sub_qty
$sub_qty[$j]['q'] = GETPOST($qty, 'int'); // the qty we want to move for this stock record
$sub_qty[$j]['id_batch'] = GETPOST($batch, 'int'); // the id into llx_product_batch of stock record to move
@@ -265,8 +276,7 @@ if (empty($reshook))
$totalqty += $subtotalqty;
} else {
// No detail were provided for lots
- if (!empty($_POST[$qty]))
- {
+ if (!empty($_POST[$qty])) {
// We try to set an amount
// Case we dont use the list of available qty for each warehouse/lot
// GUI does not allow this yet
@@ -276,8 +286,7 @@ if (empty($reshook))
} elseif (GETPOSTISSET($stockLocation)) {
//shipment line from multiple stock locations
$qty .= '_'.$j;
- while (GETPOSTISSET($stockLocation))
- {
+ while (GETPOSTISSET($stockLocation)) {
// save sub line of warehouse
$stockLine[$i][$j]['qty'] = price2num(GETPOST($qty, 'alpha'), 'MS');
$stockLine[$i][$j]['warehouse_id'] = GETPOST($stockLocation, 'int');
@@ -292,7 +301,9 @@ if (empty($reshook))
} else {
//var_dump(GETPOST($qty,'alpha')); var_dump($_POST); var_dump($batch);exit;
//shipment line for product with no batch management and no multiple stock location
- if (GETPOST($qty, 'int') > 0) $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
+ if (GETPOST($qty, 'int') > 0) {
+ $totalqty += price2num(GETPOST($qty, 'alpha'), 'MS');
+ }
}
// Extrafields
@@ -308,43 +319,38 @@ if (empty($reshook))
//var_dump($batch_line[2]);
- if ($totalqty > 0) // There is at least one thing to ship
- {
+ if ($totalqty > 0) { // There is at least one thing to ship
//var_dump($_POST);exit;
- for ($i = 0; $i < $num; $i++)
- {
+ for ($i = 0; $i < $num; $i++) {
$qty = "qtyl".$i;
- if (!isset($batch_line[$i]))
- {
+ if (!isset($batch_line[$i])) {
// not batch mode
- if (isset($stockLine[$i]))
- {
+ if (isset($stockLine[$i])) {
//shipment from multiple stock locations
$nbstockline = count($stockLine[$i]);
- for ($j = 0; $j < $nbstockline; $j++)
- {
- if ($stockLine[$i][$j]['qty'] > 0)
- {
+ for ($j = 0; $j < $nbstockline; $j++) {
+ if ($stockLine[$i][$j]['qty'] > 0) {
$ret = $object->addline($stockLine[$i][$j]['warehouse_id'], $stockLine[$i][$j]['ix_l'], $stockLine[$i][$j]['qty'], $array_options[$i]);
- if ($ret < 0)
- {
+ if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
}
} else {
- if (GETPOST($qty, 'int') > 0 || (GETPOST($qty, 'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS))
- {
+ if (GETPOST($qty, 'int') > 0 || (GETPOST($qty, 'int') == 0 && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS)) {
$ent = "entl".$i;
$idl = "idl".$i;
$entrepot_id = is_numeric(GETPOST($ent, 'int')) ?GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int');
- if ($entrepot_id < 0) $entrepot_id = '';
- if (!($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0;
+ if ($entrepot_id < 0) {
+ $entrepot_id = '';
+ }
+ if (!($objectsrc->lines[$i]->fk_product > 0)) {
+ $entrepot_id = 0;
+ }
$ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i]);
- if ($ret < 0)
- {
+ if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
@@ -352,11 +358,9 @@ if (empty($reshook))
}
} else {
// batch mode
- if ($batch_line[$i]['qty'] > 0)
- {
+ if ($batch_line[$i]['qty'] > 0) {
$ret = $object->addline_batch($batch_line[$i], $array_options[$i]);
- if ($ret < 0)
- {
+ if ($ret < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
@@ -365,13 +369,13 @@ if (empty($reshook))
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
$ret = $object->create($user); // This create shipment (like Odoo picking) and lines of shipments. Stock movement will be done when validating shipment.
- if ($ret <= 0)
- {
+ if ($ret <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
@@ -381,8 +385,7 @@ if (empty($reshook))
$error++;
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
header("Location: card.php?id=".$object->id);
exit;
@@ -391,16 +394,10 @@ if (empty($reshook))
$_GET["commande_id"] = GETPOST('commande_id', 'int');
$action = 'create';
}
- }
-
- /*
- * Build a receiving receipt
- */
- elseif ($action == 'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)
- {
+ } elseif ($action == 'create_delivery' && $conf->delivery_note->enabled && $user->rights->expedition->delivery->creer) {
+ // Build a receiving receipt
$result = $object->create_delivery($user);
- if ($result > 0)
- {
+ if ($result > 0) {
header("Location: ".DOL_URL_ROOT.'/delivery/card.php?action=create_delivery&id='.$result);
exit;
} else {
@@ -408,9 +405,8 @@ if (empty($reshook))
}
} elseif ($action == 'confirm_valid' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer))
- || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
- )
- {
+ || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate)))
+ ) {
$object->fetch_thirdparty();
$result = $object->valid($user);
@@ -419,12 +415,15 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Define output language
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $object->thirdparty->default_lang;
+ }
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -433,57 +432,47 @@ if (empty($reshook))
$ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
- if ($result < 0) dol_print_error($db, $result);
+ if ($result < 0) {
+ dol_print_error($db, $result);
+ }
}
}
- } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->expedition->supprimer)
- {
+ } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->expedition->supprimer) {
$also_update_stock = (GETPOST('alsoUpdateStock', 'alpha') ? 1 : 0);
$result = $object->cancel(0, $also_update_stock);
- if ($result > 0)
- {
+ if ($result > 0) {
$result = $object->setStatut(-1);
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer)
- {
+ } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expedition->supprimer) {
$also_update_stock = (GETPOST('alsoUpdateStock', 'alpha') ? 1 : 0);
$result = $object->delete(0, $also_update_stock);
- if ($result > 0)
- {
+ if ($result > 0) {
header("Location: ".DOL_URL_ROOT.'/expedition/index.php');
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
- }
- // TODO add alternative status
- /*elseif ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate)))
- {
- $result = $object->setStatut(0);
- if ($result < 0)
- {
- setEventMessages($object->error, $object->errors, 'errors');
- }
- }*/
-
- elseif ($action == 'setdate_livraison' && $user->rights->expedition->creer)
- {
+ // TODO add alternative status
+ //} elseif ($action == 'reopen' && (! empty($user->rights->expedition->creer) || ! empty($user->rights->expedition->shipping_advance->validate)))
+ //{
+ // $result = $object->setStatut(0);
+ // if ($result < 0)
+ // {
+ // setEventMessages($object->error, $object->errors, 'errors');
+ // }
+ //}
+ } elseif ($action == 'setdate_livraison' && $user->rights->expedition->creer) {
//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
$object->fetch($id);
$result = $object->setDeliveryDate($user, $datedelivery);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
- }
-
- // Action update
- elseif (
- ($action == 'settracking_number'
+ } elseif (($action == 'settracking_number'
|| $action == 'settracking_url'
|| $action == 'settrueWeight'
|| $action == 'settrueWidth'
@@ -491,28 +480,36 @@ if (empty($reshook))
|| $action == 'settrueDepth'
|| $action == 'setshipping_method_id')
&& $user->rights->expedition->creer
- )
- {
+ ) {
+ // Action update
$error = 0;
- if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha'));
- if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int'));
+ if ($action == 'settracking_number') {
+ $object->tracking_number = trim(GETPOST('tracking_number', 'alpha'));
+ }
+ if ($action == 'settracking_url') {
+ $object->tracking_url = trim(GETPOST('tracking_url', 'int'));
+ }
if ($action == 'settrueWeight') {
$object->trueWeight = trim(GETPOST('trueWeight', 'int'));
$object->weight_units = GETPOST('weight_units', 'int');
}
- if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int'));
+ if ($action == 'settrueWidth') {
+ $object->trueWidth = trim(GETPOST('trueWidth', 'int'));
+ }
if ($action == 'settrueHeight') {
$object->trueHeight = trim(GETPOST('trueHeight', 'int'));
$object->size_units = GETPOST('size_units', 'int');
}
- if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int'));
- if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int'));
+ if ($action == 'settrueDepth') {
+ $object->trueDepth = trim(GETPOST('trueDepth', 'int'));
+ }
+ if ($action == 'setshipping_method_id') {
+ $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int'));
+ }
- if (!$error)
- {
- if ($object->update($user) >= 0)
- {
+ if (!$error) {
+ if ($object->update($user) >= 0) {
header("Location: card.php?id=".$object->id);
exit;
}
@@ -520,8 +517,7 @@ if (empty($reshook))
}
$action = "";
- } elseif ($action == 'classifybilled')
- {
+ } elseif ($action == 'classifybilled') {
$object->fetch($id);
$result = $object->setBilled();
if ($result >= 0) {
@@ -529,8 +525,7 @@ if (empty($reshook))
exit();
}
setEventMessages($object->error, $object->errors, 'errors');
- } elseif ($action == 'classifyclosed')
- {
+ } elseif ($action == 'classifyclosed') {
$object->fetch($id);
$result = $object->setClosed();
if ($result >= 0) {
@@ -538,37 +533,27 @@ if (empty($reshook))
exit();
}
setEventMessages($object->error, $object->errors, 'errors');
- }
-
- /*
- * delete a line
- */
- elseif ($action == 'deleteline' && !empty($line_id))
- {
+ } elseif ($action == 'deleteline' && !empty($line_id)) {
+ // delete a line
$object->fetch($id);
$lines = $object->lines;
$line = new ExpeditionLigne($db);
$num_prod = count($lines);
- for ($i = 0; $i < $num_prod; $i++)
- {
- if ($lines[$i]->id == $line_id)
- {
- if (count($lines[$i]->details_entrepot) > 1)
- {
+ for ($i = 0; $i < $num_prod; $i++) {
+ if ($lines[$i]->id == $line_id) {
+ if (count($lines[$i]->details_entrepot) > 1) {
// delete multi warehouse lines
foreach ($lines[$i]->details_entrepot as $details_entrepot) {
$line->id = $details_entrepot->line_id;
- if (!$error && $line->delete($user) < 0)
- {
+ if (!$error && $line->delete($user) < 0) {
$error++;
}
}
} else {
// delete single warehouse line
$line->id = $line_id;
- if (!$error && $line->delete($user) < 0)
- {
+ if (!$error && $line->delete($user) < 0) {
$error++;
}
}
@@ -582,13 +567,8 @@ if (empty($reshook))
} else {
setEventMessages($line->error, $line->errors, 'errors');
}
- }
-
- /*
- * Update a line
- */
- elseif ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('save'))
- {
+ } elseif ($action == 'updateline' && $user->rights->expedition->creer && GETPOST('save')) {
+ // Update a line
// Clean parameters
$qty = 0;
$entrepot_id = 0;
@@ -596,10 +576,8 @@ if (empty($reshook))
$lines = $object->lines;
$num_prod = count($lines);
- for ($i = 0; $i < $num_prod; $i++)
- {
- if ($lines[$i]->id == $line_id) // we have found line to update
- {
+ for ($i = 0; $i < $num_prod; $i++) {
+ if ($lines[$i]->id == $line_id) { // we have found line to update
$line = new ExpeditionLigne($db);
// Extrafields Lines
@@ -611,28 +589,25 @@ if (empty($reshook))
}
}
$line->fk_product = $lines[$i]->fk_product;
- if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
- {
+ if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) {
// line with lot
- foreach ($lines[$i]->detail_batch as $detail_batch)
- {
+ foreach ($lines[$i]->detail_batch as $detail_batch) {
$lotStock = new Productbatch($db);
$batch = "batchl".$detail_batch->fk_expeditiondet."_".$detail_batch->fk_origin_stock;
$qty = "qtyl".$detail_batch->fk_expeditiondet.'_'.$detail_batch->id;
$batch_id = GETPOST($batch, 'int');
$batch_qty = GETPOST($qty, 'int');
- if (!empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty))
- {
- if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) // $line is ExpeditionLine
- {
- if ($lines[$i]->entrepot_id != 0)
- {
+ if (!empty($batch_id) && ($batch_id != $detail_batch->fk_origin_stock || $batch_qty != $detail_batch->qty)) {
+ if ($lotStock->fetch($batch_id) > 0 && $line->fetch($detail_batch->fk_expeditiondet) > 0) { // $line is ExpeditionLine
+ if ($lines[$i]->entrepot_id != 0) {
// allow update line entrepot_id if not multi warehouse shipping
$line->entrepot_id = $lotStock->warehouseid;
}
// detail_batch can be an object with keys, or an array of ExpeditionLineBatch
- if (empty($line->detail_batch)) $line->detail_batch = new stdClass();
+ if (empty($line->detail_batch)) {
+ $line->detail_batch = new stdClass();
+ }
$line->detail_batch->fk_origin_stock = $batch_id;
$line->detail_batch->batch = $lotStock->batch;
@@ -658,34 +633,25 @@ if (empty($reshook))
$batch_id = GETPOST($batch, 'int');
$batch_qty = GETPOST($qty, 'int');
$lineIdToAddLot = 0;
- if ($batch_qty > 0 && !empty($batch_id))
- {
- if ($lotStock->fetch($batch_id) > 0)
- {
+ if ($batch_qty > 0 && !empty($batch_id)) {
+ if ($lotStock->fetch($batch_id) > 0) {
// check if lotStock warehouse id is same as line warehouse id
- if ($lines[$i]->entrepot_id > 0)
- {
+ if ($lines[$i]->entrepot_id > 0) {
// single warehouse shipment line
- if ($lines[$i]->entrepot_id == $lotStock->warehouseid)
- {
+ if ($lines[$i]->entrepot_id == $lotStock->warehouseid) {
$lineIdToAddLot = $line_id;
}
- } elseif (count($lines[$i]->details_entrepot) > 1)
- {
+ } elseif (count($lines[$i]->details_entrepot) > 1) {
// multi warehouse shipment lines
- foreach ($lines[$i]->details_entrepot as $detail_entrepot)
- {
- if ($detail_entrepot->entrepot_id == $lotStock->warehouseid)
- {
+ foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
+ if ($detail_entrepot->entrepot_id == $lotStock->warehouseid) {
$lineIdToAddLot = $detail_entrepot->line_id;
}
}
}
- if ($lineIdToAddLot)
- {
+ if ($lineIdToAddLot) {
// add lot to existing line
- if ($line->fetch($lineIdToAddLot) > 0)
- {
+ if ($line->fetch($lineIdToAddLot) > 0) {
$line->detail_batch->fk_origin_stock = $batch_id;
$line->detail_batch->batch = $lotStock->batch;
$line->detail_batch->entrepot_id = $lotStock->warehouseid;
@@ -707,8 +673,7 @@ if (empty($reshook))
$line->detail_batch[0]->batch = $lotStock->batch;
$line->detail_batch[0]->entrepot_id = $lotStock->warehouseid;
$line->detail_batch[0]->qty = $batch_qty;
- if ($object->create_line_batch($line, $line->array_options) < 0)
- {
+ if ($object->create_line_batch($line, $line->array_options) < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
@@ -719,11 +684,9 @@ if (empty($reshook))
}
}
} else {
- if ($lines[$i]->fk_product > 0)
- {
+ if ($lines[$i]->fk_product > 0) {
// line without lot
- if ($lines[$i]->entrepot_id > 0)
- {
+ if ($lines[$i]->entrepot_id > 0) {
// single warehouse shipment line
$stockLocation = "entl".$line_id;
$qty = "qtyl".$line_id;
@@ -736,17 +699,14 @@ if (empty($reshook))
}
unset($_POST[$stockLocation]);
unset($_POST[$qty]);
- } elseif (count($lines[$i]->details_entrepot) > 1)
- {
+ } elseif (count($lines[$i]->details_entrepot) > 1) {
// multi warehouse shipment lines
- foreach ($lines[$i]->details_entrepot as $detail_entrepot)
- {
+ foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
if (!$error) {
$stockLocation = "entl".$detail_entrepot->line_id;
$qty = "qtyl".$detail_entrepot->line_id;
$warehouse = GETPOST($stockLocation, 'int');
- if (!empty($warehouse))
- {
+ if (!empty($warehouse)) {
$line->id = $detail_entrepot->line_id;
$line->entrepot_id = $warehouse;
$line->qty = GETPOST($qty, 'int');
@@ -783,10 +743,12 @@ if (empty($reshook))
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09'))
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
+ }
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -807,7 +769,9 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
- if (empty($id)) $id = $facid;
+ if (empty($id)) {
+ $id = $facid;
+ }
$triggersendname = 'SHIPPING_SENTBYMAIL';
$paramname = 'id';
$mode = 'emailfromshipment';
@@ -825,14 +789,15 @@ llxHeader('', $langs->trans('Shipment'), 'Expedition');
$form = new Form($db);
$formfile = new FormFile($db);
$formproduct = new FormProduct($db);
-if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
+if (!empty($conf->projet->enabled)) {
+ $formproject = new FormProjets($db);
+}
$product_static = new Product($db);
$shipment_static = new Expedition($db);
$warehousestatic = new Entrepot($db);
-if ($action == 'create2')
-{
+if ($action == 'create2') {
print load_fiche_titre($langs->trans("CreateShipment"), '', 'dolly');
print '
'.$langs->trans("ShipmentCreationIsDoneFromOrder");
@@ -840,31 +805,29 @@ if ($action == 'create2')
}
// Mode creation.
-if ($action == 'create')
-{
+if ($action == 'create') {
$expe = new Expedition($db);
print load_fiche_titre($langs->trans("CreateShipment"), '', 'dolly');
- if (!$origin)
- {
+ if (!$origin) {
setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors');
}
- if ($origin)
- {
+ if ($origin) {
$classname = ucfirst($origin);
$object = new $classname($db);
- if ($object->fetch($origin_id)) // This include the fetch_lines
- {
+ if ($object->fetch($origin_id)) { // This include the fetch_lines
$soc = new Societe($db);
$soc->fetch($object->socid);
$author = new User($db);
$author->fetch($object->user_author_id);
- if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db);
+ if (!empty($conf->stock->enabled)) {
+ $entrepot = new Entrepot($db);
+ }
print '