Code comment

This commit is contained in:
Laurent Destailleur 2017-08-02 17:45:35 +02:00
parent cc78a666a0
commit 52d39d9d5a

View File

@ -120,12 +120,12 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if ($cancel) if ($cancel)
{ {
$action = ''; $action = '';
$object->fetch($id); // show shipment also after canceling modification $object->fetch($id); // show shipment also after canceling modification
} }
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Set incoterm // Set incoterm
@ -134,13 +134,13 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
$result = $object->reOpen(); $result = $object->reOpen();
} }
// Set incoterm // 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')); $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
} }
if ($action == 'setref_customer') if ($action == 'setref_customer')
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
@ -157,14 +157,14 @@ if (empty($reshook))
exit; exit;
} }
} }
if ($action == 'update_extras') if ($action == 'update_extras')
{ {
// Fill array 'array_options' with data from update form // Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
@ -180,11 +180,11 @@ if (empty($reshook))
} else if ($reshook < 0) } else if ($reshook < 0)
$error++; $error++;
} }
if ($error) if ($error)
$action = 'edit_extras'; $action = 'edit_extras';
} }
// Create shipment // Create shipment
if ($action == 'add' && $user->rights->expedition->creer) if ($action == 'add' && $user->rights->expedition->creer)
{ {
@ -255,18 +255,18 @@ if (empty($reshook))
$sub_qty[$j]['q']=GETPOST($qty,'int'); // the qty we want to move for this stock record $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 $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); // the id into llx_product_batch of stock record to move
$subtotalqty+=$sub_qty[$j]['q']; $subtotalqty+=$sub_qty[$j]['q'];
//var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']); //var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']);
$j++; $j++;
$batch="batchl".$i."_".$j; $batch="batchl".$i."_".$j;
$qty = "qtyl".$i.'_'.$j; $qty = "qtyl".$i.'_'.$j;
} }
$batch_line[$i]['detail']=$sub_qty; // array of details $batch_line[$i]['detail']=$sub_qty; // array of details
$batch_line[$i]['qty']=$subtotalqty; $batch_line[$i]['qty']=$subtotalqty;
$batch_line[$i]['ix_l']=GETPOST($idl,'int'); $batch_line[$i]['ix_l']=GETPOST($idl,'int');
$totalqty+=$subtotalqty; $totalqty+=$subtotalqty;
} }
else else
@ -293,11 +293,11 @@ if (empty($reshook))
$stockLine[$i][$j]['ix_l']=GETPOST($idl,'int'); $stockLine[$i][$j]['ix_l']=GETPOST($idl,'int');
$totalqty+=GETPOST($qty,'int'); $totalqty+=GETPOST($qty,'int');
$j++; $j++;
$stockLocation="ent1".$i."_".$j; $stockLocation="ent1".$i."_".$j;
$qty = "qtyl".$i.'_'.$j; $qty = "qtyl".$i.'_'.$j;
} }
} }
else else
{ {
@ -305,7 +305,7 @@ if (empty($reshook))
//shipment line for product with no batch management and no multiple stock location //shipment line for product with no batch management and no multiple stock location
if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int');
} }
// Extrafields // Extrafields
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options[$i] = $extrafieldsline->getOptionalsFromPost($extralabelsline, $i); $array_options[$i] = $extrafieldsline->getOptionalsFromPost($extralabelsline, $i);
@ -316,9 +316,9 @@ if (empty($reshook))
unset($_POST["options_" . $key]); unset($_POST["options_" . $key]);
} }
} }
} }
//var_dump($batch_line[2]); //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
@ -328,7 +328,7 @@ if (empty($reshook))
{ {
$qty = "qtyl".$i; $qty = "qtyl".$i;
if (! isset($batch_line[$i])) if (! isset($batch_line[$i]))
{ {
// not batch mode // not batch mode
if (isset($stockLine[$i])) if (isset($stockLine[$i]))
{ {
@ -356,7 +356,7 @@ if (empty($reshook))
$entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
if ($entrepot_id < 0) $entrepot_id=''; if ($entrepot_id < 0) $entrepot_id='';
if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0;
$ret=$object->addline($entrepot_id, GETPOST($idl,'int'), GETPOST($qty,'int'), $array_options[$i]); $ret=$object->addline($entrepot_id, GETPOST($idl,'int'), GETPOST($qty,'int'), $array_options[$i]);
if ($ret < 0) if ($ret < 0)
{ {
@ -367,7 +367,7 @@ if (empty($reshook))
} }
} }
else else
{ {
// batch mode // batch mode
if ($batch_line[$i]['qty']>0) if ($batch_line[$i]['qty']>0)
{ {
@ -379,11 +379,11 @@ if (empty($reshook))
} }
} }
} }
} }
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object); $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++; if ($ret < 0) $error++;
if (! $error) if (! $error)
{ {
$ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment. $ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment.
@ -437,9 +437,9 @@ if (empty($reshook))
) )
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$result = $object->valid($user); $result = $object->valid($user);
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
@ -632,7 +632,7 @@ if ($action == 'create2')
$action=''; $id=''; $ref=''; $action=''; $id=''; $ref='';
} }
// Mode creation. // Mode creation.
if ($action == 'create') if ($action == 'create')
{ {
$expe = new Expedition($db); $expe = new Expedition($db);
@ -756,15 +756,15 @@ if ($action == 'create')
print '<td colspan="3">'; print '<td colspan="3">';
print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">'; print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">';
print "</td></tr>\n"; print "</td></tr>\n";
// Other attributes // Other attributes
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $expe->showOptionals($extrafields, 'edit'); print $expe->showOptionals($extrafields, 'edit');
} }
// Incoterms // Incoterms
if (!empty($conf->incoterm->enabled)) if (!empty($conf->incoterm->enabled))
@ -786,12 +786,12 @@ if ($action == 'create')
print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF);
print "</td></tr>\n"; print "</td></tr>\n";
} }
print "</table>"; print "</table>";
dol_fiche_end(); dol_fiche_end();
// Shipment lines // Shipment lines
$numAsked = count($object->lines); $numAsked = count($object->lines);
@ -819,14 +819,14 @@ if ($action == 'create')
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Load shipments already done for same order // Load shipments already done for same order
$object->loadExpeditions(); $object->loadExpeditions();
if ($numAsked) if ($numAsked)
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -834,7 +834,7 @@ if ($action == 'create')
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>'; print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>'; print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("QtyToShip"); print '<td align="center">'.$langs->trans("QtyToShip");
if (empty($conf->productbatch->enabled)) if (empty($conf->productbatch->enabled))
{ {
print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>'; print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>';
print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)'; print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)';
@ -871,7 +871,7 @@ if ($action == 'create')
if (! empty($line->date_end)) $type=1; if (! empty($line->date_end)) $type=1;
print "<tr ".$bc[$var].">\n"; print "<tr ".$bc[$var].">\n";
// Product label // Product label
if ($line->fk_product > 0) // If predefined product if ($line->fk_product > 0) // If predefined product
{ {
@ -899,7 +899,7 @@ if ($action == 'create')
{ {
print ($line->desc && $line->desc!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->desc):''; print ($line->desc && $line->desc!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->desc):'';
} }
print '</td>'; print '</td>';
} }
else else
@ -944,7 +944,7 @@ if ($action == 'create')
$quantityToBeDelivered = $quantityAsked - $quantityDelivered; $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
} }
$warehouse_id = GETPOST('entrepot_id','int'); $warehouse_id = GETPOST('entrepot_id','int');
$warehouseObject = null; $warehouseObject = null;
if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection
{ {
@ -1026,10 +1026,10 @@ if ($action == 'create')
{ {
// Product need lot // Product need lot
print '<td></td><td></td></tr>'; // end line and start a new one for lot/serial print '<td></td><td></td></tr>'; // end line and start a new one for lot/serial
$staticwarehouse=new Entrepot($db); $staticwarehouse=new Entrepot($db);
if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id);
$subj=0; $subj=0;
// Define nb of lines suggested for this order line // Define nb of lines suggested for this order line
$nbofsuggested=0; $nbofsuggested=0;
@ -1052,11 +1052,11 @@ if ($action == 'create')
print '<td colspan="3" ></td><td align="center">'; print '<td colspan="3" ></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">'; print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
print $staticwarehouse->getNomUrl(0).' / '; print $staticwarehouse->getNomUrl(0).' / ';
print '<!-- Show details of lot -->'; print '<!-- Show details of lot -->';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">'; print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty);
@ -1075,28 +1075,28 @@ if ($action == 'create')
print '<tr '.$bc[$var].'><td colspan="3"></td><td align="center">'; print '<tr '.$bc[$var].'><td colspan="3"></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> '; print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> ';
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
print '</td></tr>'; print '</td></tr>';
} }
} }
} }
else else
{ {
// ship from multiple locations // ship from multiple locations
if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
{ {
print '<td></td><td></td></tr>'; // end line and start a new one for each warehouse print '<td></td><td></td></tr>'; // end line and start a new one for each warehouse
print '<!-- Case warehouse not already known and product does not need lot -->'; print '<!-- Case warehouse not already known and product does not need lot -->';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
$subj=0; $subj=0;
// Define nb of lines suggested for this order line // Define nb of lines suggested for this order line
$nbofsuggested=0; $nbofsuggested=0;
foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
{ {
if ($stock_warehouse->real > 0) if ($stock_warehouse->real > 0)
{ {
$nbofsuggested++; $nbofsuggested++;
} }
@ -1105,7 +1105,7 @@ if ($action == 'create')
{ {
$warehouseObject=new Entrepot($db); $warehouseObject=new Entrepot($db);
$warehouseObject->fetch($warehouse_id); $warehouseObject->fetch($warehouse_id);
if ($stock_warehouse->real > 0) if ($stock_warehouse->real > 0)
{ {
$stock = + $stock_warehouse->real; // Convert it to number $stock = + $stock_warehouse->real; // Convert it to number
$deliverableQty = min($quantityToBeDelivered,$stock); $deliverableQty = min($quantityToBeDelivered,$stock);
@ -1120,7 +1120,7 @@ if ($action == 'create')
} }
else print $langs->trans("NA"); else print $langs->trans("NA");
print '</td>'; print '</td>';
// Stock // Stock
if (! empty($conf->stock->enabled)) if (! empty($conf->stock->enabled))
{ {
@ -1128,10 +1128,10 @@ if ($action == 'create')
if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
print $warehouseObject->getNomUrl(0).' '; print $warehouseObject->getNomUrl(0).' ';
print '<!-- Show details of stock -->'; print '<!-- Show details of stock -->';
print '('.$stock.')'; print '('.$stock.')';
} }
else else
{ {
@ -1179,7 +1179,7 @@ if ($action == 'create')
$subj=0; $subj=0;
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
$warehouseObject=new Entrepot($db); $warehouseObject=new Entrepot($db);
$productlotObject=new Productlot($db); $productlotObject=new Productlot($db);
// Define nb of lines suggested for this order line // Define nb of lines suggested for this order line
@ -1193,7 +1193,7 @@ if ($action == 'create')
} }
} }
} }
foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
{ {
$warehouseObject->fetch($warehouse_id); $warehouseObject->fetch($warehouse_id);
if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
@ -1205,11 +1205,11 @@ if ($action == 'create')
print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested)?$bc[$var]:'').'><td colspan="3"></td><td align="center">'; print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested)?$bc[$var]:'').'><td colspan="3"></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">'; print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
print $warehouseObject->getNomUrl(0).' / '; print $warehouseObject->getNomUrl(0).' / ';
print '<!-- Show details of lot -->'; print '<!-- Show details of lot -->';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">'; print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
//print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); //print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty);
@ -1247,12 +1247,12 @@ if ($action == 'create')
print $langs->trans("NA"); print $langs->trans("NA");
} }
print '</td>'; print '</td>';
print '<td align="left">'; print '<td align="left">';
if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$warehouse_selected_id = GETPOST('entrepot_id','int'); $warehouse_selected_id = GETPOST('entrepot_id','int');
if ($warehouse_selected_id > 0) if ($warehouse_selected_id > 0)
{ {
$warehouseObject=new Entrepot($db); $warehouseObject=new Entrepot($db);
$warehouseObject->fetch($warehouse_selected_id); $warehouseObject->fetch($warehouse_selected_id);
@ -1272,10 +1272,10 @@ if ($action == 'create')
print '</tr>'; print '</tr>';
} }
} }
//Display lines extrafields //Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0) if (is_array($extralabelslines) && count($extralabelslines)>0)
{ {
$colspan=5; $colspan=5;
$line = new ExpeditionLigne($db); $line = new ExpeditionLigne($db);
@ -1325,14 +1325,14 @@ else if ($id || $ref)
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($object->socid); $soc->fetch($object->socid);
$res = $object->fetch_optionals($object->id, $extralabels); $res = $object->fetch_optionals($object->id, $extralabels);
$head=shipping_prepare_head($object); $head=shipping_prepare_head($object);
dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), 0, 'sending'); dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), 0, 'sending');
$formconfirm=''; $formconfirm='';
// Confirm deleteion // Confirm deleteion
if ($action == 'delete') if ($action == 'delete')
{ {
@ -1378,18 +1378,18 @@ else if ($id || $ref)
if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
} }
// Print form confirm // Print form confirm
print $formconfirm; print $formconfirm;
// Calculate totalWeight and totalVolume for all products // Calculate totalWeight and totalVolume for all products
// by adding weight and volume of each product line. // by adding weight and volume of each product line.
$tmparray=$object->getTotalWeightVolume(); $tmparray=$object->getTotalWeightVolume();
$totalWeight=$tmparray['weight']; $totalWeight=$tmparray['weight'];
$totalVolume=$tmparray['volume']; $totalVolume=$tmparray['volume'];
if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled))
{ {
$objectsrc=new Commande($db); $objectsrc=new Commande($db);
@ -1444,15 +1444,15 @@ else if ($id || $ref)
} }
} }
$morehtmlref.='</div>'; $morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Linked documents // Linked documents
@ -1535,7 +1535,7 @@ else if ($id || $ref)
if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': ';
//print $totalWeight.' '.measuring_units_string(0,"weight"); //print $totalWeight.' '.measuring_units_string(0,"weight");
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
//if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')';
if (!empty($object->trueWeight)) print ')'; if (!empty($object->trueWeight)) print ')';
} }
print '</td></tr>'; print '</td></tr>';
@ -1582,7 +1582,7 @@ else if ($id || $ref)
print '<td colspan="3">'; print '<td colspan="3">';
$calculatedVolume=0; $calculatedVolume=0;
$volumeUnit=0; $volumeUnit=0;
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{ {
$calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth);
$volumeUnit=$object->size_units * 3; $volumeUnit=$object->size_units * 3;
@ -1590,7 +1590,7 @@ else if ($id || $ref)
// If sending volume not defined we use sum of products // If sending volume not defined we use sum of products
if ($calculatedVolume > 0) if ($calculatedVolume > 0)
{ {
if ($volumeUnit < 50) if ($volumeUnit < 50)
{ {
//print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume");
print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
@ -1611,14 +1611,14 @@ else if ($id || $ref)
// Other attributes // Other attributes
$cols = 2; $cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Sending method // Sending method
@ -1652,7 +1652,7 @@ else if ($id || $ref)
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Tracking Number // Tracking Number
print '<tr><td class="titlefield">'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number);
@ -1682,19 +1682,19 @@ else if ($id || $ref)
} }
print "</table>"; print "</table>";
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
/* /*
* Lines of products * Lines of products
*/ */
print '<br>'; print '<br>';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -1717,7 +1717,7 @@ else if ($id || $ref)
{ {
print '<td align="center">'.$langs->trans("QtyInOtherShipments").'</td>'; print '<td align="center">'.$langs->trans("QtyInOtherShipments").'</td>';
} }
print '<td align="center">'.$langs->trans("CalculatedWeight").'</td>'; print '<td align="center">'.$langs->trans("CalculatedWeight").'</td>';
print '<td align="center">'.$langs->trans("CalculatedVolume").'</td>'; print '<td align="center">'.$langs->trans("CalculatedVolume").'</td>';
//print '<td align="center">'.$langs->trans("Size").'</td>'; //print '<td align="center">'.$langs->trans("Size").'</td>';
@ -1778,7 +1778,7 @@ else if ($id || $ref)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while($i < $num) while($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -1885,7 +1885,7 @@ else if ($id || $ref)
} }
} }
} }
} }
print '</td>'; print '</td>';
// Weight // Weight
@ -1945,7 +1945,7 @@ else if ($id || $ref)
} }
print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
} }
else else
{ {
print $langs->trans("NA"); print $langs->trans("NA");
} }
@ -1955,7 +1955,7 @@ else if ($id || $ref)
} }
} }
print "</tr>"; print "</tr>";
// Display lines extrafields // Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0) { if (is_array($extralabelslines) && count($extralabelslines)>0) {
$colspan= empty($conf->productbatch->enabled) ? 5 : 6; $colspan= empty($conf->productbatch->enabled) ? 5 : 6;
@ -1968,9 +1968,9 @@ else if ($id || $ref)
$var=!$var; $var=!$var;
} }
// TODO Show also lines ordered but not delivered // TODO Show also lines ordered but not delivered
print "</table>\n"; print "</table>\n";
print '</div>'; print '</div>';
} }
@ -1981,7 +1981,7 @@ else if ($id || $ref)
$object->fetchObjectLinked($object->id,$object->element); $object->fetchObjectLinked($object->id,$object->element);
/* /*
* Boutons actions * Boutons actions
*/ */
@ -2008,14 +2008,14 @@ else if ($id || $ref)
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>'; print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>';
} }
} }
// TODO add alternative status // TODO add alternative status
// 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order)
if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer) if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
} }
// Send // Send
if ($object->statut > 0) if ($object->statut > 0)
{ {
@ -2025,16 +2025,18 @@ else if ($id || $ref)
} }
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
} }
// Create bill and Close shipment // Create bill
if (! empty($conf->facture->enabled) && $object->statut > 0) if (! empty($conf->facture->enabled) && $object->statut > 0)
{ {
if ($user->rights->facture->creer) if ($user->rights->facture->creer)
{ {
// TODO show button only if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))
// If we do that, we must also make this option official.
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
} }
} }
// This is just to generate a delivery receipt // This is just to generate a delivery receipt
//var_dump($object->linkedObjectsIds['delivery']); //var_dump($object->linkedObjectsIds['delivery']);
if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0)
@ -2056,14 +2058,14 @@ else if ($id || $ref)
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action='.$paramaction.'">'.$langs->trans($label).'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action='.$paramaction.'">'.$langs->trans($label).'</a>';
} }
} }
if ($user->rights->expedition->supprimer) if ($user->rights->expedition->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
} }
} }
print '</div>'; print '</div>';
} }
@ -2071,11 +2073,11 @@ else if ($id || $ref)
/* /*
* Documents generated * Documents generated
*/ */
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$filedir = $conf->expedition->dir_output . "/sending/" .$objectref; $filedir = $conf->expedition->dir_output . "/sending/" .$objectref;
@ -2086,12 +2088,12 @@ else if ($id || $ref)
print $formfile->showdocuments('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); print $formfile->showdocuments('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
// Show links to link elements // Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$somethingshown = $form->showLinkedObjectBlock($object, ''); $somethingshown = $form->showLinkedObjectBlock($object, '');
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element // List of actions on element
@ -2102,11 +2104,11 @@ else if ($id || $ref)
print '</div></div></div>'; print '</div></div></div>';
} }
/* /*
* Action presend * Action presend
*/ */
//Select mail models is same action as presend //Select mail models is same action as presend
if (GETPOST('modelselected')) { if (GETPOST('modelselected')) {
$action = 'presend'; $action = 'presend';
@ -2167,7 +2169,7 @@ else if ($id || $ref)
{ {
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'shi'.$object->id); $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'shi'.$object->id);
} }
$formmail->withfrom=1; $formmail->withfrom=1;
$liste=array(); $liste=array();
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
@ -2200,7 +2202,7 @@ else if ($id || $ref)
{ {
$contactarr=$objectsrc->liste_contact(-1,'external'); $contactarr=$objectsrc->liste_contact(-1,'external');
} }
if (is_array($contactarr) && count($contactarr)>0) { if (is_array($contactarr) && count($contactarr)>0) {
foreach($contactarr as $contact) { foreach($contactarr as $contact) {