'select', '#title' => t('Title of the flowsheet'), '#options' => _list_of_flowsheet(), '#default_value' => $selected, '#ajax' => array( 'callback' => 'om_flowsheet_project_details_callback' ) ); if (!$url_flowsheet_id) { $form['flowsheet_details'] = array( '#type' => 'item', '#markup' => '
' ); $form['selected_flowsheet'] = array( '#type' => 'item', '#markup' => '
' ); } //!$url_flowsheet_id else { $flowsheet_default_value = $url_flowsheet_id; $form['flowsheet_details'] = array( '#type' => 'item', '#markup' => '
' . _flowsheet_details($flowsheet_default_value) . '
' ); $form['selected_flowsheet'] = array( '#type' => 'item', '#markup' => '
' . l('Download Abstract', "chemical/flowsheeting-project/download/abstract-file/" . $flowsheet_default_value) . '
' . 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.'))) . '

Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.
To download the Simulator, click on the Simulator version mentioned above.

' ); } return $form; } function om_flowsheet_project_details_callback($form, $form_state) { $commands = array(); $flowsheet_default_value = $form_state['values']['flowsheet']; if ($flowsheet_default_value != 0) { $form['flowsheet_details']['#markup'] = _flowsheet_details($flowsheet_default_value); $flowsheet_details = _flowsheet_information($flowsheet_default_value); $provider = user_load($flowsheet_details->uid); if ($flowsheet_details->uid > 0) { $commands[] = ajax_command_html('#ajax_selected_flowsheet', l('Download Abstract', "chemical/flowsheeting-project/download/abstract-file/" . $flowsheet_default_value) . '
' . 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.'))) . '

Note: This flowsheet is compatible with the simulator version mentioned above. To simulate the flowsheet in OpenModelica, it must be opened with the above Simulator version.
To download the Simulator, click on the Simulator version mentioned above.

'); } //$flowsheet_details->uid > 0 else { $commands[] = ajax_command_html('#ajax_selected_flowsheet', ''); $commands[] = ajax_command_html('#ajax_selected_flowsheet_om', ''); } $commands[] = ajax_command_html('#ajax_flowsheet_details', _flowsheet_details($flowsheet_default_value)); } //$flowsheet_default_value != 0 else { // $form['lab_experiment_list']['#options'] = _ajax_get_experiment_list(); // $commands[] = ajax_command_replace('#ajax_selected_experiment', drupal_render($form['lab_experiment_list'])); $commands[] = ajax_command_html('#ajax_flowsheet_details', ''); $commands[] = ajax_command_html('#ajax_selected_flowsheet', ''); $commands[] = ajax_command_html('#ajax_selected_flowsheet_om', ''); $commands[] = ajax_command_data('#ajax_selected_flowsheet', 'form_state_value_select', $form_state['values']['flowsheet']); } return array( '#type' => 'ajax', '#commands' => $commands ); } function bootstrap_table_format($headers, $rows) { $thead = ""; $tbody = ""; foreach ($headers as $header) { $thead .= "{$header}"; } //$headers as $header foreach ($rows as $row) { $tbody .= ""; foreach ($row as $data) { $tbody .= "{$data}"; } //$row as $data $tbody .= ""; } //$rows as $row $table = " {$thead}{$tbody}
"; return $table; } /*****************************************************/ function _list_of_flowsheet() { $flowsheet_titles = array( '0' => 'Please select...' ); //$lab_titles_q = db_query("SELECT * FROM {om_flowsheet_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC"); $query = db_select('om_flowsheet_proposal'); $query->fields('om_flowsheet_proposal'); $query->condition('approval_status', 3); $query->orderBy('project_title', 'ASC'); $flowsheet_titles_q = $query->execute(); while ($flowsheet_titles_data = $flowsheet_titles_q->fetchObject()) { $flowsheet_titles[$flowsheet_titles_data->id] = $flowsheet_titles_data->project_title . ' (Proposed by ' . $flowsheet_titles_data->name_title . ' ' . $flowsheet_titles_data->contributor_name . ')'; } //$flowsheet_titles_data = $flowsheet_titles_q->fetchObject() return $flowsheet_titles; } function _flowsheet_information($proposal_id) { $query = db_select('om_flowsheet_proposal'); $query->fields('om_flowsheet_proposal'); $query->condition('id', $proposal_id); $query->condition('approval_status', 3); $flowhsheet_q = $query->execute(); $flowsheet_data = $flowhsheet_q->fetchObject(); if ($flowsheet_data) { return $flowsheet_data; } //$flowsheet_data else { return 'Not found'; } } function _flowsheet_details($flowsheet_default_value) { $flowsheet_details = _flowsheet_information($flowsheet_default_value); $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'] = 'About the Flowsheet
' . ''; $details = $form['flowsheet_details']['#markup']; return $details; } //$flowsheet_default_value != 0 }