Stock Limpio
"; } //Las siguientes funciones no las uso, pero no las guardo porque son muy interesantes para manejar arrays, por si las necesito en otro momento. function searchArrayKeyVal($sKey, $id, $array) { foreach ($array as $key => $val) { if ($val[$sKey] == $id) { return $key; } } return false; } //Busco una funci?n para identificar no solo al producto, sino tambi?n al producto y su fecha de lote function buscaClave($pId,$fl,$array) { foreach ($array as $key => $val) { if ($val[0] == $pId and $val[1] == $fl) { return $key; } } return false; } //Esta funci?n busca la clave s?lo usando el producto function buscaClaveProducto($pId,$array) { foreach ($array as $key => $val) { if ($val[0] == $pId) { return $key; } } return false; } $status_array = array(); $status_array[] = array('id' => '0', 'text' => 'Ver Todo'); $status_array[] = array('id' => '1', 'text' => 'Productos con mas de 30 dias'); $status_array[] = array('id' => '2', 'text' => 'Productos entre 14 y 30 dias'); $status_array[] = array('id' => '3', 'text' => 'Ordenados por posicion'); //Cargo en un array las salidas de cada producto para las fechas indicadas $tq5 = "select op.product_id products_id,sum(product_quantity) products_quantity " . "from ps_order_detail op join ps_orders o on op.id_order=o.id_order " . "join ps_cart dd on (dd.id_cart=o.id_cart) " . "join ps_address ad on o.id_address_delivery=ad.id_address ". "join ps_carrier ca on ca.id_carrier=o.id_carrier " . /*"where dd.tramo_date between '" . $fecIni . "' and '" . $fecFin . "' ";*/ "where ((dd.tramo_date between '" . $fecIni . "' and '" . $fecFin . "' and id_reference<>49) or (dd.tramo_date between '" . $fecIniBarcelona . "' and '" . $fecFinBarcelona . "' and id_reference=49)) "; if ($pedidosPreparados) { $tq5 .= "and o.id_order not in (select distinct id_order from ps_trazabilidad where year(date_upd)>=YEAR(CURDATE())) "; } $tq5 .= "and o.current_state in (2,3,4,5,14,16) ". "group by 1"; //echo $tq5; $reg_query5 = tep_db_query($tq5); $salidas = array(); while ($status_values = tep_db_fetch_array($reg_query5)) { //Averiguo si el producto actual es un men? $texto_query1 = "select p.id_product_item products_id,p.quantity products_quantity " . "from ps_pack p ". "where p.id_product_pack=".$status_values['products_id']; $status_query1 = tep_db_query($texto_query1); if (tep_db_num_rows($status_query1)>0) { while ($status_values1 = tep_db_fetch_array($status_query1)) { // CORRECCIÓN: Verificar si la clave existe antes de sumar $product_id = $status_values1['products_id']; $current_value = isset($salidas[$product_id]['cantidad']) ? $salidas[$product_id]['cantidad'] : 0; $salidas[$product_id] = array('cantidad' => $current_value + $status_values1['products_quantity'] * $status_values['products_quantity']); } } else { // CORRECCIÓN: Verificar si la clave existe antes de sumar $product_id = $status_values['products_id']; $current_value = isset($salidas[$product_id]['cantidad']) ? $salidas[$product_id]['cantidad'] : 0; $salidas[$product_id] = array('cantidad' => $current_value + $status_values['products_quantity']); } } //print_r($salidas); $reg_query4_sql = "select p.id_product products_id,name products_name,round(cantidad) cantidad,fechaLote,datediff(now(),fechaLote) dias,posicion_clasif,posicion_almac ". "from ps_product p left join ps_stock_web s on (s.products_id=p.id_product) ". "join ps_product_lang pd on (p.id_product=pd.id_product and id_lang=1) ". "left join ps_product_ptl ptl on (p.id_product=ptl.id_product) ". "where p.active=1 ". "and pd.name not like '%menu%' ". "and pd.name not like '%pack%' ". "and pd.name not like '%Semana%' ". "and pd.name not like '%Monedero%' ". "group by p.id_product,fechaLote "; if ($tipoInforme==1) { $reg_query4_sql .="having dias>30 order by dias desc,products_name "; }elseif ($tipoInforme==2) { $reg_query4_sql .="having dias>14 and dias<=30 order by dias desc,products_name "; }elseif ($tipoInforme==3) { $reg_query4_sql .="order by posicion_clasif,products_name,dias desc "; }else { $reg_query4_sql .="order by products_name,dias desc "; } //echo $reg_query4_sql.'
'; $reg_query4 = tep_db_query($reg_query4_sql); ?> Stock en Web - www.noCocinoMas.es >> LIMPIAR STOCK <<

Salidas Fecha Inicial:     Fecha Final:     

Salidas BARCELONA Fecha Inicial:     Fecha Final:     



> Descontar en salidas los pedidos ya preparados en almacen

$subIdProducto and $subIdProducto<>0) { //$claveSalida = buscaClaveProducto($reg4['products_id'],$salidas); // CORRECCIÓN: Sintaxis correcta de strpos() if (strpos(strtoupper($reg4['products_name']), 'FAMILIAR') === false && strpos(strtoupper($reg4['products_name']), 'DUKAN') === false && strpos(strtoupper($reg4['products_name']), 'GRANDE') === false) { $nProductos +=1; } // CORRECCIÓN: Verificar si la clave existe en el array $salidas $salida_cantidad = isset($salidas[$subIdProducto]['cantidad']) ? $salidas[$subIdProducto]['cantidad'] : 0; ?> 14 and $reg4['dias']<=30) { $masDe21Dias+=1; ?> 30) { $masDe30Dias+=1; ?> 0) { $nProductos +=1; // CORRECCIÓN: Verificar si la clave existe en el array $salidas $salida_cantidad = isset($salidas[$subIdProducto]['cantidad']) ? $salidas[$subIdProducto]['cantidad'] : 0; $totSalidas += $salida_cantidad; if ($reg4['dias']>14 and $reg4['dias']<=30) { $masDe21Dias+=1; } if ($reg4['dias']>30) { $masDe30Dias+=1; } if ($subTotalCantidad<10) { $prodNaranja+=1; } if ($subTotalCantidad < $salida_cantidad) { $prodRojo +=1; } $totCantidad +=$reg4['cantidad']; ?>
Stock Actualizado
Posicion Reserva ID. Producto Lote Antigüedad Cantidad Salidas Pedidos (Sin packs)
Total Parcial align="right"> align="right"> 0) { echo '   >>VIGILAR EN CAMARA<< '; } $totSalidas += $salida_cantidad; ?>
 
Total Parcial align="right"> align="right">
Total Productos diferentes:
Productos con mas de 14 dias:
Productos con mas de 30 dias:
Productos en Naranja:
Productos en Rojo:
Total Salidas:
Total Stock: