示例#1
0
 /**
  * Function generates a excel product report for google base
  * 
  * 
  * @return file
  */
 function googleProduct()
 {
     include "classes/Lib/excelwriter.inc.php";
     $excel = new ExcelWriter("GoogleBase_Product_Feed.xls");
     if ($excel == false) {
         echo $excel->error;
     }
     $myArr = array("Product Id", "Product Title", "Description", "Product Price", "Link", "Brand", "Image Link", "Weight");
     $excel->writeLine($myArr);
     $sql = 'select product_id,title,description,price,brand,thumb_image,weight from products_table';
     $obj = new Bin_Query();
     if ($obj->executeQuery($sql)) {
         $cnt = count($obj->records);
         for ($i = 0; $i < $cnt; $i++) {
             $product_id = $obj->records[$i]['product_id'];
             $title = $obj->records[$i]['title'];
             $description = strip_tags($obj->records[$i]['description']);
             $price = $obj->records[$i]['price'];
             $brand = $obj->records[$i]['brand'];
             $thumb_image = $obj->records[$i]['thumb_image'];
             $image_link = $_SERVER['SERVER_NAME'] . '/' . $thumb_image;
             $weight = $obj->records[$i]['weight'];
             $link = $_SERVER['SERVER_NAME'] . '/?do=prodetail&action=showprod&id=' . $product_id;
             $excel->writeRow();
             $excel->writeCol($product_id);
             $excel->writeCol($title);
             $excel->writeCol($description);
             $excel->writeCol($price);
             $excel->writeCol($link);
             $excel->writeCol($brand);
             $excel->writeCol($image_link);
             $excel->writeCol($weight);
         }
         $excel->close();
     }
     if (strpos($_SERVER['USER'], 'MSIE')) {
         // IE cannot download from sessions without a cache
         header('Cache-Control: public');
     } else {
         //header("Cache-Control: no-cache, must-revalidate");
         header("Cache-Control: no-cache");
     }
     $file = "GoogleBase_Product_Feed.xls";
     //chmod ($file, 0755);
     header("Pragma: no-cache");
     header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
     header("Connection: close");
     header("Content-Disposition: attachment; filename=" . $file . "\n");
     header("Content-Transfer-Encoding: binary\n");
     header("Content-length: " . (string) filesize("{$file}"));
     $fd = fopen($file, "rb");
     fpassthru($fd);
 }
示例#2
0
$excel->writeLine($main_array);
// $column++;
//print_r($arrEventInfo);exit;
//Write each datapoint to the sheet starting one row beneath
//Loop through each row
$row++;
if ($arrUsersList) {
    //$column = 0;
    foreach ($arrUsersList as $subArrayKey => $subArray) {
        if ($subArray['pkClientID'] != '') {
            /*$columnWidth = 20;
            		$worksheet->setColumn (0, $numColumns, $columnWidth);
            		$worksheet->write($row, $column, $subArray, $regularFormat);
            		$column++;*/
            $column = 0;
            $excel->writeRow();
            foreach ($subArray as $varKey => $value) {
                $excel->writeCol($value);
            }
            $row++;
        }
    }
}
$fdl = @fopen('client_list.xls', 'r');
header("Cache-Control: ");
# leave blank to avoid IE errors
header("Pragma: ");
# leave blank to avoid IE errors
header("Content-type: application/xls");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"client_list.xls\"");
 /**
  * Function exports the admin activity report from the database into various file format
  * Excel/CSV/TSV/XML Formats
  * 
  * @return file
  */
 function adminActivityDataExport()
 {
     if ($_POST['export'] == 'excel') {
         include "classes/Lib/excelwriter.inc.php";
         $excel = new ExcelWriter("adminactivity_Detail.xls");
         if ($excel == false) {
             echo $excel->error;
         }
         $myArr = array("SlNo", "UserId", "Url", "VisitedOn");
         $excel->writeLine($myArr);
         $j = 1;
         $sql = 'select user_id,url,visited_on from admin_activity_table';
         $obj = new Bin_Query();
         $obj->executeQuery($sql);
         if ($obj->executeQuery($sql)) {
             $cnt = count($obj->records);
             for ($i = 0; $i < $cnt; $i++) {
                 $user_id = $obj->records[$i]['user_id'];
                 $url = $obj->records[$i]['url'];
                 $visited_on = $obj->records[$i]['visited_on'];
                 $excel->writeRow();
                 $excel->writeCol($j);
                 $excel->writeCol($user_id);
                 $excel->writeCol($url);
                 $excel->writeCol($visited_on);
                 $j++;
             }
             $excel->close();
         }
         if (strpos($_SERVER['USER'], 'MSIE')) {
             // IE cannot download from sessions without a cache
             header('Cache-Control: public');
         } else {
             //header("Cache-Control: no-cache, must-revalidate");
             header("Cache-Control: no-cache");
         }
         $file = "adminactivity_Detail.xls";
         //chmod ($file, 0755);
         header("Pragma: no-cache");
         header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
         header("Connection: close");
         header("Content-Disposition: attachment; filename=" . $file . "\n");
         header("Content-Transfer-Encoding: binary\n");
         header("Content-length: " . (string) filesize("{$file}"));
         $fd = fopen($file, "rb");
         fpassthru($fd);
         /*function xlsBOF() 
         			{
         				echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
         				return;
         			}
         	
         			function xlsEOF() 
         			{
         				echo pack("ss", 0x0A, 0x00);
         				return;
         			}
         	
         			function xlsWriteNumber($Row, $Col, $Value) 
         			{
         				echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
         				echo pack("d", $Value);
         				return;
         			}
         	
         			function xlsWriteLabel($Row, $Col, $Value ) 
         			{
         				$L = strlen($Value);
         				echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
         				echo $Value;
         				return;
         			}
         			//Send header
         			header("Pragma: public");
         			header("Expires: 0");
         			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         			header("Content-Type: application/force-download");
         			header("Content-Type: application/octet-stream");
         			header("Content-Type: application/download");
         			header("Content-Disposition: attachment;filename=user_report.xls"); 
         			header("Content-Transfer-Encoding: binary ");
         			xlsBOF();
         					xlsWriteLabel(1,0,"No");
         					xlsWriteLabel(1,1,"First Name");
         					xlsWriteLabel(1,2,"Last Name");
         					xlsWriteLabel(1,3,"Display Name");
         					xlsWriteLabel(1,4,"Email");
         					xlsWriteLabel(1,5,"Date of Joining");
         								
         				   $xlsRow = 2;
         				   $j=1;
         					
         					//Query
         					
         					$sqlselect = "select user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
         					
         					$obj = new Bin_Query();
         					if($obj->executeQuery($sqlselect))
         					{
         						$count=count($obj->records);
         						for($i=0;$i<$count;$i++)
         						{
         							$url = $obj->records[$i]['user_fname'];
         							$last_name = $obj->records[$i]['user_lname'];
         							$display_name = $obj->records[$i]['user_display_name'];
         							$email = $obj->records[$i]['user_email'];
         							$doj =  $obj->records[$i]['user_doj'];
         							
         							xlsWriteLabel($xlsRow,0,"$j");
         							xlsWriteLabel($xlsRow,1,$url);
         							xlsWriteLabel($xlsRow,2,$last_name);
         							xlsWriteLabel($xlsRow,3,$display_name);
         							xlsWriteLabel($xlsRow,4,$email);
         							xlsWriteLabel($xlsRow,5,$doj);
         							$xlsRow++;
         							$j++;
         						}
         					}
         					xlsEOF();
         					exit();	*/
     } else {
         if ($_POST['export'] == 'xml') {
             $sqlselect = "select user_id,url,visited_on from admin_activity_table";
             $obj = new Bin_Query();
             if ($obj->executeQuery($sqlselect)) {
                 header("Content-Type: text/xml");
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: xml/force-download");
                 header("Content-Type: xml/octet-stream");
                 header("Content-Type: xml/download");
                 header("Content-Disposition: attachment;filename=adminactivity_report.xml");
                 header("Content-Transfer-Encoding: binary ");
                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
                 echo "<activitydetails>\n";
                 $count = count($obj->records);
                 for ($i = 0; $i < $count; $i++) {
                     echo "<user_id>" . $obj->records[$i]['user_id'] . "</user_id>\n";
                     $url = str_replace("&", "&amp;", $obj->records[$i]['url']);
                     echo "<url>" . $url . "</url>\n";
                     echo "<visitedon>" . $obj->records[$i]['visited_on'] . "</visitedon>\n";
                 }
                 echo "</activitydetails>\n";
                 exit;
             }
         } else {
             if ($_POST['export'] == 'csv') {
                 $csv_terminated = "\n";
                 $csv_separator = ",";
                 $csv_enclosed = '"';
                 $csv_escaped = "\\";
                 $sqlselect = "select user_id,url,visited_on from admin_activity_table";
                 $obj = new Bin_Query();
                 if ($obj->executeQuery($sqlselect)) {
                     $schema_insert = '';
                     $schema_insert .= $csv_enclosed . user_id . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . url . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . VistedOn . $csv_enclosed;
                     $count = count($obj->records);
                     for ($i = 0; $i < $count; $i++) {
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_id'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['url'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['visited_on'] . $csv_enclosed;
                     }
                     $out .= $schema_insert;
                     $out .= $csv_terminated;
                 }
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Length: " . strlen($out));
                 // Output to browser with appropriate mime type, you choose ;)
                 header("Content-type: text/x-csv");
                 //header("Content-type: text/csv");
                 //header("Content-type: application/csv");
                 header("Content-Disposition: attachment; filename=adminactivity_report.csv");
                 echo $out;
                 exit;
             } else {
                 if ($_POST['export'] == 'tab') {
                     $tab_terminated = "\n";
                     $tab_separator = "->";
                     $tab_enclosed = '"';
                     $tab_escaped = "\\";
                     $sqlselect = "select user_id,url,visited_on from admin_activity_table";
                     $obj = new Bin_Query();
                     if ($obj->executeQuery($sqlselect)) {
                         $schema_insert = '';
                         $schema_insert .= $tab_enclosed . UserId . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Url . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . VisitedOn . $tab_enclosed;
                         $count = count($obj->records);
                         for ($i = 0; $i < $count; $i++) {
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_id'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['url'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['visited_on'] . $tab_enclosed;
                         }
                         $out .= $schema_insert;
                         $out .= $tab_terminated;
                     }
                     /*header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     		header("Content-Length: " . strlen($out));
                     		// Output to browser with appropriate mime type, you choose ;)
                     		header("Content-type: application/tab");
                     		//header("Content-type: text/csv");
                     		//header("Content-type: application/csv");
                     		header("Content-Disposition: attachment; filename=user_report.tab");*/
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Content-Length: " . strlen($out));
                     header("Content-Type: tab/force-download");
                     header("Content-Type: tab/octet-stream");
                     header("Content-Type: tab/download");
                     header("Content-Disposition: attachment;filename=adminactivity_report.tsv");
                     header("Content-Transfer-Encoding: binary ");
                     echo $out;
                     exit;
                 }
             }
         }
     }
 }
 /**
  * Retourne le tableau au format excel
  *
  */
 public function getExcel()
 {
     //Inclusion de la classe pour gnération des fichiers excel
     require_once COPIX_PATH . '../excelwriter/excelwriter.inc.php';
     $excel = new ExcelWriter("temp.xls", "", "");
     if ($excel == false) {
         throw new Exception($excel->error);
     }
     //Création de la ligne de titre
     if (count($this->_title) > 0) {
         $tabTitle = array();
         foreach ($this->_title as $key => $titre) {
             $tabTitle[utf8_decode($titre)] = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
         }
         $excel->writeLine($tabTitle, "gras");
     }
     //Création des lignes de données
     foreach ($this->_array as $line) {
         $excel->writeRow();
         if (count($this->_mapObject) > 0) {
             foreach ($this->_mapObject as $key => $map) {
                 $size = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
                 $excel->writeCol(utf8_decode($line->{$map}), $size);
             }
         } else {
             foreach ($line as $key => $cell) {
                 $size = isset($this->_size[$key]) ? $this->_size[$key] : $this->_defaultSize;
                 $excel->writeCol(utf8_decode($cell), $size);
             }
         }
     }
     //Fin du document
     $excel->close();
     return $excel->getData();
 }
 /**
  * Function generates a report in the file format. 
  * @param array  $sql
  * 
  * @return file
  */
 function createReport($sql)
 {
     if ($_POST['export'] == 'excel') {
         include "classes/Lib/excelwriter.inc.php";
         $excel = new ExcelWriter("User_Detail.xls");
         if ($excel == false) {
             $excel->error;
         }
         $myArr = array("No", "Display Name", "First Name", "Last Name", "Email", "Address", "City", "State", "Zip Code", "Country");
         $excel->writeLine($myArr);
         $j = 1;
         $sql = 'select * from users_table';
         $obj = new Bin_Query();
         if ($obj->executeQuery($sql)) {
             $cnt = count($obj->records);
             for ($i = 0; $i < $cnt; $i++) {
                 $sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country   WHERE a.user_id='" . $obj->records[$i]['user_id'] . "'";
                 $objAdd = new Bin_Query();
                 $objAdd->executeQuery($sqlAdd);
                 $display_name = $obj->records[$i]['user_display_name'];
                 $first_name = $obj->records[$i]['user_fname'];
                 $last_name = $obj->records[$i]['user_lname'];
                 $email = $obj->records[$i]['user_email'];
                 $address = $objAdd->records[0]['address'];
                 $city = $objAdd->records[0]['city'];
                 $state = $objAdd->records[0]['state'];
                 $zip = $objAdd->records[0]['zip'];
                 $country = $objAdd->records[0]['cou_name'];
                 $doj = $obj->records[$i]['user_doj'];
                 $excel->writeRow();
                 $excel->writeCol($j);
                 $excel->writeCol($display_name);
                 $excel->writeCol($first_name);
                 $excel->writeCol($last_name);
                 $excel->writeCol($email);
                 $excel->writeCol($address);
                 $excel->writeCol($city);
                 $excel->writeCol($state);
                 $excel->writeCol($zip);
                 $excel->writeCol($country);
                 $excel->writeCol($doj);
                 $j++;
             }
             $excel->close();
         }
         if (strpos($_SERVER['USER'], 'MSIE')) {
             // IE cannot download from sessions without a cache
             header('Cache-Control: public');
         } else {
             //header("Cache-Control: no-cache, must-revalidate");
             header("Cache-Control: no-cache");
         }
         $file = "User_Detail.xls";
         //chmod ($file, 0755);
         header("Pragma: no-cache");
         header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
         header("Connection: close");
         header("Content-Disposition: attachment; filename=" . $file . "\n");
         header("Content-Transfer-Encoding: binary\n");
         header("Content-length: " . (string) filesize("{$file}"));
         $fd = fopen($file, "rb");
         fpassthru($fd);
     } else {
         if ($_POST['export'] == 'xml') {
             $sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
             $obj = new Bin_Query();
             if ($obj->executeQuery($sqlselect)) {
                 header("Content-Type: text/xml");
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: xml/force-download");
                 header("Content-Type: xml/octet-stream");
                 header("Content-Type: xml/download");
                 header("Content-Disposition: attachment;filename=user_report.xml");
                 header("Content-Transfer-Encoding: binary ");
                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
                 echo "<userdetails>\n";
                 $count = count($obj->records);
                 for ($i = 0; $i < $count; $i++) {
                     $sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country   WHERE a.user_id='" . $obj->records[$i]['user_id'] . "'";
                     $objAdd = new Bin_Query();
                     $objAdd->executeQuery($sqlAdd);
                     echo "<userid>" . $obj->records[$i]['user_id'] . "</userid>\n";
                     echo "<displayname>" . $obj->records[$i]['user_display_name'] . "</displayname>\n";
                     echo "<firstname>" . $obj->records[$i]['user_fname'] . "</firstname>\n";
                     echo "<lastname>" . $obj->records[$i]['user_lname'] . "</lastname>\n";
                     echo "<email>" . $obj->records[$i]['user_email'] . "</email>\n";
                     echo "<address>" . $objAdd->records[0]['address'] . "</address>\n";
                     echo "<city>" . $objAdd->records[0]['city'] . "</city>\n";
                     echo "<state>" . $objAdd->records[0]['state'] . "</state>\n";
                     echo "<zipcode>" . $objAdd->records[0]['zip'] . "</zipcode>\n";
                     echo "<country>" . $objAdd->records[0]['cou_name'] . "</country>\n";
                     echo "<userdoj>" . $obj->records[$i]['user_doj'] . "</userdoj>\n";
                 }
                 echo "</userdetails>\n";
                 exit;
             }
         } else {
             if ($_POST['export'] == 'csv') {
                 $csv_terminated = "\n";
                 $csv_separator = ",";
                 $csv_enclosed = '"';
                 $csv_escaped = "\\";
                 $sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
                 $obj = new Bin_Query();
                 if ($obj->executeQuery($sqlselect)) {
                     $schema_insert = '';
                     $schema_insert .= $csv_enclosed . No . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . FirstName . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . LastName . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . DisplayName . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Email . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . DateofJoin . $csv_enclosed;
                     $count = count($obj->records);
                     for ($i = 0; $i < $count; $i++) {
                         $sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country   WHERE a.user_id='" . $obj->records[$i]['user_id'] . "'";
                         $objAdd = new Bin_Query();
                         $objAdd->executeQuery($sqlAdd);
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_id'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_display_name'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_fname'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_lname'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_email'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $objAdd->records[0]['address'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $objAdd->records[0]['city'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $objAdd->records[0]['state'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $objAdd->records[0]['zip'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $objAdd->records[0]['cou_name'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_doj'] . $csv_enclosed;
                     }
                     $out .= $schema_insert;
                     $out .= $csv_terminated;
                 }
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Length: " . strlen($out));
                 // Output to browser with appropriate mime type, you choose ;)
                 header("Content-type: text/x-csv");
                 //header("Content-type: text/csv");
                 //header("Content-type: application/csv");
                 header("Content-Disposition: attachment; filename=user_report.csv");
                 echo $out;
                 exit;
             } else {
                 if ($_POST['export'] == 'tab') {
                     $tab_terminated = "\n";
                     $tab_separator = "->";
                     $tab_enclosed = '"';
                     $tab_escaped = "\\";
                     $sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
                     $obj = new Bin_Query();
                     if ($obj->executeQuery($sqlselect)) {
                         $schema_insert = '';
                         $schema_insert .= $tab_enclosed . No . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . DisplayName . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . FirstName . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . LastName . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Email . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Address . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . City . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . State . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Zipcode . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Country . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . DateofJoin . $tab_enclosed;
                         $count = count($obj->records);
                         for ($i = 0; $i < $count; $i++) {
                             $sqlAdd = "SELECT a.*,b.cou_code,b.cou_name FROM addressbook_table AS a LEFT JOIN country_table AS b ON b.cou_code=a.country   WHERE \ta.user_id='" . $obj->records[$i]['user_id'] . "'";
                             $objAdd = new Bin_Query();
                             $objAdd->executeQuery($sqlAdd);
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_id'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_fname'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_lname'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_display_name'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_email'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $objAdd->records[0]['address'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $objAdd->records[0]['city'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $objAdd->records[0]['state'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $objAdd->records[0]['zip'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $objAdd->records[0]['cou_name'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_doj'] . $tab_enclosed;
                         }
                         $out .= $schema_insert;
                         $out .= $tab_terminated;
                     }
                     /*header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     		header("Content-Length: " . strlen($out));
                     		// Output to browser with appropriate mime type, you choose ;)
                     		header("Content-type: application/tab");
                     		//header("Content-type: text/csv");
                     		//header("Content-type: application/csv");
                     		header("Content-Disposition: attachment; filename=user_report.tab");*/
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Content-Length: " . strlen($out));
                     header("Content-Type: tab/force-download");
                     header("Content-Type: tab/octet-stream");
                     header("Content-Type: tab/download");
                     header("Content-Disposition: attachment;filename=user_report.tab");
                     header("Content-Transfer-Encoding: binary ");
                     echo $out;
                     exit;
                 }
             }
         }
     }
 }
示例#6
0
 /**
  * Function converts the order details from the database into an Excel/CSV/TSV/XML format.
  * 
  * 
  * @return file
  */
 function OrderDataExport()
 {
     if ($_POST['export'] == 'excel') {
         include "classes/Lib/excelwriter.inc.php";
         $excel = new ExcelWriter("order_Detail.xls");
         if ($excel == false) {
             echo $excel->error;
         }
         $myArr = array("SlNo", "Orders Id", "Shipping Name", "Street Address", "Suburb", "City", "State", "Billing Company");
         $excel->writeLine($myArr);
         $j = 1;
         $sql = 'select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table';
         $obj = new Bin_Query();
         if ($obj->executeQuery($sql)) {
             $cnt = count($obj->records);
             for ($i = 0; $i < $cnt; $i++) {
                 $orders_id = $obj->records[$i]['orders_id'];
                 $shipping_name = $obj->records[$i]['shipping_name'];
                 $shipping_street_address = $obj->records[$i]['shipping_street_address'];
                 $shipping_suburb = $obj->records[$i]['shipping_suburb'];
                 $shipping_city = $obj->records[$i]['shipping_city'];
                 $shipping_state = $obj->records[$i]['shipping_state'];
                 $billing_company = $obj->records[$i]['billing_company'];
                 //$doj =  $obj->records[$i]['user_doj'];
                 $excel->writeRow();
                 $excel->writeCol($j);
                 $excel->writeCol($orders_id);
                 $excel->writeCol($shipping_name);
                 $excel->writeCol($shipping_street_address);
                 $excel->writeCol($shipping_suburb);
                 $excel->writeCol($shipping_city);
                 $excel->writeCol($shipping_state);
                 $excel->writeCol($billing_company);
                 //$excel->writeCol($doj);
                 $j++;
             }
             $excel->close();
         }
         if (strpos($_SERVER['USER'], 'MSIE')) {
             // IE cannot download from sessions without a cache
             header('Cache-Control: public');
         } else {
             //header("Cache-Control: no-cache, must-revalidate");
             header("Cache-Control: no-cache");
         }
         $file = "order_Detail.xls";
         //chmod ($file, 0755);
         header("Pragma: no-cache");
         header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
         header("Connection: close");
         header("Content-Disposition: attachment; filename=" . $file . "\n");
         header("Content-Transfer-Encoding: binary\n");
         header("Content-length: " . (string) filesize("{$file}"));
         $fd = fopen($file, "rb");
         fpassthru($fd);
     } else {
         if ($_POST['export'] == 'xml') {
             $sqlselect = "select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table";
             $obj = new Bin_Query();
             if ($obj->executeQuery($sqlselect)) {
                 header("Content-Type: text/xml");
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: xml/force-download");
                 header("Content-Type: xml/octet-stream");
                 header("Content-Type: xml/download");
                 header("Content-Disposition: attachment;filename=order_details.xml");
                 header("Content-Transfer-Encoding: binary ");
                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                 echo "<orderdetails>\n";
                 $count = count($obj->records);
                 for ($i = 0; $i < $count; $i++) {
                     echo "<orderid>" . $obj->records[$i]['orders_id'] . "</orderid>\n";
                     echo "<shipping_name>" . $obj->records[$i]['shipping_name'] . "</shipping_name>\n";
                     echo "<shipping_street_address>" . $obj->records[$i]['shipping_street_address'] . "</shipping_street_address>\n";
                     echo "<shipping_suburb>" . $obj->records[$i]['shipping_suburb'] . "</shipping_suburb>\n";
                     echo "<shipping_city>" . $obj->records[$i]['shipping_city'] . "</shipping_city>\n";
                     echo "<shipping_state>" . $obj->records[$i]['shipping_state'] . "</shipping_state>\n";
                 }
                 echo "</orderdetails>\n";
                 exit;
             }
         } else {
             if ($_POST['export'] == 'csv') {
                 $csv_terminated = "\n";
                 $csv_separator = ",";
                 $csv_enclosed = '"';
                 $csv_escaped = "\\";
                 $sqlselect = "select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table";
                 $obj = new Bin_Query();
                 if ($obj->executeQuery($sqlselect)) {
                     $schema_insert = '';
                     $schema_insert .= $csv_enclosed . Orderid . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingName . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingStreetAddress . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingSuburb . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingCity . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingState . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . BillingCompany . $csv_enclosed;
                     $count = count($obj->records);
                     for ($i = 0; $i < $count; $i++) {
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['orders_id'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['shipping_name'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['shipping_street_address'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['shipping_suburb'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['shipping_city'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['shipping_state'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['billing_company'] . $csv_enclosed;
                     }
                     $out .= $schema_insert;
                     $out .= $csv_terminated;
                 }
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Length: " . strlen($out));
                 // Output to browser with appropriate mime type, you choose ;)
                 header("Content-type: text/x-csv");
                 //header("Content-type: text/csv");
                 //header("Content-type: application/csv");
                 header("Content-Disposition: attachment; filename=order_report.csv");
                 echo $out;
                 exit;
             } else {
                 if ($_POST['export'] == 'tab') {
                     $tab_terminated = "\n";
                     $tab_separator = "->";
                     $tab_enclosed = '"';
                     $tab_escaped = "\\";
                     $sqlselect = "select orders_id,shipping_name,shipping_street_address,shipping_suburb,shipping_city,shipping_state,billing_company from orders_table";
                     $obj = new Bin_Query();
                     if ($obj->executeQuery($sqlselect)) {
                         $schema_insert = '';
                         $schema_insert .= $tab_enclosed . Orderid . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingName . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingStreetAddress . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingSuburb . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingCity . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingState . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . BillingCompany . $tab_enclosed;
                         $count = count($obj->records);
                         for ($i = 0; $i < $count; $i++) {
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['orders_id'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_name'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_street_address'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_suburb'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_city'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_state'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['billing_company'] . $tab_enclosed;
                         }
                         $out .= $schema_insert;
                         $out .= $tab_terminated;
                     }
                     /*header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     		header("Content-Length: " . strlen($out));
                     		// Output to browser with appropriate mime type, you choose ;)
                     		header("Content-type: application/tab");
                     		//header("Content-type: text/csv");
                     		//header("Content-type: application/csv");
                     		header("Content-Disposition: attachment; filename=user_report.tab");*/
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Content-Length: " . strlen($out));
                     header("Content-Type: tab/force-download");
                     header("Content-Type: tab/octet-stream");
                     header("Content-Type: tab/download");
                     header("Content-Disposition: attachment;filename=order_report.tsv");
                     header("Content-Transfer-Encoding: binary ");
                     echo $out;
                     exit;
                 }
             }
         }
     }
 }
示例#7
0
 /**
  * Function generates a product review report in the file format. 
  * @param string $sql
  * 
  * @return file
  */
 function productReviewReport($sql)
 {
     if ($_POST['export'] == 'excel') {
         include "classes/Lib/excelwriter.inc.php";
         $excel = new ExcelWriter("Product_Review.xls");
         if ($excel == false) {
             echo $excel->error;
         }
         $myArr = array("Id", "User Name", "Title", "Review Summary", "Review", "Review Date");
         $excel->writeLine($myArr);
         $obj = new Bin_Query();
         if ($obj->executeQuery($sql)) {
             $cnt = count($obj->records);
             for ($i = 0; $i < $cnt; $i++) {
                 $product_id = $obj->records[$i]['product_id'];
                 $display_name = $obj->records[$i]['user_display_name'];
                 $title = $obj->records[$i]['title'];
                 $reviewsummary = $obj->records[$i]['review_txt'];
                 $review = $obj->records[$i]['review_caption'];
                 $reviewdate = $obj->records[$i]['review_date'];
                 $excel->writeRow();
                 $excel->writeCol($product_id);
                 $excel->writeCol($display_name);
                 $excel->writeCol($title);
                 $excel->writeCol($reviewsummary);
                 $excel->writeCol($review);
                 $excel->writeCol($reviewdate);
             }
             $excel->close();
         }
         if (strpos($_SERVER['USER'], 'MSIE')) {
             // IE cannot download from sessions without a cache
             header('Cache-Control: public');
         } else {
             //header("Cache-Control: no-cache, must-revalidate");
             header("Cache-Control: no-cache");
         }
         $file = "Product_Review.xls";
         //chmod ($file, 0755);
         header("Pragma: no-cache");
         header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
         header("Connection: close");
         header("Content-Disposition: attachment; filename=" . $file . "\n");
         header("Content-Transfer-Encoding: binary\n");
         header("Content-length: " . (string) filesize("{$file}"));
         $fd = fopen($file, "rb");
         fpassthru($fd);
     } else {
         if ($_POST['export'] == 'xml') {
             //$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
             $obj = new Bin_Query();
             if ($obj->executeQuery($sql)) {
                 header("Content-Type: text/xml");
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: xml/force-download");
                 header("Content-Type: xml/octet-stream");
                 header("Content-Type: xml/download");
                 header("Content-Disposition: attachment;filename=product_review_report.xml");
                 header("Content-Transfer-Encoding: binary ");
                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
                 echo "<productreviewdetails>\n";
                 $cnt = count($obj->records);
                 for ($i = 0; $i < $cnt; $i++) {
                     /*echo ("<user id=\"". $obj->records[$i]['user_id'] ."\">\n");
                     		echo ("<firstname=\"". $obj->records[$i]['user_fname'] ."\">\n");
                     		echo ("<lastname=\"". $obj->records[$i]['user_lname'] ."\">\n");
                     		echo ("<displayname=\"". $obj->records[$i]['user_display_name'] ."\">\n");
                     		echo ("<email=\"". $obj->records[$i]['user_email'] ."\">\n");
                     		echo ("<userdoj=\"". $obj->records[$i]['user_doj'] ."\">\n");*/
                     echo "<productid>" . $obj->records[$i]['product_id'] . "<\\productid>\n";
                     echo "<username>" . $obj->records[$i]['user_display_name'] . "<\\username>\n";
                     echo "<title>" . $obj->records[$i]['title'] . "<\title>\n";
                     echo "<reviewsummary>" . $obj->records[$i]['review_txt'] . "<\reviewsummary>\n";
                     echo "<review>" . $obj->records[$i]['review_caption'] . "<\review>\n";
                     echo "<reviewdate>" . $obj->records[$i]['review_date'] . "<\reviewdate>\n";
                 }
                 echo "</productreviewdetails>\n";
             }
         } else {
             if ($_POST['export'] == 'csv') {
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Length: " . strlen($out));
                 header("Content-type: text/x-csv");
                 header("Content-Disposition: attachment; filename=product_review_report.csv");
                 $csv_terminated = "\n";
                 $csv_separator = ",";
                 $csv_enclosed = '"';
                 $csv_escaped = "\\";
                 //$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
                 $obj = new Bin_Query();
                 if ($obj->executeQuery($sql)) {
                     $schema_insert = $csv_enclosed . Id . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . UserName . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Title . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ReviewSummary . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Review . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ReviewPostedDate . $csv_enclosed;
                     $cnt = count($obj->records);
                     for ($i = 0; $i < $cnt; $i++) {
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['product_id'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['user_display_name'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['title'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['review_txt'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['review_caption'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['review_date'] . $csv_enclosed;
                     }
                     $out .= $schema_insert;
                     $out .= $csv_terminated;
                 }
                 echo $out;
                 exit;
             } else {
                 if ($_POST['export'] == 'tab') {
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Content-Length: " . strlen($out));
                     header("Content-Type: tab/force-download");
                     header("Content-Type: tab/octet-stream");
                     header("Content-Type: tab/download");
                     header("Content-Disposition: attachment;filename=product_review_report.tab");
                     header("Content-Transfer-Encoding: binary ");
                     $tab_terminated = "\n";
                     $tab_separator = "->";
                     $tab_enclosed = '"';
                     $tab_escaped = "\\";
                     //$sqlselect = "select user_id,user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
                     $obj = new Bin_Query();
                     if ($obj->executeQuery($sql)) {
                         $schema_insert = $tab_enclosed . Id . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . UserName . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Title . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ReviewSummary . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Review . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ReviewPostedDate . $tab_enclosed;
                         $count = count($obj->records);
                         for ($i = 0; $i < $count; $i++) {
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['product_id'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['user_display_name'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['title'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['review_txt'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['review_caption'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['review_date'] . $tab_enclosed;
                         }
                         $out .= $schema_insert;
                         $out .= $tab_terminated;
                     }
                     echo $out;
                     exit;
                 }
             }
         }
     }
 }
示例#8
0
 /**
  * Function generates a product details in an excel/xml/csv/tsv format file
  * 
  * 
  * @return file
  */
 function productDataExport()
 {
     if ($_POST['export'] == 'excel') {
         include "classes/Lib/excelwriter.inc.php";
         $excel = new ExcelWriter("Product_Detail.xls");
         if ($excel == false) {
             echo $excel->error;
         }
         $myArr = array("SlNo", "Title", "Description", "Brand", "Model", "Msrp", "Price", "Shipping Cost", "Intro Date");
         $excel->writeLine($myArr);
         $j = 1;
         $sql = 'select sku,title,description,brand,model,msrp,price,shipping_cost,intro_date from products_table';
         $obj = new Bin_Query();
         if ($obj->executeQuery($sql)) {
             $cnt = count($obj->records);
             for ($i = 0; $i < $cnt; $i++) {
                 $title = $obj->records[$i]['title'];
                 $description = $obj->records[$i]['description'];
                 $brand = $obj->records[$i]['brand'];
                 $model = $obj->records[$i]['model'];
                 $msrp = $obj->records[$i]['msrp'];
                 $price = $obj->records[$i]['price'];
                 $shipping_cost = $obj->records[$i]['shipping_cost'];
                 $intro_date = $obj->records[$i]['intro_date'];
                 //$doj =  $obj->records[$i]['user_doj'];
                 $excel->writeRow();
                 $excel->writeCol($j);
                 $excel->writeCol($title);
                 $excel->writeCol($description);
                 $excel->writeCol($brand);
                 $excel->writeCol($model);
                 $excel->writeCol($msrp);
                 $excel->writeCol($price);
                 $excel->writeCol($shipping_cost);
                 $excel->writeCol($intro_date);
                 //$excel->writeCol($doj);
                 $j++;
             }
             $excel->close();
         }
         if (strpos($_SERVER['USER'], 'MSIE')) {
             // IE cannot download from sessions without a cache
             header('Cache-Control: public');
         } else {
             //header("Cache-Control: no-cache, must-revalidate");
             header("Cache-Control: no-cache");
         }
         $file = "Product_Detail.xls";
         //chmod ($file, 0755);
         header("Pragma: no-cache");
         header("Content-Type: php/doc/xml/html/htm/asp/jpg/JPG/sql/txt/jpeg/gif/bmp/png/xls/csv/x-ms-asf\n");
         header("Connection: close");
         header("Content-Disposition: attachment; filename=" . $file . "\n");
         header("Content-Transfer-Encoding: binary\n");
         header("Content-length: " . (string) filesize("{$file}"));
         $fd = fopen($file, "rb");
         fpassthru($fd);
         /*function xlsBOF() 
         			{
         				echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);  
         				return;
         			}
         	
         			function xlsEOF() 
         			{
         				echo pack("ss", 0x0A, 0x00);
         				return;
         			}
         	
         			function xlsWriteNumber($Row, $Col, $Value) 
         			{
         				echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
         				echo pack("d", $Value);
         				return;
         			}
         	
         			function xlsWriteLabel($Row, $Col, $Value ) 
         			{
         				$L = strlen($Value);
         				echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
         				echo $Value;
         				return;
         			}
         			//Send header
         			header("Pragma: public");
         			header("Expires: 0");
         			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         			header("Content-Type: application/force-download");
         			header("Content-Type: application/octet-stream");
         			header("Content-Type: application/download");
         			header("Content-Disposition: attachment;filename=user_report.xls"); 
         			header("Content-Transfer-Encoding: binary ");
         			xlsBOF();
         					xlsWriteLabel(1,0,"No");
         					xlsWriteLabel(1,1,"First Name");
         					xlsWriteLabel(1,2,"Last Name");
         					xlsWriteLabel(1,3,"Display Name");
         					xlsWriteLabel(1,4,"Email");
         					xlsWriteLabel(1,5,"Date of Joining");
         								
         				   $xlsRow = 2;
         				   $j=1;
         					
         					//Query
         					
         					$sqlselect = "select user_fname,user_lname,user_display_name,user_email,user_doj from users_table";
         					
         					$obj = new Bin_Query();
         					if($obj->executeQuery($sqlselect))
         					{
         						$count=count($obj->records);
         						for($i=0;$i<$count;$i++)
         						{
         							$description = $obj->records[$i]['user_fname'];
         							$last_name = $obj->records[$i]['user_lname'];
         							$display_name = $obj->records[$i]['user_display_name'];
         							$email = $obj->records[$i]['user_email'];
         							$doj =  $obj->records[$i]['user_doj'];
         							
         							xlsWriteLabel($xlsRow,0,"$j");
         							xlsWriteLabel($xlsRow,1,$description);
         							xlsWriteLabel($xlsRow,2,$last_name);
         							xlsWriteLabel($xlsRow,3,$display_name);
         							xlsWriteLabel($xlsRow,4,$email);
         							xlsWriteLabel($xlsRow,5,$doj);
         							$xlsRow++;
         							$j++;
         						}
         					}
         					xlsEOF();
         					exit();	*/
     } else {
         if ($_POST['export'] == 'xml') {
             $sqlselect = "select sku,title,description,brand,model,msrp,price,shipping_cost,intro_date from products_table";
             $obj = new Bin_Query();
             if ($obj->executeQuery($sqlselect)) {
                 header("Content-Type: text/xml");
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: xml/force-download");
                 header("Content-Type: xml/octet-stream");
                 header("Content-Type: xml/download");
                 header("Content-Disposition: attachment;filename=product_report.xml");
                 header("Content-Transfer-Encoding:binary");
                 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
                 echo "<productdetails>\n";
                 $count = count($obj->records);
                 for ($i = 0; $i < $count; $i++) {
                     /*echo ("<user id=\"". $obj->records[$i]['user_id'] ."\">\n");
                     		echo ("<firstname=\"". $obj->records[$i]['user_fname'] ."\">\n");
                     		echo ("<lastname=\"". $obj->records[$i]['user_lname'] ."\">\n");
                     		echo ("<displayname=\"". $obj->records[$i]['user_display_name'] ."\">\n");
                     		echo ("<email=\"". $obj->records[$i]['user_email'] ."\">\n");
                     		echo ("<userdoj=\"". $obj->records[$i]['user_doj'] ."\">\n");*/
                     echo "<title>" . $obj->records[$i]['title'] . "</title>\n";
                     echo "<description>" . str_replace("&", '&amp;', $obj->records[$i]['description']) . "</description>\n";
                     echo "<brand>" . $obj->records[$i]['brand'] . "</brand>\n";
                     echo "<model>" . $obj->records[$i]['model'] . "</model>\n";
                     echo "<msrp>" . $obj->records[$i]['msrp'] . "</msrp>\n";
                     echo "<price>" . $obj->records[$i]['price'] . "</price>\n";
                     echo "<shipping_cost>" . $obj->records[$i]['shipping_cost'] . "</shipping_cost>\n";
                     echo "<intro_date>" . $obj->records[$i]['intro_date'] . "</intro_date>\n";
                 }
                 echo "</productdetails>\n";
                 exit;
             }
         } else {
             if ($_POST['export'] == 'csv') {
                 $csv_terminated = "\n";
                 $csv_separator = ",";
                 $csv_enclosed = '"';
                 $csv_escaped = "\\";
                 $sqlselect = "select sku,title,description,brand,model,msrp,price,shipping_cost,intro_date from products_table";
                 $obj = new Bin_Query();
                 if ($obj->executeQuery($sqlselect)) {
                     $schema_insert = '';
                     $schema_insert .= $csv_enclosed . Title . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Description . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Brand . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Model . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Msrp . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . Price . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . ShippingCost . $csv_enclosed . $csv_separator;
                     $schema_insert .= $csv_enclosed . IntroDate . $csv_enclosed;
                     $count = count($obj->records);
                     for ($i = 0; $i < $count; $i++) {
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['title'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['description'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['brand'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['model'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['msrp'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['price'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['ShippingCost'] . $csv_enclosed . $csv_separator;
                         $schema_insert .= $csv_enclosed . $obj->records[$i]['intro_date'] . $csv_enclosed;
                     }
                     $out .= $schema_insert;
                     $out .= $csv_terminated;
                 }
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Length: " . strlen($out));
                 // Output to browser with appropriate mime type, you choose ;)
                 header("Content-type: text/x-csv");
                 //header("Content-type: text/csv");
                 //header("Content-type: application/csv");
                 header("Content-Disposition: attachment; filename=product_report.csv");
                 echo $out;
                 exit;
             } else {
                 if ($_POST['export'] == 'tab') {
                     $tab_terminated = "\n";
                     $tab_separator = "->";
                     $tab_enclosed = '"';
                     $tab_escaped = "\\";
                     $sqlselect = "select sku,title,description,brand,model,msrp,price,shipping_cost,intro_date from products_table";
                     $obj = new Bin_Query();
                     if ($obj->executeQuery($sqlselect)) {
                         $schema_insert = '';
                         $schema_insert .= $tab_enclosed . Title . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Description . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Brand . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Model . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Msrp . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . Price . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . ShippingCost . $tab_enclosed . $tab_separator;
                         $schema_insert .= $tab_enclosed . IntroDate . $tab_enclosed;
                         $count = count($obj->records);
                         for ($i = 0; $i < $count; $i++) {
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['title'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['description'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['brand'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['model'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['msrp'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['price'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['shipping_cost'] . $tab_enclosed . $tab_separator;
                             $schema_insert .= $tab_enclosed . $obj->records[$i]['intro_date'] . $tab_enclosed;
                         }
                         $out .= $schema_insert;
                         $out .= $tab_terminated;
                     }
                     /*header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     		header("Content-Length: " . strlen($out));
                     		// Output to browser with appropriate mime type, you choose ;)
                     		header("Content-type: application/tab");
                     		//header("Content-type: text/csv");
                     		//header("Content-type: application/csv");
                     		header("Content-Disposition: attachment; filename=user_report.tab");*/
                     header("Pragma: public");
                     header("Expires: 0");
                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                     header("Content-Length: " . strlen($out));
                     header("Content-Type: tab/force-download");
                     header("Content-Type: tab/octet-stream");
                     header("Content-Type: tab/download");
                     header("Content-Disposition: attachment;filename=product_report.tsv");
                     header("Content-Transfer-Encoding: binary ");
                     echo $out;
                     exit;
                 }
             }
         }
     }
 }