From 202b397451f26953ceba68d362947af62b7ff9de Mon Sep 17 00:00:00 2001
From: Sashi20
Date: Wed, 23 Oct 2019 15:11:38 +0530
Subject: Add proposal, code submission forms
---
run.inc | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
create mode 100755 run.inc
(limited to 'run.inc')
diff --git a/run.inc b/run.inc
new file mode 100755
index 0000000..1e0aa7f
--- /dev/null
+++ b/run.inc
@@ -0,0 +1,144 @@
+ 'select',
+ '#title' => t('Title of the Custom Model'),
+ '#options' => _list_of_custom_model(),
+ '#default_value' => $selected,
+ '#ajax' => array(
+ 'callback' => 'custom_model_project_details_callback'
+ )
+ );
+ if (!$url_custom_model_id) {
+ $form['custom_model_details'] = array(
+ '#type' => 'item',
+ '#markup' => '
'
+ );
+ $form['selected_custom_model'] = array(
+ '#type' => 'item',
+ '#markup' => ''
+ );
+ } //!$url_custom_model_id
+ else {
+ $custom_model_default_value = $url_custom_model_id;
+ $form['custom_model_details'] = array(
+ '#type' => 'item',
+ '#markup' => '' . _custom_model_details($custom_model_default_value) . '
'
+ );
+ $form['selected_custom_model'] = array(
+ '#type' => 'item',
+ '#markup' => '' . l('Download Custom Model', 'custom-model/full-download/project/' . $custom_model_default_value) . '
'
+ );
+ }
+ return $form;
+}
+function custom_model_project_details_callback($form, $form_state)
+{
+ $commands = array();
+ $custom_model_default_value = $form_state['values']['custom_model'];
+ if ($custom_model_default_value != 0) {
+ $form['custom_model_details']['#markup'] = _custom_model_details($custom_model_default_value);
+ $custom_model_details = _custom_model_information($custom_model_default_value);
+ $provider = user_load($custom_model_details->uid);
+ if ($custom_model_details->uid > 0) {
+ $commands[] = ajax_command_html('#ajax_selected_custom_model', l('Download Custom Model', 'custom-model/full-download/project/' . $custom_model_default_value));
+ } //$custom_model_details->uid > 0
+ else {
+ $commands[] = ajax_command_html('#ajax_selected_custom_model', '');
+ $commands[] = ajax_command_html('#ajax_selected_custom_model_dwsim', '');
+ }
+ $commands[] = ajax_command_html('#ajax_custom_model_details', _custom_model_details($custom_model_default_value));
+ } //$custom_model_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_custom_model_details', '');
+ $commands[] = ajax_command_html('#ajax_selected_custom_model', '');
+ $commands[] = ajax_command_html('#ajax_selected_custom_model_dwsim', '');
+ $commands[] = ajax_command_data('#ajax_selected_custom_model', 'form_state_value_select', $form_state['values']['custom_model']);
+ }
+ return array(
+ '#type' => 'ajax',
+ '#commands' => $commands
+ );
+}
+function bootstrap_table_format($headers, $rows)
+{
+ $thead = "";
+ $tbody = "";
+ foreach ($headers as $header) {
+ $thead .= "{$header} | ";
+ } //$headers as $header
+ foreach ($rows as $row) {
+ $tbody .= "";
+ foreach ($row as $data) {
+ $tbody .= "{$data} | ";
+ } //$row as $data
+ $tbody .= "
";
+ } //$rows as $row
+ $table = "
+
+ ";
+ return $table;
+}
+/*****************************************************/
+function _list_of_custom_model()
+{
+ $custom_model_titles = array(
+ '0' => 'Please select...'
+ );
+ //$lab_titles_q = db_query("SELECT * FROM {custom_model_proposal} WHERE solution_display = 1 ORDER BY lab_title ASC");
+ $query = db_select('custom_model_proposal');
+ $query->fields('custom_model_proposal');
+ $query->condition('approval_status', 3);
+ $query->orderBy('project_title', 'ASC');
+ $custom_model_titles_q = $query->execute();
+ while ($custom_model_titles_data = $custom_model_titles_q->fetchObject()) {
+ $custom_model_titles[$custom_model_titles_data->id] = $custom_model_titles_data->project_title . ' (Proposed by ' . $custom_model_titles_data->name_title . ' ' . $custom_model_titles_data->contributor_name . ')';
+ } //$custom_model_titles_data = $custom_model_titles_q->fetchObject()
+ return $custom_model_titles;
+}
+function _custom_model_information($proposal_id)
+{
+ $query = db_select('custom_model_proposal');
+ $query->fields('custom_model_proposal');
+ $query->condition('id', $proposal_id);
+ $query->condition('approval_status', 3);
+ $custom_model_q = $query->execute();
+ $custom_model_data = $custom_model_q->fetchObject();
+ if ($custom_model_data) {
+ return $custom_model_data;
+ } //$custom_model_data
+ else {
+ return 'Not found';
+ }
+}
+function _custom_model_details($custom_model_default_value)
+{
+ $custom_model_details = _custom_model_information($custom_model_default_value);
+ if ($custom_model_default_value != 0) {
+ $form['custom_model_details']['#markup'] = 'About the Custom Model ' . '' . '- Proposer Name: ' . $custom_model_details->name_title . ' ' . $custom_model_details->contributor_name . '
' . '- Title of the Custom Model: ' . l($custom_model_details->project_title,'custom-model/full-download/project/' . $custom_model_default_value) . '
' . '- University: ' . $custom_model_details->university . '
';
+ $details = $form['custom_model_details']['#markup'];
+ return $details;
+ } //$custom_model_default_value != 0
+}
\ No newline at end of file
--
cgit
|