init
This commit is contained in:
73
modules/EcmPriceKopias/CreateXLS2.php
Normal file
73
modules/EcmPriceKopias/CreateXLS2.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
require_once("modules/EcmPriceKopias/ListHelper.php");
|
||||
require ("modules/EcmPriceKopias/excel.php");
|
||||
$workbook = "test.xls";
|
||||
$pathin = "/var/www/html/e5crm/vserver/e5crm.more7.com/www/e5test/modules/EcmPriceKopias/";
|
||||
$sheet = "test";
|
||||
$pathout = "/";
|
||||
|
||||
$E = new Excel;
|
||||
$E->XL($workbook,$pathin,$sheet);
|
||||
|
||||
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name,exchange_rate_id from ecmpricekopias where id='".$_COOKIE['pricebook_id']."'"));
|
||||
$name=$r['name'];
|
||||
$exchange_rate_id=$r['exchange_rate_id'];
|
||||
|
||||
$alf="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
require_once('modules/Currencies/Currency.php');
|
||||
$currency = new Currency();
|
||||
$currency->retrieve($exchange_rate_id);
|
||||
$er_value=$currency->conversion_rate;
|
||||
|
||||
$result = $GLOBALS['db']->query("select * from ecmpricekopias_customview where id='".$_COOKIE['customview_id']."'");
|
||||
$row=$GLOBALS['db']->fetchByAssoc($result);
|
||||
$c=explode("||",$row['columns']);
|
||||
$t=explode("||",$row['titles']);
|
||||
|
||||
$where="";
|
||||
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
|
||||
{
|
||||
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
|
||||
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
|
||||
$where_clauses[]="ecmpricekopias_ecmproducts.id!='".$key."'";
|
||||
$orand=' and ';
|
||||
}
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
|
||||
$where_clauses[]="ecmpricekopias_ecmproducts.id='".$key."'";
|
||||
$orand=' or ';
|
||||
}
|
||||
}
|
||||
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
|
||||
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmpricekopias_ecmproducts.id='9999999999999999' and ";
|
||||
}
|
||||
else $where="ecmpricekopias_ecmproducts.id='9999999999999999' and ";
|
||||
$result = $GLOBALS['db']->query("select ecmpricekopias_ecmproducts.price as price,ecmpricekopias_ecmproducts.id as idp,ecmproducts.* from ecmpricekopias_ecmproducts left join ecmproducts on ecmproducts.id=ecmpricekopias_ecmproducts.ecmproduct_id where ".$where."ecmpricekopias_ecmproducts.ecmpricekopia_id='".$_COOKIE['pricebook_id']."' and ecmpricekopias_ecmproducts.deleted='0' order by ".$_SESSION['pricebook_order_by']." ".$_SESSION['pricebook_sorder']);
|
||||
|
||||
$header =& $workbook->addformat();
|
||||
$header->set_bold();
|
||||
$header->set_size(12);
|
||||
$header->set_color('blue');
|
||||
|
||||
$worksheet->write_string(0,0,"Product name",$header);
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
//$worksheet->write_string(0,$i+1,dy($t[$i]),$header);
|
||||
$E->writerange("sheet1","A".$i+1,$t[$i]);
|
||||
}
|
||||
}
|
||||
$j=1;
|
||||
while($row=$GLOBALS['db']->fetchByAssoc($result)){
|
||||
$worksheet->write($j,0,dy($row['name']));
|
||||
for($i=0;$i<count($t);$i++){
|
||||
if($t[$i]){
|
||||
if($c[$i]=="list_price")$E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($row['price'],$c[$i],$er_value));
|
||||
else $E->writerange("sheet1",$alf[$j].$i+1,addExchangeRateValue($c[$i],$c[$i],$er_value));
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
$E->saveas("newwkb",$pathout,"xls");
|
||||
$E->closexl();
|
||||
unset($E);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user