File "orderList.php"

Full Path: /home/krishnamexports/public_html/panel/common/orderList.php
File size: 4.94 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8

<?php

session_start();

require_once '../../config/database.php';

ini_set('memory_limit', '-1');

ini_set('max_execution_time', 90000); //300 seconds = 5 minutes



$setExcelName	   = "Order-list-".$_SESSION['from_date']."-to-".$_SESSION['to_date'];

error_reporting(E_ALL);

ini_set('display_errors', TRUE);

ini_set('display_startup_errors', TRUE);

date_default_timezone_set('Europe/London');

$currencyFormat = html_entity_decode("0.00",ENT_QUOTES,'UTF-8');	

if (PHP_SAPI == 'cli')

	die('This example should only be run from a Web Browser');

require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';

// Create new PHPExcel object

$objPHPExcel = new PHPExcel();

$currencyFormat = html_entity_decode("0.00",ENT_QUOTES,'UTF-8');			

// Set document properties

$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")

							 ->setLastModifiedBy("Maarten Balliauw")

							 ->setTitle("Office 2007 XLSX Test Document")

							 ->setSubject("Office 2007 XLSX Test Document")

							 ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")

							 ->setKeywords("office 2007 openxml php")

							 ->setCategory("Test result file");





// Add some data

$objPHPExcel->setActiveSheetIndex(0)

            ->setCellValue('A1', 's.no.')

            ->setCellValue('B1', 'Date')

            ->setCellValue('C1', 'Invoce No.')

            ->setCellValue('D1', 'Customer Name')

			->setCellValue('E1', 'Cust. GST')

            ->setCellValue('F1', 'Cust. Address')

            ->setCellValue('G1', 'State')

			->setCellValue('H1', 'Mobile')

			->setCellValue('I1', 'Total Qty')

			->setCellValue('J1', 'Total Taxble Value')

			->setCellValue('K1', 'SGST%')

			->setCellValue('L1', 'SGST')

			->setCellValue('M1', 'CGST%')

			->setCellValue('N1', 'CGST')

			->setCellValue('O1', 'IGST%')

			->setCellValue('P1', 'IGST')

			->setCellValue('Q1', 'Total');



			// Miscellaneous glyphs, UTF-8

			$i    = 2;

			$j    = 1;

			$sgst = "";

			$cgst = "";

			$igst = "";

			$sql = mysqli_query($cn,$_SESSION['orderQuery']);

			while($rows  = mysqli_fetch_array($sql))

			{								  

					$sqlEmployee     = mysqli_query($cn,"select * from `tbl_employee` where `id`='".$rows['distributor_id']."'");                                                       							

                    $sqlEmployeeData = mysqli_fetch_array($sqlEmployee);

					

					$sqlOrder     = mysqli_query($cn,"select * from `tbl_order` where `order_id`='".$rows['order_id']."'");                                                       							

                    $productCount = mysqli_num_rows($sqlOrder);

					$sqlOrderData = mysqli_fetch_array($sqlOrder);

					

					if($sqlEmployeeData['state_id']==22)

					{

						$sgst = orderIgstTotal($rows['order_id'])/2;

						$cgst = orderIgstTotal($rows['order_id'])/2;

						$igst = "";

					}

					else

					{

						$sgst = "";

						$cgst = "";

						$igst = orderIgstTotal($rows['order_id']);	

					}

					$objPHPExcel->setActiveSheetIndex(0)

						->setCellValue('A'.$i, $j)

						->setCellValue('B'.$i, date('d-m-Y',strtotime($rows['order_date'])))

						->setCellValue('C'.$i, str_pad($rows['order_id'], 4, "0", STR_PAD_LEFT))

						->setCellValue('D'.$i, $sqlEmployeeData['company_name'])

						->setCellValue('E'.$i, $sqlEmployeeData['gst'])

						->setCellValue('F'.$i, $sqlEmployeeData['address'])

						->setCellValue('G'.$i, state($sqlEmployeeData['state_id']))

						->setCellValue('H'.$i, $sqlEmployeeData['mobile'])

						->setCellValue('I'.$i, $productCount)

						->setCellValue('J'.$i, orderBeforeGstTotal($rows['order_id']))

						->setCellValue('K'.$i, "9%")

						->setCellValue('L'.$i, $sgst)

						->setCellValue('M'.$i, "9%")

						->setCellValue('N'.$i, $cgst)

						->setCellValue('O'.$i, "18%")

						->setCellValue('P'.$i, $igst)

						->setCellValue('Q'.$i, orderTotal($rows['order_id']));

						$i++;

						$j++;

			}	

	



// Rename worksheet

$objPHPExcel->getActiveSheet()->setTitle('Simple');





// Set active sheet index to the first sheet, so Excel opens this as the first sheet

$objPHPExcel->setActiveSheetIndex(0);





// Redirect output to a client's web browser (Excel5)

header('Content-Type: application/vnd.ms-excel');

header('Content-Disposition: attachment;filename='.$setExcelName.".xls");

header('Cache-Control: max-age=0');

// If you're serving to IE 9, then the following may be needed

header('Cache-Control: max-age=1');



// If you're serving to IE over SSL, then the following may be needed

header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past

header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified

header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1

header ('Pragma: public'); // HTTP/1.0



$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

$objWriter->save('php://output');

exit;