summaryrefslogtreecommitdiff
path: root/lab_migration.module
diff options
context:
space:
mode:
Diffstat (limited to 'lab_migration.module')
-rwxr-xr-xlab_migration.module582
1 files changed, 581 insertions, 1 deletions
diff --git a/lab_migration.module b/lab_migration.module
index 43fd315..d3d2235 100755
--- a/lab_migration.module
+++ b/lab_migration.module
@@ -503,6 +503,88 @@ function lab_migration_menu()
"type" => MENU_CALLBACK,
'file' => 'dependency_approval.inc',
);*/
+
+
+
+ /*************** Lab Migration certificates ****************************/
+ $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/certificate/lm-proposer/form'] = array(
+ 'title' => 'Create Certificate',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_certificate_form'
+ ),
+ 'access arguments' => array(
+ 'Create custom Certificate'
+ )
+ );
+ $items['lab-migration/certificate/lm-proposer/form/edit'] = array(
+ 'title' => 'Edit Proposer Certificate',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'lab_migration_certificate_edit_form'
+ ),
+ 'access arguments' => array(
+ 'Create custom Certificate'
+ )
+ );
+ $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/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/verify"] = array(
+ "title" => "Lab Migration Certificate Verification",
+ "page callback" => "verify_lab_migration_certificates",
+ "access arguments" => array(
+ "Verify custom Certificate of lab"
+ ),
+ 'file' => 'pdf/verify_lab_migration_certificates.inc'
+ );
+ $items['lab-migration/download/syllabus-copy-file'] = array(
+ 'title' => 'Syllabus Copy Download',
+ 'description' => 'Syllabus Copy Download',
+ 'page callback' => 'lab_migration_download_syllabus_copy',
+ 'access arguments' => array(
+ 'lab migration bulk manage code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+);
return $items;
}
/**
@@ -558,8 +640,17 @@ function lab_migration_permission()
'lab migration generate lab' => array(
'title' => t('lab migration generate lab'),
'restrict access' => TRUE
- )
+ ),
+ "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');
}
/* AJAX CALLS */
@@ -826,3 +917,492 @@ function _lm_list_of_software_version()
return $directory_name;
}
+ 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)
+ {
+ if ($details->type == "Proposer")
+ {
+ $search_rows[] = array(
+ $details->lab_name,
+ $details->institute_name,
+ $details->name,
+ $details->type,
+ l('Download Certificate', 'lab-migration/certificate/generate-pdf/' . $details->proposal_id . '/' . $details->id),
+ l('Edit Certificate', 'lab-migration/certificate/lm-proposer/form/edit/' . $details->proposal_id . '/' . $details->id)
+ );
+ } //$details->type == "Proposer"
+ else
+ {
+ $search_rows[] = array(
+ $details->lab_name,
+ $details->institute_name,
+ $details->name,
+ $details->type,
+ 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)
+ );
+ }
+ } //$details_list as $details
+ $search_header = array(
+ 'Lab Name',
+ 'Institute name',
+ 'Name',
+ 'Type',
+ 'Download Certificates',
+ 'Edit Certificates'
+ );
+ $output .= theme('table', array(
+ 'header' => $search_header,
+ 'rows' => $search_rows
+ ));
+ return $output;
+ }
+/********** Lab migration certificate form **************/
+function lab_migration_certificate_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 Proposer'),
+ '#maxlength' => 50,
+ '#required' => TRUE
+ );
+ $form['email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 50
+ );
+ $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 - cfd.fossee.in/lab-migration/lab-migration-run/64)',
+ '#required' => TRUE
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+ }
+function lab_migration_certificate_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,type,creation_date) VALUES
+ (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :semester_details,:proposal_id,:type,: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" => trim($v['proposal_id']),
+ ":type" => "Proposer",
+ ":creation_date" => time()
+ );
+ $proposal_id = db_query($result, $args);
+ drupal_goto('lab-migration/certificate');
+ }
+function lab_migration_certificate_edit_form($form, $form_state)
+ {
+ $type = arg(2);
+ $action = arg(4);
+ $proposal_id = arg(5);
+ $certi_id = arg(6);
+ //var_dump($type. "--".$action."--".$proposal_id."--".$certi_id);
+ //die;
+ if ($type == "lm-proposer" && $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();
+ if ($details_list->type == "Proposer")
+ {
+ $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 Proposer'),
+ '#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 it in respective completed labs url -> cfd.fossee.in/lab-migration/lab-migration-run/64 <- this number is the proposal id for respective lab',
+ '#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')
+ );
+ } //$details_list->type == "Proposer"
+ else
+ {
+ $form['err_message'] = array(
+ '#type' => 'item',
+ '#title' => t('Message'),
+ '#markup' => 'Invalid information'
+ );
+ }
+ } //$type == "lm-proposer" && $action == "edit"
+ else
+ {
+ $form['err_message'] = array(
+ '#type' => 'item',
+ '#title' => t('Message'),
+ '#markup' => 'Invalid information'
+ );
+ }
+ return $form;
+ }
+function lab_migration_certificate_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,
+ type=:type,
+ 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']),
+ ":type" => "Proposer",
+ ":creation_date" => time(),
+ ":certi_id" => $v['certi_id']
+ );
+ $proposal_id = db_query($result, $args);
+ drupal_goto('lab-migration/certificate');
+ }
+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 - cfd.fossee.in/lab-migration/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,type,creation_date) VALUES
+ (:uid, :name_title, :name, :email_id, :institute_name, :institute_address, :lab_name, :department, :semester_details,:proposal_id,:type,: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'],
+ ":type" => "Participant",
+ ":creation_date" => time()
+ );
+ $proposal_id = db_query($result, $args);
+ drupal_goto('lab-migration/certificate');
+ }
+function lab_migration_certificate_participation_edit_form($form, $form_state)
+ {
+ $type = arg(2);
+ $action = arg(4);
+ $proposal_id = arg(5);
+ $certi_id = arg(6);
+ if ($type == "lm-participation" && $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();
+ if ($details_list->type == "Participant")
+ {
+ $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 - cfd.fossee.in/lab-migration/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')
+ );
+ } //$details_list->type == "Participant"
+ else
+ {
+ $form['err_message'] = array(
+ '#type' => 'item',
+ '#title' => t('Message'),
+ '#markup' => 'Invalid information'
+ );
+ }
+ } //$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,
+ type=:type,
+ 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']),
+ ":type" => "Participant",
+ ":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