diff options
author | Sashi20 | 2019-06-06 12:25:00 +0530 |
---|---|---|
committer | Sashi20 | 2019-06-06 12:25:00 +0530 |
commit | 4f1f4155a53465658b63b35bb775368e64e20f62 (patch) | |
tree | 3393c013570236c55c6cebc60bb7b951a51ce467 | |
parent | a5a6f5ba17e322eed4672682e562605a4440ce76 (diff) | |
download | om_flowsheet-4f1f4155a53465658b63b35bb775368e64e20f62.tar.gz om_flowsheet-4f1f4155a53465658b63b35bb775368e64e20f62.tar.bz2 om_flowsheet-4f1f4155a53465658b63b35bb775368e64e20f62.zip |
Update dropdown to select the updated dwsim flowsheets
-rwxr-xr-x | om_flowsheet.module | 28 | ||||
-rwxr-xr-x | proposal.inc | 83 | ||||
-rwxr-xr-x | upload_code.inc | 6 |
3 files changed, 90 insertions, 27 deletions
diff --git a/om_flowsheet.module b/om_flowsheet.module index 9fbd450..34c8cce 100755 --- a/om_flowsheet.module +++ b/om_flowsheet.module @@ -714,6 +714,7 @@ function _df_list_of_simulator_version_used() } //$om_unit_operations_list_data = $om_unit_operations_list->fetchObject() return $om_simulator_versions; } + function _df_list_of_thermodynamic_packages() { $om_thermodynamic_packages = array(); @@ -801,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'); @@ -861,6 +863,32 @@ function om_DF_RenameDir($proposal_id, $dir_name) } 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()) + { + $om_flowsheets[$om_flowsheets_list_data->project_title] = $om_flowsheets_list_data->project_title; + } + 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()) + { + $dwsim_flowsheets[$dwsim_flowsheets_list_data->project_title] = $dwsim_flowsheets_list_data->project_title; + } + $flowsheets = array_unique(array_merge(array_diff($dwsim_flowsheets, $om_flowsheets))); + //var_dump($flowsheets);die; + return $flowsheets; +} function CreateReadmeFileOpenModelicaFlowsheetingProject($proposal_id) { $result = db_query("SELECT * from om_flowsheet_proposal WHERE id = :proposal_id", array( diff --git a/proposal.inc b/proposal.inc index 91eb4da..df956f2 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'), @@ -343,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); @@ -353,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); @@ -418,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) @@ -434,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'] != '') @@ -503,13 +545,14 @@ function om_flowsheet_proposal_form_submit($form, &$form_state) $simulator_version_used_id = $result->id; if($form_state['values']['dwsim_flowsheet_check'] == 1) { - $dwsim_flowsheet_check = 1; + $project_title = $v['dwsim_flowsheet_name_dropdown']; } 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']; @@ -533,7 +576,6 @@ 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, @@ -563,7 +605,6 @@ 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, @@ -592,9 +633,9 @@ 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, diff --git a/upload_code.inc b/upload_code.inc index 3db1cd7..14cba14 100755 --- a/upload_code.inc +++ b/upload_code.inc @@ -376,12 +376,6 @@ 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 */ |