pp=99999; $vc->where="(purchaseorder.postatus='Created' or purchaseorder.postatus='Approved' or purchaseorder.postatus='Delivered')"; $vc->getData(); $cnt=$vc->getCount(); $data=$vc->data; $vd=$data; function getValueByCode($data,$code,$status=""){ $r=mysql_fetch_array(mysql_query("select conversion_rate from currencies where name like 'USD'")); for($i=0;$i'; echo ''; echo $tbs1; echo $trs; echo ''; echo $tbs2; echo $trs; echo $tds11."Name".$tde1; echo $tds12."Inv qty".$tde1; echo $tds13."Inv value".$tde1; echo $tds13."Ord value".$tde1; echo $tds13."Ord on sea value".$tde1; echo $tds13."Ord approved value".$tde1; echo $tds13."Ord created value".$tde1; echo $tds13."Pur 12m".$tde1; echo $tds13."Stock m".$tde1; echo $tds13."Stock m + ord".$tde1; echo $tds13."CBM".$tde1; echo $tre; if($_GET['category'])$cw=" and id='".$_GET['category']."'"; else $cw=""; $z="select name,id from ecmproductcategories where deleted='0'".$cw." order by name"; $w=$GLOBALS['db']->query($z); $as=sum($year,$_REQUEST['account'],"","",$_REQUEST['active']); $last=getSumLast($_REQUEST['account'],$_REQUEST['active']); while($r=$GLOBALS['db']->fetchByAssoc($w)){ $ems_qty_in_stock=0; $stock_value=0; $order_value=0; $order_created_value=0; $order_approved_value=0; $order_delivered_value=0; $cbm=0; if($_GET['category']==$r['id']){ $catd=""; $imgd="basic"; } else { $catd="none;"; $imgd="advanced"; } echo $trs.$tds_cat.''.$r['name'].' '.$tde_cat; $act=""; if($_REQUEST['active']=="active")$act=" and product_active='1'"; elseif($_REQUEST['active']=="active")$act=" and product_active='0'"; $zz="select ems_qty_in_stock,ems_price,carton_volume_meter as cvm,pieces_per_carton as ppc,code from ecmproducts where product_category_id='".$r['id']."' and deleted='0'".$act; $ww=$GLOBALS['db']->query($zz); while($rr=$GLOBALS['db']->fetchByAssoc($ww)){ $ems_qty_in_stock+=$rr['ems_qty_in_stock']; $stock_value+=$rr['ems_qty_in_stock']*$rr['ems_price']; @$cbm+=$rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc']); $order_value+=getValueByCode($vd,$rr['code']); $order_created_value+=getValueByCode($vd,$rr['code'],"Created"); $order_approved_value+=getValueByCode($vd,$rr['code'],"Approved"); $order_delivered_value+=getValueByCode($vd,$rr['code'],"Delivered"); } $cbm_total+=$cbm; $ems_qty_in_stock_total+=$ems_qty_in_stock; $stock_value_total+=$stock_value; $order_value_total+=$order_value; $order_created_value_total+=$order_created_value; $order_approved_value_total+=$order_approved_value; $order_delivered_value_total+=$order_delivered_value; $sumy=getSum($as,$year,"",$r['id']); $tot_pur+=$sumy['total_purchase']; $stock_m=0; $stock_m_order=0; if($sumy['total_purchase'])$stock_m=@$stock_value/($last[$r['id']]/12); if($sumy['total_purchase'])$stock_m_order=@($stock_value+$order_value)/($last[$r['id']]/12); $stock_m_total+=$stock_m; $stock_m_order_total+=$stock_m_order; $pur12m+=$last[$r['id']]; echo $tds_cat.''.$ems_qty_in_stock.''.$tde_cat; echo $tds_cat.''.number_format($stock_value,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($order_value,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($order_delivered_value,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($order_approved_value,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($order_created_value,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($last[$r['id']]/12,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($stock_m,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($stock_m_order,0,",",".").''.$tde_cat; echo $tds_cat.''.number_format($cbm,0,",",".").''.$tde_cat; echo $tre; echo ''; $zz="select id,name,code,ems_qty_in_stock,ems_price,carton_volume_meter as cvm,pieces_per_carton as ppc from ecmproducts where product_category_id='".$r['id']."' and deleted='0'".$act." order by code asc"; $ww=$GLOBALS['db']->query($zz); while($rr=$GLOBALS['db']->fetchByAssoc($ww)){ $sumy=getSum($as,$year,$rr['id'],""); $stock_m=0; $stock_m_order=0; $o_value=0; $o_value+=getValueByCode($vd,$rr['code']); $o_c_value=0; $o_c_value+=getValueByCode($vd,$rr['code'],"Created"); $o_a_value=0; $o_a_value+=getValueByCode($vd,$rr['code'],"Approved"); $o_d_value=0; $o_d_value+=getValueByCode($vd,$rr['code'],"Delivered"); if($sumy['total_purchase'])$stock_m=@($rr['ems_qty_in_stock']*$rr['ems_price'])/($last[$rr['id']]/12); if($sumy['total_purchase'])$stock_m_order=@(($rr['ems_qty_in_stock']*$rr['ems_price'])+$o_value)/($last[$rr['id']]/12); echo $trs; echo '
'.''.$rr['code'].' '.$rr['name'].'
'.$tde; echo ''.$rr['ems_qty_in_stock'].$tde; echo ''.number_format(($rr['ems_qty_in_stock']*$rr['ems_price']),0,",",".").$tde; echo ''.number_format($o_value,0,",",".").$tde; echo ''.number_format($o_c_value,0,",",".").$tde; echo ''.number_format($o_a_value,0,",",".").$tde; echo ''.number_format($o_d_value,0,",",".").$tde; echo ''.number_format($last[$rr['id']]/12,0,",",".").$tde; echo ''.number_format($stock_m,0,",",".").$tde; echo ''.number_format($stock_m_order,0,",",".").$tde; echo ''.@number_format(($rr['ems_qty_in_stock']*($rr['cvm']/$rr['ppc'])),0,",",".").$tde; echo $tre; } echo ''; } echo $trs; echo ''.$tde; echo ''.$ems_qty_in_stock_total.$tde; echo ''.number_format(($stock_value_total),0,",",".").$tde; echo ''.number_format(($order_value_total),0,",",".").$tde; echo ''.number_format(($order_delivered_value_total),0,",",".").$tde; echo ''.number_format(($order_approved_value_total),0,",",".").$tde; echo ''.number_format(($order_created_value_total),0,",",".").$tde; echo ''.number_format($pur12m/12,0,",",".").$tde; echo ''.number_format(($stock_value_total/($pur12m/12)),0,",",".").$tde; echo ''.number_format((($stock_value_total+$order_value_total)/($pur12m/12)),0,",",".").$tde; echo ''.@number_format(($cbm_total),0,",",".").$tde; echo $tre; echo $tbe; //end 1 column echo $tde; echo '
'; //start 2 column echo $tbs; echo $trs; for($i=0;$iquery($z); while($r=$GLOBALS['db']->fetchByAssoc($w)){ echo $trs_cat; $avg_cat=0; $avg_cat_qty=0; $avg_cat_pur=0; $sumy=getSum($as,$year,"",$r['id']); $avg_cat+=$sumy["total"]; $summary_avg_cat+=$sumy['total']; $avg_cat_pur+=$sumy["total_purchase"]; $summary_avg_cat_pur+=$sumy['total_purchase']; $avg_cat_qty+=$sumy["qty"]; $summary_avg_cat_qty+=$sumy['qty']; for($i=0;$ifetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='sale'")); $rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$year."' and month='".$i."' and bean_id='".$r['id']."' and type='qty'")); if($rvs['value']<=0)$rvs['value']=$avg_cat/$mmm; if($rvq['value']<=0)$rvq['value']=$avg_cat_qty/$mmm; $ajax_cat=ajaxWindow($r['id'],$i,$rvs['value'],$_REQUEST['account'],"sale",$year); @$ajax_cat_qty=ajaxWindow($r['id'],$i,$rvq['value'],$_REQUEST['account'],"qty",$year,($avg_cat/$avg_cat_qty)); $summary['total'][$year."-".$months[$i]]+=$cat; $summary['total_purchase'][$year."-".$months[$i]]+=$cat_pur; $summary['total_qty'][$year."-".$months[$i]]+=$cat_qty; $summary['total_cbm'][$year."-".$months[$i]]+=$cbm; $summary['total'][$year]+=$cat; $summary['total_purchase'][$year]+=$cat_pur; $summary['total_qty'][$year]+=$cat_qty; $summary['total_cbm'][$year]+=$cbm; echo $tdsf1.''.number_format($cat_qty,0,"","").''.$tde; echo $tdsf2.''.number_format($avg_cat_qty/$mmm,0,"","").''.$tde; echo $tdsf2.''.number_format($cat,0,",",".").''.$tde; echo $tdsf2.''.number_format($avg_cat/$mmm,0,",",".").''.$tde; echo $tdsf2.''.number_format($cat_pur,0,",",".").''.$tde; echo $tdsf2.''.number_format($avg_cat_pur/$mmm,2,",",".").''.$tde; echo $tdsf2.''.number_format($margin,0,",",".")."%".''.$tde; echo $tdsf2.''.number_format($cbm,0,",",".").''.$tde; echo $tdsf2.''.$ajax_cat.''.$tde; echo $tdsf3.''.$ajax_cat_qty.''.$tde; } if($sumy["total_purchase"])$margin=100*($sumy["total"]-$sumy["total_purchase"])/$sumy["total"]; else $margin=0; $cbm=$sumy["cbm"]; echo $tdsfs1.''.number_format(($sumy["qty"]),0,"","").''.$tde; echo $tdsfs2.''.number_format($avg_cat_qty/$mmm,0,"","").''.$tde; echo $tdsfs2.''.number_format($sumy["total"],0,",",".").''.$tde; echo $tdsfs2.''.number_format($avg_cat/$mmm,0,",",".").''.$tde; echo $tdsfs2.''.number_format($sumy["total_purchase"],0,",",".").''.$tde; echo $tdsfs2.''.number_format($avg_cat_pur/$mmm,0,",",".").''.$tde; echo $tdsfs2.''.number_format($margin,0,",",".").'%'.$tde; echo $tdsfs2.''.number_format($cbm,0,",",".").''.$tde; echo $tdsfs2.''.number_format($avg_cat/$mmm,0,",",".").''.$tde; echo $tdsfs2.''.number_format($avg_cat_qty/$mmm,0,"","").''.$tde; echo $tre; if($_GET['category']==$r['id'])$catd=""; else $catd="none;"; echo ''; echo ''; } echo $trs_cat; $avg_cat=0; $avg_cat_qty=0; for($i=0;$i'.$tde; echo $tre; echo $tbe; ?>