$val) { if ($i%2==0) $bgcolor="#E9F3FF"; else $bgcolor="#FFFFFF"; //$sql="select group_concat(b.id) as po_id, sum(CASE WHEN b.is_confirmed=1 THEN b.po_quantity*a.total_set_qnty END) AS 'confPoQty', sum(CASE WHEN b.is_confirmed=2 THEN b.po_quantity*a.total_set_qnty END) AS 'projPoQty' from wo_po_details_master as a, wo_po_break_down as b where a.job_no=b.job_no_mst and a.is_deleted=0 and a.status_active=1 and b.is_deleted=0 and b.status_active=1 and b.pub_shipment_date like '".$val."-%"."'"; $sql="select b.id as po_id, a.country_id, sum(CASE WHEN b.is_confirmed=1 THEN a.order_quantity ELSE 0 END) AS 'confpoqty', sum(CASE WHEN b.is_confirmed=2 THEN a.order_quantity ELSE 0 END) AS 'projpoqty' from wo_po_color_size_breakdown as a, wo_po_break_down as b, wo_po_details_master as c where a.po_break_down_id=b.id and b.job_no_mst=c.job_no and c.company_name in($manufacturing_company) and a.is_deleted=0 and a.status_active=1 and b.is_deleted=0 and b.status_active=1 and c.is_deleted=0 and c.status_active=1 and a.country_ship_date like '".$val."-%"."' group by b.id, a.country_id"; //echo $sql ;die; $result=sql_select($sql); /*$projPoQty=$result[0]['projPoQty']; $confPoQty=$result[0]['confPoQty']; $totQty=$projPoQty+$confPoQty; $exFactoryQty=0; $po_id=explode(",",$result[0]['po_id']); foreach($po_id as $id) { $exFactoryQty+=$exFactory_arr[$id]; }*/ $confPoQty=0; $projPoQty=0; $exFactoryQty=0; foreach($result as $row) { $confPoQty+=$row[csf('confpoqty')]; $projPoQty+=$row[csf('projpoqty')]; $exFactoryQty+=$exFactory_arr[$row[csf('po_id')]][$row[csf('country_id')]]; } $totQty=$projPoQty+$confPoQty; $perc=($exFactoryQty/$totQty)*100; echo '
'; echo ''.date("M",strtotime($val))."'".date("y",strtotime($val)).' '.number_format($projPoQty,0).' '.number_format($confPoQty,0).' '.number_format($totQty,0).' '.number_format($exFactoryQty,0).' '.number_format($perc,2).''; echo '
'; $totProjQty+=$projPoQty; $totConfQty+=$confPoQty; $totExFactoryQty+=$exFactoryQty; $grandTotQty+=$totQty; $i++; } ?>