ok
Direktori : /proc/thread-self/root/home2/selectio/www/lilyexpresslive/software/admin/excel/ |
Current File : //proc/thread-self/root/home2/selectio/www/lilyexpresslive/software/admin/excel/excel-customer.php |
<?php session_start(); include("../inc/config.php"); $condition=''; $branch_id=$_POST['branch_id']; if($branch_id==0){ $condition="";}else{$condition.=" and tb.id=".$branch_id;} $tbl_branch=""; if($_SESSION['lily_express_software_live']['id']!=1 && $_SESSION['lily_express_software_live']['role_branches']!='0'){ $condition.=" and tb.id in (".$_SESSION['lily_express_software_live']['role_branches'].")"; } $client_id=$_POST['excel_client_id']; if($client_id==0){ $condition.="";}else{$condition.=" and tc.client_id=".$client_id;} $customer_type=$_POST['customer_type']; if($customer_type!='all'){$condition.=" and tc.cust_type='".$customer_type."'";} $statement = $pdo->prepare("SELECT tc.* FROM `tbl_customer` tc INNER JOIN tbl_user tu on tc.client_id=tu.id INNER JOIN tbl_branch tb on tu.branch_id=tb.id where 1=1 $condition "); //$statement = $pdo->prepare("SELECT * FROM `tbl_customer` $condition"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $now = gmdate("d-m-Y"); header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=Customer-list-'.$now.'.csv'); $output = fopen("php://output", "w"); fputcsv($output, array('SL', 'DP Code', 'Customer Name', 'Mobile', 'Address', 'City', 'State', 'Pincode', 'Destination')); $i=1; foreach ($result as $row) { fputcsv($output, array($i,$row['cust_code'],$row['cust_name'],$row['cust_phone'],$row['cust_address'],$row['cust_city'],$row['cust_state'],$row['cust_zip'],$row['destination_city'])); $i++; } fclose($output); ?>