| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/(Del)pathways.org.hk/MIS20140127/old20140414/Receipt/ |
Upload File : |
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
ini_set('display_errors', 1);
include_once '../include/DBConnect.php';
include_once '../receipt/changemoney.php';
require_once '../include/Classes/PHPExcel.php' ;
require_once '../include/Classes/PHPExcel/IOFactory.php' ;
require_once '../include/Classes/PHPExcel/Writer/Excel2007.php';
$Export_id = $_GET['id'];
$maxlength = 50;
$payofmaxlength = 160;
$name;
$money;
$payof;
$payway;
$bank_name;
$cheque_no;
$campus;
$type;
$paydate;
$loadname;
$receiptNo;
$query = "Select receipt_code, receipt_date, receipt_from, payment_of, total_amount, is_cash, bank_name, cheque_code, is_normal, campus_id from receipt where deleted = 0 and receipt_id = '$Export_id'";
$result = $dbh->query($query);
$result->setFetchMode(PDO::FETCH_OBJ);
while ($row = $result->fetch()) {
$receiptNo = $row->receipt_code;
$paydate = $row->receipt_date;
$name = $row->receipt_from;
$money = $row->total_amount;
$payof = $row->payment_of;
$bank_name = $row->bank_name;
$cheque_no = $row->cheque_code;
if ($row->is_cash == 0)
$payway = 'By cash :';
else if ($row->is_cash == 1)
$payway = 'By cheque :';
if ($row->is_normal == 0) {
if ($row->campus_id == 1) {
$loadname = 'Pathway_receipt_S.xlsx';
} else if ($row->campus_id == 2) {
$loadname = 'Pathway_receipt_K.xlsx';
}
} else if ($row->is_normal == 1) {
if ($row->campus_id == 1) {
$loadname = 'Pathway_receipt_C_S.xlsx';
} else if ($row->campus_id == 2) {
$loadname = 'Pathway_receipt_C_K.xlsx';
}
}
}
function umoney($str){
return $str;
}
$PHPExcel = new PHPExcel();
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$PHPExcel = $reader->load($loadname);
$PHPExcel->getProperties()->setCreator("Pathways");
$PHPExcel->getProperties()->setTitle("Receipt");
$PHPExcel->setActiveSheetIndex(0);
$PHPExcel->getActiveSheet()->setCellValue('B6', $name);
$fline;
$sline;
if (strlen(umoney($money)) < $maxlength) {
$PHPExcel->getActiveSheet()->setCellValue('B8', umoney($money));
} elseif (strlen(umoney($money)) > $maxlength) {
$string = umoney($money);
$string = wordwrap($string, $maxlength);
$fline = substr($string, 0, strpos($string, "\n"));
$sline = substr($string, strpos($string, "\n"));
$PHPExcel->getActiveSheet()->setCellValue('B8', $fline);
$PHPExcel->getActiveSheet()->setCellValue('B9', $sline);
}
if ($payof < $payofmaxlength) {
$PHPExcel->getActiveSheet()->setCellValue('B10', $payof);
} elseif ($payof > $payofmaxlength) {
$string = $payof;
$string = wordwrap($string, $payofmaxlength);
$fline = substr($string, 0, strpos($string, "\n"));
$sline = substr($string, strpos($string, "\n"));
$PHPExcel->getActiveSheet()->setCellValue('B10', $fline);
$PHPExcel->getActiveSheet()->setCellValue('B11', $sline);
}
$PHPExcel->getActiveSheet()->setCellValue('A11', $payway);
if ($payway == 'By cheque :') {
$PHPExcel->getActiveSheet()->setCellValue('B12', $bank_name . ' ' . $cheque_no);
}
$PHPExcel->getActiveSheet()->setCellValue('E8', $money);
$PHPExcel->getActiveSheet()->setCellValue('E6', $paydate);
$PHPExcel->getActiveSheet()->setCellValue('E4', $receiptNo);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Voucher_'.$gl_transaction->voucherno.'.xls"');
header('Cache-Control: max-age=0');
$PHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5');
$objWriter->save('php://output');