query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'"); $result = $GLOBALS['db']->query("select * from ecmprices_customview where id='".$_GET['customview_id']."'"); $row=$GLOBALS['db']->fetchByAssoc($result); $c=explode("||",$row['columns']); $t=explode("||",$row['titles']); $o=explode("||",$row['orders']); if($_COOKIE['customview_id']!=$_GET['customview_id'] || $_SESSION['customview_id']=="" || !$_GET['order_by']) { $pbo=array(); for($i=0;$i<=8;$i++) { if($o[$i]) { $exp=explode(" ",$o[$i]); $adesc=$exp[1]; $ord=$exp[0]; if($ord=="list_price")$pbo[]="ecmprices_ecmproducts.price ".$adesc; else $pbo[]="ecmproducts.".$ord." ".$adesc; } } $_SESSION['pricebook_order']=implode(",",$pbo); } setcookie('customview_id',$_GET['customview_id'],time()+60*24*60*3600); $order=$_SESSION['pricebook_order']; $order=str_replace("ecmproducts.margin_rate","margin_rate",$order); if($_REQUEST['order_by']){ $order=str_replace($_REQUEST['order_by']." desc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order); $order=str_replace($_REQUEST['order_by']." asc",$_REQUEST['order_by']." ".$_REQUEST['sorder'],$order); } $_SESSION['pricebook_order']=$order; if($_REQUEST['order_by'] && $_REQUEST['sorder'])$_SESSION['pricebook_order']=$_REQUEST['order_by']." ".$_REQUEST['sorder']; //if($_REQUEST['order_by'])$_SESSION['pricebook_order_by']=$_SESSION['pricebook_order']=$_REQUEST['order_by']; //$_SESSION['pricebook_sorder']=$_REQUEST['sorder']; $_SESSION['pricebook_sorder']=$_REQUEST['sorder']; $_COOKIE['pricebook_id']=$_REQUEST['pricebook_id']; $r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id,ecmlanguage,currency_value from ecmprices where id='".$_COOKIE['pricebook_id']."'")); $name=$r['name']; $exchange_rate_id=$r['exchange_rate_id']; $lang=$r['ecmlanguage']; $er_value=$r['currency_value']; if(!$er_value){ require_once('modules/Currencies/Currency.php'); $currency = new Currency(); $currency->retrieve($exchange_rate_id); $er_value=$currency->conversion_rate; } $sorder=$_REQUEST['sorder']; $result = $GLOBALS['db']->query("select ecmprices_ecmproducts.price as price,ecmprices_ecmproducts.id as idp,ecmproducts.* from ecmprices_ecmproducts left join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ecmprices_ecmproducts.ecmprice_id='".$_COOKIE['pricebook_id']."' and ecmprices_ecmproducts.deleted='0'"); $checkc=''; $checkc.='if(document.getElementById(\'checkin\').checked==true) { mintajaxget(\'index.php?to_pdf=1&module=EcmPrices&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=true\',\'checkin\'); } else { mintajaxget(\'index.php?to_pdf=1&module=EcmPrices&action=checkAllProducts&pricebook_id='.$_REQUEST['pricebook_id'].'&value=false\',\'checkin\'); }'; while($ro=$GLOBALS['db']->fetchByAssoc($result)) { $checkc.='if(document.getElementById(\'checkin\').checked==true) { document.getElementById(\'checkc'.$ro['idp'].'\').checked=true; } else { document.getElementById(\'checkc'.$ro['idp'].'\').checked=false; } '; } print ''; $z="select ecmprices_ecmproducts.price as price, ecmprices_ecmproducts.popular as popular, ecmprices_ecmproducts.recipient_code as recipient_code, ecmprices_ecmproducts.id as idp, ecmprices_ecmproducts.margin_rate, ecmprices_ecmproducts.position as position, ecmprices_ecmproducts.remarks_pl as remarks_pl, ecmprices_ecmproducts.remarks_en as remarks_en, ecmprices_ecmproducts.remarks_de as remarks_de, ecmproducts.*, ecmproduct_language_pl_view.ean as ean_pl, ecmproduct_language_pl_view.short_description as short_description_pl, ecmproduct_language_pl_view.long_description as long_description_pl, ecmproduct_language_pl_view.remarks as default_remarks_pl, ecmproduct_language_en_view.ean as ean_en, ecmproduct_language_en_view.short_description as short_description_en, ecmproduct_language_en_view.long_description as long_description_en, ecmproduct_language_en_view.remarks as default_remarks_en, ecmproduct_language_de_view.ean as ean_de, ecmproduct_language_de_view.short_description as short_description_de, ecmproduct_language_de_view.long_description as long_description_de, ecmproduct_language_de_view.remarks as default_remarks_de from ecmprices_ecmproducts left join ecmproduct_language_pl_view on ecmproduct_language_pl_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id left join ecmproduct_language_en_view on ecmproduct_language_en_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id left join ecmproduct_language_de_view on ecmproduct_language_de_view.ecmproduct_id=ecmprices_ecmproducts.ecmproduct_id inner join ecmproducts on ecmproducts.id=ecmprices_ecmproducts.ecmproduct_id where ecmprices_ecmproducts.ecmprice_id='".$_REQUEST['pricebook_id']."' and ecmprices_ecmproducts.deleted='0'"; $tmp = substr(trim($_SESSION['pricebook_order']), -1); if ($tmp!='.') if($_SESSION['pricebook_order'])$z.=" order by ".$_SESSION['pricebook_order']; //$z.=" COLLATE utf8_polish_ci"; //print $z; if ($_REQUEST['customview_id']=='4cf54ba0-db9b-dc0d-e781-522f24a92e60') { $ttttt = '

Marża:   Rabat:   Cena z VAT:   Rodzaj przeliczania:

'; echo $ttttt; } $result = $GLOBALS['db']->query($z); include_once("modules/EcmProductReports/vtigerConnector.php"); $count = $result->num_rows; while($row=$GLOBALS['db']->fetchByAssoc($result)) { if ($licz%100==0 && $licz>0) { print ''; print ''; print ''; } if ($licz%100==0) { print '
'; print ''; print ''; print ''; //print mysql_error(); $t[1]='Nazwa'; $t[2]='Kategoria'; for($i=0;$i'.sortLink($corder_by,$sorder,$t[$i]).''; } $mm=$mod_strings; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } $stop[$row['code']]=false; $sale30=""; $qty30=""; $sale90=""; $qty90=""; $sale180=""; $qty180=""; if($_SESSION['EcmPrices_high'][$row['idp']])$color="#cccccc"; else $color=""; $licz++; print ''; print ''; print ''; //print ''; /*$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select purchase_price from ecmproducts where id='".$row['id']."'")); $purchase_price=$rr['purchase_price']; @$margin=100-(100*$purchase_price/$row['price']); $margin=number_format($margin,2,",",".");*/ for($i=0;$iquery("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='".$row['id']."' and ecminvoiceouts.type!='correct' and ecminvoiceouts.register_date>'".$ddate."'"); while($r=$GLOBALS['db']->fetchByAssoc($w)){ $sale+=$r['price']*$r['quantity']; $qty+=$r['quantity']; $aq[$r['no']]+=$r['quantity']; $date=date("Y-m"); $date1=date("Y-m",mktime()-1*24*3600*31); $date2=date("Y-m",mktime()-2*24*3600*31); $date3=date("Y-m",mktime()-3*24*3600*31); $date4=date("Y-m",mktime()-4*24*3600*31); $date5=date("Y-m",mktime()-5*24*3600*31); $date6=date("Y-m",mktime()-6*24*3600*31); $d=explode("-",$r['date']); $dd=$d[0]."-".$d[1]; if($dd==$date6){ //echo 3; $qty_6+=$r['quantity']; } if($dd==$date5){ //echo 3; $qty_5+=$r['quantity']; } if($dd==$date4){ //echo 3; $qty_4+=$r['quantity']; } if($dd==$date3){ //echo 3; $qty_3+=$r['quantity']; } if($dd==$date2){ //echo 2; $qty_2+=$r['quantity']; } if($dd==$date1){ //echo 1; $qty_1+=$r['quantity']; } if($dd==$date){ $sale0+=$r['price']*$r['quantity']; $qty0+=$r['quantity']; $aq0[$r['no']]+=$r['quantity']; } if($dd==$date1){ $sale30+=$r['price']*$r['quantity']; $qty30+=$r['quantity']; $aq30[$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 || $dd==$date4 || $dd==$date5 || $dd==$date6){ $sale180+=$r['price']*$r['quantity']; $qty180+=$r['quantity']; $aq180[$r['no']]+=$r['quantity']; } } @$trend_6_5=$qty_5/$qty_6; @$trend_5_4=$qty_4/$qty_5; @$trend_4_3=$qty_3/$qty_4; @$trend_3_2=$qty_2/$qty_3; @$trend_2_1=$qty_1/$qty_2; $trend=($qty_1+$qty_2+$qty_3)/3; $qty__1=$trend; $qty__2=$trend; $qty__3=$trend; if($qty__1<0)$qty__1=0; if($qty__2<0)$qty__2=0; if($qty__3<0)$qty__3=0; $stop[$row['code']]=true; } print ''; } } if($row['popular']==1)$po_checked="checked"; else $po_checked=""; print ''; print ''; print ''; if ($licz==$count) { print '
'.sortLink("ecmprices_ecmproducts.position",$sorder,"Pos.").'Popularność'.$mm['LBL_UNIT_PRICE'].''.$mm['LBL_MARGIN'].''.$mm['LBL_LIST_PRICE_PRICEBOOK'].'Cena brutto'.$mm['LBL_RECIPIENT_CODE'].''.$mm['LBL_REMARKS_PL'].''.$mm['LBL_REMARKS_EN'].''.$mm['LBL_REMARKS_DE'].'   
'.($row['position']).''.$row['name'].''; if($c[$i]=="ordered")print number_format($row['ordered'],0,"",""); elseif($c[$i]=="sale_qty30")print number_format($qty30,0,"",""); elseif($c[$i]=="sale_qty90")print number_format($qty90/3,0,"",""); elseif($c[$i]=="sale_qty180")print number_format($qty180/6,0,"",""); elseif($c[$i]=="sale_avg_price30")print number_format($sale30,2,",","."); elseif($c[$i]=="sale_avg_price90")print number_format($sale90,2,",","."); elseif($c[$i]=="sale_avg_price180")print number_format($sale180,2,",","."); elseif($c[$i]=="ems_qty_in_stock")print number_format($row['ems_qty_in_stock'],0,"",""); elseif($c[$i]=="list_price")print addExchangeRateValue($row['price'],$c[$i],$er_value); elseif($c[$i]=="margin_rate")print number_format($row['margin_rate'],2,",","."); elseif($c[$i]=="name"){ if($lang=="en_us"){ if($row['short_description_en'])print ''.$row['short_description_en'].''; else print 'none'; } elseif($lang=="ge_ge"){ if($row['short_description_de'])print ''.$row['short_description_de'].''; else print 'none'; } else print ''.$row['name'].''; } elseif($c[$i]=="product_category_name"){ if($lang=="en_us"){ $rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_en from ecmproductcategories where id='".$row['product_category_id']."'")); if($rrp['name_en'])print $rrp['name_en']; } elseif($lang=="ge_ge"){ $rrp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name_de from ecmproductcategories where id='".$row['product_category_id']."'")); if($rrp['name_de'])print $rrp['name_de']; } else print $row['product_category_name']; print ' '; } else print addExchangeRateValue($row[$c[$i]],$c[$i],$er_value); print ' '; print '
'; print ''; print '
'; } } //print ''; print '

'; ?>