View file File name : export-orders-rating.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 c.id='".$name."'"; } if($_REQUEST['search_user_id']!=''){ $name=$_REQUEST['search_user_id']; $where.=" and c.user_id='".$name."'"; } if($_REQUEST['storename']!=''){ $name=$_REQUEST['storename']; $where.=" and a.store_id='".$name."'"; } if($_REQUEST['search_email']!=''){ $name=$_REQUEST['search_email'] ; $where.=" and ship_email like '%$name%' "; } if($_REQUEST['store_rating'] || $_REQUEST['store_rating']=='0'){ $name=$_REQUEST['store_rating']; $name2=$_REQUEST['store_rating']+1; $where.=" and a.rating>='".$name."' and a.rating<'".$name2."'"; } if($_REQUEST['store_state']!=''){ $name=$_REQUEST['store_state'] ; $where.=" and d.stateCode like '%$name%' "; } if($_REQUEST['search_from_date']!='' && $_REQUEST['search_to_date']!=''){ $where.=" and c.order_date>='".$_REQUEST['search_from_date']."' and c.order_date<='".$_REQUEST['search_to_date']."' "; } $order_by='a.id'; $order_by2=' desc '; $sql=$obj->Query("SELECT a.order_id,b.storename,c.order_date,c.ship_fname,c.ship_email,c.user_id, a.order_id, a.rating,a.review,d.stateCode,d.state FROM `tbl_rating` a left join stores b on a.store_id=b.storeid left join tbl_order as c on a.order_id=c.id left join tbl_us_zipcodes as d on d.zipCode=c.ship_pincode where 1=1 $where order by $order_by $order_by2",$debug=-1); $csvData=''; $csvData.="Order Date,Order ID, User ID ,Email, Store Name, State, Rating, Comments "; $csvData.="\n\r"; $reccnt=$obj->numRows($sql); if($reccnt>0){ $count=1; while($data=$obj->fetchNextObject($sql)) { $csvData.=date('d/m/Y',strtotime($data->order_date)).","; $csvData.=$data->order_id.","; $csvData.=stripslashes($data->user_id).","; $csvData.=stripslashes($data->ship_email).","; $csvData.=stripslashes($data->storename).","; $csvData.=stripslashes($data->stateCode).","; $csvData.=stripslashes($data->rating).","; $csvData.=stripslashes($data->review).","; $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(); } ?>