diff options
author | prashantsinalkar | 2017-01-11 16:24:53 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-01-11 16:24:53 +0530 |
commit | 032116b4dba160d7415d0863fd1877f8fd918166 (patch) | |
tree | 744e0ee421a288be19bd127fb3f741a50b2ff67c | |
parent | 745d226aa12c0dc7c6f2aa608d473559e02dc761 (diff) | |
download | DWSIM_textbook_companion-032116b4dba160d7415d0863fd1877f8fd918166.tar.gz DWSIM_textbook_companion-032116b4dba160d7415d0863fd1877f8fd918166.tar.bz2 DWSIM_textbook_companion-032116b4dba160d7415d0863fd1877f8fd918166.zip |
fixed minor issue and formated the code
-rwxr-xr-x | code_approval.inc | 10 | ||||
-rwxr-xr-x | manage_proposal.inc | 149 | ||||
-rwxr-xr-x | run.inc | 18 |
3 files changed, 110 insertions, 67 deletions
diff --git a/code_approval.inc b/code_approval.inc index ab96fa5..e3a11a2 100755 --- a/code_approval.inc +++ b/code_approval.inc @@ -531,16 +531,16 @@ function bulk_approval_form_submit($form, &$form_state) $num_updated = $query->execute(); } //$chapter_data = $chapter_q->fetchObject() $query = db_update('textbook_companion_preference'); - $query->fields(array( - 'submited_all_examples_code' => 1 - )); - $query->condition('id', $form_state['values']['book']); + $query->fields(array( + 'submited_all_examples_code' => 2 + )); + $query->condition('id', $form_state['values']['book']); $num_updated = $query->execute(); drupal_set_message(t('Approved Entire Book.'), 'status'); /* email */ //$email_subject = t('Your uploaded examples have been approved'); //$email_body = array(0=>t('Your all the uploaded examples for the book have been approved.')); - $email_subject = t('[!site_name] Your uploaded Textbook Companion examples have been approved', array( + $email_subject = t('[!site_name][Textbook Companion] Your uploaded Textbook Companion examples have been approved', array( '!site_name' => variable_get('site_name', '') )); $email_body = array( diff --git a/manage_proposal.inc b/manage_proposal.inc index 487f848..78a6312 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -13,7 +13,7 @@ function _proposal_pending() $pending_rows[$pending_data->id] = array( date('d-m-Y', $pending_data->creation_date), l($pending_data->full_name, 'user/' . $pending_data->uid), - date('d-m-Y', $pending_data->completion_date), + date('d-m-Y', $pending_data->proposed_completion_date), l('Approve', 'textbook-companion/manage-proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'textbook-companion/manage-proposal/edit/' . $pending_data->id) ); } //$pending_data = $pending_q->fetchObject() @@ -25,7 +25,7 @@ function _proposal_pending() $pending_header = array( 'Date of Submission', 'Contributor Name', - 'Date of Completion', + 'Proposed Date of Completion', 'Action' ); $output = theme('table', array( @@ -100,12 +100,19 @@ function _proposal_all() $proposal_status = 'Unknown'; break; } //$proposal_data->proposal_status + if ($proposal_data->proposed_completion_date != 0) { + $proposed_completion_date = date('d-m-Y', $proposal_data->proposed_completion_date); + } //$proposal_data->proposed_completion_date != 0 + else { + $proposed_completion_date = "-----"; + } $proposal_rows[] = array( date('d-m-Y', $proposal_data->creation_date), "{$preference_data->book} <br> <em>by {$preference_data->author}</em>", l($proposal_data->full_name, 'user/' . $proposal_data->uid), date('d-m-Y', $proposal_data->completion_date), + $proposed_completion_date, $proposal_status, l('Status', 'textbook-companion/manage-proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'textbook-companion/manage-proposal/edit/' . $proposal_data->id) . _tbc_ext($proposal_status, $preference_data->id) ); @@ -119,7 +126,8 @@ function _proposal_all() 'Date of Submission', 'Title of the Book', 'Contributor Name', - 'Expected Date of Completion', + 'Actual Date of Completion', + 'Proposed Date of Completion', 'Status', 'Action' ); @@ -215,7 +223,7 @@ function _category_all() /******************************************************************************/ /************************** PROPOSAL APPROVAL FORM ****************************/ /******************************************************************************/ -function proposal_approval_form($form, $form_state) +function proposal_approval_form($form, &$form_state) { global $user; /* get current proposal */ @@ -241,70 +249,87 @@ function proposal_approval_form($form, $form_state) drupal_goto('textbook-companion/manage-proposal'); return; } - $form['full_name'] = array( + $form['full_name'] = array( '#type' => 'item', '#markup' => l($row->full_name, 'user/' . $row->uid), '#title' => t('Contributor Name') ); - $form['email'] = array( + $form['email'] = array( '#type' => 'item', '#markup' => user_load($row->uid)->mail, '#title' => t('Email') ); - $form['mobile'] = array( + $form['mobile'] = array( '#type' => 'item', '#markup' => $row->mobile, '#title' => t('Mobile') ); - $form['how_project'] = array( + $form['how_project'] = array( '#type' => 'item', '#markup' => $row->how_project, '#title' => t('How did you come to know about this project') ); - $form['course'] = array( + $form['course'] = array( '#type' => 'item', '#markup' => $row->course, '#title' => t('Course') ); - $form['branch'] = array( + $form['branch'] = array( '#type' => 'item', '#markup' => $row->branch, '#title' => t('Department/Branch') ); - $form['university'] = array( + $form['university'] = array( '#type' => 'item', '#markup' => $row->university, '#title' => t('University/Institute') ); - $form['city'] = array( + $form['city'] = array( '#type' => 'item', '#markup' => $row->city, '#title' => t('City/Village') ); - $form['pincode'] = array( + $form['pincode'] = array( '#type' => 'item', '#markup' => $row->pincode, '#title' => t('Pincode') ); - $form['state'] = array( + $form['state'] = array( '#type' => 'item', '#markup' => $row->state, '#title' => t('State') ); - $form['faculty'] = array( + $form['faculty'] = array( '#type' => 'hidden', '#markup' => $row->faculty, '#title' => t('College Teacher/Professor') ); - $form['reviewer'] = array( + $form['reviewer'] = array( '#type' => 'hidden', '#markup' => $row->reviewer, '#title' => t('Reviewer') ); + if ($row->proposed_completion_date != 0) { + $proposed_completion_date = date('d-m-Y', $row->proposed_completion_date); + } //$row->proposed_completion_date != 0 + else { + $proposed_completion_date = "-----"; + } + $form['proposed_completion_date'] = array( + '#type' => 'item', + '#markup' => $proposed_completion_date, + '#title' => t('Proposed Date of Completion') + ); + if ($row->completion_date != 0) { + $actual_completion_date = date('d-m-Y', $row->completion_date); + } //$row->completion_date != 0 + else { + $actual_completion_date = "-----"; + } $form['completion_date'] = array( '#type' => 'item', - '#markup' => date('d-m-Y', $row->completion_date), - '#title' => t('Expected Date of Completion') + '#markup' => $actual_completion_date, + '#title' => t('Actual Date of Completion') ); $form['operating_system'] = array( '#type' => 'item', @@ -314,7 +339,7 @@ function proposal_approval_form($form, $form_state) $form['version'] = array( '#type' => 'item', '#markup' => $row->dwsim_version, - '#title' => t('DWSIM Version') + '#title' => t('dwsim Version') ); $form['reference'] = array( '#type' => 'item', @@ -436,6 +461,7 @@ function proposal_approval_form_submit($form, &$form_state) 'approver_uid' => $user->uid, 'approval_date' => time(), 'proposal_status' => 2, + 'completion_date' => '0', 'message' => $form_state['values']['message'] )); $query->condition('id', $proposal_id); @@ -467,11 +493,11 @@ function proposal_approval_form_submit($form, &$form_state) $book_user = user_load($row->uid); $email_to = $book_user->mail; $from = variable_get('textbook_companion_from_email', ''); - $bcc = variable_get('textbook_companion_bcc_emails', ''); + $bcc = variable_get('textbook_companion_emails', ''); $cc = variable_get('textbook_companion_cc_emails', ''); - $params['proposal_disapproved']['proposal_id'] = $proposal_id; - $params['proposal_disapproved']['user_id'] = $row->uid; - $params['proposal_disapproved']['headers'] = array( + $param['proposal_disapproved']['proposal_id'] = $proposal_id; + $param['proposal_disapproved']['user_id'] = $row->uid; + $param['proposal_disapproved']['headers'] = array( 'From' => $from, 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', @@ -480,7 +506,7 @@ function proposal_approval_form_submit($form, &$form_state) 'Cc' => $cc, 'Bcc' => $bcc ); - if (!drupal_mail('textbook_companion', 'proposal_disapproved', $email_to, language_default(), $params, $from, TRUE)) + if (!drupal_mail('textbook_companion', 'proposal_disapproved', $email_to, language_default(), $param, $from, TRUE)) drupal_set_message('Error sending email message.', 'error'); drupal_set_message('Book proposal dis-approved. User has been notified of the dis-approval.', 'error'); drupal_goto('textbook-companion/manage-proposal'); @@ -525,11 +551,11 @@ function proposal_approval_form_submit($form, &$form_state) $book_user = user_load($row->uid); $email_to = $book_user->mail; $from = variable_get('textbook_companion_from_email', ''); - $bcc = variable_get('textbook_companion_bcc_emails', ''); + $bcc = variable_get('textbook_companion_emails', ''); $cc = variable_get('textbook_companion_cc_emails', ''); - $params['proposal_approved']['proposal_id'] = $proposal_id; - $params['proposal_approved']['user_id'] = $row->uid; - $params['proposal_approved']['headers'] = array( + $param['proposal_approved']['proposal_id'] = $proposal_id; + $param['proposal_approved']['user_id'] = $row->uid; + $param['proposal_approved']['headers'] = array( 'From' => $from, 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', @@ -538,7 +564,7 @@ function proposal_approval_form_submit($form, &$form_state) 'Cc' => $cc, 'Bcc' => $bcc ); - if (!drupal_mail('textbook_companion', 'proposal_approved', $email_to, language_default(), $params, $from, TRUE)) + if (!drupal_mail('textbook_companion', 'proposal_approved', $email_to, language_default(), $param, $from, TRUE)) drupal_set_message('Error sending email message.', 'error'); drupal_set_message('Book proposal approved. User has been notified of the approval', 'status'); drupal_goto('textbook-companion/manage-proposal'); @@ -710,7 +736,7 @@ function proposal_status_form($from, $form_state) $query->condition('proposal_id', $proposal_id); $query->orderBy('pref_number', 'ASC'); $preference_q_status = $query->execute()->fetchObject(); - if ($preference_q_status->submited_all_examples_code < 1 && $proposal_data->proposal_status == 5) { + if ($preference_q_status->submited_all_examples_code == 1) { $form['submit_all_code'] = array( '#type' => 'checkbox', '#title' => t('<strong>Enable Code Submission for user</strong>'), @@ -720,18 +746,20 @@ function proposal_status_form($from, $form_state) '#type' => 'hidden', '#value' => 0 ); - } //$preference_q_status->submited_all_examples_code < 1 && $proposal_data->proposal_status == 5 - if ($proposal_data->proposal_status == 1 || $proposal_data->proposal_status == 4 || $preference_q_status->submited_all_examples_code == 1 && $proposal_data->proposal_status == 5) { - $form['completed'] = array( - '#type' => 'checkbox', - '#title' => t('<strong>Completed</strong>'), - '#description' => t('Check if user has completed all the book examples.') - ); - $form['submit_all_code'] = array( - '#type' => 'hidden', - '#value' => 0 - ); - } //$proposal_data->proposal_status == 1 || $proposal_data->proposal_status == 4 || $preference_q_status->submited_all_examples_code == 1 && $proposal_data->proposal_status == 5 + } //$preference_q_status->submited_all_examples_code == 1 + else if ($preference_q_status->submited_all_examples_code == 2) { + if (($proposal_data->proposal_status == 1 || $proposal_data->proposal_status == 4) || $proposal_data->proposal_status == 5) { + $form['completed'] = array( + '#type' => 'checkbox', + '#title' => t('<strong>Completed</strong>'), + '#description' => t('Check if user has completed all the book examples.') + ); + $form['submit_all_code'] = array( + '#type' => 'hidden', + '#value' => 0 + ); + } //($proposal_data->proposal_status == 1 || $proposal_data->proposal_status == 4) || $proposal_data->proposal_status == 5 + } //$preference_q_status->submited_all_examples_code == 2 if ($proposal_data->proposal_status == 0) { $form['approve'] = array( '#type' => 'item', @@ -778,24 +806,38 @@ function proposal_status_form_submit($form, &$form_state) } //!$proposal_data = $proposal_q->fetchObject() if ($form_state['values']['submit_all_code'] == 1) { /*db_query("UPDATE {textbook_companion_proposal} SET proposal_status = 3 WHERE id = %d", $proposal_id);*/ - $query = db_update('textbook_companion_proposal'); + $query = db_update('textbook_companion_preference'); $query->fields(array( - 'proposal_status' => 1 + 'submited_all_examples_code' => 0 )); $query->condition('id', $proposal_id); $num_updated = $query->execute(); /* sending email */ $book_user = user_load($proposal_data->uid); + $email_to = $book_user->mail; + $from = variable_get('textbook_companion_from_email', ''); + $bcc = variable_get('textbook_companion_bcc_emails', ''); + $cc = variable_get('textbook_companion_cc_emails', ''); + $book_user = user_load($proposal_data->uid); $params['all_code_submitted_status_changed']['proposal_id'] = $proposal_id; $params['all_code_submitted_status_changed']['user_id'] = $proposal_data->uid; - $email_to = $book_user->mail; - if (!drupal_mail('textbook_companion', 'all_code_submitted_status_changed', $email_to, language_default(), $params, variable_get('textbook_companion_from_email', NULL), TRUE)) + $params['all_code_submitted_status_changed']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc + ); + if (!drupal_mail('textbook_companion', 'all_code_submitted_status_changed', $email_to, language_default(), $params, $from, TRUE)) drupal_set_message('Error sending email message.', 'error'); drupal_set_message('User has been notified of that code submission interface is now available .', 'status'); drupal_goto('textbook-companion/manage-proposal'); return; } //$form_state['values']['submit_all_code'] == 1 - else /* set the book status to completed */ if ($form_state['values']['completed'] == 1) { + else if ($form_state['values']['completed'] == 1) { + /* set the book status to completed */ /*db_query("UPDATE {textbook_companion_proposal} SET proposal_status = 3 WHERE id = %d", $proposal_id);*/ $query = db_update('textbook_companion_proposal'); $query->fields(array( @@ -809,11 +851,11 @@ function proposal_status_form_submit($form, &$form_state) $book_user = user_load($proposal_data->uid); $email_to = $book_user->mail; $from = variable_get('textbook_companion_from_email', ''); - $bcc = variable_get('textbook_companion_bcc_emails', ''); + $bcc = variable_get('textbook_companion_emails', ''); $cc = variable_get('textbook_companion_cc_emails', ''); - $params['proposal_completed']['proposal_id'] = $proposal_id; - $params['proposal_completed']['user_id'] = $proposal_data->uid; - $params['proposal_completed']['headers'] = array( + $param['proposal_completed']['proposal_id'] = $proposal_id; + $param['proposal_completed']['user_id'] = $proposal_data->uid; + $param['proposal_completed']['headers'] = array( 'From' => $from, 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', @@ -837,7 +879,7 @@ function proposal_status_form_submit($form, &$form_state) /******************************************************************************/ /**************************** PROPOSAL EDIT FORM ******************************/ /******************************************************************************/ -function proposal_edit_form($fom, $form_state, $nonaicte_book) +function proposal_edit_form($form, &$form_state, $nonaicte_book) { global $user; /* get current proposal */ @@ -1738,7 +1780,8 @@ function _failed_all($preference_id = 0, $confirm = "") Kindly upload the TBC codes on the interface within 5 days from now.<br> Failure to submit the same will result in disapproval of your work and cancellation of your internship.<br><br> Regards,<br> - DWSIM TBC Team + DWSIM TBC Team,<br> + FOSSEE. </p> "; $message = array( @@ -73,14 +73,14 @@ function textbook_companion_run_form($form, &$form_state) '#ajax' => array( 'callback' => 'ajax_example_list_callback' ), - '#validated' => TRUE, - '#states' => array( - 'invisible' => array( - ':input[name="category"]' => array( - 'value' => 0 - ) - ) + '#validated' => TRUE + /* '#states' => array( + 'invisible' => array( + ':input[name="category"]' => array( + 'value' => 0 + ) ) + )*/ ); $form['download_chapter'] = array( '#type' => 'item', @@ -448,7 +448,7 @@ function _list_of_books($preference_id = NULL) } return $book_titles; } -function _list_of_chapters($preference_id = 0) +function _list_of_chapters($preference_id) { $book_chapters = array( 0 => 'Please select...' @@ -552,7 +552,7 @@ function _html_book_info($preference_id) $book_details = $query->execute()->fetchObject(); $html_data = ''; if ($book_details) { - $html_data = '<table cellspacing="1" cellpadding="1" border="0" style="width: 100%;" valign="top">' . '<tr><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Book</strong></span></td><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Contributor</strong></span></td>' . '<tr><td valign="top"><ul>' . '<li><strong>Author:</strong> ' . $book_details->preference_author . '</li>' . '<li><strong>Title of the Book:</strong> ' . $book_details->preference_book . '</li>' . '<li><strong>Publisher:</strong> ' . $book_details->preference_publisher . '</li>' . '<li><strong>Year:</strong> ' . $book_details->preference_year . '</li>' . '<li><strong>Edition:</strong> ' . $book_details->preference_edition . '</li>' . '</ul></td><td valign="top"><ul>' . '<li><strong>Contributor Name: </strong>' . $book_details->proposal_full_name . ', ' . $book_details->proposal_course . ', ' . $book_details->proposal_branch . ', ' . $book_details->proposal_university . '</li>' . '<li><strong>College Teacher: </strong>' . $book_details->proposal_faculty . '</li>' . '<li><strong>Reviewer: </strong>' . $book_details->proposal_reviewer . '</li>' . '</ul></td></tr>' . '</table>'; + $html_data = '<table cellspacing="1" cellpadding="1" border="0" style="width: 100%;" valign="top">' . '<tr><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Book</strong></span></td><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Contributor</strong></span></td>' . '<tr><td valign="top"><ul>' . '<li><strong>Author:</strong> ' . $book_details->preference_author . '</li>' . '<li><strong>Title of the Book:</strong> ' . $book_details->preference_book . '</li>' . '<li><strong>Publisher:</strong> ' . $book_details->preference_publisher . '</li>' . '<li><strong>Year:</strong> ' . $book_details->preference_year . '</li>' . '<li><strong>Edition:</strong> ' . $book_details->preference_edition . '</li>' . '</ul></td><td valign="top"><ul>' . '<li><strong>Contributor Name: </strong>' . $book_details->proposal_full_name . ', ' . $book_details->proposal_course . ', ' . $book_details->proposal_branch . ', ' . $book_details->proposal_university . '</li>' . '<li><strong>Reviewer: </strong>' . $book_details->proposal_reviewer . '</li>' . '</ul></td></tr>' . '</table>'; } //$book_details return $html_data; } |