summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xabstract_approval.inc387
-rwxr-xr-xabstract_bulk_approval.inc532
-rwxr-xr-xdwsim_flowsheet.module69
-rwxr-xr-xemail.inc6
-rwxr-xr-xflowsheet_details.inc2
-rwxr-xr-xfull_download.inc371
-rwxr-xr-xgeneral_deletion.inc483
-rwxr-xr-xmanage_proposal.inc63
-rwxr-xr-xproposal.inc2
-rwxr-xr-xrun.inc144
-rwxr-xr-xupload_code.inc659
11 files changed, 1937 insertions, 781 deletions
diff --git a/abstract_approval.inc b/abstract_approval.inc
new file mode 100755
index 0000000..90081bf
--- /dev/null
+++ b/abstract_approval.inc
@@ -0,0 +1,387 @@
+<?php
+// $Id$
+function dwsim_flowsheet_abstract_approval()
+ {
+ /* get a list of unapproved solutions */
+ //$pending_solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE approval_status = 0");
+ $query = db_select('lab_migration_solution');
+ $query->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 dwsim_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 . ')' . '<br/>';
+ /*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)' . '<br/>';
+ }*/
+ }
+ }
+ /* 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' . ')' . '<br/>';
+ }
+ $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 dwsim_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 dwsim_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..f9c3242
--- /dev/null
+++ b/abstract_bulk_approval.inc
@@ -0,0 +1,532 @@
+<?php
+
+function dwsim_flowsheet_abstract_bulk_approval_form($form, &$form_state)
+{
+ $options_first = _bulk_list_of_flowsheet_project();
+ $selected = isset($form_state['values']['flowsheet_project']) ? $form_state['values']['flowsheet_project'] : key($options_first);
+ $form = array();
+ $form['flowsheet_project'] = array(
+ '#type' => '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' => '<div id="ajax_selected_flowsheet"></div><div id="ajax_selected_flowsheet_pdf"></div>'
+ );
+ $form['flowsheet_actions'] = array(
+ '#type' => 'select',
+ '#title' => t('Please select action for Flowsheeting project'),
+ '#options' => _bulk_list_flowsheet_actions(),
+ '#default_value' => 0,
+ '#prefix' => '<div id="ajax_selected_flowsheet_action" style="color:red;">',
+ '#suffix' => '</div>',
+ '#states' => array(
+ 'invisible' => array(
+ ':input[name="flowsheet_project"]' => array(
+ 'value' => 0
+ )
+ )
+ )
+ );
+ $form['message'] = array(
+ '#type' => 'textarea',
+ '#title' => t('If Dis-Approved please specify reason for Dis-Approval'),
+ '#prefix' => '<div id= "message_submit">',
+ '#states' => array(
+ 'visible' => array(
+ array(
+ ':input[name="flowsheet_actions"]' => array(
+ 'value' => 3
+ )
+ ),
+ 'or',
+ array(
+ ':input[name="flowsheet_actions"]' => array(
+ 'value' => 4
+ )
+ )
+ )
+ )
+ );
+ $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 dwsim_flowsheet_abstract_bulk_approval_form_submit($form, &$form_state)
+{
+ global $user;
+ $msg = '';
+ $root_path = dwsim_flowsheet_document_path();
+ if ($form_state['clicked_button']['#value'] == 'Submit')
+ {
+ if ($form_state['values']['flowsheet_project'])
+ // dwsim_flowsheet_abstract_del_lab_pdf($form_state['values']['flowsheet_project']);
+ if (user_access('dwsim flowsheet bulk manage abstract'))
+ {
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_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 {dwsim_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 {dwsim_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 Flosheeting 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,
+
+Your uploaded abstract for the flowsheeting project has been approved:
+
+Title of flowsheeting project : ' . $user_info->project_title . '
+
+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('dwsim_flowsheet_from_email', '');
+ $bcc = variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_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('dwsim_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ {
+ $msg = drupal_set_message('Error sending email message.', 'error');
+ } //!drupal_mail('dwsim_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('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_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 {dwsim_flowsheet_submitted_abstracts} SET abstract_approval_status = 0, approver_uid = :approver_uid WHERE id = :id", array(
+ ':approver_uid' => $user->uid,
+ ':id' => $abstract_data->id
+ ));
+ db_query("UPDATE {dwsim_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('Approved Flosheeting project.'), '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('dwsim_flowsheet_from_email', '');
+ $bcc = variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_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('dwsim_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ {
+ drupal_set_message('Error sending email message.', 'error');
+ } //!drupal_mail('dwsim_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('dwsim flowsheet bulk delete abstract'))
+ {
+ $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 (dwsim_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project'])) //////
+ {
+ drupal_set_message(t('Dis-Approved and Deleted Entire Flowsheeting project.'), 'status');
+ } //dwsim_flowsheet_abstract_delete_project($form_state['values']['flowsheet_project'])
+ else
+ {
+ drupal_set_message(t('Error Dis-Approving and Deleting Entire flowsheeting project.'), 'error');
+ }
+ // email
+ $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,
+
+Your all the uploaded flowsheet for the whole flowsheeting project Title : ' . $user_info->project_title . ' have been marked as dis-approved.
+
+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
+ ))
+ );
+ } //$form_state['values']['flowsheet_actions'] == 3
+ elseif ($form_state['values']['flowsheet_actions'] == 4)
+ {
+ if (strlen(trim($form_state['values']['message'])) <= 30)
+ {
+ form_set_error('message', t(''));
+ $msg = drupal_set_message("Please mention the reason for disapproval/deletion. Minimum 30 character required", 'error');
+ return $msg;
+ } //strlen(trim($form_state['values']['message'])) <= 30
+ $query = db_select('dwsim_flowsheet_abstract_experiment');
+ $query->fields('dwsim_flowsheet_abstract_experiment');
+ $query->condition('proposal_id', $form_state['values']['lab']);
+ $query->orderBy('number', 'ASC');
+ $experiment_q = $query->execute();
+ $experiment_list = '';
+ while ($experiment_data = $experiment_q->fetchObject())
+ {
+ $experiment_list .= '<p>' . $experiment_data->number . ') ' . $experiment_data->title . '<br> Description : ' . $experiment_data->description . '<br>';
+ $experiment_list .= ' ';
+ $experiment_list .= '</p>';
+ } //$experiment_data = $experiment_q->fetchObject()
+ if (!user_access('lab migration bulk delete code'))
+ {
+ $msg = drupal_set_message(t('You do not have permission to Bulk Delete Entire Lab Including Proposal.'), 'error');
+ return $msg;
+ } //!user_access('lab migration bulk delete code')
+ // check if dependency files are present
+ $dep_q = db_query("SELECT * FROM {dwsim_flowsheet_abstract_dependency_files} WHERE proposal_id = :proposal_id", array(
+ ":proposal_id" => $form_state['values']['lab']
+ ));
+ if ($dep_data = $dep_q->fetchObject())
+ {
+ $msg = drupal_set_message(t("Cannot delete lab since it has dependency files that can be used by others. First delete the dependency files before deleting the lab."), 'error');
+ return $msg ;
+ } //$dep_data = $dep_q->fetchObject()
+ if (dwsim_flowsheet_abstract_delete_lab($form_state['values']['lab']))
+ {
+ drupal_set_message(t('Dis-Approved and Deleted Entire Lab solutions.'), 'status');
+ $query = db_select('dwsim_flowsheet_abstract_experiment');
+ $query->fields('dwsim_flowsheet_abstract_experiment');
+ $query->condition('proposal_id', $form_state['values']['lab']);
+ $experiment_q = $query->execute()->fetchObject();
+ $dir_path = $root_path . $experiment_q->directory_name;
+ if (is_dir($dir_path))
+ {
+ $res = rmdir($dir_path);
+ if (!$res)
+ {
+ $msg = drupal_set_message(t("Cannot delete Lab directory : " . $dir_path . ". Please contact administrator."), 'error');
+ return $msg;
+ } //!$res
+ } //is_dir($dir_path)
+ else
+ {
+ drupal_set_message(t("Lab directory not present : " . $dir_path . ". Skipping deleting lab directory."), 'status');
+ }
+ //deleting full proposal
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_abstract_proposal} WHERE id = %d", $form_state['values']['lab']);
+ $proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_abstract_proposal} WHERE id = :id", array(
+ ":id" => $form_state['values']['lab']
+ ));
+ $proposal_data = $proposal_q->fetchObject();
+ $proposal_id = $proposal_data->id;
+ db_query("DELETE FROM {dwsim_flowsheet_abstract_experiment} WHERE proposal_id = :proposal_id", array(
+ ":proposal_id" => $proposal_id
+ ));
+ db_query("DELETE FROM {dwsim_flowsheet_abstract_proposal} WHERE id = :id", array(
+ ":id" => $proposal_id
+ ));
+ drupal_set_message(t('Deleted Lab Proposal.'), 'status');
+ //email
+ $email_subject = t('[!site_name] Your uploaded Lab Migration solutions including the Lab proposal have been deleted', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $email_body = array(
+ 0 => t('
+
+Dear !user_name,
+
+We regret to inform you that all the uploaded Experiments of your Lab with following details have been deleted permanently.
+
+Title of Lab :' . $user_info->lab_title . '
+
+List of experiments : ' . $experiment_list . '
+
+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
+ // $email_subject = t('Your uploaded Lab Migration solutions including the Lab proposal have been deleted');
+ $email_body = array(
+ 0 => t('Your all the uploaded solutions including the Lab proposal have been deleted permanently.')
+ );
+ } //dwsim_flowsheet_abstract_delete_lab($form_state['values']['lab'])
+ else
+ {
+ $msg = drupal_set_message(t('Error Dis-Approving and Deleting Entire Lab.'), 'error');
+ }
+ } //$form_state['values']['flowsheet_actions'] == 4
+ else
+ {
+ $msg = drupal_set_message(t('You do not have permission to bulk manage code.'), 'error');
+ }
+ } //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('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_proposal');
+ $query_pro->fields('dwsim_flowsheet_proposal');
+ $query_pro->condition('id', $flowsheet_proposal_id);
+ $abstracts_pro = $query_pro->execute()->fetchObject();
+ $query_pdf = db_select('dwsim_flowsheet_submitted_abstracts_file');
+ $query_pdf->fields('dwsim_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('dwsim_flowsheet_submitted_abstracts_file');
+ $query_process->fields('dwsim_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('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_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_dwsim == '')
+ {
+ $unit_operations_used_in_dwsim = "Not entered";
+ } //$abstracts_q->unit_operations_used_in_dwsim == ''
+ else
+ {
+ $unit_operations_used_in_dwsim = $abstracts_q->unit_operations_used_in_dwsim;
+ }
+ 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;
+ }
+ if ($abstracts_q->logical_blocks_used == '')
+ {
+ $logical_blocks_used = "Not entered";
+ } //$abstracts_q->logical_blocks_used == ''
+ else
+ {
+ $logical_blocks_used = $abstracts_q->logical_blocks_used;
+ }
+ } //$abstracts_query_process == TRUE
+ else
+ {
+ $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
+ $unit_operations_used_in_dwsim = "Not entered";
+ $thermodynamic_packages_used = "Not entered";
+ $logical_blocks_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 .= '<strong>Proposer Name:</strong><br />' . $abstracts_pro->name_title . ' ' . $abstracts_pro->contributor_name . '<br /><br />';
+ $return_html .= '<strong>Title of the Flowsheet Project:</strong><br />' . $abstracts_pro->project_title . '<br /><br />';
+ $return_html .= '<strong>DWSIM version:</strong><br />' . $abstracts_pro->version . '<br /><br />';
+ $return_html .= '<strong>Unit Operations used in DWSIM:</strong><br />' . $unit_operations_used_in_dwsim . '<br /><br />';
+ $return_html .= '<strong>Thermodynamic Packages Used:</strong><br />' . $thermodynamic_packages_used . '<br /><br />';
+ $return_html .= '<strong>Logical Blocks used:</strong><br />' . $logical_blocks_used . '<br /><br />';
+ $return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata . '<br />';
+ $return_html .= '<strong>List of compounds from DWSIM Database used in process flowsheet:</strong><br />' . $abstracts_pro->dwsim_database_compound_name . '<br /><br />';
+ $return_html .= '<strong>List of user defined compounds used in process flowsheet:</strong><br />' . _dwsim_flowsheet_list_of_user_defined_compound($abstracts_pro->id) . '<br />';
+ $return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />';
+ $return_html .= '<strong>Upload the DWSIM flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
+ $return_html .= $download_flowsheet;
+ return $return_html;
+}
diff --git a/dwsim_flowsheet.module b/dwsim_flowsheet.module
index e687f6e..49067e6 100755
--- a/dwsim_flowsheet.module
+++ b/dwsim_flowsheet.module
@@ -131,12 +131,12 @@ function dwsim_flowsheet_menu()
'type' => MENU_NORMAL_ITEM,
'file' => 'code_approval.inc'
);
- $items['flowsheeting-project/code-approval/approve'] = array(
+ $items['flowsheeting-project/abstract-approval/approve'] = array(
'title' => 'Code Approval',
'description' => 'Code Approval',
'page callback' => 'drupal_get_form',
'page arguments' => array(
- 'dwsim_flowsheet_code_approval_form'
+ 'dwsim_flowsheet_abstract_approval_form'
),
'access arguments' => array(
'dwsim flowsheet approve code'
@@ -145,19 +145,19 @@ function dwsim_flowsheet_menu()
'weight' => 1,
'file' => 'code_approval.inc'
);
- $items['flowsheeting-project/code-approval/bulk'] = array(
+ $items['flowsheeting-project/abstract-approval/bulk'] = array(
'title' => 'Bulk Manage',
'description' => 'Bulk Mangage',
'page callback' => 'drupal_get_form',
'page arguments' => array(
- 'dwsim_flowsheet_bulk_approval_form'
+ 'dwsim_flowsheet_abstract_bulk_approval_form'
),
'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
+ 'dwsim flowsheet bulk manage abstract'
),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
- 'file' => 'bulk_approval.inc'
+ 'file' => 'abstract_bulk_approval.inc'
);
$items['flowsheeting-project/code-approval/bulk'] = array(
'title' => 'Bulk Manage',
@@ -167,7 +167,7 @@ function dwsim_flowsheet_menu()
'dwsim_flowsheet_bulk_approval_form'
),
'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
+ 'dwsim flowsheet bulk manage abstract'
),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
@@ -178,7 +178,7 @@ function dwsim_flowsheet_menu()
'description' => 'Dependency Mangage',
'page callback' => 'drupal_get_form',
'page arguments' => array('dwsim_flowsheet_dependency_approval_form'),
- 'access arguments' => array('dwsim flowsheet bulk manage code'),
+ 'access arguments' => array('dwsim flowsheet bulk manage abstract'),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'dependency_approval.inc',
@@ -191,7 +191,7 @@ function dwsim_flowsheet_menu()
'dwsim_flowsheet_bulk_upload_code_form'
),
'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
+ 'dwsim flowsheet bulk manage abstract'
),
'type' => MENU_CALLBACK,
'weight' => 4,
@@ -205,7 +205,7 @@ function dwsim_flowsheet_menu()
'dwsim_flowsheet_lab_notes_form'
),
'access arguments' => array(
- 'dwsim flowsheet bulk manage code'
+ 'dwsim flowsheet bulk manage abstract'
),
'type' => MENU_CALLBACK,
'weight' => 4,
@@ -213,7 +213,7 @@ function dwsim_flowsheet_menu()
);
/* CODE UPLOAD */
$items['flowsheeting-project/abstract-code'] = array(
- 'title' => 'Abstract Submission',
+ 'title' => 'Abstract and Flowsheet Submission',
'description' => 'Abstract Submission',
'page callback' => 'dwsim_flowsheet_abstract',
'access callback' => 'user_access',
@@ -234,7 +234,7 @@ function dwsim_flowsheet_menu()
'weight' => 1
);
$items['flowsheeting-project/abstract-code/upload'] = array(
- 'title' => 'Abstract Submission',
+ 'title' => 'Abstract and Flowsheet Submission',
'description' => 'Abstract Submission',
'page callback' => 'drupal_get_form',
'page arguments' => array(
@@ -326,10 +326,10 @@ function dwsim_flowsheet_menu()
'type' => MENU_CALLBACK,
'file' => 'full_download.inc'
);
- $items['flowsheeting-project/full-download/lab'] = array(
+ $items['flowsheeting-project/full-download/project'] = array(
'title' => 'Code Download',
'description' => 'Code Download',
- 'page callback' => 'dwsim_flowsheet_download_full_lab',
+ 'page callback' => 'dwsim_flowsheet_download_full_project',
'access arguments' => array(
'dwsim flowsheet approve code'
),
@@ -438,7 +438,7 @@ function dwsim_flowsheet_menu()
"title" => "Ajax callbacks",
"page callback" => "lab_bulk_manage_exp_ajax",
"access arguments" => array(
- "dwsim flowsheet bulk manage code"
+ "dwsim flowsheet bulk manage abstract"
),
"type" => MENU_CALLBACK,
'file' => 'bulk_approval.inc'
@@ -446,7 +446,7 @@ function dwsim_flowsheet_menu()
/* $items["dwsim_flowsheet/code_approval/dependency/ajax"] = array(
"title" => "Ajax callbacks",
"page callback" => "dwsim_flowsheet_dependency_approval_ajax",
- "access arguments" => array("dwsim flowsheet bulk manage code"),
+ "access arguments" => array("dwsim flowsheet bulk manage abstract"),
"type" => MENU_CALLBACK,
'file' => 'dependency_approval.inc',
);*/
@@ -478,23 +478,23 @@ function dwsim_flowsheet_permission()
'title' => t('dwsim flowsheet propose solution'),
'restrict access' => TRUE
),
- 'dwsim flowsheet approve code' => array(
+ 'dwsim flowsheet approve abstract' => array(
'title' => t('dwsim flowsheet approve code'),
'restrict access' => TRUE
),
- 'dwsim flowsheet bulk manage code' => array(
- 'title' => t('dwsim flowsheet bulk manage code'),
+ 'dwsim flowsheet bulk manage abstract' => array(
+ 'title' => t('dwsim flowsheet bulk manage abstract'),
'restrict access' => TRUE
),
- 'dwsim flowsheet bulk delete code' => array(
+ 'dwsim flowsheet bulk delete abstract' => array(
'title' => t('dwsim flowsheet bulk delete code'),
'restrict access' => TRUE
),
- 'dwsim flowsheet upload code' => array(
+ 'dwsim flowsheet upload abstract' => array(
'title' => t('dwsim flowsheet upload code'),
'restrict access' => TRUE
),
- 'dwsim flowsheet download code' => array(
+ 'dwsim flowsheet download abstract' => array(
'title' => t('dwsim flowsheet download code'),
'restrict access' => TRUE
),
@@ -502,12 +502,12 @@ function dwsim_flowsheet_permission()
'title' => t('administer dwsim flowsheet'),
'restrict access' => TRUE
),
- 'dwsim flowsheet generate lab' => array(
- 'title' => t('dwsim flowsheet generate lab'),
+ 'dwsim flowsheet generate abstract' => array(
+ 'title' => t('dwsim flowsheet generate abstract'),
'restrict access' => TRUE
)
);
- // return array('dwsim flowsheet create proposal', 'dwsim flowsheet manage proposal', 'dwsim flowsheet edit proposal', 'dwsim flowsheet approve proposal', 'dwsim flowsheet propose solution', 'dwsim flowsheet approve code', 'dwsim flowsheet bulk manage code', 'dwsim flowsheet bulk delete code', 'dwsim flowsheet upload code', 'dwsim flowsheet download code', 'administer dwsim flowsheet', 'dwsim flowsheet generate lab');
+ // return array('dwsim flowsheet create proposal', 'dwsim flowsheet manage proposal', 'dwsim flowsheet edit proposal', 'dwsim flowsheet approve proposal', 'dwsim flowsheet propose solution', 'dwsim flowsheet approve code', 'dwsim flowsheet bulk manage abstract', 'dwsim flowsheet bulk delete code', 'dwsim flowsheet upload code', 'dwsim flowsheet download code', 'administer dwsim flowsheet', 'dwsim flowsheet generate lab');
}
/* AJAX CALLS */
function dwsim_flowsheet_ajax()
@@ -859,7 +859,7 @@ function CreateReadmeFileDWSIMFlowsheetingProject($proposal_id)
$txt .= "About the lab";
$txt .= "\n" . "\n";
$txt .= "Title Of The Flowsheet Project: " . $proposal_data->project_title . "\n";
- $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->student_name . "\n";
+ $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n";
$txt .= "University: " . $proposal_data->university . "\n";
$txt .= "\n" . "\n";
$txt .= "DWSIM Flowsheet Project By FOSSEE, IIT Bombay" . "\n";
@@ -932,15 +932,16 @@ function rrmdir($dir)
function _dwsim_flowsheet_list_of_user_defined_compound($proposal_id)
{
$data = "";
- $query = db_select('dwsim_flowsheet_user_defined_compound');
- $query->fields('dwsim_flowsheet_user_defined_compound');
- $query->condition('proposal_id', $proposal_id, '=');
- $query->orderBy('user_defined_compound', 'ASC');
- $user_defined_compound_list = $query->execute();
+ //$query = db_select('dwsim_flowsheet_user_defined_compound');
+ //$query->fields('dwsim_flowsheet_user_defined_compound');
+ //$query->condition('proposal_id', $proposal_id, '=');
+ //$query->orderBy('user_defined_compound', 'ASC');
+ $user_defined_compound_list = db_query("SELECT * FROM dwsim_flowsheet_user_defined_compound WHERE proposal_id = :proposal_id", array(":proposal_id" => $proposal_id));
$headers = array(
- "User defined compound",
+ "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())
{
@@ -950,9 +951,13 @@ function _dwsim_flowsheet_list_of_user_defined_compound($proposal_id)
);
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/email.inc b/email.inc
index 714d1d3..0cd2030 100755
--- a/email.inc
+++ b/email.inc
@@ -218,10 +218,10 @@ FOSSEE,IIT Bombay', array(
/* initializing data */
$query = db_select('dwsim_flowsheet_proposal');
$query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $params['dwsim_flowsheet_proposal_approved']['proposal_id']);
+ $query->condition('id', $params['dwsim_flowsheet_proposal_completed']['proposal_id']);
$query->range(0, 1);
$proposal_data = $query->execute()->fetchObject();
- $user_data = user_load($params['dwsim_flowsheet_proposal_approved']['user_id']);
+ $user_data = user_load($params['dwsim_flowsheet_proposal_completed']['user_id']);
if ($proposal_data->project_guide_name == "NULL" || $proposal_data->project_guide_name == "")
{
$project_guide_name = "Not Entered";
@@ -238,7 +238,7 @@ FOSSEE,IIT Bombay', array(
{
$project_guide_email_id = $proposal_data->project_guide_email_id;
}
- $message['headers'] = $params['dwsim_flowsheet_proposal_approved']['headers'];
+ $message['headers'] = $params['dwsim_flowsheet_proposal_completed']['headers'];
$message['subject'] = t('[!site_name][Flowsheeting Project] Your DWSIM Flowsheeting Project proposal has been completed', array(
'!site_name' => variable_get('site_name', '')
), array(
diff --git a/flowsheet_details.inc b/flowsheet_details.inc
index 1626754..61f6968 100755
--- a/flowsheet_details.inc
+++ b/flowsheet_details.inc
@@ -6,7 +6,7 @@ function dwsim_flowsheet_completed_proposals_all()
$query = db_select('dwsim_flowsheet_proposal');
$query->fields('dwsim_flowsheet_proposal');
$query->condition('approval_status', 3);
- $query->condition('is_completed', 1);
+ //$query->condition('is_completed', 1);
$result = $query->execute();
if ($result->rowCount() == 0)
{
diff --git a/full_download.inc b/full_download.inc
index a8e7173..1fd9b58 100755
--- a/full_download.inc
+++ b/full_download.inc
@@ -1,241 +1,134 @@
<?php
// $Id$
-function lab_migration_download_full_experiment()
- {
- $experiment_id = arg(3);
- $root_path = lab_migration_path();
- $APPROVE_PATH = 'APPROVED/';
- $PENDING_PATH = 'PENDING/';
- /* get solution data */
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE id = %d", $experiment_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_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);
- /* approved solutions */
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_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 * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
- /*$query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_row->id);
- $solution_files_q = $query->execute();*/
- $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
- //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
- }
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
- {
- // $dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
- /* unapproved solutions */
- // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_id);
- $query->condition('approval_status', 0);
- $solution_q = $query->execute();
- while ($solution_row = $solution_q->fetchObject())
- {
- $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
- //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
- /*$query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_row->id);
- $solution_files_q = $query->execute();*/
- $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
-
- //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_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, $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
- }
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
- {
- // $dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_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, $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
- $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));
- readfile($zip_filename);
- unlink($zip_filename);
- }
- else
- {
- drupal_set_message("There are no solutions in this experiment to download", 'error');
- drupal_goto('lab-migration/code-approval/bulk');
- }
- }
-function lab_migration_download_full_lab()
- {
- $lab_id = arg(3);
- var_dump($lab_id);
- //die;
- $root_path = lab_migration_path();
- $APPROVE_PATH = 'APPROVED/';
- $PENDING_PATH = 'PENDING/';
- /* get solution data */
- //$lab_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $lab_id);
- $query = db_select('lab_migration_proposal');
- $query->fields('lab_migration_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);
- /* approved solutions */
- //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $lab_id);
- $query = db_select('lab_migration_experiment');
- $query->fields('lab_migration_experiment');
- $query->condition('proposal_id', $lab_id);
- $experiment_q = $query->execute();
- while ($experiment_row = $experiment_q->fetchObject())
- {
- $EXP_PATH = 'EXP' . $experiment_row->number . '/';
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 1", $experiment_row->id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_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 * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
- /*$query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_row->id);
- $solution_files_q = $query->execute();*/
- $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
- //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
- }
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
- {
- //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_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, $APPROVE_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
- /* unapproved solutions */
- //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE experiment_id = %d AND approval_status = 0", $experiment_row->id);
- $query = db_select('lab_migration_solution');
- $query->fields('lab_migration_solution');
- $query->condition('experiment_id', $experiment_row->id);
- $query->condition('approval_status', 0);
- $solution_q = $query->execute();
- while ($solution_row = $solution_q->fetchObject())
- {
- $CODE_PATH = 'CODE' . $solution_row->code_number . '/';
- //$solution_files_q = db_query("SELECT * FROM {lab_migration_solution_files} WHERE solution_id = %d", $solution_row->id);
- /* $query = db_select('lab_migration_solution_files');
- $query->fields('lab_migration_solution_files');
- $query->condition('solution_id', $solution_row->id);
- $solution_files_q = $query->execute();*/
- $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM lab_migration_solution_files lmsf JOIN lab_migration_solution lms JOIN lab_migration_experiment lme JOIN lab_migration_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));
-
- //$solution_dependency_files_q = db_query("SELECT * FROM {lab_migration_solution_dependency} WHERE solution_id = %d", $solution_row->id);
- $query = db_select('lab_migration_solution_dependency');
- $query->fields('lab_migration_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, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . $solution_files_row->filename);
- }
- /* dependency files */
- while ($solution_dependency_files_row = $solution_dependency_files_q->fetchObject())
- {
- //$dependency_file_data = (db_query("SELECT * FROM {lab_migration_dependency_files} WHERE id = %d LIMIT 1", $solution_dependency_files_row->dependency_id))->fetchObject();
- $query = db_select('lab_migration_dependency_files');
- $query->fields('lab_migration_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, $LAB_PATH . $PENDING_PATH . $EXP_PATH . $CODE_PATH . 'DEPENDENCIES/' . $dependency_file_data->filename);
- }
- }
- }
- $zip_file_count = $zip->numFiles;
- $zip->close();
- if ($zip_file_count > 0)
- {
- /* download zip file */
- ob_clean();
- //flush();
- header('Content-Type: application/zip');
- header('Content-disposition: attachment; filename="' . $lab_data->lab_title . '.zip"');
- header('Content-Length: ' . filesize($zip_filename));
- readfile($zip_filename);
- unlink($zip_filename);
- }
- else
- {
- drupal_set_message("There are no solutions in this lab to download", 'error');
- drupal_goto('lab-migration/code-approval/bulk');
- }
- }
+function dwsim_flowsheet_download_full_project()
+{
+ global $user;
+ $flowsheet_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_udc_q = $query->execute();
+ while ($flowsheet_udc_row = $flowsheet_udc_q->fetchObject()) {
+ if ($flowsheet_udc_row->user_defined_compound_filepath || $flowsheet_udc_row->user_defined_compound_filepath != 'NULL') {
+ $USER_DEFINED_PATH = 'user_defined_compound/';
+ $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $flowsheet_udc_row->user_defined_compound_filepath, $USER_DEFINED_PATH . str_replace(' ', '_', basename($flowsheet_udc_row->user_defined_compound_filepath)));
+ } //$flowsheet_udc_row->user_defined_compound_filepath || $flowsheet_udc_row->user_defined_compound_filepath != 'NULL'
+ } //$flowsheet_udc_row = $flowsheet_udc_q->fetchObject()
+ $query = db_select('dwsim_flowsheet_submitted_abstracts_file');
+ $query->fields('dwsim_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 flowsheet project in this proposal to download", 'error');
+ drupal_goto('flowsheeting-project/full-download/project');
+ }
+}
+function dwsim_flowsheet_download_completed_project()
+{
+ global $user;
+ $flowsheet_id = arg(3);
+ $root_path = dwsim_flowsheet_path();
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $flowsheet_id);
+ $flowsheet_udc_q = $query->execute();
+ while ($flowsheet_udc_row = $flowsheet_udc_q->fetchObject()) {
+ if ($flowsheet_udc_row->user_defined_compound_filepath || $flowsheet_udc_row->user_defined_compound_filepath != 'NULL') {
+ $USER_DEFINED_PATH = 'user_defined_compound/';
+ $zip->addFile($root_path . $FLOWSHEET_PATH . '/' . $flowsheet_udc_row->user_defined_compound_filepath, $USER_DEFINED_PATH . str_replace(' ', '_', basename($flowsheet_udc_row->user_defined_compound_filepath)));
+ } //$flowsheet_udc_row->user_defined_compound_filepath || $flowsheet_udc_row->user_defined_compound_filepath != 'NULL'
+ } //$flowsheet_udc_row = $flowsheet_udc_q->fetchObject()
+ $query = db_select('dwsim_flowsheet_submitted_abstracts_file');
+ $query->fields('dwsim_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 flowsheet project in this proposal to download", 'error');
+ drupal_goto('flowsheeting-project/dwsim-flowsheet-run');
+ }
+}
diff --git a/general_deletion.inc b/general_deletion.inc
index 6999595..bbd4c46 100755
--- a/general_deletion.inc
+++ b/general_deletion.inc
@@ -2,300 +2,189 @@
/******************************************************************************/
/****************************** DELETION FUNCTIONS ****************************/
/******************************************************************************/
-function dwsim_flowsheet_delete_solution($solution_id)
- {
- global $user;
- $root_path = dwsim_flowsheet_path();
- $status = TRUE;
- //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE id = %d", $solution_id);
- $query = db_select('dwsim_flowsheet_solution');
- $query->fields('dwsim_flowsheet_solution');
- $query->condition('id', $solution_id);
- $solution_q = $query->execute();
- $solution_data = $solution_q->fetchObject();
- if (!$solution_data)
- {
- drupal_set_message(t('Invalid solution.'), 'error');
- return FALSE;
- }
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $solution_data->experiment_id);
- $experiment_q = db_query("SELECT lme.*, lmp.id, lmp.directory_name FROM dwsim_flowsheet_experiment lme JOIN dwsim_flowsheet_proposal lmp WHERE lmp.id = lme.proposal_id AND lme.id = :experiment_id",array(':experiment_id' => $solution_data->experiment_id));
- $experiment_data = $experiment_q->fetchObject();
- if (!$experiment_data)
- {
- drupal_set_message(t('Invalid experiment.'), 'error');
- return FALSE;
- }
- /* deleting solution files */
- //$solution_files_q = db_query("SELECT * FROM {dwsim_flowsheet_solution_files} WHERE solution_id = %d", $solution_id);
- $solution_files_q = db_query("SELECT lmsf.*, lmp.directory_name FROM dwsim_flowsheet_solution_files lmsf JOIN dwsim_flowsheet_solution lms JOIN dwsim_flowsheet_experiment lme JOIN dwsim_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('dwsim_flowsheet_solution_files');
- $query->fields('dwsim_flowsheet_solution_files');
- $query->condition('solution_id', $solution_id);
- $solution_files_q = $query->execute();*/
- while ($solution_files_data = $solution_files_q->fetchObject())
- {
- if (!file_exists($root_path .$solution_files_data->directory_name. '/'. $solution_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file. File does not exists.', array(
- '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath
- )), 'error');
- continue;
- }
- /* removing solution file */
- if (!unlink($root_path . $solution_files_data->directory_name. '/'. $solution_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file', array(
- '!file' => $solution_files_data->directory_name. '/' . $solution_files_data->filepath
- )), 'error');
- /* sending email to admins */
- $email_to = variable_get('dwsim_flowsheet_emails', '');
- $from = variable_get('dwsim_flowsheet_from_email', '');
- $bcc = "";
- $cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting example file";
- $param['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
- solution id : " . $solution_id . "
- file id : " . $solution_files_data->id . "
- file path : " . $solution_files_data->directory_name. '/'. $solution_files_data->filepath . "
- PDF path : " . $PdfStatus;
- $param['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('dwsim_flowsheet', 'standard', $email_to, language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- }
- else
- {
- /* deleting example files database entries */
- db_delete('dwsim_flowsheet_solution_files')->condition('id', $solution_files_data->id)->execute();
- }
- }
- if (!$status)
- return FALSE;
- /* removing code folder */
- $ex_path = $experiment_data->directory_name . '/EXP' . $experiment_data->number . '/CODE' . $solution_data->code_number;
- $dir_path = $root_path . $ex_path;
- if (is_dir($dir_path))
- {
- if (!rmdir($dir_path))
- {
- drupal_set_message(t('Error deleting folder !folder', array(
- '!folder' => $dir_path
- )), 'error');
- /* sending email to admins */
- $email_to = variable_get('dwsim_flowsheet_emails', '');
- $from = variable_get('dwsim_flowsheet_from_email', '');
- $bcc = "";
- $cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting folder";
- $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- $param['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('dwsim_flowsheet', 'standard', $email_to, language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- return FALSE;
- }
- }
- else
- {
- drupal_set_message(t('Cannot delete solution folder. !folder does not exists.', array(
- '!folder' => $dir_path
- )), 'error');
- return FALSE;
- }
- /* deleting solution dependency and solution database entries */
- db_delete('dwsim_flowsheet_solution_dependency')->condition('solution_id', $solution_id)->execute();
- db_delete('dwsim_flowsheet_solution')->condition('id', $solution_id)->execute();
- return $status;
- }
-function dwsim_flowsheet_delete_experiment($experiment_id)
- {
- $status = TRUE;
- $root_path = dwsim_flowsheet_path();
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE id = %d", $experiment_id);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('id', $experiment_id);
- $experiment_q = $query->execute();
- $experiment_data = $experiment_q->fetchObject();
- if (!$experiment_data)
- {
- drupal_set_message('Invalid experiment.', 'error');
- return FALSE;
- }
- /* deleting solutions */
- //$solution_q = db_query("SELECT * FROM {dwsim_flowsheet_solution} WHERE experiment_id = %d", $experiment_id);
- $query = db_select('dwsim_flowsheet_solution');
- $query->fields('dwsim_flowsheet_solution');
- $query->condition('experiment_id', $experiment_id);
- $solution_q = $query->execute();
- $delete_exp_folder = FALSE;
- while ($solution_data = $solution_q->fetchObject())
- {
- $delete_exp_folder = TRUE;
- if (!dwsim_flowsheet_delete_solution($solution_data->id))
- $status = FALSE;
- }
- if (!$delete_exp_folder)
- {
- return TRUE;
- }
- if ($status)
- {
- $dir_path = $root_path . $experiment_data->directory_name . '/EXP' . $experiment_data->number;
- if (is_dir($dir_path))
- {
- $res = rmdir($dir_path);
- if (!$res)
- {
- drupal_set_message(t('Error deleting experiment folder !folder', array(
- '!folder' => $dir_path
- )), 'error');
- /* sending email to admins */
- $email_to = variable_get('dwsim_flowsheet_emails', '');
- $from = variable_get('dwsim_flowsheet_from_email', '');
- $bcc = "";
- $cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting experiment folder";
- $param['standard']['body'] = "Error deleting folder " . $dir_path;
- $param['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('dwsim_flowsheet', 'standard', $email_to, language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- return FALSE;
- }
- else
- {
- return TRUE;
- }
- }
- else
- {
- drupal_set_message(t('Cannot delete experiment folder. !folder does not exists.', array(
- '!folder' => $dir_path
- )), 'error');
- return FALSE;
- }
- }
- return FALSE;
- }
-function dwsim_flowsheet_delete_lab($lab_id)
- {
- $status = TRUE;
- $root_path = dwsim_flowsheet_path();
- //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $lab_id);
- $query = db_select('dwsim_flowsheet_proposal');
- $query->fields('dwsim_flowsheet_proposal');
- $query->condition('id', $lab_id);
- $proposal_q = $query->execute();
- $proposal_data = $proposal_q->fetchObject();
- if (!$proposal_data)
- {
- drupal_set_message('Invalid Lab.', 'error');
- return FALSE;
- }
- /* delete experiments */
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d", $proposal_data->id);
- $query = db_select('dwsim_flowsheet_experiment');
- $query->fields('dwsim_flowsheet_experiment');
- $query->condition('proposal_id', $proposal_data->id);
- $experiment_q = $query->execute();
- while ($experiment_data = $experiment_q->fetchObject())
- {
- if (!dwsim_flowsheet_delete_experiment($experiment_data->id))
- {
- $status = FALSE;
- }
- }
- return $status;
- }
-function dwsim_flowsheet_del_lab_pdf($lab_id)
- {
- $root_path = dwsim_flowsheet_path();
- $dir_path = $root_path . "latex/";
- $pdf_filename = "lab_" . $lab_id . ".pdf";
- if (file_exists($dir_path . $pdf_filename))
- unlink($dir_path . $pdf_filename);
- }
-function dwsim_flowsheet_delete_dependency($dependency_id)
- {
- global $user;
- $root_path = dwsim_flowsheet_path();
- $status = TRUE;
- //$dependency_files_q = db_query("SELECT * FROM {dwsim_flowsheet_dependency_files} WHERE id = %d", $dependency_id);
- $query = db_select('dwsim_flowsheet_dependency_files');
- $query->fields('dwsim_flowsheet_dependency_files');
- $query->condition('id', $dependency_id);
- $dependency_files_q = $query->execute();
- $dependency_files_data = $dependency_files_q->fetchObject();
- if (!$dependency_files_data)
- {
- drupal_set_message(t('Invalid dependency.'), 'error');
- return FALSE;
- }
- if (!file_exists($root_path . $dependency_files_data->filepath))
- {
- drupal_set_message(t('Error deleting !file. File does not exists.', array(
- '!file' => $dependency_files_data->filepath
- )), 'error');
- return FALSE;
- }
- /* removing dependency file */
- if (!unlink($root_path . $dependency_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file', array(
- '!file' => $dependency_files_data->filepath
- )), 'error');
- /* sending email to admins */
- $email_to = variable_get('dwsim_flowsheet_emails', '');
- $from = variable_get('dwsim_flowsheet_from_email', '');
- $bcc = "";
- $cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting dependency file";
- $param['standard']['body'] = "Error deleting dependency files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
- dependency id : " . $dependency_id . "
- file id : " . $dependency_files_data->id . "
- file path : " . $dependency_files_data->filepath;
- $param['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('dwsim_flowsheet', 'standard', $email_to, language_default(), $param, $from, TRUE))
- drupal_set_message('Error sending email message.', 'error');
- }
- else
- {
- /* deleting dependency files database entries */
- db_delete('dwsim_flowsheet_dependency_files')->condition('id', $dependency_id)->execute();
- }
- return $status;
- }
+function dwsim_flowsheet_delete_abstract_file($abstract_id)
+{
+ $status = TRUE;
+ $root_path = dwsim_flowsheet_path();
+ $abstract_q = db_query("SELECT * from dwsim_flowsheet_proposal dfp
+LEFT JOIN dwsim_flowsheet_submitted_abstracts dfsa ON dfp.id = dfsa.proposal_id
+WHERE dfsa.id = :abstract_id", array(
+ ":abstract_id" => $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('dwsim_flowsheet_submitted_abstracts_file');
+ $query->fields('dwsim_flowsheet_submitted_abstracts_file');
+ $query->condition('submitted_abstract_id', $abstract_id);
+ $abstract_f_q = $query->execute();
+ $delete_project_folder = FALSE;
+ while ($abstract_f_data = $abstract_f_q->fetchObject())
+ {
+ $delete_project_folder = TRUE;
+ if (!_dwsim_flowsheet_delete_abstract_file($abstract_f_data->id))
+ $status = FALSE;
+ } //$abstract_f_data = $abstract_f_q->fetchObject()
+ if (!$delete_project_folder)
+ {
+ return TRUE;
+ } //!$delete_project_folder
+ if ($status)
+ {
+ $dir_path_udc = $root_path . $abstract_f_data->directory_name . '/user_defined_compound';
+ if (is_dir($dir_path_udc))
+ {
+ unlink($root_path . $abstract_f_data->directory_name . '/' . $abstract_f_data->user_defined_compound_filepath);
+ $res = rmdir($dir_path_udc);
+ if (!$res)
+ {
+ drupal_set_message(t('Error in deleting user defiend folder !folder', array(
+ '!folder' => $abstract_f_data->directory_name
+ )), 'error');
+ /* sending email to admins */
+ $email_to = variable_get('dwsim_flowsheet_emails', '');
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = "";
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['standard']['subject'] = "[ERROR] Error deleting experiment folder";
+ $params['standard']['body'] = "Error deleting folder " . $dir_path;
+ $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('dwsim_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ return FALSE;
+ } //!$res
+ else
+ {
+ return TRUE;
+ }
+ } //is_dir($dir_path_udc)
+ } //$status
+ return FALSE;
+}
+function dwsim_flowsheet_abstract_delete_project($proposal_id)
+{
+ $status = TRUE;
+ $root_path = dwsim_flowsheet_path();
+ //$proposal_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE id = %d", $lab_id);
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_data->id);
+ $abstract_q = $query->execute();
+ while ($abstract_data = $abstract_q->fetchObject())
+ {
+ if (!dwsim_flowsheet_delete_abstract_file($abstract_data->id))
+ {
+ $status = FALSE;
+ } //!dwsim_flowsheet_delete_abstract_file($abstract_data->id)
+ } //$abstract_data = $abstract_q->fetchObject()
+ db_delete('dwsim_flowsheet_submitted_abstracts')->condition('proposal_id', $proposal_data->id)->execute();
+ $dir_path_udc = $root_path . $proposal_data->directory_name . '/user_defined_compound';
+ if (is_dir($dir_path_udc))
+ {
+ unlink($root_path . $proposal_data->directory_name . '/' . $proposal_data->user_defined_compound_filepath);
+ $res = rmdir($dir_path_udc);
+ } //is_dir($dir_path_udc)
+ $dir_main_path = $root_path . $proposal_data->directory_name;
+ if (is_dir($dir_main_path))
+ {
+ $res_main = rmdir($dir_main_path);
+ } //is_dir($dir_main_path)
+ db_delete('dwsim_flowsheet_proposal')->condition('id', $proposal_data->id)->execute();
+ return $status;
+}
+function _dwsim_flowsheet_delete_abstract_file($abstract_id)
+{
+ global $user;
+ $root_path = dwsim_flowsheet_path();
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $abstract_id);
+ $abstract_q = $query->execute();
+ $abstract_data = $abstract_q->fetchObject();
+ $abstract_q = db_query("SELECT * from dwsim_flowsheet_proposal dfp
+LEFT JOIN dwsim_flowsheet_submitted_abstracts dfsa ON dfp.id = dfsa.proposal_id
+WHERE dfsa.id = :abstract_id", array(
+ ":abstract_id" => $abstract_id
+ ));
+ $abstract_data = $abstract_q->fetchObject();
+ if (!$abstract_data)
+ {
+ drupal_set_message('Invalid flowsheet project abstract.', 'error');
+ return FALSE;
+ } //!$abstract_data
+ /* deleting abstract files */
+ $query = db_select('dwsim_flowsheet_submitted_abstracts_file');
+ $query->fields('dwsim_flowsheet_submitted_abstracts_file');
+ $query->condition('submitted_abstract_id', $abstract_id);
+ $abstract_f_q = $query->execute();
+ while ($abstract_f_data = $abstract_f_q->fetchObject())
+ {
+ if (!file_exists($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file. File does not exists.', array(
+ '!file' => $abstract_data->directory_name . '/' . $abstract_f_data->filepath
+ )), 'error');
+ continue;
+ } //!file_exists($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath)
+ /* removing solution file */
+ if (!unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath))
+ {
+ $status = FALSE;
+ drupal_set_message(t('Error deleting !file', array(
+ '!file' => $abstract_data->directory_name . '/' . $abstract_f_data->filepath
+ )), 'error');
+ /* sending email to admins */
+ $from = variable_get('dwsim_flowsheet_from_email', '');
+ $bcc = variable_get('dwsim_flowsheet_emails', '');
+ $cc = variable_get('dwsim_flowsheet_cc_emails', '');
+ $params['standard']['subject'] = "[ERROR] Error deleting example file";
+ $params['standard']['body'] = "Error deleting solution files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
+ file id : " . $abstract_data->id . "
+ file path : " . $abstract_data->directory_name . '/' . $abstract_f_data->filepath;
+ $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('dwsim_flowsheet', 'standard', $email_to, language_default(), $params, $from, TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ } //!unlink($root_path . $abstract_data->directory_name . '/' . $abstract_f_data->filepath)
+ else
+ {
+ /* deleting example files database entries */
+ db_delete('dwsim_flowsheet_submitted_abstracts_file')->condition('id', $abstract_f_data->id)->execute();
+ }
+ } //$abstract_f_data = $abstract_f_q->fetchObject()
+ if (!$status)
+ {
+ return FALSE;
+ } //!$status
+ return $status;
+}
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 3e07608..b1a7a92 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -205,6 +205,11 @@ function dwsim_flowsheet_proposal_approval_form($form, &$form_state)
'#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'),
@@ -294,12 +299,13 @@ function dwsim_flowsheet_proposal_approval_form($form, &$form_state)
'#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
'#markup' => $proposal_data->dwsim_database_compound_name
);
+
$form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
'#type' => 'item',
'#title' => t('List of user defined compounds used in process flowsheet'),
'#markup' => _dwsim_flowsheet_list_of_user_defined_compound($proposal_id)
);
- if ($proposal_data->user_defined_compound_filepath != "")
+ if (($proposal_data->user_defined_compound_filepath != "") && ($proposal_data->user_defined_compound_filepath != 'NULL'))
{
$form['user_defined_compound_filepath'] = array(
'#type' => 'item',
@@ -572,12 +578,31 @@ function dwsim_flowsheet_proposal_status_form($form, &$form_state)
'#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
'#markup' => $proposal_data->dwsim_database_compound_name
);
- if ($proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL)
+ $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
+ if (_dwsim_flowsheet_list_of_user_defined_compound($proposal_data->id) != "Not entered")
{
$form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
'#type' => 'item',
'#title' => t('List of user defined compounds used in process flowsheet'),
- '#markup' => $proposal_data->user_defined_compounds_used_in_process
+ '#markup' => _dwsim_flowsheet_list_of_user_defined_compound($proposal_data->id)
);
} //$proposal_data->user_defined_compounds_used_in_process != "" || $proposal_data->user_defined_compounds_used_in_process != NULL
else
@@ -588,7 +613,7 @@ function dwsim_flowsheet_proposal_status_form($form, &$form_state)
'#markup' => "Not entered"
);
}
- if ($proposal_data->user_defined_compound_filepath != "")
+ if ($proposal_data->user_defined_compound_filepath != "" && $proposal_data->user_defined_compound_filepath != "NULL")
{
$form['user_defined_compound_filepath'] = array(
'#type' => 'item',
@@ -604,25 +629,6 @@ function dwsim_flowsheet_proposal_status_form($form, &$form_state)
'#markup' => "Not uploaded<br><br>"
);
}
- $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,
@@ -713,9 +719,9 @@ function dwsim_flowsheet_proposal_status_form_submit($form, &$form_state)
$from = variable_get('dwsim_flowsheet_from_email', '');
$bcc = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');
$cc = variable_get('dwsim_flowsheet_cc_emails', '');
- $params['proposal_completed']['proposal_id'] = $proposal_id;
- $params['proposal_completed']['user_id'] = $proposal_data->uid;
- $params['proposal_completed']['headers'] = array(
+ $params['dwsim_flowsheet_proposal_completed']['proposal_id'] = $proposal_id;
+ $params['dwsim_flowsheet_proposal_completed']['user_id'] = $proposal_data->uid;
+ $params['dwsim_flowsheet_proposal_completed']['headers'] = array(
'From' => $from,
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
@@ -724,11 +730,8 @@ function dwsim_flowsheet_proposal_status_form_submit($form, &$form_state)
'Cc' => $cc,
'Bcc' => $bcc
);
- if (!drupal_mail('dwsim_flowsheet', 'proposal_completed', $email_to, language_default(), $params, $from, TRUE))
+ if (!drupal_mail('dwsim_flowsheet', 'dwsim_flowsheet_proposal_completed', $email_to, language_default(), $params, $from, TRUE))
drupal_set_message('Error sending email message.', 'error');
- /*$email_to = $user->mail . ', ' . variable_get('dwsim_flowsheet_emails', '');;
- if (!drupal_mail('dwsim_flowsheet', 'proposal_completed', $email_to , language_default(), $params, variable_get('dwsim_flowsheet_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');*/
drupal_set_message('Congratulations! DWSIM 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');
diff --git a/proposal.inc b/proposal.inc
index 03369ef..846238e 100755
--- a/proposal.inc
+++ b/proposal.inc
@@ -549,7 +549,7 @@ function dwsim_flowsheet_proposal_form_validate($form, &$form_state)
} //$form_state['values']['version'] == 'Old version'
if ($form_state['values']['dwsim_database_compound_name'])
{
- $dwsim_database_compound_name = implode(", ", $_POST['dwsim_database_compound_name']);
+ $dwsim_database_compound_name = implode("| ", $_POST['dwsim_database_compound_name']);
$form_state['values']['dwsim_database_compound_name'] = trim($dwsim_database_compound_name);
} //$form_state['values']['dwsim_database_compound_name']
if ($form_state['values']['ucompound'] == 1)
diff --git a/run.inc b/run.inc
new file mode 100755
index 0000000..2b38df7
--- /dev/null
+++ b/run.inc
@@ -0,0 +1,144 @@
+<?php
+function dwsim_flowsheet_run_form($form, &$form_state)
+{
+ $options_first = _list_of_flowsheet();
+ $url_flowsheet_id = (int) arg(2);
+ $flowsheet_data = _flowsheet_information($url_flowsheet_id);
+ if ($flowsheet_data == 'Not found') {
+ $url_flowsheet_id = '';
+ } //$flowsheet_data == 'Not found'
+ if (!$url_flowsheet_id) {
+ $selected = isset($form_state['values']['flowsheet']) ? $form_state['values']['flowsheet'] : key($options_first);
+ } //!$url_flowsheet_id
+ elseif ($url_flowsheet_id == '') {
+ $selected = 0;
+ } //$url_flowsheet_id == ''
+ else {
+ $selected = $url_flowsheet_id;
+ }
+ $form = array();
+ $form['flowsheet'] = array(
+ '#type' => 'select',
+ '#title' => t('Title of the flowsheet'),
+ '#options' => _list_of_flowsheet(),
+ '#default_value' => $selected,
+ '#ajax' => array(
+ 'callback' => 'dwsim_flowsheet_project_details_callback'
+ )
+ );
+ if (!$url_flowsheet_id) {
+ $form['flowsheet_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_flowsheet_details"></div>'
+ );
+ $form['selected_flowsheet'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_flowsheet"></div>'
+ );
+ } //!$url_flowsheet_id
+ else {
+ $flowsheet_default_value = $url_flowsheet_id;
+ $form['flowsheet_details'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_flowsheet_details">' . _flowsheet_details($flowsheet_default_value) . '</div>'
+ );
+ $form['selected_flowsheet'] = array(
+ '#type' => 'item',
+ '#markup' => '<div id="ajax_selected_flowsheet">' . l('Download Flowsheet', 'flowsheeting-project/full-download/project/' . $flowsheet_default_value) . '</div>'
+ );
+ }
+ return $form;
+}
+function dwsim_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));
+ } //$flowsheet_details->uid > 0
+ else {
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet', '');
+ $commands[] = ajax_command_html('#ajax_selected_flowsheet_dwsim', '');
+ }
+ $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_dwsim', '');
+ $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 .= "<th>{$header}</th>";
+ } //$headers as $header
+ foreach ($rows as $row) {
+ $tbody .= "<tr>";
+ foreach ($row as $data) {
+ $tbody .= "<td>{$data}</td>";
+ } //$row as $data
+ $tbody .= "</tr>";
+ } //$rows as $row
+ $table = "
+ <table class='table table-bordered table-hover' style='margin-left:-140px'>
+ <thead>{$thead}</thead>
+ <tbody>{$tbody}</tbody>
+ </table>
+ ";
+ return $table;
+}
+/*****************************************************/
+function _list_of_flowsheet()
+{
+ $flowsheet_titles = array(
+ '0' => 'Please select...'
+ );
+ //$lab_titles_q = db_query("SELECT * FROM {dwsim_flowsheet_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_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'] = '<span style="color: rgb(128, 0, 0);"><strong>About the Flowsheet</strong></span></td><td style="width: 35%;"><br />' . '<ul>' . '<li><strong>Proposer Name:</strong> ' . $flowsheet_details->name_title . ' ' . $flowsheet_details->contributor_name . '</li>' . '<li><strong>Title of the Flowhseet:</strong> ' . $flowsheet_details->project_title . '</li>' . '<li><strong>University:</strong> ' . $flowsheet_details->university . '</li>' . '</ul>';
+ $details = $form['flowsheet_details']['#markup'];
+ return $details;
+ } //$flowsheet_default_value != 0
+}
diff --git a/upload_code.inc b/upload_code.inc
index 49f5ed7..3591a64 100755
--- a/upload_code.inc
+++ b/upload_code.inc
@@ -10,87 +10,105 @@ function dwsim_flowsheet_abstract()
drupal_goto('');
return;
} //!$proposal_data
-
//$return_html .= l('Upload abstract', 'flowsheeting-project/abstract-code/upload') . '<br />';
/* get experiment list */
- $experiment_rows = array();
- //$experiment_q = db_query("SELECT * FROM {dwsim_flowsheet_experiment} WHERE proposal_id = %d ORDER BY number ASC", $proposal_data->id);
-
$query = db_select('dwsim_flowsheet_submitted_abstracts');
$query->fields('dwsim_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
+ }
$query_pro = db_select('dwsim_flowsheet_proposal');
$query_pro->fields('dwsim_flowsheet_proposal');
$query_pro->condition('id', $proposal_data->id);
$abstracts_pro = $query_pro->execute()->fetchObject();
-
-
$query_pdf = db_select('dwsim_flowsheet_submitted_abstracts_file');
$query_pdf->fields('dwsim_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;
- }else{
- $abstract_filename = "File not uploaded";
- }
- }else{
- $abstract_filename = "File not uploaded";
+ 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('dwsim_flowsheet_submitted_abstracts_file');
$query_process->fields('dwsim_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;
- }else{
- $abstracts_query_process_filename = "File not uploaded";
- }
- }else{
- $abstracts_query_process_filename = "File not uploaded";
- }
- if($abstracts_q->is_submitted == ''){
- $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
- }
- else if($abstracts_q->is_submitted == 1){
- $url= "";
- }else if($abstracts_q->is_submitted == 0 ){
- $url= l('Edit abstract', 'flowsheeting-project/abstract-code/edit');
-
- }
- if($abstracts_q->unit_operations_used_in_dwsim ==''){
- $unit_operations_used_in_dwsim = "Not entered";
- }else{
-
- $unit_operations_used_in_dwsim = $abstracts_q->unit_operations_used_in_dwsim;
- }
-
- if($abstracts_q->thermodynamic_packages_used ==''){
- $thermodynamic_packages_used = "Not entered";
- }else{
-
- $thermodynamic_packages_used = $abstracts_q->thermodynamic_packages_used;
- }
- if($abstracts_q->logical_blocks_used ==''){
- $logical_blocks_used = "Not entered";
- }else{
-
- $logical_blocks_used = $abstracts_q->logical_blocks_used;
+ //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->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_dwsim == '')
+ {
+ $unit_operations_used_in_dwsim = "Not entered";
+ } //$abstracts_q->unit_operations_used_in_dwsim == ''
+ else
+ {
+ $unit_operations_used_in_dwsim = $abstracts_q->unit_operations_used_in_dwsim;
+ }
+ 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;
+ }
+ if ($abstracts_q->logical_blocks_used == '')
+ {
+ $logical_blocks_used = "Not entered";
+ } //$abstracts_q->logical_blocks_used == ''
+ else
+ {
+ $logical_blocks_used = $abstracts_q->logical_blocks_used;
+ }
+ } //$abstracts_query_process == TRUE
+ else
+ {
+ $url = l('Upload abstract', 'flowsheeting-project/abstract-code/upload');
+ $unit_operations_used_in_dwsim = "Not entered";
+ $thermodynamic_packages_used = "Not entered";
+ $logical_blocks_used = "Not entered";
+ $abstracts_query_process_filename = "File not uploaded";
}
-
$headers = array(
"Name of compound for which process development is carried out",
"CAS No."
@@ -105,24 +123,18 @@ function dwsim_flowsheet_abstract()
'header' => $headers,
'rows' => $rows
));
-
$return_html .= '<strong>Proposer Name:</strong><br />' . $proposal_data->name_title . ' ' . $proposal_data->contributor_name . '<br /><br />';
-
$return_html .= '<strong>Title of the Flowsheet Project:</strong><br />' . $proposal_data->project_title . '<br /><br />';
-
-
$return_html .= '<strong>DWSIM version:</strong><br />' . $proposal_data->version . '<br /><br />';
-
$return_html .= '<strong>Unit Operations used in DWSIM:</strong><br />' . $unit_operations_used_in_dwsim . '<br /><br />';
$return_html .= '<strong>Thermodynamic Packages Used:</strong><br />' . $thermodynamic_packages_used . '<br /><br />';
$return_html .= '<strong>Logical Blocks used:</strong><br />' . $logical_blocks_used . '<br /><br />';
- $return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' .$prodata . '<br />';
+ $return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata . '<br />';
$return_html .= '<strong>List of compounds from DWSIM Database used in process flowsheet:</strong><br />' . $proposal_data->dwsim_database_compound_name . '<br /><br />';
$return_html .= '<strong>List of user defined compounds used in process flowsheet:</strong><br />' . _dwsim_flowsheet_list_of_user_defined_compound($proposal_data->id) . '<br />';
$return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />';
$return_html .= '<strong>Upload the DWSIM flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />';
$return_html .= $url . '<br />';
-
return $return_html;
}
function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
@@ -159,6 +171,18 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
drupal_goto('flowsheeting-project/abstract-code');
return;
}
+ $query = db_select('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_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
$form['project_title'] = array(
'#type' => 'item',
'#markup' => $proposal_data->project_title,
@@ -168,34 +192,93 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
'#type' => 'item',
'#title' => t('DWSIM version'),
'#markup' => $proposal_data->version
- );
- $form['unit_operations_used_in_dwsim'] = array(
- '#type' => 'select',
- '#title' => t('Unit Operations used in DWSIM'),
- '#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]')
- );
- $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]')
- );
- $form['logical_blocks_used'] = array(
- '#type' => 'select',
- '#title' => t('Logical Blocks used (If any)'),
- '#options' => _df_list_of_logical_block(),
- '#multiple' => TRUE,
- '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
- );
+ );
+
+ if($abstracts_q == TRUE){
+
+ if ($abstracts_q->unit_operations_used_in_dwsim)
+ {
+ $existing_unit_operations_used_in_dwsim = default_value_for_selections("unit_operations_used_in_dwsim", $proposal_data->id);
+ $form['unit_operations_used_in_dwsim'] = array(
+ '#type' => 'select',
+ '#title' => t('Unit Operations used in DWSIM'),
+ '#options' => _df_list_of_unit_operations(),
+ '#required' => TRUE,
+ '#default_value' => $existing_unit_operations_used_in_dwsim,
+ '#size' => '20',
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ } }//$abstracts_q->unit_operations_used_in_dwsim
+ else
+ {
+ $form['unit_operations_used_in_dwsim'] = array(
+ '#type' => 'select',
+ '#title' => t('Unit Operations used in DWSIM'),
+ '#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);
+ //var_dump($existing_thermodynamic_packages_used);die;
+ $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
+ }
+ 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]')
+ );
+ }
+ if($abstracts_q == TRUE){
+ if ($abstracts_q->logical_blocks_used != "Not entered")
+ {
+ $existing_logical_blocks_used = default_value_for_selections("logical_blocks_used", $proposal_data->id);
+ $form['logical_blocks_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Logical Blocks used (If any)'),
+ '#options' => _df_list_of_logical_block(),
+ '#default_value' => $existing_logical_blocks_used,
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ } //$abstracts_q->logical_blocks_used != "Not entered"
+ }
+ else
+ {
+ $form['logical_blocks_used'] = array(
+ '#type' => 'select',
+ '#title' => t('Logical Blocks used (If any)'),
+ '#options' => _df_list_of_logical_block(),
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+
+ }
$headers = array(
- "User defined compound",
+ "Name of compound for which process development is carried out",
"CAS No."
);
$rows = array();
@@ -213,24 +296,57 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
'#title' => t('Name of compound for which process development is carried out'),
'#markup' => $prodata
);
- //var_dump( _df_list_of_dwsim_compound($proposal_data->id));die;
- $form['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = array(
- '#type' => 'textfield',
- '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
- '#value' => $proposal_data->dwsim_database_compound_name,
- '#size' => 20,
- '#disabled' => TRUE,
- );
+ if ($proposal_data->dwsim_database_compound_name)
+ {
+ $existing_dwsim_database_compound_name = default_value_for_selections("dwsim_database_compound_name", $proposal_data->id);
+ //var_dump($existing_dwsim_database_compound_name);die;
+ $form['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = array(
+ '#type' => 'select',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#options' => _df_list_of_dwsim_compound(),
+ '#default_value' => $existing_dwsim_database_compound_name,
+ '#size' => '20',
+ '#multiple' => TRUE,
+ '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
+ );
+ } //$proposal_data->dwsim_database_compound_name
+ else
+ {
+ $form['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = array(
+ '#type' => 'slect',
+ '#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
+ '#options' => _df_list_of_dwsim_compound(),
+ '#size' => '20',
+ '#multiple' => TRUE
+ );
+ }
+
+ $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";
+ }
$form['upload_an_abstract'] = array(
'#type' => 'file',
'#title' => t('Upload an abstract (brief outline) of the project.'),
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_abstract_upload_extensions', '') . '</span>'
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_A_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_abstract_upload_extensions', '') . '</span>'
);
+
+ $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";
+ }
$form['upload_flowsheet_developed_process'] = array(
'#type' => 'file',
'#title' => t('Upload the DWSIM flowsheet for the developed process.'),
- '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '') . '</span>'
+ '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_S_file->filename . '<br />Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '') . '</span>'
+ );
+ $form['prop_id'] = array(
+ '#type' => 'hidden',
+ '#value' => $proposal_data->id
);
$form['submit'] = array(
'#type' => 'submit',
@@ -242,7 +358,6 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
);
return $form;
}
-
function dwsim_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
{
if ($form_state['values']['unit_operations_used_in_dwsim'])
@@ -250,65 +365,92 @@ function dwsim_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
$unit_operations_used_in_dwsim = implode(", ", $_POST['unit_operations_used_in_dwsim']);
$form_state['values']['unit_operations_used_in_dwsim'] = $unit_operations_used_in_dwsim;
} //$form_state['values']['unit_operations_used_in_dwsim']
+ else{
+ form_set_error('unit_operations_used_in_dwsim', 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']
- if($form_state['values']['logical_blocks_used'] != ""){
- if ($form_state['values']['logical_blocks_used'])
+ else{
+ form_set_error('thermodynamic_packages_used', t('Please select.'));
+ }
+ if($form_state['values']['logical_blocks_used']){
+ $logical_blocks_used_in = $_POST['logical_blocks_used'];
+ if ($logical_blocks_used_in != "")
+ {
+ if ($logical_blocks_used_in)
+ {
+ $logical_blocks_used = implode(", ", $logical_blocks_used_in);
+ $form_state['values']['logical_blocks_used'] = $logical_blocks_used;
+ } //$form_state['values']['logical_blocks_used']
+ } //$logical_blocks_used_in != ""
+ else
{
- $logical_blocks_used = implode(", ", $_POST['logical_blocks_used']);
- $form_state['values']['logical_blocks_used'] = $logical_blocks_used;
- } //$form_state['values']['logical_blocks_used']
- }else{
$form_state['values']['logical_blocks_used'] = "Not entered";
}
+ }else{
+ $form_state['values']['logical_blocks_used'] = "Not entered";
+}
+ //var_dump($form_state['values']['logical_blocks_used']);die;
if ($form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'])
{
- $list_of_compounds_from_dwsim_database_used_in_process_flowsheet = implode(", ", $_POST['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']);
+ $list_of_compounds_from_dwsim_database_used_in_process_flowsheet = implode("| ", $_POST['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']);
+ //var_dump($form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']);die;
$form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'] = $list_of_compounds_from_dwsim_database_used_in_process_flowsheet;
} //$form_state['values']['list_of_compounds_from_dwsim_database_used_in_process_flowsheet']
if (isset($_FILES['files']))
{
/* check if file is uploaded */
- if (!($_FILES['files']['name']['upload_flowsheet_developed_process']))
- form_set_error('upload_flowsheet_developed_process', t('Please upload the file.'));
- if (!($_FILES['files']['name']['upload_an_abstract']))
- form_set_error('upload_an_abstract', t('Please upload the file.'));
+ $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 */
- foreach ($_FILES['files']['name'] as $file_form_name => $file_name)
+ if ($_FILES['files']['name']['upload_an_abstract'] || $_FILES['files']['name']['upload_flowsheet_developed_process'])
{
- if ($file_name)
+ foreach ($_FILES['files']['name'] as $file_form_name => $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)
+ if ($file_name)
{
- case 'S':
- $allowed_extensions_str = variable_get('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '');
- break;
- case 'A':
- $allowed_extensions_str = variable_get('dwsim_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 (!dwsim_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
+ /* 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('dwsim_flowsheet_flowsheet_developed_process_source_extensions', '');
+ break;
+ case 'A':
+ $allowed_extensions_str = variable_get('dwsim_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 (!dwsim_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');
@@ -332,8 +474,32 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
$dest_path = $proposal_directory . '/';
if (!is_dir($root_path . $dest_path))
mkdir($root_path . $dest_path);
- /* creating solution database entry */
- $query = "INSERT INTO {dwsim_flowsheet_submitted_abstracts} (
+ if ($proposal_data)
+ {
+ $query = "UPDATE {dwsim_flowsheet_proposal} SET
+
+ dwsim_database_compound_name = :dwsim_database_compound_name
+
+ WHERE id = :proposal_id
+ ";
+ $args = array(
+ ":dwsim_database_compound_name" => $v['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'],
+ ":proposal_id" => $proposal_id
+ );
+ $submitted_proposal_id = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ } //$proposal_data
+ $proposal_id = $proposal_data->id;
+ $query_s = "SELECT * FROM {dwsim_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 {dwsim_flowsheet_submitted_abstracts} (
proposal_id,
approver_uid,
abstract_approval_status,
@@ -344,20 +510,46 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
abstract_approval_date,
is_submitted) VALUES (:proposal_id, :approver_uid, :abstract_approval_status, :unit_operations_used_in_dwsim,
:thermodynamic_packages_used, :logical_blocks_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_dwsim" => $v['unit_operations_used_in_dwsim'],
- ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
- ":logical_blocks_used" => $v['logical_blocks_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
- ));
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":approver_uid" => 0,
+ ":abstract_approval_status" => 0,
+ ":unit_operations_used_in_dwsim" => $v['unit_operations_used_in_dwsim'],
+ ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
+ ":logical_blocks_used" => $v['logical_blocks_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
+ ));
+ drupal_set_message('Abstract uploaded successfully.', 'status');
+ } //!$query_s_result
+ else
+ {
+ $query = "UPDATE {dwsim_flowsheet_submitted_abstracts} SET
+
+ unit_operations_used_in_dwsim= :unit_operations_used_in_dwsim,
+ thermodynamic_packages_used= :thermodynamic_packages_used,
+ logical_blocks_used=:logical_blocks_used,
+ abstract_upload_date =:abstract_upload_date,
+ is_submitted= :is_submitted
+ WHERE proposal_id = :proposal_id
+ ";
+ $args = array(
+ ":unit_operations_used_in_dwsim" => $v['unit_operations_used_in_dwsim'],
+ ":thermodynamic_packages_used" => $v['thermodynamic_packages_used'],
+ ":logical_blocks_used" => $v['logical_blocks_used'],
+ ":abstract_upload_date" => time(),
+ ":is_submitted" => 1,
+ ":proposal_id" => $proposal_id
+ );
+ $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)
{
@@ -365,9 +557,9 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
{
/* 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';
+ $file_type = 'S';
+ else if (strstr($file_form_name, 'upload_an_abstract'))
+ $file_type = 'A';
else
$file_type = 'U';
if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
@@ -381,22 +573,48 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
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 = "INSERT INTO {dwsim_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,
+ $query_ab_f = "SELECT * FROM dwsim_flowsheet_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype =
+ :filetype";
+ $args_ab_f = array(
":proposal_id" => $proposal_id,
- ":uid" => $user->uid,
- ":approvar_uid" => 0,
- ":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],
- ":filetype" => $file_type,
- ":timestamp" => time()
+ ":filetype" => $file_type
);
- db_query($query, $args);
- drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ $query_ab_f_result = db_query($query_ab_f, $args_ab_f)->fetchObject();
+ if (!$query_ab_f_result)
+ {
+ $query = "INSERT INTO {dwsim_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 {dwsim_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
{
@@ -404,12 +622,12 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
}
} //$file_name
} //$_FILES['files']['name'] as $file_form_name => $file_name
- drupal_set_message('Abstract uploaded successfully.', 'status');
/* sending email */
$email_to = $user->mail;
$from = variable_get('dwsim_flowsheet_from_email', '');
$bcc = variable_get('dwsim_flowsheet_emails', '');
$cc = variable_get('dwsim_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(
@@ -425,3 +643,88 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
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('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_flowsheet_submitted_abstracts');
+ $query->condition('proposal_id', $proposal_id);
+ $abstracts_q = $query->execute()->fetchObject();
+ $selected_pacakege_array = array();
+ if ($opration == "unit_operations_used_in_dwsim")
+ {
+ $uouid = explode(',', $abstracts_q->unit_operations_used_in_dwsim);
+ $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_dwsim"
+ 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"
+ elseif ($opration == "logical_blocks_used")
+ {
+ $lbuid = explode(',', $abstracts_q->logical_blocks_used);
+ $lbui = 0;
+ $logical_blocks = new stdClass();
+ foreach ($lbuid as $logical_blocks->$lbui)
+ {
+ $selected_pacakege_array[$logical_blocks->$lbui] = trim($logical_blocks->$lbui);
+ $lbui++;
+ } //$lbuid as $logical_blocks->$lbui
+ } //$opration == "logical_blocks_used"
+ elseif ($opration == "dwsim_database_compound_name")
+ {
+ $dwsim_database_compound_name = new stdClass();
+ $query = db_select('dwsim_flowsheet_proposal');
+ $query->fields('dwsim_flowsheet_proposal');
+ $query->condition('id', $proposal_id);
+ $proposal_q = $query->execute()->fetchObject();
+ $ddcm = explode('| ', $proposal_q->dwsim_database_compound_name);
+ $ddcmi = 0;
+ foreach ($ddcm as $dwsim_database_compound_name->$ddcmi)
+ {
+ $selected_pacakege_array[$dwsim_database_compound_name->$ddcmi] = trim($dwsim_database_compound_name->$ddcmi);
+ $ddcmi++;
+ } //$ddcm as $dwsim_database_compound_name->$ddcmi
+ } //$opration == "dwsim_database_compound_name"
+ else
+ {
+ return $selected_pacakege_array;
+ }
+ return $selected_pacakege_array;
+}
+function default_value_for_uploaded_files($filetype, $proposal_id)
+{
+ $query = db_select('dwsim_flowsheet_submitted_abstracts_file');
+ $query->fields('dwsim_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;
+}