diff options
author | Sashi20 | 2021-08-10 16:25:28 +0530 |
---|---|---|
committer | GitHub | 2021-08-10 16:25:28 +0530 |
commit | e549abedacf81fecdaf7fe5c2dff95b4fb437cae (patch) | |
tree | e99fa42cd83b454c53501a9539970460c27bd156 /lab_migration.module | |
parent | 21cfc2425884841b69969a6cddccd5201f053808 (diff) | |
parent | 2ea5fde67291c53e48cdd081d4e572defcf6a4cf (diff) | |
download | esim_lab_migration-e549abedacf81fecdaf7fe5c2dff95b4fb437cae.tar.gz esim_lab_migration-e549abedacf81fecdaf7fe5c2dff95b4fb437cae.tar.bz2 esim_lab_migration-e549abedacf81fecdaf7fe5c2dff95b4fb437cae.zip |
Merge pull request #1 from Saketh1499/developement
Certificate generation
Diffstat (limited to 'lab_migration.module')
-rwxr-xr-x | lab_migration.module | 366 |
1 files changed, 364 insertions, 2 deletions
diff --git a/lab_migration.module b/lab_migration.module index 0d37946..63b0362 100755 --- a/lab_migration.module +++ b/lab_migration.module @@ -417,7 +417,7 @@ function lab_migration_menu() 'file' => 'settings.inc', ); /* AJAX REQUEST */ -$items["lab_bulk_manage_exp/ajax"] = array( + $items["lab_bulk_manage_exp/ajax"] = array( "title" => "Ajax callbacks", "page callback" => "lab_bulk_manage_exp_ajax", "access arguments" => array("lab migration bulk manage code"), @@ -431,7 +431,113 @@ $items["lab_bulk_manage_exp/ajax"] = array( "type" => MENU_CALLBACK, 'file' => 'dependency_approval.inc', );*/ - + $items['lab_migration/certificates'] = array( + 'title' => 'List of Lab Migration Certificates', + 'description' => 'List of Lab Migration Certificates', + 'page callback' => '_list_lab_migration_certificates', + 'access arguments' => array( + 'list Lab Migration certificates', + ), + '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', + 'page callback' => 'drupal_get_form', + 'page arguments' => array( + 'generate_pdf', + ), + 'type' => MENU_CALLBACK, + 'access arguments' => array( + 'generate pdf', + ), + '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', + 'page callback'=> '_list_cfd_lab_migration_custom_certificates', + 'access arguments'=> array( + 'list Case Study custom certificates' + ), + 'file'=> 'pdf/list_mentor_certificates.inc' + ); + $items['lab_migration/certificates-custom/pdf'] = array( + 'title'=> 'Download Certificate', + 'description'=> 'Download Certificate', + 'page callback'=> 'drupal_get_form', + 'page arguments'=> array( + 'generate_pdf' + ), + 'type'=> MENU_CALLBACK, + 'access arguments'=> array( + 'generate pdf' + ), + '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", + 'page arguments' => array( + 'verify_certificates', + ), + "access arguments" => array( + "verify certificates", + ), + '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; } @@ -488,6 +594,33 @@ function lab_migration_permission() { 'title' => t('lab migration generate lab'), 'restrict access' => TRUE, ), + "list Lab Migration certificates" => array( + "title" => t("list the certificates"), + "description" => t("list the certificates"), + 'restrict access' => true, + ), + "list Lab Migration custom certificates" => array( + "title" => t("list the mentor certificates"), + "description" => t("list the mentor certificates"), + 'restrict access' => true, + ), + "verify certificates" => array( + "title" => t("verify the certificates"), + "description" => t("verify the certificates"), + 'restrict access' => true, + ), + "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'); } @@ -657,3 +790,232 @@ 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['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, proposal_id,creation_date) VALUES + (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :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']), + ":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['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, + 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']), + ":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 |