<?php
/**
 * Exports Order / Shipping Information From Zen Cart in various chosen formats
 *
 * @package Export Shipping and Order Information
 * @copyright Copyright 2009, Eric Leuenberger http://www.zencartoptimization.com
 * @copyright Portions Copyright 2003-2006 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: shipping_export.php, v 1.3.2 08.05.2010 11:41 Eric Leuenberger econcepts@zencartoptimization.com$
 * Thanks to dhcernese and Scott Wilson (That Software Guy) for contributing various portions that contained several bug-fixes.
 */
 define('VERSION', '1.3.2');
 require_once('includes/application_top.php');
 //require_once(DIR_WS_CLASSES . 'currencies.php');
 //$currencies = new currencies();
 //require_once(DIR_WS_CLASSES . 'order.php');
//echo "HERE";
//exit;
$today = date('Y-m-d');
$today = $today." 00:00:00";
$sql = "SELECT * FROM zen_coupons WHERE 1 ";
$order_details = $db->Execute($sql);
if($order_details->RecordCount() > 0) { 
	while( !$order_details->EOF ) {
		//print"<pre>";
		//print_r($order_details);
		if(strtotime($order_details->fields['coupon_expire_date']) <= strtotime($today)){
			$cexparr = explode(" ",$order_details->fields['coupon_expire_date']);
			$dat = $cexparr[0];
			$dtarra = explode("-",$dat);
			$newexpdate = '2020-'.$dtarra[1]."-".$dtarra[2]." 00:00:00";
			
			$sql ="UPDATE zen_coupons SET coupon_expire_date = '".$newexpdate."' WHERE coupon_id = '".$order_details->fields['coupon_id']."'";
			//echo $sql."<br />";
			//exit;
			$db->execute($sql);
		}
		$order_details->MoveNext();				
	}
}
 
?>