NEW Add an option to hide by default icon shippable order in command list

This commit is contained in:
lvessiller 2020-11-19 14:14:24 +01:00
parent b9f072498c
commit 73dab143a3
3 changed files with 94 additions and 89 deletions

View File

@ -114,6 +114,8 @@ $pagenext = $page + 1;
if (!$sortfield) $sortfield = 'c.ref'; if (!$sortfield) $sortfield = 'c.ref';
if (!$sortorder) $sortorder = 'DESC'; if (!$sortorder) $sortorder = 'DESC';
$show_shippable_command = GETPOST('show_shippable_command', 'aZ09');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Commande($db); $object = new Commande($db);
$hookmanager->initHooks(array('orderlist')); $hookmanager->initHooks(array('orderlist'));
@ -569,6 +571,11 @@ if ($resql)
$moreforfilter = ''; $moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('ShowShippableCommand').': ';
$moreforfilter .= '<input type="checkbox" name="show_shippable_command" value="show_shippable_command"'.($show_shippable_command == 'show_shippable_command' ? ' checked' : '').'>';
$moreforfilter.='</div>';
// If the user can view prospects other than his' // If the user can view prospects other than his'
if ($user->rights->societe->client->voir || $socid) if ($user->rights->societe->client->voir || $socid)
{ {
@ -950,19 +957,18 @@ if ($resql)
if (!empty($arrayfields['c.ref']['checked'])) if (!empty($arrayfields['c.ref']['checked']))
{ {
print '<td class="nowraponall">'; print '<td class="nowraponall">';
if(!empty($show_shippable_command)) {
$generic_commande->getLinesArray(); // This set ->lines $generic_commande->getLinesArray(); // This set ->lines
}
print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1);
if(!empty($show_shippable_command)) {
// Show shippable Icon (create subloop, so may be slow) // Show shippable Icon (create subloop, so may be slow)
if ($conf->stock->enabled) if ($conf->stock->enabled) {
{ if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) {
if (($obj->fk_statut > 0) && ($obj->fk_statut < 3))
{
$numlines = count($generic_commande->lines); // Loop on each line of order $numlines = count($generic_commande->lines); // Loop on each line of order
for ($lig = 0; $lig < $numlines; $lig++) for ($lig = 0; $lig < $numlines; $lig++) {
{
if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service
{ {
$nbprod++; // order contains real products $nbprod++; // order contains real products
@ -986,8 +992,7 @@ if ($resql)
$text_info .= ' - ' . $langs->trans("VirtualStock") . ': <span class="' . ($generic_product->stock_theorique > 0 ? 'ok' : 'error') . '">' . $generic_product->stock_theorique . '</span>'; $text_info .= ' - ' . $langs->trans("VirtualStock") . ': <span class="' . ($generic_product->stock_theorique > 0 ? 'ok' : 'error') . '">' . $generic_product->stock_theorique . '</span>';
$text_info .= '<br>'; $text_info .= '<br>';
if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) {
{
$notshippable++; $notshippable++;
} }
} else { // Detailed virtual stock, looks bugged, uncomplete and need heavy load. } else { // Detailed virtual stock, looks bugged, uncomplete and need heavy load.
@ -996,8 +1001,7 @@ if ($resql)
$stock_order_supplier = 0; $stock_order_supplier = 0;
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ?
{ {
if (!empty($conf->commande->enabled)) if (!empty($conf->commande->enabled)) {
{
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
$generic_product->load_stats_commande(0, '1,2'); $generic_product->load_stats_commande(0, '1,2');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
@ -1006,8 +1010,7 @@ if ($resql)
} }
$stock_order = $generic_product->stats_commande['qty']; $stock_order = $generic_product->stats_commande['qty'];
} }
if (!empty($conf->fournisseur->enabled)) if (!empty($conf->fournisseur->enabled)) {
{
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
$generic_product->load_stats_commande_fournisseur(0, '3'); $generic_product->load_stats_commande_fournisseur(0, '3');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
@ -1046,14 +1049,14 @@ if ($resql)
} }
} }
if ($nbprod) if ($nbprod) {
{
print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2);
} }
if ($warning) { // Always false in default mode if ($warning) { // Always false in default mode
print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders') . '<br>' . $text_warning, 2, 1, img_picto('', 'error'), '', 2); print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders') . '<br>' . $text_warning, 2, 1, img_picto('', 'error'), '', 2);
} }
} }
}
// Warning late icon and note // Warning late icon and note
if ($generic_commande->hasDelay()) { if ($generic_commande->hasDelay()) {

View File

@ -27,5 +27,6 @@ Recipient=Recipient
ErrorStockIsNotEnough=There's not enough stock ErrorStockIsNotEnough=There's not enough stock
Shippable=Shippable Shippable=Shippable
NonShippable=Not Shippable NonShippable=Not Shippable
ShowShippableCommand=Show shippable command
ShowReceiving=Show delivery receipt ShowReceiving=Show delivery receipt
NonExistentOrder=Nonexistent order NonExistentOrder=Nonexistent order

View File

@ -27,5 +27,6 @@ Recipient=Destinataire
ErrorStockIsNotEnough=Le stock est insuffisant ErrorStockIsNotEnough=Le stock est insuffisant
Shippable=Expédiable Shippable=Expédiable
NonShippable=Non expédiable NonShippable=Non expédiable
ShowShippableCommand=Afficher statut expédiabilité
ShowReceiving=Afficher le bon de réception ShowReceiving=Afficher le bon de réception
NonExistentOrder=Commande inexistante NonExistentOrder=Commande inexistante