Edit file File name : export-subscription-orders.php Content :<?php include("../include/config.php"); include("../include/functions.php"); if($_REQUEST['exportExcel']=='yes'){ $where=''; if($_REQUEST['search_order_id']!=''){ $name=$_REQUEST['search_order_id']; $where.=" and a.order_id='".$name."'"; } if($_REQUEST['search_user_id']!=''){ $name=$_REQUEST['search_user_id']; $where.=" and a.userid='".$name."'"; } if($_REQUEST['storename']!=''){ $name=$_REQUEST['storename']; $where.=" and b.store_id='".$name."'"; } if($_REQUEST['search_email']!=''){ $name=$_REQUEST['search_email'] ; $where.=" and c.ship_email like '%$name%' "; } if($_REQUEST['search_from_date']!='' && $_REQUEST['search_to_date']!=''){ $where.=" and a.subscription_date>='".$_REQUEST['search_from_date']."' and a.subscription_date<='".$_REQUEST['search_to_date']."' "; } if($_REQUEST['subscription_status'] || $_REQUEST['subscription_status']=='0'){ $name=$_REQUEST['subscription_status']; $where.=" and a.subscription_status='".$name."'"; } $order_by='a.sub_id'; $order_by2=' desc '; $sql=$obj->Query("SELECT a.sub_id,a.order_id,a.userid,a.subscription_date,a.subscription_status,a.subscription_cancel_date,a.reason_for_cancel,b.store_id,b.subscription_type,b.product_name,b.section,c.ship_fname,c.ship_lname,c.ship_email,c.ship_mobile FROM `user_subscription` as a left join user_subscription_order_details as b on b.subs_id=a.sub_id left join tbl_order as c on a.order_id=c.id where 1=1 $where order by $order_by $order_by2",$debug=-1); $csvData=''; $csvData.="Order Date,Order ID, Subscription Type, User ID ,Email, Store Name, Subscription Status, Reson for Cancel"; $csvData.="\n\r"; $reccnt=$obj->numRows($sql); if($reccnt>0){ $count=1; while($data=$obj->fetchNextObject($sql)) { $rstorename=getFieldWhere('storename', 'stores', 'storeid', $line->store_id); if($data->subscription_status==1){ $subscription_status="Active"; } else { $subscription_status="Cancel"; } $csvData.=date('d/m/Y',strtotime($data->subscription_date)).","; $csvData.=$data->order_id.","; $csvData.=stripslashes($data->subscription_type).","; $csvData.=stripslashes($data->userid).","; $csvData.=stripslashes($data->ship_email).","; $csvData.=stripslashes($rstorename).","; $csvData.=stripslashes($subscription_status).","; $csvData.=stripslashes($data->reason_for_cancel).","; $csvData.="\n\r"; $count++; } } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/csv"); header("Content-Disposition: attachment; filename=Order-Raing-Report-".date("dMY_H:i").".csv"); echo $csvData; exit; header("location:".$_SERVER['HTTP_REFERER']); exit(); } ?> Save