diff options
-rwxr-xr-x | abstract_bulk_approval.inc | 20 | ||||
-rwxr-xr-x | email.inc | 28 | ||||
-rwxr-xr-x | flowsheet_details.inc | 3 | ||||
-rwxr-xr-x | full_download.inc | 12 | ||||
-rwxr-xr-x | manage_proposal.inc | 44 | ||||
-rwxr-xr-x | om_flowsheet.module | 53 | ||||
-rwxr-xr-x | proposal.inc | 100 | ||||
-rwxr-xr-x | run.inc | 16 | ||||
-rwxr-xr-x | upload_code.inc | 80 |
9 files changed, 260 insertions, 96 deletions
diff --git a/abstract_bulk_approval.inc b/abstract_bulk_approval.inc index 50ffbfe..efcf6d3 100755 --- a/abstract_bulk_approval.inc +++ b/abstract_bulk_approval.inc @@ -80,9 +80,6 @@ function ajax_bulk_flowsheet_abstract_details_callback($form, $form_state) { $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 @@ -156,7 +153,7 @@ Note: It will take upto 45 days from the time we receive your forms, to process Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -235,7 +232,7 @@ You are requested to visit the Abstract and Flowsheet submission page at https:/ Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -303,7 +300,7 @@ Now, you can propose a new flowsheet. Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -395,7 +392,7 @@ function _flowsheet_details($flowsheet_proposal_id) { $abstract_filename = "File not uploaded"; } - $query_sp = db_select('om_flowsheet_submitted_abstracts_file'); + /*$query_sp = db_select('om_flowsheet_submitted_abstracts_file'); $query_sp->fields('om_flowsheet_submitted_abstracts_file'); $query_sp->condition('proposal_id', $flowsheet_proposal_id); $query_sp->condition('filetype', 'P'); @@ -414,7 +411,7 @@ function _flowsheet_details($flowsheet_proposal_id) else { $sp_filename = "File not uploaded"; - } + }*/ $query_process = db_select('om_flowsheet_submitted_abstracts_file'); $query_process->fields('om_flowsheet_submitted_abstracts_file'); $query_process->condition('proposal_id', $flowsheet_proposal_id); @@ -483,6 +480,11 @@ function _flowsheet_details($flowsheet_proposal_id) 'header' => $headers, 'rows' => $rows )); + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $abstracts_pro->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_used = l($result->simulator_version_name, $result->link); $download_flowsheet = l('Download flowsheet project','chemical/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 />'; @@ -492,7 +494,7 @@ function _flowsheet_details($flowsheet_proposal_id) $return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata; $return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />'; $return_html .= '<strong>Upload the OpenModelica flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />'; - $return_html .= '<strong>Upload the OpenModelica flowsheet for the simulator package:</strong><br />' . $sp_filename . '<br /><br />'; + $return_html .= '<strong>Upload the OpenModelica flowsheet for the simulator package:</strong><br />' . $simulator_version_used . '<br /><br />'; $return_html .= $download_flowsheet; return $return_html; } @@ -59,7 +59,7 @@ Your proposal is under review. You will be notified via email about the approval Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -116,7 +116,7 @@ Thank you for participating in the OpenModelica Flowsheeting Project. You are we Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -172,7 +172,7 @@ You can upload your abstract using abstract and flowsheet submission interface' Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -229,7 +229,7 @@ Thank you for participating in the OpenModelica Flowsheeting Project. You are we Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -286,7 +286,7 @@ You can propose a new flowsheet project. Best Wishes, -!site_name Team, +!site_name Team FOSSEE,IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -326,7 +326,7 @@ You shall be notified via email after the flowsheet and abstract are reviewed an Best Wishes, -!site_name Team, +!site_name Team FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -371,8 +371,8 @@ Please ensure that ALL the codes follow guidelines at https://om.fossee.in/om-fl Best Wishes, -!site_name Team, -FOSSEE,IIT Bombay', array( +!site_name Team +FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name ), array( @@ -402,8 +402,8 @@ Reason for dis-approval : ' . $params['solution_disapproved']['message'] . ' Best Wishes, -!site_name Team, -FOSSEE,IIT Bombay', array( +!site_name Team +FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name ), array( @@ -434,8 +434,8 @@ Caption : ' . $params['solution_deleted_user']['solution_caption'] . ' Best Wishes, -!site_name Team, -FOSSEE,IIT Bombay', array( +!site_name Team +FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name ), array( @@ -463,8 +463,8 @@ Please ensure that ALL the codes follow guidelines at https://om.fossee.in/om-fl Best Wishes, -!site_name Team, -FOSSEE,IIT Bombay', array( +!site_name Team +FOSSEE, IIT Bombay', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name ), array( diff --git a/flowsheet_details.inc b/flowsheet_details.inc index 38ffdd8..c4e00ad 100755 --- a/flowsheet_details.inc +++ b/flowsheet_details.inc @@ -7,7 +7,6 @@ function om_flowsheet_completed_proposals_all() $query->fields('om_flowsheet_proposal'); $query->condition('approval_status', 3); $query->orderBy('actual_completion_date', 'ASC'); - //$query->condition('is_completed', 1); $result = $query->execute(); if ($result->rowCount() == 0) { @@ -24,7 +23,7 @@ function om_flowsheet_completed_proposals_all() $completion_date = date("Y", $row->actual_completion_date); $preference_rows[] = array( $i, - l($row->project_title, "chemical/flowsheeting-project/om-flowsheet-run/" . $row->id, array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))), + l($row->project_title, "chemical/flowsheeting-project/om-flowsheet-run/" . $row->id, array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a mo file which is the OpenModelica flowsheet which is to be viewed by right clicking on the file and opening with OpenModelica.'))), $row->contributor_name, $row->university, $completion_date diff --git a/full_download.inc b/full_download.inc index dc8edac..54cfdb8 100755 --- a/full_download.inc +++ b/full_download.inc @@ -35,11 +35,11 @@ function om_flowsheet_download_full_project() 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); + ob_clean(); + ob_end_flush(); + flush(); } //$user->uid else { header('Content-Type: application/zip'); @@ -48,11 +48,11 @@ function om_flowsheet_download_full_project() header("Content-Transfer-Encoding: binary"); header('Expires: 0'); header('Pragma: no-cache'); - ob_end_flush(); - ob_clean(); - flush(); readfile($zip_filename); unlink($zip_filename); + ob_clean(); + ob_end_flush(); + flush(); } } //$zip_file_count > 0 else { diff --git a/manage_proposal.inc b/manage_proposal.inc index 2cfbf19..368b82f 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -194,6 +194,11 @@ function om_flowsheet_proposal_approval_form($form, &$form_state) { $project_guide_email_id = $proposal_data->project_guide_email_id; } + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $proposal_data->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_name = l($result->simulator_version_name, $result->link); $form['contributor_name'] = array( '#type' => 'item', '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid), @@ -294,6 +299,11 @@ function om_flowsheet_proposal_approval_form($form, &$form_state) '#title' => t('Name of compound for which process development is carried out'), '#markup' => $prodata ); + $form['simulator_version_used'] = array( + '#type' => 'item', + '#title' => t('Simulator version used for creating the flowsheet'), + '#markup' => $simulator_version_name, + ); $form['reference'] = array( '#type' => 'item', '#title' => t('Reference'), @@ -477,6 +487,11 @@ function om_flowsheet_proposal_status_form($form, &$form_state) drupal_goto('chemical/flowsheeting-project/manage-proposal'); return; } + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $proposal_data->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_name = l($result->simulator_version_name, $result->link); $form['contributor_name'] = array( '#type' => 'item', '#markup' => l($proposal_data->name_title . ' ' . $proposal_data->contributor_name, 'user/' . $proposal_data->uid), @@ -563,6 +578,11 @@ function om_flowsheet_proposal_status_form($form, &$form_state) '#title' => t('CAS Number of compound for which process development is carried out'), '#markup' => $proposal_data->process_development_compound_cas_number ); + $form['simulator_version_used'] = array( + '#type' => 'item', + '#title' => t('Simulator version used for creating the flowsheet'), + '#markup' => $simulator_version_name, + ); $form['reference'] = array( '#type' => 'item', '#title' => t('Reference'), @@ -666,7 +686,7 @@ function om_flowsheet_proposal_status_form_submit($form, &$form_state) ":expected_completion_date" => time() ); $result = db_query($up_query, $args); - CreateReadmeFileomFlowsheetingProject($proposal_id); + CreateReadmeFileOpenModelicaFlowsheetingProject($proposal_id); if (!$result) { drupal_set_message('Error in update status', 'error'); @@ -728,6 +748,11 @@ function om_flowsheet_proposal_edit_form($form, &$form_state) drupal_goto('chemical/flowsheeting-project/manage-proposal'); return; } + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $proposal_data->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_name = $result->simulator_version_name; $user_data = user_load($proposal_data->uid); $form['name_title'] = array( '#type' => 'select', @@ -939,6 +964,13 @@ else{ '#default_value' => $proposal_data->process_development_compound_cas_number ); + $form['simulator_version_used'] = array( + '#type' => 'select', + '#title' => t('Simulator version used for creating the flowsheet'), + '#options' => _df_list_of_simulator_version_used(), + '#required' => TRUE, + '#default_value' => $simulator_version_name, + ); $form['delete_proposal'] = array( '#type' => 'checkbox', '#title' => t('Delete Proposal') @@ -1046,6 +1078,12 @@ function om_flowsheet_proposal_edit_form_submit($form, &$form_state) } //$form_state['values']['delete_proposal'] == 1 /* update proposal */ $v = $form_state['values']; + $simulator_version_used = $v['simulator_version_used']; + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('simulator_version_name', $simulator_version_used); + $result = $query->execute()->fetchObject(); + $simulator_version_used_id = $result->id; $project_title = $v['project_title']; $proposar_name = $v['name_title'] . ' ' . $v['contributor_name']; $university = $v['university']; @@ -1074,7 +1112,8 @@ function om_flowsheet_proposal_edit_form_submit($form, &$form_state) project_guide_name=:project_guide_name, month_year_of_degree=:month_year_of_degree, process_development_compound_name=:process_development_compound_name, - process_development_compound_cas_number=:process_development_compound_cas_number + process_development_compound_cas_number=:process_development_compound_cas_number, + simulator_version_id = :simulator_version_id WHERE id=:proposal_id"; $args = array( ':name_title' => $v['name_title'], @@ -1093,6 +1132,7 @@ function om_flowsheet_proposal_edit_form_submit($form, &$form_state) ':month_year_of_degree' => $v['month_year_of_degree'], ':process_development_compound_name' => $v['process_development_compound_name'], ':process_development_compound_cas_number' => $v['process_development_compound_cas_no'], + ':simulator_version_id' => $simulator_version_used_id, ':proposal_id' => $proposal_id ); $result = db_query($query, $args); diff --git a/om_flowsheet.module b/om_flowsheet.module index 43214fb..ecf095a 100755 --- a/om_flowsheet.module +++ b/om_flowsheet.module @@ -701,6 +701,20 @@ function _df_list_of_unit_operations() } //$om_unit_operations_list_data = $om_unit_operations_list->fetchObject() return $om_unit_operations; } +function _df_list_of_simulator_version_used() +{ + $om_simulator_versions = array(); + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->orderBy('id', 'ASC'); + $om_simulator_versions_list = $query->execute(); + while ($om_simulator_versions_list_data = $om_simulator_versions_list->fetchObject()) + { + $om_simulator_versions[$om_simulator_versions_list_data->simulator_version_name] = $om_simulator_versions_list_data->simulator_version_name; + } //$om_unit_operations_list_data = $om_unit_operations_list->fetchObject() + return $om_simulator_versions; +} + function _df_list_of_thermodynamic_packages() { $om_thermodynamic_packages = array(); @@ -788,6 +802,7 @@ function _om_df_list_of_departments() function _om_df_list_of_software_version() { $software_version = array(); + db_set_active(); $query = db_select('om_flowsheet_version'); $query->fields('om_flowsheet_version'); $query->orderBy('id', 'ASC'); @@ -846,21 +861,37 @@ function om_DF_RenameDir($proposal_id, $dir_name) drupal_set_message('Project directory name not present in databse'); return; } - //var_dump($files);die; - /* if ($files != NULL) + return; +} +function _df_list_of_dwsim_flowsheets() +{ + $dwsim_flowsheets = array(); + $om_flowsheets = array(); + $flowsheets = array(); + $query = db_select('om_flowsheet_proposal'); + $query->fields('om_flowsheet_proposal'); + $query->condition(db_or()->condition('approval_status',0)->condition('approval_status',1)->condition('approval_status',3)); + $result = $query->execute(); + while ($om_flowsheets_list_data = $result->fetchObject()) { - $new_directory_name = rename(om_flowsheet_path() . $result->directory_name, om_flowsheet_path() . $dir_name) or drupal_set_message("Unable to rename folder"); + $om_flowsheets[$om_flowsheets_list_data->project_title] = $om_flowsheets_list_data->project_title; } - else + db_set_active('dwsim_2015'); + $query = db_select('dwsim_flowsheet_proposal'); + $query->fields('dwsim_flowsheet_proposal'); + $query->condition('approval_status', 3); + $dwsim_flowsheets_list = $query->execute(); + while ($dwsim_flowsheets_list_data = $dwsim_flowsheets_list->fetchObject()) { - $new_directory_name = 'Can not rename the directory. Directory not present'; - }*/ - return; + $dwsim_flowsheets[$dwsim_flowsheets_list_data->project_title] = $dwsim_flowsheets_list_data->project_title; + } + $flowsheets = array_diff($dwsim_flowsheets, $om_flowsheets); + //var_dump($flowsheets);die; + return $flowsheets; } -function CreateReadmeFileomFlowsheetingProject($proposal_id) +function CreateReadmeFileOpenModelicaFlowsheetingProject($proposal_id) { - $result = db_query(" - SELECT * from om_flowsheet_proposal WHERE id = :proposal_id", array( + $result = db_query("SELECT * from om_flowsheet_proposal WHERE id = :proposal_id", array( ":proposal_id" => $proposal_id )); $proposal_data = $result->fetchObject(); @@ -873,7 +904,7 @@ function CreateReadmeFileomFlowsheetingProject($proposal_id) $txt .= "Proposar Name: " . $proposal_data->name_title . " " . $proposal_data->contributor_name . "\n"; $txt .= "University: " . $proposal_data->university . "\n"; $txt .= "\n" . "\n"; - $txt .= "om Flowsheet Project By FOSSEE, IIT Bombay" . "\n"; + $txt .= "OpenModelica Flowsheet Project By FOSSEE, IIT Bombay" . "\n"; fwrite($readme_file, $txt); fclose($readme_file); return $txt; diff --git a/proposal.inc b/proposal.inc index 5ae6e83..40af71f 100755 --- a/proposal.inc +++ b/proposal.inc @@ -241,13 +241,6 @@ function om_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) '#type' => 'item', '#markup' => '<hr>' ); - $form['project_title'] = array( - '#type' => 'textarea', - '#title' => t('Project Title'), - '#size' => 250, - '#description' => t('Maximum character limit is 250'), - '#required' => TRUE - ); $form['dwsim_flowsheet_check'] = array( '#type' => 'radios', '#title' => t('Is the proposed OpenModelica flowsheet is from list of Completed DWSIM Flowsheets?'), @@ -257,7 +250,37 @@ function om_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) ), '#validated' => TRUE, ); - $form['dwsim_flowsheet_name'] = array( + $form['dwsim_flowsheet_name_dropdown'] = array( + '#type' => 'select', + '#title' => t('Select the name of flowsheet proposed.'), + '#required' => TRUE, + '#options' => _df_list_of_dwsim_flowsheets(), + // '#description' => t('For example, if you are proposing flowsheet no. 10 from the list of completed DWSIM flowsheet, enter as: "10. Removal of Isopentane in Gasoline Manufacturing Plant"'), + '#validated' => TRUE, + '#states' => array( + 'visible' => array( + ':input[name="dwsim_flowsheet_check"]' => array( + 'value' => '1' + ) + ) + ), + ); + $form['project_title'] = array( + '#type' => 'textarea', + '#title' => t('Project Title'), + '#size' => 250, + '#description' => t('Maximum character limit is 250'), + '#required' => TRUE, + '#validated' => TRUE, + '#states' => array( + 'visible' => array( + ':input[name="dwsim_flowsheet_check"]' => array( + 'value' => '0' + ) + ) + ), + ); + /*$form['dwsim_flowsheet_name'] = array( '#type' => 'textfield', '#title' => t('Enter the exact name of flowsheet along with its serial number.'), '#required' => TRUE, @@ -270,7 +293,7 @@ function om_flowsheet_proposal_form($form, &$form_state, $no_js_use = FALSE) ) ) ), - ); + );*/ $form['reference'] = array( '#type' => 'textfield', '#title' => t('Reference'), @@ -318,6 +341,12 @@ Ex: Ethanol'), Ex: 64-17-5'), '#required' => TRUE ); + $form['simulator_version_used'] = array( + '#type' => 'select', + '#title' => t('Simulator version used for creating the flowsheet'), + '#options' => _df_list_of_simulator_version_used(), + '#required' => TRUE, + ); $form['term_condition'] = array( '#type' => 'checkboxes', @@ -337,7 +366,7 @@ Ex: 64-17-5'), /***************************************/ function om_flowsheet_proposal_form_validate($form, &$form_state) { - $project_title = $form_state['values']['project_title']; + /*$project_title = $form_state['values']['project_title']; $query = db_select('om_flowsheet_proposal'); $query->fields('om_flowsheet_proposal'); $query->condition('project_title', $project_title); @@ -347,7 +376,7 @@ function om_flowsheet_proposal_form_validate($form, &$form_state) { form_set_error('project_title', t('Project title name already exists')); return; - } + }*/ /*$query = db_select('om_flowsheet_proposal'); $query->fields('om_flowsheet_proposal'); $query->condition('project_title', $project_title); @@ -412,7 +441,26 @@ function om_flowsheet_proposal_form_validate($form, &$form_state) } //$form_state['values']['city'] == '' } //Validation for project title - $form_state['values']['project_title'] = trim($form_state['values']['project_title']); + if($form_state['values']['dwsim_flowsheet_check'] == 1) + { + $project_title = $form_state['values']['dwsim_flowsheet_name_dropdown']; + } + else{ + + $project_title = $form_state['values']['project_title']; + } + //var_dump($project_title);die; + $query = db_select('om_flowsheet_proposal'); + $query->fields('om_flowsheet_proposal'); + $query->condition('project_title', $project_title); + $query->condition(db_or()->condition('approval_status',0)->condition('approval_status',1)->condition('approval_status',3)); + $result = $query->execute()->rowCount(); + //var_dump($result);die; + if ($result >= 1) + { + form_set_error('', t('Project title name already exists')); + return; + } if ($form_state['values']['project_title'] != '') { if (strlen($form_state['values']['project_title']) > 250) @@ -428,10 +476,10 @@ function om_flowsheet_proposal_form_validate($form, &$form_state) form_set_error('project_title', t('Special characters are not allowed for project title')); //strlen($form_state['values']['project_title']) < 10 } //$form_state['values']['project_title'] != '' - else + /*else { form_set_error('project_title', t('Project title shoud not be empty')); - } + } */ // validation for Name of compound for which process development is carried out $form_state['values']['process_development_compound_name'] = trim($form_state['values']['process_development_compound_name']); if ($form_state['values']['process_development_compound_name'] != '') @@ -468,11 +516,11 @@ function om_flowsheet_proposal_form_validate($form, &$form_state) form_set_error('older', t('Please provide valid version')); } //$form_state['values']['older'] == '' } //$form_state['values']['version'] == 'Old version' - if ($form_state['values']['om_database_compound_name']) + /*if ($form_state['values']['om_database_compound_name']) { $om_database_compound_name = implode("| ", $_POST['om_database_compound_name']); $form_state['values']['om_database_compound_name'] = trim($om_database_compound_name); - } //$form_state['values']['om_database_compound_name'] + } *///$form_state['values']['om_database_compound_name'] return; } function om_flowsheet_proposal_form_submit($form, &$form_state) @@ -489,14 +537,23 @@ function om_flowsheet_proposal_form_submit($form, &$form_state) } //$form_state['values']['version'] == 'Old version' /* inserting the user proposal */ $v = $form_state["values"]; + $simulator_version_used = $v['simulator_version_used']; + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('simulator_version_name', $simulator_version_used); + $result = $query->execute()->fetchObject(); + $simulator_version_used_id = $result->id; if($form_state['values']['dwsim_flowsheet_check'] == 1) { + $project_title = $v['dwsim_flowsheet_name_dropdown']; $dwsim_flowsheet_check = 1; } else{ $dwsim_flowsheet_check = 0; + $project_title = $v['project_title']; } - $project_title = trim($v['project_title']); + + //$project_title = trim($v['project_title']); $proposar_name = trim($v['name_title'] . ' ' . $v['contributor_name']); $university = trim($v['university']); $month_year_of_degree = $v['month_year_of_degree']; @@ -520,9 +577,9 @@ function om_flowsheet_proposal_form_submit($form, &$form_state) project_guide_university, project_title, dwsim_flowsheet_check, - dwsim_flowsheet_name, process_development_compound_name, process_development_compound_cas_number, + simulator_version_id, approval_status, is_completed, dissapproval_reason, @@ -549,9 +606,9 @@ function om_flowsheet_proposal_form_submit($form, &$form_state) :project_guide_university, :project_title, :dwsim_flowsheet_check, - :dwsim_flowsheet_name, :process_development_compound_name, :process_development_compound_cas_number, + :simulator_version_id, :approval_status, :is_completed, :dissapproval_reason, @@ -577,11 +634,12 @@ function om_flowsheet_proposal_form_submit($form, &$form_state) ":project_guide_name" => $v['project_guide_name'], ":project_guide_email_id" => trim($v['project_guide_email_id']), ":project_guide_university" => trim($v['project_guide_university']), - ":project_title" => $v['project_title'], + ":project_title" => $project_title, ":dwsim_flowsheet_check" => $dwsim_flowsheet_check, - ":dwsim_flowsheet_name" => $v['dwsim_flowsheet_name'], + //":dwsim_flowsheet_name" => $v['dwsim_flowsheet_name'], ":process_development_compound_name" => _om_df_sentence_case($v['process_development_compound_name']), ":process_development_compound_cas_number" => $v['process_development_compound_cas_no'], + ":simulator_version_id" => $simulator_version_used_id, ":approval_status" => 0, ":is_completed" => 0, ":dissapproval_reason" => "NULL", @@ -44,7 +44,7 @@ function om_flowsheet_run_form($form, &$form_state) ); $form['selected_flowsheet'] = array( '#type' => 'item', - '#markup' => '<div id="ajax_selected_flowsheet">' . l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '</div>' + '#markup' => '<div id="ajax_selected_flowsheet">' . l('Download Flowsheet', 'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a mo file which is the OpenModelica flowsheet which is to be viewed by right clicking on the file and opening with OpenModelica.'))) . '</div>' ); } return $form; @@ -94,7 +94,7 @@ function bootstrap_table_format($headers, $rows) $tbody .= "</tr>"; } //$rows as $row $table = " - <table class='table table-bordered table-hover' style='margin-left:-140px'> + <table class='table table-bordered table-hover table-responsive' style='margin-left:-140px'> <thead>{$thead}</thead> <tbody>{$tbody}</tbody> </table> @@ -135,9 +135,19 @@ function _flowsheet_information($proposal_id) } function _flowsheet_details($flowsheet_default_value) { + $flowsheet_details = _flowsheet_information($flowsheet_default_value); + $query = db_select('om_flowsheet_submitted_abstracts'); + $query->fields('om_flowsheet_submitted_abstracts'); + $query->condition('proposal_id', $flowsheet_default_value); + $abstracts_q = $query->execute()->fetchObject(); + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $flowsheet_details->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_used = l($result->simulator_version_name, $result->link); 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> ' . l($flowsheet_details->project_title,'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a dwxml/dwxmz file which is the om flow sheet which is to be viewed by right clicking on the file and opening with om.'))) . '</li>' . '<li><strong>Institution:</strong> ' . $flowsheet_details->university . '</li>' . '<li><strong>Version:</strong> ' . $flowsheet_details->version . '</li>' . '<li><strong>Reference:</strong> ' . $flowsheet_details->reference . '</li>' . '</ul>'; + $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> ' . l($flowsheet_details->project_title,'chemical/flowsheeting-project/full-download/project/' . $flowsheet_default_value,array('attributes' => array('title' => 'This is a zip file containing a pdf (abstract) and a mo file which is the OpenModelica flowsheet which is to be viewed by right clicking on the file and opening with OpenModelica.'))) . '</li>' . '<li><strong>Institution:</strong> ' . $flowsheet_details->university . '</li>' . '<li><strong>Version:</strong> ' . $flowsheet_details->version . '</li>' . '<li><strong>Reference:</strong> ' . $flowsheet_details->reference . '</li>' . '<li><strong>Simulator version used for creating the flowsheet:</strong> ' . $simulator_version_used . '</li>' . '</ul>'; $details = $form['flowsheet_details']['#markup']; return $details; } //$flowsheet_default_value != 0 diff --git a/upload_code.inc b/upload_code.inc index 3970b90..14cba14 100755 --- a/upload_code.inc +++ b/upload_code.inc @@ -25,6 +25,12 @@ function om_flowsheet_abstract() //return; } //$abstracts_q->is_submitted == 1 } //$abstracts_q + //var_dump($abstracts_q->library_used_id);die; + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $proposal_data->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_used_name = l($result->simulator_version_name, $result->link); $query_pro = db_select('om_flowsheet_proposal'); $query_pro->fields('om_flowsheet_proposal'); $query_pro->condition('id', $proposal_data->id); @@ -49,6 +55,7 @@ function om_flowsheet_abstract() { $abstract_filename = "File not uploaded"; } + /* Code to upload the simulator package(used earlier) $query_sp = db_select('om_flowsheet_submitted_abstracts_file'); $query_sp->fields('om_flowsheet_submitted_abstracts_file'); $query_sp->condition('proposal_id', $proposal_data->id); @@ -68,7 +75,7 @@ function om_flowsheet_abstract() else { $sp_filename = "File not uploaded"; - } + }*/ $query_process = db_select('om_flowsheet_submitted_abstracts_file'); $query_process->fields('om_flowsheet_submitted_abstracts_file'); $query_process->condition('proposal_id', $proposal_data->id); @@ -120,7 +127,7 @@ function om_flowsheet_abstract() $unit_operations_used_in_om = "Not entered"; $thermodynamic_packages_used = "Not entered"; $abstracts_query_process_filename = "File not uploaded"; - $sp_filename = "File not uploaded"; + //$sp_filename = "File not uploaded"; } $headers = array( "Name of compound for which process development is carried out", @@ -144,8 +151,8 @@ function om_flowsheet_abstract() $return_html .= '<strong>Thermodynamic Packages Used:</strong><br />' . $thermodynamic_packages_used . '<br /><br />'; $return_html .= '<strong>Name of compound for which process development is carried out:</strong><br />' . $prodata . '<br />'; $return_html .= '<strong>Uploaded an abstract (brief outline) of the project:</strong><br />' . $abstract_filename . '<br /><br />'; - $return_html .= '<strong>Upload the om flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />'; - $return_html .= '<strong>Upload the om flowsheet for the Simulator package:</strong><br />' . $sp_filename . '<br /><br />'; + $return_html .= '<strong>Upload the OpenModelica flowsheet for the developed process:</strong><br />' . $abstracts_query_process_filename . '<br /><br />'; + $return_html .= '<strong>Version of the library used for OpenModelica flowsheet for the Simulator package:</strong><br />' . $simulator_version_used_name . '<br /><br />'; $return_html .= $url . '<br />'; return $return_html; } @@ -307,7 +314,7 @@ function om_flowsheet_upload_abstract_code_form($form, &$form_state) '#title' => t('Upload the OpenModelica flowsheet for the developed process.'), '#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('om_flowsheet_flowsheet_developed_process_source_extensions', '') . '</span>' ); - $existing_uploaded_P_file = default_value_for_uploaded_files("P", $proposal_data->id); + /*$existing_uploaded_P_file = default_value_for_uploaded_files("P", $proposal_data->id); if (!$existing_uploaded_P_file) { $existing_uploaded_P_file = new stdClass(); @@ -317,6 +324,18 @@ function om_flowsheet_upload_abstract_code_form($form, &$form_state) '#type' => 'file', '#title' => t('Upload the Simulator package used to simulate the flowsheet'), '#description' => t('<span style="color:red;">Current File :</span> ' . $existing_uploaded_P_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('om_flowsheet_simulator_package_extensions', '') . '</span>' + );*/ + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('id', $proposal_data->simulator_version_id); + $result = $query->execute()->fetchObject(); + $simulator_version_used_name = $result->simulator_version_name; + $form['simulator_version_used'] = array( + '#type' => 'select', + '#title' => t('Select the Simulator package used to simulate the flowsheet'), + '#options' => _df_list_of_simulator_version_used(), + '#required' => TRUE, + '#default_value' => $simulator_version_used_name, ); $form['prop_id'] = array( '#type' => 'hidden', @@ -357,18 +376,12 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state) { form_set_error('thermodynamic_packages_used', t('Please select.')); } - - if ($form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet']) - { - $list_of_compounds_from_om_database_used_in_process_flowsheet = implode("| ", $_POST['list_of_compounds_from_om_database_used_in_process_flowsheet']); - $form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet'] = $list_of_compounds_from_om_database_used_in_process_flowsheet; - } //$form_state['values']['list_of_compounds_from_om_database_used_in_process_flowsheet'] if (isset($_FILES['files'])) { /* check if file is uploaded */ $existing_uploaded_A_file = default_value_for_uploaded_files("A", $form_state['values']['prop_id']); $existing_uploaded_S_file = default_value_for_uploaded_files("S", $form_state['values']['prop_id']); - $existing_uploaded_P_file = default_value_for_uploaded_files("P", $form_state['values']['prop_id']); + /*$existing_uploaded_P_file = default_value_for_uploaded_files("P", $form_state['values']['prop_id']); */ if (!$existing_uploaded_S_file) { if (!($_FILES['files']['name']['upload_flowsheet_developed_process'])) @@ -379,11 +392,11 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state) if (!($_FILES['files']['name']['upload_an_abstract'])) form_set_error('upload_an_abstract', t('Please upload the file.')); } //!$existing_uploaded_A_file - if (!$existing_uploaded_P_file) + /*if (!$existing_uploaded_P_file) { if (!($_FILES['files']['name']['upload_simulator_package'])) form_set_error('upload_simulator_package', t('Please upload the file.')); - } + } */ /* check for valid filename extensions */ if ($_FILES['files']['name']['upload_an_abstract'] || $_FILES['files']['name']['upload_flowsheet_developed_process'] || $_FILES['files']['name']['upload_simulator_package']) { @@ -396,8 +409,8 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state) $file_type = 'S'; else if (strstr($file_form_name, 'upload_an_abstract')) $file_type = 'A'; - else if (strstr($file_form_name, 'upload_simulator_package')) - $file_type = 'P'; + //else if (strstr($file_form_name, 'upload_simulator_package')) + // $file_type = 'P'; else $file_type = 'U'; $allowed_extensions_str = ''; @@ -409,9 +422,9 @@ function om_flowsheet_upload_abstract_code_form_validate($form, &$form_state) case 'A': $allowed_extensions_str = variable_get('om_flowsheet_abstract_upload_extensions', ''); break; - case 'P': + /*case 'P': $allowed_extensions_str = variable_get('om_flowsheet_simulator_package_extensions', ''); - break; + break;*/ } //$file_type $allowed_extensions = explode(',', $allowed_extensions_str); $tmp_ext = explode('.', strtolower($_FILES['files']['name'][$file_form_name])); @@ -434,6 +447,7 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) { global $user; $v = $form_state['values']; + //var_dump($simulator_version_used_id);die; $root_path = om_flowsheet_path(); $proposal_data = om_flowsheet_get_proposal(); $proposal_id = $proposal_data->id; @@ -453,6 +467,13 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) $args_s = array( ":proposal_id" => $proposal_id ); + $simulator_version_used = $v['simulator_version_used']; + //var_dump($simulator_version_used);die; + $query = db_select('om_flowsheet_library'); + $query->fields('om_flowsheet_library'); + $query->condition('simulator_version_name', $simulator_version_used); + $result = $query->execute()->fetchObject(); + $simulator_version_used_id = $result->id; $query_s_result = db_query($query_s, $args_s)->fetchObject(); if (!$query_s_result) { @@ -480,9 +501,10 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) $submitted_abstract_id = db_query($query, $args, array( 'return' => Database::RETURN_INSERT_ID )); - $query1 = "UPDATE {om_flowsheet_proposal} SET is_submitted = :is_submitted WHERE id = :id"; + $query1 = "UPDATE {om_flowsheet_proposal} SET simulator_version_id = :simulator_version_id, is_submitted = :is_submitted WHERE id = :id"; $args1 = array( ":is_submitted" => 1, + ":simulator_version_id" => $simulator_version_used_id, ":id" => $proposal_id ); db_query($query1,$args1); @@ -504,9 +526,10 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) ":is_submitted" => 1, ":proposal_id" => $proposal_id ); - $query1 = "UPDATE {om_flowsheet_proposal} SET is_submitted = :is_submitted WHERE id = :id"; + $query1 = "UPDATE {om_flowsheet_proposal} SET simulator_version_id = :simulator_version_id, is_submitted = :is_submitted WHERE id = :id"; $args1 = array( ":is_submitted" => 1, + ":simulator_version_id" => $simulator_version_used_id, ":id" => $proposal_id ); db_query($query1,$args1); @@ -529,10 +552,10 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) { $file_type = 'A'; } //strstr($file_form_name, 'upload_an_abstract') - else if (strstr($file_form_name, 'upload_simulator_package')) + /*else if (strstr($file_form_name, 'upload_simulator_package')) { $file_type = 'P'; - } + } */ else { $file_type = 'U'; @@ -662,7 +685,7 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error'); } break; - case 'P': + /*case 'P': if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) { //unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]); @@ -672,10 +695,10 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) '!filename' => $_FILES['files']['name'][$file_form_name] )), 'error'); } //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]) - /* uploading file */ + /* uploading file else if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) { - /* for uploaded files making an entry in the database */ + /* for uploaded files making an entry in the database $query_ab_f = "SELECT * FROM om_flowsheet_submitted_abstracts_file WHERE proposal_id = :proposal_id AND filetype = :filetype"; $args_ab_f = array( @@ -723,7 +746,7 @@ function om_flowsheet_upload_abstract_code_form_submit($form, &$form_state) { drupal_set_message('Error uploading file : ' . $dest_path . $file_name, 'error'); } - break; + break; */ } //$file_type } //$file_name } //$_FILES['files']['name'] as $file_form_name => $file_name @@ -777,6 +800,7 @@ function default_value_for_selections($opration, $proposal_id) $tpui++; } //$tpuid as $thermodynamic_item->$tpui } //$opration == "thermodynamic_packages_used" + else { return $selected_pacakege_array; @@ -801,12 +825,12 @@ function default_value_for_uploaded_files($filetype, $proposal_id) $filetype_q = $query->execute()->fetchObject(); return $filetype_q; } - elseif ($filetype == "P") + /*elseif ($filetype == "P") { $query->condition('filetype', $filetype); $filetype_q = $query->execute()->fetchObject(); return $filetype_q; - } //$filetype == "S" + }*/ //$filetype == "S" else { return; |