From 2c7074d2134f21ee0933d645ae2e2106da357d30 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Wed, 23 Nov 2016 15:38:11 +0530 Subject: added verify tbc certificate functionality --- pdf/verify_certificates.inc | 96 +++++++++++++++++++++++++++++++++++++++++++++ textbook_companion.module | 17 +++++++- 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 pdf/verify_certificates.inc diff --git a/pdf/verify_certificates.inc b/pdf/verify_certificates.inc new file mode 100644 index 0000000..20f21be --- /dev/null +++ b/pdf/verify_certificates.inc @@ -0,0 +1,96 @@ + 'markup', + '#markup' => '' + ); + $form["QR_code"] = array( + "#type" => "textfield", + "#title" => "Enter QR Code", + "#default_value" => '', + "#required" => TRUE + ); + $form["submit"] = array( + "#type" => "submit", + "#value" => "Verify", + '#ajax' => array( + 'callback' => 'verify_certificates_form_submit', + 'progress' => array( + 'message' => '' + ) + ) + ); + $form['displaytable'] = array( + '#type' => 'markup', + '#prefix' => '
', + '#suffix' => '
', + '#markup' => '' + ); + return $form; +} +function verify_certificates_form_submit($form, &$form_state) +{ + $page_content = ""; + $v = $form_state["values"]; + $qr_code = $v["QR_code"]; + $page_content = verify_qrcode_fromdb($qr_code); + $form['displaytable']['#markup'] = $page_content; + $commands[] = ajax_command_html("#displaytable", drupal_render($form['displaytable'])); + return array( + '#type' => 'ajax', + '#commands' => $commands + ); +} +function verify_qrcode_fromdb($qr_code) +{ + $query = db_select('textbook_companion_qr_code'); + $query->fields('textbook_companion_qr_code', array( + 'proposal_id' + )); + $query->condition('qr_code', $qr_code); + $result = $query->execute(); + $proposal_id = $result->fetchObject()->proposal_id; + if ($proposal_id) + { + $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(); + $page_content = ""; + $page_content .= "

Participation Details

"; + $page_content .= ""; + $page_content .= ""; + $page_content .= ""; + $page_content .= ""; + $page_content .= ""; + $page_content .= ""; + $page_content .= ""; + $page_content .= "
Name" . $data3->full_name . "
ProjectScilab Textbook Companion
Books completed" . $data2->book . "
Book Author" . $data2->author . "
"; + } //$proposal_id + else + { + $page_content = "Sorry ! The serial number you entered seems to be invalid. Please try again ! "; + } + return $page_content; +} diff --git a/textbook_companion.module b/textbook_companion.module index 3f55940..4310d49 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -642,7 +642,7 @@ function textbook_companion_menu() ), 'file' => 'cheque_contact.inc' ); - $items['certificate'] = array( + $items['certificates'] = array( 'title' => 'List of all Certificates', 'description' => 'List of all Certificates', 'page callback' => '_list_all_certificates', @@ -651,18 +651,27 @@ function textbook_companion_menu() ), 'file' => 'pdf/list_all_certificates.inc' ); - $items['certificate/generate_pdf'] = array( + $items['certificates/generate_pdf'] = array( 'title' => 'Download Certificate', 'description' => 'Download Certificate', 'page callback' => 'drupal_get_form', 'page arguments' => array( 'generate_pdf' ), + 'type' => MENU_NORMAL_ITEM, 'access arguments' => array( 'generate pdf' ), 'file' => 'pdf/generate_pdf.inc' ); + $items["certificates/verify"] = array( + "title" => "Certificate Verification", + "page callback" => "verify_certificates", + "access arguments" => array( + "verify certificates" + ), + 'file' => 'pdf/verify_certificates.inc', + ); /*******************/ $items['Summer_Internship_Forms/forms'] = array( 'title' => 'List of all Copyright Form and Undertaking Form for books', @@ -790,6 +799,10 @@ function textbook_companion_permission() "title" => t("list all certificates"), "description" => t("Allows users to list all certificates.") ), + "verify certificates" => array( + "title" => t("Verify certificates"), + "description" => t("Allows users to verify certificates.") + ), "generate pdf" => array( "title" => t("Generate pdf"), "description" => t("Allows users to Generate pdf.") -- cgit