summaryrefslogtreecommitdiff
path: root/pdf/generate_pdf.inc
diff options
context:
space:
mode:
authorprashantsinalkar2016-09-08 12:29:40 +0530
committerprashantsinalkar2016-09-08 12:29:40 +0530
commit0c6c2c6f38a0729832750892e7bbacb6369aef15 (patch)
treeb959ff5bf4d84dc1b0eb158511828ac3e821c9f0 /pdf/generate_pdf.inc
parent7a0cc4abf3fdf0d0c1438737df719a882c2d29f6 (diff)
downloadscilab_textbook_companion-0c6c2c6f38a0729832750892e7bbacb6369aef15.tar.gz
scilab_textbook_companion-0c6c2c6f38a0729832750892e7bbacb6369aef15.tar.bz2
scilab_textbook_companion-0c6c2c6f38a0729832750892e7bbacb6369aef15.zip
added interface to generate undertaking form dynamicaly
Diffstat (limited to 'pdf/generate_pdf.inc')
-rwxr-xr-xpdf/generate_pdf.inc100
1 files changed, 98 insertions, 2 deletions
diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc
index 97eee5b..e9a8f36 100755
--- a/pdf/generate_pdf.inc
+++ b/pdf/generate_pdf.inc
@@ -127,7 +127,7 @@ function generate_pdf()
drupal_goto('certificate');
return;
}
-function generate_form_pdf()
+function generate_copyright_form_pdf()
{
$mpath = drupal_get_path('module', 'textbook_companion');
require($mpath . '/pdf/fpdf/fpdf.php');
@@ -218,6 +218,102 @@ function generate_form_pdf()
} //!feof($fp)
fclose($fp);
unlink($file);
- drupal_goto('Summer_Internship_Forms/copyright-form');
+ drupal_goto('Summer_Internship_Forms/forms');
+ return;
+}
+function generate_undertaking_form_pdf()
+{
+ $mpath = drupal_get_path('module', 'textbook_companion');
+ require($mpath . '/pdf/fpdf/fpdf.php');
+ global $user;
+ $x = $user->uid;
+ $proposal_id = arg(3);
+ $query2 = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status=1 AND proposal_id= :prop_id", array(
+ ':prop_id' => $proposal_id
+ ));
+ $data2 = $query2->fetchObject();
+ $query3 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id= :prop_id", array(
+ ':prop_id' => $proposal_id
+ ));
+ $data3 = $query3->fetchObject();
+ //var_dump($data3->gender);
+ $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', 'textbook_companion');
+ $pdf->SetFont('Arial', 'B', 25);
+ $pdf->Ln(30);
+ $pdf->Cell(200, 8, 'Undertaking Form', 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 Scilab 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 Scilab 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 Scilab 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->SetY(144);
+ $pdf->SetX(120);
+ $pdf->multicell(140, 14, 'Name: ' . '____________________', 0, '');
+ $pdf->SetX(120);
+ $pdf->multicell(140, 14, 'Designation: ' . '______________', 0, '');
+ $filename = str_replace(' ', '-', $data3->full_name) . '-Scilab-Textbook-Companion-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(); // this doesn't really matter.
+ $fp = fopen($file, "r");
+ while (!feof($fp))
+ {
+ echo fread($fp, 65536);
+ flush(); // this is essential for large downloads
+ } //!feof($fp)
+ fclose($fp);
+ unlink($file);
+ drupal_goto('Summer_Internship_Forms/forms');
return;
}