1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php include_once '../include/DBConnect.php'; ?> <?php include_once '../receipt/changemoney.php'; ?> <?php require_once '../include/Classes/PHPExcel.php' ?> <?php require_once '../include/Classes/PHPExcel/IOFactory.php' ?> <?php require_once '../include/Classes/PHPExcel/Writer/Excel2007.php' ?>
<?php
$Export_id = $_GET['id']; $maxlength = 45; $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) { $loadname = 'Pathway_receipt_C.xlsx'; } }
$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); } $PHPExcel->getActiveSheet()->setCellValue('B10', $payof); $PHPExcel->getActiveSheet()->setCellValue('A11', $payway); if ($payway == 'By cheque :') { $PHPExcel->getActiveSheet()->setCellValue('B11', $bank_name . ' ' . $cheque_no); } $PHPExcel->getActiveSheet()->setCellValue('E8', $money); $PHPExcel->getActiveSheet()->setCellValue('E6', $paydate); $PHPExcel->getActiveSheet()->setCellValue('E4', $receiptNo); $PHPExcelWriter = PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel2007'); $PHPExcelWriter->save('' . $receiptNo . '.xlsx'); @header("Content-type: application/force-download"); @header("Content-Disposition: attachment; filename=\"'$receiptNo'.xlsx\""); @header("Content-Length: " . filesize($receiptNo . '.xlsx'));
echo("<script>location.href ='receipt_index';</script>"); ?>
|