From 4890fb2cd79ac1f5be60e10a69ca201659a2fa88 Mon Sep 17 00:00:00 2001
From: Sashi20
Date: Tue, 9 Apr 2019 17:55:49 +0530
Subject: Add interface for flowsheeting project
---
README | 6 +
README.md | 1 -
abstract_approval.inc | 387 ++++++++++++++++
abstract_bulk_approval.inc | 444 ++++++++++++++++++
download.inc | 270 +++++++++++
email.inc | 494 ++++++++++++++++++++
flowsheet_details.inc | 91 ++++
full_download.inc | 123 +++++
general_deletion.inc | 71 +++
manage_proposal.inc | 1090 ++++++++++++++++++++++++++++++++++++++++++++
om_flowsheet.info | 7 +
om_flowsheet.module | 974 +++++++++++++++++++++++++++++++++++++++
proposal.inc | 622 +++++++++++++++++++++++++
run.inc | 144 ++++++
settings.inc | 98 ++++
upload_code.inc | 699 ++++++++++++++++++++++++++++
16 files changed, 5520 insertions(+), 1 deletion(-)
create mode 100755 README
delete mode 100644 README.md
create mode 100755 abstract_approval.inc
create mode 100755 abstract_bulk_approval.inc
create mode 100755 download.inc
create mode 100755 email.inc
create mode 100755 flowsheet_details.inc
create mode 100755 full_download.inc
create mode 100755 general_deletion.inc
create mode 100755 manage_proposal.inc
create mode 100755 om_flowsheet.info
create mode 100755 om_flowsheet.module
create mode 100755 proposal.inc
create mode 100755 run.inc
create mode 100755 settings.inc
create mode 100755 upload_code.inc
diff --git a/README b/README
new file mode 100755
index 0000000..f686895
--- /dev/null
+++ b/README
@@ -0,0 +1,6 @@
+OpenModelica Flowsheet Module for FOSSEE, IIT Bombay written for Drupal 7
+
+Author:
+
+BMK SASHI REKHA
+
diff --git a/README.md b/README.md
deleted file mode 100644
index 082fd5c..0000000
--- a/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# om_flowsheet
\ No newline at end of file
diff --git a/abstract_approval.inc b/abstract_approval.inc
new file mode 100755
index 0000000..9c4a592
--- /dev/null
+++ b/abstract_approval.inc
@@ -0,0 +1,387 @@
+fields('lab_migration_solution');
+ $query->condition('approval_status', 0);
+ $pending_solution_q = $query->execute();
+ if (!$pending_solution_q)
+ {
+ drupal_set_message(t('There are no pending code approvals.'), 'status');
+ return '';
+ }
+ $pending_solution_rows = array();
+ while ($pending_solution_data = $pending_solution_q->fetchObject())
+ {
+ /* get experiment data */
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $pending_solution_data->experiment_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $pending_solution_data->experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ /* get proposal data */
+ // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $experiment_data->proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $experiment_data->proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ /* get solution provider details */
+ $solution_provider_user_name = '';
+ $user_data = user_load($proposal_data->solution_provider_uid);
+ if ($user_data)
+ {
+ $solution_provider_user_name = $user_data->name;
+ }
+ else
+ {
+ $solution_provider_user_name = '';
+ }
+ /* setting table row information */
+ $pending_solution_rows[] = array(
+ $proposal_data->lab_title,
+ $experiment_data->title,
+ $proposal_data->name,
+ $solution_provider_user_name,
+ l('Edit', 'lab-migration/code-approval/approve/' . $pending_solution_data->id)
+ );
+ }
+ /* check if there are any pending solutions */
+ if (!$pending_solution_rows)
+ {
+ drupal_set_message(t('There are no pending solutions'), 'status');
+ return '';
+ }
+ $header = array(
+ 'Title of the Lab',
+ 'Experiment',
+ 'Proposer',
+ 'Solution Provider',
+ 'Actions'
+ );
+ //$output = theme_table($header, $pending_solution_rows);
+ $output = theme('table', array(
+ 'header' => $header,
+ 'rows' => $pending_solution_rows
+ ));
+ return $output;
+ }
+function om_flowsheet_abstract_approval_form($form, &$form_state)
+ {
+ $solution_id = (int) arg(3);
+ /* get solution details */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $solution_id);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ if (!$solution_data)
+ {
+ drupal_set_message(t('Invalid solution selected.'), 'status');
+ drupal_goto('lab-migration/code-approval');
+ }
+ if ($solution_data->approval_status == 1)
+ {
+ drupal_set_message(t('This solution has already been approved. Are you sure you want to change the approval status?'), 'error');
+ }
+ if ($solution_data->approval_status == 2)
+ {
+ drupal_set_message(t('This solution has already been dis-approved. Are you sure you want to change the approval status?'), 'error');
+ }
+ /* get experiment data */
+ //xperiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $solution_data->experiment_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ /* get proposal data */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $experiment_data->proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $experiment_data->proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ /* get solution provider details */
+ $solution_provider_user_name = '';
+ $user_data = user_load($proposal_data->solution_provider_uid);
+ if ($user_data)
+ {
+ $solution_provider_user_name = $user_data->name;
+ }
+ else
+ {
+ $solution_provider_user_name = '';
+ }
+ $form['#tree'] = TRUE;
+ $form['lab_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->lab_title,
+ '#title' => t('Title of the Lab')
+ );
+ $form['name'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->name,
+ '#title' => t('Contributor Name')
+ );
+ $form['experiment']['number'] = array(
+ '#type' => 'item',
+ '#markup' => $experiment_data->number,
+ '#title' => t('Experiment Number')
+ );
+ $form['experiment']['title'] = array(
+ '#type' => 'item',
+ '#markup' => $experiment_data->title,
+ '#title' => t('Title of the Experiment')
+ );
+ $form['back_to_list'] = array(
+ '#type' => 'item',
+ '#markup' => l('Back to Code Approval List', 'lab-migration/code-approval')
+ );
+ $form['code_number'] = array(
+ '#type' => 'item',
+ '#markup' => $solution_data->code_number,
+ '#title' => t('Code No')
+ );
+ $form['code_caption'] = array(
+ '#type' => 'item',
+ '#markup' => $solution_data->caption,
+ '#title' => t('Caption')
+ );
+ /* get solution files */
+ $solution_files_html = '';
+ //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d ORDER BY id ASC", $solution_id);
+ $query = db_select('lab_migration_solution_files');
+ $query->fields('lab_migration_solution_files');
+ $query->condition('solution_id', $solution_id);
+ $query->orderBy('id', 'ASC');
+ $solution_files_q = $query->execute();
+ if ($solution_files_q)
+ {
+ while ($solution_files_data = $solution_files_q->fetchObject())
+ {
+ $code_file_type = '';
+ switch ($solution_files_data->filetype)
+ {
+ case 'S':
+ $code_file_type = 'Source';
+ break;
+ case 'R':
+ $code_file_type = 'Result';
+ break;
+ case 'X':
+ $code_file_type = 'Xcox';
+ break;
+ case 'U':
+ $code_file_type = 'Unknown';
+ break;
+ default:
+ $code_file_type = 'Unknown';
+ break;
+ }
+ $solution_files_html .= l($solution_files_data->filename, 'lab-migration/download/file/' . $solution_files_data->id) . ' (' . $code_file_type . ')' . '
';
+ /*if(strlen($solution_files_data->pdfpath)>=5){
+ $pdfname=substr($solution_files_data->pdfpath, strrpos($solution_files_data->pdfpath, '/') + 1);
+ $solution_files_html .=l($pdfname, 'lab-migration/download/pdf/' . $solution_files_data->id). ' (PDF File)' . '
';
+ }*/
+ }
+ }
+ /* get dependencies files */
+ //$dependency_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d ORDER BY id ASC", $solution_id);
+ $query = db_select('lab_migration_solution_dependency');
+ $query->fields('lab_migration_solution_dependency');
+ $query->condition('solution_id', $solution_id);
+ $query->orderBy('id', 'ASC');
+ $dependency_q = $query->execute();
+ while ($dependency_data = $dependency_q->fetchObject())
+ {
+ //$dependency_files_q = db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d", $dependency_data->dependency_id);
+ $query = db_select('lab_migration_dependency_files');
+ $query->fields('lab_migration_dependency_files');
+ $query->condition('id', $dependency_data->dependency_id);
+ $dependency_files_q = $query->execute();
+ $dependency_files_data = $dependency_files_q->fetchObject();
+ $solution_file_type = 'Dependency file';
+ $solution_files_html .= l($dependency_files_data->filename, 'lab-migration/download/dependency/' . $dependency_files_data->id) . ' (' . 'Dependency' . ')' . '
';
+ }
+ $form['solution_files'] = array(
+ '#type' => 'item',
+ '#markup' => $solution_files_html,
+ '#title' => t('Solution')
+ );
+ $form['approved'] = array(
+ '#type' => 'radios',
+ '#options' => array(
+ '0' => 'Pending',
+ '1' => 'Approved',
+ '2' => 'Dis-approved (Solution will be deleted)'
+ ),
+ '#title' => t('Approval'),
+ '#default_value' => $solution_data->approval_status
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for dis-approval'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approved"]' => array(
+ 'value' => '2'
+ )
+ ),
+ 'required' => array(
+ ':input[name="approved"]' => array(
+ 'value' => '2'
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#markup' => l(t('Cancel'), 'lab_migration/code_approval')
+ );
+ return $form;
+ }
+function om_flowsheet_abstract_approval_form_validate($form, &$form_state)
+ {
+ if ($form_state['values']['approved'] == 2)
+ {
+ if (strlen(trim($form_state['values']['message'])) <= 30)
+ {
+ form_set_error('message', t('Please mention the reason for disapproval.'));
+ }
+ }
+ return;
+ }
+function om_flowsheet_abstract_approval_form_submit($form, &$form_state)
+ {
+ global $user;
+ $solution_id = (int) arg(3);
+ /* get solution details */
+ //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d", $solution_id);
+ $query = db_select('lab_migration_solution');
+ $query->fields('lab_migration_solution');
+ $query->condition('id', $solution_id);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ if (!$solution_data)
+ {
+ drupal_set_message(t('Invalid solution selected.'), 'status');
+ drupal_goto('lab_migration/code_approval');
+ }
+ /* get experiment data */
+ //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $solution_data->experiment_id);
+ $query = db_select('lab_migration_experiment');
+ $query->fields('lab_migration_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ /* get proposal data */
+ //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $experiment_data->proposal_id);
+ $query = db_select('lab_migration_proposal');
+ $query->fields('lab_migration_proposal');
+ $query->condition('id', $experiment_data->proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ $user_data = user_load($proposal_data->uid);
+ $solution_prove_user_data = user_load($proposal_data->solution_provider_uid);
+ // **** TODO **** : del_lab_pdf($proposal_data->id);
+ if ($form_state['values']['approved'] == "0")
+ {
+ $query = "UPDATE {lab_migration_solution} SET approval_status = 0, approver_uid = :approver_uid, approval_date = :approval_date WHERE id = :solution_id";
+ $args = array(
+ ":approver_uid" => $user->uid,
+ ":approval_date" => time(),
+ ":solution_id" => $solution_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_pending']['solution_id'] = $solution_id;
+ $param['solution_pending']['user_id'] = $user_data->uid;
+ $param['solution_pending']['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
+ );
+ if (!drupal_mail('lab_migration', 'solution_pending', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ else if ($form_state['values']['approved'] == "1")
+ {
+ $query = "UPDATE {lab_migration_solution} SET approval_status = 1, approver_uid = :approver_uid, approval_date = :approval_date WHERE id = :solution_id";
+ $args = array(
+ ":approver_uid" => $user->uid,
+ ":approval_date" => time(),
+ ":solution_id" => $solution_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_approved']['solution_id'] = $solution_id;
+ $param['solution_approved']['user_id'] = $user_data->uid;
+ $param['solution_approved']['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
+ );
+ if (!drupal_mail('lab_migration', 'solution_approved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ else if ($form_state['values']['approved'] == "2")
+ {
+ if (lab_migration_delete_solution($solution_id))
+ {
+ /* sending email */
+ $email_to = $user_data->mail;
+ $from = variable_get('lab_migration_from_email', '');
+ $bcc = variable_get('lab_migration_emails', '');
+ $cc = variable_get('lab_migration_cc_emails', '');
+ $param['solution_disapproved']['experiment_number'] = $experiment_data->number;
+ $param['solution_disapproved']['experiment_title'] = $experiment_data->title;
+ $param['solution_disapproved']['solution_number'] = $solution_data->code_number;
+ $param['solution_disapproved']['solution_caption'] = $solution_data->caption;
+ $param['solution_disapproved']['user_id'] = $user_data->uid;
+ $param['solution_disapproved']['message'] = $form_state['values']['message'];
+ $param['solution_disapproved']['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
+ );
+ if (!drupal_mail('lab_migration', 'solution_disapproved', $email_to, language_default(), $param, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ else
+ {
+ drupal_set_message('Error disapproving and deleting solution. Please contact administrator.', 'error');
+ }
+ }
+ drupal_set_message('Updated successfully.', 'status');
+ drupal_goto('lab-migration/code-approval');
+ }
diff --git a/abstract_bulk_approval.inc b/abstract_bulk_approval.inc
new file mode 100755
index 0000000..2bcfbff
--- /dev/null
+++ b/abstract_bulk_approval.inc
@@ -0,0 +1,444 @@
+ 'select',
+ '#title' => t('Title of the flowsheeting project'),
+ '#options' => _bulk_list_of_flowsheet_project(),
+ '#default_value' => $selected,
+ '#ajax' => array(
+
+ 'callback' => 'ajax_bulk_flowsheet_abstract_details_callback'
+ ),
+ '#suffix' => '
',
+ '#states' => array(
+ 'visible' => array(
+ array(
+ ':input[name="flowsheet_actions"]' => array(
+ 'value' => 3
+ )
+ ),
+ 'or',
+ array(
+ ':input[name="flowsheet_actions"]' => array(
+ 'value' => 2
+ )
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="lab"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ return $form;
+}
+function ajax_bulk_flowsheet_abstract_details_callback($form, $form_state)
+{
+ $commands = array();
+ $flowsheet_project_default_value = $form_state['values']['flowsheet_project'];
+ if ($flowsheet_project_default_value != 0)
+ {
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', _flowsheet_details($flowsheet_project_default_value));
+ $form['flowsheet_actions']['#options'] = _bulk_list_flowsheet_actions();
+ //$form['lab_experiment_list']['#options'] = _ajax_bulk_get_experiment_list($lab_default_value);
+ // $commands[] = ajax_command_data('#ajax_selected_flowsheet', 'form_state_value_select', $form_state['values']['lab_experiment_list']);
+ // $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ $commands[] = ajax_command_replace('#ajax_selected_flowsheet_action', drupal_render($form['flowsheet_actions']));
+ } //$flowsheet_project_default_value != 0
+ else
+ {
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', '');
+ $commands[] = ajax_command_data('#ajax_selected_flowsheet', 'form_state_value_select', $form_state['values']['flowsheet_project']);
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+/************************************************************/
+function om_flowsheet_abstract_bulk_approval_form_submit($form, &$form_state)
+{
+ global $user;
+ $msg = '';
+ $root_path = om_flowsheet_document_path();
+ if ($form_state['clicked_button']['#value'] == 'Submit')
+ {
+ if ($form_state['values']['flowsheet_project'])
+ // om_flowsheet_abstract_del_lab_pdf($form_state['values']['flowsheet_project']);
+ if (user_access('om flowsheet bulk manage abstract'))
+ {
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $form_state['values']['flowsheet_project']);
+ $user_query = $query->execute();
+ $user_info = $user_query->fetchObject();
+ $user_data = user_load($user_info->uid);
+ if ($form_state['values']['flowsheet_actions'] == 1)
+ {
+ // approving entire project //
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $form_state['values']['flowsheet_project']);
+ $abstracts_q = $query->execute();
+ $experiment_list = '';
+ while ($abstract_data = $abstracts_q->fetchObject())
+ {
+ db_query("UPDATE {om_flowsheet_submitted_abstracts} SET abstract_approval_status = 1, approver_uid = :approver_uid WHERE id = :id", array(
+ ':approver_uid' => $user->uid,
+ ':id' => $abstract_data->id
+ ));
+ db_query("UPDATE {om_flowsheet_submitted_abstracts_file} SET file_approval_status = 1, approvar_uid = :approver_uid WHERE submitted_abstract_id = :submitted_abstract_id", array(
+ ':approver_uid' => $user->uid,
+ ':submitted_abstract_id' => $abstract_data->id
+ ));
+ } //$abstract_data = $abstracts_q->fetchObject()
+ drupal_set_message(t('Approved Flowsheeting project.'), 'status');
+ // email
+ $email_subject = t('[!site_name][Flowsheeting Project] Your uploaded flowsheeting project have been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $email_body = array(
+ 0 => t('
+
+Dear !user_name,
+
+Congratulations!
+Your om flowsheet and abstract with the following details have been approved.
+
+Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . '
+Project Title: ' . $user_info->project_title . '
+Name of compound for which process development is carried out : ' . $user_info->process_development_compound_name . '
+
+Kindly send us the internship forms as early as possible for processing your honorarium on time. In case you have already sent these forms, please share the the consignment number or tracking id with us.
+
+Note: It will take upto 30 days from the time we receive your forms, to process your honorarium.
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ /** sending email when everything done **/
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['standard']['subject'] = $email_subject;
+ $params['standard']['body'] = $email_body;
+ $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
+ );
+ if (!drupal_mail('om_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ {
+ $msg = drupal_set_message('Error sending email message.', 'error');
+ } //!drupal_mail('om_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE)
+ } //$form_state['values']['flowsheet_actions'] == 1
+ elseif ($form_state['values']['flowsheet_actions'] == 2)
+ {
+ //pending review entire project
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $form_state['values']['flowsheet_project']);
+ $abstracts_q = $query->execute();
+ $experiment_list = '';
+ while ($abstract_data = $abstracts_q->fetchObject())
+ {
+ db_query("UPDATE {om_flowsheet_submitted_abstracts} SET abstract_approval_status = 0, is_submitted = 0, approver_uid = :approver_uid WHERE id = :id", array(
+ ':approver_uid' => $user->uid,
+ ':id' => $abstract_data->id
+ ));
+ db_query("UPDATE {om_flowsheet_submitted_abstracts_file} SET file_approval_status = 0, approvar_uid = :approver_uid WHERE submitted_abstract_id = :submitted_abstract_id", array(
+ ':approver_uid' => $user->uid,
+ ':submitted_abstract_id' => $abstract_data->id
+ ));
+ } //$abstract_data = $abstracts_q->fetchObject()
+ drupal_set_message(t('Resubmit the project files.'), 'status');
+ // email
+ $email_subject = t('[!site_name][Flowsheeting Project] Your uploaded flowsheeting project have been marked as pending', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $email_body = array(
+ 0 => t('
+
+Dear !user_name,
+
+Your all the uploaded flowsheeting project with Title : ' . $user_info->project_title . ' have been marked as pending to be reviewed.
+
+You will be able to see the flowsheeting project after approved by one of our reviewers.
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ /** sending email when everything done **/
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['standard']['subject'] = $email_subject;
+ $params['standard']['body'] = $email_body;
+ $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
+ );
+ if (!drupal_mail('om_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ {
+ drupal_set_message('Error sending email message.', 'error');
+ } //!drupal_mail('om_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE)
+ } //$form_state['values']['flowsheet_actions'] == 2
+ elseif ($form_state['values']['flowsheet_actions'] == 3) //disapprove and delete entire flowsheeting project
+ {
+ if (strlen(trim($form_state['values']['message'])) <= 30)
+ {
+ form_set_error('message', t(''));
+ $msg = drupal_set_message("Please mention the reason for disapproval. Minimum 30 character required", 'error');
+ return $msg;
+ } //strlen(trim($form_state['values']['message'])) <= 30
+ if (!user_access('om flowsheet bulk delete code'))
+ {
+ $msg = drupal_set_message(t('You do not have permission to Bulk Dis-Approved and Deleted Entire Lab.'), 'error');
+ return $msg;
+ } //!user_access('flowsheet bulk delete code')
+ if (om_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project'])) //////
+ {
+ drupal_set_message(t('Dis-Approved and Deleted Entire Flowsheeting project.'), 'status');
+ $email_subject = t('[!site_name][Flowsheeting Project] Your uploaded flowsheeting project have been marked as dis-approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $email_body = array(
+ 0 => t('
+
+Dear !user_name,
+
+We regret to inform you that your om flowsheet and abstract with the following details have been disapproved:
+
+Full Name: ' . $user_info->name_title . ' ' . $user_info->contributor_name . '
+Project Title: ' . $user_info->project_title . '
+Name of compound for which process development is carried out : ' . $user_info->process_development_compound_name . '
+Reason for dis-approval: ' . $form_state['values']['message'] . '
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['standard']['subject'] = $email_subject;
+ $params['standard']['body'] = $email_body;
+ $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
+ );
+ if (!drupal_mail('om_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ {
+ drupal_set_message('Error sending email message.', 'error');
+ }
+ } //om_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project'])
+ else
+ {
+ drupal_set_message(t('Error Dis-Approving and Deleting Entire flowsheeting project.'), 'error');
+ }
+ }//$form_state['values']['flowsheet_actions'] == 3
+ //$form_state['values']['flowsheet_actions'] == 4
+
+ } //user_access('flowsheet project bulk manage code')
+ return $msg;
+ } //$form_state['clicked_button']['#value'] == 'Submit'
+}
+/**********************************************************/
+function _bulk_list_of_flowsheet_project()
+{
+ $project_titles = array(
+ '0' => 'Please select...'
+ );
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 1);
+ $query->orderBy('project_title', 'ASC');
+ $project_titles_q = $query->execute();
+ while ($project_titles_data = $project_titles_q->fetchObject())
+ {
+ $project_titles[$project_titles_data->id] = $project_titles_data->project_title . ' (Proposed by ' . $project_titles_data->contributor_name . ')';
+ } //$project_titles_data = $project_titles_q->fetchObject()
+ return $project_titles;
+}
+function _bulk_list_flowsheet_actions()
+{
+ $flowsheet_actions = array(
+ 0 => 'Please select...'
+ );
+ $flowsheet_actions[1] = 'Approve Entire Flowsheeting Project';
+ $flowsheet_actions[2] = 'Pending Review Entire Flowsheeting Project';
+ $flowsheet_actions[3] = 'Dis-Approve Entire Flowsheeting Project (This will delete Flowsheeting Project)';
+ //$flowsheet_actions[4] = 'Delete Entire Flowsheeting Project Including Proposal';
+ return $flowsheet_actions;
+}
+function _flowsheet_details($flowsheet_proposal_id)
+{
+ $return_html = "";
+ $query_pro = db_select('om_flowsheet_proposal');
+ $query_pro->fields('om_flowsheet_proposal');
+ $query_pro->condition('id', $flowsheet_proposal_id);
+ $abstracts_pro = $query_pro->execute()->fetchObject();
+ $query_pdf = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_pdf->fields('om_flowsheet_submitted_abstracts_file');
+ $query_pdf->condition('proposal_id', $flowsheet_proposal_id);
+ $query_pdf->condition('filetype', 'A');
+ $abstracts_pdf = $query_pdf->execute()->fetchObject();
+ if ($abstracts_pdf == TRUE)
+ {
+ if ($abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != "")
+ {
+ $abstract_filename = $abstracts_pdf->filename;
+ } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
+ else
+ {
+ $abstract_filename = "File not uploaded";
+ }
+ } //$abstracts_pdf == TRUE
+ else
+ {
+ $abstract_filename = "File not uploaded";
+ }
+ $query_process = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_process->fields('om_flowsheet_submitted_abstracts_file');
+ $query_process->condition('proposal_id', $flowsheet_proposal_id);
+ $query_process->condition('filetype', 'S');
+ $abstracts_query_process = $query_process->execute()->fetchObject();
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $flowsheet_proposal_id);
+ $abstracts_q = $query->execute()->fetchObject();
+ if ($abstracts_q)
+ {
+ if ($abstracts_q->is_submitted == 0)
+ {
+ //drupal_set_message(t('Abstract is not submmited yet.'), 'error', $repeat = FALSE);
+ //return;
+ } //$abstracts_q->is_submitted == 0
+ } //$abstracts_q
+ //var_dump($abstracts_query_process);die;
+ if ($abstracts_query_process == TRUE)
+ {
+ if ($abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != "")
+ {
+ $abstracts_query_process_filename = $abstracts_query_process->filename;
+ } //$abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != ""
+ else
+ {
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ if ($abstracts_q->unit_operations_used_in_om == '')
+ {
+ $unit_operations_used_in_om = "Not entered";
+ } //$abstracts_q->unit_operations_used_in_om == ''
+ else
+ {
+ $unit_operations_used_in_om = $abstracts_q->unit_operations_used_in_om;
+ }
+ if ($abstracts_q->thermodynamic_packages_used == '')
+ {
+ $thermodynamic_packages_used = "Not entered";
+ } //$abstracts_q->thermodynamic_packages_used == ''
+ else
+ {
+ $thermodynamic_packages_used = $abstracts_q->thermodynamic_packages_used;
+ }
+
+ } //$abstracts_query_process == TRUE
+ else
+ {
+ $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
+ $unit_operations_used_in_om = "Not entered";
+ $thermodynamic_packages_used = "Not entered";
+
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ $headers = array(
+ "Name of compound for which process development is carried out",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$abstracts_pro->process_development_compound_name}",
+ "{$abstracts_pro->process_development_compound_cas_number}"
+ );
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
+ $download_flowsheet = l('Download flowsheet project','flowsheeting-project/full-download/project/'.$flowsheet_proposal_id);
+ $return_html .= '
Proposer Name:' . $abstracts_pro->name_title . ' ' . $abstracts_pro->contributor_name . '
';
+ $return_html .= '
Title of the Flowsheet Project:' . $abstracts_pro->project_title . '
';
+ $return_html .= '
OpenModelica version:' . $abstracts_pro->version . '
';
+ $return_html .= '
Unit Operations used in OpenModelica:' . $unit_operations_used_in_om . '
';
+ $return_html .= '
Thermodynamic Packages Used:' . $thermodynamic_packages_used . '
';
+ $return_html .= '
Name of compound for which process development is carried out:' . $prodata;
+ $return_html .= '
Uploaded an abstract (brief outline) of the project:' . $abstract_filename . '
';
+ $return_html .= '
Upload the OpenModelica flowsheet for the developed process:' . $abstracts_query_process_filename . '
';
+ $return_html .= $download_flowsheet;
+ return $return_html;
+}
diff --git a/download.inc b/download.inc
new file mode 100755
index 0000000..fa1fdd1
--- /dev/null
+++ b/download.inc
@@ -0,0 +1,270 @@
+fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $om_flowsheet_user_compund_data = $result->fetchObject();
+ $samplecodename = substr($om_flowsheet_user_compund_data->user_defined_compound_filepath, strrpos($om_flowsheet_user_compund_data->user_defined_compound_filepath, '/') + 1);
+ header('Content-Type: txt/zip');
+ header('Content-disposition: attachment; filename="' . $samplecodename . '"');
+ header('Content-Length: ' . filesize($root_path . $om_flowsheet_user_compund_data->directory_name . '/' . $om_flowsheet_user_compund_data->user_defined_compound_filepath));
+ ob_clean();
+ readfile($root_path . $om_flowsheet_user_compund_data->directory_name . '/' . $om_flowsheet_user_compund_data->user_defined_compound_filepath);
+}
+function om_flowsheet_download_solution_file()
+{
+ $solution_file_id = arg(3);
+ $root_path = om_flowsheet_path();
+ // $solution_files_q = db_query("SELECT * FROM {om_flowsheet_solution_files} WHERE id = %d LIMIT 1", $solution_file_id);
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id LIMIT 1", array(
+ ':solution_id' => $solution_file_id
+ ));
+ $solution_file_data = $solution_files_q->fetchObject();
+ header('Content-Type: ' . $solution_file_data->filemime);
+ //header('Content-Type: application/octet-stram');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($solution_file_data->filename)) . '"');
+ header('Content-Length: ' . filesize($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath));
+ readfile($root_path . $solution_file_data->directory_name . '/' . $solution_file_data->filepath);
+}
+function om_flowsheet_download_dependency_file()
+{
+ $dependency_file_id = arg(3);
+ $root_path = om_flowsheet_path();
+ $query = db_select('om_flowsheet_dependency_files');
+ $query->fields('om_flowsheet_dependency_files');
+ $query->condition('id', $dependency_file_id);
+ $query->range(0, 1);
+ $dependency_files_q = $query->execute();
+ $dependency_file_data = $dependency_files_q->fetchObject();
+ header('Content-Type: ' . $dependency_file_data->filemime);
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', ($dependency_file_data->filename)) . '"');
+ header('Content-Length: ' . filesize($root_path . $dependency_file_data->filepath));
+ readfile($root_path . $dependency_file_data->filepath);
+}
+function om_flowsheet_download_solution()
+{
+ $solution_id = arg(3);
+ $root_path = om_flowsheet_path();
+ $query = db_select('om_flowsheet_solution');
+ $query->fields('om_flowsheet_solution');
+ $query->condition('id', $solution_id);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('om_flowsheet_experiment');
+ $query->fields('om_flowsheet_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array(
+ ':solution_id' => $solution_id
+ ));
+ $query = db_select('om_flowsheet_solution_dependency');
+ $query->fields('om_flowsheet_solution_dependency');
+ $query->condition('solution_id', $solution_id);
+ $solution_dependency_files_q = $query->execute();
+ $CODE_PATH = 'CODE' . $solution_data->code_number . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ while ($solution_files_row = $solution_files_q->fetchObject())
+ {
+ $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename)));
+ }
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ $query = db_select('om_flowsheet_dependency_files');
+ $query->fields('om_flowsheet_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject()
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="CODE' . $solution_data->code_number . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ //flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$zip_file_count > 0
+ else
+ {
+ drupal_set_message("There are no files in this solutions to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+}
+function om_flowsheet_download_experiment()
+{
+ $experiment_id = (int) arg(3);
+ $root_path = om_flowsheet_path();
+ /* get solution data */
+ $query = db_select('om_flowsheet_experiment');
+ $query->fields('om_flowsheet_experiment');
+ $query->condition('id', $experiment_id);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $EXP_PATH = 'EXP' . $experiment_data->number . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive;
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ $query = db_select('om_flowsheet_solution');
+ $query->fields('om_flowsheet_solution');
+ $query->condition('experiment_id', $experiment_id);
+ $query->condition('approval_status', 1);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.solution_id = :solution_id", array(
+ ':solution_id' => $solution_row->id
+ ));
+ while ($solution_files_row = $solution_files_q->fetchObject())
+ {
+ $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename)));
+ } //$solution_files_row = $solution_files_q->fetchObject()
+ /* dependency files */
+ $query = db_select('om_flowsheet_solution_dependency');
+ $query->fields('om_flowsheet_solution_dependency');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_dependency_files_q = $query->execute();
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ $query = db_select('om_flowsheet_dependency_files');
+ $query->fields('om_flowsheet_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject()
+ } //$solution_row = $solution_q->fetchObject()
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="EXP' . $experiment_data->number . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ //flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$zip_file_count > 0
+ else
+ {
+ drupal_set_message("There are no solutions in this experiment to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+}
+function om_flowsheet_download_lab()
+{
+ global $user;
+ $lab_id = arg(3);
+ $root_path = om_flowsheet_path();
+ /* get solution data */
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $lab_id);
+ $lab_q = $query->execute();
+ $lab_data = $lab_q->fetchObject();
+ $LAB_PATH = $lab_data->lab_title . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive();
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ $query = db_select('om_flowsheet_experiment');
+ $query->fields('om_flowsheet_experiment');
+ $query->condition('proposal_id', $lab_id);
+ $experiment_q = $query->execute();
+ while ($experiment_row = $experiment_q->fetchObject())
+ {
+ $EXP_PATH = 'EXP' . $experiment_row->number . '/';
+ $query = db_select('om_flowsheet_solution');
+ $query->fields('om_flowsheet_solution');
+ $query->condition('experiment_id', $experiment_row->id);
+ $query->condition('approval_status', 1);
+ $solution_q = $query->execute();
+ while ($solution_row = $solution_q->fetchObject())
+ {
+ $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
+ $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM om_flowsheet_solution_files lmsf JOIN om_flowsheet_solution lms JOIN om_flowsheet_experiment lme JOIN om_flowsheet_proposal lmp WHERE lms.id = lmsf.solution_id AND lme.id = lms.experiment_id AND lmp.id = lme.proposal_id AND lmsf.id = :solution_id", array(
+ ':solution_id' => $solution_row->id
+ ));
+ $query = db_select('om_flowsheet_solution_dependency');
+ $query->fields('om_flowsheet_solution_dependency');
+ $query->condition('solution_id', $solution_row->id);
+ $solution_dependency_files_q = $query->execute();
+ while ($solution_files_row = $solution_files_q->fetchObject())
+ {
+ $zip->addFile($root_path . $solution_files_row->directory_name . '/' . $solution_files_row->filepath, $EXP_PATH . $CODE_PATH . str_replace(' ', '_', ($solution_files_row->filename)));
+ //var_dump($zip->numFiles);
+ } //$solution_files_row = $solution_files_q->fetchObject()
+ // die;
+ /* dependency files */
+ while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
+ {
+ $query = db_select('om_flowsheet_dependency_files');
+ $query->fields('om_flowsheet_dependency_files');
+ $query->condition('id', $solution_dependency_files_row->dependency_id);
+ $query->range(0, 1);
+ $dependency_file_data = $query->execute()->fetchObject();
+ if ($dependency_file_data)
+ $zip->addFile($root_path . $dependency_file_data->filepath, $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . str_replace(' ', '_', ($dependency_file_data->filename)));
+ } //$solution_dependency_files_row = $solution_dependency_files_q->fetchObject()
+ } //$solution_row = $solution_q->fetchObject()
+ } //$experiment_row = $experiment_q->fetchObject()
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0)
+ {
+ if ($user->uid)
+ {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_clean();
+ //flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$user->uid
+ else
+ {
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $lab_data->lab_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ } //$zip_file_count > 0
+ else
+ {
+ drupal_set_message("There are no solutions in this Lab to download", 'error');
+ drupal_goto('lab-migration/lab-migration-run');
+ }
+}
diff --git a/email.inc b/email.inc
new file mode 100755
index 0000000..80a5d82
--- /dev/null
+++ b/email.inc
@@ -0,0 +1,494 @@
+fields('om_flowsheet_proposal');
+ $query->condition('id', $params['om_flowsheet_proposal_received']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $phpdate = time( $proposal_data->creation_date );
+ $user_data = user_load($params['om_flowsheet_proposal_received']['user_id']);
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+
+ $message['headers'] = $params['om_flowsheet_proposal_received']['headers'];
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your om Flowsheeting Project proposal has been received', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Thank you for submitting proposal for the om Flowsheeting Project. The details of your proposal are as below.
+
+Full Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Email: ' . $user_data->mail . '
+University/Institute: ' . $proposal_data->university . '
+City: ' . $proposal_data->city . '
+Project Title: ' . $proposal_data->project_title . '
+Name of compound for which process development is carried out: ' . $proposal_data->process_development_compound_name . '
+
+Your proposal is under review. You will be notified via email about the approval/disapproval within ten working days.
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'om_flowsheet_proposal_disapproved':
+ /* initializing data */
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $params['om_flowsheet_proposal_disapproved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $phpdate = time( $proposal_data->creation_date );
+ $user_data = user_load($params['om_flowsheet_proposal_disapproved']['user_id']);
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['om_flowsheet_proposal_disapproved']['headers'];
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your om Flowsheeting Project proposal has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+We regret to inform you that your om Flowsheeting Project proposal with following details have been disapproved.
+
+Full Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Project Title: ' . $proposal_data->project_title . '
+Name of compound for which process development is carried out: ' . $proposal_data->process_development_compound_name . '
+Reason(s) / Feedback: ' . $proposal_data->dissapproval_reason . '
+
+Please note that any files that were uploaded along with the proposal form will be deleted from all our database(s).
+
+Thank you for participating in the om Flowsheeting Project. You are welcome to submit a new proposal.
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'om_flowsheet_proposal_approved':
+ /* initializing data */
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $params['om_flowsheet_proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['om_flowsheet_proposal_approved']['user_id']);
+ $url = 'https://om.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting';
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['om_flowsheet_proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your om Flowsheeting Project proposal has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Congratulations! Your proposal for om Flowsheeting Project with the following details is approved.
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Project Title : ' . $proposal_data->project_title . '
+Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . '
+
+Please ensure that ALL the guidelines for coding at https://om.fossee.in/flowsheeting-project/coding-guidelines-flowsheeting are strictly followed. Refer https://om.fossee.in/flowsheeting-project/flowsheeting-internship for the further procedure for submission of the project. Kindly ensure that the flowsheet and abstract are submitted within 1 month.
+
+You can upload your abstract using abstract submission interface.
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'om_flowsheet_proposal_completed':
+ /* initializing data */
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $params['om_flowsheet_proposal_completed']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['om_flowsheet_proposal_completed']['user_id']);
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['om_flowsheet_proposal_completed']['headers'];
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your om Flowsheeting Project proposal has been completed', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your om flowsheet and abstract on the following process have been published successfully.
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Project Title : ' . $proposal_data->project_title . '
+
+Kindly access this link to download the same.
+https://om.fossee.in/flowsheeting-project/completed-flowsheet
+
+You can now download your e-certificate after logging into the om website: om.fossee.in. On the left-hand side panel, go to User Dashboard > Flowsheet Certificates > Download. In case of any difficulties, kindly let us know.
+
+Thank you for participating in the om Flowsheeting Project. You are welcome to propose a new flowsheet.
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'om_flowsheet_proposal_deleted':
+ /* initializing data */
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $params['om_flowsheet_proposal_deleted']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+ $user_data = user_load($params['om_flowsheet_proposal_deleted']['user_id']);
+
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $message['headers'] = $params['om_flowsheet_proposal_deleted']['headers'];
+ $message['subject'] = t('[!site_name][Flowsheeting Project] Your om Flowsheeting Project proposal has been deleted', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your om Flowsheeting Project proposal with the following details has been deleted :
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Email : ' . $user_data->mail . '
+Month and Year of Award of Degree : ' . $proposal_data->month_year_of_degree . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+Country : ' . $proposal_data->country . '
+
+Project Guide : ' . $project_guide_name . '
+Project Guide Email : ' . $project_guide_email_id . '
+
+om Version : ' . $proposal_data->version . '
+
+Project Title : ' . $proposal_data->project_title . '
+
+Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . '
+
+
+
+You can propose a new flowsheet project.
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ /**************************************************************/
+ case 'abstract_uploaded':
+ // $solution_q = db_query("SELECT * FROM {om_flowsheet_solution} WHERE id = %d LIMIT 1", $params['abstract_uploaded']['solution_id']);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $params['abstract_uploaded']['proposal_id']);
+ $query->range(0, 1);
+ $proposal_data = $query->execute()->fetchObject();
+
+ $user_data = user_load($params['abstract_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name][Flowsheeting Project] You have uploaded om flowsheet abstract', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['headers'] = $params['abstract_uploaded']['headers'];
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+You have successfully uploaded your om flowsheet and abstract with the following details.
+
+Full Name : ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
+Project Title : ' . $proposal_data->project_title . '
+Name of compound for which process development is carried out : ' . $proposal_data->process_development_compound_name . '
+
+You shall be notified via email after the flowsheet and abstract are reviewed and approved / disapproved. This may take upto 30 working days.
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_approved':
+ //$solution_q = db_query("SELECT * FROM {om_flowsheet_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']);
+ $query = db_select('om_flowsheet_solution');
+ $query->fields('om_flowsheet_solution');
+ $query->condition('id', $params['solution_approved']['solution_id']);
+ $query->range(0, 1);
+ $solution_q = $query->execute();
+ $solution_data = $solution_q->fetchObject();
+ $query = db_select('om_flowsheet_experiment');
+ $query->fields('om_flowsheet_experiment');
+ $query->condition('id', $solution_data->experiment_id);
+ $query->range(0, 1);
+ $experiment_q = $query->execute();
+ $experiment_data = $experiment_q->fetchObject();
+ $user_data = user_load($params['solution_approved']['user_id']);
+ $message['headers'] = $params['solution_approved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded om flowsheet solution has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following solution has been approved:
+
+Experiment Title : ' . $experiment_data->title . '
+
+Solution number : ' . $solution_data->code_number . '
+Caption : ' . $solution_data->caption . '
+
+Please ensure that ALL the codes follow guidelines at https://om.fossee.in/om-flowsheet-project/om-flowsheet-guidelines
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_disapproved':
+ $user_data = user_load($params['solution_disapproved']['user_id']);
+ $message['headers'] = $params['solution_disapproved']['headers'];
+ $message['subject'] = t('[!site_name] Your uploaded om flowsheet solution has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following solution has been disapproved:
+
+Solution number : ' . $params['solution_disapproved']['solution_number'] . '
+Caption : ' . $params['solution_disapproved']['solution_caption'] . '
+
+Reason for dis-approval : ' . $params['solution_disapproved']['message'] . '
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'solution_deleted_user':
+ $user_data = user_load($params['solution_deleted_user']['user_id']);
+ $message['headers'] = $params['solution_deleted_user']['headers'];
+ $message['subject'] = t('[!site_name] User has deleted pending om flowsheet solution', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+Your following pending solution has been deleted :
+
+Title of the Lab : ' . $params['solution_deleted_user']['lab_title'] . '
+Title of the Experiment : ' . $params['solution_deleted_user']['experiment_title'] . '
+
+Solution number : ' . $params['solution_deleted_user']['solution_number'] . '
+Caption : ' . $params['solution_deleted_user']['solution_caption'] . '
+
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'dependency_uploaded':
+ $user_data = user_load($params['dependency_uploaded']['user_id']);
+ $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
+ $message['headers'] = $params['dependency_uploaded']['headers'];
+ $message['subject'] = t('[!site_name] You have uploaded dependency file', array(
+ '!site_name' => variable_get('site_name', '')
+ ), array(
+ 'language' => $language->language
+ ));
+ $message['body'] = array(
+ 'body' => t('
+Dear !user_name,
+
+You have uploaded following dependency files :
+ ' . $dependency_files . '
+
+Please ensure that ALL the codes follow guidelines at https://om.fossee.in/om-flowsheet-project/om-flowsheet-guidelines
+
+Best Wishes,
+
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ), array(
+ 'language' => $language->language
+ ))
+ );
+ break;
+ case 'standard':
+ $message['subject'] = $params['standard']['subject'];
+ $message['body'] = $params['standard']['body'];
+ $message['headers'] = $params['standard']['headers'];
+ break;
+ } //$key
+}
diff --git a/flowsheet_details.inc b/flowsheet_details.inc
new file mode 100755
index 0000000..116440f
--- /dev/null
+++ b/flowsheet_details.inc
@@ -0,0 +1,91 @@
+fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 3);
+ $query->orderBy('actual_completion_date', 'ASC');
+ //$query->condition('is_completed', 1);
+ $result = $query->execute();
+ if ($result->rowCount() == 0)
+ {
+ $output .= "Work has been completed for the following flow sheets. We welcome your contributions. For more details, please visit ".l("https://om.fossee.in/flowsheeting-project","https://om.fossee.in/flowsheeting-project", array('attributes' => array('target' => '_blank')))."
"."
"."If you are looking for flowsheeting project ideas, ".l("click here","https://om.fossee.in/flowsheeting-ideas",array('attributes' => array('class' => array('flash_content'), 'target' => '_blank')))."
"."
";
+
+ } //$result->rowCount() == 0
+ else
+ {
+ $output .= "Work has been completed for the following flow sheets. We welcome your contributions. For more details, please visit ".l("https://om.fossee.in/flowsheeting-project","https://om.fossee.in/flowsheeting-project", array('attributes' => array('target' => '_blank')))."
"."
"."If you are looking for flowsheeting project ideas, ".l("click here","https://om.fossee.in/flowsheeting-ideas",array('attributes' => array('class' => array('flash_content'), 'target' => '_blank')))."
"."
";
+ $preference_rows = array();
+ $i = 1;
+ while ($row = $result->fetchObject())
+ {
+ $completion_date = date("Y", $row->actual_completion_date);
+ $preference_rows[] = array(
+ $i,
+ l($row->project_title, "flowsheeting-project/om-flowsheet-run/" . $row->id, array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))),
+ $row->contributor_name,
+ $row->university,
+ $completion_date
+ );
+ $i++;
+ } //$row = $result->fetchObject()
+ $preference_header = array(
+ 'No',
+ 'Flowsheet Project',
+ 'Contributor Name',
+ 'Institution',
+ 'Year'
+ );
+ $output .= theme('table', array(
+ 'header' => $preference_header,
+ 'rows' => $preference_rows
+ ));
+ }
+ return $output;
+}
+// om Flowsheet display in progress proposals
+function om_flowsheet_progress_all()
+{
+ $page_content = "";
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 1);
+ $query->condition('is_completed', 0);
+ $result = $query->execute();
+ if ($result->rowCount() == 0)
+ {
+ $page_content .= "Work is in progress for the following flowsheets under Flowsheeting Project
";
+ } //$result->rowCount() == 0
+ else
+ {
+ $page_content .= "Work is in progress for the following flowsheets under Flowsheeting Project
";;
+ $preference_rows = array();
+ $i = 1;
+ while ($row = $result->fetchObject())
+ {
+ $approval_date = date("Y", $row->approval_date);
+ $preference_rows[] = array(
+ $i,
+ $row->project_title,
+ $row->contributor_name,
+ $row->university,
+ $approval_date
+ );
+ $i++;
+ } //$row = $result->fetchObject()
+ $preference_header = array(
+ 'No',
+ 'Flowsheet Project',
+ 'Contributor Name',
+ 'Institution',
+ 'Year'
+ );
+ $page_content .= theme('table', array(
+ 'header' => $preference_header,
+ 'rows' => $preference_rows
+ ));
+ }
+ return $page_content;
+}
\ No newline at end of file
diff --git a/full_download.inc b/full_download.inc
new file mode 100755
index 0000000..07646d6
--- /dev/null
+++ b/full_download.inc
@@ -0,0 +1,123 @@
+fields('om_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_q = $query->execute();
+ $flowsheet_data = $flowsheet_q->fetchObject();
+ $FLOWSHEET_PATH = $flowsheet_data->directory_name . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive();
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_udc_q = $query->execute();
+ $query = db_select('om_flowsheet_submitted_abstracts_file');
+ $query->fields('om_flowsheet_submitted_abstracts_file');
+ $query->condition('proposal_id', $flowsheet_id);
+ $flowsheet_f_q = $query->execute();
+ while ($flowsheet_f_row = $flowsheet_f_q->fetchObject()) {
+ $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $flowsheet_f_row->filepath, $FLOWSHEET_PATH . str_replace(' ', '_', basename($flowsheet_f_row->filename)));
+ } //$flowsheet_f_row = $flowsheet_f_q->fetchObject()
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0) {
+ if ($user->uid) {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $flowsheet_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$user->uid
+ else {
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $flowsheet_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ } //$zip_file_count > 0
+ else {
+ drupal_set_message("There are no flowsheet project in this proposal to download", 'error');
+ drupal_goto('flowsheeting-project/full-download/project');
+ }
+}
+function om_flowsheet_download_completed_project()
+{
+ global $user;
+ $flowsheet_id = arg(3);
+ $root_path = om_flowsheet_path();
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_q = $query->execute();
+ $flowsheet_data = $flowsheet_q->fetchObject();
+ $FLOWSHEET_PATH = $flowsheet_data->directory_name . '/';
+ /* zip filename */
+ $zip_filename = $root_path . 'zip-' . time() . '-' . rand(0, 999999) . '.zip';
+ /* creating zip archive on the server */
+ $zip = new ZipArchive();
+ $zip->open($zip_filename, ZipArchive::CREATE);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_udc_q = $query->execute();
+
+ $query = db_select('om_flowsheet_submitted_abstracts_file');
+ $query->fields('om_flowsheet_submitted_abstracts_file');
+ $query->condition('proposal_id', $flowsheet_id);
+ $flowsheet_f_q = $query->execute();
+ while ($flowsheet_f_row = $flowsheet_f_q->fetchObject()) {
+ $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $flowsheet_f_row->filepath, str_replace(' ', '_', basename($flowsheet_f_row->filename)));
+ } //$flowsheet_f_row = $flowsheet_f_q->fetchObject()
+ $zip_file_count = $zip->numFiles;
+ $zip->close();
+ if ($zip_file_count > 0) {
+ if ($user->uid) {
+ /* download zip file */
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $flowsheet_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ } //$user->uid
+ else {
+ header('Content-Type: application/zip');
+ header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $flowsheet_data->project_title) . '.zip"');
+ header('Content-Length: ' . filesize($zip_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ ob_end_flush();
+ ob_clean();
+ flush();
+ readfile($zip_filename);
+ unlink($zip_filename);
+ }
+ } //$zip_file_count > 0
+ else {
+ drupal_set_message("There are no flowsheet project in this proposal to download", 'error');
+ drupal_goto('flowsheeting-project/om-flowsheet-run');
+ }
+}
diff --git a/general_deletion.inc b/general_deletion.inc
new file mode 100755
index 0000000..5912345
--- /dev/null
+++ b/general_deletion.inc
@@ -0,0 +1,71 @@
+ $abstract_id
+ ));
+ $abstract_data = $abstract_q->fetchObject();
+ if (!$abstract_data)
+ {
+ drupal_set_message('Invalid flowsheet project abstract.', 'error');
+ return FALSE;
+ } //!$abstract_data
+ /* deleting solutions */
+ $query = db_select('om_flowsheet_submitted_abstracts_file');
+ $query->fields('om_flowsheet_submitted_abstracts_file');
+ $query->condition('submitted_abstract_id', $abstract_id);
+ $abstract_f_q = $query->execute();
+
+ while ($abstract_f_data = $abstract_f_q->fetchObject())
+ {
+ unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath);
+
+ }
+
+ return True;
+}
+function om_flowsheet_abstract_delete_project($proposal_id)
+{
+ $status = TRUE;
+ $root_path = om_flowsheet_path();
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $lab_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message('Invalid Flowsheeting Project.', 'error');
+ return FALSE;
+ } //!$proposal_data
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstract_q = $query->execute();
+ while ($abstract_data = $abstract_q->fetchObject())
+ {
+ if (!om_flowsheet_delete_abstract_file($abstract_data->id))
+ {
+ $status = FALSE;
+ } //!om_flowsheet_delete_abstract_file($abstract_data->id)
+ } //$abstract_data = $abstract_q->fetchObject()
+
+ $dir_main_path = $root_path . $proposal_data->directory_name;
+ //var_dump($dir_main_path);die;
+ if (is_dir($dir_main_path))
+ {
+ $res_main = rmdir($dir_main_path);
+ } //is_dir($dir_main_path)
+ db_delete('om_flowsheet_proposal')->condition('id', $proposal_data->id)->execute();
+ db_delete('om_flowsheet_submitted_abstracts')->condition('proposal_id', $proposal_data->id)->execute();
+ db_delete('om_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute();
+ return $status;
+}
\ No newline at end of file
diff --git a/manage_proposal.inc b/manage_proposal.inc
new file mode 100755
index 0000000..5c5b519
--- /dev/null
+++ b/manage_proposal.inc
@@ -0,0 +1,1090 @@
+fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 0);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ l($pending_data->name_title . ' ' . $pending_data->contributor_name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ l('Approve', 'flowsheeting-project/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'flowsheeting-project/manage-proposal/edit/' . $pending_data->id)
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no pending proposals.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Flowsheet Project',
+ 'Action'
+ );
+ //$output = theme_table($pending_header, $pending_rows);
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
+}
+function om_flowsheet_proposal_pending_solution()
+{
+ /* get pending proposals to be approved */
+ $pending_rows = array();
+ //$pending_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE approval_status = 1 ORDER BY id DESC");
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 1);
+ $query->orderBy('id', 'DESC');
+ $pending_q = $query->execute();
+ while ($pending_data = $pending_q->fetchObject())
+ {
+ $pending_rows[$pending_data->id] = array(
+ date('d-m-Y', $pending_data->creation_date),
+ date('d-m-Y', $pending_data->approval_date),
+ l($pending_data->name, 'user/' . $pending_data->uid),
+ $pending_data->project_title,
+ $pending_data->department,
+ l('Status', 'flowsheeting-project/manage-proposal/status/' . $pending_data->id)
+ );
+ } //$pending_data = $pending_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$pending_rows)
+ {
+ drupal_set_message(t('There are no proposals pending for solutions.'), 'status');
+ return '';
+ } //!$pending_rows
+ $pending_header = array(
+ 'Date of Submission',
+ 'Date of Approval',
+ 'Student name',
+ 'Title of the Flowsheet Project',
+ 'Department',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $pending_header,
+ 'rows' => $pending_rows
+ ));
+ return $output;
+}
+function om_flowsheet_proposal_all()
+{
+ /* get pending proposals to be approved */
+ $proposal_rows = array();
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} ORDER BY id DESC");
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->orderBy('id', 'DESC');
+ $proposal_q = $query->execute();
+ while ($proposal_data = $proposal_q->fetchObject())
+ {
+ $approval_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $approval_status = 'Pending';
+ break;
+ case 1:
+ $approval_status = 'Approved';
+ break;
+ case 2:
+ $approval_status = 'Dis-approved';
+ break;
+ case 3:
+ $approval_status = 'Completed';
+ break;
+ default:
+ $approval_status = 'Unknown';
+ break;
+ } //$proposal_data->approval_status
+ if ($proposal_data->actual_completion_date == 0)
+ {
+ $actual_completion_date = "Not Completed";
+ } //$proposal_data->actual_completion_date == 0
+ else
+ {
+ $actual_completion_date = date('d-m-Y', $proposal_data->actual_completion_date);
+ }
+ $proposal_rows[] = array(
+ date('d-m-Y', $proposal_data->creation_date),
+ l($proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ $proposal_data->project_title,
+ $actual_completion_date,
+ $approval_status,
+ l('Status', 'flowsheeting-project/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'flowsheeting-project/manage-proposal/edit/' . $proposal_data->id)
+ );
+ } //$proposal_data = $proposal_q->fetchObject()
+ /* check if there are any pending proposals */
+ if (!$proposal_rows)
+ {
+ drupal_set_message(t('There are no proposals.'), 'status');
+ return '';
+ } //!$proposal_rows
+ $proposal_header = array(
+ 'Date of Submission',
+ 'Student Name',
+ 'Title of the Lab',
+ 'Date of Completion',
+ 'Status',
+ 'Action'
+ );
+ $output = theme('table', array(
+ 'header' => $proposal_header,
+ 'rows' => $proposal_rows
+ ));
+ return $output;
+}
+/******************************************************************************/
+/************************** PROPOSAL APPROVAL FORM ****************************/
+/******************************************************************************/
+function om_flowsheet_proposal_approval_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
+ {
+ $project_guide_name = "Not Entered";
+ } //$proposal_data->project_guide_name == NULL
+ else
+ {
+ $project_guide_name = $proposal_data->project_guide_name;
+ }
+ if ($proposal_data->project_guide_email_id == "NULL" || $proposal_data->project_guide_email_id == "")
+ {
+ $project_guide_email_id = "Not Entered";
+ } //$proposal_data->project_guide_email_id == NULL
+ else
+ {
+ $project_guide_email_id = $proposal_data->project_guide_email_id;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#size' => 250,
+ '#title' => t('Student name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['contributor_contact_no'] = array(
+ '#title' => t('Contact No.'),
+ '#type' => 'item',
+ '#markup' => $proposal_data->contact_no,
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('om version'),
+ '#markup' => $proposal_data->version
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide'),
+ '#markup' => $project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide email'),
+ '#markup' => $project_guide_email_id
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['dwsim_flowsheet_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of the DWSIM flowsheet'),
+ '#markup' => $proposal_data->dwsim_flowsheet_name,
+ );
+ $headers = array(
+ "User defined compound",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$proposal_data->process_development_compound_name}",
+ "{$proposal_data->process_development_compound_cas_number}"
+ );
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
+ $form['process_development_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#markup' => $prodata
+ );
+ /*
+ $form['process_development_compound_cas_number'] = array(
+ '#type' => 'item',
+ '#title' => t('CAS Number of compound for which process development is carried out'),
+ '#markup' => $proposal_data->process_development_compound_cas_number
+ );*/
+ $form['approval'] = array(
+ '#type' => 'radios',
+ '#title' => t('om flowsheeting proposal'),
+ '#options' => array(
+ '1' => 'Approve',
+ '2' => 'Disapprove'
+ ),
+ '#required' => TRUE
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reason for disapproval'),
+ '#attributes' => array(
+ 'placeholder' => t('Enter reason for disapproval in minimum 30 characters '),
+ 'cols' => 50,
+ 'rows' => 4
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="approval"]' => array(
+ 'value' => '2'
+ )
+ )
+ )
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+function om_flowsheet_proposal_approval_form_validate($form, &$form_state)
+{
+ if ($form_state['values']['approval'] == 2)
+ {
+ if ($form_state['values']['message'] == '')
+ {
+ form_set_error('message', t('Reason for disapproval could not be empty'));
+ } //$form_state['values']['message'] == ''
+ } //$form_state['values']['approval'] == 2
+}
+function om_flowsheet_proposal_approval_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ // $proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ if ($form_state['values']['approval'] == 1)
+ {
+ $query = "UPDATE {om_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 1 WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":proposal_id" => $proposal_id
+ );
+ db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['om_flowsheet_proposal_approved']['proposal_id'] = $proposal_id;
+ $params['om_flowsheet_proposal_approved']['user_id'] = $proposal_data->uid;
+ $params['om_flowsheet_proposal_approved']['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
+ );
+ if (!drupal_mail('om_flowsheet', 'om_flowsheet_proposal_approved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('om flowsheeting proposal No. ' . $proposal_id . ' approved. User has been notified of the approval.', 'status');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 1
+ else if ($form_state['values']['approval'] == 2)
+ {
+ $query = "UPDATE {om_flowsheet_proposal} SET approver_uid = :uid, approval_date = :date, approval_status = 2, dissapproval_reason = :dissapproval_reason WHERE id = :proposal_id";
+ $args = array(
+ ":uid" => $user->uid,
+ ":date" => time(),
+ ":dissapproval_reason" => $form_state['values']['message'],
+ ":proposal_id" => $proposal_id
+ );
+ $result = db_query($query, $args);
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['om_flowsheet_proposal_disapproved']['proposal_id'] = $proposal_id;
+ $params['om_flowsheet_proposal_disapproved']['user_id'] = $proposal_data->uid;
+ $params['om_flowsheet_proposal_disapproved']['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
+ );
+ if (!drupal_mail('om_flowsheet', 'om_flowsheet_proposal_disapproved', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('om flowsheeting proposal No. ' . $proposal_id . ' dis-approved. User has been notified of the dis-approval.', 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //$form_state['values']['approval'] == 2
+}
+/******************************************************************************/
+/*************************** PROPOSAL STATUS FORM *****************************/
+/******************************************************************************/
+function om_flowsheet_proposal_status_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ $form['contributor_name'] = array(
+ '#type' => 'item',
+ '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid),
+ '#size' => 250,
+ '#title' => t('Student name')
+ );
+ $form['student_email_id'] = array(
+ '#title' => t('Student Email'),
+ '#type' => 'item',
+ '#markup' => user_load($proposal_data->uid)->mail,
+ '#title' => t('Email')
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+0',
+ '#datepicker_options' => array(
+ 'maxDate' => 0
+ ),
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->university,
+ '#title' => t('University/Institute')
+ );
+ $form['country'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->country,
+ '#title' => t('Country')
+ );
+ $form['all_state'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->state,
+ '#title' => t('State')
+ );
+ $form['city'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->city,
+ '#title' => t('City')
+ );
+ $form['pincode'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->pincode,
+ '#title' => t('Pincode/Postal code')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('om version'),
+ '#markup' => $proposal_data->version
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide'),
+ '#markup' => $proposal_data->project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Project guide email'),
+ '#markup' => $proposal_data->project_guide_email_id
+ );
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['dwsim_flowsheet_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of the DWSIM flowsheet'),
+ '#markup' => $proposal_data->dwsim_flowsheet_name,
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#markup' => $proposal_data->process_development_compound_name
+ );
+ $form['process_development_compound_cas_number'] = array(
+ '#type' => 'item',
+ '#title' => t('CAS Number of compound for which process development is carried out'),
+ '#markup' => $proposal_data->process_development_compound_cas_number
+ );
+ $proposal_status = '';
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ $proposal_status = t('Pending');
+ break;
+ case 1:
+ $proposal_status = t('Approved');
+ break;
+ case 2:
+ $proposal_status = t('Dis-approved');
+ break;
+ case 3:
+ $proposal_status = t('Completed');
+ break;
+ default:
+ $proposal_status = t('Unkown');
+ break;
+ } //$proposal_data->approval_status
+
+ $form['proposal_status'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_status,
+ '#title' => t('Proposal Status')
+ );
+ if ($proposal_data->approval_status == 0)
+ {
+ $form['approve'] = array(
+ '#type' => 'item',
+ '#markup' => l('Click here', 'flowsheeting-project/manage-proposal/approve/' . $proposal_id),
+ '#title' => t('Approve')
+ );
+ } //$proposal_data->approval_status == 0
+ if ($proposal_data->approval_status == 1)
+ {
+ $form['completed'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Completed'),
+ '#description' => t('Check if user has provided all the required files and pdfs.')
+ );
+ } //$proposal_data->approval_status == 1
+ if ($proposal_data->approval_status == 2)
+ {
+ $form['message'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->message,
+ '#title' => t('Reason for disapproval')
+ );
+ } //$proposal_data->approval_status == 2
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'markup',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal/all')
+ );
+ return $form;
+}
+function om_flowsheet_proposal_status_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ /* set the book status to completed */
+ if ($form_state['values']['completed'] == 1)
+ {
+ $up_query = "UPDATE om_flowsheet_proposal SET approval_status = :approval_status , actual_completion_date = :expected_completion_date WHERE id = :proposal_id";
+ $args = array(
+ ":approval_status" => '3',
+ ":proposal_id" => $proposal_id,
+ ":expected_completion_date" => time()
+ );
+ $result = db_query($up_query, $args);
+ CreateReadmeFileomFlowsheetingProject($proposal_id);
+ if (!$result)
+ {
+ drupal_set_message('Error in update status', 'error');
+ return;
+ } //!$result
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = $user->mail . ', ' . variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['om_flowsheet_proposal_completed']['proposal_id'] = $proposal_id;
+ $params['om_flowsheet_proposal_completed']['user_id'] = $proposal_data->uid;
+ $params['om_flowsheet_proposal_completed']['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
+ );
+ if (!drupal_mail('om_flowsheet', 'om_flowsheet_proposal_completed', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message('Congratulations! om flowsheeting proposal has been marked as completed. User has been notified of the completion.', 'status');
+ } //$form_state['values']['completed'] == 1
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+}
+/******************************************************************************/
+/**************************** PROPOSAL EDIT FORM ******************************/
+/******************************************************************************/
+function om_flowsheet_proposal_edit_form($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ $user_data = user_load($proposal_data->uid);
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Mrs' => 'Mrs',
+ 'Ms' => 'Ms'
+ ),
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->name_title
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the Proposer'),
+ '#size' => 30,
+ '#maxlength' => 250,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->contributor_name
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->version,
+ '#options' => _df_list_of_software_version()
+ );
+ $form['student_email_id'] = array(
+ '#type' => 'item',
+ '#title' => t('Email'),
+ '#markup' => $user_data->mail
+ );
+ $form['contributor_contact_no'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Contact No.'),
+ '#size' => 10,
+ '#default_value' => $proposal_data->contact_no
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => $proposal_data->month_year_of_degree,
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960:+22',
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#default_value' => $proposal_data->university
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide'),
+ '#size' => 250,
+ '#default_value' => $proposal_data->project_guide_name
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide email'),
+ '#size' => 30,
+ '#default_value' => $proposal_data->project_guide_email_id
+ );
+ $form['project_guide_university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Guide University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#default_value' => $proposal_data->project_guide_university
+ );
+ if($proposal_data->country == 'India'){
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#default_value' => $proposal_data->country,
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#default_value' => $proposal_data->state,
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+}
+else{
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Country(Other than India)'),
+ '#size' => 100,
+ '#default_value' => $proposal_data->country,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#default_value' => $proposal_data->state,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City(Other than India)'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#default_value' => $proposal_data->city,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+}
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#default_value' => $proposal_data->pincode,
+ '#attributes' => array(
+ 'placeholder' => 'Insert pincode of your city/ village....'
+ )
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Title of the Flowsheet Project'),
+ '#size' => 300,
+ '#maxlength' => 350,
+ '#required' => TRUE,
+ '#default_value' => $proposal_data->project_title
+ );
+ $form['dwsim_flowsheet_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('The name of DWSIM flowsheet along with its serial number.'),
+ '#default_value' => $proposal_data->dwsim_flowsheet_name,
+ '#validated' => TRUE,
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference of the Flowsheet Project'),
+ '#size' => 300,
+ '#maxlength' => 350,
+ '#default_value' => $proposal_data->reference
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#size' => 50,
+ '#default_value' => $proposal_data->process_development_compound_name
+ );
+ $form['process_development_compound_cas_no'] = array(
+ '#type' => 'textfield',
+ '#title' => t('CAS number for compound which process development is carried out'),
+ '#size' => 50,
+ '#default_value' => $proposal_data->process_development_compound_cas_number
+
+ );
+ $form['delete_proposal'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete Proposal')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+/*
+function om_flowsheet_proposal_edit_form_validate($form, &$form_state)
+{
+$proposal_id = (int) arg(3);
+// check before delete proposal
+if ($form_state['values']['delete_proposal'] == 1)
+{
+//$experiment_q = db_query("SELECT * FROM {om_flowsheet_experiment} WHERE proposal_id = %d", $proposal_id);
+$query = db_select('om_flowsheet_user_defined_compound');
+$query->fields('om_flowsheet_user_defined_compound');
+$query->condition('proposal_id', $proposal_id);
+$experiment_q = $query->execute();
+while ($experiment_data = $experiment_q->fetchObject())
+{
+//$solution_q = db_query("SELECT * FROM {om_flowsheet_solution} WHERE experiment_id = %d", $experiment_data->id);
+$query = db_select('om_flowsheet_user_defined_compound');
+$query->fields('om_flowsheet_user_defined_compound');
+$query->condition('proposal_id', $proposal_id);
+$solution_q = $query->execute();
+if ($solution_q->fetchObject())
+{
+form_set_error('', t('Cannot delete proposal since there are solutions already uploaded. Use the "Bulk Manage" interface to delete this proposal'));
+} //$solution_q->fetchObject()
+} //$experiment_data = $experiment_q->fetchObject()
+} //$form_state['values']['delete_proposal'] == 1
+return;
+}*/
+function om_flowsheet_proposal_edit_form_submit($form, &$form_state)
+{
+ global $user;
+ /* get current proposal */
+ $proposal_id = (int) arg(3);
+ // $proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ }
+ /* delete proposal */
+ if ($form_state['values']['delete_proposal'] == 1)
+ {
+ /* sending email */
+ $user_data = user_load($proposal_data->uid);
+ $email_to = $user_data->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['om_flowsheet_proposal_deleted']['proposal_id'] = $proposal_id;
+ $params['om_flowsheet_proposal_deleted']['user_id'] = $proposal_data->uid;
+ //$params['om_flowsheet_proposal_deleted']['file_name'] = $_FILES['files']['name'][$file_form_name];
+ $params['om_flowsheet_proposal_deleted']['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
+ );
+ if (!drupal_mail('om_flowsheet', 'om_flowsheet_proposal_deleted', $email_to, user_preferred_language($user), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('om Flowsheeting proposal has been deleted.'), 'status');
+ //db_query("DELETE FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ if (om_rrmdir_project($proposal_id) == TRUE)
+ {
+ $query = db_delete('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $num_deleted = $query->execute();
+ drupal_set_message(t('Proposal Deleted'), 'status');
+ drupal_goto('flowsheeting-project/manage-proposal');
+ return;
+ } //om_rrmdir_project($proposal_id) == TRUE
+ } //$form_state['values']['delete_proposal'] == 1
+ /* update proposal */
+ $v = $form_state['values'];
+ $project_title = $v['project_title'];
+ $proposar_name = $v['name_title'] . ' ' . $v['contributor_name'];
+ $university = $v['university'];
+ $directory_names = _om_df_dir_name($project_title, $proposar_name);
+ if (om_DF_RenameDir($proposal_id, $directory_names))
+ {
+ $directory_name = $directory_names;
+ } //LM_RenameDir($proposal_id, $directory_names)
+ else
+ {
+ return;
+ }
+ $query = "UPDATE om_flowsheet_proposal SET
+ name_title=:name_title,
+ contributor_name=:contributor_name,
+ version = :version,
+ university=:university,
+ city=:city,
+ pincode=:pincode,
+ state=:state,
+ project_title=:project_title,
+ reference=:reference,
+ directory_name=:directory_name,
+ project_guide_university=:project_guide_university,
+ project_guide_email_id=:project_guide_email_id,
+ project_guide_name=:project_guide_name,
+ month_year_of_degree=:month_year_of_degree,
+ process_development_compound_name=:process_development_compound_name,
+ process_development_compound_cas_number=:process_development_compound_cas_number
+ WHERE id=:proposal_id";
+ $args = array(
+ ':name_title' => $v['name_title'],
+ ':contributor_name' => $v['contributor_name'],
+ ':version' => $v['version'],
+ ':university' => $v['university'],
+ ':city' => $v['city'],
+ ':pincode' => $v['pincode'],
+ ':state' => $v['all_state'],
+ ':project_title' => $project_title,
+ ':reference' => $v['reference'],
+ ':directory_name' => $directory_name,
+ ':project_guide_university' => $v['project_guide_university'],
+ ':project_guide_email_id' => $v['project_guide_email_id'],
+ ':project_guide_name' => $v['project_guide_name'],
+ ':month_year_of_degree' => $v['month_year_of_degree'],
+ ':process_development_compound_name' => $v['process_development_compound_name'],
+ ':process_development_compound_cas_number' => $v['process_development_compound_cas_no'],
+ ':proposal_id' => $proposal_id
+ );
+ $result = db_query($query, $args);
+ drupal_set_message(t('Proposal Updated'), 'status');
+}
diff --git a/om_flowsheet.info b/om_flowsheet.info
new file mode 100755
index 0000000..7a24b8c
--- /dev/null
+++ b/om_flowsheet.info
@@ -0,0 +1,7 @@
+name = "OM Flowsheet"
+description = "Flowsheeting Project, FOSSEE, IIT Bombay"
+package = FOSSEE
+version = "7.x"
+core = "7.x"
+
+;scripts[] = js/jquery-1.4.1.min.js
diff --git a/om_flowsheet.module b/om_flowsheet.module
new file mode 100755
index 0000000..5867668
--- /dev/null
+++ b/om_flowsheet.module
@@ -0,0 +1,974 @@
+ 'Flowsheet Proposal Form',
+ 'description' => 'Flowsheet Proposal Form Proposal Form',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet create proposal'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal'] = array(
+ 'title' => 'Manage Flowsheet Proposals',
+ 'description' => 'Manage Flowsheet Proposals',
+ 'page callback' => 'om_flowsheet_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/pending'] = array(
+ 'title' => 'Pending Proposals',
+ 'description' => 'Pending om flowsheet Proposals Queue',
+ 'page callback' => 'om_flowsheet_proposal_pending',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/all'] = array(
+ 'title' => 'All Proposals',
+ 'description' => 'All Proposals',
+ 'page callback' => 'om_flowsheet_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 4,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/approve'] = array(
+ 'title' => 'Approve Proposal',
+ 'description' => 'Approve Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/solution-proposal-approve'] = array(
+ 'title' => 'Approve Solution Proposal',
+ 'description' => 'Approve Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_solution_proposal_approval_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_solution_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/edit'] = array(
+ 'title' => 'Edit Proposal',
+ 'description' => 'Edit Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_proposal_edit_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet manage proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/manage-proposal/status'] = array(
+ 'title' => 'Proposal Status',
+ 'description' => 'Proposal Status',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_proposal_status_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet approve proposal'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['flowsheeting-project/show-proposal'] = array(
+ 'title' => 'om flowsheet Solution Proposal',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_solution_proposal_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet propose solution'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'solution_proposal.inc'
+ );
+ /* CODE REVIEW */
+ $items['flowsheeting-project/code-approval'] = array(
+ 'title' => 'LM Manage Code Approval',
+ 'description' => 'Manage Code Approval',
+ 'page callback' => 'om_flowsheet_code_approval',
+ 'access arguments' => array(
+ 'om flowsheet approve code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'code_approval.inc'
+ );
+ $items['flowsheeting-project/abstract-approval/approve'] = array(
+ 'title' => 'Code Approval',
+ 'description' => 'Code Approval',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_abstract_approval_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet approve code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 1,
+ 'file' => 'code_approval.inc'
+ );
+ $items['flowsheeting-project/abstract-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_abstract_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet bulk manage abstract'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'abstract_bulk_approval.inc'
+ );
+ $items['flowsheeting-project/code-approval/bulk'] = array(
+ 'title' => 'Bulk Manage',
+ 'description' => 'Bulk Mangage',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_bulk_approval_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet bulk manage abstract'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 2,
+ 'file' => 'bulk_approval.inc'
+ );
+ $items['flowsheeting-project/code-approval/upload'] = array(
+ 'title' => 'Upload Code',
+ 'description' => 'Admin Upload',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_bulk_upload_code_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet bulk manage abstract'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'bulk_upload_code.inc'
+ );
+ $items['flowsheeting-project/code-approval/notes'] = array(
+ 'title' => 'Notes for Reviewers',
+ 'description' => 'Notes for Reviewers',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_lab_notes_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet bulk manage abstract'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'weight' => 4,
+ 'file' => 'notes.inc'
+ );
+ /* CODE UPLOAD */
+ $items['flowsheeting-project/abstract-code'] = array(
+ 'title' => 'Abstract and Flowsheet Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'om_flowsheet_abstract',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'om flowsheet upload code'
+ ),
+ 'file' => 'upload_code.inc'
+ );
+ $items['flowsheeting-project/abstract-code/flowsheet-project-list'] = array(
+ 'title' => 'Flowsheet project',
+ 'description' => 'List Experiments',
+ 'page callback' => 'om_flowsheet_abstract',
+ 'access arguments' => array(
+ 'om flowsheet upload code'
+ ),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 1
+ );
+ $items['flowsheeting-project/abstract-code/upload'] = array(
+ 'title' => 'Abstract and Flowsheet Submission',
+ 'description' => 'Abstract Submission',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_upload_abstract_code_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet upload code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'upload_code.inc',
+ 'weight' => 2
+ );
+ $items['flowsheeting-project/abstract-code/delete'] = array(
+ 'title' => 'Delete Solution',
+ 'description' => 'Delete Solution',
+ 'page callback' => 'om_flowsheet_upload_code_delete',
+ 'access arguments' => array(
+ 'om flowsheet upload code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'upload_code_delete.inc'
+ );
+ /* CODE DOWNLOADS */
+ $items['flowsheeting-project/download/file'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_solution_file',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/download/solution'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_solution',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_experiment',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/download/lab'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_lab',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ $items['flowsheeting-project/full-download/experiment'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_full_experiment',
+ 'access arguments' => array(
+ 'om flowsheet approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ $items['flowsheeting-project/full-download/project'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'om_flowsheet_download_full_project',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ /* COMPLETED om flowsheetS */
+ $items['flowsheeting-project/completed-flowsheet'] = array(
+ 'title' => 'Completed Flowsheets',
+ 'page callback' => 'om_flowsheet_completed_proposals_all',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'file' => 'flowsheet_details.inc'
+ );
+ /* LABS IN PROGRESS */
+ $items['flowsheeting-project/flowsheet-progress'] = array(
+ 'title' => 'Flowsheets in Progress',
+ 'page callback' => 'om_flowsheet_progress_all',
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'file' => 'flowsheet_details.inc'
+ );
+ /* DOWNLOAD FOR EVERYONE */
+ $items['flowsheeting-project/om-flowsheet-run'] = array(
+ 'title' => 'Download Codes',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_run_form'
+ ),
+ 'access arguments' => array(
+ 'om flowsheet download code'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'run.inc'
+ );
+ $items['flowsheeting-project/download/user-defined-compound-file'] = array(
+ 'title' => 'Download user defined compound file',
+ 'description' => 'Download user defined compound',
+ 'page callback' => 'om_flowsheet_download_user_defined_compound',
+ 'access arguments' => array(
+ 'download code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'download.inc'
+ );
+ /* LATEX SCRIPT */
+ $items['flowsheeting-project/generate-lab'] = array(
+ 'title' => 'Generate Lab',
+ 'description' => 'Generate Lab From Latex Script',
+ 'page callback' => 'om_flowsheet_download_lab_pdf',
+ 'access arguments' => array(
+ 'om flowsheet generate lab'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ $items['flowsheeting-project/delete-lab'] = array(
+ 'title' => 'Delete Lab PDF',
+ 'description' => 'Delete Lab PDF',
+ 'page callback' => 'om_flowsheet_delete_lab_pdf',
+ 'access arguments' => array(
+ 'om flowsheet approve code'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'latex.inc'
+ );
+ /* ADMIN SETTINGS */
+ $items['admin/settings/om-flowsheet'] = array(
+ 'title' => 'om flowsheet Settings',
+ 'description' => 'om flowsheet Settings',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'om_flowsheet_settings_form'
+ ),
+ 'access arguments' => array(
+ 'administer om flowsheet'
+ ),
+ 'type' => MENU_NORMAL_ITEM,
+ 'file' => 'settings.inc'
+ );
+ /* AJAX REQUEST */
+ $items["lab-bulk-manage-exp/ajax"] = array(
+ "title" => "Ajax callbacks",
+ "page callback" => "lab_bulk_manage_exp_ajax",
+ "access arguments" => array(
+ "om flowsheet bulk manage abstract"
+ ),
+ "type" => MENU_CALLBACK,
+ 'file' => 'bulk_approval.inc'
+ );
+ $items['flowsheeting-project/certificates'] = array(
+ 'title' => 'List of Flowsheet Certificates',
+ 'description' => 'List of flowsheet Certificates',
+ 'page callback' => '_list_flowsheet_certificates',
+ 'access arguments' => array(
+ 'list flowsheet certificates'
+ ),
+ 'file' => 'pdf/list_flowsheet_certificate.inc'
+ );
+ $items['flowsheeting-project/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['flowsheeting-project/certificates-custom'] = array(
+ 'title' => 'List of Flowsheet Custom Certificates',
+ 'description' => 'List of flowsheet Custom Certificates',
+ 'page callback' => '_list_flowsheet_custom_certificates',
+ 'access arguments' => array(
+ 'list flowsheet custom certificates'
+ ),
+ 'file' => 'pdf/list_mentor_certificates.inc'
+ );
+ $items['flowsheeting-project/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["flowsheeting-project/certificates/verify"] = array(
+ "title" => "Certificate Verification",
+ "page callback" => "verify_certificates",
+ "access arguments" => array(
+ "verify certificates"
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'pdf/verify_certificates.inc'
+ );
+ return $items;
+}
+/**
+ * Implementation of hook_perm().
+ */
+function om_flowsheet_permission()
+{
+ return array(
+ 'om flowsheet create proposal' => array(
+ 'title' => t('om flowsheet create proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet manage proposal' => array(
+ 'title' => t('om flowsheet manage proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet edit proposal' => array(
+ 'title' => t('om flowsheet edit proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet approve proposal' => array(
+ 'title' => t('om flowsheet approve proposal'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet propose solution' => array(
+ 'title' => t('om flowsheet propose solution'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet approve abstract' => array(
+ 'title' => t('om flowsheet approve code'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet bulk manage abstract' => array(
+ 'title' => t('om flowsheet bulk manage abstract'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet bulk delete code' => array(
+ 'title' => t('om flowsheet bulk delete code'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet upload abstract' => array(
+ 'title' => t('om flowsheet upload code'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet download abstract' => array(
+ 'title' => t('om flowsheet download code'),
+ 'restrict access' => TRUE
+ ),
+ 'administer om flowsheet' => array(
+ 'title' => t('administer om flowsheet'),
+ 'restrict access' => TRUE
+ ),
+ 'om flowsheet generate abstract' => array(
+ 'title' => t('om flowsheet generate abstract'),
+ 'restrict access' => TRUE
+ ),
+ "list flowsheet certificates" => array(
+ "title" => t("list flowsheet certificates"),
+ "description" => t("Allows users to list flowsheet certificates.")
+ ),
+ "list flowsheet custom certificates" => array(
+ "title" => t("list flowsheet custom certificates"),
+ "description" => t("Allows users to list flowsheet custom certificates.")
+ ),
+ "generate pdf" => array(
+ "title" => t("Generate pdf"),
+ "description" => t("Allows users to Generate pdf.")
+ )
+ );
+ // return array('om flowsheet create proposal', 'om flowsheet manage proposal', 'om flowsheet edit proposal', 'om flowsheet approve proposal', 'om flowsheet propose solution', 'om flowsheet approve code', 'om flowsheet bulk manage abstract', 'om flowsheet bulk delete code', 'om flowsheet upload code', 'om flowsheet download code', 'administer om flowsheet', 'om flowsheet generate lab');
+}
+/* AJAX CALLS */
+function om_flowsheet_ajax()
+{
+ $query_type = arg(2);
+ if ($query_type == 'chapter_title')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ //$chapter_q = db_query("SELECT * FROM {om_flowsheet_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
+ $query = db_select('om_flowsheet_chapter');
+ $query->fields('om_flowsheet_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if ($chapter_data = $chapter_q->fetchObject())
+ {
+ echo $chapter_data->name;
+ return;
+ } //$chapter_data = $chapter_q->fetchObject()
+ } //$query_type == 'chapter_title'
+ else if ($query_type == 'example_exists')
+ {
+ $chapter_number = arg(3);
+ $preference_id = arg(4);
+ $example_number = arg(5);
+ $chapter_id = 0;
+ $query = db_select('om_flowsheet_chapter');
+ $query->fields('om_flowsheet_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if (!$chapter_data = $chapter_q->fetchObject())
+ {
+ echo '';
+ return;
+ } //!$chapter_data = $chapter_q->fetchObject()
+ else
+ {
+ $chapter_id = $chapter_data->id;
+ }
+ $query = db_select('om_flowsheet_example');
+ $query->fields('om_flowsheet_example');
+ $query->condition('chapter_id', $chapter_id);
+ $query->condition('number', $example_number);
+ $query->range(0, 1);
+ $example_q = $query->execute();
+ if ($example_data = $example_q->fetchObject())
+ {
+ if ($example_data->approval_status == 1)
+ echo 'Warning! Solution already approved. You cannot upload the same solution again.';
+ else
+ echo 'Warning! Solution already uploaded. Delete the solution and reupload it.';
+ return;
+ } //$example_data = $example_q->fetchObject()
+ } //$query_type == 'example_exists'
+ echo '';
+}
+/*************************** VALIDATION FUNCTIONS *****************************/
+function om_flowsheet_check_valid_filename($file_name)
+{
+ if (!preg_match('/^[0-9a-zA-Z\.\_]+$/', $file_name))
+ return FALSE;
+ else if (substr_count($file_name, ".") > 1)
+ return FALSE;
+ else
+ return TRUE;
+}
+function om_flowsheet_check_name($name = '')
+{
+ if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
+ return FALSE;
+ else
+ return TRUE;
+}
+function om_flowsheet_check_code_number($number = '')
+{
+ if (!preg_match('/^[0-9]+$/', $number))
+ return FALSE;
+ else
+ return TRUE;
+}
+function om_flowsheet_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'openmodelica_uploads/om_flowsheet_uploads/';
+}
+/************************* USER VERIFICATION FUNCTIONS ************************/
+function om_flowsheet_get_proposal()
+{
+ global $user;
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE solution_provider_uid = ".$user->uid." AND solution_status = 2 ORDER BY id DESC LIMIT 1");
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if (!$proposal_data)
+ {
+ drupal_set_message("You do not have any approved om Flowsheet proposal. Please propose the flowsheet proposal", 'error');
+ drupal_goto('');
+ } //!$proposal_data
+ switch ($proposal_data->approval_status)
+ {
+ case 0:
+ drupal_set_message(t('Proposal is awaiting approval.'), 'status');
+ return FALSE;
+ case 1:
+ return $proposal_data;
+ case 2:
+ drupal_set_message(t('Proposal has been dis-approved.'), 'error');
+ return FALSE;
+ case 3:
+ drupal_set_message(t('Proposal has been marked as completed.'), 'status');
+ return FALSE;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ return FALSE;
+ } //$proposal_data->approval_status
+ return FALSE;
+}
+/*************************************************************************/
+/***** Function To convert only first charater of string in uppercase ****/
+/*************************************************************************/
+function om_flowsheet_ucname($string)
+{
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+function _om_df_sentence_case($string)
+{
+ $string = ucwords(strtolower($string));
+ foreach (array(
+ '-',
+ '\''
+ ) as $delimiter)
+ {
+ if (strpos($string, $delimiter) !== false)
+ {
+ $string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+ } //strpos($string, $delimiter) !== false
+ } //array( '-', '\'' ) as $delimiter
+ return $string;
+}
+function _df_list_of_om_compound()
+{
+ $om_compound = array();
+ $query = db_select('om_flowsheet_compounds_from_om');
+ $query->fields('om_flowsheet_compounds_from_om');
+ $query->orderBy('id', 'ASC');
+ $om_compound_list = $query->execute();
+ while ($om_compound_list_data = $om_compound_list->fetchObject())
+ {
+ $om_compound[$om_compound_list_data->compound] = $om_compound_list_data->compound;
+ } //$om_compound_list_data = $om_compound_list->fetchObject()
+ return $om_compound;
+}
+function _df_list_of_unit_operations()
+{
+ $om_unit_operations = array();
+ $query = db_select('om_flowsheet_unit_operations');
+ $query->fields('om_flowsheet_unit_operations');
+ $query->orderBy('id', 'ASC');
+ $om_unit_operations_list = $query->execute();
+ while ($om_unit_operations_list_data = $om_unit_operations_list->fetchObject())
+ {
+ $om_unit_operations[$om_unit_operations_list_data->unit_operations] = $om_unit_operations_list_data->unit_operations;
+ } //$om_unit_operations_list_data = $om_unit_operations_list->fetchObject()
+ return $om_unit_operations;
+}
+function _df_list_of_thermodynamic_packages()
+{
+ $om_thermodynamic_packages = array();
+ $query = db_select('om_flowsheet_thermodynamic_packages');
+ $query->fields('om_flowsheet_thermodynamic_packages');
+ $query->orderBy('thermodynamic_packages', 'ASC');
+ $om_thermodynamic_packages_list = $query->execute();
+ while ($om_thermodynamic_packages_list_data = $om_thermodynamic_packages_list->fetchObject())
+ {
+ $om_thermodynamic_packages[$om_thermodynamic_packages_list_data->thermodynamic_packages] = $om_thermodynamic_packages_list_data->thermodynamic_packages;
+ } //$om_thermodynamic_packages_list_data = $om_thermodynamic_packages_list->fetchObject()
+ return $om_thermodynamic_packages;
+}
+function _df_list_of_logical_block()
+{
+ $om_logical_block = array();
+ $query = db_select('om_flowsheet_logical_block');
+ $query->fields('om_flowsheet_logical_block');
+ $query->orderBy('id', 'ASC');
+ $om_logical_block_list = $query->execute();
+ while ($om_logical_block_list_data = $om_logical_block_list->fetchObject())
+ {
+ $om_logical_block[$om_logical_block_list_data->logical_block] = $om_logical_block_list_data->logical_block;
+ } //$om_logical_block_list_data = $om_logical_block_list->fetchObject()
+ return $om_logical_block;
+}
+function _om_df_list_of_states()
+{
+ $states = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_states_of_india');
+ $query->fields('list_states_of_india');
+ //$query->orderBy('', '');
+ $states_list = $query->execute();
+ while ($states_list_data = $states_list->fetchObject())
+ {
+ $states[$states_list_data->state] = $states_list_data->state;
+ } //$states_list_data = $states_list->fetchObject()
+ return $states;
+}
+function _om_df_list_of_cities()
+{
+ $city = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_cities_of_india');
+ $query->fields('list_cities_of_india');
+ $query->orderBy('city', 'ASC');
+ $city_list = $query->execute();
+ while ($city_list_data = $city_list->fetchObject())
+ {
+ $city[$city_list_data->city] = $city_list_data->city;
+ } //$city_list_data = $city_list->fetchObject()
+ return $city;
+}
+function _om_df_list_of_pincodes()
+{
+ $pincode = array(
+ 0 => '-Select-'
+ );
+ $query = db_select('list_of_all_india_pincode');
+ $query->fields('list_of_all_india_pincode');
+ $query->orderBy('pincode', 'ASC');
+ $pincode_list = $query->execute();
+ while ($pincode_list_data = $pincode_list->fetchObject())
+ {
+ $pincode[$pincode_list_data->pincode] = $pincode_list_data->pincode;
+ } //$pincode_list_data = $pincode_list->fetchObject()
+ return $pincode;
+}
+function _om_df_list_of_departments()
+{
+ $department = array();
+ $query = db_select('list_of_departments');
+ $query->fields('list_of_departments');
+ $query->orderBy('id', 'DESC');
+ $department_list = $query->execute();
+ while ($department_list_data = $department_list->fetchObject())
+ {
+ $department[$department_list_data->department] = $department_list_data->department;
+ } //$department_list_data = $department_list->fetchObject()
+ return $department;
+}
+function _om_df_list_of_software_version()
+{
+ $software_version = array();
+ $query = db_select('om_flowsheet_version');
+ $query->fields('om_flowsheet_version');
+ $query->orderBy('id', 'ASC');
+ $software_version_list = $query->execute();
+ while ($software_version_list_data = $software_version_list->fetchObject())
+ {
+ $software_version[$software_version_list_data->om_version] = $software_version_list_data->om_version;
+ } //$software_version_list_data = $software_version_list->fetchObject()
+ return $software_version;
+}
+function _om_df_dir_name($project, $proposar_name)
+{
+
+ $project_title = ucname($project);
+ $proposar_name = ucname($proposar_name);
+ $dir_name = $project_title . ' By ' . $proposar_name;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", str_replace("/", " ", $dir_name)));
+ return $directory_name;
+}
+function om_flowsheet_document_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'openmodelica_uploads/om_flowsheet_uploads/';
+}
+function om_DF_RenameDir($proposal_id, $dir_name)
+{
+ $proposal_id = $proposal_id;
+ $dir_name = $dir_name;
+ $query = db_query("SELECT directory_name,id FROM om_flowsheet_proposal WHERE id = :proposal_id", array(
+ ':proposal_id' => $proposal_id
+ ));
+ $result = $query->fetchObject();
+ if ($result != NULL)
+ {
+ $files = scandir(om_flowsheet_path());
+ $files_id_dir = om_flowsheet_path() . $result->id;
+ //var_dump($files);die;
+ $file_dir = om_flowsheet_path() . $result->directory_name;
+ if (is_dir($file_dir))
+ {
+ $new_directory_name = rename(om_flowsheet_path() . $result->directory_name, om_flowsheet_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($file_dir)
+ else if (is_dir($files_id_dir))
+ {
+ $new_directory_name = rename(om_flowsheet_path() . $result->id, om_flowsheet_path() . $dir_name);
+ return $new_directory_name;
+ } //is_dir($files_id_dir)
+ else
+ {
+ drupal_set_message('Directory not available for rename.');
+ return;
+ }
+ } //$result != NULL
+ else
+ {
+ drupal_set_message('Project directory name not present in databse');
+ return;
+ }
+ //var_dump($files);die;
+ /* if ($files != NULL)
+ {
+ $new_directory_name = rename(om_flowsheet_path() . $result->directory_name, om_flowsheet_path() . $dir_name) or drupal_set_message("Unable to rename folder");
+ }
+ else
+ {
+ $new_directory_name = 'Can not rename the directory. Directory not present';
+ }*/
+ return;
+}
+function CreateReadmeFileomFlowsheetingProject($proposal_id)
+{
+ $result = db_query("
+ SELECT * from om_flowsheet_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = om_flowsheet_path();
+ $readme_file = fopen($root_path . $proposal_data->directory_name . "/README.txt", "w") or die("Unable to open file!");
+ $txt = "";
+ $txt .= "About the flowsheet";
+ $txt .= "\n" . "\n";
+ $txt .= "Title Of The Flowsheet Project: " . $proposal_data->project_title . "\n";
+ $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n";
+ $txt .= "University: " . $proposal_data->university . "\n";
+ $txt .= "\n" . "\n";
+ $txt .= "om Flowsheet Project By FOSSEE, IIT Bombay" . "\n";
+ fwrite($readme_file, $txt);
+ fclose($readme_file);
+ return $txt;
+}
+function om_rrmdir_project($prop_id)
+{
+ $proposal_id = $prop_id;
+ $result = db_query("
+ SELECT * from om_flowsheet_proposal WHERE id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ $proposal_data = $result->fetchObject();
+ $root_path = om_flowsheet_document_path();
+ $dir = $root_path . $proposal_data->directory_name;
+ if ($proposal_data->id == $prop_id)
+ {
+ if (is_dir($dir))
+ {
+ $objects = scandir($dir);
+ foreach ($objects as $object)
+ {
+ if ($object != "." && $object != "..")
+ {
+ if (filetype($dir . "/" . $object) == "dir")
+ {
+ rrmdir($dir . "/" . $object);
+ } //filetype($dir . "/" . $object) == "dir"
+ else
+ {
+ unlink($dir . "/" . $object);
+ }
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ $msg = drupal_set_message("Directory deleted successfully");
+ return $msg;
+ } //is_dir($dir)
+ $msg = drupal_set_message("Directory not present");
+ return $msg;
+ } //$proposal_data->id == $prop_id
+ else
+ {
+ $msg = drupal_set_message("Data not found");
+ return $msg;
+ }
+}
+function om_rrmdir($dir)
+{
+ if (is_dir($dir))
+ {
+ $objects = scandir($dir);
+ foreach ($objects as $object)
+ {
+ if ($object != "." && $object != "..")
+ {
+ if (filetype($dir . "/" . $object) == "dir")
+ rrmdir($dir . "/" . $object);
+ else
+ unlink($dir . "/" . $object);
+ } //$object != "." && $object != ".."
+ } //$objects as $object
+ reset($objects);
+ rmdir($dir);
+ } //is_dir($dir)
+}
+function _om_flowsheet_list_of_user_defined_compound($proposal_id)
+{
+ $data = "";
+ //$query = db_select('om_flowsheet_user_defined_compound');
+ //$query->fields('om_flowsheet_user_defined_compound');
+ //$query->condition('proposal_id', $proposal_id, '=');
+ //$query->orderBy('user_defined_compound', 'ASC');
+ $user_defined_compound_list = db_query("SELECT * FROM om_flowsheet_user_defined_compound WHERE proposal_id = :proposal_id", array(":proposal_id" => $proposal_id));
+ $headers = array(
+ "List of user defined compounds used in process flowsheet",
+ "CAS No."
+ );
+ if($user_defined_compound_list){
+ $rows = array();
+ while ($row = $user_defined_compound_list->fetchObject())
+ {
+ $item = array(
+ "{$row->user_defined_compound}",
+ "{$row->cas_no}"
+ );
+ array_push($rows, $item);
+ } //$row = $user_defined_compound_list->fetchObject()
+
+ $data .= theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
+ }else{
+ $data .= "Not entered";
+ }
+ return $data;
+}
diff --git a/proposal.inc b/proposal.inc
new file mode 100755
index 0000000..9f7f849
--- /dev/null
+++ b/proposal.inc
@@ -0,0 +1,622 @@
+uid == 0)
+ {
+ $msg = drupal_set_message(t('It is mandatory to ' . l('login', 'user') . ' on this website to access the flowsheet proposal form. If you are new user please create a new account first.'), 'error');
+ //drupal_goto('om-flowsheet-project');
+ drupal_goto('user');
+ return $msg;
+ } //$user->uid == 0
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
+ $proposal_data = $proposal_q->fetchObject();
+ if ($proposal_data)
+ {
+ if ($proposal_data->approval_status == 0 || $proposal_data->approval_status == 1)
+ {
+ drupal_set_message(t('We have already received your proposal.'), 'status');
+ drupal_goto('');
+ return;
+ } //$proposal_data->approval_status == 0 || $proposal_data->approval_status == 1
+ } //$proposal_data
+ $imp = t('
*This is a mandatory field');
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ $form['name_title'] = array(
+ '#type' => 'select',
+ '#title' => t('Title'),
+ '#options' => array(
+ 'Dr' => 'Dr',
+ 'Prof' => 'Prof',
+ 'Mr' => 'Mr',
+ 'Mrs' => 'Mrs',
+ 'Ms' => 'Ms'
+ ),
+ '#required' => TRUE
+ );
+ $form['contributor_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of the contributor'),
+ '#size' => 250,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your full name.....')
+ ),
+ '#maxlength' => 250,
+ '#required' => TRUE
+ );
+ $form['contributor_contact_no'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Contact No.'),
+ '#size' => 10,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your contact number')
+ ),
+ '#maxlength' => 250
+ );
+ $form['month_year_of_degree'] = array(
+ '#type' => 'date_popup',
+ '#title' => t('Month and year of award of degree'),
+ '#date_label_position' => '',
+ '#description' => '',
+ '#default_value' => '',
+ '#date_format' => 'M-Y',
+ '#date_increment' => 0,
+ '#date_year_range' => '1960: +22',
+
+ '#required' => TRUE
+ );
+ $form['contributor_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of your institute/ university.... '
+ )
+ );
+ $form['project_guide_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide'),
+ '#size' => 250,
+ '#attributes' => array(
+ 'placeholder' => t('Enter full name of project guide')
+ ),
+ '#maxlength' => 250
+ );
+ $form['project_guide_email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project guide email'),
+ '#size' => 30
+ );
+ $form['project_guide_university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Guide University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of the institute/ university of your project guide.... '
+ )
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _df_list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#description' => $imp
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _df_list_of_cities(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ ),
+ '#description' => $imp,
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#required' => False,
+ '#attributes' => array(
+ 'placeholder' => 'Enter pincode....'
+ ),
+ '#required' => TRUE
+ );
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '
'
+ );
+ $form['project_title'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Project Title'),
+ '#size' => 250,
+ '#description' => t('Maximum character limit is 250'),
+ '#required' => TRUE
+ );
+ $form['dwsim_flowsheet_check'] = array(
+ '#type' => 'radios',
+ '#title' => t('Is the proposed OpenModelica flowsheet is from list of Completed DWSIM Flowsheets?'),
+ '#options' => array(
+ '1' => 'Yes',
+ '0' => 'No',
+ ),
+ '#validated' => TRUE,
+ );
+ $form['dwsim_flowsheet_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Enter the exact name of flowsheet along with its serial number.'),
+ '#required' => TRUE,
+ '#description' => t('For example, if you are proposing flowsheet no. 10 from the list of completed DWSIM flowsheet, enter as: "10. Removal of Isopentane in Gasoline Manufacturing Plant"'),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="dwsim_flowsheet_check"]' => array(
+ 'value' => '1'
+ )
+ )
+ ),
+ );
+ $form['reference'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Reference'),
+ '#maxsize' => 250,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Enter reference'
+ )
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _om_df_list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other Version'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used as format "om v2.0"'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="version"]' => array(
+ 'value' => 'Old version'
+ )
+ )
+ )
+ );
+ $form['process_development_compound_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#size' => 50,
+ '#description' => t('Mention the compound name as shown:
+Ex: Ethanol'),
+ '#required' => TRUE
+ );
+ $form['process_development_compound_cas_no'] = array(
+ '#type' => 'textfield',
+ '#title' => t('CAS number for compound which process development is carried out'),
+ '#size' => 50,
+ '#description' => t('Mention the compound CAS No as shown:
+Ex: 64-17-5'),
+ '#required' => TRUE
+ );
+
+ $form['term_condition'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Terms And Conditions'),
+ '#options' => array(
+ 'status' => t('
I agree to the Terms and Conditions')
+ ),
+ '#required' => TRUE
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
+
+/***************************************/
+function om_flowsheet_proposal_form_validate($form, &$form_state)
+{
+ $project_title = $form_state['values']['project_title'];
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('project_title', $project_title);
+ $query->condition(db_or()->condition('approval_status',1)->condition('approval_status',3));
+ $result = $query->execute()->rowCount();
+ if ($result > 0)
+ {
+ form_set_error('project_title', t('Project title name already exists'));
+ return;
+ }
+ /*$query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('project_title', $project_title);
+ $query->condition('approval_status',3);
+ $result1 = $query->execute()->rowCount();
+ if ($result1 > 0)
+ {
+ form_set_error('project_title', t('Project title name already exists'));
+ return;
+ }*/
+ if ($form_state['values']['term_condition'] == '1')
+ {
+ form_set_error('term_condition', t('Please check the terms and conditions'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['term_condition'] == '1'
+ if ($form_state['values']['country'] == 'Others')
+ {
+ if ($form_state['values']['other_country'] == '')
+ {
+ form_set_error('other_country', t('Enter country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_country'] == ''
+ else
+ {
+ $form_state['values']['country'] = $form_state['values']['other_country'];
+ }
+ if ($form_state['values']['other_state'] == '')
+ {
+ form_set_error('other_state', t('Enter state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_state'] == ''
+ else
+ {
+ $form_state['values']['all_state'] = $form_state['values']['other_state'];
+ }
+ if ($form_state['values']['other_city'] == '')
+ {
+ form_set_error('other_city', t('Enter city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['other_city'] == ''
+ else
+ {
+ $form_state['values']['city'] = $form_state['values']['other_city'];
+ }
+ } //$form_state['values']['country'] == 'Others'
+ else
+ {
+ if ($form_state['values']['country'] == '0')
+ {
+ form_set_error('country', t('Select country name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['country'] == ''
+ if ($form_state['values']['all_state'] == '0')
+ {
+ form_set_error('all_state', t('Select state name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['all_state'] == ''
+ if ($form_state['values']['city'] == '0')
+ {
+ form_set_error('city', t('Select city name'));
+ // $form_state['values']['country'] = $form_state['values']['other_country'];
+ } //$form_state['values']['city'] == ''
+ }
+ //Validation for project title
+ $form_state['values']['project_title'] = trim($form_state['values']['project_title']);
+ if ($form_state['values']['project_title'] != '')
+ {
+ if (strlen($form_state['values']['project_title']) > 250)
+ {
+ form_set_error('project_title', t('Maximum charater limit is 250 charaters only, please check the length of the project title'));
+ } //strlen($form_state['values']['project_title']) > 250
+ else if (strlen($form_state['values']['project_title']) < 10)
+ {
+ form_set_error('project_title', t('Minimum charater limit is 10 charaters, please check the length of the project title'));
+
+ }
+ else if(preg_match('/[\^£$%&*()}{@#~?><>.:;`|=_+¬]/', $form_state['values']['project_title']))
+ form_set_error('project_title', t('Special characters are not allowed for project title'));
+ //strlen($form_state['values']['project_title']) < 10
+ } //$form_state['values']['project_title'] != ''
+ else
+ {
+ form_set_error('project_title', t('Project title shoud not be empty'));
+ }
+ // validation for Name of compound for which process development is carried out
+ $form_state['values']['process_development_compound_name'] = trim($form_state['values']['process_development_compound_name']);
+ if ($form_state['values']['process_development_compound_name'] != '')
+ {
+ if (strlen($form_state['values']['process_development_compound_name']) >= 50)
+ {
+ form_set_error('process_development_compound_name', t('Maximum charater limit is 50 charaters only, please check the length'));
+ } //strlen($form_state['values']['process_development_compound_name']) >= 50
+ else if (strlen($form_state['values']['process_development_compound_name']) < 1)
+ {
+ form_set_error('process_development_compound_name', t('Minimum charater limit is 1 charaters, please check the length'));
+ } //strlen($form_state['values']['process_development_compound_name']) < 1
+ } //$form_state['values']['process_development_compound_name'] != ''
+ else
+ {
+ form_set_error('process_development_compound_name', t('Field should not be empty'));
+ }
+ $form_state['values']['process_development_compound_cas_no'] = trim($form_state['values']['process_development_compound_cas_no']);
+ if ($form_state['values']['process_development_compound_cas_no'] != '')
+ {
+ if (strlen($form_state['values']['process_development_compound_cas_no']) < 1)
+ {
+ form_set_error('process_development_compound_cas_no', t('Minimum charater limit is 1 charaters, please check the length'));
+ } //strlen($form_state['values']['process_development_compound_cas_no']) < 1
+ } //$form_state['values']['process_development_compound_cas_no'] != ''
+ else
+ {
+ form_set_error('process_development_compound_cas_no', t('CAS number field should not be empty'));
+ }
+ if ($form_state['values']['version'] == 'Old version')
+ {
+ if ($form_state['values']['older'] == '')
+ {
+ form_set_error('older', t('Please provide valid version'));
+ } //$form_state['values']['older'] == ''
+ } //$form_state['values']['version'] == 'Old version'
+ if ($form_state['values']['om_database_compound_name'])
+ {
+ $om_database_compound_name = implode("| ", $_POST['om_database_compound_name']);
+ $form_state['values']['om_database_compound_name'] = trim($om_database_compound_name);
+ } //$form_state['values']['om_database_compound_name']
+ return;
+}
+function om_flowsheet_proposal_form_submit($form, &$form_state)
+{
+ global $user;
+ if (!$user->uid)
+ {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
+ } //!$user->uid
+ if ($form_state['values']['version'] == 'Old version')
+ {
+ $form_state['values']['version'] = trim($form_state['values']['older']);
+ } //$form_state['values']['version'] == 'Old version'
+ /* inserting the user proposal */
+ $v = $form_state["values"];
+ if($form_state['values']['dwsim_flowsheet_check'] == 1)
+ {
+ $dwsim_flowsheet_check = 1;
+ }
+ else{
+ $dwsim_flowsheet_check = 0;
+ }
+ $project_title = trim($v['project_title']);
+ $proposar_name = trim($v['name_title'] . ' ' . $v['contributor_name']);
+ $university = trim($v['university']);
+ $month_year_of_degree = $v['month_year_of_degree'];
+ $directory_name = _om_df_dir_name($project_title, $proposar_name);
+ $result = "INSERT INTO {om_flowsheet_proposal}
+ (
+ uid,
+ approver_uid,
+ name_title,
+ contributor_name,
+ contact_no,
+ month_year_of_degree,
+ university,
+ city,
+ pincode,
+ state,
+ country,
+ version,
+ project_guide_name,
+ project_guide_email_id,
+ project_guide_university,
+ project_title,
+ dwsim_flowsheet_check,
+ dwsim_flowsheet_name,
+ process_development_compound_name,
+ process_development_compound_cas_number,
+ approval_status,
+ is_completed,
+ dissapproval_reason,
+ creation_date,
+ approval_date,
+ directory_name,
+ reference
+ ) VALUES
+ (
+ :uid,
+ :approver_uid,
+ :name_title,
+ :contributor_name,
+ :contact_no,
+ :month_year_of_degree,
+ :university,
+ :city,
+ :pincode,
+ :state,
+ :country,
+ :version,
+ :project_guide_name,
+ :project_guide_email_id,
+ :project_guide_university,
+ :project_title,
+ :dwsim_flowsheet_check,
+ :dwsim_flowsheet_name,
+ :process_development_compound_name,
+ :process_development_compound_cas_number,
+ :approval_status,
+ :is_completed,
+ :dissapproval_reason,
+ :creation_date,
+ :approval_date,
+ :directory_name,
+ :reference
+ )";
+
+ $args = array(
+ ":uid" => $user->uid,
+ ":approver_uid" => 0,
+ ":name_title" => $v['name_title'],
+ ":contributor_name" => _om_df_sentence_case(trim($v['contributor_name'])),
+ ":contact_no" => $v['contributor_contact_no'],
+ ":month_year_of_degree" => $month_year_of_degree,
+ ":university" => trim($v['university']),
+ ":city" => $v['city'],
+ ":pincode" => $v['pincode'],
+ ":state" => $v['all_state'],
+ ":country" => $v['country'],
+ ":version" => $v['version'],
+ ":project_guide_name" => $v['project_guide_name'],
+ ":project_guide_email_id" => trim($v['project_guide_email_id']),
+ ":project_guide_university" => trim($v['project_guide_university']),
+ ":project_title" => $v['project_title'],
+ ":dwsim_flowsheet_check" => $dwsim_flowsheet_check,
+ ":dwsim_flowsheet_name" => $v['dwsim_flowsheet_name'],
+ ":process_development_compound_name" => _om_df_sentence_case($v['process_development_compound_name']),
+ ":process_development_compound_cas_number" => $v['process_development_compound_cas_no'],
+ ":approval_status" => 0,
+ ":is_completed" => 0,
+ ":dissapproval_reason" => "NULL",
+ ":creation_date" => time(),
+ ":approval_date" => 0,
+ ":directory_name" => $directory_name,
+ ":reference" => $v['reference']
+ );
+ //var_dump($args);die;
+ $proposal_id = db_query($result, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+
+ if (!$proposal_id)
+ {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
+ } //!$proposal_id
+ /* sending email */
+ $email_to = $user->mail;
+ $form = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['om_flowsheet_proposal_received']['proposal_id'] = $proposal_id;
+ $params['om_flowsheet_proposal_received']['user_id'] = $user->uid;
+ $params['om_flowsheet_proposal_received']['headers'] = array(
+ 'From' => $form,
+ '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
+ );
+ if (!drupal_mail('om_flowsheet', 'om_flowsheet_proposal_received', $email_to, user_preferred_language($user), $params, $form, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_set_message(t('We have received your OpenModelica Flowsheeting proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+}
diff --git a/run.inc b/run.inc
new file mode 100755
index 0000000..49c218b
--- /dev/null
+++ b/run.inc
@@ -0,0 +1,144 @@
+ 'select',
+ '#title' => t('Title of the flowsheet'),
+ '#options' => _list_of_flowsheet(),
+ '#default_value' => $selected,
+ '#ajax' => array(
+ 'callback' => 'om_flowsheet_project_details_callback'
+ )
+ );
+ if (!$url_flowsheet_id) {
+ $form['flowsheet_details'] = array(
+ '#type' => 'item',
+ '#markup' => '
'
+ );
+ $form['selected_flowsheet'] = array(
+ '#type' => 'item',
+ '#markup' => '
'
+ );
+ } //!$url_flowsheet_id
+ else {
+ $flowsheet_default_value = $url_flowsheet_id;
+ $form['flowsheet_details'] = array(
+ '#type' => 'item',
+ '#markup' => '
' . _flowsheet_details($flowsheet_default_value) . '
'
+ );
+ $form['selected_flowsheet'] = array(
+ '#type' => 'item',
+ '#markup' => '
' . l('Download Flowsheet', 'flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '
'
+ );
+ }
+ return $form;
+}
+function om_flowsheet_project_details_callback($form, $form_state)
+{
+ $commands = array();
+ $flowsheet_default_value = $form_state['values']['flowsheet'];
+ if ($flowsheet_default_value != 0) {
+ $form['flowsheet_details']['#markup'] = _flowsheet_details($flowsheet_default_value);
+ $flowsheet_details = _flowsheet_information($flowsheet_default_value);
+ $provider = user_load($flowsheet_details->uid);
+ if ($flowsheet_details->uid > 0) {
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', l('Download Flowsheet', 'flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))));
+ } //$flowsheet_details->uid > 0
+ else {
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', '');
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet_om', '');
+ }
+ $commands[] = ajax_command_html('#ajax_flowsheet_details', _flowsheet_details($flowsheet_default_value));
+ } //$flowsheet_default_value != 0
+ else {
+ // $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list();
+ // $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list']));
+ $commands[] = ajax_command_html('#ajax_flowsheet_details', '');
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', '');
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet_om', '');
+ $commands[] = ajax_command_data('#ajax_selected_flowsheet', 'form_state_value_select', $form_state['values']['flowsheet']);
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+function bootstrap_table_format($headers, $rows)
+{
+ $thead = "";
+ $tbody = "";
+ foreach ($headers as $header) {
+ $thead .= "
{$header} | ";
+ } //$headers as $header
+ foreach ($rows as $row) {
+ $tbody .= "
";
+ foreach ($row as $data) {
+ $tbody .= "{$data} | ";
+ } //$row as $data
+ $tbody .= "
";
+ } //$rows as $row
+ $table = "
+
+ ";
+ return $table;
+}
+/*****************************************************/
+function _list_of_flowsheet()
+{
+ $flowsheet_titles = array(
+ '0' => 'Please select...'
+ );
+ //$lab_titles_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('approval_status', 3);
+ $query->orderBy('project_title', 'ASC');
+ $flowsheet_titles_q = $query->execute();
+ while ($flowsheet_titles_data = $flowsheet_titles_q->fetchObject()) {
+ $flowsheet_titles[$flowsheet_titles_data->id] = $flowsheet_titles_data->project_title . ' (Proposed by ' . $flowsheet_titles_data->name_title . ' ' . $flowsheet_titles_data->contributor_name . ')';
+ } //$flowsheet_titles_data = $flowsheet_titles_q->fetchObject()
+ return $flowsheet_titles;
+}
+function _flowsheet_information($proposal_id)
+{
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $query->condition('approval_status', 3);
+ $flowhsheet_q = $query->execute();
+ $flowsheet_data = $flowhsheet_q->fetchObject();
+ if ($flowsheet_data) {
+ return $flowsheet_data;
+ } //$flowsheet_data
+ else {
+ return 'Not found';
+ }
+}
+function _flowsheet_details($flowsheet_default_value)
+{
+ $flowsheet_details = _flowsheet_information($flowsheet_default_value);
+ if ($flowsheet_default_value != 0) {
+ $form['flowsheet_details']['#markup'] = '
About the Flowsheet ' . '' . '- Proposer Name: ' . $flowsheet_details->name_title . ' ' . $flowsheet_details->contributor_name . '
' . '- Title of the Flowhseet: ' . l($flowsheet_details->project_title,'flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '
' . '- Institution: ' . $flowsheet_details->university . '
' . '- Version: ' . $flowsheet_details->version . '
' . '- Reference: ' . $flowsheet_details->reference . '
' . ' ';
+ $details = $form['flowsheet_details']['#markup'];
+ return $details;
+ } //$flowsheet_default_value != 0
+}
diff --git a/settings.inc b/settings.inc
new file mode 100755
index 0000000..9542dbd
--- /dev/null
+++ b/settings.inc
@@ -0,0 +1,98 @@
+ 'textfield',
+ '#title' => t('(Bcc) Notification emails'),
+ '#description' => t('Specify emails id for Bcc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_emails', '')
+ );
+ $form['cc_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('(Cc) Notification emails'),
+ '#description' => t('Specify emails id for Cc option of mail system with comma separated'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_cc_emails', '')
+ );
+ $form['from_email'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Outgoing from email address'),
+ '#description' => t('Email address to be display in the from field of all outgoing messages'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_from_email', '')
+ );
+ $form['extensions']['user_defind_compound_source'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed source file extensions for user defind compound'),
+ '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_user_defind_compound_source_extensions', '')
+ );
+ $form['extensions']['dependency'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed dependency file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of dependency file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_dependency_extensions', '')
+ );
+ $form['extensions']['result'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed result file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of result file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_result_extensions', '')
+ );
+ $form['extensions']['abstract_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed abstract file extensions'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_abstract_upload_extensions', '')
+ );
+ $form['extensions']['flowsheet_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed om flowsheet for the developed process'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('om_flowsheet_flowsheet_developed_process_source_extensions', '')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
+function om_flowsheet_settings_form_validate($form, &$form_state)
+{
+ return;
+}
+function om_flowsheet_settings_form_submit($form, &$form_state)
+{
+ variable_set('om_flowsheet_emails', $form_state['values']['emails']);
+ variable_set('om_flowsheet_cc_emails', $form_state['values']['cc_emails']);
+ variable_set('om_flowsheet_from_email', $form_state['values']['from_email']);
+ variable_set('om_flowsheet_user_defind_compound_source_extensions', $form_state['values']['user_defind_compound_source']);
+ variable_set('om_flowsheet_dependency_extensions', $form_state['values']['dependency']);
+ variable_set('om_flowsheet_result_extensions', $form_state['values']['result']);
+ variable_set('om_flowsheet_abstract_upload_extensions', $form_state['values']['abstract_upload']);
+ variable_set('om_flowsheet_flowsheet_developed_process_source_extensions', $form_state['values']['flowsheet_upload']);
+ drupal_set_message(t('Settings updated'), 'status');
+}
diff --git a/upload_code.inc b/upload_code.inc
new file mode 100755
index 0000000..bc8f9e9
--- /dev/null
+++ b/upload_code.inc
@@ -0,0 +1,699 @@
+ ';
+ /* get experiment list */
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstracts_q = $query->execute()->fetchObject();
+ if ($abstracts_q)
+ {
+ if ($abstracts_q->is_submitted == 1)
+ {
+ drupal_set_message(t('Your abstract is under review, you can not edit exisiting abstract without reviewer permission.'), 'error', $repeat = FALSE);
+ //drupal_goto('flowsheeting-project/abstract-code');
+ //return;
+ } //$abstracts_q->is_submitted == 1
+ } //$abstracts_q
+ $query_pro = db_select('om_flowsheet_proposal');
+ $query_pro->fields('om_flowsheet_proposal');
+ $query_pro->condition('id', $proposal_data->id);
+ $abstracts_pro = $query_pro->execute()->fetchObject();
+ $query_pdf = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_pdf->fields('om_flowsheet_submitted_abstracts_file');
+ $query_pdf->condition('proposal_id', $proposal_data->id);
+ $query_pdf->condition('filetype', 'A');
+ $abstracts_pdf = $query_pdf->execute()->fetchObject();
+ if ($abstracts_pdf == TRUE)
+ {
+ if ($abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != "")
+ {
+ $abstract_filename = $abstracts_pdf->filename;
+ } //$abstracts_pdf->filename != "NULL" || $abstracts_pdf->filename != ""
+ else
+ {
+ $abstract_filename = "File not uploaded";
+ }
+ } //$abstracts_pdf == TRUE
+ else
+ {
+ $abstract_filename = "File not uploaded";
+ }
+ $query_process = db_select('om_flowsheet_submitted_abstracts_file');
+ $query_process->fields('om_flowsheet_submitted_abstracts_file');
+ $query_process->condition('proposal_id', $proposal_data->id);
+ $query_process->condition('filetype', 'S');
+ $abstracts_query_process = $query_process->execute()->fetchObject();
+ if ($abstracts_query_process == TRUE)
+ {
+ if ($abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != "")
+ {
+ $abstracts_query_process_filename = $abstracts_query_process->filename;
+ } //$abstracts_query_process->filename != "NULL" || $abstracts_query_process->filename != ""
+ else
+ {
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ if ($abstracts_q->is_submitted == '')
+ {
+ $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
+ } //$abstracts_q->is_submitted == ''
+ else if ($abstracts_q->is_submitted == 1)
+ {
+ $url = "";
+ } //$abstracts_q->is_submitted == 1
+ else if ($abstracts_q->is_submitted == 0)
+ {
+ $url = l('Edit abstract', 'flowsheeting-project/abstract-code/upload');
+ } //$abstracts_q->is_submitted == 0
+ if ($abstracts_q->unit_operations_used_in_om == '')
+ {
+ $unit_operations_used_in_om = "Not entered";
+ } //$abstracts_q->unit_operations_used_in_om == ''
+ else
+ {
+ $unit_operations_used_in_om = $abstracts_q->unit_operations_used_in_om;
+ }
+ if ($abstracts_q->thermodynamic_packages_used == '')
+ {
+ $thermodynamic_packages_used = "Not entered";
+ } //$abstracts_q->thermodynamic_packages_used == ''
+ else
+ {
+ $thermodynamic_packages_used = $abstracts_q->thermodynamic_packages_used;
+ }
+
+ } //$abstracts_query_process == TRUE
+ else
+ {
+ $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
+ $unit_operations_used_in_om = "Not entered";
+ $thermodynamic_packages_used = "Not entered";
+ $abstracts_query_process_filename = "File not uploaded";
+ }
+ $headers = array(
+ "Name of compound for which process development is carried out",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$proposal_data->process_development_compound_name}",
+ "{$proposal_data->process_development_compound_cas_number}"
+ );
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
+ $uploaded_user_defined_compound_filepath = basename($proposal_data->user_defined_compound_filepath) ? basename($proposal_data->user_defined_compound_filepath) : "Not uploaded";
+ $return_html .= 'Proposer Name: ' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '
';
+ $return_html .= 'Title of the Flowsheet Project: ' . $proposal_data->project_title . '
';
+ $return_html .= 'OpenModelica version: ' . $proposal_data->version . '
';
+ $return_html .= 'Unit Operations used in OpenModelica: ' . $unit_operations_used_in_om . '
';
+ $return_html .= 'Thermodynamic Packages Used: ' . $thermodynamic_packages_used . '
';
+ $return_html .= 'Name of compound for which process development is carried out: ' . $prodata . ' ';
+ $return_html .= 'Uploaded an abstract (brief outline) of the project: ' . $abstract_filename . '
';
+ $return_html .= 'Upload the om flowsheet for the developed process: ' . $abstracts_query_process_filename . '
';
+ $return_html .= $url . ' ';
+ return $return_html;
+}
+function om_flowsheet_upload_abstract_code_form($form, &$form_state)
+{
+ global $user;
+ $form['#attributes'] = array(
+ 'enctype' => "multipart/form-data"
+ );
+ /* get current proposal */
+ //$proposal_id = (int) arg(3);
+ $uid = $user->uid;
+ //$proposal_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE id = %d", $proposal_id);
+ $query = db_select('om_flowsheet_proposal');
+ $query->fields('om_flowsheet_proposal');
+ $query->condition('uid', $uid);
+ $query->condition('approval_status', '1');
+ $proposal_q = $query->execute();
+ if ($proposal_q)
+ {
+ if ($proposal_data = $proposal_q->fetchObject())
+ {
+ /* everything ok */
+ } //$proposal_data = $proposal_q->fetchObject()
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+ return;
+ }
+ } //$proposal_q
+ else
+ {
+ drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+ return;
+ }
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstracts_q = $query->execute()->fetchObject();
+ if ($abstracts_q)
+ {
+ if ($abstracts_q->is_submitted == 1)
+ {
+ drupal_set_message(t('Your abstract is under review, you can not edit exisiting abstract without reviewer permission.'), 'error', $repeat = FALSE);
+ drupal_goto('flowsheeting-project/abstract-code');
+ //return;
+ } //$abstracts_q->is_submitted == 1
+ } //$abstracts_q->is_submitted == 1
+ $form['project_title'] = array(
+ '#type' => 'item',
+ '#markup' => $proposal_data->project_title,
+ '#title' => t('Title of the Flowsheet Project')
+ );
+ $form['version'] = array(
+ '#type' => 'item',
+ '#title' => t('OpenModelica version'),
+ '#markup' => $proposal_data->version
+ );
+ if ($abstracts_q == TRUE)
+ {
+ if ($abstracts_q->unit_operations_used_in_om)
+ {
+ $existing_unit_operations_used_in_om = default_value_for_selections("unit_operations_used_in_om", $proposal_data->id);
+ $form['unit_operations_used_in_om'] = array(
+ '#type' => 'select',
+ '#title' => t('Unit Operations used in om'),
+ '#options' => _df_list_of_unit_operations(),
+ '#required' => TRUE,
+ '#default_value' => $existing_unit_operations_used_in_om,
+ '#size' => '20',
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ } //$abstracts_q->unit_operations_used_in_om
+ } //$abstracts_q->unit_operations_used_in_om
+ else
+ {
+ $form['unit_operations_used_in_om'] = array(
+ '#type' => 'select',
+ '#title' => t('Unit Operations used in om'),
+ '#options' => _df_list_of_unit_operations(),
+ '#required' => TRUE,
+ '#size' => '20',
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ }
+ if ($abstracts_q == TRUE)
+ {
+ if ($abstracts_q->thermodynamic_packages_used)
+ {
+ $existing_thermodynamic_packages_used = default_value_for_selections("thermodynamic_packages_used", $proposal_data->id);
+ $form['thermodynamic_packages_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Thermodynamic Packages Used'),
+ '#options' => _df_list_of_thermodynamic_packages(),
+ '#required' => TRUE,
+ '#size' => '20',
+ '#default_value' => $existing_thermodynamic_packages_used,
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ } //$abstracts_q->thermodynamic_packages_used
+ } //$abstracts_q == TRUE
+ else
+ {
+ $form['thermodynamic_packages_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Thermodynamic Packages Used'),
+ '#options' => _df_list_of_thermodynamic_packages(),
+ '#required' => TRUE,
+ '#size' => '20',
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ }
+
+ $headers = array(
+ "Name of compound for which process development is carried out",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$proposal_data->process_development_compound_name}",
+ "{$proposal_data->process_development_compound_cas_number}"
+ );
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
+ $form['process_development_compound_name'] = array(
+ '#type' => 'item',
+ '#title' => t('Name of compound for which process development is carried out'),
+ '#markup' => $prodata
+ );
+
+ $existing_uploaded_A_file = default_value_for_uploaded_files("A", $proposal_data->id);
+ if (!$existing_uploaded_A_file)
+ {
+ $existing_uploaded_A_file = new stdClass();
+ $existing_uploaded_A_file->filename = "No file uploaded";
+ } //!$existing_uploaded_A_file
+ $form['upload_an_abstract'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload an abstract (brief outline) of the project.'),
+ '#description' => t('Current File : ' . $existing_uploaded_A_file->filename . ' Separate filenames with underscore. No spaces or any special characters allowed in filename.') . ' ' . t('Allowed file extensions : ') . variable_get('om_flowsheet_abstract_upload_extensions', '') . ''
+ );
+ $existing_uploaded_S_file = default_value_for_uploaded_files("S", $proposal_data->id);
+ if (!$existing_uploaded_S_file)
+ {
+ $existing_uploaded_S_file = new stdClass();
+ $existing_uploaded_S_file->filename = "No file uploaded";
+ } //!$existing_uploaded_S_file
+ $form['upload_flowsheet_developed_process'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload the OpenModelica flowsheet for the developed process.'),
+ '#description' => t('Current File : ' . $existing_uploaded_S_file->filename . ' Separate filenames with underscore. No spaces or any special characters allowed in filename.') . ' ' . t('Allowed file extensions : ') . variable_get('om_flowsheet_flowsheet_developed_process_source_extensions', '') . ''
+ );
+ $form['prop_id'] = array(
+ '#type' => 'hidden',
+ '#value' => $proposal_data->id
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit'),
+ '#submit' => array(
+ 'om_flowsheet_upload_abstract_code_form_submit'
+ )
+ );
+ $form['cancel'] = array(
+ '#type' => 'item',
+ '#markup' => l(t('Cancel'), 'flowsheeting-project/manage-proposal')
+ );
+ return $form;
+}
+
+///////////////////////////////////////////////////////////////
+function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
+{
+ if ($form_state['values']['unit_operations_used_in_om'])
+ {
+ $unit_operations_used_in_om = implode(", ", $_POST['unit_operations_used_in_om']);
+ $form_state['values']['unit_operations_used_in_om'] = $unit_operations_used_in_om;
+ } //$form_state['values']['unit_operations_used_in_om']
+ else
+ {
+ form_set_error('unit_operations_used_in_om', t('Please select.'));
+ }
+ if ($form_state['values']['thermodynamic_packages_used'])
+ {
+ $thermodynamic_packages_used = implode(", ", $_POST['thermodynamic_packages_used']);
+ $form_state['values']['thermodynamic_packages_used'] = $thermodynamic_packages_used;
+ } //$form_state['values']['thermodynamic_packages_used']
+ else
+ {
+ form_set_error('thermodynamic_packages_used', t('Please select.'));
+ }
+
+ if ($form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet'])
+ {
+ $list_of_compounds_from_om_database_used_in_process_flowsheet = implode("| ", $_POST['list_of_compounds_from_om_database_used_in_process_flowsheet']);
+ $form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet'] = $list_of_compounds_from_om_database_used_in_process_flowsheet;
+ } //$form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet']
+ if (isset($_FILES['files']))
+ {
+ /* check if file is uploaded */
+ $existing_uploaded_A_file = default_value_for_uploaded_files("A", $form_state['values']['prop_id']);
+ $existing_uploaded_S_file = default_value_for_uploaded_files("S", $form_state['values']['prop_id']);
+ if (!$existing_uploaded_S_file)
+ {
+ if (!($_FILES['files']['name']['upload_flowsheet_developed_process']))
+ form_set_error('upload_flowsheet_developed_process', t('Please upload the file.'));
+ } //!$existing_uploaded_S_file
+ if (!$existing_uploaded_A_file)
+ {
+ if (!($_FILES['files']['name']['upload_an_abstract']))
+ form_set_error('upload_an_abstract', t('Please upload the file.'));
+ } //!$existing_uploaded_A_file
+ /* check for valid filename extensions */
+ if ($_FILES['files']['name']['upload_an_abstract'] || $_FILES['files']['name']['upload_flowsheet_developed_process'])
+ {
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_flowsheet_developed_process'))
+ $file_type = 'S';
+ else if (strstr($file_form_name, 'upload_an_abstract'))
+ $file_type = 'A';
+ else
+ $file_type = 'U';
+ $allowed_extensions_str = '';
+ switch ($file_type)
+ {
+ case 'S':
+ $allowed_extensions_str = variable_get('om_flowsheet_flowsheet_developed_process_source_extensions', '');
+ break;
+ case 'A':
+ $allowed_extensions_str = variable_get('om_flowsheet_abstract_upload_extensions', '');
+ break;
+ } //$file_type
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $tmp_ext = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($tmp_ext);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ if (!om_flowsheet_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ } //isset($_FILES['files'])
+ // drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
+ // drupal_static_reset('drupal_add_js') ;
+}
+function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
+{
+ global $user;
+ $v = $form_state['values'];
+ $root_path = om_flowsheet_path();
+ $proposal_data = om_flowsheet_get_proposal();
+ $proposal_id = $proposal_data->id;
+ if (!$proposal_data)
+ {
+ drupal_goto('');
+ return;
+ } //!$proposal_data
+ $proposal_id = $proposal_data->id;
+ $proposal_directory = $proposal_data->directory_name;
+ /* create proposal folder if not present */
+ $dest_path = $proposal_directory . '/';
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ $proposal_id = $proposal_data->id;
+ $query_s = "SELECT * FROM {om_flowsheet_submitted_abstracts} WHERE proposal_id = :proposal_id";
+ $args_s = array(
+ ":proposal_id" => $proposal_id
+ );
+ $query_s_result = db_query($query_s, $args_s)->fetchObject();
+ if (!$query_s_result)
+ {
+ /* creating solution database entry */
+ $query = "INSERT INTO {om_flowsheet_submitted_abstracts} (
+ proposal_id,
+ approver_uid,
+ abstract_approval_status,
+ unit_operations_used_in_om,
+ thermodynamic_packages_used,
+ abstract_upload_date,
+ abstract_approval_date,
+ is_submitted) VALUES (:proposal_id, :approver_uid, :abstract_approval_status, :unit_operations_used_in_om,
+ :thermodynamic_packages_used, :abstract_upload_date, :abstract_approval_date, :is_submitted)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":approver_uid" => 0,
+ ":abstract_approval_status" => 0,
+ ":unit_operations_used_in_om" => $v['unit_operations_used_in_om'],
+ ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
+ ":abstract_upload_date" => time(),
+ ":abstract_approval_date" => 0,
+ ":is_submitted" => 1
+ );
+ $submitted_abstract_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ $query1 = "UPDATE {om_flowsheet_proposal} SET is_submitted = :is_submitted WHERE id = :id";
+ $args1 = array(
+ ":is_submitted" => 1,
+ ":id" => $proposal_id
+ );
+ db_query($query1,$args1);
+ drupal_set_message('Abstract uploaded successfully.', 'status');
+ } //!$query_s_result
+ else
+ {
+ $query = "UPDATE {om_flowsheet_submitted_abstracts} SET
+ unit_operations_used_in_om= :unit_operations_used_in_om,
+ thermodynamic_packages_used= :thermodynamic_packages_used,
+ abstract_upload_date =:abstract_upload_date,
+ is_submitted= :is_submitted
+ WHERE proposal_id = :proposal_id
+ ";
+ $args = array(
+ ":unit_operations_used_in_om" => $v['unit_operations_used_in_om'],
+ ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
+ ":abstract_upload_date" => time(),
+ ":is_submitted" => 1,
+ ":proposal_id" => $proposal_id
+ );
+ $query1 = "UPDATE {om_flowsheet_proposal} SET is_submitted = :is_submitted WHERE id = :id";
+ $args1 = array(
+ ":is_submitted" => 1,
+ ":id" => $proposal_id
+ );
+ db_query($query1,$args1);
+ $submitted_abstract_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ drupal_set_message('Abstract updated successfully.', 'status');
+ }
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ {
+ if ($file_name)
+ {
+ /* checking file type */
+ if (strstr($file_form_name, 'upload_flowsheet_developed_process'))
+ {
+ $file_type = 'S';
+ } //strstr($file_form_name, 'upload_flowsheet_developed_process')
+ else if (strstr($file_form_name, 'upload_an_abstract'))
+ {
+ $file_type = 'A';
+ } //strstr($file_form_name, 'upload_an_abstract')
+ else
+ {
+ $file_type = 'U';
+ }
+ switch ($file_type)
+ {
+ case 'S':
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ )), 'error');
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ /* for uploaded files making an entry in the database */
+ $query_ab_f = "SELECT * FROM om_flowsheet_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ :filetype";
+ $args_ab_f = array(
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ if (!$query_ab_f_result)
+ {
+ $query = "INSERT INTO {om_flowsheet_submitted_abstracts_file} (submitted_abstract_id, proposal_id, uid, approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
+ VALUES (:submitted_abstract_id, :proposal_id, :uid, :approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
+ $args = array(
+ ":submitted_abstract_id" => $submitted_abstract_id,
+ ":proposal_id" => $proposal_id,
+ ":uid" => $user->uid,
+ ":approvar_uid" => 0,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":filetype" => $file_type,
+ ":timestamp" => time()
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //!$query_ab_f_result
+ else
+ {
+ unlink($root_path . $dest_path . $query_ab_f_result->filename);
+ $query = "UPDATE {om_flowsheet_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
+ $args = array(
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":timestamp" => time(),
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' file updated successfully.', 'status');
+ }
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else
+ {
+ drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error');
+ }
+ break;
+ case 'A':
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+
+ drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
+ '!filename' => $_FILES['files']['name'][$file_form_name]
+ )), 'error');
+ } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ /* uploading file */
+ else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
+ {
+ /* for uploaded files making an entry in the database */
+ $query_ab_f = "SELECT * FROM om_flowsheet_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ :filetype";
+ $args_ab_f = array(
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ if (!$query_ab_f_result)
+ {
+ $query = "INSERT INTO {om_flowsheet_submitted_abstracts_file} (submitted_abstract_id, proposal_id, uid, approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
+ VALUES (:submitted_abstract_id, :proposal_id, :uid, :approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
+ $args = array(
+ ":submitted_abstract_id" => $submitted_abstract_id,
+ ":proposal_id" => $proposal_id,
+ ":uid" => $user->uid,
+ ":approvar_uid" => 0,
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":filetype" => $file_type,
+ ":timestamp" => time()
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } //!$query_ab_f_result
+ else
+ {
+ unlink($root_path . $dest_path . $query_ab_f_result->filename);
+ $query = "UPDATE {om_flowsheet_submitted_abstracts_file} SET filename = :filename, filepath=:filepath, filemime=:filemime, filesize=:filesize, timestamp=:timestamp WHERE proposal_id = :proposal_id AND filetype = :filetype";
+ $args = array(
+ ":filename" => $_FILES['files']['name'][$file_form_name],
+ ":filepath" => $file_path . $_FILES['files']['name'][$file_form_name],
+ ":filemime" => mime_content_type($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]),
+ ":filesize" => $_FILES['files']['size'][$file_form_name],
+ ":timestamp" => time(),
+ ":proposal_id" => $proposal_id,
+ ":filetype" => $file_type
+ );
+ db_query($query, $args);
+ drupal_set_message($file_name . ' file updated successfully.', 'status');
+ }
+ } //move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
+ else
+ {
+ drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error');
+ }
+ break;
+ } //$file_type
+ } //$file_name
+ } //$_FILES['files']['name'] as $file_form_name => $file_name
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('om_flowsheet_from_email', '');
+ $bcc = variable_get('om_flowsheet_emails', '');
+ $cc = variable_get('om_flowsheet_cc_emails', '');
+ $params['abstract_uploaded']['proposal_id'] = $proposal_id;
+ $params['abstract_uploaded']['submitted_abstract_id'] = $submitted_abstract_id;
+ $params['abstract_uploaded']['user_id'] = $user->uid;
+ $params['abstract_uploaded']['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
+ );
+ if (!drupal_mail('om_flowsheet', 'abstract_uploaded', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ drupal_goto('flowsheeting-project/abstract-code');
+}
+function default_value_for_selections($opration, $proposal_id)
+{
+ $query = db_select('om_flowsheet_submitted_abstracts');
+ $query->fields('om_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_id);
+ $abstracts_q = $query->execute()->fetchObject();
+ $selected_pacakege_array = array();
+ if ($opration == "unit_operations_used_in_om")
+ {
+ $uouid = explode(',', $abstracts_q->unit_operations_used_in_om);
+ $ui = 0;
+ $unit_item = new stdClass();
+ foreach ($uouid as $unit_item->$ui)
+ {
+ $selected_pacakege_array[$ui] = trim($unit_item->$ui);
+ $ui++;
+ } //$uouid as $unit_item->$ui
+ } //$opration == "unit_operations_used_in_om"
+ elseif ($opration == "thermodynamic_packages_used")
+ {
+ $tpuid = explode(',', $abstracts_q->thermodynamic_packages_used);
+ $tpui = 0;
+ $thermodynamic_item = new stdClass();
+ foreach ($tpuid as $thermodynamic_item->$tpui)
+ {
+ $selected_pacakege_array[$tpui] = trim($thermodynamic_item->$tpui);
+ $tpui++;
+ } //$tpuid as $thermodynamic_item->$tpui
+ } //$opration == "thermodynamic_packages_used"
+ else
+ {
+ return $selected_pacakege_array;
+ }
+ return $selected_pacakege_array;
+}
+function default_value_for_uploaded_files($filetype, $proposal_id)
+{
+ $query = db_select('om_flowsheet_submitted_abstracts_file');
+ $query->fields('om_flowsheet_submitted_abstracts_file');
+ $query->condition('proposal_id', $proposal_id);
+ $selected_files_array = "";
+ if ($filetype == "A")
+ {
+ $query->condition('filetype', $filetype);
+ $filetype_q = $query->execute()->fetchObject();
+ return $filetype_q;
+ } //$filetype == "A"
+ elseif ($filetype == "S")
+ {
+ $query->condition('filetype', $filetype);
+ $filetype_q = $query->execute()->fetchObject();
+ return $filetype_q;
+ } //$filetype == "S"
+ else
+ {
+ return;
+ }
+ return;
+}
--
cgit
|