';
//$arr['category_name']=$r['product_category_name'];
//$arr['product_code']=$r['code'];
$arr['date']=$r['register_date'];
$arr['account_id']=$r['parent_id'];
//$arr['account_name']=$r['parent_name'];
$arr['cvm']=$r['cvm'];
$arr['ppc']=$r['ppc'];
$arr['currency_value']=$currency_value;
$arr['wz']=$r['wz_id'];
$arr['parent_account_id']=$r['wz_parent_id'];
if($r['ppc']>0)$arr['cbm']=$r['quantity']*($r['cvm']/$r['ppc']);
if($r['type']!="correct"){
$purchase_price=$r['purchase_price'];
$total_price=$currency_value*($r['price']*$r['quantity']);
$total_qty=$r['quantity'];
$total_purchase_price=$purchase_price*$r['quantity'];
if($r['ppc']>0)$arr['cbm']=$r['quantity']*($r['cvm']/$r['ppc']);
}
else{
$zz="select price,quantity,purchase_price from ecminvoiceoutitems where id='".$r['item_id']."'";
$rcor=mysql_fetch_array(mysql_query($zz));
$purchase_price=$rcor['purchase_price'];
$total_price=$currency_value*($r['price']*$r['quantity']-$rcor['price']*$rcor['quantity']);
$total_qty=$r['quantity']-$rcor['quantity'];
$total_purchase_price=$purchase_price*($r['quantity']-$rcor['quantity']);
if($r['ppc']>0)$arr['cbm']=($r['quantity']-$rcor['quantity'])*($r['cvm']/$r['ppc']);
}
$arr['price']=$r['price'];
$arr['purchase_price']=$purchase_price;
$arr['total_price']=$total_price;
$arr['total_purchase_price']=$total_purchase_price;
$arr['total_qty']=$total_qty;
//if(eregi("2010-01",$arr['date']))echo $arr['purchase_price'].' '.$r['iditem'].' '.$arr['price'].' '.$arr['total_qty'].'
';
$row[]=$arr;
}
return $row;
}
function ajaxWindow($id,$i,$value,$account,$type,$year,$price=0){
if($price){
$pp='mintajaxget(\'index.php?to_pdf=1&module=EcmReports&action=setValRep&account_id='.$account.'&year='.$year.'&month='.$i.'&type=sale&bean_id='.$id.'&value=\'+(parseInt(document.getElementById(\'value'.$id.'_'.$i.'_qty\').value)*'.((float)$price).'),\'new'.$id.'_'.$i.'_sale\');document.getElementById(\'div'.$id.'_'.$i.'_sale\').style.display=\'none\';';
}
else $pp='';
$ajax='
';
return $ajax;
}
function getSum($arr,$year,$product_id="",$category_id=""){
if(count($arr)>0){
foreach($arr as $a){
if($product_id && $product_id!=$a['product_id'])continue;
if($category_id && $category_id!=$a['category_id'])continue;
if(!eregi($year,$a['date']))continue;
$total+=$a['total_price'];
$qty+=$a['total_qty'];
$total_purchase+=$a['total_purchase_price'];
$cbm+=$a['cbm'];
}
}
return array("total"=>$total,"qty"=>$qty,"total_purchase"=>$total_purchase,"cbm"=>$cbm);
}
function sumCat($year,$month,$account,$type){
$w=mysql_query("select id from ecmproductcategories where deleted='0'");
while($r=mysql_fetch_array($w)){
$arr[]="bean_id='".$r['id']."'";
}
$r=mysql_fetch_array(mysql_query("select sum(value) as sum from ecmsalesreports_predictions_cat where deleted='0' and type='".$type."' and account_id='".$account."' and month='".$month."' and year='".$year."' and (".implode(" or ",$arr).")"));
return $r['sum'];
}
$year=$_GET['year'];
if(!$year)$year=(int)date("Y");
if($year==date("Y")){
$mmm=(int)date("m")-1;
}
else $mmm=12;
if(!$mmm)$mmm=1;
//if(!$_REQUEST['account'])$_REQUEST['account']=134;
//if(!$_REQUEST['active'])$_REQUEST['active']="active";
$trs='| '; $tds12=' | '; $tds13=' | '; $tds13=' | '; $tds2=' | '; $tds22=' | '; $tds3=' | '; $tds4=' | '; $tbe=' |