'".$ddate."' limit 100"; $w=mysql_query("select ecminvoiceoutitems.price as price,ecminvoiceoutitems.quantity as quantity,ecminvoiceouts.register_date as date from ecminvoiceoutitems inner join ecminvoiceouts on ecminvoiceoutitems.ecminvoiceout_id=ecminvoiceouts.id where ecminvoiceoutitems.ecmproduct_id='".$code."' and ecminvoiceouts.type!='correct' and ecminvoiceouts.register_date>'".$ddate."'"); //$w=mysql_query("select ecmproducts_fk_list.price as price,ecmproducts_fk_list.quantity as quantity,ecmproducts_fk_list.no as no,ecmproducts_fk_list.date as date from ecmproducts_fk_list where ecmproducts_fk_list.code like '".$code."'"); while($r=mysql_fetch_array($w)){ $date=date("Y-m"); $m=(int)date("m"); $date1=date("Y-m",mktime(0,0,0,($m-1),1,date("Y"))); $date2=date("Y-m",mktime(0,0,0,($m-2),1,date("Y"))); $date3=date("Y-m",mktime(0,0,0,($m-3),1,date("Y"))); $d=explode("-",$r['date']); $dd=$d[0]."-".$d[1]; if($dd==$date){ $sale0+=$r['price']*$r['quantity']; $qty0+=$r['quantity']; $aq0[$r['no']]+=$r['quantity']; } if($dd==$date1 || $dd==$date2 || $dd==$date3){ $sale90+=$r['price']*$r['quantity']; $qty90+=$r['quantity']; $aq90[$r['no']]+=$r['quantity']; } //if($dd==$date1 || $dd==$date2 || $dd==$date3){ $sale1+=$r['price']*$r['quantity']; $qty1+=$r['quantity']; $aq1[$r['no']]+=$r['quantity']; //} } if($qty0>0)$SALE_AVG_PRICE0=round($sale0/$qty0,2); if($qty90>0)$SALE_AVG_PRICE90=round($sale90/$qty90,2); return array( "qty0"=>$qty0, "qty90"=>($qty90/3), "qty1"=>($qty1/12), "sale0"=>$sale0, "sale90"=>$sale90, "sale1"=>$sale1, "avg0"=>$SALE_AVG_PRICE0, "avg90"=>$SALE_AVG_PRICE90, ); } $vc=new vtigerConnector(); $vc->start=$_GET['start']+1; //$wc[]="purchaseorder.tracking_no=''"; $wh[]="1=1"; if($_GET['submit']){ if($_GET['product_category_id'])$wh[]="product_category_id='".$_GET['product_category_id']."'"; if($_GET['product_name'])$wh[]="name like '".$_GET['product_name']."%'"; if($_GET['product_code'])$wh[]="code like '".$_GET['product_code']."%'"; if($_GET['active']){ if($_GET['active']=="yes")$wh[]="product_active='1'"; if($_GET['active']=="no")$wh[]="product_active='0'"; } if($_GET['production']){ if($_GET['production']=="yes")$wh[]="production='1'"; if($_GET['production']=="no")$wh[]="production='0'"; } if($_GET['end_of_line']){ if($_GET['end_of_line']=="yes")$wh[]="end_of_line='1'"; if($_GET['end_of_line']=="no")$wh[]="end_of_line='0'"; } } //$vc->where=@implode(" and ",$wc); if(!$_GET['start'])$limit="0,".$vc->pp; else $limit=$_GET['start'].",".$vc->pp; if($_GET['order_by'])$order_by=$_GET['order_by']; else $order_by="name"; if($_GET['sorder'])$sorder=$_GET['sorder']; else $sorder="desc"; //$vc->where=@implode(" and ",$wc); $vc->getData(); $cnt=$vc->getCount(); $data=$vc->data; for($i=0;$i"; $qty_pom=$dat[strtoupper($data[$i]['productcode'])]['quantity']; if($dat[strtoupper($data[$i]['productcode'])]['deliverydate'])$dd_pom[strtoupper($data[$i]['productcode'])]=$dat[strtoupper($data[$i]['productcode'])]['deliverydate']; $dat[strtoupper($data[$i]['productcode'])]=$data[$i]; //$dat[strtoupper($data[$i]['productcode'])]['deliverydate']=$data[$i]['deliverydate']; $dat[strtoupper($data[$i]['productcode'])]['quantity']=$qty_pom+$dat[strtoupper($data[$i]['productcode'])]['quantity']; if($dd_pom[strtoupper($data[$i]['productcode'])]>$data[$i]['deliverydate'])$dat[strtoupper($data[$i]['productcode'])]['deliverydate']=$data[$i]['deliverydate']; } $data=$dat; if($_REQUEST['die']==1){ echo '
';
print_r($data);
echo '
'; die(); } $_SESSION['EcmProductReportsData']=$data; ?>
EcmProducts

Products Reports: Products to orders


Product Code Category
Active Production End of line
 

Products List

pp>=$vc->count && $_GET['start']-$vc->pp>0){ // >= >= $btns=array(0,0,0,0); } elseif($_GET['start']+$vc->pp<$vc->count && $_GET['start']-$vc->pp>=0){ // < >= $btns=array(1,1,1,1); } elseif($_GET['start']+$vc->pp>=$vc->count){ // >= < $btns=array(1,1,0,0); } elseif($_GET['start']+$vc->pp<$vc->count && $_GET['start']-$vc->pp<0){ // < < $btns=array(0,0,1,1); } print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print ''; print ''; ?> '; print ''; print $vc->sortableColumn("Product","name",$_GET['sorder'],20,"index"); print $vc->sortableColumn("Code","code",$_GET['sorder'],5,"index"); print $vc->sortableColumn("Category","product_category_name",$_GET['sorder'],10,"index"); print $vc->sortableColumn("Inv pcs","ems_qty_in_stock",$_GET['sorder'],5,"index"); print $vc->sortableColumn("Ord pcs","name",$_GET['sorder'],7,"index"); print $vc->sortableColumn("Delivery Date","deliverydate",$_GET['sorder'],10,"index"); print $vc->sortableColumn("Inv+Ord","ems_qty_in_stock",$_GET['sorder'],7,"index"); print $vc->sortableColumn("Qty 12m","qty90",$_GET['sorder'],10,"index"); print $vc->sortableColumn("Qty this m","qty0",$_GET['sorder'],10,"index"); print $vc->sortableColumn("Stock m + ord","stock_month",$_GET['sorder'],7,"index"); print $vc->sortableColumn("Pricebook","name",$_GET['sorder'],10,"index"); print $vc->sortableColumn("Bestsell","name",$_GET['sorder'],7,"index"); print ''; include_once('modules/EcmCharts/chartHelper.php'); $s=sum(2009); if($_GET['product_category_id'])$wh_cat=" and product_category_id='".$_GET['product_category_id']."'"; else $wh_cat=""; if($_GET['active']){ if($_GET['active']=="yes")$wh_act=" and product_active='1'"; if($_GET['active']=="no")$wh_act=" and product_active='0'"; } else $wh_act=""; if($_GET['production']){ if($_GET['production']=="yes")$wh_p=" and production='1'"; if($_GET['production']=="no")$wh_p=" and production='0'"; } else $wh_p=""; if($_GET['end_of_line']){ if($_GET['end_of_line']=="yes")$wh_e=" and end_of_line='1'"; if($_GET['end_of_line']=="no")$wh_e=" and end_of_line='0'"; } else $wh_e=""; $w=mysql_query("select id,code,name from ecmproducts where deleted='0' and product_category_id is not null ".$wh_e." ".$wh_p." ".$wh_act." ".$wh_cat); $i=0; $sum=0; echo mysql_error(); while($r=mysql_fetch_array($w)){ $ss=$s[2009]; if($ss['product_sum_'.$r['id']]-$ss['product_pur_sum_'.$r['id']]<0)$value=0; else $value=$ss['product_sum_'.$r['id']]-$ss['product_pur_sum_'.$r['id']]; $sum+=$value; $ii++; $arr[]=array( "name"=>$r['code'], "name1"=>$r['name'], "value"=>$value, ); } $arr=multisort($arr,array(array('key'=>'value','sort'=>'desc'))); $i=0; if(count($arr)>0){ foreach($arr as $best){ if($best['value']>$sum/$ii)$bests[]=$best['name']; $i++; } } $w=mysql_query("select * from ecmproducts where deleted='0' and product_category_id is not null and ".implode(" and ",$wh)." order by ".$order_by." ".$sorder); print ''; while($r=mysql_fetch_array($w)){ $id=$r['id']; //if(mysql_num_rows(mysql_query("select id from ecmproductcomponents where ecmproduct_id='".$id."' and deleted='0'"))>0)continue; $gs=getSales($id); $inv_value=$r['ems_qty_in_stock']; $inv_qty=$r['ems_qty_in_stock']; $inv_price=$r['ems_price']; $deliverydate=$data[strtoupper($r['code'])]['deliverydate']; $_ord=0; //if(!$data[$r['code']."_S"]['quantity']){ //$ww=mysql_query("select ordered from ecmproducts where code like '".$r['code']."_S' and deleted='0'"); //while($rr=mysql_fetch_array($ww))$_ord+=$rr['ordered']; //} //else{ //$_ord+=$data[$r['code']."_S"]['quantity']; //$_ord+=$data[$r['code']."_s"]['quantity']; //} $_ord+=$data[strtoupper($r['code'])."_S"]['quantity']; $_ord+=$data[strtoupper($r['code'])."_s"]['quantity']; $_ord+=$data[strtoupper($r['code'])]['quantity']; print ''; print ''; print ''; print ''; print ''; if(@in_array($r['code'],$bests))$b="B"; else $b=""; print ''; print ''; print ''; print ''; print ''; print ''; if($gs['qty1']>$gs['qty0'])$avg=$gs['qty1']; else $avg=$gs['qty0']; if($avg)@$stockm=number_format(floor(($inv_value+$_ord)/($avg)),0,"",""); else $stockm="err"; mysql_query("update ecmproducts set stock_month='".$stockm."',qty0='".$gs['qty0']."',qty90='".$gs['qty1']."' where id='".$r['id']."'"); //if(($deliverydate<$pom[$r['id']] || !$pom[$r['id']]) && $deliverydate)$pom[$r['id']]=$deliverydate; //if($pom[$r['id']])mysql_query("update ecmproducts set deliverydate='".$pom[$r['id']]."' where id='".$r['id']."'"); print ''; //pricebook $accounts=array("Auchan","Carrefour","Euro","Real"); $dig=array(); foreach($accounts as $account){ $www=mysql_query("select p.id from ecmpricebooks_ecmproducts as p inner join ecmpricebooks as e on e.id=p.ecmpricebook_id where p.ecmproduct_id='".$id."' and e.name='".$account."' and e.deleted='0' and p.deleted='0'"); if(mysql_num_rows($www)>0)$dig[]=$account[0]; } print ''; print ''; print ''; } print ''; print '
$v)$link.=$k."=".$v."&"; print ' '; ?>
'.$r['name'].''.$r['code'].''.$r['product_category_name'].''.number_format($inv_value,0,"","").''.number_format($_ord,0,"","").''.$vc->timeDate($deliverydate).''.number_format(($inv_qty+$_ord),0,"","").''.number_format(($gs['qty1']),0,"","").''.number_format(($gs['qty0']),0,"","").''.$stockm.''.implode(",",$dig).''.$b.'
'; print '
'; print '
'; ?>