diff options
-rwxr-xr-x | pdf/generate_pdf.inc | 101 | ||||
-rw-r--r-- | pdf/list_all_form_pdf.inc | 65 | ||||
-rwxr-xr-x | textbook_companion.module | 4 |
3 files changed, 160 insertions, 10 deletions
diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc index 4a60020..97eee5b 100755 --- a/pdf/generate_pdf.inc +++ b/pdf/generate_pdf.inc @@ -36,9 +36,6 @@ function generate_pdf() ); } } //$data3->gender - //die; - /*if($data3->proposal_status == 3) - {*/ $pdf = new FPDF('L', 'mm', 'Letter'); if (!$pdf) { @@ -129,10 +126,98 @@ function generate_pdf() unlink($file); drupal_goto('certificate'); return; - /*} - else +} +function generate_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) { - drupal_set_message('Your Book Is Still Under Review.', 'status'); - }*/ + echo "Error!"; + } //!$pdf + $pdf->AddPage(); + $path = drupal_get_path('module', 'textbook_companion'); + $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 Scilab Textbook Companion for ' . $data2->book . ' ( Author: ' . $data2->author . ', Edition: ' . $data2->edition . ', Publisher: ' . $data2->publisher . ', Year: ' . $data2->year . ') to FOSSEE Project, IIT Bombay.', 0); + $pdf->Ln(10); + $pdf->MultiCell(200, 8, 'I understand that the FOSSEE project will release the Textbook Companion 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) . '-Scilab-Textbook-Companion-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(); // 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/copyright-form'); + return; } -?> diff --git a/pdf/list_all_form_pdf.inc b/pdf/list_all_form_pdf.inc new file mode 100644 index 0000000..1cb07f8 --- /dev/null +++ b/pdf/list_all_form_pdf.inc @@ -0,0 +1,65 @@ +<?php +//Used to generate forms dynamiclay +function _list_all_copyright_forms() +{ + global $user; + $query_id = db_query("SELECT id FROM textbook_companion_proposal WHERE proposal_status=3 AND uid= :uid", array( + ':uid' => $user->uid + )); + $exist_id = $query_id->fetchObject(); + if ($exist_id->id) + { + 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'); + return ''; + } //$exist_id->id < 3 + else + { + $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( + ':uid' => $user->uid + )); + while ($search_data3 = $query3->fetchObject()) + { + if ($search_data3->id) + { + $search_rows[] = array( + $search_data3->isbn, + $search_data3->book, + $search_data3->author, + l('Download Copyright Form', 'Summer_Internship_Forms/copyright-form/generate_pdf/' . $search_data3->id) + ); + } //$search_data3->id + } //$search_data3 = $query3->fetchObject() + if ($search_rows) + { + $search_header = array( + 'ISBN', + 'Book Name', + 'Author', + 'Download Copyright Form' + ); + $output = theme('table', array( + 'header' => $search_header, + 'rows' => $search_rows + )); + return $output; + } //$search_rows + else + { + echo ("Error"); + return ''; + } + } + } //$exist_id->id + else + { + 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'); + return ''; + } +} + + diff --git a/textbook_companion.module b/textbook_companion.module index 1bf8a85..98263fb 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -661,14 +661,14 @@ function textbook_companion_menu() 'access arguments' => array( 'list all certificates' ), - 'file' => 'pdf/generate_form_pdf.inc' + 'file' => 'pdf/list_all_form_pdf.inc' ); $items['Summer_Internship_Forms/copyright-form/generate_pdf'] = array( 'title' => 'Download Copyright Forms for Completed books', 'description' => 'Download Copyright Forms for Completed books', 'page callback' => 'drupal_get_form', 'page arguments' => array( - 'generate_pdf' + 'generate_form_pdf' ), 'access arguments' => array( 'generate pdf' |