"January","02"=>"February","03"=>"March","04"=>"April","05"=>"May","06"=>"June","07"=>"July","08"=>"August","09"=>"September","10"=>"October","11"=>"November","12"=>"December"); include_once("modules/EcmReports/cache.php"); $as=sum($_REQUEST['year'],$_REQUEST['account'],"",$_REQUEST['id'],$_REQUEST['active']); $_REQUEST['mmm']=(int)date("m")-1; $act=""; if($_REQUEST['active']=="active")$act=" and product_active='1'"; elseif($_REQUEST['active']=="active")$act=" and product_active='0'"; $zz="select id,name,code from ecmproducts where product_category_id='".$_REQUEST['id']."' and deleted='0'".$act." order by code asc"; $ww=$GLOBALS['db']->query($zz); while($rr=$GLOBALS['db']->fetchByAssoc($ww)){ $t.=$trs; $avg_p=0; $avg_p_qty=0; $avg_p_pur=0; $sumy=getSum($as,$_REQUEST['year'],$rr['id'],$_REQUEST['id']); //for($i=0;$ifetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$_REQUEST['year']."' and month='".$i."' and bean_id='".$rr['id']."' and type='sale'")); $rvq=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select value from ecmsalesreports_predictions_cat where account_id='".$_REQUEST['account']."' and year='".$_REQUEST['year']."' and month='".$i."' and bean_id='".$rr['id']."' and type='qty'")); $ajax_cat=ajaxWindow($rr['id'],$i,$rvs['value'],$_REQUEST['account'],"sale",$year); $ajax_cat_qty=ajaxWindow($rr['id'],$i,$rvq['value'],$_REQUEST['account'],"qty",$year); $t.=$tdsf1.number_format($p_qty,2,",",".").$tde; $t.=$tdsf2.number_format($avg_p_qty/$_REQUEST['mmm'],0,"","").$tde; $t.=$tdsf2.number_format($p,2,",",".").$tde; $t.=$tdsf2.number_format($avg_p/$_REQUEST['mmm'],2,",",".").$tde; $t.=$tdsf2.number_format($p_pur,2,",",".").$tde; $t.=$tdsf2.number_format($avg_p_pur/$_REQUEST['mmm'],2,",",".").$tde; $t.=$tdsf2.number_format($margin,2,",",".")."%".$tde; $t.=$tdsf2.number_format($cbm,2,",",".").$tde; $t.=$tdsf2.$ajax_cat.$tde; $t.=$tdsf2.$ajax_cat_qty.$tde; } $s_pur=$sumy["total_purchase"]; $s_qty=$sumy["total_qty"]; $s=$sumy["total"]; $cbm=$sumy["cbm"]; if($s)$margin=100*($s-$s_pur)/$s; else $margin=0; if(!$s)$s=number_format(0,2,",","."); $t.=$tdsfs1.''.number_format(($sumy["qty"]),0,"","").''.$tde; $t.=$tdsfs2.number_format($avg_p_qty/$_REQUEST['mmm'],0,"","").$tde; $t.=$tdsfs2.''.number_format($s,2,",",".").''.$tde; $t.=$tdsfs2.number_format($avg_p/$_REQUEST['mmm'],2,",",".").$tde; $t.=$tdsfs2.''.number_format($s_pur,2,",",".").''.$tde; $t.=$tdsfs2.number_format($avg_p_pur/$_REQUEST['mmm'],2,",",".").$tde; $t.=$tdsfs2.''.number_format($margin,2,",",".").'%'.$tde; $t.=$tdsfs2.''.number_format($cbm,2,",",".").''.$tde; $t.=$tdsfs2.number_format($avg_p/$_REQUEST['mmm'],2,",",".").$tde; $t.=$tdsfs2.number_format($avg_p_qty/$_REQUEST['mmm'],0,"","").$tde; $t.=$tre; } echo $t; ?>