diff options
author | Saketh1499 | 2021-07-28 17:23:32 +0530 |
---|---|---|
committer | Saketh1499 | 2021-07-28 17:23:32 +0530 |
commit | 6be8872ca50144293edc84af7b53c6919442591f (patch) | |
tree | d27434e0eb52d724bf24ac129224ead9bd93a404 | |
parent | 55da020ef0a1ff59309a45ed45f1922eb248d8f9 (diff) | |
download | esim_lab_migration-6be8872ca50144293edc84af7b53c6919442591f.tar.gz esim_lab_migration-6be8872ca50144293edc84af7b53c6919442591f.tar.bz2 esim_lab_migration-6be8872ca50144293edc84af7b53c6919442591f.zip |
Certificate generation
-rwxr-xr-x | lab_migration.module | 302 | ||||
-rwxr-xr-x | pdf/cert_new.inc | 40 | ||||
-rw-r--r-- | pdf/generate_pdf.inc | 184 | ||||
-rwxr-xr-x | pdf/verify_lab_migration_certificates.inc | 102 |
4 files changed, 611 insertions, 17 deletions
diff --git a/lab_migration.module b/lab_migration.module index 050f44a..134cb89 100755 --- a/lab_migration.module +++ b/lab_migration.module @@ -440,6 +440,14 @@ function lab_migration_menu() ), 'file' => 'pdf/list_lab_migration_certificate.inc', ); + $items['lab_migration/certificate'] = array( + 'title' => 'List Of All Certificates LM', + 'description' => 'List of all available lab migration certificates', + 'page callback' => '_list_all_lm_certificates', + 'access arguments' => array( + 'Create custom Certificate' + ) + ); $items['lab_migration/certificates/generate-pdf'] = array( 'title' => 'Download Certificate', 'description' => 'Download Certificate', @@ -453,6 +461,18 @@ function lab_migration_menu() ), 'file' => 'pdf/cert_new.inc', ); + $items['lab_migration/certificate/generate-pdf'] = array( + 'title' => 'Download Certificate', + 'description' => 'Download Certificate', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'generate_lm_pdf' + ), + 'access arguments' => array( + 'Create custom Certificate' + ), + 'file' => 'pdf/generate_pdf.inc' + ); /*$items['lab_migration/certificates-custom'] = array( 'title'=> 'List of Case Study Custom Certificates', 'description'=> 'List of Case Study Custom Certificates', @@ -475,6 +495,26 @@ function lab_migration_menu() ), 'file'=> 'pdf/mentor_cert_pdf.inc' ); */ + $items['lab_migration/certificate/lm-participation/form'] = array( + 'title' => 'Create Certificates for Participation', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'lab_migration_certificate_participation_form' + ), + 'access arguments' => array( + 'Create custom Certificate' + ) + ); + $items['lab_migration/certificate/lm-participation/form/edit'] = array( + 'title' => 'Edit Certificates for Participation', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'lab_migration_certificate_participation_edit_form' + ), + 'access arguments' => array( + 'Create custom Certificate' + ) + ); $items['lab_migration/certificates/verify'] = array( "title" => "Certificate Verification", "page callback" => "verify_certificates", @@ -487,7 +527,17 @@ function lab_migration_menu() 'type' => MENU_CALLBACK, 'file' => 'pdf/verify_certificates.inc', ); - + $items["lab_migration/certificate/verify"] = array( + "title" => "Lab Migration Certificate Verification", + "page callback" => "verify_lab_migration_certificates", + 'page arguments' => array( + 'verify_lab_migration_certificates', + ), + "access arguments" => array( + "Verify custom Certificate of lab" + ), + 'file' => 'pdf/verify_lab_migration_certificates.inc' + ); return $items; } @@ -562,6 +612,14 @@ function lab_migration_permission() { "generate pdf" => array( "title" => t("Generate pdf"), "description" => t("Allows users to Generate pdf.") + ), + "Create custom Certificate" => array( + "title" => t("create custom certificate "), + "description" => t("Create custom Certificate") + ), + "Verify custom Certificate of lab" => array( + "title" => t("Verify custom Certificate of lab"), + "description" => t("Verify custom Certificate of lab") ) ); // return array('lab migration create proposal', 'lab migration manage proposal', 'lab migration edit proposal', 'lab migration approve proposal', 'lab migration propose solution', 'lab migration approve code', 'lab migration bulk manage code', 'lab migration bulk delete code', 'lab migration upload code', 'lab migration download code', 'administer lab migration', 'lab migration generate lab'); @@ -732,3 +790,245 @@ function lab_migration_get_category_name($category_id) { drupal_add_js(drupal_get_path('module', 'lab_migration') . '/js/lab_migration_ajax.js', array ('scope' => 'footer')); }*/ + + +/***************** Functions for certificates ************************/ + +function _list_all_lm_certificates() + { + $query = db_query("SELECT * FROM lab_migration_certificate"); + $search_rows = array(); + $output = ''; + $details_list = $query->fetchAll(); + foreach ($details_list as $details) + { + $search_rows[] = array( + $details->lab_name, + $details->institute_name, + $details->name, + l('Download Certificate', 'lab_migration/certificate/generate-pdf/' . $details->proposal_id . '/' . $details->id), + l('Edit Certificate', 'lab_migration/certificate/lm-participation/form/edit/' . $details->proposal_id . '/' . $details->id) + ); + + } + $search_header = array( + 'Lab Name', + 'Institute name', + 'Name', + 'Download Certificates', + 'Edit Certificates' + ); + $output .= theme('table', array( + 'header' => $search_header, + 'rows' => $search_rows + )); + return $output; + } + + +function lab_migration_certificate_participation_form($form, $form_state) + { + $form['name_title'] = array( + '#type' => 'select', + '#title' => t('Title'), + '#options' => array( + 'Dr.' => 'Dr.', + 'Prof.' => 'Prof.', + 'Mr.' => 'Mr.', + 'Mrs.' => 'Mrs.', + 'Ms.' => 'Ms.' + ), + '#required' => TRUE + ); + $form['name'] = array( + '#type' => 'textfield', + '#title' => t('Name of Participant'), + '#maxlength' => 50, + '#required' => TRUE + ); + $form['email_id'] = array( + '#type' => 'textfield', + '#title' => t('Email'), + '#size' => 50, + '#default_value' => 'Not availbale' + ); + $form['institute_name'] = array( + '#type' => 'textfield', + '#title' => t('Collage / Institue Name'), + '#required' => TRUE + ); + $form['institute_address'] = array( + '#type' => 'textfield', + '#title' => t('Collage / Institue address'), + '#required' => TRUE + ); + $form['lab_name'] = array( + '#type' => 'textfield', + '#title' => t('Lab name'), + '#required' => TRUE + ); + $form['department'] = array( + '#type' => 'textfield', + '#title' => t('Department'), + '#required' => TRUE + ); + $form['semester_details'] = array( + '#type' => 'textfield', + '#title' => t('Semester details'), + '#required' => TRUE + ); + $form['proposal_id'] = array( + '#type' => 'textfield', + '#title' => t('Lab Proposal Id'), + '#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - scilab.in/lab_migration_run/64)', + '#required' => TRUE + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + return $form; + } +function lab_migration_certificate_participation_form_submit($form, &$form_state) + { + global $user; + $v = $form_state["values"]; + $result = "INSERT INTO {lab_migration_certificate} + (uid, name_title, name, email_id, institute_name, institute_address, lab_name, department, semester_details,proposal_id,creation_date) VALUES + (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :semester_details,:proposal_id,:creation_date)"; + $args = array( + ":uid" => $user->uid, + ":name_title" => trim($v['name_title']), + ":name" => trim($v['name']), + ":email_id" => trim($v['email_id']), + ":institute_name" => trim($v['institute_name']), + ":institute_address" => trim($v['institute_address']), + ":lab_name" => trim($v['lab_name']), + ":department" => trim($v['department']), + ":semester_details" => trim($v['semester_details']), + ":proposal_id" => $v['proposal_id'], + ":creation_date" => time() + ); + $proposal_id = db_query($result, $args); + drupal_goto('lab_migration/certificate'); + } +function lab_migration_certificate_participation_edit_form($form, $form_state) + { + $action = arg(4); + $proposal_id = arg(5); + $certi_id = arg(6); + if ($action == "edit") + { + $query = db_query("SELECT * FROM lab_migration_certificate WHERE proposal_id=:prop_id AND id=:certi_id", array( + ":prop_id" => $proposal_id, + ":certi_id" => $certi_id + )); + $details_list = $query->fetchobject(); + $form['name_title'] = array( + '#type' => 'select', + '#title' => t('Title'), + '#options' => array( + 'Dr.' => 'Dr.', + 'Prof.' => 'Prof.', + 'Mr.' => 'Mr.', + 'Mrs.' => 'Mrs.', + 'Ms.'=> 'Ms.' + ), + '#default_value' => $details_list->name_title + ); + $form['name'] = array( + '#type' => 'textfield', + '#title' => t('Name of Participant'), + '#maxlength' => 50, + '#default_value' => $details_list->name + ); + $form['email_id'] = array( + '#type' => 'textfield', + '#title' => t('Email'), + '#size' => 50, + '#default_value' => $details_list->email_id + ); + $form['institute_name'] = array( + '#type' => 'textfield', + '#title' => t('Collage / Institue Name'), + '#default_value' => $details_list->institute_name + ); + $form['institute_address'] = array( + '#type' => 'textfield', + '#title' => t('Collage / Institue address'), + '#default_value' => $details_list->institute_address + ); + $form['lab_name'] = array( + '#type' => 'textfield', + '#title' => t('Lab name'), + '#default_value' => $details_list->lab_name + ); + $form['department'] = array( + '#type' => 'textfield', + '#title' => t('Department'), + '#default_value' => $details_list->department + ); + $form['semester_details'] = array( + '#type' => 'textfield', + '#title' => t('Semester details'), + '#default_value' => $details_list->semester_details + ); + $form['proposal_id'] = array( + '#type' => 'textfield', + '#title' => t('Lab Proposal Id'), + '#description' => 'Note: You can find the respective Lab Proposal Id from the url for the completed lab. For example: The Lab Proposal Id is 64 for this completed lab. ( Url - scilab.in/lab_migration_run/64)', + '#default_value' => $details_list->proposal_id + ); + $form['certi_id'] = array( + '#type' => 'hidden', + '#default_value' => $details_list->id + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit') + ); + } //$type == "lm_participation" && $action == "edit" + else + { + $form['err_message'] = array( + '#type' => 'item', + '#title' => t('Message'), + '#markup' => 'Invalid information' + ); + } + return $form; + } +function lab_migration_certificate_participation_edit_form_submit($form, &$form_state) + { + global $user; + $v = $form_state["values"]; + $result = "UPDATE lab_migration_certificate SET + uid=:uid, + name_title=:name_title, + name=:name, + email_id=:email_id, + institute_name=:institute_name, + institute_address=:institute_address, + lab_name=:lab_name, + department=:department, + semester_details=:semester_details, + proposal_id=:proposal_id, + creation_date=:creation_date + WHERE id=:certi_id"; + $args = array( + ":uid" => $user->uid, + ":name_title" => trim($v['name_title']), + ":name" => trim($v['name']), + ":email_id" => trim($v['email_id']), + ":institute_name" => trim($v['institute_name']), + ":institute_address" => trim($v['institute_address']), + ":lab_name" => trim($v['lab_name']), + ":department" => trim($v['department']), + ":semester_details" => trim($v['semester_details']), + ":proposal_id" => trim($v['proposal_id']), + ":creation_date" => time(), + ":certi_id" => $v['certi_id'] + ); + $proposal_id = db_query($result, $args); + drupal_goto('lab_migration/certificate'); + }
\ No newline at end of file diff --git a/pdf/cert_new.inc b/pdf/cert_new.inc index 2556d87..911b122 100755 --- a/pdf/cert_new.inc +++ b/pdf/cert_new.inc @@ -62,47 +62,55 @@ function generate_pdf() //$pdf->SetTextColor(139, 69, 19); //$pdf->Cell(240, 8, 'Certificate of Participation', '0', 1, 'C'); //$pdf->Ln(26); - $pdf->SetFont('Times', 'I', 16); + $pdf->SetFont('Times', 'I', 14); $pdf->SetTextColor(0, 0, 0); - $pdf->Cell(320, 10, 'This is to certify that', '0', '1', 'C'); - $pdf->Ln(-4); - $pdf->SetFont('Times', 'I', 20); + $pdf->Cell(320, 10, 'This is to certify that under the supervision/guidance of ', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 15); //$pdf->SetFont('Arial', 'BI', 25); $pdf->SetTextColor(129, 80, 47); - $pdf->Cell(320, 12, $data3->name, '0', '1', 'C'); + $pdf->Cell(320, 12, $data3->name_title . ' ' . $data3->name, '0', '1', 'C'); $pdf->Ln(0); - $pdf->SetFont('Times', 'I', 16); + $pdf->SetFont('Times', 'I', 14); if (strtolower($data3->branch) != "others") { + $pdf->SetFont('Times', 'I', 14); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell(320, 8, 'from the Department of ' . $data3->department . ', ', '0', '1', 'C'); + $pdf->Ln(0); $pdf->SetTextColor(0, 0, 0); //$pdf->Cell(240, 8, 'from ' . $data3->university . ' has successfully', '0', '1', 'C'); - $pdf->MultiCell(320, 8, 'from ' . $data3->university, '0','C'); + $pdf->MultiCell(320, 8, $data3->university, '0','C'); $pdf->Ln(0); - $pdf->Cell(320, 8, 'has successfully completed the Lab Migration of', '0', '1', 'C'); + $pdf->Cell(320, 8, 'has successfully migrated the ', '0', '1', 'C'); $pdf->Ln(0); //$pdf->Cell(240, 8, 'He/she has simulated a circuit titled ', '0', '1', 'C'); //$pdf->Ln(0); $pdf->SetTextColor(129, 80, 47); - $pdf->SetFont('Times','I',15); + $pdf->SetFont('Times','I',14); $pdf->Cell(320, 12, $data3->lab_title, '0', '1', 'C'); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(0); //$txt= $pdf->WriteHTML("<span>under</span>"); - $pdf->SetFont('Times', 'I', 16); - $pdf->Cell(320, 8, 'under eSim Lab Migration Project', '0', '1', 'C'); + $pdf->SetFont('Times', 'I', 14); + $pdf->Cell(320, 8, 'to a eSim-only Lab', '0', '1', 'C'); $pdf->Ln(0); } //strtolower($data3->branch) != "others" else { + $pdf->SetFont('Times', 'I', 14); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell(320, 12, 'from the Department of ' . $data3->department . ', ', '0', '1', 'C'); + $pdf->Ln(0); $pdf->SetTextColor(0, 0, 0); - $pdf->Cell(240, 8, 'from ' . $data3->university . ' college', '0', '1', 'C'); + $pdf->Cell(240, 8, $data3->university . ' college', '0', '1', 'C'); $pdf->Ln(0); - $pdf->Cell(240, 8, 'has successfully completed the Lab Migration of', '0', '1', 'C'); + $pdf->Cell(240, 8, 'has successfully migrated the', '0', '1', 'C'); $pdf->Ln(0); - $pdf->SetTextColor(139, 69, 19); + $pdf->SetTextColor(139, 69, 16); $pdf->Cell(320, 12, $data3->lab_title, '0', '1', 'C'); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(0); - $pdf->SetFont('Times', '', 16); - $pdf->Cell(320, 8, ' under eSim Lab Migration Project', '0', '1', 'C'); + $pdf->SetFont('Times', '', 14); + $pdf->Cell(320, 8, 'to a eSim-only Lab', '0', '1', 'C'); //$pdf->Cell(240, 8, 'He/she has coded ' . $number_of_example . ' solved examples using DWSIM from the', '0', '1', 'C'); //$pdf->Ln(0); //$pdf->Cell(240, 8, 'Book: ' . $data2->book . ', Author: ' . $data2->author . '.', '0', '1', 'C'); diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc new file mode 100644 index 0000000..ed2cbfc --- /dev/null +++ b/pdf/generate_pdf.inc @@ -0,0 +1,184 @@ +<?php +function generate_lm_pdf() + { + $mpath = drupal_get_path('module', 'lab_migration'); + //var_dump($mpath);die; + require($mpath . '/pdf/fpdf/fpdf.php'); + require($mpath . '/pdf/phpqrcode/qrlib.php'); + global $user; + $x = $user->uid; + $proposal_id = arg(3); // proposal id of lab + $lab_certi_id = arg(4); + if ($proposal_id != NULL && $lab_certi_id != NULL) + { + $query3 = db_query("SELECT * FROM lab_migration_certificate WHERE proposal_id= :prop_id AND id=:certi_id", array( + ':prop_id' => $proposal_id, + ":certi_id" => $lab_certi_id + )); + $data3 = $query3->fetchObject(); + $pdf = new FPDF('L', 'mm', 'Letter'); + if (!$pdf) + { + echo "Error!"; + } //!$pdf + $pdf->AddPage(); + $image_bg = $mpath . "/pdf/images/bg_cert.png"; + $pdf->Image($image_bg, 0, 0, $pdf->GetPageWidth(), $pdf->GetPageHeight()); + //$pdf->Rect(5, 5, 267, 207, 'D'); //For A4 + $pdf->SetMargins(18, 1, 18); + //$pdf->Line(7.0, 7.0, 270.0, 7.0); + //$pdf->Line(7.0, 7.0, 7.0, 210.0); + //$pdf->Line(270.0, 210.0, 270.0, 7.0); + //$pdf->Line(7.0, 210.0, 270.0, 210.0); + $path = drupal_get_path('module', 'lab_migration'); + //$image1 = $mpath . "/pdf/images/scilab.png"; + $pdf->Ln(30); + //$pdf->Cell(200, 8, $pdf->Image($image1, 100, 19, 0, 28), 0, 1, 'C'); + /*$pdf->SetFont('Times', 'BI', 25); + $pdf->SetTextColor(139, 69, 19); + $pdf->Cell(240, 8, 'Certificate of Participation', '0', 1, 'C'); + $pdf->Ln(3);*/ + $pdf->SetFont('Times', 'BI', 14); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell(320, 8, 'This is to certify that', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 16); + $pdf->SetTextColor(139, 69, 19); + $pdf->Cell(320, 12, $data3->name_title . ' ' . $data3->name, '0', 1, 'C'); + $pdf->Ln(0); + $pdf->SetFont('Times', 'I', 14); + $pdf->SetTextColor(0, 0, 0); + $pdf->Cell(320, 12, 'from the Department of ' . $data3->department . ', ', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(320, 8, $data3->institute_name . ', ' . $data3->institute_address, '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(320, 8, ' has developed the solutions in eSim for the ', '0', '1', 'C'); + $pdf->Ln(0); + $pdf->Cell(320, 12, $data3->lab_name . ' (' . $data3->semester_details . ').', '0', '1', 'C'); + $pdf->Cell(320, 5, '', '0', '1', 'C'); + $pdf->SetX(125); + $pdf->SetTextColor(0, 0, 0); + $pdf->write(0, 'The work done is available at '); + $pdf->SetFont('Times', 'U' , '14'); + $pdf->SetTextColor(139, 69, 19); + $pdf->write(0, 'https://esim.fossee.in/', 'https://esim.fossee.in/'); + $pdf->SetFont('', ''); + $pdf->SetTextColor(0, 0, 0); + $pdf->write(0, '.', '.'); + //$proposal_get_id=0; + $UniqueString = ""; + $tempDir = $path . "/pdf/temp_prcode/"; + //$UniqueString=generateRandomString(); + $query = db_select('lab_migration_certificate_qr_code'); + $query->fields('lab_migration_certificate_qr_code', array( + 'qr_code', + 'certificate_id' + )); + //$query->condition('qr_code', $UniqueString); + $query->condition('proposal_id', $proposal_id); + $query->condition('certificate_id', $lab_certi_id); + $result = $query->execute(); + $data = $result->fetchObject(); + $DBString = $data->qr_code; + //$proposal_get_id=$data->proposal_id; + if ($DBString == "" || $DBString == "null") + { + $UniqueString = generateRandomString(); + $query = " + INSERT INTO lab_migration_certificate_qr_code + (proposal_id,qr_code,certificate_id,gen_date) + VALUES + (:proposal_id,:qr_code,:certificate_id,:gen_date) + "; + $args = array( + ":proposal_id" => $proposal_id, // id is not the proposal id its lab migration certificate table id + ":qr_code" => $UniqueString, + ":certificate_id" => $lab_certi_id, + ":gen_date" => time() + ); + /* storing the row id in $result */ + $result = db_query($query, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); + } //$DBString == "" || $DBString == "null" + else + { + $UniqueString = $DBString; + } + $codeContents = "https://esim.fossee.in/lab-migration/certificates/verify/" . $UniqueString; + $fileName = 'generated_qrcode.png'; + $pngAbsoluteFilePath = $tempDir . $fileName; + $urlRelativeFilePath = $path . "/pdf/temp_prcode/" . $fileName; + QRcode::png($codeContents, $pngAbsoluteFilePath); + $pdf->SetY(85); + $pdf->SetX(320); + $pdf->Ln(10); + $sign1 = $path . "/pdf/images/sign1.png"; + //$sign2 = $path . "/pdf/images/sign2.png"; + $pdf->Image($sign1, $pdf->GetX()+110, $pdf->GetY() + 40, 85, 0); + //$pdf->Image($sign2, $pdf->GetX()+160, $pdf->GetY() + 45, 85, 0); + $pdf->Image($pngAbsoluteFilePath, $pdf->GetX()+15, $pdf->GetY()+70, 30, 0); + $fossee = $path . "/pdf/images/fossee.png"; + $moe = $path . "/pdf/images/moe.png"; + $pdf->Image($fossee, $pdf->GetX()+80, $pdf->GetY()+80, 50, 0); + $pdf->Image($moe, $pdf->GetX()+180, $pdf->GetY()+80, 40, 0); + //$pdf->SetX(29); + //$pdf->SetY(-50); + $pdf->Ln(2); + $ftr_line = $path . "/pdf/images/bottom_line.png"; + $pdf->Image($ftr_line, $pdf->GetX()+50, $pdf->GetY()+102, 150, 0); + $pdf->SetFont('Times', 'I', 14); + $pdf->SetLeftMargin(40); + $pdf->GetY()+60; + $pdf->Ln(62); + $pdf->Cell(320, 8, $UniqueString, '0', '1', 'L'); + //$pdf->Ln(6); + $pdf->SetFont('Arial', 'I', 14); + $pdf->SetTextColor(0, 0, 0); + $filename = str_replace(' ', '-', $data3->name) . '-eSim-Lab-migration-Participation-Certificate.pdf'; + $file = $path . '/pdf/temp_certificate/' . $proposal_id . '_' . $filename; + $pdf->Output($file, 'F'); + ob_clean(); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header("Content-Type: application/pdf"); + header("Content-Disposition: attachment; filename=" . $filename); + header("Content-Length: " . filesize($file)); + header("Content-Transfer-Encoding: binary"); + header("Expires: 0"); + header("Pragma: no-cache"); + flush(); + $fp = fopen($file, "r"); + while (!feof($fp)) { + echo fread($fp, filesize($file)); + flush(); + } //!feof($fp) + ob_end_flush(); + ob_clean(); + fclose($fp); + unlink($file); + //drupal_goto('flowsheeting-project/certificate'); + return; + //$data3->type = 'Proposer' + } + else + { + drupal_set_message('Your lab Is Still Under Review.', 'status'); + } + } +function generateRandomString($length = 5) + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) + { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } //$i = 0; $i < $length; $i++ + return $randomString; + } + + diff --git a/pdf/verify_lab_migration_certificates.inc b/pdf/verify_lab_migration_certificates.inc new file mode 100755 index 0000000..8aaeb19 --- /dev/null +++ b/pdf/verify_lab_migration_certificates.inc @@ -0,0 +1,102 @@ +<?php +function verify_lab_migration_certificates($qr_code = 0) + { + $qr_code = arg(3); + $page_content = ""; + if ($qr_code) + { + $page_content = verify_qrcode_lm_fromdb($qr_code); + } //$qr_code + else + { + $verify_certificates_form = drupal_get_form("verify_lab_migration_certificates_form"); + $page_content = drupal_render($verify_certificates_form); + } + return $page_content; + } +function verify_lab_migration_certificates_form($form, &$form_state) + { + $form = array(); + $form['Title'] = array( + '#type' => '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_lab_migration_certificates_form_submit', + 'progress' => array( + 'message' => '' + ) + ) + ); + $form['displaytable'] = array( + '#type' => 'markup', + '#prefix' => '<div><div id="displaytable" style="font-weight:bold;padding-top:10px">', + '#suffix' => '</div></div>', + '#markup' => '' + ); + return $form; + } +function verify_lab_migration_certificates_form_submit($form, &$form_state) + { + $page_content = ""; + $v = $form_state["values"]; + $qr_code = $v["QR_code"]; + $page_content = verify_qrcode_lm_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_lm_fromdb($qr_code) + { + $query = db_select('lab_migration_certificate_qr_code'); + $query->fields('lab_migration_certificate_qr_code'); + $query->condition('qr_code', $qr_code); + $result = $query->execute()->fetchObject(); + $proposal_id = $result->proposal_id; + $certificate_id = $result->certificate_id; + if ($proposal_id) + { + $query2 = db_query("SELECT * FROM {lab_migration_certificate} WHERE proposal_id= :prop_id AND id=:certificate_id", array( + ':prop_id' => $proposal_id, + ':certificate_id' => $certificate_id + )); + $data2 = $query2->fetchObject(); + $page_content = ""; + $page_content .= "<h4>Participation Details</h4><table>"; + //$page_content.="<tr><td>Name</td>"; + //$page_content.="<td>".$data2->name_title. ' '.$data2->name."</td></tr>"; + $page_content .= "<tr><td>Project</td>"; + $page_content .= "<td>eSim Lab Migration Project</td></tr>"; + $page_content .= "<tr><td>Contributed to complete the lab</td>"; + $page_content .= "<td>" . $data2->lab_name . "</td></tr>"; + $page_content .= "<tr><td>Participant</td>"; + $page_content .= "<td>" . $data2->name_title . " " . $data2->name . "</td></tr>"; + $page_content .= "<tr><td>Department</td>"; + $page_content .= "<td>" . $data2->department . "</td></tr>"; + $page_content .= "<tr><td>Semester Details</td>"; + $page_content .= "<td>" . $data2->semester_details . "</td></tr>"; + $page_content .= "<tr><td>Institute Name</td>"; + $page_content .= "<td>" . $data2->institute_name . "</td></tr>"; + $page_content .= "<tr><td>Institute Address</td>"; + $page_content .= "<td>" . $data2->institute_address . "</td></tr>"; + $page_content .= "</table>"; + + } + else + { + $page_content = "<b>Sorry ! The serial number you entered seems to be invalid. Please try again ! <b>"; + } //$proposal_id + return $page_content; + } |