Ayuda para verificar Query SQL
Cuando ejecuto esta Query integrada a un PHP tengo problemas para visualiar los datos dado que no me figuran todos los datos me pueden hechar una mano?
‘3’ AND
a.RECEIPT_STATUS IN (‘0′,’1’) AND
e.STOCK_TYPE <> ‘#’ AND e.STOCK_TYPE <> ‘1’ AND
e.CLASS <> ‘P’ AND
c.ITEM_141_STAT = ‘6’ AND
(a.DSTRCT_CODE = ‘1ZNA’ OR a.DSTRCT_CODE=’2ZNA’ OR a.DSTRCT_CODE=’3ZNA’ OR a.DSTRCT_CODE= ‘4ZNA’ OR a.DSTRCT_CODE= ‘5ZNA’ OR a.DSTRCT_CODE=’FLTA’) AND
e.STOCK_TYPE = ‘#’ AND
a.CURR_QTY_P > 0 AND
a.CURR_QTY_P > a.QTY_RCV_DIR_I
and round(sysdate – to_date(c. last_acq_date, ‘yyyymmdd’),0) <= 30
group by a.DSTRCT_CODE
order by a.DSTRCT_CODE";
$personal = $db->Execute($sql);
$zna1_21=0;
$zna2_21=0;
$zna3_21=0;
$zna4_21=0;
$zna5_21=0;
$flta_21=0;
while (!$personal->EOF){
$paso= $personal->fields[1]*1 ;
if ( $paso > $max){
$max=$paso;
}
if ($personal->fields[0]==’1ZNA’){
$zna1_21=$personal->fields[1];
}
if ($personal->fields[0]==’2ZNA’){
$zna2_21=$personal->fields[1];
}
if ($personal->fields[0]==’3ZNA’){
$zna3_21=$personal->fields[1];
}
if ($personal->fields[0]==’4ZNA’){
$zna4_21=$personal->fields[1];
}
if ($personal->fields[0]==’5ZNA’){
$zna5_21=$personal->fields[1];
}
if ($personal->fields[0]==’FLTA’){
$flta_21=$personal->fields[1];
}
$personal->movenext();
}
// 6 a 9 AND
$t1 =$zna1_21 + $zna2_21 + $zna3_21 + $zna4_21 + $zna5_21 + $flta_21;
$sql = «SELECT a.DSTRCT_CODE, count(a.PO_ITEM_NO) as cant
FROM MSF221 a, MSF220 b, MSF141 c, MSF100 e, MSF140 f
WHERE b.DSTRCT_CODE = a.DSTRCT_CODE AND
b.SUPPLIER_NO = c.DSTRCT_CODE AND
c.DSTRCT_CODE = f.DSTRCT_CODE AND
a.IREQ_NO = f.IREQ_NO AND
a.PREQ_STK_CODE = c.STOCK_CODE AND
a.PREQ_STK_CODE = e.STOCK_CODE AND
a.IREQ_NO = c.IREQ_NO AND
a.IREQ_ITEM = c.IREQ_ITEM AND
b.PO_NO = a.PO_NO AND
a.STATUS_221 <> ‘3’ AND
a.RECEIPT_STATUS IN (‘0′,’1’) AND
e.class = ‘C’ and
c.ITEM_141_STAT = ‘6’ AND
(a.DSTRCT_CODE = ‘1ZNA’ OR a.DSTRCT_CODE=’2ZNA’ OR a.DSTRCT_CODE=’3ZNA’ OR a.DSTRCT_CODE= ‘4ZNA’ OR a.DSTRCT_CODE= ‘5ZNA’ OR a.DSTRCT_CODE=’FLTA’) AND
e.STOCK_TYPE = ‘#’ AND
a.CURR_QTY_P > 0 AND
a.CURR_QTY_P > a.QTY_RCV_DIR_I
and round(sysdate – to_date(c. last_acq_date, ‘yyyymmdd’),0) > 30
and round(sysdate – to_date(c. last_acq_date, ‘yyyymmdd’),0) <= 60
group by a.DSTRCT_CODE
order by a.DSTRCT_CODE";
$personal = $db->Execute($sql);
$zna1_22=0;
$zna2_22=0;
$zna3_22=0;
$zna4_22=0;
$zna5_22=0;
$flta_21=0;
while (!$personal->EOF){
$paso= $personal->fields[1]*1 ;
if ( $paso > $max){
$max=$paso;
}
if ($personal->fields[0]==’1ZNA’){
$zna1_22=$personal->fields[1];
}
if ($personal->fields[0]==’2ZNA’){
$zna2_22=$personal->fields[1];
}
if ($personal->fields[0]==’3ZNA’){
$zna3_22=$personal->fields[1];
}
if ($personal->fields[0]==’4ZNA’){
$zna4_22=$personal->fields[1];
}
if ($personal->fields[0]==’5ZNA’){
$zna5_22=$personal->fields[1];
}
if ($personal->fields[0]==’FLTA’){
$flta_22=$personal->fields[1];
}
$personal->movenext();
}
$t2 =$zna1_22 + $zna2_22 + $zna3_22 + $zna4_22 + $zna5_22 + $flta_22;
$sql = «SELECT a.DSTRCT_CODE, count(a.PO_ITEM_NO) as cant
FROM MSF221 a, MSF220 b, MSF141 c, MSF100 e, MSF140 f
WHERE b.DSTRCT_CODE = a.DSTRCT_CODE AND
b.SUPPLIER_NO = c.DSTRCT_CODE AND
c.DSTRCT_CODE = f.DSTRCT_CODE AND
a.IREQ_NO = f.IREQ_NO AND
a.PREQ_STK_CODE = c.STOCK_CODE AND
a.PREQ_STK_CODE = e.STOCK_CODE AND
a.IREQ_NO = c.IREQ_NO AND
a.IREQ_ITEM = c.IREQ_ITEM AND
b.PO_NO = a.PO_NO AND
a.STATUS_221 <> ‘3’ AND
a.RECEIPT_STATUS IN (‘0′,’1’) AND
e.class = ‘C’ and
c.ITEM_141_STAT = ‘6’ AND
(a.DSTRCT_CODE = ‘1ZNA’ OR a.DSTRCT_CODE=’2ZNA’ OR a.DSTRCT_CODE=’3ZNA’ OR a.DSTRCT_CODE= ‘4ZNA’ OR a.DSTRCT_CODE= ‘5ZNA’ OR a.DSTRCT_CODE=’ROPA’) AND
e.STOCK_TYPE = ‘#’ AND
a.CURR_QTY_P > 0 AND
a.CURR_QTY_P > a.QTY_RCV_DIR_I
and round(sysdate – to_date(c. last_acq_date, ‘yyyymmdd’),0) > 60
group by a.DSTRCT_CODE
order by a.DSTRCT_CODE»;
$personal = $db->Execute($sql);
$zna1_23=0;
$zna2_23=0;
$zna3_23=0;
$zna4_23=0;
$zna5_23=0;
$ropa_23=0;
while (!$personal->EOF){
$paso= $personal->fields[1]*1 ;
if ( $paso > $max){
$max=$paso;
}
if ($personal->fields[0]==’1ZNA’){
$zna1_23=$personal->fields[1];
}
if ($personal->fields[0]==’2ZNA’){
$zna2_23=$personal->fields[1];
}
if ($personal->fields[0]==’3ZNA’){
$zna3_23=$personal->fields[1];
}
if ($personal->fields[0]==’4ZNA’){
$zna4_23=$personal->fields[1];
}
if ($personal->fields[0]==’5ZNA’){
$zna5_23=$personal->fields[1];
}
if ($personal->fields[0]==’FLTA’){
$flta_23=$personal->fields[1];
}
$personal->movenext();
}
$t3 =$zna1_23 + $zna2_23 + $zna3_23 + $zna4_23 + $zna5_23 + $flta_23;
$html=»
ESTADO | 1ZNA | 2ZNA | 3ZNA | 4ZNA | 5ZNA | FLTA | TOTAL |
<= 30 (dias) | «.number_format($zna1_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna2_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna3_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna4_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna5_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($ropa_21,$decimales,$sep_dec,$sep_mil).» | «.number_format($t1,$decimales,$sep_dec,$sep_mil).» |
>30 y <=60 (dias) | «.number_format($zna1_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna2_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna3_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna4_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna5_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($ropa_22,$decimales,$sep_dec,$sep_mil).» | «.number_format($t2,$decimales,$sep_dec,$sep_mil).» |
> 60 (dias) | «.number_format($zna1_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna2_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna3_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna4_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($zna5_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($ropa_23,$decimales,$sep_dec,$sep_mil).» | «.number_format($t3,$decimales,$sep_dec,$sep_mil).» |
«;
print($html);
$total = $t1 + $t2 + $t3;
$p1 = round($t1 *100 / $total,2);
$p2 = round($t2 *100 / $total,2);
$p3 = round($t3 *100 / $total,2);
$title = new title( ‘ITEMS EN PEDIMENTOS DE UURR’);
$title->set_style( «{font-size: 18px; color: #0000FF; text-align: center;}» );
$pie = new pie();
$pie->set_alpha(0.6);
$pie->set_start_angle( 35 );
$pie->add_animation( new pie_fade() );
$pie->set_tooltip( ‘#val# de #total#
#percent# de 100%’ );
$pie->set_colours( array(‘#008000′,’#FFFF00′,’#FF0000’) );
$d = array();
$tmp = new pie_value($t1*1,»SERVICIO DE BODEGA <= 30 (dias) (".$p1.")");
$tmp->set_colour( ‘#008000’ );
$tmp->set_label($p1.»%», «#0000FF», 16 );
$d[] = $tmp;
$tmp = new pie_value($t2*1,»SERVICIO DE BODEGA >30 y <=60 (dias) (".$p2.")");
$tmp->set_colour( ‘#FFFF00’ );
$tmp->set_label($p2.»%», «#0000FF», 16 );
$d[] = $tmp;
$tmp = new pie_value($t3*1,»SERVICIO DE BODEGA > 30 (dias) («.$p3.»)»);
$tmp->set_colour( ‘#FF0000’ );
$tmp->set_label($p3.»%», «#0000FF», 16 );
$d[] = $tmp;
$pie->set_values($d);
$chart = new open_flash_chart();
//$chart->set_title( $title );
$chart->add_element( $pie );
$chart->x_axis = null;
$chart->set_bg_colour( ‘#FFFFFF’ );
$fp = fopen(«data03.txt»,»w»);
fwrite($fp,$chart->toPrettyString());
fclose($fp);
}
?>