Sellby always before Eatby #18361

This commit is contained in:
Laurent Destailleur 2021-08-17 17:55:00 +02:00
parent ed250bb6a4
commit c0a086fad8
9 changed files with 82 additions and 75 deletions

View File

@ -738,12 +738,12 @@ if ($id > 0 || !empty($ref)) {
print '<td>'.$langs->trans("Description").'</td>';
if (!empty($conf->productbatch->enabled)) {
print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
}
} else {
print '<td></td>';
print '<td></td>';
@ -828,12 +828,12 @@ if ($id > 0 || !empty($ref)) {
print $linktoprod;
print "</td>";
print '<td class="dispatch_batch_number"></td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo"></td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc"></td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo"></td>';
}
} else {
print '<td>';
print $linktoprod;
@ -841,12 +841,12 @@ if ($id > 0 || !empty($ref)) {
print '<td class="dispatch_batch_number">';
print $langs->trans("ProductDoesNotUseBatchSerial");
print '</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo"></td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc"></td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo"></td>';
}
}
} else {
print '<td colspan="4">';
@ -913,7 +913,7 @@ if ($id > 0 || !empty($ref)) {
print '<td>';
print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.GETPOST('lot_number'.$suffix).'">';
print '</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="nowraponall">';
$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year'));
print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, '');
@ -929,8 +929,8 @@ if ($id > 0 || !empty($ref)) {
} else {
$type = 'dispatch';
$colspan = 7;
$colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
$colspan = (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) ? --$colspan : $colspan;
$colspan = (!empty($conf->global->PRODUCT_DISABLE_EATBY)) ? --$colspan : $colspan;
print '<td class="right">';
print '</td>'; // Qty to dispatch
print '<td>';
@ -1142,12 +1142,12 @@ if ($id > 0 || !empty($ref)) {
print '<td>'.$langs->trans("DateDeliveryPlanned").'</td>';
if (!empty($conf->productbatch->enabled)) {
print '<td class="dispatch_batch_number_title">'.$langs->trans("batch_number").'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc_title">'.$langs->trans("SellByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo_title">'.$langs->trans("EatByDate").'</td>';
}
}
print '<td class="right">'.$langs->trans("QtyDispatched").'</td>';
print '<td>'.$langs->trans("Warehouse").'</td>';
@ -1202,16 +1202,20 @@ if ($id > 0 || !empty($ref)) {
$lot = new Productlot($db);
$lot->fetch(0, $objp->pid, $objp->batch);
print '<td class="dispatch_batch_number">'.$lot->getNomUrl(1).'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo">'.dol_print_date($lot->eatby, 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc">'.dol_print_date($lot->sellby, 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo">'.dol_print_date($lot->eatby, 'day').'</td>';
}
} else {
print '<td class="dispatch_batch_number"></td>';
print '<td class="dispatch_dluo"></td>';
print '<td class="dispatch_dlc"></td>';
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc"></td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="dispatch_dluo"></td>';
}
}
}

View File

@ -123,12 +123,12 @@ $arrayfields = array(
//'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
);
if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
unset($arrayfields['pl.eatby']);
}
if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
unset($arrayfields['pl.sellby']);
}
if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
unset($arrayfields['pl.eatby']);
}
$objectlist->fields = dol_sort_array($objectlist->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');

View File

@ -284,10 +284,10 @@ if ($resql)
print '<td class="liste_titre center"><input class="flat" type="text" name="search_batch" size="6" value="'.$search_batch.'"></td>';
print '<td class="liste_titre right">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="liste_titre">&nbsp;</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre">&nbsp;</td>';
@ -306,12 +306,12 @@ if ($resql)
print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder);
//print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right );
print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center ');
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center ');
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center ');
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center ');
}
print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right ');
// TODO Add info of running suppliers/customers orders
//print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right ');
@ -408,16 +408,19 @@ if ($resql)
}
print '</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->eatby), 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->sellby), 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="center">'.dol_print_date($db->jdate($objp->eatby), 'day').'</td>';
}
print '<td class="right">';
//if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' ';
print $objp->stock_physique;
print '</td>';
print '<td class="right"><a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?idproduct='.$product_static->id.'&search_warehouse='.$objp->fk_entrepot.'&search_batch='.($objp->batch != 'Undefined' ? $objp->batch : 'Undefined').'">'.$langs->trans("Movements").'</a></td>';
print '<td class="right nowrap">'.$product_static->LibStatut($objp->statut, 5, 0).'</td>';
print '<td class="right nowrap">'.$product_static->LibStatut($objp->tobuy, 5, 1).'</td>';

View File

@ -121,12 +121,12 @@ $arrayfields = array(
//'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
);
if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
unset($arrayfields['pl.eatby']);
}
if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
unset($arrayfields['pl.sellby']);
}
if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) {
unset($arrayfields['pl.eatby']);
}
// Security check
if (!$user->rights->stock->mouvement->lire) {

View File

@ -830,14 +830,14 @@ if (!$variants) {
$colspan = 3;
print '<tr class="liste_titre"><td width="10%"></td>';
print '<td class="right" width="10%">'.$langs->trans("batch_number").'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$colspan--;
print '<td class="center" width="10%">'.$langs->trans("EatByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
$colspan--;
print '<td class="center" width="10%">'.$langs->trans("SellByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$colspan--;
print '<td class="center" width="10%">'.$langs->trans("EatByDate").'</td>';
}
print '<td colspan="'.$colspan.'"></td>';
print '<td></td>';
print '<td></td>';
@ -917,16 +917,16 @@ if (!$variants) {
print '<input type="hidden" name="token" value="'.newToken().'">';
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 centpercent"><tr><td width="10%"></td>';
print '<td class="right" width="10%"><input type="text" name="batch_number" value="'.$pdluo->batch.'"></td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="center" width="10%">';
print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0);
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="center" width="10%">';
print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0);
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="center" width="10%">';
print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0);
print '</td>';
}
print '<td class="right" colspan="3">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>';
print '<td colspan="4"><input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button button-cancel" id="cancellinebutton" name="Cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
@ -945,14 +945,14 @@ if (!$variants) {
print $product_lot_static->getNomUrl(1);
print '</td>';
$colspan = 3;
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$colspan--;
print '<td class="center">'.dol_print_date($pdluo->eatby, 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
$colspan--;
print '<td class="center">'.dol_print_date($pdluo->sellby, 'day').'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$colspan--;
print '<td class="center">'.dol_print_date($pdluo->eatby, 'day').'</td>';
}
print '<td class="right" colspan="'.$colspan.'">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>';
print '<td colspan="4"></td>';
print '</tr>';

View File

@ -335,6 +335,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label;
print '</td></tr>';
// Sell by
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<tr><td>';
print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
}
// Eat by
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<tr><td>';
@ -345,15 +355,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</tr>';
}
// Sell by
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<tr><td>';
print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
}
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';

View File

@ -115,18 +115,18 @@ if (!empty($conf->productbatch->enabled) &&
print '</td>';
print '</tr>';
print '<tr>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td>'.$langs->trans("EatByDate").'</td><td>';
$eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td>'.$langs->trans("SellByDate").'</td><td>';
$sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear'));
print $form->selectDate($sellbyselected, 'sellby', '', '', 1, "");
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td>'.$langs->trans("EatByDate").'</td><td>';
$eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear'));
print $form->selectDate($eatbyselected, 'eatby', '', '', 1, "");
print '</td>';
}
print '</tr>';
}

View File

@ -108,16 +108,16 @@ if (!empty($conf->productbatch->enabled) &&
print '</tr>';
print '<tr>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td>'.$langs->trans("EatByDate").'</td><td>';
print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td>'.$langs->trans("SellByDate").'</td><td>';
print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td>'.$langs->trans("EatByDate").'</td><td>';
print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
print '</td>';
}
print '</tr>';
}

View File

@ -983,12 +983,12 @@ if ($action == 'create')
if (!empty($conf->productbatch->enabled))
{
print '<td class="left">'.$langs->trans("batch_number").'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="left">'.$langs->trans("EatByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="left">'.$langs->trans("SellByDate").'</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td class="left">'.$langs->trans("EatByDate").'</td>';
}
}
print "</tr>\n";
}
@ -1077,8 +1077,7 @@ if ($action == 'create')
print '</td>';
if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$quantityToBeDelivered = 0;
} else {
$quantityToBeDelivered = $dispatchLines[$indiceAsked]['qty'];
@ -1130,12 +1129,12 @@ if ($action == 'create')
if (!empty($product->status_batch))
{
print '<td><input name="batch'.$indiceAsked.'" value="'.$dispatchLines[$indiceAsked]['lot'].'"></td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td>';
print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, "");
print '</td>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '<td>';
print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, "");
print '</td>';
@ -1827,11 +1826,11 @@ if ($action == 'create')
if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch))
{
print '<td> <input name="batch'.$line_id.'" id="batch'.$line_id.'" type="text" value="'.$lines[$i]->batch.'"> </br>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print $langs->trans('EatByDate').' : ';
print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'</br>';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print $langs->trans('SellByDate').' : ';
print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, "");
}