Respuesta: Problema PHP se cortan los procesos _ te doy una parte
Código PHP:
Ver original $reemplazar = array("<SPAN CLASS=TEXTITULO >","</SPAN>","&","-GT;","|"); $reemplazarB = array("<SPAN CLASS=TEXTITULO >","</SPAN>","&","-GT;"); foreach($locationids as $key=>$almacen){ if($almacen>0){ $rc_almacen = &$conn->Execute(' SELECT UPPER(company.companyname) FROM inventorylocation,company WHERE inventorylocation.id = '.$almacen.' AND inventorylocation.companyid=company.id and company.cancel=0 order by company.companyname'); foreach($ITEMID as $b=>$itemid){ $SQL='SELECT itemid, SUM(qty), SUM(sales_vr*qty), SUM(itemcost*qty), SUM(itemvta*qty), SUM(costnet*qty), SUM(total_sales) as precio_total, SUM(sales_dcto) as descuento_total FROM sales_log WHERE itemid = "'.$itemid.'" AND locationid = "'.$almacen.'" AND date >= "'.$FechaIni.'" AND date <= "'.$FechaFinal.'" AND cancel = 0 GROUP BY itemid'; if($rc_item = &$conn->Execute($SQL)===false) {echo 'Error SQL{'.$SQL.'}';exit;} /*itemid = "'.$itemid.'" AND*/ if(!$rc_item->EOF){ while(!$rc_item->EOF){ $InfoItem = $ItemD->infoqtycostprice($rc_item->fields[0],$almacen); $ivaitem = $ItemD->itemIvA($rc_item->fields[0]); $PVPsinIva = ($rc_item->fields[2]*100)/(100+$ivaitem); $PVPsinIvaPig = ($rc_item->fields[4]*100)/(100+$ivaitem); ${"POSvta".$itemid}[] = $rc_item->fields[2]/$rc_item->fields[1]; ${"PILOGvta".$itemid}[] = $rc_item->fields[4]/$rc_item->fields[1]; $precio_total = $rc_item->fields['precio_total']; $descuento_total = $rc_item->fields['descuento_total']; //unidades vendidas por almacen ${"qty".$itemid.'_'.$almacen} = $rc_item->fields[1]; $agrupacion = trim(str_replace($reemplazarB,"|",$ItemD->itempurchase($rc_item->fields[0],'pay'))); ############ ###################### ############################### ########################################## ########################### /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ echo $rc_almacen->fields[0].'|'.$ItemD->itemplu($rc_item->fields[0]).'|'; } $concate .=$rc_almacen->fields[0].'|'.$ItemD->itemplu($rc_item->fields[0]).'|'; $salto = 1; $VecBarcod = $ItemD->Barcode($rc_item->fields[0]); for($h=0;$h<count($VecBarcod);$h++){ ############ ###################### ############################### ########################################## ########################### /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ echo trim($VecBarcod[$h]).' '; } $concate .=trim($VecBarcod[$h]).' '; } ############ ###################### ############################### ########################################## ########################### /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ 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'))).'|'; $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'))).'|'; } $SLP=' SELECT itven.vendorid, itven.status FROM itemvendor AS itven, vendor AS ven, company AS comp WHERE itven.itemid = '.$rc_item->fields[0].' AND itven.locationid = '.$almacen.' '.$strVendorid.' AND itven.vendorid=ven.id AND ven.cancel=0 AND itven.cancel = 0 AND ven.paytocompanyid=comp.id AND comp.cancel=0 LIMIT 1'; if( $rc_vendor = &$conn->Execute($SLP)===false) {echo 'Error SQL {'.$rc_vendor.'}';} //echo $SLP; if($rc_vendor->RecordCount() === 0){ /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ echo '?|?|?|?|'; } $concate .='?|?|?|?|'; }else{ while(!$rc_vendor->EOF){ if($rc_vendor->fields[1]){ $strcompra = 'INACTIVO'; }else{ $strcompra = 'ACTIVO'; } $noid = $rc_vendor->fields[0]; $rc_vendorname = &$conn->Execute(' SELECT UPPER(c.companyname) FROM company c, vendor v WHERE v.paytocompanyid = c.id AND v.id = '.$rc_vendor->fields[0].''); $vendornombre = trim(str_replace($reemplazar,"",$rc_vendorname->fields[0])); ############ ###################### ############################### ########################################## ########################### /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ 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]).'|'; } $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]).'|'; $rc_vendor->MoveNext(); } } ############ ###################### ############################### ########################################## ########################### /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ 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; } $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; if($rc_vendor->RecordCount() === 1 && !$vendorid){ $rc_vendor = &$conn->Execute('SELECT itven.vendorid, itven.status FROM itemvendor AS itven, vendor AS ven, company AS comp WHERE itven.vendorid=ven.id AND ven.paytocompanyid=comp.id AND itven.itemid = '.$rc_item->fields[0].' AND itven.locationid = '.$almacen.' AND itven.cancel = 0 AND ven.cancel=0 AND comp.cancel=0 AND vendorid != '.$noid.'' ); /* $rc_vendor = &$conn->Execute('SELECT vendorid, status FROM itemvendor WHERE itemid = '.$rc_item->fields[0].' AND locationid = '.$almacen.' AND cancel = 0 AND vendorid != '.$noid.''); */ while(!$rc_vendor->EOF){ /** * SI NO VA POR AUTOMATICA, IMPRIME POR ACA */ if($_REQUEST['automatic']!='TRUE'){ echo "\r\n"; } $concate .="\r\n"; if($rc_vendor->fields[1]){ $strcompra = 'INACTIVO';}else{ $strcompra = 'ACTIVO';} $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,, |