|
|
|
|
@@ -5,7 +5,7 @@
|
|
|
|
|
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
|
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
|
|
|
|
* Copyright (C) 2013 Cédric Salvador <csalvador.gpcsolutions.fr>
|
|
|
|
|
* Copyright (C) 2013-2015 Juanjo Menent <jmenent@2byte.es>
|
|
|
|
|
* Copyright (C) 2013-2018 Juanjo Menent <jmenent@2byte.es>
|
|
|
|
|
* Copyright (C) 2014-2015 Cédric Gross <c.gross@kreiz-it.fr>
|
|
|
|
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
|
|
|
|
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
|
|
|
|
@@ -45,6 +45,13 @@ if (! empty($conf->projet->enabled))
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($conf->variants->enabled)) {
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttribute.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductAttributeValue.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination2ValuePair.class.php';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadlangs(array('products', 'orders', 'bills', 'stocks', 'sendings'));
|
|
|
|
|
if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
|
|
|
|
|
@@ -518,6 +525,8 @@ if ($id > 0 || $ref)
|
|
|
|
|
$object = new Product($db);
|
|
|
|
|
$result = $object->fetch($id,$ref);
|
|
|
|
|
|
|
|
|
|
$variants = $object->hasVariants();
|
|
|
|
|
|
|
|
|
|
$object->load_stock();
|
|
|
|
|
|
|
|
|
|
$title = $langs->trans('ProductServiceCard');
|
|
|
|
|
@@ -558,174 +567,161 @@ if ($id > 0 || $ref)
|
|
|
|
|
print '<div class="underbanner clearboth"></div>';
|
|
|
|
|
print '<table class="border tableforfield" width="100%">';
|
|
|
|
|
|
|
|
|
|
if ($conf->productbatch->enabled)
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("ManageLotSerial").'</td><td>';
|
|
|
|
|
print $object->getLibStatut(0,2);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
if (! $variants) {
|
|
|
|
|
|
|
|
|
|
// PMP
|
|
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("AverageUnitPricePMP").'</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT");
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
if ($conf->productbatch->enabled) {
|
|
|
|
|
print '<tr><td class="titlefield">' . $langs->trans("ManageLotSerial") . '</td><td>';
|
|
|
|
|
print $object->getLibStatut(0, 2);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Minimum Price
|
|
|
|
|
print '<tr><td>'.$langs->trans("BuyingPriceMin").'</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
$product_fourn = new ProductFournisseur($db);
|
|
|
|
|
if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
|
|
|
|
|
{
|
|
|
|
|
if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
|
|
|
|
|
else print $langs->trans("NotDefined");
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
// PMP
|
|
|
|
|
print '<tr><td class="titlefield">' . $langs->trans("AverageUnitPricePMP") . '</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
if ($object->pmp > 0) print price($object->pmp) . ' ' . $langs->trans("HT");
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
|
|
|
|
{
|
|
|
|
|
// Price
|
|
|
|
|
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
|
|
|
|
if ($object->price_base_type == 'TTC') {
|
|
|
|
|
print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
} else {
|
|
|
|
|
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
// Minimum Price
|
|
|
|
|
print '<tr><td>' . $langs->trans("BuyingPriceMin") . '</td>';
|
|
|
|
|
print '<td>';
|
|
|
|
|
$product_fourn = new ProductFournisseur($db);
|
|
|
|
|
if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) {
|
|
|
|
|
if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
|
|
|
|
|
else print $langs->trans("NotDefined");
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Price minimum
|
|
|
|
|
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
|
|
|
|
if ($object->price_base_type == 'TTC') {
|
|
|
|
|
print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
|
|
|
|
|
// Price
|
|
|
|
|
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
|
|
|
|
if ($object->price_base_type == 'TTC') {
|
|
|
|
|
print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
} else {
|
|
|
|
|
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Price minimum
|
|
|
|
|
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
|
|
|
|
if ($object->price_base_type == 'TTC') {
|
|
|
|
|
print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
} else {
|
|
|
|
|
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
} else {
|
|
|
|
|
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
|
|
|
|
|
// Price
|
|
|
|
|
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
|
|
|
|
print $langs->trans("Variable");
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Price minimum
|
|
|
|
|
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
|
|
|
|
print $langs->trans("Variable");
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Price
|
|
|
|
|
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
|
|
|
|
|
print $langs->trans("Variable");
|
|
|
|
|
|
|
|
|
|
// Stock alert threshold
|
|
|
|
|
print '<tr><td>' . $form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer) . '</td><td>';
|
|
|
|
|
print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Price minimum
|
|
|
|
|
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
|
|
|
|
|
print $langs->trans("Variable");
|
|
|
|
|
// Hook formObject
|
|
|
|
|
$parameters = array();
|
|
|
|
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
|
|
|
|
// Desired stock
|
|
|
|
|
print '<tr><td>' . $form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer);
|
|
|
|
|
print '</td><td>';
|
|
|
|
|
print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer, 'string');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Real stock
|
|
|
|
|
$text_stock_options = $langs->trans("RealStockDesc") . '<br>';
|
|
|
|
|
$text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen") . '<br>';
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? $langs->trans("DeStockOnShipment") . '<br>' : '');
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? $langs->trans("DeStockOnValidateOrder") . '<br>' : '');
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? $langs->trans("DeStockOnBill") . '<br>' : '');
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? $langs->trans("ReStockOnBill") . '<br>' : '');
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? $langs->trans("ReStockOnValidateOrder") . '<br>' : '');
|
|
|
|
|
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? $langs->trans("ReStockOnDispatchOrder") . '<br>' : '');
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td>' . price2num($object->stock_reel, 'MS');
|
|
|
|
|
if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
$stocktheo = price2num($object->stock_theorique, 'MS');
|
|
|
|
|
|
|
|
|
|
$found = 0;
|
|
|
|
|
$helpondiff = '<strong>' . $langs->trans("StockDiffPhysicTeoric") . ':</strong><br>';
|
|
|
|
|
// Number of customer orders running
|
|
|
|
|
if (!empty($conf->commande->enabled)) {
|
|
|
|
|
if ($found) $helpondiff .= '<br>'; else $found = 1;
|
|
|
|
|
$helpondiff .= $langs->trans("ProductQtyInCustomersOrdersRunning") . ': ' . $object->stats_commande['qty'];
|
|
|
|
|
$result = $object->load_stats_commande(0, '0', 1);
|
|
|
|
|
if ($result < 0) dol_print_error($db, $object->error);
|
|
|
|
|
$helpondiff .= ' (' . $langs->trans("ProductQtyInDraft") . ': ' . $object->stats_commande['qty'] . ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of product from customer order already sent (partial shipping)
|
|
|
|
|
if (!empty($conf->expedition->enabled)) {
|
|
|
|
|
if ($found) $helpondiff .= '<br>'; else $found = 1;
|
|
|
|
|
$result = $object->load_stats_sending(0, '2', 1);
|
|
|
|
|
$helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of supplier order running
|
|
|
|
|
if (!empty($conf->fournisseur->enabled)) {
|
|
|
|
|
if ($found) $helpondiff .= '<br>'; else $found = 1;
|
|
|
|
|
$result = $object->load_stats_commande_fournisseur(0, '3,4', 1);
|
|
|
|
|
$helpondiff .= $langs->trans("ProductQtyInSuppliersOrdersRunning") . ': ' . $object->stats_commande_fournisseur['qty'];
|
|
|
|
|
$result = $object->load_stats_commande_fournisseur(0, '0,1,2', 1);
|
|
|
|
|
if ($result < 0) dol_print_error($db, $object->error);
|
|
|
|
|
$helpondiff .= ' (' . $langs->trans("ProductQtyInDraftOrWaitingApproved") . ': ' . $object->stats_commande_fournisseur['qty'] . ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of product from supplier order already received (partial receipt)
|
|
|
|
|
if (!empty($conf->fournisseur->enabled)) {
|
|
|
|
|
if ($found) $helpondiff .= '<br>'; else $found = 1;
|
|
|
|
|
$helpondiff .= $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied") . ': ' . $object->stats_reception['qty'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculating a theorical value
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc"));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "<td>";
|
|
|
|
|
//print (empty($stocktheo)?0:$stocktheo);
|
|
|
|
|
print $form->textwithpicto((empty($stocktheo) ? 0 : $stocktheo), $helpondiff);
|
|
|
|
|
if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' ' . img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Last movement
|
|
|
|
|
$sql = "SELECT max(m.datem) as datem";
|
|
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "stock_mouvement as m";
|
|
|
|
|
$sql .= " WHERE m.fk_product = '" . $object->id . "'";
|
|
|
|
|
$resqlbis = $db->query($sql);
|
|
|
|
|
if ($resqlbis) {
|
|
|
|
|
$obj = $db->fetch_object($resqlbis);
|
|
|
|
|
$lastmovementdate = $db->jdate($obj->datem);
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
|
|
|
|
print '<tr><td class="tdtop">' . $langs->trans("LastMovement") . '</td><td>';
|
|
|
|
|
if ($lastmovementdate) {
|
|
|
|
|
print dol_print_date($lastmovementdate, 'dayhour') . ' ';
|
|
|
|
|
print '(<a href="' . DOL_URL_ROOT . '/product/stock/mouvement.php?idproduct=' . $object->id . '">' . $langs->trans("FullList") . '</a>)';
|
|
|
|
|
} else {
|
|
|
|
|
print '<a href="' . DOL_URL_ROOT . '/product/stock/mouvement.php?idproduct=' . $object->id . '">' . $langs->trans("None") . '</a>';
|
|
|
|
|
}
|
|
|
|
|
print "</td></tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stock alert threshold
|
|
|
|
|
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1),'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td>';
|
|
|
|
|
print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Hook formObject
|
|
|
|
|
$parameters=array();
|
|
|
|
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
|
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
|
|
|
|
// Desired stock
|
|
|
|
|
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer);
|
|
|
|
|
print '</td><td>';
|
|
|
|
|
print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer,'string');
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Real stock
|
|
|
|
|
$text_stock_options = $langs->trans("RealStockDesc").'<br>';
|
|
|
|
|
$text_stock_options.= $langs->trans("RealStockWillAutomaticallyWhen").'<br>';
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)?$langs->trans("DeStockOnShipment").'<br>':'');
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':'');
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_BILL)?$langs->trans("DeStockOnBill").'<br>':'');
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)?$langs->trans("ReStockOnBill").'<br>':'');
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)?$langs->trans("ReStockOnValidateOrder").'<br>':'');
|
|
|
|
|
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)?$langs->trans("ReStockOnDispatchOrder").'<br>':'');
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td>'.price2num($object->stock_reel, 'MS');
|
|
|
|
|
if ($object->seuil_stock_alerte != '' && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
$stocktheo = price2num($object->stock_theorique, 'MS');
|
|
|
|
|
|
|
|
|
|
$found=0;
|
|
|
|
|
$helpondiff='<strong>'.$langs->trans("StockDiffPhysicTeoric").':</strong><br>';
|
|
|
|
|
// Number of customer orders running
|
|
|
|
|
if (! empty($conf->commande->enabled))
|
|
|
|
|
{
|
|
|
|
|
if ($found) $helpondiff.='<br>'; else $found=1;
|
|
|
|
|
$helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty'];
|
|
|
|
|
$result=$object->load_stats_commande(0,'0', 1);
|
|
|
|
|
if ($result < 0) dol_print_error($db,$object->error);
|
|
|
|
|
$helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of product from customer order already sent (partial shipping)
|
|
|
|
|
if (! empty($conf->expedition->enabled))
|
|
|
|
|
{
|
|
|
|
|
if ($found) $helpondiff.='<br>'; else $found=1;
|
|
|
|
|
$result=$object->load_stats_sending(0,'2', 1);
|
|
|
|
|
$helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of supplier order running
|
|
|
|
|
if (! empty($conf->fournisseur->enabled))
|
|
|
|
|
{
|
|
|
|
|
if ($found) $helpondiff.='<br>'; else $found=1;
|
|
|
|
|
$result=$object->load_stats_commande_fournisseur(0,'3,4', 1);
|
|
|
|
|
$helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty'];
|
|
|
|
|
$result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1);
|
|
|
|
|
if ($result < 0) dol_print_error($db,$object->error);
|
|
|
|
|
$helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Number of product from supplier order already received (partial receipt)
|
|
|
|
|
if (! empty($conf->fournisseur->enabled))
|
|
|
|
|
{
|
|
|
|
|
if ($found) $helpondiff.='<br>'; else $found=1;
|
|
|
|
|
$helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculating a theorical value
|
|
|
|
|
print '<tr><td>';
|
|
|
|
|
print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc"));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "<td>";
|
|
|
|
|
//print (empty($stocktheo)?0:$stocktheo);
|
|
|
|
|
print $form->textwithpicto((empty($stocktheo)?0:$stocktheo), $helpondiff);
|
|
|
|
|
if ($object->seuil_stock_alerte != '' && ($object->stock_theorique < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit", $object->seuil_stock_alerte));
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Last movement
|
|
|
|
|
$sql = "SELECT max(m.datem) as datem";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
|
|
|
|
|
$sql.= " WHERE m.fk_product = '".$object->id."'";
|
|
|
|
|
$resqlbis = $db->query($sql);
|
|
|
|
|
if ($resqlbis)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resqlbis);
|
|
|
|
|
$lastmovementdate=$db->jdate($obj->datem);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
|
|
|
|
print '<tr><td class="tdtop">'.$langs->trans("LastMovement").'</td><td>';
|
|
|
|
|
if ($lastmovementdate)
|
|
|
|
|
{
|
|
|
|
|
print dol_print_date($lastmovementdate,'dayhour').' ';
|
|
|
|
|
print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("FullList").'</a>)';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("None").'</a>';
|
|
|
|
|
}
|
|
|
|
|
print "</td></tr>";
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
@@ -770,229 +766,305 @@ if (empty($reshook))
|
|
|
|
|
{
|
|
|
|
|
print "<div class=\"tabsAction\">\n";
|
|
|
|
|
|
|
|
|
|
if ($user->rights->stock->mouvement->creer)
|
|
|
|
|
{
|
|
|
|
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
|
|
|
|
|
}
|
|
|
|
|
if (! $variants) {
|
|
|
|
|
|
|
|
|
|
//if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch())
|
|
|
|
|
if ($user->rights->stock->mouvement->creer)
|
|
|
|
|
{
|
|
|
|
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert">'.$langs->trans("TransferStock").'</a>';
|
|
|
|
|
if ($user->rights->stock->mouvement->creer) {
|
|
|
|
|
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=correction">' . $langs->trans("CorrectStock") . '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch())
|
|
|
|
|
if ($user->rights->stock->mouvement->creer) {
|
|
|
|
|
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=transfert">' . $langs->trans("TransferStock") . '</a>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Stock detail (by warehouse). May go down into batch details.
|
|
|
|
|
*/
|
|
|
|
|
if (! $variants) {
|
|
|
|
|
/*
|
|
|
|
|
* Stock detail (by warehouse). May go down into batch details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td colspan="4">'.$langs->trans("Warehouse").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("NumberOfUnit").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("AverageUnitPricePMPShort").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("EstimatedStockValueShort").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("SellPriceMin").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
|
|
|
|
|
{
|
|
|
|
|
print '<tr class="liste_titre"><td width="10%"></td>';
|
|
|
|
|
print '<td align="right" width="10%">'.$langs->trans("batch_number").'</td>';
|
|
|
|
|
print '<td align="center" width="10%">'.$langs->trans("EatByDate").'</td>';
|
|
|
|
|
print '<td align="center" width="10%">'.$langs->trans("SellByDate").'</td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT e.rowid, e.ref as label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
|
|
|
|
|
$sql.= " ".MAIN_DB_PREFIX."product_stock as ps";
|
|
|
|
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
|
|
|
|
|
$sql.= " WHERE ps.reel != 0";
|
|
|
|
|
$sql.= " AND ps.fk_entrepot = e.rowid";
|
|
|
|
|
$sql.= " AND e.entity IN (".getEntity('stock').")";
|
|
|
|
|
$sql.= " AND ps.fk_product = ".$object->id;
|
|
|
|
|
$sql.= " ORDER BY e.ref";
|
|
|
|
|
|
|
|
|
|
$entrepotstatic=new Entrepot($db);
|
|
|
|
|
$product_lot_static=new Productlot($db);
|
|
|
|
|
|
|
|
|
|
$total=0;
|
|
|
|
|
$totalvalue=$totalvaluesell=0;
|
|
|
|
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$total=$totalwithpmp;
|
|
|
|
|
$i=0; $var=false;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$entrepotstatic->id=$obj->rowid;
|
|
|
|
|
$entrepotstatic->libelle=$obj->label;
|
|
|
|
|
$entrepotstatic->lieu=$obj->lieu;
|
|
|
|
|
$stock_real = price2num($obj->reel, 'MS');
|
|
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
|
|
|
|
|
print '<td align="right">'.$stock_real.($stock_real < 0 ?' '.img_warning():'').'</td>';
|
|
|
|
|
// PMP
|
|
|
|
|
print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>';
|
|
|
|
|
// Value purchase
|
|
|
|
|
print '<td align="right">'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').'</td>';
|
|
|
|
|
// Sell price
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1);
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value sell
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>';
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</tr>'; ;
|
|
|
|
|
$total += $obj->reel;
|
|
|
|
|
if (price2num($object->pmp)) $totalwithpmp += $obj->reel;
|
|
|
|
|
$totalvalue = $totalvalue + ($object->pmp*$obj->reel);
|
|
|
|
|
$totalvaluesell = $totalvaluesell + ($object->price*$obj->reel);
|
|
|
|
|
// Batch Detail
|
|
|
|
|
if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
|
|
|
|
|
{
|
|
|
|
|
$details=Productbatch::findAll($db, $obj->product_stock_id, 0, $object->id);
|
|
|
|
|
if ($details<0) dol_print_error($db);
|
|
|
|
|
foreach ($details as $pdluo)
|
|
|
|
|
{
|
|
|
|
|
$product_lot_static->id = $pdluo->lotid;
|
|
|
|
|
$product_lot_static->batch = $pdluo->batch;
|
|
|
|
|
$product_lot_static->eatby = $pdluo->eatby;
|
|
|
|
|
$product_lot_static->sellby = $pdluo->sellby;
|
|
|
|
|
|
|
|
|
|
if ($action == 'editline' && GETPOST('lineid','int') == $pdluo->id)
|
|
|
|
|
{ //Current line edit
|
|
|
|
|
print "\n".'<tr>';
|
|
|
|
|
print '<td colspan="9">';
|
|
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
|
|
|
print '<input type="hidden" name="pdluoid" value="'.$pdluo->id.'"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="'.$id.'"><table class="noborder" width="100%"><tr><td width="10%"></td>';
|
|
|
|
|
print '<td align="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.'"></td>';
|
|
|
|
|
print '<td align="center" width="10%">';
|
|
|
|
|
print $form->selectDate($pdluo->eatby,'eatby','','',1,'',1,0);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="center" width="10%">';
|
|
|
|
|
print $form->selectDate($pdluo->sellby,'sellby','','',1,'',1,0);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="right" width="10%">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>';
|
|
|
|
|
print '<td colspan="4"><input type="submit" class="button" id="savelinebutton" name="save" value="'.$langs->trans("Save").'">';
|
|
|
|
|
print '<input type="submit" class="button" id="cancellinebutton" name="Cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
|
|
|
|
print '</table>';
|
|
|
|
|
print '</form>';
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print "\n".'<tr><td align="right">';
|
|
|
|
|
print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' ';
|
|
|
|
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'">'.$langs->trans("TransferStock").'</a>';
|
|
|
|
|
// Disabled, because edition of stock content must use the "Correct stock menu".
|
|
|
|
|
// Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ...
|
|
|
|
|
//print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=editline&lineid='.$pdluo->id.'#'.$pdluo->id.'">';
|
|
|
|
|
//print img_edit().'</a></td>';
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
print $product_lot_static->getNomUrl(1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="center">'. dol_print_date($pdluo->eatby,'day') .'</td>';
|
|
|
|
|
print '<td align="center">'. dol_print_date($pdluo->sellby,'day') .'</td>';
|
|
|
|
|
print '<td align="right">'.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').'</td>';
|
|
|
|
|
print '<td colspan="4"></td></tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$i++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else dol_print_error($db);
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">'.$langs->trans("Total").':</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">'.price2num($total, 'MS').'</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
print ($totalwithpmp?price(price2num($totalvalue/$totalwithpmp,'MU')):' '); // This value may have rounding errors
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value purchase
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
print $totalvalue?price(price2num($totalvalue,'MT'),1):' ';
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total?price($totalvaluesell/$total,1):' ');
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value to sell
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell,'MT'),1);
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "</tr>";
|
|
|
|
|
print "</table>";
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE))
|
|
|
|
|
{
|
|
|
|
|
print '<br><br>';
|
|
|
|
|
print_titre($langs->trans('AddNewProductStockWarehouse'));
|
|
|
|
|
|
|
|
|
|
if (!empty($user->rights->produit->creer)){
|
|
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
|
|
|
|
print '<input type="hidden" name="action" value="addlimitstockwarehouse">';
|
|
|
|
|
print '<input type="hidden" name="id" value="'.$id.'">';
|
|
|
|
|
}
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
if (!empty($user->rights->produit->creer)){
|
|
|
|
|
print '<tr class="liste_titre"><td width="40%">'.$formproduct->selectWarehouses('', 'fk_entrepot').'</td>';
|
|
|
|
|
print '<td align="right"><input name="seuil_stock_alerte" type="text" placeholder="'.$langs->trans("StockLimit").'" /></td>';
|
|
|
|
|
print '<td align="right"><input name="desiredstock" type="text" placeholder="'.$langs->trans("DesiredStock").'" /></td>';
|
|
|
|
|
print '<td align="right"><input type="submit" value="'.$langs->trans('Save').'" class="button" /></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}else{
|
|
|
|
|
print '<tr class="liste_titre"><td width="40%">'.$langs->trans("Warehouse").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("StockLimit").'</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("DesiredStock").'</td>';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td colspan="4">' . $langs->trans("Warehouse") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("NumberOfUnit") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("AverageUnitPricePMPShort") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("EstimatedStockValueShort") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("SellPriceMin") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("EstimatedStockValueSellShort") . '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) {
|
|
|
|
|
print '<tr class="liste_titre"><td width="10%"></td>';
|
|
|
|
|
print '<td align="right" width="10%">' . $langs->trans("batch_number") . '</td>';
|
|
|
|
|
print '<td align="center" width="10%">' . $langs->trans("EatByDate") . '</td>';
|
|
|
|
|
print '<td align="center" width="10%">' . $langs->trans("SellByDate") . '</td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '<td></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pse = new ProductStockEntrepot($db);
|
|
|
|
|
$lines = $pse->fetchAll($id);
|
|
|
|
|
$sql = "SELECT e.rowid, e.ref as label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp";
|
|
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "entrepot as e,";
|
|
|
|
|
$sql .= " " . MAIN_DB_PREFIX . "product_stock as ps";
|
|
|
|
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = ps.fk_product";
|
|
|
|
|
$sql .= " WHERE ps.reel != 0";
|
|
|
|
|
$sql .= " AND ps.fk_entrepot = e.rowid";
|
|
|
|
|
$sql .= " AND e.entity IN (" . getEntity('stock') . ")";
|
|
|
|
|
$sql .= " AND ps.fk_product = " . $object->id;
|
|
|
|
|
$sql .= " ORDER BY e.ref";
|
|
|
|
|
|
|
|
|
|
if (!empty($lines))
|
|
|
|
|
{
|
|
|
|
|
$var=false;
|
|
|
|
|
foreach($lines as $line)
|
|
|
|
|
{
|
|
|
|
|
$ent = new Entrepot($db);
|
|
|
|
|
$ent->fetch($line['fk_entrepot']);
|
|
|
|
|
print '<tr class="oddeven"><td width="40%">'.$ent->getNomUrl(3).'</td>';
|
|
|
|
|
print '<td align="right">'.$line['seuil_stock_alerte'].'</td>';
|
|
|
|
|
print '<td align="right">'.$line['desiredstock'].'</td>';
|
|
|
|
|
if (!empty($user->rights->produit->creer)){
|
|
|
|
|
print '<td align="right"><a href="?id='.$id.'&fk_productstockwarehouse='.$line['id'].'&action=delete_productstockwarehouse">'.img_delete().'</a></td>';
|
|
|
|
|
$entrepotstatic = new Entrepot($db);
|
|
|
|
|
$product_lot_static = new Productlot($db);
|
|
|
|
|
|
|
|
|
|
$total = 0;
|
|
|
|
|
$totalvalue = $totalvaluesell = 0;
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$total = $totalwithpmp;
|
|
|
|
|
$i = 0;
|
|
|
|
|
$var = false;
|
|
|
|
|
while ($i < $num) {
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$entrepotstatic->id = $obj->rowid;
|
|
|
|
|
$entrepotstatic->libelle = $obj->label;
|
|
|
|
|
$entrepotstatic->lieu = $obj->lieu;
|
|
|
|
|
$stock_real = price2num($obj->reel, 'MS');
|
|
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
print '<td colspan="4">' . $entrepotstatic->getNomUrl(1) . '</td>';
|
|
|
|
|
print '<td align="right">' . $stock_real . ($stock_real < 0 ? ' ' . img_warning() : '') . '</td>';
|
|
|
|
|
// PMP
|
|
|
|
|
print '<td align="right">' . (price2num($object->pmp) ? price2num($object->pmp, 'MU') : '') . '</td>';
|
|
|
|
|
// Value purchase
|
|
|
|
|
print '<td align="right">' . (price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '') . '</td>';
|
|
|
|
|
// Sell price
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price, 'MU'), 1);
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value sell
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price * $obj->reel, 'MT'), 1) . '</td>';
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</tr>';;
|
|
|
|
|
$total += $obj->reel;
|
|
|
|
|
if (price2num($object->pmp)) $totalwithpmp += $obj->reel;
|
|
|
|
|
$totalvalue = $totalvalue + ($object->pmp * $obj->reel);
|
|
|
|
|
$totalvaluesell = $totalvaluesell + ($object->price * $obj->reel);
|
|
|
|
|
// Batch Detail
|
|
|
|
|
if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) {
|
|
|
|
|
$details = Productbatch::findAll($db, $obj->product_stock_id, 0, $object->id);
|
|
|
|
|
if ($details < 0) dol_print_error($db);
|
|
|
|
|
foreach ($details as $pdluo) {
|
|
|
|
|
$product_lot_static->id = $pdluo->lotid;
|
|
|
|
|
$product_lot_static->batch = $pdluo->batch;
|
|
|
|
|
$product_lot_static->eatby = $pdluo->eatby;
|
|
|
|
|
$product_lot_static->sellby = $pdluo->sellby;
|
|
|
|
|
|
|
|
|
|
if ($action == 'editline' && GETPOST('lineid', 'int') == $pdluo->id) { //Current line edit
|
|
|
|
|
print "\n" . '<tr>';
|
|
|
|
|
print '<td colspan="9">';
|
|
|
|
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
|
|
|
|
print '<input type="hidden" name="pdluoid" value="' . $pdluo->id . '"><input type="hidden" name="action" value="updateline"><input type="hidden" name="id" value="' . $id . '"><table class="noborder" width="100%"><tr><td width="10%"></td>';
|
|
|
|
|
print '<td align="right" width="10%"><input type="text" name="batch_number" value="' . $pdluo->batch . '"></td>';
|
|
|
|
|
print '<td align="center" width="10%">';
|
|
|
|
|
print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="center" width="10%">';
|
|
|
|
|
print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="right" width="10%">' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . '</td>';
|
|
|
|
|
print '<td colspan="4"><input type="submit" class="button" id="savelinebutton" name="save" value="' . $langs->trans("Save") . '">';
|
|
|
|
|
print '<input type="submit" class="button" id="cancellinebutton" name="Cancel" value="' . $langs->trans("Cancel") . '"></td></tr>';
|
|
|
|
|
print '</table>';
|
|
|
|
|
print '</form>';
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
} else {
|
|
|
|
|
print "\n" . '<tr><td align="right">';
|
|
|
|
|
print img_picto($langs->trans("Tranfer"), 'uparrow', 'class="hideonsmartphone"') . ' ';
|
|
|
|
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&id_entrepot=' . $entrepotstatic->id . '&action=transfert&pdluoid=' . $pdluo->id . '">' . $langs->trans("TransferStock") . '</a>';
|
|
|
|
|
// Disabled, because edition of stock content must use the "Correct stock menu".
|
|
|
|
|
// Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ...
|
|
|
|
|
//print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&action=editline&lineid='.$pdluo->id.'#'.$pdluo->id.'">';
|
|
|
|
|
//print img_edit().'</a></td>';
|
|
|
|
|
print '<td align="right">';
|
|
|
|
|
print $product_lot_static->getNomUrl(1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td align="center">' . dol_print_date($pdluo->eatby, 'day') . '</td>';
|
|
|
|
|
print '<td align="center">' . dol_print_date($pdluo->sellby, 'day') . '</td>';
|
|
|
|
|
print '<td align="right">' . $pdluo->qty . ($pdluo->qty < 0 ? ' ' . img_warning() : '') . '</td>';
|
|
|
|
|
print '<td colspan="4"></td></tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$i++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else dol_print_error($db);
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_total"><td align="right" class="liste_total" colspan="4">' . $langs->trans("Total") . ':</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">' . price2num($total, 'MS') . '</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
print ($totalwithpmp ? price(price2num($totalvalue / $totalwithpmp, 'MU')) : ' '); // This value may have rounding errors
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value purchase
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' ';
|
|
|
|
|
print '</td>';
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total ? price($totalvaluesell / $total, 1) : ' ');
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
// Value to sell
|
|
|
|
|
print '<td class="liste_total" align="right">';
|
|
|
|
|
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell, 'MT'), 1);
|
|
|
|
|
else print $langs->trans("Variable");
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "</tr>";
|
|
|
|
|
print "</table>";
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) {
|
|
|
|
|
print '<br><br>';
|
|
|
|
|
print_titre($langs->trans('AddNewProductStockWarehouse'));
|
|
|
|
|
|
|
|
|
|
if (!empty($user->rights->produit->creer)) {
|
|
|
|
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
|
|
|
|
print '<input type="hidden" name="action" value="addlimitstockwarehouse">';
|
|
|
|
|
print '<input type="hidden" name="id" value="' . $id . '">';
|
|
|
|
|
}
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
if (!empty($user->rights->produit->creer)) {
|
|
|
|
|
print '<tr class="liste_titre"><td width="40%">' . $formproduct->selectWarehouses('', 'fk_entrepot') . '</td>';
|
|
|
|
|
print '<td align="right"><input name="seuil_stock_alerte" type="text" placeholder="' . $langs->trans("StockLimit") . '" /></td>';
|
|
|
|
|
print '<td align="right"><input name="desiredstock" type="text" placeholder="' . $langs->trans("DesiredStock") . '" /></td>';
|
|
|
|
|
print '<td align="right"><input type="submit" value="' . $langs->trans('Save') . '" class="button" /></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
} else {
|
|
|
|
|
print '<tr class="liste_titre"><td width="40%">' . $langs->trans("Warehouse") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("StockLimit") . '</td>';
|
|
|
|
|
print '<td align="right">' . $langs->trans("DesiredStock") . '</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
$pse = new ProductStockEntrepot($db);
|
|
|
|
|
$lines = $pse->fetchAll($id);
|
|
|
|
|
|
|
|
|
|
if (!empty($user->rights->produit->creer)){
|
|
|
|
|
print '</form>';
|
|
|
|
|
if (!empty($lines)) {
|
|
|
|
|
$var = false;
|
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
|
$ent = new Entrepot($db);
|
|
|
|
|
$ent->fetch($line['fk_entrepot']);
|
|
|
|
|
print '<tr class="oddeven"><td width="40%">' . $ent->getNomUrl(3) . '</td>';
|
|
|
|
|
print '<td align="right">' . $line['seuil_stock_alerte'] . '</td>';
|
|
|
|
|
print '<td align="right">' . $line['desiredstock'] . '</td>';
|
|
|
|
|
if (!empty($user->rights->produit->creer)) {
|
|
|
|
|
print '<td align="right"><a href="?id=' . $id . '&fk_productstockwarehouse=' . $line['id'] . '&action=delete_productstockwarehouse">' . img_delete() . '</a></td>';
|
|
|
|
|
}
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
|
|
if (!empty($user->rights->produit->creer)) {
|
|
|
|
|
print '</form>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// List of variants
|
|
|
|
|
|
|
|
|
|
$prodstatic = new Product($db);
|
|
|
|
|
$prodcomb = new ProductCombination($db);
|
|
|
|
|
$comb2val = new ProductCombination2ValuePair($db);
|
|
|
|
|
$productCombinations = $prodcomb->fetchAllByFkProductParent($object->id);
|
|
|
|
|
|
|
|
|
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
|
|
print '<input type="hidden" name="action" value="massaction">';
|
|
|
|
|
print '<input type="hidden" name="id" value="'.$id.'">';
|
|
|
|
|
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
|
|
|
|
|
|
|
|
|
// load variants
|
|
|
|
|
$title = $langs->trans("ProductCombinations");
|
|
|
|
|
|
|
|
|
|
print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0);
|
|
|
|
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
|
|
|
?>
|
|
|
|
|
<table class="liste">
|
|
|
|
|
<tr class="liste_titre">
|
|
|
|
|
<td class="liste_titre"><?php echo $langs->trans('Product') ?></td>
|
|
|
|
|
<td class="liste_titre"><?php echo $langs->trans('Combination') ?></td>
|
|
|
|
|
<td class="liste_titre center"><?php echo $langs->trans('OnSell') ?></td>
|
|
|
|
|
<td class="liste_titre center"><?php echo $langs->trans('OnBuy') ?></td>
|
|
|
|
|
<td class="liste_titre right"><?php echo $langs->trans('Stock') ?></td>
|
|
|
|
|
<td class="liste_titre"></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
if (count($productCombinations))
|
|
|
|
|
{
|
|
|
|
|
$stock_total= 0;
|
|
|
|
|
foreach ($productCombinations as $currcomb)
|
|
|
|
|
{
|
|
|
|
|
$prodstatic->fetch($currcomb->fk_product_child);
|
|
|
|
|
$prodstatic->load_stock();
|
|
|
|
|
$stock_total+=$prodstatic->stock_reel;
|
|
|
|
|
?>
|
|
|
|
|
<tr class="oddeven">
|
|
|
|
|
<td><?php echo $prodstatic->getNomUrl(1) ?></td>
|
|
|
|
|
<td>
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$productCombination2ValuePairs = $comb2val->fetchByFkCombination($currcomb->id);
|
|
|
|
|
$iMax = count($productCombination2ValuePairs);
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < $iMax; $i++) {
|
|
|
|
|
echo dol_htmlentities($productCombination2ValuePairs[$i]);
|
|
|
|
|
|
|
|
|
|
if ($i !== ($iMax - 1)) {
|
|
|
|
|
echo ', ';
|
|
|
|
|
}
|
|
|
|
|
} ?>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 0) ?></td>
|
|
|
|
|
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 1) ?></td>
|
|
|
|
|
<td class="right"><?php echo $prodstatic->stock_reel ?></td>
|
|
|
|
|
<td class="right">
|
|
|
|
|
<a class="paddingleft paddingright" href="<?php echo dol_buildpath('/product/stock/product.php?id='.$currcomb->fk_product_child, 2) ?>"><?php echo img_edit() ?></a>
|
|
|
|
|
</td>
|
|
|
|
|
<?php
|
|
|
|
|
?>
|
|
|
|
|
</tr>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_total">';
|
|
|
|
|
print '<td colspan="4" align="left">'.$langs->trans("Total").'</td>';
|
|
|
|
|
print '<td align="right">'.$stock_total.'</td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td colspan="8"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
print '</div>';
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// End of page
|
|
|
|
|
|