<?php
ob_start();
require_once './configs/webconfig.php';
require_once './utility/common_model.php';

require_once './controller/admin_controller.php';

$MyPdodb = new MyPDO();	

		$MyPdodb->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('MyPDOStatement'));		
		
		
		$sql = "SELECT *from hi_members order by id asc"; 
		
				$stm  = $MyPdodb->prepare($sql);      		
				$stm->execute(array($start,$limit));
				$results = $stm->fetchAll(PDO::FETCH_CLASS);
				
				
				
				$exportData = $results;
if(count($exportData)> 0) {?>Family No.,Name,Gender,Blood Group,Birth Date,Native Place,Marital Status,Address1,Address2,City,State,Country,Zip,Phone,Mobile,Email,Photo File Name,Education,Occupation,Name of Company,Designation,Business Address1,Business Address2,Business City,Business State,Business Country,Business Zip,Business Phone,Business Website,Business Email,Business Nature,No. of Family Members,Anniversary Date, Renewal Date, Status<?php				  
                           $i=$start;						   
							  foreach ($exportData as $project) { 							  
								$i++;	
								if($project->dob!="" and $project->dob!="0000-00-00"){
									$dob = date("d-m-Y",strtotime($project->dob));
								 }	else{
									$dob = "";
								 }
								 if($project->expirydate!="" and $project->expirydate!="0000-00-00"){
									$expdate = date("d-m-Y",strtotime($project->expirydate));
								 }	else{
									$expdate = "";
								 }					              
							echo "\n".$project->familyno.",".str_replace(",","",$project->fullname).",".str_replace(",","",$project->gender).",".str_replace(",","",$project->bloodgroup).",".$dob.",".str_replace(",","",$project->nativeplace).",".str_replace(",","",$project->maritalstatus).",".str_replace(",","",$project->address1).",".str_replace(",","",$project->address2).",".str_replace(",","",$project->city).",".str_replace(",","",$project->state).",".str_replace(",","",$project->country).",".str_replace(",","",$project->zip).",".str_replace(",","",$project->phone).",".str_replace(",","",$project->mobile).",".str_replace(",","",$project->email).",".str_replace(",","",$project->simage).",".str_replace(",","",$project->education).",".str_replace(",","",$project->occupation).",".str_replace(",","",$project->bus_nameofcompany).",".str_replace(",","",$project->bus_designation).",".str_replace(",","",$project->bus_address1).",".str_replace(",","",$project->bus_address2).",".str_replace(",","",$project->bus_city).",".str_replace(",","",$project->bus_state).",".str_replace(",","",$project->bus_country).",".str_replace(",","",$project->bus_zip).",".str_replace(",","",$project->bus_phone).",".str_replace(",","",$project->bus_website).",".str_replace(",","",$project->bus_email).",".str_replace(",","",$project->bus_nature).",".str_replace(",","",$project->nooffamilymembers).",".str_replace(",","",$project->expirydate).",".str_replace(",","",$project->renew_date).",".$expdate.",".str_replace(",","",$project->status);
							   }
                           }else{ ?>No records found.<?php } ?>                  
<?php
$filename = "JPCMemberList-".date("dmY").".csv";
header( "Content-Type: application/vnd.ms-excel" );
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
ob_flush();
?>