This repository has been archived by the owner on Oct 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
member_free_loan_letter_pdfgen.php
154 lines (145 loc) · 5.63 KB
/
member_free_loan_letter_pdfgen.php
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* Free Loan Letter PDF Generator
* Copyright (C) 2019 Drajat Hasan 2017 ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
define('INDEX_AUTH', '1');
require '../../../../sysconfig.inc.php';
require MDLBS.'membership/fll/fpdf/fpdfpp.php';
require SB.'admin/default/session.inc.php';
require SB.'admin/default/session_check.inc.php';
// Function to show number on letter
function counter(){
$handle = fopen(MDLBS.'membership/fll/loanquee.txt', "r");
if(!$handle){
utility::jsAlert(__('File Not Found!'));
} else {
$counter = (int) fread($handle,20);
fclose ($handle);
$counter++;
$handle = fopen(MDLBS.'membership/fll/loanquee.txt', "w");
fwrite($handle,$counter) ;
fclose ($handle) ;
}
}
// include printed settings configuration file
include MDLBS.'membership/fll/printed_settings.inc.php';
// load print settings from database to override value from printed_settings file
loadPrintSettings($dbs, 'freeloan');
// local date format
$sysconf['month'] = date('n');
$sysconf['array_ina_month_format'] = array('1' => 'Januari','2' => 'Februari','3' => 'Maret','4' => 'April','5' => 'Mei','6' => 'Juni','7' => 'Juli', '8' => 'Agustus','9' => 'September','10' => 'Oktober','11' => 'November','12' => 'Desember');
$sysconf['month_full'] = date('d')." ".$sysconf['array_ina_month_format'][$sysconf['month']]." ".date("Y");
// check if label session array is available
if (!isset($_SESSION['fll'])) {
utility::jsAlert(__('There is no data to print!'));
die();
}
if (count($_SESSION['fll']) < 1) {
utility::jsAlert(__('There is no data to print!'));
die();
}
// concat all ID together
$member_ids = '';
foreach ($_SESSION['fll'] as $id) {
$member_ids .= '\''.$id.'\',';
}
// strip the last comma
$member_ids = substr_replace($member_ids, '', -1);
$member_q = $dbs->query('SELECT m.member_essay, m.member_name, m.member_id, m.member_image, m.member_address, m.member_email, m.inst_name, m.postal_code, m.pin, m.member_phone, m.expire_date, m.register_date, mt.member_type_name FROM member AS m
LEFT JOIN mst_member_type AS mt ON m.member_type_id=mt.member_type_id
WHERE m.member_id IN('.$member_ids.')');
$member_datas = array();
while ($member_d = $member_q->fetch_assoc()) {
if ($member_d['member_id']) {
$member_datas[] = $member_d;
}
}
$show = fopen(MDLBS.'membership/fll/loanquee.txt', "r");
if (!$show) {
utility::jsAlert(__('Can not read file! loanquee.txt'));
exit();
}
// chunk cards array
$chunked_card_arrays = array_chunk($member_datas, $sysconf['print']['freeloan']['items_per_row']);
$pdf = new PDFPP();
foreach ($chunked_card_arrays as $membercard_rows) {
foreach ($membercard_rows as $card) {
// Get num
$number = (int)file_get_contents(MDLBS.'membership/fll/loanquee.txt');
if ($number == 0) {
$number = $number + 1;
}
$sysconf['number'] = sprintf("%03d", $number);
/* Add page*/
$pdf->AddPage();
/* Header */
$pdf->Image(MDLBS.'membership'.DS.'fll'.DS.'freeloan'.DS.$sysconf['print']['freeloan']['logo_surat'], 27, 10,-180);
$pdf->Ln(35);
$pdf->SetFont('Arial','U',14);
$pdf->Cell(190,3, $sysconf['print']['freeloan']['caption_letter'],0,1,'C');
$pdf->SetFont('Arial','',12);
$pdf->Cell(190,10,'Nomor : '.$sysconf['number'].$sysconf['print']['freeloan']['number_format'].$sysconf['print']['freeloan']['institute']."/".$sysconf['print']['freeloan']['period']."/".$sysconf['print']['freeloan']['year'], 0,1,'C');
$pdf->SetFont('Arial','',12);
$pdf->Ln(10);
/* Content */
$pdf->Cell(23,5,'',0);
$pdf->Cell(190,3, $sysconf['print']['freeloan']['declare_letter'] ,0,1,'L');
$pdf->Ln();
$pdf->Cell(25,5,'',0);
$pdf->Cell(30,10,'Nama', 0, '', 'L');
$pdf->Cell(5,10,':',0, '', 'C');
$pdf->Cell(120,10,$card['member_name'], 0, '', 'L');
$pdf->Ln();
$pdf->Cell(25,5,'',0);
$pdf->Cell(30,10,'NIM', 0, '', 'L');
$pdf->Cell(5,10,':',0, '', 'C');
$pdf->Cell(120,10,$card['member_id'], 0, '', 'L');
$pdf->Ln();
$pdf->Cell(25,5,'',0);
$pdf->Cell(30,10,'Judul', 0, '', 'L');
$pdf->Cell(5,10,':',0, '', 'C');
$pdf->Cell(120,10,$card['member_essay'], 0, '', 'L');
$pdf->Ln(13);
$pdf->Cell(24,5,'',0);
$pdf->MultiCell(145,6,$sysconf['print']['freeloan']['result_letter'],0);
$pdf->Ln(13);
/* Signature */
$pdf->Cell(120,5,'',0);
$pdf->Cell(70,5,$sysconf['print']['freeloan']['city'].', '.$sysconf['month_full'],0,1,'L');
$pdf->Cell(120,5,'',0);
$pdf->Cell(70,5,$sysconf['print']['freeloan']['division_of_signature'],0,1,'L');
$pdf->Ln(20);
$pdf->Cell(120,5,'',0);
$pdf->SetFont('Arial','U',12);
$pdf->Cell(70,5,$sysconf['print']['freeloan']['name_of_signature'],0,1,'L');
$pdf->SetFont('Arial','',12);
$pdf->Cell(120,5,'',0);
$pdf->Cell(70,5,$sysconf['print']['freeloan']['id_of_signature'],0,1,'L');
// add next num
$next_num = $number + 1;
file_put_contents(MDLBS.'membership/fll/loanquee.txt', $next_num);
}
}
// Auto print
if ($sysconf['print']['freeloan']['autoprint']) {
$pdf->AutoPrint();
}
$pdf->Output();
unset($_SESSION['fll']);
exit();