diff options
-rwxr-xr-x | bulk_approval.inc | 79 | ||||
-rwxr-xr-x | proposal.inc | 59 | ||||
-rwxr-xr-x | run.inc | 24 | ||||
-rwxr-xr-x | settings.inc | 2 | ||||
-rwxr-xr-x | solution_proposal.inc | 52 |
5 files changed, 162 insertions, 54 deletions
diff --git a/bulk_approval.inc b/bulk_approval.inc index 03f764c..36910d8 100755 --- a/bulk_approval.inc +++ b/bulk_approval.inc @@ -355,6 +355,14 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) lab_migration_del_lab_pdf($form_state['values']['lab']); } if (user_access('lab migration bulk manage code')) { + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $form_state['values']['lab']); + $user_query = $query->execute(); + $user_info =$user_query->fetchObject(); + + $user_data = user_load($user_info->uid); + if (($form_state['values']['lab_actions'] == 1) && ($form_state['values']['lab_experiment_actions'] == 0) && ($form_state['values']['lab_experiment_solution_actions'] == 0)) { /* approving entire lab */ // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d", $form_state['values']['lab']); @@ -371,7 +379,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) } drupal_set_message(t('Approved Entire Lab.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -391,7 +399,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) } drupal_set_message(t('Pending Review Entire Lab.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been marked as pending', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been marked as pending', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -415,7 +423,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) drupal_set_message(t('Error Dis-Approving and Deleting Entire Lab.'), 'error'); } /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been marked as dis-approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been marked as dis-approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -472,7 +480,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) )); drupal_set_message(t('Deleted Lab Proposal.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions including the Lab proposal have been deleted', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions including the Lab proposal have been deleted', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -488,7 +496,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) )); drupal_set_message(t('Approved Entire Experiment.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -500,7 +508,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) )); drupal_set_message(t('Entire Experiment marked as Pending Review.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been marked as pending', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been marked as pending', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -524,7 +532,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) drupal_set_message(t('Error Dis-Approving and Deleting Entire Experiment.'), 'error'); } /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solutions have been marked as dis-approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solutions have been marked as dis-approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -541,7 +549,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) )); drupal_set_message(t('Solution approved.'), 'status'); /* email */ - $email_subject = t('[!site_name Lab Migration Project] Your uploaded solution has been approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solution has been approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -553,7 +561,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) )); drupal_set_message(t('Solution marked as Pending Review.'), 'status'); /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solution has been marked as pending', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solution has been marked as pending', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -573,7 +581,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) drupal_set_message(t('Error Dis-Approving and Deleting Solution.'), 'error'); } /* email */ - $email_subject = t('[!site_name - Lab Migration Project] Your uploaded solution has been marked as dis-approved', array( + $email_subject = t('[!site_name] Your uploaded Lab Migration solution has been marked as dis-approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( @@ -588,7 +596,7 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) return; } /****** sending email when everything done ******/ - if (isset($email_subject)) { + /* if (isset($email_subject)) { $email_to = variable_get('lab_migration_emails', '') . ', ' . $user->mail; // $email_to = "contact@scilab.in" . ', ' . $user->mail; //$email_to = "prashantsinalkar@gmail.com"; @@ -596,13 +604,60 @@ function lab_migration_bulk_approval_form_submit($form, $form_state) $param['standard']['body'] = $email_body; if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE)) drupal_set_message('Error sending email message.', 'error'); - } + }*/ + + /**** sending email when everything done ****/ + if ($email_subject) + { + $email_to = $user_data->mail; + $from = "contact-dwsim@fossee.in"; + // $email_to = "contact@scilab.in" . ', ' . $user->mail; + //$email_to = "prashantsinalkar@gmail.com"; + // $email_bcc= variable_get('lab_migration_emails', ''); + $email_bcc = 'diptiiitb17@gmail.com' ; + $email_cc="essarmax21@gmail.com"; + //$email_bcc=array('Bcc' => $header_bcc,'Cc' => $header_cc); + $param['standard']['subject'] = $email_subject; + $param['standard']['body'] = $email_body; + $param['standard']['headers'] = $email_bcc; + + + // if (!drupal_mail('lab_migration', 'standard', $email_to, language_default(), $param, variable_get('lab_migration_from_email', NULL), TRUE)) + if (!send_mail($from, $email_to,$email_cc, $email_bcc, $email_subject, $email_body)) + drupal_set_message('Error sending email message.', 'error'); + } } else { drupal_set_message(t('You do not have permission to bulk manage code.'), 'error'); } } return; } + +function send_mail($from, $email_to,$email_cc, $email_bcc, $email_subject, $email_body) { + $my_module = 'lab_migration'; + $my_mail_token = microtime(); + $message = array( + 'id' => $my_module . '_' . $my_mail_token, + 'to' => $email_to, + 'subject' => $email_subject, + 'body' => $email_body, + 'headers' => array( + 'From' => $from, + 'Sender' => $from, + 'Return-Path' => $from, + 'Cc' => $email_cc, + 'Bcc' => $email_bcc, + ), + ); + $system = drupal_mail_system($my_module, $my_mail_token); + $message = $system->format($message); + if ($system->mail($message)) { + return TRUE; + } + else { + return FALSE; + } + } /************************************************************/ function _bulk_list_of_labs() { diff --git a/proposal.inc b/proposal.inc index e2eabc4..be05951 100755 --- a/proposal.inc +++ b/proposal.inc @@ -169,7 +169,24 @@ function lab_migration_proposal_form($form,$form_state) '#type' => 'item', '#markup' => '<hr>', ); - + $form['version'] = array( + '#type' => 'select', + '#title' => t('Version'), + '#options' => _list_of_software_version(), + '#required' => TRUE, + ); + $form['older'] = array( + '#type' => 'textfield', + '#size' => 30, + '#maxlength' => 50, + //'#required' => TRUE, + '#description' => t('Specify the Older version used'), + '#states' => array( + 'visible' => array( + ':input[name="version"]' => array('value' => 'olderversion'), + ), + ), + ); $form['lab_title'] = array( '#type' => 'textfield', '#title' => t('Title of the Lab'), @@ -254,7 +271,7 @@ function lab_migration_proposal_form_validate($form, &$form_state) if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['contact_ph'])){ form_set_error('contact_ph', t('Invalid contact phone number')); - + } if($form_state['values']['country']=='Others'){ if($form_state['values']['other_country']== ''){ @@ -301,6 +318,12 @@ function lab_migration_proposal_form_validate($form, &$form_state) } } } + + if($form_state['values']['version'] == 'olderversion'){ + if($form_state['values']['older'] == ''){ + form_set_error('older', t('Please provide valid version')); + } + } return; } @@ -337,7 +360,9 @@ function lab_migration_proposal_form_submit($form, &$form_state) $solution_display = 1; else $solution_display = 1; - +if($form_state['values']['version'] == 'olderversion'){ + $form_state['values']['version'] = $form_state['values']['older']; + } /* inserting the user proposal */ $v = $form_state["values"]; $lab_title = ucname($v['lab_title']); @@ -345,9 +370,9 @@ function lab_migration_proposal_form_submit($form, &$form_state) $dir_name = $lab_title." ". $university; $directory_name = str_replace("__","_",str_replace(" ","_",$dir_name)); $result = "INSERT INTO {lab_migration_proposal} - (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, directory_name) VALUES + (uid, approver_uid, name_title, name, contact_ph, department, university, city, pincode, state, country, version, lab_title, approval_status, solution_status, solution_provider_uid, solution_display, creation_date, approval_date, solution_date, solution_provider_name_title, solution_provider_name, solution_provider_contact_ph, solution_provider_department, solution_provider_university, directory_name) VALUES (:uid, :approver_uid, :name_title, :name, :contact_ph, :department, :university, :city, :pincode, :state, :country, - :lab_title, :approval_status, :solution_status, :solution_provider_uid, :solution_display, :creation_date, + :version, :lab_title, :approval_status, :solution_status, :solution_provider_uid, :solution_display, :creation_date, :approval_date, :solution_date, :solution_provider_name_title, :solution_provider_name, :solution_provider_contact_ph, :solution_provider_department, :solution_provider_university, :directory_name)"; $args= array( @@ -362,6 +387,7 @@ function lab_migration_proposal_form_submit($form, &$form_state) ":pincode" => $v['pincode'], ":state" => $v['all_state'], ":country" => $v['country'], + ":version" => $form_state['values']['version'], ":lab_title" => $v['lab_title'], ":approval_status" => 0, ":solution_status" => $solution_status, @@ -426,9 +452,9 @@ function lab_migration_proposal_form_submit($form, &$form_state) drupal_set_message(t('We have received you Lab migration proposal. We will get back to you soon.'), 'status'); drupal_goto(''); } - +/* function _list_of_states(){ - $states = array(0 => '-Select-'); + $states = array(); $query = db_select('list_states_of_india'); $query->fields('list_states_of_india'); @@ -442,7 +468,7 @@ function _list_of_states(){ } function _list_of_cities(){ - $city = array(0 => '-Select-'); + $city = array(); $query = db_select('list_cities_of_india'); $query->fields('list_cities_of_india'); $query->orderBy('city', 'ASC'); @@ -455,7 +481,7 @@ function _list_of_cities(){ } function _list_of_departments(){ - $department = array(0 => '-Select-'); + $department = array(); $query = db_select('list_of_departments'); $query->fields('list_of_departments'); $query->orderBy('id', 'DESC'); @@ -466,5 +492,16 @@ function _list_of_departments(){ } return $department; } - - +function _list_of_software_version(){ + $software_version = array(); + $query = db_select('dwsim_software_version'); + $query->fields('dwsim_software_version'); + $query->orderBy('id', 'DESC'); + $department_list = $query->execute(); + while ($software_version_list_data = $software_version_list->fetchObject()) + { + $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version; + } + return $software_version; +} +*/ @@ -31,9 +31,9 @@ '#type' => 'item', '#markup' => '<div id="ajax_selected_lab"></div>', ); - $form['selected_lab_freeeda'] = array( + $form['selected_lab_dwsim'] = array( '#type' => 'item', - '#markup' => '<div id="ajax_selected_lab_freeeda"></div>', + '#markup' => '<div id="ajax_selected_lab_dwsim"></div>', ); $form['selected_lab_pdf'] = array( '#type' => 'item', @@ -93,17 +93,17 @@ '#markup' => '<div id="ajax_selected_lab">'.l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value).'</div>', ); - $form['selected_lab_pdf'] = array( + /* $form['selected_lab_pdf'] = array( '#type' => 'item', '#markup' => '<div id="ajax_selected_lab_pdf">'. l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1') .'</div>', - - ); + + );*/ if($lab_default_value=='2'){ -$form['selected_lab_freeeda'] = array( +$form['selected_lab_dwsim'] = array( '#type' => 'item', - '#markup' => '<div id="ajax_selected_lab_freeeda">'.l('Download Lab Solutions (FreeEDA Version)', 'lab-migration-uploads/Open_Source_EDA_Lab_FreeEDA_Version.zip').'</div>', - + '#markup' => '<div id="ajax_selected_lab_dwsim">'.l('Download Lab Solutions (dwsim Version)', 'lab-migration-uploads/dwsim_Version.zip').'</div>', + ); } $form['lab_details'] = array( @@ -185,13 +185,13 @@ function ajax_experiment_list_callback($form, $form_state) { if ($lab_details->solution_provider_uid > 0) { $commands[] = ajax_command_html('#ajax_selected_lab', l('Download Lab Solutions', 'lab-migration/download/lab/' . $lab_default_value)); if($lab_default_value=='2'){ - $commands[] = ajax_command_html('#ajax_selected_lab_freeeda', l('Download Lab Solutions (FreeEDA Version)', 'lab-migration_uploads/Open_Source_EDA_Lab_FreeEDA_Version.zip'));} - $commands[] = ajax_command_html('#ajax_selected_lab_pdf', l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1')); + $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', l('Download Lab Solutions (dwsim Version)', 'lab-migration_uploads/dwsim_Version.zip'));} + /* $commands[] = ajax_command_html('#ajax_selected_lab_pdf', l('Download PDF of Lab Solutions', 'lab-migration/generate-lab/' . $lab_default_value . '/1'));*/ }else{ $commands[] = ajax_command_html('#ajax_selected_lab', ''); $commands[] = ajax_command_html('#ajax_selected_lab_pdf', ''); - $commands[] = ajax_command_html('#ajax_selected_lab_freeeda', ''); + $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', ''); } $commands[] = ajax_command_html('#ajax_lab_details', _lab_details($lab_default_value)); @@ -209,7 +209,7 @@ function ajax_experiment_list_callback($form, $form_state) { $commands[] = ajax_command_html('#ajax_lab_details', ''); $commands[] = ajax_command_html('#ajax_selected_lab', ''); - $commands[] = ajax_command_html('#ajax_selected_lab_freeeda', ''); + $commands[] = ajax_command_html('#ajax_selected_lab_dwsim', ''); $commands[] = ajax_command_html('#ajax_selected_lab_pdf', ''); $commands[] = ajax_command_data('#ajax_selected_lab', 'form_state_value_select', $form_state['values']['lab']); $commands[] = ajax_command_html('#ajax_selected_experiment',''); diff --git a/settings.inc b/settings.inc index 528e712..2b71660 100755 --- a/settings.inc +++ b/settings.inc @@ -1,7 +1,7 @@ <?php // $Id$ -function lab_migration_settings_form($form_state) +function lab_migration_settings_form($form, $form_state) { $form['emails'] = array( '#type' => 'textfield', diff --git a/solution_proposal.inc b/solution_proposal.inc index 5d5c910..75e8bdd 100755 --- a/solution_proposal.inc +++ b/solution_proposal.inc @@ -24,7 +24,7 @@ function lab_migration_proposal_open() return $return_html; } -function lab_migration_solution_proposal_form($form_state) +function lab_migration_solution_proposal_form($form, $form_state) { global $user; @@ -98,17 +98,7 @@ function lab_migration_solution_proposal_form($form_state) $form['solution_provider_department'] = array( '#type' => 'select', '#title' => t('Department/Branch'), - '#options' => array('' => 'Please select...', - 'Computer Engineering' => 'Computer Engineering', - 'Electrical Engineering' => 'Electrical Engineering', - 'Electronics Engineering' => 'Electronics Engineering', - 'Chemical Engineering' => 'Chemical Engineering', - 'Instrumentation Engineering' => 'Instrumentation Engineering', - 'Mechanical Engineering' => 'Mechanical Engineering', - 'Civil Engineering' => 'Civil Engineering', - 'Physics' => 'Physics', - 'Mathematics' => 'Mathematics', - 'Others' => 'Others'), + '#options' => _list_of_departments(), '#required' => TRUE, ); $form['solution_provider_university'] = array( @@ -118,18 +108,41 @@ function lab_migration_solution_proposal_form($form_state) '#maxlength' => 50, '#required' => TRUE, ); + $form['version'] = array( + '#type' => 'select', + '#title' => t('Version'), + '#options' => _list_of_software_version(), + '#required' => TRUE, + ); + $form['older'] = array( + '#type' => 'textfield', + '#size' => 30, + '#maxlength' => 50, + //'#required' => TRUE, + '#description' => t('Specify the Older version used'), + '#states' => array( + 'visible' => array( + ':input[name="version"]' => array('value' => 'olderversion'), + ), + ), + ); $form['submit'] = array( '#type' => 'submit', - '#value' => t('Apply for Solution') + '#value' => t('Apply for Solution'), ); return $form; } -function lab_migration_solution_proposal_form_validate($form_state, &$form_state) +function lab_migration_solution_proposal_form_validate($form, &$form_state) { global $user; - + if($form_state['values']['version'] == 'olderversion'){ + if($form_state['values']['older'] == ''){ + form_set_error('older', t('Please provide valid version')); + } + } + return; //$solution_provider_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE solution_provider_uid = ".$user->uid." AND approval_status IN (0, 1) AND solution_status IN (0, 1, 2)"); $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); @@ -143,12 +156,14 @@ function lab_migration_solution_proposal_form_validate($form_state, &$form_state } } -function lab_migration_solution_proposal_form_submit($form_state, &$form_state) +function lab_migration_solution_proposal_form_submit($form, &$form_state) { global $user; $proposal_id = (int)arg(2); - + if($form_state['values']['version'] == 'olderversion'){ + $form_state['values']['version'] = $form_state['values']['older']; + } //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d", $proposal_id); $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); @@ -165,9 +180,10 @@ function lab_migration_solution_proposal_form_submit($form_state, &$form_state) drupal_goto('lab-migration/open-proposal'); } - $query = "UPDATE {lab_migration_proposal} set solution_provider_uid = :uid, solution_status = 1, solution_provider_name_title = :solution_provider_name_title, solution_provider_name = :solution_provider_contact_name, solution_provider_contact_ph = :solution_provider_contact_ph, solution_provider_department = :solution_provider_department, solution_provider_university = :solution_provider_university WHERE id = :proposal_id"; + $query = "UPDATE {lab_migration_proposal} set solution_provider_uid = :uid, solution_status = 1, version = :version, solution_provider_name_title = :solution_provider_name_title, solution_provider_name = :solution_provider_contact_name, solution_provider_contact_ph = :solution_provider_contact_ph, solution_provider_department = :solution_provider_department, solution_provider_university = :solution_provider_university WHERE id = :proposal_id"; $args = array( ":uid" => $user->uid, + ":version" => $form_state['values']['version'], ":solution_provider_name_title" => $form_state['values']['solution_provider_name_title'], ":solution_provider_contact_name" => $form_state['values']['solution_provider_name'], ":solution_provider_contact_ph" => $form_state['values']['solution_provider_contact_ph'], |