diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 6d9bba9b464..05770c7d44a 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -1139,449 +1139,457 @@ if ($action == 'create')
$line = $object->lines[$indiceAsked];
+ $parameters = array('i' => $indiceAsked, 'line' => $line, 'num' => $numAsked);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- // Show product and description
- $type=$line->product_type?$line->product_type:$line->fk_product_type;
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (! empty($line->date_start)) $type=1;
- if (! empty($line->date_end)) $type=1;
-
- print ''."\n";
- print '
'."\n";
-
- // Product label
- if ($line->fk_product > 0) // If predefined product
+ if(empty($reshook))
{
- $product->fetch($line->fk_product);
- $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch
- //var_dump($product->stock_warehouse[1]);
+ // Show product and description
+ $type=$line->product_type?$line->product_type:$line->fk_product_type;
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (! empty($line->date_start)) $type=1;
+ if (! empty($line->date_end)) $type=1;
- print '';
- print ' '; // ancre pour retourner sur la ligne
+ print ''."\n";
+ print ' '."\n";
- // Show product and description
- $product_static->type=$line->fk_product_type;
- $product_static->id=$line->fk_product;
- $product_static->ref=$line->ref;
- $product_static->status_batch=$line->product_tobatch;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label);
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc));
- print $form->textwithtooltip($text,$description,3,'','',$i);
+ // Product label
+ if ($line->fk_product > 0) // If predefined product
+ {
+ $product->fetch($line->fk_product);
+ $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch
+ //var_dump($product->stock_warehouse[1]);
- // Show range
- print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end));
+ print '';
+ print ' '; // ancre pour retourner sur la ligne
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
- {
- print ($line->desc && $line->desc!=$line->product_label)?' '.dol_htmlentitiesbr($line->desc):'';
- }
+ // Show product and description
+ $product_static->type=$line->fk_product_type;
+ $product_static->id=$line->fk_product;
+ $product_static->ref=$line->ref;
+ $product_static->status_batch=$line->product_tobatch;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.(! empty($line->label)?$line->label:$line->product_label);
+ $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->desc));
+ print $form->textwithtooltip($text,$description,3,'','',$i);
- print ' ';
- }
- else
- {
- print "";
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ // Show range
+ print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end));
- if (! empty($line->label)) {
- $text.= ' '.$line->label.' ';
- print $form->textwithtooltip($text,$line->desc,3,'','',$i);
- } else {
- print $text.' '.nl2br($line->desc);
- }
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print ($line->desc && $line->desc!=$line->product_label)?' '.dol_htmlentitiesbr($line->desc):'';
+ }
- // Show range
- print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end));
- print " \n";
- }
-
- // Qty
- print ''.$line->qty;
- print ' ';
- print ' ';
- $qtyProdCom=$line->qty;
-
- // Qty already shipped
- print '';
- $quantityDelivered = $object->expeditions[$line->id];
- print $quantityDelivered;
- print ' ';
- print ' ';
-
- // Qty to ship
- $quantityAsked = $line->qty;
- if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $quantityToBeDelivered = 0;
- }
- else
- {
- $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
- }
- $warehouse_id = GETPOST('entrepot_id','int');
-
- $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
- {
- print '';
- //ship from preselected location
- $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number
- $deliverableQty=min($quantityToBeDelivered, $stock);
- if ($deliverableQty < 0) $deliverableQty = 0;
- if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
+ print '';
+ }
+ else
{
- // Quantity to send
- print '';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int');
- print ' ';
- print ' ';
- }
- else print $langs->trans("NA");
- print ' ';
+ print "";
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
- // Stock
- if (! empty($conf->stock->enabled))
- {
- print ' ';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ?
- {
- // Show warehouse combo list
- $ent = "entl".$indiceAsked;
- $idl = "idl".$indiceAsked;
- $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id;
- if ($line->fk_product > 0)
- {
- print '';
- print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1);
- if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id)
- {
- //print $stock.' '.$quantityToBeDelivered;
- if ($stock < $quantityToBeDelivered)
- {
- print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse
- }
- }
- }
- }
- else
- {
- print $langs->trans("Service");
- }
- print ' ';
- }
+ if (! empty($line->label)) {
+ $text.= ' '.$line->label.' ';
+ print $form->textwithtooltip($text,$line->desc,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($line->desc);
+ }
- print " \n";
+ // Show range
+ print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end));
+ print "\n";
+ }
- // Show subproducts of product
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
- {
- $product->get_sousproduits_arbo();
- $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
- if(count($prods_arbo) > 0)
- {
- foreach($prods_arbo as $key => $value)
- {
- //print $value[0];
- $img='';
- if ($value['stock'] < $value['stock_alert'])
- {
- $img=img_warning($langs->trans("StockTooLow"));
- }
- print " ->
- ".$value['fullpath']."
- (".$value['nb'].") ".$value['nb_total']."    
- ".$value['stock']." ".$img." ";
- }
- }
- }
+ // Qty
+ print ''.$line->qty;
+ print ' ';
+ print ' ';
+ $qtyProdCom=$line->qty;
+
+ // Qty already shipped
+ print '';
+ $quantityDelivered = $object->expeditions[$line->id];
+ print $quantityDelivered;
+ print ' ';
+ print ' ';
+
+ // Qty to ship
+ $quantityAsked = $line->qty;
+ if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ $quantityToBeDelivered = 0;
}
else
{
- // Product need lot
- print ' '; // end line and start a new one for lot/serial
- print '';
+ $quantityToBeDelivered = $quantityAsked - $quantityDelivered;
+ }
+ $warehouse_id = GETPOST('entrepot_id','int');
- $staticwarehouse=new Entrepot($db);
- if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id);
-
- $subj=0;
- // Define nb of lines suggested for this order line
- $nbofsuggested=0;
- if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
+ $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
+ {
+ print '';
+ //ship from preselected location
+ $stock = + $product->stock_warehouse[$warehouse_id]->real; // Convert to number
+ $deliverableQty=min($quantityToBeDelivered, $stock);
+ if ($deliverableQty < 0) $deliverableQty = 0;
+ if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
{
- foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
- {
- $nbofsuggested++;
- }
- }
- print ' ';
- if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
- {
- foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch
+ // Quantity to send
+ print '';
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
- //var_dump($dbatch);
- $batchStock = + $dbatch->qty; // To get a numeric
- $deliverableQty = min($quantityToBeDelivered,$batchStock);
- print ' ';
- print '';
- print ' ';
- print ' ';
+ if (GETPOST('qtyl'.$indiceAsked, 'int')) $deliverableQty=GETPOST('qtyl'.$indiceAsked, 'int');
+ print ' ';
+ print ' ';
+ }
+ else print $langs->trans("NA");
+ print '';
- print '';
+ // Stock
+ if (! empty($conf->stock->enabled))
+ {
print '';
-
- print $staticwarehouse->getNomUrl(0).' / ';
-
- print ' ';
-
- $detail='';
- $detail.= $langs->trans("Batch").': '.$dbatch->batch;
- $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
- $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
- $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
- $detail.= ' ';
- print $detail;
-
- $quantityToBeDelivered -= $deliverableQty;
- if ($quantityToBeDelivered < 0)
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ?
{
- $quantityToBeDelivered = 0;
+ // Show warehouse combo list
+ $ent = "entl".$indiceAsked;
+ $idl = "idl".$indiceAsked;
+ $tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):$warehouse_id;
+ if ($line->fk_product > 0)
+ {
+ print '';
+ print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1);
+ if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id)
+ {
+ //print $stock.' '.$quantityToBeDelivered;
+ if ($stock < $quantityToBeDelivered)
+ {
+ print ' '.img_warning($langs->trans("StockTooLow")); // Stock too low for this $warehouse_id but you can change warehouse
+ }
+ }
+ }
+ }
+ else
+ {
+ print $langs->trans("Service");
+ }
+ print ' ';
+ }
+
+ print " \n";
+
+ // Show subproducts of product
+ if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
+ {
+ $product->get_sousproduits_arbo();
+ $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
+ if(count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
+ {
+ //print $value[0];
+ $img='';
+ if ($value['stock'] < $value['stock_alert'])
+ {
+ $img=img_warning($langs->trans("StockTooLow"));
+ }
+ print " ->
+ ".$value['fullpath']."
+ (".$value['nb'].") ".$value['nb_total']."    
+ ".$value['stock']." ".$img." ";
+ }
}
- $subj++;
- print '';
}
}
else
{
- print '';
- print '';
- print ' ';
- print ' ';
+ // Product need lot
+ print ' '; // end line and start a new one for lot/serial
+ print '';
- print '';
- print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
- print ' ';
- }
- }
- }
- else
- {
- // ship from multiple locations
- if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
- {
- print '';
- print ' '."\n"; // end line and start a new one for each warehouse
+ $staticwarehouse=new Entrepot($db);
+ if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id);
- print ' ';
- $subj=0;
- // Define nb of lines suggested for this order line
- $nbofsuggested=0;
- foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
- {
- if ($stock_warehouse->real > 0)
+ $subj=0;
+ // Define nb of lines suggested for this order line
+ $nbofsuggested=0;
+ if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
{
- $nbofsuggested++;
+ foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch)
+ {
+ $nbofsuggested++;
+ }
}
- }
- $tmpwarehouseObject=new Entrepot($db);
- foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock
- {
- $tmpwarehouseObject->fetch($warehouse_id);
- if ($stock_warehouse->real > 0)
+ print ' ';
+ if (is_object($product->stock_warehouse[$warehouse_id]) && count($product->stock_warehouse[$warehouse_id]->detail_batch))
{
- $stock = + $stock_warehouse->real; // Convert it to number
- $deliverableQty = min($quantityToBeDelivered,$stock);
- $deliverableQty = max(0, $deliverableQty);
- // Quantity to send
- print '';
- print '';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- print ' ';
- print ' ';
- }
- else print $langs->trans("NA");
- print ' ';
-
- // Stock
- if (! empty($conf->stock->enabled))
- {
- print '';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- print $tmpwarehouseObject->getNomUrl(0).' ';
-
- print '';
- print '('.$stock.')';
- }
- else
- {
- print $langs->trans("Service");
- }
- print ' ';
- }
- $quantityToBeDelivered -= $deliverableQty;
- if ($quantityToBeDelivered < 0)
- {
- $quantityToBeDelivered = 0;
- }
- $subj++;
- print " \n";
- }
- }
- // Show subproducts of product (not recommanded)
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
- {
- $product->get_sousproduits_arbo();
- $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
- if (count($prods_arbo) > 0)
- {
- foreach($prods_arbo as $key => $value)
- {
- //print $value[0];
- $img='';
- if ($value['stock'] < $value['stock_alert'])
- {
- $img=img_warning($langs->trans("StockTooLow"));
- }
- print '';
- print " ->
- ".$value['fullpath']."
- (".$value['nb'].") ".$value['nb_total']."    
- ".$value['stock']." ".$img." ";
- print " ";
- }
- }
- }
- }
- else
- {
- print '';
- print ' '; // end line and start a new one for lot/serial
-
- $subj=0;
- print ' ';
-
- $tmpwarehouseObject=new Entrepot($db);
- $productlotObject=new Productlot($db);
- // Define nb of lines suggested for this order line
- $nbofsuggested=0;
- foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
- {
- if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
- foreach ($stock_warehouse->detail_batch as $dbatch)
- {
- $nbofsuggested++;
- }
- }
- }
- foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
- {
- $tmpwarehouseObject->fetch($warehouse_id);
- if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
- foreach ($stock_warehouse->detail_batch as $dbatch)
+ foreach ($product->stock_warehouse[$warehouse_id]->detail_batch as $dbatch) // $dbatch is instance of Productbatch
{
//var_dump($dbatch);
$batchStock = + $dbatch->qty; // To get a numeric
$deliverableQty = min($quantityToBeDelivered,$batchStock);
- if ($deliverableQty < 0) $deliverableQty = 0;
- print '';
+ print ' ';
+ print '';
print ' ';
print ' ';
+ print '';
print '';
- print $tmpwarehouseObject->getNomUrl(0).' / ';
+ print $staticwarehouse->getNomUrl(0).' / ';
- print '';
print ' ';
- //print '|'.$line->fk_product.'|'.$dbatch->batch.'| ';
- print $langs->trans("Batch").': ';
- $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
- if ($result > 0) print $productlotObject->getNomUrl(1);
- else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
- print ' ('.$dbatch->qty.')';
+ $detail='';
+ $detail.= $langs->trans("Batch").': '.$dbatch->batch;
+ $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
+ $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
+ $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
+ $detail.= ' ';
+ print $detail;
+
$quantityToBeDelivered -= $deliverableQty;
if ($quantityToBeDelivered < 0)
{
$quantityToBeDelivered = 0;
}
- //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock);
$subj++;
print ' ';
}
}
+ else
+ {
+ print '';
+ print '';
+ print ' ';
+ print ' ';
+
+ print '';
+ print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
+ print ' ';
+ }
}
}
- if ($subj == 0) // Line not shown yet, we show it
+ else
{
- print '';
- print '';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ // ship from multiple locations
+ if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
{
- $disabled='';
- if (! empty($conf->productbatch->enabled) && $product->hasbatch())
- {
- $disabled='disabled="disabled"';
- }
- print ' ';
- }
- else
- {
- print $langs->trans("NA");
- }
- print ' ';
+ print '';
+ print ' '."\n"; // end line and start a new one for each warehouse
- print '';
- if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $warehouse_selected_id = GETPOST('entrepot_id','int');
- if ($warehouse_selected_id > 0)
- {
- $warehouseObject=new Entrepot($db);
- $warehouseObject->fetch($warehouse_selected_id);
- print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle);
- }
- else
- {
- if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow");
- else print '';
- }
+ print ' ';
+ $subj=0;
+ // Define nb of lines suggested for this order line
+ $nbofsuggested=0;
+ foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
+ {
+ if ($stock_warehouse->real > 0)
+ {
+ $nbofsuggested++;
+ }
+ }
+ $tmpwarehouseObject=new Entrepot($db);
+ foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock
+ {
+ $tmpwarehouseObject->fetch($warehouse_id);
+ if ($stock_warehouse->real > 0)
+ {
+ $stock = + $stock_warehouse->real; // Convert it to number
+ $deliverableQty = min($quantityToBeDelivered,$stock);
+ $deliverableQty = max(0, $deliverableQty);
+ // Quantity to send
+ print ' ';
+ print '';
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ print ' ';
+ print ' ';
+ }
+ else print $langs->trans("NA");
+ print ' ';
+
+ // Stock
+ if (! empty($conf->stock->enabled))
+ {
+ print '';
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ print $tmpwarehouseObject->getNomUrl(0).' ';
+
+ print '';
+ print '('.$stock.')';
+
+ }
+ else
+ {
+ print $langs->trans("Service");
+ }
+ print ' ';
+ }
+ $quantityToBeDelivered -= $deliverableQty;
+ if ($quantityToBeDelivered < 0)
+ {
+ $quantityToBeDelivered = 0;
+ }
+ $subj++;
+ print " \n";
+ }
+ }
+ // Show subproducts of product (not recommanded)
+ if (! empty($conf->global->PRODUIT_SOUSPRODUITS) && $line->fk_product > 0)
+ {
+ $product->get_sousproduits_arbo();
+ $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
+ if (count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
+ {
+ //print $value[0];
+ $img='';
+ if ($value['stock'] < $value['stock_alert'])
+ {
+ $img=img_warning($langs->trans("StockTooLow"));
+ }
+ print '';
+ print " ->
+ ".$value['fullpath']."
+ (".$value['nb'].") ".$value['nb_total']."    
+ ".$value['stock']." ".$img." ";
+ print " ";
+ }
+ }
+ }
}
else
{
- print $langs->trans("Service");
+ print '';
+ print ' '; // end line and start a new one for lot/serial
+
+ $subj=0;
+ print ' ';
+
+ $tmpwarehouseObject=new Entrepot($db);
+ $productlotObject=new Productlot($db);
+ // Define nb of lines suggested for this order line
+ $nbofsuggested=0;
+ foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
+ {
+ if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
+ foreach ($stock_warehouse->detail_batch as $dbatch)
+ {
+ $nbofsuggested++;
+ }
+ }
+ }
+ foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse)
+ {
+ $tmpwarehouseObject->fetch($warehouse_id);
+ if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) {
+ foreach ($stock_warehouse->detail_batch as $dbatch)
+ {
+ //var_dump($dbatch);
+ $batchStock = + $dbatch->qty; // To get a numeric
+ $deliverableQty = min($quantityToBeDelivered,$batchStock);
+ if ($deliverableQty < 0) $deliverableQty = 0;
+ print '';
+ print ' ';
+ print ' ';
+
+ print '';
+
+ print $tmpwarehouseObject->getNomUrl(0).' / ';
+
+ print '';
+ print ' ';
+
+ //print '|'.$line->fk_product.'|'.$dbatch->batch.'| ';
+ print $langs->trans("Batch").': ';
+ $result = $productlotObject->fetch(0, $line->fk_product, $dbatch->batch);
+ if ($result > 0) print $productlotObject->getNomUrl(1);
+ else print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
+ print ' ('.$dbatch->qty.')';
+ $quantityToBeDelivered -= $deliverableQty;
+ if ($quantityToBeDelivered < 0)
+ {
+ $quantityToBeDelivered = 0;
+ }
+ //dol_syslog('deliverableQty = '.$deliverableQty.' batchStock = '.$batchStock);
+ $subj++;
+ print ' ';
+ }
+ }
+ }
+
}
- print '';
+ if ($subj == 0) // Line not shown yet, we show it
+ {
+ print '';
+ print '';
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ $disabled='';
+ if (! empty($conf->productbatch->enabled) && $product->hasbatch())
+ {
+ $disabled='disabled="disabled"';
+ }
+ print ' ';
+ }
+ else
+ {
+ print $langs->trans("NA");
+ }
+ print ' ';
+
+ print '';
+ if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
+ {
+ $warehouse_selected_id = GETPOST('entrepot_id','int');
+ if ($warehouse_selected_id > 0)
+ {
+ $warehouseObject=new Entrepot($db);
+ $warehouseObject->fetch($warehouse_selected_id);
+ print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->libelle);
+ }
+ else
+ {
+ if ($line->fk_product) print img_warning().' '.$langs->trans("StockTooLow");
+ else print '';
+ }
+ }
+ else
+ {
+ print $langs->trans("Service");
+ }
+ print ' ';
+ print ' ';
+ }
+ }
+
+
+ //Display lines extrafields
+ if (is_array($extralabelslines) && count($extralabelslines)>0)
+ {
+ $colspan=5;
+ $orderLineExtrafields = new Extrafields($db);
+ $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line);
+ $srcLine = new OrderLine($db);
+ $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline
+ $line = new ExpeditionLigne($db);
+ //$line->fetch_optionals($line->id);
+ $line->array_options = array_merge($line->array_options, $srcLine->array_options);
+ print '';
+ print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
print ' ';
}
- }
-
- //Display lines extrafields
- if (is_array($extralabelslines) && count($extralabelslines)>0)
- {
- $colspan=5;
- $orderLineExtrafields = new Extrafields($db);
- $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line);
- $srcLine = new OrderLine($db);
- $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline
- $line = new ExpeditionLigne($db);
- //$line->fetch_optionals($line->id);
- $line->array_options = array_merge($line->array_options, $srcLine->array_options);
- print '';
- print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
- print ' ';
- }
-
- $indiceAsked++;
+ $indiceAsked++;
+ }
}
print "";
@@ -1978,6 +1986,11 @@ else if ($id || $ref)
print '';
}
+ // Other attributes
+ $parameters = array('colspan' => ' colspan="3"');
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+
print "";
print '';
@@ -2132,298 +2145,305 @@ else if ($id || $ref)
// Loop on each product to send/sent
for ($i = 0 ; $i < $num_prod ; $i++)
{
- print ''; // id of order line
- print '';
+ $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- // Adds a line numbering column
- if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
+ if(empty($reshook))
{
- print ''.($i+1).' ';
- }
+ print ''; // id of order line
+ print ' ';
- // Predefined product or service
- if ($lines[$i]->fk_product > 0)
- {
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ // #
+ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
{
- $prod = new Product($db);
- $prod->fetch($lines[$i]->fk_product);
- $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
+ print ''.($i+1).' ';
+ }
+
+ // Predefined product or service
+ if ($lines[$i]->fk_product > 0)
+ {
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $prod = new Product($db);
+ $prod->fetch($lines[$i]->fk_product);
+ $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
+ }
+ else
+ $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label);
+
+ print '';
+
+ // Show product and description
+ $product_static->type=$lines[$i]->fk_product_type;
+ $product_static->id=$lines[$i]->fk_product;
+ $product_static->ref=$lines[$i]->ref;
+ $product_static->status_batch=$lines[$i]->product_tobatch;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.$label;
+ $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description));
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+ print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?' '.dol_htmlentitiesbr($lines[$i]->description):'';
+ }
+ print " \n";
}
else
- $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label);
-
- print '';
-
- // Show product and description
- $product_static->type=$lines[$i]->fk_product_type;
- $product_static->id=$lines[$i]->fk_product;
- $product_static->ref=$lines[$i]->ref;
- $product_static->status_batch=$lines[$i]->product_tobatch;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.$label;
- $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description));
- print $form->textwithtooltip($text,$description,3,'','',$i);
- print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
- print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?' '.dol_htmlentitiesbr($lines[$i]->description):'';
- }
- print " \n";
- }
- else
- {
- print "";
- if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ print " ";
+ if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
- if (! empty($lines[$i]->label)) {
- $text.= ' '.$lines[$i]->label.' ';
- print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i);
- } else {
- print $text.' '.nl2br($lines[$i]->description);
- }
-
- print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
- print " \n";
- }
-
- // Qty ordered
- print ''.$lines[$i]->qty_asked.' ';
-
- // Qty in other shipments (with shipment and warehouse used)
- if ($origin && $origin_id > 0)
- {
- print '';
- foreach ($alreadysent as $key => $val)
- {
- if ($lines[$i]->fk_origin_line == $key)
- {
- $j = 0;
- foreach($val as $shipmentline_id=> $shipmentline_var)
- {
- if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments"
-
- $j++;
- if ($j > 1) print ' ';
- $shipment_static->fetch($shipmentline_var['shipment_id']);
- print $shipment_static->getNomUrl(1);
- print ' - '.$shipmentline_var['qty_shipped'];
- $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour'));
- if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0)
- {
- $warehousestatic->fetch($shipmentline_var['warehouse']);
- $htmltext .= ' '.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1);
- }
- print ' '.$form->textwithpicto('', $htmltext, 1);
- }
- }
- }
- }
- print ' ';
-
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- // edit mode
- print '';
- if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
- {
- print '';
- $line = new ExpeditionLigne($db);
- foreach ($lines[$i]->detail_batch as $detail_batch)
- {
- print '';
- // Qty to ship or shipped
- print '' . ' ' . ' ';
- // Batch number managment
- if ($lines[$i]->entrepot_id == 0)
- {
- // only show lot numbers from src warehouse when shipping from multiple warehouses
- $line->fetch($detail_batch->fk_expeditiondet);
- }
- print '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). ' ';
- print ' ';
+ if (! empty($lines[$i]->label)) {
+ $text.= ' '.$lines[$i]->label.' ';
+ print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($lines[$i]->description);
}
- // add a 0 qty lot row to be able to add a lot
- print '';
- // Qty to ship or shipped
- print '' . ' ' . ' ';
- // Batch number managment
- print '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). ' ';
- print ' ';
+
+ print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
+ print "\n";
}
- else if (! empty($conf->stock->enabled))
+
+ // Qty ordered
+ print ''.$lines[$i]->qty_asked.' ';
+
+ // Qty in other shipments (with shipment and warehouse used)
+ if ($origin && $origin_id > 0)
+ {
+ print '';
+ foreach ($alreadysent as $key => $val)
+ {
+ if ($lines[$i]->fk_origin_line == $key)
+ {
+ $j = 0;
+ foreach($val as $shipmentline_id=> $shipmentline_var)
+ {
+ if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments"
+
+ $j++;
+ if ($j > 1) print ' ';
+ $shipment_static->fetch($shipmentline_var['shipment_id']);
+ print $shipment_static->getNomUrl(1);
+ print ' - '.$shipmentline_var['qty_shipped'];
+ $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour'));
+ if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0)
+ {
+ $warehousestatic->fetch($shipmentline_var['warehouse']);
+ $htmltext .= ' '.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1);
+ }
+ print ' '.$form->textwithpicto('', $htmltext, 1);
+ }
+ }
+ }
+ }
+ print ' ';
+
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
{
- if ($lines[$i]->fk_product > 0)
+ // edit mode
+ print '';
+ if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
{
- if ($lines[$i]->entrepot_id > 0)
+ print '';
+ $line = new ExpeditionLigne($db);
+ foreach ($lines[$i]->detail_batch as $detail_batch)
{
- print '';
print '';
// Qty to ship or shipped
- print '' . ' ' . ' ';
- // Warehouse source
- print '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' ';
+ print '' . ' ' . ' ';
// Batch number managment
- print ' - ' . $langs->trans("NA") . ' ';
+ if ($lines[$i]->entrepot_id == 0)
+ {
+ // only show lot numbers from src warehouse when shipping from multiple warehouses
+ $line->fetch($detail_batch->fk_expeditiondet);
+ }
+ print '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). ' ';
print ' ';
}
- else if (count($lines[$i]->details_entrepot) > 1)
+ // add a 0 qty lot row to be able to add a lot
+ print '';
+ // Qty to ship or shipped
+ print '' . ' ' . ' ';
+ // Batch number managment
+ print '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). ' ';
+ print ' ';
+ }
+ else if (! empty($conf->stock->enabled))
+ {
+ if ($lines[$i]->fk_product > 0)
{
- print '';
- foreach ($lines[$i]->details_entrepot as $detail_entrepot)
+ if ($lines[$i]->entrepot_id > 0)
{
+ print '';
print '';
// Qty to ship or shipped
- print '' . ' ' . ' ';
+ print '' . ' ' . ' ';
// Warehouse source
- print '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' ';
+ print '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' ';
// Batch number managment
print ' - ' . $langs->trans("NA") . ' ';
print ' ';
}
+ else if (count($lines[$i]->details_entrepot) > 1)
+ {
+ print '';
+ foreach ($lines[$i]->details_entrepot as $detail_entrepot)
+ {
+ print '';
+ // Qty to ship or shipped
+ print '' . ' ' . ' ';
+ // Warehouse source
+ print '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' ';
+ // Batch number managment
+ print ' - ' . $langs->trans("NA") . ' ';
+ print ' ';
+ }
+ }
+ else
+ {
+ print '';
+ print ''.$langs->trans("NotEnoughStock").' ';
+ }
}
else
{
- print '';
- print ''.$langs->trans("NotEnoughStock").' ';
+ print '';
+ print '';
+ // Qty to ship or shipped
+ print '' . ' ' . ' ';
+ // Warehouse source
+ print '' . ' ';
+ // Batch number managment
+ print '' . ' ';
+ print ' ';
}
}
- else
- {
- print '';
- print '';
- // Qty to ship or shipped
- print '' . ' ' . ' ';
- // Warehouse source
- print '' . ' ';
- // Batch number managment
- print '' . ' ';
- print ' ';
- }
- }
- print '
';
- }
- else
- {
- // Qty to ship or shipped
- print ''.$lines[$i]->qty_shipped.' ';
-
- // Warehouse source
- if (! empty($conf->stock->enabled))
- {
- print '';
- if ($lines[$i]->entrepot_id > 0)
- {
- $entrepot = new Entrepot($db);
- $entrepot->fetch($lines[$i]->entrepot_id);
- print $entrepot->getNomUrl(1);
- }
- else if (count($lines[$i]->details_entrepot) > 1)
- {
- $detail = '';
- foreach ($lines[$i]->details_entrepot as $detail_entrepot)
- {
- if ($detail_entrepot->entrepot_id > 0)
- {
- $entrepot = new Entrepot($db);
- $entrepot->fetch($detail_entrepot->entrepot_id);
- $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).' ';
- }
- }
- print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail);
- }
- print ' ';
- }
-
- // Batch number managment
- if (! empty($conf->productbatch->enabled))
- {
- if (isset($lines[$i]->detail_batch))
- {
- print '';
- print '';
- if ($lines[$i]->product_tobatch)
- {
- $detail = '';
- foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch
- {
- $detail.= $langs->trans("Batch").': '.$dbatch->batch;
- $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
- $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
- $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
- $detail.= ' ';
- }
- print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
- }
- else
- {
- print $langs->trans("NA");
- }
- print ' ';
- } else {
- print ' ';
- }
- }
- }
-
- // Weight
- print '';
- if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight");
- else print ' ';
- print ' ';
-
- // Volume
- print '';
- if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume");
- else print ' ';
- print ' ';
-
- // Size
- //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").' ';
-
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- print '';
- print ' ';
- print ' ';
- }
- else if ($object->statut == 0)
- {
- // edit-delete buttons
- print ' ';
- print 'id . '&action=editline&lineid=' . $lines[$i]->id . '">' . img_edit() . ' ';
- print ' ';
- print '';
- print 'id . '&action=deleteline&lineid=' . $lines[$i]->id . '">' . img_delete() . ' ';
- print ' ';
-
- // Display lines extrafields
- if (! empty($rowExtrafieldsStart))
- {
- print $rowExtrafieldsStart;
- print $rowExtrafieldsView;
- print $rowEnd;
- }
- }
- print "";
-
- // Display lines extrafields
- if (is_array($extralabelslines) && count($extralabelslines)>0) {
- $colspan= empty($conf->productbatch->enabled) ? 5 : 6;
- $line = new ExpeditionLigne($db);
- $line->fetch_optionals($lines[$i]->id);
- print '';
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ print '
';
}
else
{
- print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ // Qty to ship or shipped
+ print ''.$lines[$i]->qty_shipped.' ';
+
+ // Warehouse source
+ if (! empty($conf->stock->enabled))
+ {
+ print '';
+ if ($lines[$i]->entrepot_id > 0)
+ {
+ $entrepot = new Entrepot($db);
+ $entrepot->fetch($lines[$i]->entrepot_id);
+ print $entrepot->getNomUrl(1);
+ }
+ else if (count($lines[$i]->details_entrepot) > 1)
+ {
+ $detail = '';
+ foreach ($lines[$i]->details_entrepot as $detail_entrepot)
+ {
+ if ($detail_entrepot->entrepot_id > 0)
+ {
+ $entrepot = new Entrepot($db);
+ $entrepot->fetch($detail_entrepot->entrepot_id);
+ $detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).' ';
+ }
+ }
+ print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail);
+ }
+ print ' ';
+ }
+
+ // Batch number managment
+ if (! empty($conf->productbatch->enabled))
+ {
+ if (isset($lines[$i]->detail_batch))
+ {
+ print '';
+ print '';
+ if ($lines[$i]->product_tobatch)
+ {
+ $detail = '';
+ foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch
+ {
+ $detail.= $langs->trans("Batch").': '.$dbatch->batch;
+ $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
+ $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
+ $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
+ $detail.= ' ';
+ }
+ print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
+ }
+ else
+ {
+ print $langs->trans("NA");
+ }
+ print ' ';
+ } else {
+ print ' ';
+ }
+ }
+ }
+
+ // Weight
+ print '';
+ if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight");
+ else print ' ';
+ print ' ';
+
+ // Volume
+ print '';
+ if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume");
+ else print ' ';
+ print ' ';
+
+ // Size
+ //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").' ';
+
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ else if ($object->statut == 0)
+ {
+ // edit-delete buttons
+ print ' ';
+ print 'id . '&action=editline&lineid=' . $lines[$i]->id . '">' . img_edit() . ' ';
+ print ' ';
+ print '';
+ print 'id . '&action=deleteline&lineid=' . $lines[$i]->id . '">' . img_delete() . ' ';
+ print ' ';
+
+ // Display lines extrafields
+ if (! empty($rowExtrafieldsStart))
+ {
+ print $rowExtrafieldsStart;
+ print $rowExtrafieldsView;
+ print $rowEnd;
+ }
+ }
+ print " ";
+
+ // Display lines extrafields
+ if (is_array($extralabelslines) && count($extralabelslines)>0) {
+ $colspan= empty($conf->productbatch->enabled) ? 5 : 6;
+ $line = new ExpeditionLigne($db);
+ $line->fetch_optionals($lines[$i]->id);
+ print '';
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
+ {
+ print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ }
+ else
+ {
+ print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ }
+ print ' ';
}
- print '';
}
}
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index 50307a56f38..039c45125b5 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -44,6 +44,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi
// Load translation files required by the page
$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
+$hookmanager->initHooks(array('ordershipmentcard'));
+
$id=GETPOST('id','int'); // id of order
$ref= GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
@@ -612,6 +614,7 @@ if ($id > 0 || ! empty($ref))
$sql.= " cd.qty,";
$sql.= ' cd.date_start,';
$sql.= ' cd.date_end,';
+ $sql.= ' cd.special_code,';
$sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc';
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@@ -647,164 +650,169 @@ if ($id > 0 || ! empty($ref))
{
$objp = $db->fetch_object($resql);
+ $parameters = array('i' => $i, 'line' => $objp, 'num' => $num);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- // Show product and description
- $type=isset($objp->type)?$objp->type:$objp->product_type;
-
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (! empty($objp->date_start)) $type=1;
- if (! empty($objp->date_end)) $type=1;
-
- print '';
-
- // Product label
- if ($objp->fk_product > 0)
+ if(empty($reshook))
{
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ // Show product and description
+ $type=isset($objp->type)?$objp->type:$objp->product_type;
+
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (! empty($objp->date_start)) $type=1;
+ if (! empty($objp->date_end)) $type=1;
+
+ print ' ';
+
+ // Product label
+ if ($objp->fk_product > 0)
{
- $object->fetch_thirdparty();
-
- $prod = new Product($db);
- $prod->id = $objp->fk_product;
- $prod->entity = $objp->entity;
- $prod->getMultiLangs();
-
- $outputlangs = $langs;
- $newlang='';
- if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
- if (! empty($newlang))
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
+ $object->fetch_thirdparty();
+
+ $prod = new Product($db);
+ $prod->id = $objp->fk_product;
+ $prod->entity = $objp->entity;
+ $prod->getMultiLangs();
+
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ }
+ else
+ $label = (! empty($objp->label)?$objp->label:$objp->product_label);
+
+ print '';
+ print ' '; // ancre pour retourner sur la ligne
+
+ // Show product and description
+ $product_static->type=$type;
+ $product_static->id=$objp->fk_product;
+ $product_static->ref=$objp->ref;
+ $product_static->entity = $objp->entity;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.$label;
+ $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).' ';
+ $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
}
- $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ print ' ';
}
else
- $label = (! empty($objp->label)?$objp->label:$objp->product_label);
-
- print '';
- print ' '; // ancre pour retourner sur la ligne
-
- // Show product and description
- $product_static->type=$type;
- $product_static->id=$objp->fk_product;
- $product_static->ref=$objp->ref;
- $product_static->entity = $objp->entity;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.$label;
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).' ';
- $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
- print $form->textwithtooltip($text,$description,3,'','',$i);
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
-
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
- print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
+ print " ";
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($objp->label)) {
+ $text.= ' '.$objp->label.' ';
+ print $form->textwithtooltip($text,$objp->description,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($objp->description);
+ }
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+ print " \n";
}
- print '';
- }
- else
- {
- print "";
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ // Qty ordered
+ print ' ' . $objp->qty . ' ';
- if (! empty($objp->label)) {
- $text.= ' '.$objp->label.' ';
- print $form->textwithtooltip($text,$objp->description,3,'','',$i);
- } else {
- print $text.' '.nl2br($objp->description);
- }
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
- print "\n";
- }
-
- // Qty ordered
- print '' . $objp->qty . ' ';
-
- // Qty already shipped
- $qtyProdCom=$objp->qty;
- print '';
- // Nb of sending products for this line of order
- $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
- print $qtyAlreadyShipped;
- print ' ';
-
- // Qty remains to ship
- print '';
- if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
- $toBeShippedTotal += $toBeShipped[$objp->fk_product];
- print $toBeShipped[$objp->fk_product];
- }
- else
- {
- print '0 ('.$langs->trans("Service").')';
- }
- print ' ';
-
- if ($objp->fk_product > 0)
- {
- $product = new Product($db);
- $product->fetch($objp->fk_product);
- $product->load_stock('warehouseopen');
- }
-
- if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
- {
+ // Qty already shipped
+ $qtyProdCom=$objp->qty;
print '';
- print $product->stock_reel;
- if ($product->stock_reel < $toBeShipped[$objp->fk_product])
+ // Nb of sending products for this line of order
+ $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
+ print $qtyAlreadyShipped;
+ print ' ';
+
+ // Qty remains to ship
+ print '';
+ if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
- print ' '.img_warning($langs->trans("StockTooLow"));
+ $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
+ $toBeShippedTotal += $toBeShipped[$objp->fk_product];
+ print $toBeShipped[$objp->fk_product];
+ }
+ else
+ {
+ print '0 ('.$langs->trans("Service").')';
}
print ' ';
- }
- else
- {
- print ' ';
- }
- print " \n";
- // Show subproducts lines
- if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
- // Set tree of subproducts in product->sousprods
- $product->get_sousproduits_arbo();
- //var_dump($product->sousprods);exit;
-
- // Define a new tree with quantiies recalculated
- $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
- //var_dump($prods_arbo);
- if (count($prods_arbo) > 0)
+ if ($objp->fk_product > 0)
{
- foreach($prods_arbo as $key => $value)
+ $product = new Product($db);
+ $product->fetch($objp->fk_product);
+ $product->load_stock('warehouseopen');
+ }
+
+ if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
+ {
+ print '';
+ print $product->stock_reel;
+ if ($product->stock_reel < $toBeShipped[$objp->fk_product])
{
- $img='';
- if ($value['stock'] < $value['stock_alert'])
+ print ' '.img_warning($langs->trans("StockTooLow"));
+ }
+ print ' ';
+ }
+ else
+ {
+ print ' ';
+ }
+ print "\n";
+
+ // Show subproducts lines
+ if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ // Set tree of subproducts in product->sousprods
+ $product->get_sousproduits_arbo();
+ //var_dump($product->sousprods);exit;
+
+ // Define a new tree with quantiies recalculated
+ $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
+ //var_dump($prods_arbo);
+ if (count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
{
- $img=img_warning($langs->trans("StockTooLow"));
+ $img='';
+ if ($value['stock'] < $value['stock_alert'])
+ {
+ $img=img_warning($langs->trans("StockTooLow"));
+ }
+ print ' -> '.$value['fullpath'].' ('.$value['nb'].') ';
+ print ' '.$value['nb_total'].' ';
+ print '  ';
+ print '  ';
+ print ''.$value['stock'].' '.$img.' '."\n";
}
- print ' -> '.$value['fullpath'].' ('.$value['nb'].') ';
- print ' '.$value['nb_total'].' ';
- print '  ';
- print '  ';
- print ''.$value['stock'].' '.$img.' '."\n";
}
}
}
-
$i++;
}
$db->free($resql);
diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php
index 5344e3765d7..cb70ebf4683 100644
--- a/htdocs/hrm/index.php
+++ b/htdocs/hrm/index.php
@@ -324,7 +324,7 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
{
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut, u.photo, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
- if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE u.rowid = x.fk_user_author";
$sql.= " AND x.entity = ".$conf->entity;
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')';
diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php
index 36847d9c670..f567773d714 100644
--- a/htdocs/livraison/card.php
+++ b/htdocs/livraison/card.php
@@ -604,85 +604,94 @@ else
}
while ($i < $num_prod)
{
- print '';
- if ($object->lines[$i]->fk_product > 0)
+ $parameters = array('i' => $i, 'line' => $object->lines[$i], 'num' => $num_prod);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ if (empty($reshook))
{
- $product = new Product($db);
- $product->fetch($object->lines[$i]->fk_product);
-
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ print ' ';
+ if ($object->lines[$i]->fk_product > 0)
{
- $outputlangs = $langs;
- $newlang='';
- if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ $product = new Product($db);
+ $product->fetch($object->lines[$i]->fk_product);
- $label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $outputlangs = $langs;
+ $newlang = '';
+ if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
+ if (empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $label = (!empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $object->lines[$i]->product_label;
+ }
+ else
+ {
+ $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : $object->lines[$i]->product_label);
+ }
+
+ print '';
+
+ // Affiche ligne produit
+ $text = '';
+ if ($object->lines[$i]->fk_product_type == 1) $text .= img_object($langs->trans('ShowService'), 'service');
+ else $text .= img_object($langs->trans('ShowProduct'), 'product');
+ $text .= ' ' . $object->lines[$i]->product_ref . ' ';
+ $text .= ' - ' . $label;
+ $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($object->lines[$i]->description));
+ //print $description;
+ print $form->textwithtooltip($text, $description, 3, '', '', $i);
+ print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
+ if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print (!empty($object->lines[$i]->description) && $object->lines[$i]->description != $object->lines[$i]->product_label) ? ' ' . dol_htmlentitiesbr($object->lines[$i]->description) : '';
+ }
}
else
- $label = ( ! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
-
- print ' ';
-
- // Affiche ligne produit
- $text = '';
- if ($object->lines[$i]->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
- else $text.= img_object($langs->trans('ShowProduct'),'product');
- $text.= ' '.$object->lines[$i]->product_ref.' ';
- $text.= ' - '.$label;
- $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->description));
- //print $description;
- print $form->textwithtooltip($text,$description,3,'','',$i);
- print_date_range($object->lines[$i]->date_start,$object->lines[$i]->date_end);
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
- print (! empty($object->lines[$i]->description) && $object->lines[$i]->description!=$object->lines[$i]->product_label)?' '.dol_htmlentitiesbr($object->lines[$i]->description):'';
- }
- }
- else
- {
- print " ";
- if ($object->lines[$i]->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ print " ";
+ if ($object->lines[$i]->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service');
+ else $text = img_object($langs->trans('Product'), 'product');
- if (! empty($object->lines[$i]->label)) {
- $text.= ' '.$object->lines[$i]->label.' ';
- print $form->textwithtooltip($text,$object->lines[$i]->description,3,'','',$i);
- } else {
- print $text.' '.nl2br($object->lines[$i]->description);
+ if (!empty($object->lines[$i]->label)) {
+ $text .= ' ' . $object->lines[$i]->label . ' ';
+ print $form->textwithtooltip($text, $object->lines[$i]->description, 3, '', '', $i);
+ } else {
+ print $text . ' ' . nl2br($object->lines[$i]->description);
+ }
+
+ print_date_range($objp->date_start, $objp->date_end);
+ print " \n";
}
- print_date_range($objp->date_start,$objp->date_end);
- print "\n";
- }
+ print '' . $object->lines[$i]->qty_asked . ' ';
+ print '' . $object->lines[$i]->qty_shipped . ' ';
- print ''.$object->lines[$i]->qty_asked.' ';
- print ''.$object->lines[$i]->qty_shipped.' ';
+ print " ";
- print "";
-
- //Display lines extrafields
- if (is_array($extralabelslines) && count($extralabelslines)>0) {
- $colspan=2;
- $mode = ($object->statut == 0) ? 'edit' : 'view';
- $line = new LivraisonLigne($db);
- $line->fetch_optionals($object->lines[$i]->id);
- if ($action = 'create_delivery') {
- $srcLine = new ExpeditionLigne($db);
- $expeditionLineExtrafields = new Extrafields($db);
- $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
- $srcLine->fetch_optionals($expedition->lines[$i]->id);
- $line->array_options = array_merge($line->array_options, $srcLine->array_options);
+ // Display lines extrafields
+ if (is_array($extralabelslines) && count($extralabelslines) > 0) {
+ $colspan = 2;
+ $mode = ($object->statut == 0) ? 'edit' : 'view';
+ $line = new LivraisonLigne($db);
+ $line->fetch_optionals($object->lines[$i]->id);
+ if ($action = 'create_delivery') {
+ $srcLine = new ExpeditionLigne($db);
+ $expeditionLineExtrafields = new Extrafields($db);
+ $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
+ $srcLine->fetch_optionals($expedition->lines[$i]->id);
+ $line->array_options = array_merge($line->array_options, $srcLine->array_options);
+ }
+ print '';
+ print $line->showOptionals($extrafieldsline, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i);
+ print ' ';
}
- print '';
- print $line->showOptionals($extrafieldsline, $mode, array('style'=>'class="oddeven"', 'colspan'=>$colspan),$i);
- print ' ';
}
$i++;