<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php
// Send Header
    $xls->setHeader('Promocode_'.date('Y_m_d').'.xls');

    // XLS Data Cell
    $xls->BOF();
	$xls->writeLabel(0,0,'Promo Code');
	$xls->writeLabel(0,1,'Type');
	$xls->writeLabel(0,2,'Gift Value');
	$xls->writeLabel(0,3,'From Date');
	$xls->writeLabel(0,4,'To Date');
	$xls->writeLabel(0,5,'Status');
	$xls->writeLabel(0,6,'Description');
	$xls->writeLabel(0,7,'Minimum Amount');
	$i=1;
	foreach($data as $udt){
	
	    $from_dt = strtotime($udt[$cpntbl]["from_date"]);	
		$from_date=date("m-d-Y",$from_dt);
		$to_dt	 = strtotime($udt[$cpntbl]["to_date"]);											
        $to_date=date("m-d-Y",$to_dt);
		$xls->writeLabel($i,0,$udt[$cpntbl]["code"]);
		$xls->writeLabel($i,1,$udt[$cpntbl]["type"]);
		$xls->writeLabel($i,2,$udt[$cpntbl]["giftvalue"]);
		$xls->writeLabel($i,3,$from_date);
		$xls->writeLabel($i,4,$to_date);
		
		$today=date('Y-m-d');	
		$status='';
		if(strtotime($udt[$cpntbl]["to_date"]) < strtotime($today))												
		$status='Expired';
		else
		$status='Active';
		
		$xls->writeLabel($i,5,$status);
		$xls->writeLabel($i,6,$udt[$cpntbl]["descr"]);
		$xls->writeNumber($i,7,$udt[$cpntbl]["minamt"]);
		$i++;
	}
 	$xls->EOF();
    exit();
	//rows for data
?>