summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2017-03-02 17:54:18 +0530
committerprashantsinalkar2017-03-02 17:54:42 +0530
commit66eac54bc3cd2bd4ad8a41db7f51e4479671f0b0 (patch)
tree0c01d11445f9e8d08dc267638a83cbeb66c12b6b
parente1f8c648b5aa5e6b184bcd266bf3299a243792d5 (diff)
downloaddwsim_flowsheet-66eac54bc3cd2bd4ad8a41db7f51e4479671f0b0.tar.gz
dwsim_flowsheet-66eac54bc3cd2bd4ad8a41db7f51e4479671f0b0.tar.bz2
dwsim_flowsheet-66eac54bc3cd2bd4ad8a41db7f51e4479671f0b0.zip
done chnages for uploading the abstract
-rwxr-xr-xupload_code.inc224
1 files changed, 167 insertions, 57 deletions
diff --git a/upload_code.inc b/upload_code.inc
index 2b53a89..49f5ed7 100755
--- a/upload_code.inc
+++ b/upload_code.inc
@@ -3,34 +3,126 @@
function dwsim_flowsheet_abstract()
{
global $user;
+ $return_html = "";
$proposal_data = dwsim_flowsheet_get_proposal();
if (!$proposal_data)
{
drupal_goto('');
return;
} //!$proposal_data
- $return_html = '<strong>Title of the Flowsheet Project:</strong><br />' . $proposal_data->project_title . '<br /><br />';
- $return_html .= '<strong>Proposer Name:</strong><br />' . $proposal_data->name_title . ' ' . $proposal_data->student_name . '<br /><br />';
- $return_html .= l('Upload abstract', 'flowsheeting-project/abstract-code/upload') . '<br />';
+
+ //$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_experiment');
- $query->fields('dwsim_flowsheet_experiment');
+
+ $query = db_select('dwsim_flowsheet_submitted_abstracts');
+ $query->fields('dwsim_flowsheet_submitted_abstracts');
$query->condition('proposal_id', $proposal_data->id);
- $query->orderBy('number', 'ASC');
- $experiment_q = $query->execute();
- $experiment_header = array(
- 'No. Uploaded File',
- 'Type',
- 'Status',
- 'Actions'
+ $abstracts_q = $query->execute()->fetchObject();
+
+ $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";
+ }
+
+
+ $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;
+ }
+
+ $headers = array(
+ "Name of compound for which process development is carried out",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$proposal_data->process_development_compound_name}",
+ "{$proposal_data->process_development_compound_cas_number}"
);
- // $return_html .= theme_table($experiment_header, $experiment_rows);
- $return_html .= theme('table', array(
- 'header' => $experiment_header,
- 'rows' => $experiment_rows
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ '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>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)
@@ -82,6 +174,7 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
'#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]')
);
@@ -90,6 +183,7 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
'#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]')
);
@@ -97,30 +191,37 @@ function dwsim_flowsheet_upload_abstract_code_form($form, &$form_state)
'#type' => 'select',
'#title' => t('Logical Blocks used (If any)'),
'#options' => _df_list_of_logical_block(),
- '#required' => TRUE,
'#multiple' => TRUE,
'#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
);
+ $headers = array(
+ "User defined compound",
+ "CAS No."
+ );
+ $rows = array();
+ $item = array(
+ "{$proposal_data->process_development_compound_name}",
+ "{$proposal_data->process_development_compound_cas_number}"
+ );
+ array_push($rows, $item);
+ $prodata = theme('table', array(
+ 'header' => $headers,
+ 'rows' => $rows
+ ));
$form['process_development_compound_name'] = array(
- '#type' => 'textfield',
+ '#type' => 'item',
'#title' => t('Name of compound for which process development is carried out'),
- '#size' => 50,
- '#description' => t('Mention the compound name with CAS No as shown below:
-Ex: Ethanol (64-17-5)')
+ '#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' => 'select',
+ '#type' => 'textfield',
'#title' => t('List of compounds from DWSIM Database used in process flowsheet'),
- '#options' => _df_list_of_dwsim_compound(),
- '#multiple' => TRUE,
- '#description' => t('[You can select multiple options by holding ctrl + left key of mouse]')
- );
- $form['user_defined_compounds_used_in_process_flowsheetcompound_name'] = array(
- '#type' => 'textarea',
- '#title' => t('List of user defined compounds used in process flowsheet'),
- '#required' => FALSE,
- '#description' => 'List all user defined compounds with CAS No. as in format - Ex: Ethylene (74-85-1)'
+ '#value' => $proposal_data->dwsim_database_compound_name,
+ '#size' => 20,
+ '#disabled' => TRUE,
);
+
$form['upload_an_abstract'] = array(
'#type' => 'file',
'#title' => t('Upload an abstract (brief outline) of the project.'),
@@ -141,6 +242,7 @@ Ex: Ethanol (64-17-5)')
);
return $form;
}
+
function dwsim_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
{
if ($form_state['values']['unit_operations_used_in_dwsim'])
@@ -153,11 +255,15 @@ function dwsim_flowsheet_upload_abstract_code_form_validate($form, &$form_state)
$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'] != ""){
+ if ($form_state['values']['logical_blocks_used'])
{
$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";
+ }
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']);
@@ -221,16 +327,23 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
return;
} //!$proposal_data
$proposal_id = $proposal_data->id;
- $proposal_drectory = $proposal_data->directory_name;
+ $proposal_directory = $proposal_data->directory_name;
/* create proposal folder if not present */
- $dest_path = $proposal_drectory . '/';
+ $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} (proposal_id, approver_uid, abstract_approval_status, unit_operations_used_in_dwsim, thermodynamic_packages_used, logical_blocks_used, process_development_compound_name, list_of_compounds_from_dwsim_database_used_in_process_flowsheet, user_defined_compounds_used_in_process_flowsheet, abstract_upload_date, abstract_approval_date) VALUES (:proposal_id, :approver_uid, :abstract_approval_status, :unit_operations_used_in_dwsim,
- :thermodynamic_packages_used, :logical_blocks_used, :process_development_compound_name,
- :list_of_compounds_from_dwsim_database_used_in_process_flowsheet,
- :user_defined_compounds_used_in_process_flowsheet, :abstract_upload_date, :abstract_approval_date)";
+ $query = "INSERT INTO {dwsim_flowsheet_submitted_abstracts} (
+ 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) 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,
@@ -238,11 +351,9 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
":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'],
- ":process_development_compound_name" => $v['process_development_compound_name'],
- ":list_of_compounds_from_dwsim_database_used_in_process_flowsheet" => $v['list_of_compounds_from_dwsim_database_used_in_process_flowsheet'],
- ":user_defined_compounds_used_in_process_flowsheet" => $v['user_defined_compounds_used_in_process_flowsheetcompound_name'],
":abstract_upload_date" => time(),
- ":abstract_approval_date" => 0
+ ":abstract_approval_date" => 0,
+ ":is_submitted" => 1
);
$submitted_abstract_id = db_query($query, $args, array(
'return' => Database::RETURN_INSERT_ID
@@ -253,30 +364,29 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
if ($file_name)
{
/* checking file type */
- if (strstr($file_form_name, 'source'))
- $file_type = 'S';
- else if (strstr($file_form_name, 'result'))
- $file_type = 'R';
- else if (strstr($file_form_name, 'xcos'))
- $file_type = 'X';
+ 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';
if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]))
{
- drupal_set_message(t("Error uploading file. File !filename already exists.", array(
+ unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ drupal_set_message(t("File !filename already exists hence overwirtten the exisitng file ", array(
'!filename' => $_FILES['files']['name'][$file_form_name]
)), 'error');
- return;
} //file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])
/* uploading file */
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,approvar_uid, filename, filepath, filemime, filesize, filetype, timestamp)
- VALUES (:submitted_abstract_id, :proposal_id,:approvar_uid, :filename, :filepath, :filemime, :filesize, :filetype, :timestamp)";
+ $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" => $file_path . $_FILES['files']['name'][$file_form_name],
@@ -294,15 +404,15 @@ 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('Solution uploaded successfully.', 'status');
+ 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['solution_uploaded']['solution_id'] = $solution_id;
- $params['solution_uploaded']['user_id'] = $user->uid;
- $params['solution_uploaded']['headers'] = array(
+ $params['abstract_uploaded']['submitted_abstract_id'] = $submitted_abstract_id;
+ $params['abstract_uploaded']['user_id'] = $user->uid;
+ $params['abstract_uploaded']['headers'] = array(
'From' => $from,
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
@@ -311,7 +421,7 @@ function dwsim_flowsheet_upload_abstract_code_form_submit($form, &$form_state)
'Cc' => $cc,
'Bcc' => $bcc
);
- if (!drupal_mail('dwsim_flowsheet', 'solution_uploaded', $email_to, language_default(), $params, $from, TRUE))
+ if (!drupal_mail('dwsim_flowsheet', 'abstract_uploaded', $email_to, language_default(), $params, $from, TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_goto('flowsheeting-project/abstract-code');
}