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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
<?php
function generate_pdf()
{
$mpath = drupal_get_path('module', 'cfd_case_study');
require($mpath.'/pdf/fpdf/fpdf.php');
require($mpath.'/pdf/phpqrcode/qrlib.php');
global $user;
$x = $user->uid;
$proposal_id = arg(3);
$query3 = db_query("SELECT * FROM case_study_proposal WHERE approval_status=3 AND uid= :uid AND id=:proposal_id", array(
':uid' => $user->uid,
':proposal_id'=>$proposal_id
));
$data3 = $query3->fetchObject();
if($data3){
if($data3->uid != $x){
drupal_set_message('Certificate is not available','error');
return;
}
}
$gender = array(
'salutation' => 'Mr. /Ms.',
'gender' => 'He/She'
);
if ($data3->gender) {
if ($data3->gender == 'M') {
$gender = array(
'salutation' => 'Mr.',
'gender' => 'He'
);
} //$data3->gender == 'M'
else {
$gender = array(
'salutation' => 'Ms.',
'gender' => 'She'
);
}
} //$data3->gender
$pdf = new FPDF('L', 'mm', 'Letter');
if (!$pdf) {
echo "Error!";
} //!$pdf
$pdf->AddPage();
$image_bg = $mpath . "/pdf/images/bg_cert.png";
//$pdf->Image($image_bg, 0, 0, $pdf->w, $pdf->h);
$pdf->Image($image_bg, 0, 0, $pdf->GetPageWidth(), $pdf->GetPageHeight());
//$pdf->Rect(5, 5, 267, 207, 'D');
$pdf->SetMargins(18, 1, 18);
//$pdf->Line(7.0, 7.0, 270.0, 7.0);
//$pdf->Line(7.0, 7.0, 7.0, 210.0);
//$pdf->Line(270.0, 210.0, 270.0, 7.0);
//$pdf->Line(7.0, 210.0, 270.0, 210.0);
$path = drupal_get_path('module', 'cfd_case_study');
//$image1 = $mpath . "/pdf/images/dwsim_logo.png";
$pdf->Ln(30);
//$pdf->Cell(200, 8, $pdf->Image($image1, 105, 15, 0, 28), 0, 1, 'C');
//$pdf->Ln(20);
//$pdf->SetTextColor(139, 69, 19);
//$pdf->Cell(240, 8, 'Certificate of Participation', '0', 1, 'C');
//$pdf->Ln(26);
$pdf->SetFont('Times', 'I', 18);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(320, 10, 'This is to certify that', '0', '1', 'C');
$pdf->Ln(0);
$pdf->SetFont('Times', 'I', 18);
//$pdf->SetFont('Arial', 'BI', 25);
$pdf->SetTextColor(37, 22, 247);
$pdf->Cell(320, 10, $data3->name_title . '. ' . $data3->contributor_name, '0', '1', 'C');
$pdf->Ln(0);
$pdf->SetFont('Times', 'I', 18);
if (strtolower($data3->branch) != "others") {
$title = WordWrap($data3->project_title,60);
$university = 'from ' . $data3->university;
$pdf->SetTextColor(0, 0, 0);
//$pdf->Cell(240, 8, 'from ' . $data3->university . ' has successfully', '0', '1', 'C');
$pdf->MultiCell(320, 10, $university, '0','C');
$pdf->Ln(0);
$pdf->Cell(320, 10, 'has successfully completed the case study on', '0', '1', 'C');
$pdf->Ln(0);
$pdf->SetTextColor(37, 22, 247);
$pdf->SetFont('Times','I',20);
$pdf->MultiCell(320, 10, $title, '0', 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->Ln(0);
$pdf->SetFont('Times','I',18);
$pdf->Cell(320, 8, 'using OpenFOAM.', '0', '1', 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->Ln(4);
$pdf->Cell(320, 8, 'The work done is available at', '0', '1', 'C');
$pdf->Cell(320, 4, '', '0', '1', 'C');
$pdf->SetX(130);
$pdf->SetFont('Times', 'I', 'U');
$pdf->SetTextColor(37, 22, 247);
$pdf->write(0, 'https://cfd.fossee.in/case-study-project', 'https://cfd.fossee.in/case-study-project');
$pdf->Ln(0);
//$pdf->SetFont('Times', 'I', 16);
//$pdf->Cell(320, 8, 'under Case Study Project', '0', '1', 'C');
//$pdf->Ln(0);
//$pdf->SetFont('Helvetica', '', 18);
//$pdf->Cell(0, 0, ' Case Study Project', '0', '0', 'C');
//$pdf->Cell(240, 4, '', '0', '1', 'C');
//$pdf->SetX(120);
//$pdf->SetFont('', 'U');
//$pdf->SetTextColor(139, 69, 19);
//$pdf->write(0, 'http://CFD.fossee.in/', 'http://CFD.fossee.in/');
//$pdf->Ln(0);
//$pdf->Cell(240, 8, 'Book: ' . $data2->book . ', Author: ' . $data2->author . '.', '0', '1', 'C');
//$pdf->MultiCell(240, 8, 'Book: ' . $data2->book . ', Author: ' . $data2->author . '.', '0','C');
$pdf->Ln(0);
} //strtolower($data3->branch) != "others"
else {
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(240, 8, 'from ' . $data3->university . ' college', '0', '1', 'C');
$pdf->Ln(0);
$pdf->Cell(240, 8, 'has successfully completed the case study of', '0', '1', 'C');
$pdf->Ln(0);
$pdf->SetTextColor(139, 69, 19);
$pdf->Cell(320, 12, $data3->project_title, '0', '1', 'C');
$pdf->SetTextColor(0, 0, 0);
$pdf->Ln(0);
$pdf->SetFont('Times', '', 16);
$pdf->Cell(320, 8, ' under Case Study Project', '0', '1', 'C');
//$pdf->Cell(240, 8, 'He/she has coded ' . $number_of_example . ' solved examples using DWSIM from the', '0', '1', 'C');
//$pdf->Ln(0);
//$pdf->Cell(240, 8, 'Book: ' . $data2->book . ', Author: ' . $data2->author . '.', '0', '1', 'C');
//$pdf->Ln(0);
}
$proposal_get_id = 0;
$UniqueString = "";
$tempDir = $path . "/pdf/temp_prcode/";
$query = db_select('case_study_qr_code');
$query->fields('case_study_qr_code');
$query->condition('proposal_id', $proposal_id);
$result = $query->execute();
$data = $result->fetchObject();
$DBString = $data->qr_code;
$proposal_get_id = $data->proposal_id;
if ($DBString == "" || $DBString == "null") {
$UniqueString = generateRandomString();
$query = "
INSERT INTO case_study_qr_code
(proposal_id,qr_code)
VALUES
(:proposal_id,:qr_code)
";
$args = array(
":proposal_id" => $proposal_id,
":qr_code" => $UniqueString
);
$result = db_query($query, $args, array(
'return' => Database::RETURN_INSERT_ID
));
} //$DBString == "" || $DBString == "null"
else {
$UniqueString = $DBString;
}
$codeContents = "https://cfd.fossee.in/case-study-project/certificates/verify/" . $UniqueString;
$fileName = 'generated_qrcode.png';
$pngAbsoluteFilePath = $tempDir . $fileName;
$urlRelativeFilePath = $path . "/pdf/temp_prcode/" . $fileName;
QRcode::png($codeContents, $pngAbsoluteFilePath);
$pdf->SetY(85);
$pdf->SetX(320);
$pdf->Ln(10);
$sign1 = $path . "/pdf/images/sign1.png";
$sign2 = $path . "/pdf/images/sign2.png";
$pdf->Image($sign1, $pdf->GetX()+75, $pdf->GetY() + 45, 60, 0);
$pdf->Image($sign2, $pdf->GetX()+160, $pdf->GetY() + 45, 75, 0);
$pdf->Image($pngAbsoluteFilePath, $pdf->GetX()+15, $pdf->GetY()+75, 30, 0);
$fossee = $path . "/pdf/images/fossee.png";
$mhrd = $path . "/pdf/images/mhrd.png";
$nia_logo = $path . "/pdf/images/nia.png";
$start_date = 1606761000;
$end_date = 1640975364;
if($data3->approval_date > $start_date && $data3->approval_date < $end_date){
$pdf->Image($fossee, $pdf->GetX()+55, $pdf->GetY()+80, 50, 0);
$pdf->Image($nia_logo, $pdf->GetX()+135, $pdf->GetY()+80, 50, 0);
$pdf->Image($mhrd, $pdf->GetX()+200, $pdf->GetY()+80, 40, 0);
$pdf->Ln(2);
$ftr_line = $path . "/pdf/images/ftr_line.png";
$pdf->Image($ftr_line, $pdf->GetX()+15, $pdf->GetY()+105, 220, 0);
$pdf->Ln(3);
$ftr_line_2 = $path . "/pdf/images/ftr_line_2.png";
$pdf->Image($ftr_line_2, $pdf->GetX()+25, $pdf->GetY()+106, 190, 0);
}
else{
$pdf->Image($fossee, $pdf->GetX()+100, $pdf->GetY()+80, 50, 0);
$pdf->Image($mhrd, $pdf->GetX()+180, $pdf->GetY()+80, 40, 0);
$pdf->Ln(4);
$ftr_line = $path . "/pdf/images/ftr_line.png";
$pdf->Image($ftr_line, $pdf->GetX()+15, $pdf->GetY()+105, 220, 0);
}
//$pdf->SetX(29);
//$pdf->SetY(-50);
$pdf->SetFont('Times', 'I', 15);
$pdf->SetLeftMargin(40);
$pdf->GetY()+60;
$pdf->Ln(62);
$pdf->Cell(320, 8, $UniqueString, '0', '1', 'L');
//$pdf->Ln(6);
$pdf->SetFont('Arial', 'I', 8);
$pdf->SetTextColor(0, 0, 0);
$filename = str_replace(' ', '-', $data3->contributor_name) . '-CFD-case-study-Certificate.pdf';
$file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename;
$pdf->Output($file, 'F');
ob_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Length: " . filesize($file));
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Pragma: no-cache");
flush();
$fp = fopen($file, "r");
while (!feof($fp)) {
echo fread($fp, filesize($file));
flush();
} //!feof($fp)
ob_end_flush();
ob_clean();
fclose($fp);
unlink($file);
//drupal_goto('flowsheeting-project/certificate');
return;
}
function generateRandomString($length = 5)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
} //$i = 0; $i < $length; $i++
return $randomString;
}
function generate_copyright_form_pdf()
{
$mpath = drupal_get_path('module', 'circuit_simulation');
require($mpath . '/pdf/fpdf/fpdf.php');
global $user;
$x = $user->uid;
$proposal_id = arg(3);
$query2 = db_query("SELECT id FROM case_study_proposal WHERE approval_status=3 AND uid= :uid", array(
':uid' => $user->uid
));
$data2 = $query2->fetchObject();
$query3 = db_query("SELECT * FROM case_study_proposal WHERE approval_status=3 AND uid= :uid", array(
':uid' => $user->uid
));
$data3 = $query3->fetchObject();
$gender = array(
'salutation' => 'Mr. /Ms.',
'gender' => 'He/She'
);
if ($data3->gender) {
if ($data3->gender == 'M') {
$gender = array(
'salutation' => 'Mr.',
'gender' => 'He'
);
} //$data3->gender == 'M'
else {
$gender = array(
'salutation' => 'Ms.',
'gender' => 'She'
);
}
} //$data3->gender
$pdf = new FPDF('P', 'mm', 'Letter');
if (!$pdf) {
echo "Error!";
} //!$pdf
$pdf->AddPage();
$path = drupal_get_path('module', 'circuit_simulation');
$pdf->SetFont('Arial', 'B', 25);
$pdf->Ln(30);
$pdf->Cell(200, 8, 'Copyright Transfer Form', 0, 1, 'C');
$pdf->Ln(20);
$pdf->SetFont('Arial', '', 12);
$pdf->MultiCell(200, 8, 'I hereby transfer the copyrights of the DWSIM Flowsheeting Project for ' . $data2->project_title . ' to FOSSEE Project, IIT Bombay.', 0);
$pdf->Ln(10);
$pdf->MultiCell(200, 8, 'I understand that the FOSSEE project will release the Flowsheet under the Creative Commons (CC) license.');
$pdf->SetX(75);
$pdf->SetFont('', 'U');
$pdf->SetTextColor(0, 0, 255);
$pdf->SetFont('', '');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetY(-10);
$pdf->SetX(209);
$cur_date = date('jS F, Y');
$pdf->SetY(140);
$pdf->SetFont('', '');
$pdf->Ln(0);
$pdf->Cell(200, 0, ' Date: ' . $cur_date . '', 0, 1, 'L');
$pdf->Cell(200, 20, ' Place: _________________', 0, 1, 'L');
$pdf->SetY(140);
$pdf->SetX(120);
$pdf->Cell(180, 0, 'Signature: _________________', 0, 1, 'L');
$pdf->SetY(144);
$pdf->SetX(120);
$pdf->multicell(140, 14, 'Name: ' . $gender['salutation'] . ' ' . $data3->full_name . '', 0, '');
$filename = str_replace(' ', '-', $data3->full_name) . '-eSim-Circuit-Simulation-copyright-form.pdf';
$file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename;
$pdf->Output($file, 'F');
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush();
$fp = fopen($file, "r");
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
} //!feof($fp)
fclose($fp);
unlink($file);
drupal_goto('Summer_Internship_Forms/forms');
return;
}
function generate_undertaking_form_pdf()
{
$mpath = drupal_get_path('module', 'circuit_simulation');
require($mpath . '/pdf/fpdf/fpdf.php');
global $user;
$x = $user->uid;
$proposal_id = arg(3);
$query2 = db_query("SELECT id FROM case_study_proposal WHERE approval_status=3 AND uid= :uid", array(
':uid' => $user->uid
));
$data2 = $query2->fetchObject();
$query3 = db_query("SELECT * FROM case_study_proposal WHERE approval_status=3 AND uid= :uid", array(
':uid' => $user->uid
));
$data3 = $query3->fetchObject();
$gender = array(
'salutation' => 'Mr. /Ms.',
'gender' => 'He/She'
);
if ($data3->gender) {
if ($data3->gender == 'M') {
$gender = array(
'salutation' => 'Mr.',
'gender' => 'He'
);
} //$data3->gender == 'M'
else {
$gender = array(
'salutation' => 'Ms.',
'gender' => 'She'
);
}
} //$data3->gender
$pdf = new FPDF('P', 'mm', 'Letter');
if (!$pdf) {
echo "Error!";
} //!$pdf
$pdf->AddPage();
$path = drupal_get_path('module', 'circuit_simulation');
$pdf->SetFont('Arial', 'B', 25);
$pdf->Ln(30);
$pdf->Cell(200, 8, 'Undertaking Form', 0, 1, 'C');
$pdf->Ln(0);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(200, 8, '(To be signed by college teacher)', 0, 1, 'C');
$pdf->Ln(20);
$pdf->SetFont('Arial', '', 12);
$pdf->MultiCell(200, 8, 'I hereby certify that all the codes written by ' . $gender['salutation'] . ' ' . $data3->full_name . ' under the DWSIM Textbook Companion Project for the book ' . $data2->book . ' ( Author: ' . $data2->author . ', Edition: ' . $data2->edition . ', Publisher: ' . $data2->publisher . ', Year: ' . $data2->year . ') are correctly reproducing the results given in the aforementioned book.', 0);
$pdf->Ln(10);
$pdf->MultiCell(200, 8, 'I understand that the DWSIM Textbook Companion created is a part of FOSSEE project, IIT Bombay, and is sponsored by the National Mission on Education through Information and Communication Technology (NMEICT), under MHRD, Govt. of India. The project requires that the textbook companion is made available for public access as an open source document. Hence I undertake that this DWSIM Textbook Companion can be made public along with the information that I have certified all the codes as giving the correct answer.');
$pdf->SetX(75);
$pdf->SetFont('', 'U');
$pdf->SetTextColor(0, 0, 255);
$pdf->SetFont('', '');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '');
$pdf->SetTextColor(0, 0, 0);
$pdf->SetY(-10);
$pdf->SetX(209);
$cur_date = date('jS F, Y');
$pdf->SetY(180);
$pdf->SetFont('', '');
$pdf->Ln(0);
$pdf->Cell(200, 0, ' Date: ' . $cur_date . '', 0, 1, 'L');
$pdf->Cell(200, 20, ' Place: _________________', 0, 1, 'L');
$pdf->SetY(180);
$pdf->SetX(120);
$pdf->Cell(140, 0, 'Signature: _________________', 0, 1, 'L');
$pdf->SetX(120);
$pdf->multicell(140, 14, 'Name: ' . '____________________', 0, '');
$pdf->SetX(120);
$pdf->multicell(140, 14, 'Designation: ' . '______________', 0, '');
$filename = str_replace(' ', '-', $data3->full_name) . '-eSim-Circuit-Simulation-undertaking-form.pdf';
$file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename;
$pdf->Output($file, 'F');
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush();
$fp = fopen($file, "r");
while (!feof($fp)) {
echo fread($fp, 65536);
flush();
} //!feof($fp)
fclose($fp);
unlink($file);
drupal_goto('Summer_Internship_Forms/forms');
return;
}
|