summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashant2015-01-29 15:26:35 +0530
committerprashant2015-01-29 15:26:35 +0530
commit8217eebf9cf79414158f1df65dab890987d76bd2 (patch)
tree46d6c5f01a353d060d55c42657ca78e42c364f4b
parent5f3663c16c05e3ce4da7652dd84ad4728549c22d (diff)
downloadscilab_textbook_companion-8217eebf9cf79414158f1df65dab890987d76bd2.tar.gz
scilab_textbook_companion-8217eebf9cf79414158f1df65dab890987d76bd2.tar.bz2
scilab_textbook_companion-8217eebf9cf79414158f1df65dab890987d76bd2.zip
added book suggestion form
-rwxr-xr-xjs/textbook_companion.js6
-rwxr-xr-xmanage_proposal.inc58
-rwxr-xr-xsearch.inc6
-rwxr-xr-xsettings.inc10
-rwxr-xr-xtextbook_companion.module589
5 files changed, 651 insertions, 18 deletions
diff --git a/js/textbook_companion.js b/js/textbook_companion.js
index ff9dd6e..bbbb851 100755
--- a/js/textbook_companion.js
+++ b/js/textbook_companion.js
@@ -120,17 +120,15 @@ $('#edit-version').change(function() {
else
{
$('#edit-older-wrapper').hide();
- }
-
+ }
});
/* hide nonaicte_proposal form textbox of other reason */
$('#edit-other-reason-wrapper').hide();
$(function() {
enable_cb();
- $("#edit-reason-4").click(enable_cb);
+ $("#edit-reason-Other-reason").click(enable_cb);
});
-
function enable_cb() {
if (this.checked) {
$('#edit-other-reason-wrapper').show();
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 7e117ec..9df2ddf 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -59,7 +59,7 @@ function _proposal_all()
$proposal_rows[] = array(
date('d-m-Y', $proposal_data->creation_date),
- "{$preference_data->book} <br> <em>by {$preference_data->author}</em>",
+ "{$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),
$proposal_status,
@@ -199,6 +199,16 @@ function proposal_approval_form($form_state)
'#value' => $row->scilab_version,
'#title' => t('Scilab Version'),
);
+ $form['reference'] = array(
+ '#type' => 'item',
+ '#value' => $row->reference,
+ '#title' => t('References'),
+ );
+ $form['reason'] = array(
+ '#type' => 'item',
+ '#value' => $row->reason,
+ '#title' => t('Reasons'),
+ );
/* get book preference */
$preference_rows = array();
@@ -207,16 +217,27 @@ function proposal_approval_form($form_state)
{
$preference_rows[$preference_data->id] = $preference_data->book . ' (Written by ' . $preference_data->author . ')';
}
-
+ if($row->proposal_type == 1){
+ $form['book_preference'] = array(
+ '#type' => 'radios',
+ '#options' => $preference_rows,
+ '#title' => t('Book Preferences'),
+ '#required' => TRUE,
+
+ );
+ }
+ else{
$form['book_preference'] = array(
'#type' => 'radios',
'#title' => t('Book Preferences'),
'#options' => $preference_rows,
- );
+ '#required' => TRUE,
+ );}
$form['disapprove'] = array(
'#type' => 'checkbox',
'#title' => t('Disapprove all the above book preferences'),
+
);
$form['message'] = array(
@@ -395,6 +416,20 @@ function proposal_status_form($form_state)
'#value' => $proposal_data->scilab_version,
'#title' => t('Scilab Version'),
);
+ if($proposal_data->proposal_type == 1)
+ {
+ $form['reason'] = array(
+ '#type' => 'item',
+ '#value' => $proposal_data->reason,
+ '#title' => t('Reason'),
+ );
+ $form['reference'] = array(
+ '#type' => 'item',
+ '#value' => $proposal_data->reference,
+ '#title' => t('References'),
+ );
+ }
+
/* get book preference */
$preference_html = '<ul>';
@@ -511,7 +546,7 @@ function proposal_status_form_submit($form, &$form_state)
/**************************** PROPOSAL EDIT FORM ******************************/
/******************************************************************************/
-function proposal_edit_form($form_state)
+function proposal_edit_form($form_state,$nonaicte_book)
{
global $user;
@@ -700,6 +735,7 @@ function proposal_edit_form($form_state)
'#required' => TRUE,
'#default_value' => $preference1_data->year,
);
+ if($preference2_data){
$form['preference2'] = array(
'#type' => 'fieldset',
'#title' => t('Book Preference 2'),
@@ -754,6 +790,8 @@ function proposal_edit_form($form_state)
'#required' => TRUE,
'#default_value' => $preference2_data->year,
);
+}
+if($preference3_data){
$form['preference3'] = array(
'#type' => 'fieldset',
'#title' => t('Book Preference 3'),
@@ -808,6 +846,7 @@ function proposal_edit_form($form_state)
'#required' => TRUE,
'#default_value' => $preference3_data->year,
);
+}
/* hidden fields */
$form['hidden_proposal_id'] = array(
@@ -826,8 +865,10 @@ function proposal_edit_form($form_state)
return $form;
}
-function proposal_edit_form_validate($form, &$form_state)
+function proposal_edit_form_validate($form, &$form_state, &$nonaicte_book)
+
{
+
/* mobile */
if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile']))
form_set_error('mobile', t('Invalid mobile number'));
@@ -846,18 +887,23 @@ function proposal_edit_form_validate($form, &$form_state)
/* edition */
if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition1']))
form_set_error('edition1', t('Invalid edition for Book Preference 1'));
+ if($form_state['values']['edition2']){
if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition2']))
form_set_error('edition2', t('Invalid edition for Book Preference 2'));
if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition3']))
form_set_error('edition3', t('Invalid edition for Book Preference 3'));
+}
+
/* year of publication */
if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year1']))
form_set_error('year1', t('Invalid year of pulication for Book Preference 1'));
+ if($form_state['values']['edition2']){
if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year2']))
form_set_error('year2', t('Invalid year of pulication for Book Preference 2'));
if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year3']))
form_set_error('year3', t('Invalid year of pulication for Book Preference 3'));
+}
/* year of publication */
$cur_year = date('Y');
@@ -871,10 +917,12 @@ function proposal_edit_form_validate($form, &$form_state)
/* isbn */
if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1']))
form_set_error('isbn1', t('Invalid ISBN for Book Preference 1'));
+ if($form_state['values']['edition2']){
if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn2']))
form_set_error('isbn2', t('Invalid ISBN for Book Preference 2'));
if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn3']))
form_set_error('isbn3', t('Invalid ISBN for Book Preference 3'));
+}
return;
}
diff --git a/search.inc b/search.inc
index 2b50b23..13ae686 100755
--- a/search.inc
+++ b/search.inc
@@ -155,15 +155,17 @@ function textbook_companion_browse_student()
$return_html = _browse_list('student');
$return_html .= '<br /><br />';
$query_character = arg(2);
+ print $query_character;
+ die();
if (!$query_character) {
/* all books */
$return_html .= "Please select the starting character of the student's name";
return $return_html;
}
$book_rows = array();
- $query = "SELECT *, pro.id AS proposal_id, pre.id AS preference_id FROM textbook_companion_proposal pro LEFT JOIN textbook_companion_preference pre ON pro.id = pre.proposal_id WHERE full_name";
+ $query = "SELECT *, pro.id AS proposal_id, pre.id AS preference_id FROM textbook_companion_proposal pro LEFT JOIN textbook_companion_preference pre ON pro.id = pre.proposal_id WHERE full_name = '%s%'";
$student_q = db_query($query);
- while ($student_data = db_fetch_object($student_q))
+ while ($student_data = db_fetch_object($student_q,$query_character))
{
$query = "SELECT * FROM textbook_companion_preference WHERE proposal_id = " . $student_data->proposal_id . " AND approval_status = 1";
$book_q = db_query($query);
diff --git a/settings.inc b/settings.inc
index 2b05f00..e31c8a0 100755
--- a/settings.inc
+++ b/settings.inc
@@ -12,6 +12,15 @@ function textbook_companion_settings_form($form_state)
'#required' => TRUE,
'#default_value' => variable_get('textbook_companion_emails', ''),
);
+ $form['to_emails'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Notification emails to all'),
+ '#description' => t('A comma separated list of email addresses to receive notifications emails'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('textbook_companion_emails_all', ''),
+ );
$form['from_email'] = array(
'#type' => 'textfield',
@@ -75,6 +84,7 @@ function textbook_companion_settings_form_validate($form, &$form_state)
function textbook_companion_settings_form_submit($form, &$form_state)
{
variable_set('textbook_companion_emails', $form_state['values']['emails']);
+ variable_set('textbook_companion_emails_all', $form_state['values']['to_emails']);
variable_set('textbook_companion_from_email', $form_state['values']['from_email']);
variable_set('textbook_companion_source_extensions', $form_state['values']['source']);
variable_set('textbook_companion_dependency_extensions', $form_state['values']['dependency']);
diff --git a/textbook_companion.module b/textbook_companion.module
index d5e041d..acb6f66 100755
--- a/textbook_companion.module
+++ b/textbook_companion.module
@@ -25,6 +25,13 @@ function textbook_companion_menu()
'access arguments' => array('create book proposal'),
'type' => MENU_NORMAL_ITEM,
);
+ $items["all_proposal"] = array(
+ "title" => "Book Proposal",
+ "description" => "Book Proposal Form",
+ "page callback" => "textbook_companion_aicte_proposal_all",
+ 'access arguments' => array('create book proposal'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
/* for reviewers */
$items['manage_proposal'] = array(
'title' => 'Manage Book Proposals',
@@ -530,6 +537,15 @@ function textbook_companion_menu()
'type' => MENU_CALLBACK,
'file' => 'cheque_contact.inc',
);
+ /*Non AICTE proposal */
+ $items["nonaicte_proposal"] = array(
+ "title" => "Book Suggestion Form ",
+ "description" => "NON-AICTE Book Proposal Form",
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('book_proposal_nonaicte_form'),
+ 'access arguments' => array('create book proposal'),
+ 'type' => MENU_NORMAL_ITEM,
+ );
return $items;
}
@@ -694,8 +710,8 @@ function textbook_companion_aicte_proposal_all() {
$page_content .= "<ul>";
$page_content .= "<li>These are the list of books available for <em>Textbook Companion</em> proposal.</li>";
$page_content .= "<li>Please <a href='/user'><b><u>Login</u></b></a> to create a proposal.</li>";
- $page_content .= "<li>Unable to propose particular book: <a id='aicte-report' href='#'>Click here</a></li>";
- $page_content .= "<li>Do not wish to propose any of the below books: <a id='aicte-report' href='http://fossee.in/feedback/scilab-aicte' target = _blank>Click here</a></li>";
+ //$page_content .= "<li>Unable to propose particular book: <a id='aicte-report' href='#'>Click here</a></li>";
+ //$page_content .= "<li>Do not wish to propose any of the below books: <a id='aicte-report' href='http://fossee.in/feedback/scilab-aicte' target = _blank>Click here</a></li>";
$page_content .= "</ul>";
$page_content .= "Search : <input type='text' id='searchtext' style='width:82%'/>";
$page_content .= "<input type='button' value ='clear' id='search_clear'/>";
@@ -763,9 +779,9 @@ function textbook_companion_aicte_proposal_all() {
}
variable_del("aicte_".$user->uid);
- $page_content .= "<h5><b>* Please select any 3 books from the below available list.</b></h5></br>";
- $page_content .= "Unable to propose particular book: <a id='aicte-report' href='#'>Click here</a></br></br>";
- $page_content .= "Do not wish to propose any of the below books: <a id='aicte-report' href='http://fossee.in/feedback/scilab-aicte' target = _blank>Click here</a></br></br>";
+ $page_content .= "<h5><b>* Please select any 3 books from the below list.</b></h5></br>";
+ //$page_content .= "Unable to propose particular book: <a id='aicte-report' href='#'>Click here</a></br></br>";
+ //$page_content .= "Do not wish to propose any of the below books: <a id='aicte-report' href='http://fossee.in/feedback/scilab-aicte' target = _blank>Click here</a></br></br>";
$page_content .= "Search : <input type='text' id='searchtext' style='width:82%'/>";
$page_content .= "<input type='button' value ='clear' id='search_clear'/>";
$page_content .= drupal_get_form("textbook_companion_aicte_report_form");
@@ -833,6 +849,65 @@ function textbook_companion_proposal_all() {
return $page_content;
}
+function textbook_companion_proposals_all() {
+ global $user;
+ $page_content = "";
+
+ // if (!$user->uid) {
+ // drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ // return;
+ // }
+
+ /* check if user has already submitted a proposal */
+ $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid = %d ORDER BY id DESC LIMIT 1", $user->uid);
+ if ($proposal_q) {
+ if ($proposal_data = db_fetch_object($proposal_q)) {
+ switch ($proposal_data->proposal_status) {
+ case 0:
+ drupal_set_message(t('We have already received your proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+ return;
+ break;
+ case 1:
+ drupal_set_message(t('Your proposal has been approved. Please go to ' . l('Code Submission', 'textbook_companion/code') . ' to upload your code'), 'status');
+ drupal_goto('');
+ return;
+ break;
+ case 2:
+ drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal below.'), 'error');
+ break;
+ case 3:
+ drupal_set_message(t('Congratulations! You have completed your last book proposal. You can create another proposal below.'), 'status');
+ break;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ drupal_goto('');
+ return;
+ break;
+ }
+ }
+ }
+
+ $selections = variable_get("aicte_".$user->uid, "");
+ if($selections) {
+ $selections = implode(",", $selections);
+ $query = "
+ SELECT * FROM textbook_companion_aicte
+ WHERE id IN ({$selections})
+ ";
+ $result = db_query($query);
+ $row1 = db_fetch_object($result);
+ $row2 = db_fetch_object($result);
+ $row3 = db_fetch_object($result);
+ $page_content .= drupal_get_form("book_proposal_form", $row1, $row2, $row3);
+ } else {
+ $page_content .= drupal_get_form("book_proposal_form");
+ // drupal_goto("aicte_proposal");
+ }
+
+ return $page_content;
+}
+
function book_proposal_form($form_state, $row1=NULL, $row2=NULL, $row3=NULL)
{
global $user;
@@ -1383,7 +1458,8 @@ function textbook_companion_mail($key, &$message, $params)
$language = $message['lianguage'];
$tbc_bcc_emails = array(
'Bcc' => variable_get('textbook_companion_emails', ''),
- );
+ );
+
switch ($key)
{
case 'proposal_received':
@@ -1464,6 +1540,7 @@ Best Wishes,
$user_data = user_load($params['proposal_disapproved']['user_id']);
$message['subject'] = t('[!site_name] Your book proposal has been disapproved', array('!site_name' => variable_get('site_name', '')), $language->language);
+ if($proposal_data->proposal_type != 1){
$message['body'] = t('
Dear !user_name,
@@ -1510,8 +1587,141 @@ Year of publication : ' . $preference3_data->year . '
Best Wishes,
!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
+}
+else{
+//Non AICTE book proposal dissaprove//
+$message['body'] = t('
+Dear !user_name,
+
+Your following book proposal has been disapproved:
+
+Reason for disapproval: ' . $proposal_data->message . '
+
+Full Name : ' . $proposal_data->full_name . '
+Email : ' . $user_data->mail . '
+Mobile : ' . $proposal_data->mobile . '
+Course : ' . $proposal_data->course . '
+Department/Branch : ' . $proposal_data->branch . '
+University/Institute : ' . $proposal_data->university . '
+College Teacher / Professor : ' . $proposal_data->faculty . '
+Reviewer : ' . $proposal_data->reviewer . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
+
+Your Book Preferences :
+
+Book Preference :-
+Title of the book : ' . $preference1_data->book . '
+Author name : ' . $preference1_data->author . '
+ISBN No. : ' . $preference1_data->isbn . '
+Publisher and Place : ' . $preference1_data->publisher . '
+Edition : ' . $preference1_data->edition . '
+Year of publication : ' . $preference1_data->year . '
+
+
+
+Best Wishes,
+
+!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
+}
break;
+ /* Non AICTE Book Proposal */
+ case 'nonaicte_proposal_received':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+ /* initializing data */
+ $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
+ $proposal_data = db_fetch_object($proposal_q);
+ $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_received']['proposal_id'], 1);
+ $preference1_data = db_fetch_object($preference1_q);
+
+ $user_data = user_load($params['proposal_received']['user_id']);
+
+ $message['subject'] = t('[!site_name] Your book proposal has been received', array('!site_name' => variable_get('site_name', '')), $language->language);
+ $message['body'] = t('
+Dear !user_name,
+
+We have received your following book proposal:
+
+Full Name : ' . $proposal_data->full_name . '
+Email : ' . $user_data->mail . '
+Mobile : ' . $proposal_data->mobile . '
+Course : ' . $proposal_data->course . '
+Department/Branch : ' . $proposal_data->branch . '
+University/Institute : ' . $proposal_data->university . '
+College Teacher / Professor : ' . $proposal_data->faculty . '
+Reviewer : ' . $proposal_data->reviewer . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
+
+Your Non AICTE Book Preferences :
+
+Book Preference :-
+Title of the book : ' . $preference1_data->book . '
+Author name : ' . $preference1_data->author . '
+ISBN No. : ' . $preference1_data->isbn . '
+Publisher and Place : ' . $preference1_data->publisher . '
+Edition : ' . $preference1_data->edition . '
+Year of publication : ' . $preference1_data->year . '
+
+
+Your proposal is under review and you will soon receive an email from us regarding the same.
+
+Best Wishes,
+
+!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
+ break;
+case 'nonaicte_proposal_to_pi':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+ /* initializing data */
+ $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
+ $proposal_data = db_fetch_object($proposal_q);
+ $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_received']['proposal_id'], 1);
+ $preference1_data = db_fetch_object($preference1_q);
+
+ $user_data = user_load($params['proposal_received']['user_id']);
+
+ $message['subject'] = t('[!site_name] Your book proposal has been received', array('!site_name' => variable_get('site_name', '')), $language->language);
+ $message['body'] = t('
+Dear Sir,
+
+We have received following book proposal:
+
+Full Name : ' . $proposal_data->full_name . '
+Email : ' . $user_data->mail . '
+Mobile : ' . $proposal_data->mobile . '
+Course : ' . $proposal_data->course . '
+Department/Branch : ' . $proposal_data->branch . '
+University/Institute : ' . $proposal_data->university . '
+College Teacher / Professor : ' . $proposal_data->faculty . '
+Reviewer : ' . $proposal_data->reviewer . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
+
+Reason(s): '. $proposal_data->reason . '
+
+
+Your Non AICTE Book Preferences :
+
+Book Preference :-
+Title of the book : ' . $preference1_data->book . '
+Author name : ' . $preference1_data->author . '
+ISBN No. : ' . $preference1_data->isbn . '
+Publisher and Place : ' . $preference1_data->publisher . '
+Edition : ' . $preference1_data->edition . '
+Year of publication : ' . $preference1_data->year . '
+
+Reference :- '.$proposal_data->reference.'
+
+Please click here for further approval/disapproval : http://scilab.in/comments
+
+
+Best Wishes,
+
+!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
+ break;
+
+
+
case 'proposal_approved':
// bcc to textbook_companion_emails
$message['headers'] += $tbc_bcc_emails;
@@ -2048,7 +2258,7 @@ function delete_example($example_id)
return $status;
}
-function delete_chapter($chapter_id)
+function delete_chapter($chapter_id)
{
$status = TRUE;
$root_path = textbook_companion_path();
@@ -2164,6 +2374,371 @@ function delete_file($file_id)
}
}
+//Non aicte book proposal form
+
+function book_proposal_nonaicte_form($form_state)
+{
+
+ global $user;
+ $form = array();
+ $form['imp_notice'] = array(
+ '#type' => 'item',
+ '#value' => '<font color="red"><b>Please fill up this form carefully as the details entered here will be exactly written in the Textbook Companion and also follow the additional guidelines.</b></font>',
+ );
+ $form['guidelines'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Guidelines'),
+ '#attributes' => array('style'=>'font-weight: bold'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['guidelines']['book'] = array(
+ '#type' => 'item',
+ '#required' => TRUE,
+ '#value' => '<ul style="list-style-type:disc;font-weight: normal">
+ <li>All the fields are compulsory</li>
+ <li>Proof (example: syllabus) to the usage/ popularity of the textbook must be provided in the references box below</li>
+ <li>Please make sure that the book proposed by you has <b>at least 80</b> examples which include numerical computations and which can be coded in Scilab</li>
+ <li>If the book has less than 80 examples the <a href="tbc_honorarium" target="_blank">honorarium</a> will be provided on a pro-rata basis </li>
+ <li>Make sure the book you propose is not already an <a href="aicte_proposal" target="_blank">AICTE recommended book</a>, <a href="Completed_Books" target="_blank">completed book</a>
+ or a <a href="Books_Progress" target="_blank">book in progress</a> </li>
+ <li>You will be intimated about the approval or rejection of your suggestion via e-mail</li>
+
+</ul> ',
+
+ );
+
+
+ $form['full_name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Full Name'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ );
+ $form['email_id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Email'),
+ '#size' => 30,
+ '#value' => $user->mail,
+ '#disabled' => TRUE,
+ );
+ $form['mobile'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Mobile No.'),
+ '#size' => 30,
+ '#maxlength' => 15,
+ '#required' => TRUE,
+ );
+ $form['gender'] = array(
+ '#type' => 'radios',
+ '#title' => t('Gender'),
+ '#options' => array('M' => 'Male', 'F' => 'Female'),
+ '#required' => TRUE,
+ );
+
+ $form['how_project'] = array(
+ '#type' => 'select',
+ '#title' => t('How did you come to know about this project'),
+ '#options' => array('Scilab Website' => 'Scilab Website',
+ 'Friend' => 'Friend',
+ 'Professor/Teacher' => 'Professor/Teacher',
+ 'Mailing List' => 'Mailing List',
+ 'Poster in my/other college' => 'Poster in my/other college',
+ 'Others' => 'Others'),
+ '#required' => TRUE,
+ );
+ $form['course'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Course'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ );
+ $form['branch'] = array(
+ '#type' => 'select',
+ '#title' => t('Department/Branch'),
+ '#options' => array('Electrical Engineering' => 'Electrical Engineering',
+ 'Electronics Engineering' => 'Electronics Engineering',
+ 'Computer Engineering' => 'Computer Engineering',
+ 'Chemical Engineering' => 'Chemical Engineering',
+ 'Instrumentation Engineering' => 'Instrumentation Engineering',
+ 'Mechanical Engineering' => 'Mechanical Engineering',
+ 'Civil Engineering' => 'Civil Engineering',
+ 'Physics' => 'Physics',
+ 'Mathematics' => 'Mathematics',
+ 'Others' => 'Others'),
+ '#required' => TRUE,
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/Institute'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ );
+ $form['faculty'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('College Teacher/Professor'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Teacher/Professor Email Id'),
+ '#default_value' => '@email.com',
+ '#size' => 30,
+ '#maxlength' => 50,
+ );
+ $form['reviewer'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Reviewer'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => array('scilab 5.4.1' => 'Scilab 5.4.1',
+ 'scilab 5.3.3' => 'Scilab 5.3.3',
+ 'olderversion' => 'Older Version'),
+ '#required' => TRUE,
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used'),
+ );
+ $form['completion_date'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Expected Date of Completion'),
+ '#description' => t('Input date format should be DD-MM-YYYY. Eg: 23-03-2011'),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#required' => TRUE,
+ );
+ $form['operating_system'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Operating System'),
+ '#required' => TRUE,
+ '#size' => 30,
+ '#maxlength' => 50,
+ );
+
+ $reason=array(
+ 'Used in more than one University' =>t('Used in more than one University'),
+ 'The book has multiple editions' => t('The book has multiple editions'),
+ 'Extremely useful' => t('Extremely useful'),
+ 'Other reason' => t('Any other reason state below')
+ );
+ $form['reason'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Reasons'),
+ '#options' => $reason,
+ '#required' => TRUE,
+ );
+ $form['other_reason'] = array(
+ '#type' => 'textarea',
+ '#size' => 300,
+ '#maxlength' => 300,
+ //'#required' => FALSE,
+ );
+ $form['proposal_type'] = array(
+ '#type' => 'hidden',
+ '#default_value' => '1',
+ '#required' => FALSE,
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference'),
+ '#required' => TRUE,
+ '#size' => 500,
+ '#maxlength' => 500,
+
+ );
+ $form['preference1'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Book Preference'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ $form['preference1']['book1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the book'),
+ '#size' => 30,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#value' => $row1->book,
+ '#disabled' => ($row1->book?TRUE:FALSE),
+ );
+ $form['preference1']['author1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Author Name'),
+ '#size' => 30,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#value' => $row1->author,
+ '#disabled' => ($row1->author?TRUE:FALSE),
+ );
+ $form['preference1']['isbn1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('ISBN No'),
+ '#size' => 30,
+ '#maxlength' => 25,
+ '#required' => TRUE,
+ '#value' => $row1->isbn,
+ '#disabled' => ($row1->isbn?TRUE:FALSE),
+ );
+ $form['preference1']['publisher1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Publisher & Place'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ '#value' => $row1->publisher,
+ );
+ $form['preference1']['edition1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Edition'),
+ '#size' => 4,
+ '#maxlength' => 2,
+ '#required' => TRUE,
+ '#value' => $row1->edition,
+ );
+ $form['preference1']['year1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Year of pulication'),
+ '#size' => 4,
+ '#maxlength' => 4,
+ '#required' => TRUE,
+ '#value' => $row1->year,
+ );
+
+ $form['termconditions'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Terms And Conditions'),
+ '#options' => array(
+ 'status' => t('<a href="term-and-conditions" target="_blank">I agree to the Terms and Conditions</a>'),),
+ '#required' => TRUE,
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+
+ /* #value fix for #default_value bug drupal6 */
+ foreach(array("preference1") as $preference) {
+ foreach($form[$preference] as $key => $value) {
+ if(!$form[$preference][$key]["#value"]) {
+ unset($form[$preference][$key]["#value"]);
+ }
+ }
+ }
+ return $form;
+}
+
+
+function book_proposal_nonaicte_form_submit($form, &$form_state)
+{
+ global $user;
+ $selections = variable_get("aicte_".$user->uid, "");
+ $tbc_to_emails = variable_get("textbook_companion_emails_all");
+
+
+ if (!$user->uid) {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
+ }
+
+ /* completion date to timestamp */
+ list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
+ $completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
+
+ /* Reasons for suggesting a book*/
+
+
+ if (isset($_POST['reason'])) {
+
+ if(!($form_state['values']['other_reason'])){
+
+ $my_reason = implode(", ", $_POST['reason']);
+
+ }
+
+ else{
+ $my_reason = implode(", ", $_POST['reason']);
+ $my_reason = $my_reason."-"." ".$form_state['values']['other_reason'];
+ }
+ }
+
+ /************************************/
+
+
+ $scilab_version = $form_state['values']['version'];
+
+ if($form_state['values']['version'] == 'olderversion'){
+ $scilab_version = $form_state['values']['older'];
+ }
+
+ //var_dump($form_state['values']);
+
+ $query = "INSERT INTO {textbook_companion_proposal}
+ (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university, faculty, reviewer, reference, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email, proposal_type, reason ) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['gender']."', '".$form_state['values']['how_project']."', '".$form_state['values']['course']."', '".$form_state['values']['branch']."', '".$form_state['values']['university']."', '".ucwords(strtolower($form_state['values']['faculty']))."', '".ucwords(strtolower($form_state['values']['reviewer']))."', '".strtolower($form_state['values']['reference'])."', '".$completion_date_timestamp."', '".time()."', 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."','".$form_state['values']['proposal_type']."','".$my_reason."')";
+
+ $result = db_query($query);
+ if (!$result)
+ {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
+ }
+ /* proposal id */
+ $proposal_id = db_last_insert_id('textbook_companion_proposal', 'id');
+
+ /* inserting first book preference */
+ if ($form_state['values']['book1'])
+ {
+ $result = db_query("INSERT INTO {textbook_companion_preference}
+ (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status, nonaicte_book) VALUES
+ (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d)",
+ $proposal_id,
+ 1,
+ ucwords(strtolower($form_state['values']['book1'])),
+ ucwords(strtolower($form_state['values']['author1'])),
+ $form_state['values']['isbn1'],
+ ucwords(strtolower($form_state['values']['publisher1'])),
+ $form_state['values']['edition1'],
+ $form_state['values']['year1'],
+ 0,
+ 0,
+ 1
+ );
+ if (!$result)
+ {
+ drupal_set_message(t('Error receiving your first book preference.'), 'error');
+ }
+ }
+
+ /* sending email */
+ $email_to = $user->mail;
+ $param['proposal_received']['proposal_id'] = $proposal_id;
+ $param['proposal_received']['user_id'] = $user->uid;
+ if (!drupal_mail('textbook_companion', 'nonaicte_proposal_received', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ if (!drupal_mail('textbook_companion', 'nonaicte_proposal_to_pi', $tbc_to_emails, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+
+ drupal_set_message(t('We have received your book proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
+}
+
+//
+
function del_book_pdf($book_id)
{
$root_path = textbook_companion_path();