Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/09/2013, 08:43
Avatar de wizanchez
wizanchez
 
Fecha de Ingreso: junio-2013
Ubicación: bogota
Mensajes: 120
Antigüedad: 10 años, 11 meses
Puntos: 6
Respuesta: Problema PHP se cortan los procesos

_ te doy una parte

Código PHP:
Ver original
  1. array_unique($ITEMID);
  2.     $reemplazar = array("<SPAN CLASS=TEXTITULO >","</SPAN>","&","-GT;","|");
  3.     $reemplazarB = array("<SPAN CLASS=TEXTITULO >","</SPAN>","&","-GT;");  
  4. foreach($locationids as $key=>$almacen){
  5.    
  6.     if($almacen>0){
  7.    
  8.                     $rc_almacen = &$conn->Execute(' SELECT
  9.                                                             UPPER(company.companyname)
  10.                                                     FROM
  11.                                                             inventorylocation,company
  12.                                                     WHERE
  13.                                                             inventorylocation.id = '.$almacen.'
  14.                                                             AND inventorylocation.companyid=company.id
  15.                                                             and company.cancel=0  
  16.                                                     order by
  17.                                                             company.companyname');
  18.    
  19.    
  20.     foreach($ITEMID as $b=>$itemid){
  21.        
  22.         $SQL='SELECT
  23.                         itemid,
  24.                         SUM(qty),
  25.                         SUM(sales_vr*qty),
  26.                         SUM(itemcost*qty),
  27.                         SUM(itemvta*qty),
  28.                         SUM(costnet*qty),
  29.                         SUM(total_sales)    as precio_total,
  30.                         SUM(sales_dcto)     as descuento_total
  31.               FROM
  32.                         sales_log
  33.               WHERE  
  34.                         itemid = "'.$itemid.'"
  35.                         AND locationid = "'.$almacen.'"
  36.                         AND date >= "'.$FechaIni.'"
  37.                         AND date <= "'.$FechaFinal.'"
  38.                         AND cancel = 0
  39.             GROUP BY itemid';
  40.        
  41.     if($rc_item = &$conn->Execute($SQL)===false)
  42.         {echo 'Error SQL{'.$SQL.'}';exit;}
  43.     /*itemid = "'.$itemid.'" AND*/
  44.    
  45.    
  46.    
  47.    
  48.    
  49.    
  50.    
  51.     if(!$rc_item->EOF){
  52.         while(!$rc_item->EOF){
  53.  
  54.             $InfoItem                   = $ItemD->infoqtycostprice($rc_item->fields[0],$almacen);
  55.             $ivaitem                    = $ItemD->itemIvA($rc_item->fields[0]);
  56.             $PVPsinIva                  = ($rc_item->fields[2]*100)/(100+$ivaitem);
  57.             $PVPsinIvaPig               = ($rc_item->fields[4]*100)/(100+$ivaitem);
  58.             ${"POSvta".$itemid}[]       = $rc_item->fields[2]/$rc_item->fields[1];
  59.             ${"PILOGvta".$itemid}[]     = $rc_item->fields[4]/$rc_item->fields[1];           
  60.             $precio_total               = $rc_item->fields['precio_total'];          
  61.             $descuento_total            = $rc_item->fields['descuento_total'];           
  62.             //unidades vendidas por almacen
  63.             ${"qty".$itemid.'_'.$almacen} = $rc_item->fields[1];
  64.  
  65.            
  66.             $agrupacion = trim(str_replace($reemplazarB,"|",$ItemD->itempurchase($rc_item->fields[0],'pay')));
  67.            
  68.             $agrup = explode('|',substr_replace($agrupacion,'',-1,1)); 
  69.     ############ ###################### ############################### ##########################################  ###########################  
  70. /**
  71.  * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  72.  */
  73. if($_REQUEST['automatic']!='TRUE'){
  74.    
  75.      echo $rc_almacen->fields[0].'|'.$ItemD->itemplu($rc_item->fields[0]).'|';
  76.     }
  77.  
  78.     $concate    .=$rc_almacen->fields[0].'|'.$ItemD->itemplu($rc_item->fields[0]).'|';
  79.    
  80.                         $salto = 1;
  81.                        
  82.                         $VecBarcod = $ItemD->Barcode($rc_item->fields[0]);
  83.  
  84.                         for($h=0;$h<count($VecBarcod);$h++){
  85.     ############ ###################### ############################### ##########################################  ###########################  
  86.                             /**
  87.                              * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  88.                              */
  89.                             if($_REQUEST['automatic']!='TRUE'){
  90.  
  91.                             echo trim($VecBarcod[$h]).' ';
  92.                                 }
  93.  
  94.                             $concate    .=trim($VecBarcod[$h]).' ';
  95.                         }  
  96.     ############ ###################### ############################### ##########################################  ###########################  
  97.             /**
  98.              * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  99.              */
  100.             if($_REQUEST['automatic']!='TRUE'){
  101.  
  102.                 echo '|'.$ItemD->itemsection($rc_item->fields[0]).'|'.$agrup[0].'|'.$agrup[1].'|'.$agrup[2].'|'.$agrup[3].'|'.$agrup[4].'|'.trim(str_replace($reemplazar,"",$ItemD->ItemDescription($rc_item->fields[0],'1'))).'|'.trim(str_replace($reemplazar,"",$ItemD->ItemDescription($rc_item->fields[0],'3'))).'|';
  103.                 $concate    .='|'.$ItemD->itemsection($rc_item->fields[0]).'|'.$agrup[0].'|'.$agrup[1].'|'.$agrup[2].'|'.$agrup[3].'|'.$agrup[4].'|'.trim(str_replace($reemplazar,"",$ItemD->ItemDescription($rc_item->fields[0],'1'))).'|'.trim(str_replace($reemplazar,"",$ItemD->ItemDescription($rc_item->fields[0],'3'))).'|';
  104.             }
  105.                                 $SLP='  SELECT
  106.                                                 itven.vendorid,
  107.                                                 itven.status
  108.                                             FROM
  109.                                                 itemvendor  AS itven,
  110.                                                 vendor      AS ven,
  111.                                                 company     AS comp
  112.                                             WHERE
  113.                                                 itven.itemid = '.$rc_item->fields[0].'
  114.                                                 AND itven.locationid = '.$almacen.'    
  115.                                                 '.$strVendorid.'
  116.                                                 AND itven.vendorid=ven.id
  117.                                                 AND ven.cancel=0
  118.                                                 AND itven.cancel = 0
  119.                                                 AND ven.paytocompanyid=comp.id
  120.                                                 AND comp.cancel=0
  121.                                             LIMIT 1';
  122.            
  123.            
  124.            if( $rc_vendor = &$conn->Execute($SLP)===false)
  125.             {echo 'Error SQL {'.$rc_vendor.'}';}       
  126.                 //echo $SLP;                           
  127.                                            
  128.             if($rc_vendor->RecordCount() === 0){
  129.                 /**
  130.              * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  131.              */
  132.             if($_REQUEST['automatic']!='TRUE'){
  133.                 echo '?|?|?|?|';
  134.                
  135.                 }
  136.  
  137.             $concate    .='?|?|?|?|';
  138.  
  139.             }else{
  140.             while(!$rc_vendor->EOF){
  141.                    
  142.                     if($rc_vendor->fields[1]){
  143.                             $strcompra = 'INACTIVO';
  144.                         }else{
  145.                             $strcompra = 'ACTIVO';
  146.                             }
  147.                 $noid           = $rc_vendor->fields[0];
  148.                
  149.                 $rc_vendorname  = &$conn->Execute(' SELECT
  150.                                                             UPPER(c.companyname)
  151.                                                     FROM
  152.                                                             company c,
  153.                                                             vendor v
  154.                                                     WHERE
  155.                                                             v.paytocompanyid = c.id
  156.                                                             AND v.id = '.$rc_vendor->fields[0].'');
  157.                 $vendornombre = trim(str_replace($reemplazar,"",$rc_vendorname->fields[0]));
  158.     ############ ###################### ############################### ##########################################  ###########################  
  159.             /**
  160.              * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  161.              */
  162.             if($_REQUEST['automatic']!='TRUE'){
  163.                
  164.                 echo $strcompra.'|'.$rc_vendor->fields[0].' :: '.$vendornombre.'|'.$signo.$ItemD->itemcostvendor($rc_item->fields[0],$rc_vendor->fields[0],$almacen).'|'.$ItemD->itemembalaje($rc_item->fields[0],$rc_vendor->fields[0]).'|';
  165.                    
  166.                     }
  167.  
  168.                 $concate    .=$strcompra.'|'.$rc_vendor->fields[0].' :: '.$vendornombre.'|'.$signo.$ItemD->itemcostvendor($rc_item->fields[0],$rc_vendor->fields[0],$almacen).'|'.$ItemD->itemembalaje($rc_item->fields[0],$rc_vendor->fields[0]).'|';
  169.                 $rc_vendor->MoveNext();
  170.             }
  171.             }  
  172.     ############ ###################### ############################### ##########################################  ###########################  
  173.             /**
  174.              * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  175.              */
  176.             if($_REQUEST['automatic']!='TRUE'){
  177.  
  178.                 echo number_format($InfoItem[1], 0,',','').'|'.number_format($InfoItem[2], 0,',','').'|'.number_format($InfoItem[6], 0,',','').'|'.number_format($rc_item->fields[1], 2,',','').'|'.number_format($rc_item->fields[3], 0,',','').'|'.number_format($rc_item->fields[5], 0,',','').'|'.number_format($PVPsinIva, 0,',','').'|'.number_format($rc_item->fields[2], 0,',','').'|'.number_format($PVPsinIvaPig, 0,',','').'|'.number_format($rc_item->fields[4], 0,',','').'|'.number_format((($PVPsinIva - $rc_item->fields[3])/$PVPsinIva)*100, 0,',','').'|'.$precio_total.'|'.$descuento_total;
  179.             }
  180.  
  181.                 $concate    .=number_format($InfoItem[1], 0,',','').'|'.number_format($InfoItem[2], 0,',','').'|'.number_format($InfoItem[6], 0,',','').'|'.number_format($rc_item->fields[1], 2,',','').'|'.number_format($rc_item->fields[3], 0,',','').'|'.number_format($rc_item->fields[5], 0,',','').'|'.number_format($PVPsinIva, 0,',','').'|'.number_format($rc_item->fields[2], 0,',','').'|'.number_format($PVPsinIvaPig, 0,',','').'|'.number_format($rc_item->fields[4], 0,',','').'|'.number_format((($PVPsinIva - $rc_item->fields[3])/$PVPsinIva)*100, 0,',','').'|'.$precio_total.'|'.$descuento_total;
  182.                
  183.             if($rc_vendor->RecordCount() === 1 && !$vendorid){
  184.  
  185.             $rc_vendor = &$conn->Execute('SELECT
  186.                                                 itven.vendorid,
  187.                                                 itven.status
  188.                                             FROM
  189.                                                 itemvendor  AS itven,
  190.                                                 vendor      AS ven,
  191.                                                 company     AS comp
  192.                                             WHERE
  193.                                                 itven.vendorid=ven.id
  194.                                                 AND ven.paytocompanyid=comp.id
  195.                                                 AND itven.itemid = '.$rc_item->fields[0].'
  196.                                                 AND itven.locationid = '.$almacen.'
  197.                                                 AND itven.cancel = 0
  198.                                                 AND ven.cancel=0
  199.                                                 AND comp.cancel=0
  200.                                                 AND vendorid != '.$noid.''  ); 
  201.  
  202. /*
  203.  
  204.             $rc_vendor = &$conn->Execute('SELECT
  205.                                                 vendorid,
  206.                                                 status
  207.                                             FROM
  208.                                                 itemvendor
  209.                                             WHERE
  210.                                                 itemid = '.$rc_item->fields[0].'
  211.                                                 AND locationid = '.$almacen.'
  212.                                                 AND cancel = 0
  213.                                                 AND vendorid != '.$noid.'');    */ 
  214.             while(!$rc_vendor->EOF){
  215.                 /**
  216.                  * SI NO VA POR AUTOMATICA, IMPRIME POR ACA
  217.                  */
  218.                 if($_REQUEST['automatic']!='TRUE'){
  219.                     echo "\r\n";
  220.                 }
  221.  
  222.                 $concate    .="\r\n";
  223.                 if($rc_vendor->fields[1]){ $strcompra = 'INACTIVO';}else{ $strcompra = 'ACTIVO';}
  224.                 $rc_vendorname = &$conn->Execute('SELECT

- es un informe de venta que en teoria lo hace por sucursales y productos
- es un promedio de 53.000 registros, siendo de los de menos registros
- este informe se podria optimizar pero igual hay mas informes ya optimizados, no utilizando mas de 2 tablas por consulta, pero esto no mejora,
- cuando se ejecuta varios informes se hace d varios PC
__________________
---------
cubesoftechnology.com
Wizanchez,,