diff options
-rwxr-xr-x | code_approval.inc | 65 | ||||
-rw-r--r-- | display_books.inc | 54 | ||||
-rwxr-xr-x | pdf/generate_pdf.inc | 103 | ||||
-rw-r--r-- | pdf/list_all_form_pdf.inc | 10 | ||||
-rwxr-xr-x | textbook_companion.module | 45 |
5 files changed, 240 insertions, 37 deletions
diff --git a/code_approval.inc b/code_approval.inc index d315228..5aad0cf 100755 --- a/code_approval.inc +++ b/code_approval.inc @@ -284,7 +284,7 @@ function code_approval_form_submit($form, &$form_state) /******************************************************************************/ /********************************* BULK APPROVAL ******************************/ /******************************************************************************/ -function bulk_approval_form($form, $form_state) +function bulk_approval_form($form, &$form_state) { $options_first = _bulk_list_of_books(); $options_two = _ajax_bulk_get_chapter_list(); @@ -452,7 +452,6 @@ function bulk_approval_form($form, $form_state) } function bulk_approval_submit_validate($form, &$form_state) { - //var_dump('test'); if (($form_state['values']['book_actions'] == 0) && ($form_state['values']['chapter_actions'] == 0) && ($form_state['values']['example_actions'] == 0)) drupal_set_message("Wrong selection of action. Please select any one action1", 'error'); return; @@ -473,8 +472,11 @@ function bulk_approval_form_submit($form, &$form_state) { global $user; $root_path = textbook_companion_path(); + if ($form_state['clicked_button']['#value'] == 'Submit') { + $book_name_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = :book_id",array(":book_id"=>$form_state['values']['book'])); + $book_name= $book_name_q->fetchObject(); if ($form_state['values']['book']) del_book_pdf($form_state['values']['book']); if (user_access('bulk manage code')) @@ -502,9 +504,9 @@ function bulk_approval_form_submit($form, &$form_state) } //$chapter_data = $chapter_q->fetchObject() drupal_set_message(t('Approved Entire Book.'), 'status'); /* email */ - $email_subject = t('Your uploaded examples have been approved'); + $email_subject = t('[scilab.in] Your uploaded examples have been approved'); $email_body = array( - 0 => t('Your all the uploaded examples for the book have been approved.') + 0 => t('Your all the uploaded examples for the book '. $book_name->book .' have been approved.') ); } //($form_state['values']['book_actions'] == 1) && ($form_state['values']['chapter_actions'] == 0) && ($form_state['values']['example_actions'] == 0) else if (($form_state['values']['book_actions'] == 2) && ($form_state['values']['chapter_actions'] == 0) && ($form_state['values']['example_actions'] == 0)) @@ -527,9 +529,9 @@ function bulk_approval_form_submit($form, &$form_state) } //$chapter_data = $chapter_q->fetchObject() drupal_set_message(t('Pending Review Entire Book.'), 'status'); /* email */ - $email_subject = t('Your uploaded examples have been marked as pending'); + $email_subject = t('[scilab.in] Your uploaded examples have been marked as pending'); $email_body = array( - 0 => t('Your all the uploaded examples for the book have been marked as pending to be review. You will be able to see the exmaples after they have been approved by one of our reviewers.') + 0 => t('Your all the uploaded examples for the book '. $book_name->book .' have been marked as pending to be review. You will be able to see the exmaples after they have been approved by one of our reviewers.') ); } //($form_state['values']['book_actions'] == 2) && ($form_state['values']['chapter_actions'] == 0) && ($form_state['values']['example_actions'] == 0) else if (($form_state['values']['book_actions'] == 3) && ($form_state['values']['chapter_actions'] == 0) && ($form_state['values']['example_actions'] == 0)) @@ -548,9 +550,9 @@ function bulk_approval_form_submit($form, &$form_state) drupal_set_message(t('Error Dis-Approving and Deleting Entire Book.'), 'error'); } /* email */ - $email_subject = t('Your uploaded examples have been marked as dis-approved'); + $email_subject = t('[scilab.in] Your uploaded examples have been marked as dis-approved'); $email_body = array( - 0 => t('Your all the uploaded examples for the whole book have been marked as dis-approved. + 0 => t('Your all the uploaded examples for the whole book '. $book_name->book .' have been marked as dis-approved. Reason for dis-approval: @@ -603,18 +605,12 @@ Reason for dis-approval: $query->condition('id', $form_state['values']['book']); $result = $query->execute(); $preference_data = $result->fetchObject(); + $book_name = $preference_data->book; $proposal_id = $preference_data->proposal_id; - /*db_query("DELETE FROM {textbook_companion_preference} WHERE proposal_id = %d", $proposal_id);*/ - $query = db_delete('textbook_companion_preference'); - $query->condition('proposal_id', $proposal_id); - $num_deleted = $query->execute(); - /*db_query("DELETE FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);*/ - $query = db_delete('textbook_companion_proposal'); - $query->condition('id', $proposal_id); - $num_deleted = $query->execute(); + drupal_set_message(t('Deleted Book Proposal.'), 'status'); /* email */ - $email_subject = t('Your uploaded examples including the book proposal have been deleted'); + $email_subject = t('[scilab.in] Your uploaded examples including the book '. $book_name->book .' proposal have been deleted'); $email_body = array( 0 => t('Your all the uploaded examples including the book have been deleted permanently. @@ -622,6 +618,15 @@ Reason for deletion: ' . $form_state['values']['message']) ); + /*db_query("DELETE FROM {textbook_companion_preference} WHERE proposal_id = %d", $proposal_id);*/ + $query = db_delete('textbook_companion_preference'); + $query->condition('proposal_id', $proposal_id); + $num_deleted = $query->execute(); + + /*db_query("DELETE FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);*/ + $query = db_delete('textbook_companion_proposal'); + $query->condition('id', $proposal_id); + $num_deleted = $query->execute(); } //delete_book($form_state['values']['book']) else { @@ -641,7 +646,7 @@ Reason for deletion: $num_updated = $query->execute(); drupal_set_message(t('Approved Entire Chapter.'), 'status'); /* email */ - $email_subject = t('Your uploaded examples have been approved'); + $email_subject = t('[scilab.in] Your uploaded examples have been approved'); $email_body = array( 0 => t('Your all the uploaded examples for the chapter have been approved.') ); @@ -657,7 +662,7 @@ Reason for deletion: $num_updated = $query->execute(); drupal_set_message(t('Entire Chapter marked as Pending Review.'), 'status'); /* email */ - $email_subject = t('Your uploaded examples have been marked as pending'); + $email_subject = t('[scilab.in] Your uploaded examples have been marked as pending'); $email_body = array( 0 => t('Your all the uploaded examples for the chapter have been marked as pending to be review.') ); @@ -678,7 +683,7 @@ Reason for deletion: drupal_set_message(t('Error Dis-Approving and Deleting Entire Chapter.'), 'error'); } /* email */ - $email_subject = t('Your uploaded example have been marked as dis-approved'); + $email_subject = t('[scilab.in] Your uploaded example have been marked as dis-approved'); $email_body = array( 0 => t('Your uploaded example for the entire chapter have been marked as dis-approved. @@ -699,7 +704,7 @@ Reason for dis-approval: $num_updated = $query->execute(); drupal_set_message(t('Example approved.'), 'status'); /* email */ - $email_subject = t('Your uploaded example has been approved'); + $email_subject = t('[scilab.in] Your uploaded example has been approved'); $email_body = array( 0 => t('Your uploaded example has been approved.') ); @@ -715,7 +720,7 @@ Reason for dis-approval: $num_updated = $query->execute(); drupal_set_message(t('Example marked as Pending Review.'), 'status'); /* email */ - $email_subject = t('Your uploaded example has been marked as pending'); + $email_subject = t('[scilab.in] Your uploaded example has been marked as pending'); $email_body = array( 0 => t('Your uploaded example has been marked as pending to be review.') ); @@ -731,7 +736,7 @@ Reason for dis-approval: drupal_set_message(t('Error Dis-Approving and Deleting Example.'), 'error'); } /* email */ - $email_subject = t('Your uploaded example has been marked as dis-approved'); + $email_subject = t('[scilab.in] Your uploaded example has been marked as dis-approved'); $email_body = array( 0 => t('Your uploaded example has been marked as dis-approved. @@ -744,6 +749,20 @@ Reason for dis-approval: if ($email_subject) { $email_to = $user->mail; + $from = variable_get('textbook_companion_from_email', ''); + $bcc = variable_get('textbook_companion_emails', ''); + $cc = variable_get('textbook_companion_cc_emails', ''); + //$params['proposal_disapproved']['proposal_id'] = $proposal_id; + //$params['proposal_disapproved']['user_id'] = $row->uid; + $params['standard']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc + ); $params['standard']['subject'] = $email_subject; $params['standard']['body'] = $email_body; if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $params, variable_get('textbook_companion_from_email', NULL), TRUE)) diff --git a/display_books.inc b/display_books.inc new file mode 100644 index 0000000..dd8706d --- /dev/null +++ b/display_books.inc @@ -0,0 +1,54 @@ +<?php +/* function to display books in progress */ +function tbc_books_in_progress_all() +{ + $output = ""; + $query = db_select('list_of_category'); + $query->fields('list_of_category'); + $query->orderBy('id', 'ASC'); + $category_list = $query->execute(); + + $query = " + SELECT po.creation_date, pe.book as book, pe.author as author, pe.publisher as publisher,pe.edition as edition, pe.isbn as isbn, pe.year as year, pe.id as pe_id, loc.category_name as category, loc.category_id as cat_id +FROM textbook_companion_preference pe +LEFT JOIN textbook_companion_proposal po ON pe.proposal_id = po.id +LEFT JOIN list_of_category loc on pe.category = loc.category_id +WHERE po.proposal_status IN (1,4) AND pe.approval_status = 1 +ORDER BY po.creation_date DESC + "; + $result = db_query($query); + $proposal_rows = array(); + $i = 1; + $category_data = _tbc_list_of_category($preference_data->category); + $output = "<hr>"; + while ($row = $result->fetchObject()) + { + $proposal_date = date("d-m-Y", $row->creation_date); // remove comment to display year + if ($row->category != NULL) + { + $category = $row->category; + } //$row->category != NULL + else + { + $category = "Not assigned"; + } + $preference_rows[] = array( + $i, + $proposal_date, + $row->book . "<br><br>[ Author: " . $row->author . ", Publisher: " . $row->publisher . ", Year: " . $row->year . ", Edition: " . $row->edition . ", ISBN: " . $row->isbn . " ]", + $category + ); + $i++; + } //$row = $result->fetchObject() + $preference_header = array( + 'No', + 'Proposal Date', + 'Book', + 'Category' + ); + $output .= theme('table', array( + 'header' => $preference_header, + 'rows' => $preference_rows + )); + return $output; +} 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, diff --git a/textbook_companion.module b/textbook_companion.module index 98263fb..3f55940 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -8,6 +8,16 @@ function textbook_companion_menu() { $items = array(); /* users */ + /* BOOKS IN PROGRESS */ + $items['books_in_progress'] = array( + 'title' => 'Books in Progress', + 'page callback' => 'tbc_books_in_progress_all', + 'access arguments' => array( + 'display books in progress' + ), + 'type' => MENU_LOCAL_TASK, + 'file' => 'display_books.inc' + ); $items['proposal'] = array( 'title' => 'Book Proposal Form', 'description' => 'Book Proposal Form.', @@ -633,8 +643,8 @@ function textbook_companion_menu() 'file' => 'cheque_contact.inc' ); $items['certificate'] = array( - 'title' => 'List Of All Certificates', - 'description' => 'List Of All Certificates', + 'title' => 'List of all Certificates', + 'description' => 'List of all Certificates', 'page callback' => '_list_all_certificates', 'access arguments' => array( 'list all certificates' @@ -654,25 +664,40 @@ function textbook_companion_menu() 'file' => 'pdf/generate_pdf.inc' ); /*******************/ - $items['Summer_Internship_Forms/copyright-form'] = array( - 'title' => 'List Of All Copyright Forms for Completed books', - 'description' => 'List Of All Copyright Forms for Completed books', + $items['Summer_Internship_Forms/forms'] = array( + 'title' => 'List of all Copyright Form and Undertaking Form for books', + 'description' => 'List of all Copyright Form for books', 'page callback' => '_list_all_copyright_forms', 'access arguments' => array( 'list all certificates' ), + 'type' => MENU_LOCAL_TASK, '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', + 'title' => 'Download Copyright Form for books', + 'description' => 'Download Copyright Form for books', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'generate_copyright_form_pdf' + ), + 'access arguments' => array( + 'generate pdf' + ), + 'type' => MENU_LOCAL_TASK, + 'file' => 'pdf/generate_pdf.inc' + ); + $items['Summer_Internship_Forms/undertaking-form/generate_pdf'] = array( + 'title' => 'Download Undertaking Form for books', + 'description' => 'Download Undertaking Form for books', 'page callback' => 'drupal_get_form', 'page arguments' => array( - 'generate_form_pdf' + 'generate_undertaking_form_pdf' ), 'access arguments' => array( 'generate pdf' ), + 'type' => MENU_LOCAL_TASK, 'file' => 'pdf/generate_pdf.inc' ); /*******************/ @@ -701,6 +726,10 @@ function textbook_companion_permission() "title" => t("Book Proposal Form"), "description" => t("Book Proposal Form.") ), + "display books in progress" => array( + "title" => t("Book display books in progress"), + "description" => t("display books in progress.") + ), "approve book proposal" => array( "title" => t("Approve book proposal"), "description" => t("Allows users to approve book proposal.") |