diff options
author | Prashant S | 2016-10-06 10:18:39 +0530 |
---|---|---|
committer | GitHub | 2016-10-06 10:18:39 +0530 |
commit | c2c6a180da55d79d4431c3d322e8796cfafa277a (patch) | |
tree | be319ed330b96983783aa4e417d387f88e8b283e /pdf | |
parent | ef585554e8b1bb2b435074adea302970573cb02e (diff) | |
parent | f6cde8479056a9801407584f8c331d4a7e117e8a (diff) | |
download | scilab_textbook_companion-c2c6a180da55d79d4431c3d322e8796cfafa277a.tar.gz scilab_textbook_companion-c2c6a180da55d79d4431c3d322e8796cfafa277a.tar.bz2 scilab_textbook_companion-c2c6a180da55d79d4431c3d322e8796cfafa277a.zip |
Merge pull request #4 from prashantsinalkar/drupal_7.x
changed formating and added new features
Diffstat (limited to 'pdf')
-rwxr-xr-x | pdf/generate_pdf.inc | 103 | ||||
-rw-r--r-- | pdf/list_all_form_pdf.inc | 10 |
2 files changed, 107 insertions, 6 deletions
diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc index 97eee5b..aca2837 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,105 @@ 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(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 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; } diff --git a/pdf/list_all_form_pdf.inc b/pdf/list_all_form_pdf.inc index 1cb07f8..678af68 100644 --- a/pdf/list_all_form_pdf.inc +++ b/pdf/list_all_form_pdf.inc @@ -11,7 +11,7 @@ function _list_all_copyright_forms() { if ($exist_id->id < 3) { - drupal_set_message('<strong>You need to propose a book <a href="http://www.scilab.in/book_proposal">Book Proposal</a></strong> or if you have already proposed then your book is under reviewing process', 'status'); + drupal_set_message('<strong>You need to propose a <a href="http://www.scilab.in/book_proposal">Book Proposal</a></strong> or if you have already proposed then your book is under reviewing process', 'status'); return ''; } //$exist_id->id < 3 else @@ -19,7 +19,7 @@ function _list_all_copyright_forms() $search_rows = array(); global $output; $output = ''; - $query3 = db_query("SELECT prop.id,pref.isbn,pref.book,pref.author FROM textbook_companion_proposal as prop,textbook_companion_preference as pref WHERE prop.proposal_status=3 AND pref.approval_status=1 AND pref.proposal_id=prop.id AND prop.uid= :uid", array( + $query3 = db_query("SELECT prop.id,pref.isbn,pref.book,pref.author FROM textbook_companion_proposal as prop,textbook_companion_preference as pref WHERE prop.proposal_status = 3 AND pref.approval_status =1 AND pref.proposal_id = prop.id AND prop.uid = :uid", array( ':uid' => $user->uid )); while ($search_data3 = $query3->fetchObject()) @@ -30,7 +30,8 @@ function _list_all_copyright_forms() $search_data3->isbn, $search_data3->book, $search_data3->author, - l('Download Copyright Form', 'Summer_Internship_Forms/copyright-form/generate_pdf/' . $search_data3->id) + l('Download Copyright Form', 'Summer_Internship_Forms/copyright-form/generate_pdf/' . $search_data3->id), + l('Download Undertaking Form', 'Summer_Internship_Forms/undertaking-form/generate_pdf/' . $search_data3->id) ); } //$search_data3->id } //$search_data3 = $query3->fetchObject() @@ -40,7 +41,8 @@ function _list_all_copyright_forms() 'ISBN', 'Book Name', 'Author', - 'Download Copyright Form' + 'Download Copyright Form', + 'Download Undertaking Form' ); $output = theme('table', array( 'header' => $search_header, |