diff options
author | prashant | 2015-07-07 15:52:27 +0530 |
---|---|---|
committer | prashant | 2015-07-07 15:52:27 +0530 |
commit | 52e471ef5136bbbbf6e437470d05a9deee094fae (patch) | |
tree | a8394ad5edc66e5f61e711da036092462bd3beea | |
parent | afe714532f90ab5e6a69d105356a52eb2d0bd72d (diff) | |
download | scilab_textbook_companion-52e471ef5136bbbbf6e437470d05a9deee094fae.tar.gz scilab_textbook_companion-52e471ef5136bbbbf6e437470d05a9deee094fae.tar.bz2 scilab_textbook_companion-52e471ef5136bbbbf6e437470d05a9deee094fae.zip |
added city and state in formfiled with some minor changes
-rwxr-xr-x | manage_proposal.inc | 62 | ||||
-rwxr-xr-x | textbook_companion.module | 135 |
2 files changed, 189 insertions, 8 deletions
diff --git a/manage_proposal.inc b/manage_proposal.inc index 7652e75..d6d6028 100755 --- a/manage_proposal.inc +++ b/manage_proposal.inc @@ -646,6 +646,60 @@ function proposal_edit_form($form_state,$nonaicte_book) '#required' => TRUE, '#default_value' => $proposal_data->university, ); + $form['city'] = array( + '#type' => 'textfield', + '#title' => t('City/Village'), + '#size' => 50, + '#maxlength' => 50, + '#required' => TRUE, + '#default_value' => $proposal_data->city, + ); + $form['states'] = array( + '#type' => 'select', + '#title' => t('State'), + '#options' => array ( + '' => 'Please select...', + 'Andhra Pradesh' => 'Andhra Pradesh', + 'Arunachal Pradesh' => 'Arunachal Pradesh', + 'Assam' => 'Assam', + 'Bihar' => 'Bihar', + 'CT' => 'Chhattisgarh', + 'Chhattisgarh' => 'Goa', + 'Gujarat' => 'Gujarat', + 'Haryana' => 'Haryana', + 'Himachal Pradesh' => 'Himachal Pradesh', + 'Jammu & Kashmir' => 'Jammu & Kashmir', + 'Jharkhand' => 'Jharkhand', + 'Karnataka' => 'Karnataka', + 'Kerala' => 'Kerala', + 'Madhya Pradesh' => 'Madhya Pradesh', + 'Maharashtra' => 'Maharashtra', + 'Manipur' => 'Manipur', + 'Meghalaya' => 'Meghalaya', + 'Mizoram' => 'Mizoram', + 'Nagaland' => 'Nagaland', + 'Odisha' => 'Odisha', + 'Punjab' => 'Punjab', + 'Rajasthan' => 'Rajasthan', + 'Sikkim' => 'Sikkim', + 'Tamil Nadu' => 'Tamil Nadu', + 'Telangana' => 'Telangana', + 'Tripura' => 'Tripura', + 'Uttarakhand' => 'Uttarakhand', + 'Uttar Pradesh'=> 'Uttar Pradesh', + 'West Bengal' => 'West Bengal', + 'Andaman & Nicobar' => 'Andaman & Nicobar', + 'Chandigarh' => 'Chandigarh', + 'Dadra and Nagar Haveli' => 'Dadra and Nagar Haveli', + 'Daman & Diu' => 'Daman & Diu', + 'Delhi' => 'Delhi', + 'Lakshadweep' => 'Lakshadweep', + 'Puducherry' => 'Puducherry', + 'Others' => 'Others', + ), + '#required' => TRUE, + '#default_value' => $proposal_data->state, + ); $form['faculty'] = array( '#type' => 'textfield', '#title' => t('College Teacher/Professor'), @@ -870,6 +924,12 @@ if($preference3_data){ function proposal_edit_form_validate($form, &$form_state, &$nonaicte_book) { + if($form_state['values']['city']== ''){ + form_set_error('city', t('Invalid city/village')); + } + if($form_state['values']['state']== ''){ + form_set_error('state', t('Invalid state')); + } /* mobile */ if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile'])) @@ -937,7 +997,7 @@ function proposal_edit_form_submit($form, &$form_state) $proposal_id = $form_state['values']['hidden_proposal_id']; - $query = "UPDATE {textbook_companion_proposal} SET full_name = '".$form_state['values']['full_name']."', mobile = '".$form_state['values']['mobile']."', how_project = '".$form_state['values']['how_project']."', course = '".$form_state['values']['course']."', branch = '".$form_state['values']['branch']."', university = '".$form_state['values']['university']."', faculty = '".$form_state['values']['faculty']."', reviewer = '".$form_state['values']['reviewer']."', completion_date = $completion_date_timestamp, operating_system= '".$form_state['values']['operating_system']."', scilab_version= '".$form_state['values']['scilab_version']."' WHERE id =".$proposal_id; + $query = "UPDATE {textbook_companion_proposal} SET full_name = '".$form_state['values']['full_name']."', mobile = '".$form_state['values']['mobile']."', how_project = '".$form_state['values']['how_project']."', course = '".$form_state['values']['course']."', branch = '".$form_state['values']['branch']."', university = '".$form_state['values']['university']."', city = '".$form_state['values']['city']."', state = '".$form_state['values']['state']."', faculty = '".$form_state['values']['faculty']."', reviewer = '".$form_state['values']['reviewer']."', completion_date = $completion_date_timestamp, operating_system= '".$form_state['values']['operating_system']."', scilab_version= '".$form_state['values']['scilab_version']."' WHERE id =".$proposal_id; db_query($query); diff --git a/textbook_companion.module b/textbook_companion.module index d482703..49a74f9 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -844,10 +844,13 @@ function textbook_companion_proposal_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; - // } + if (!$user->uid) { + + $page_content .= "<ul>"; + $page_content .= "<li>Please <a href='/user'><b><u>Login</u></b></a> to create a proposal.</li>"; + $page_content .= "</ul>"; + return $page_content; + } /* 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); @@ -978,6 +981,59 @@ function book_proposal_form($form_state, $row1=NULL, $row2=NULL, $row3=NULL) '#maxlength' => 50, '#required' => TRUE, ); + $form['city'] = array( + '#type' => 'textfield', + '#title' => t('City/Village'), + '#size' => 50, + '#maxlength' => 50, + '#required' => TRUE, + ); + $form['states'] = array( + '#type' => 'select', + '#title' => t('State'), + '#options' => array ( + '' => 'Please select....', + 'Andhra Pradesh' => 'Andhra Pradesh', + 'Arunachal Pradesh' => 'Arunachal Pradesh', + 'Assam' => 'Assam', + 'Bihar' => 'Bihar', + 'Chhattisgarh' => 'Chhattisgarh', + 'Goa' => 'Goa', + 'Gujarat' => 'Gujarat', + 'Haryana' => 'Haryana', + 'Himachal Pradesh' => 'Himachal Pradesh', + 'Jammu & Kashmir' => 'Jammu & Kashmir', + 'Jharkhand' => 'Jharkhand', + 'Karnataka' => 'Karnataka', + 'Kerala' => 'Kerala', + 'Madhya Pradesh' => 'Madhya Pradesh', + 'Maharashtra' => 'Maharashtra', + 'Manipur' => 'Manipur', + 'Meghalaya' => 'Meghalaya', + 'Mizoram' => 'Mizoram', + 'Nagaland' => 'Nagaland', + 'Odisha' => 'Odisha', + 'Punjab' => 'Punjab', + 'Rajasthan' => 'Rajasthan', + 'Sikkim' => 'Sikkim', + 'Tamil Nadu' => 'Tamil Nadu', + 'Telangana' => 'Telangana', + 'Tripura' => 'Tripura', + 'Uttarakhand' => 'Uttarakhand', + 'Uttar Pradesh'=> 'Uttar Pradesh', + 'West Bengal' => 'West Bengal', + 'Andaman & Nicobar' => 'Andaman & Nicobar', + 'Chandigarh' => 'Chandigarh', + 'Dadra and Nagar Haveli' => 'Dadra and Nagar Haveli', + 'Daman & Diu' => 'Daman & Diu', + 'Delhi' => 'Delhi', + 'Lakshadweep' => 'Lakshadweep', + 'Puducherry' => 'Puducherry', + 'Others' => 'Others', + ), + '#required' => TRUE, + + ); $form['faculty'] = array( '#type' => 'hidden', '#value' => 'None', @@ -1233,6 +1289,12 @@ function book_proposal_form($form_state, $row1=NULL, $row2=NULL, $row3=NULL) function book_proposal_form_validate($form, &$form_state) { +if($form_state['values']['city']== ''){ + form_set_error('city', t('Invalid city/village')); + } + if($form_state['values']['state']== ''){ + form_set_error('state', t('Invalid state')); + } /* mobile */ if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile'])) form_set_error('mobile', t('Invalid mobile number')); @@ -1313,7 +1375,7 @@ function book_proposal_form_submit($form, &$form_state) //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, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email) 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']))."', '".$completion_date_timestamp."', '".time()."', 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."')"; + (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university, city, state, faculty, reviewer, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email) 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']."', '".$form_state['values']['city']."','".$form_state['values']['state']."' ,'".ucwords(strtolower($form_state['values']['faculty']))."', '".ucwords(strtolower($form_state['values']['reviewer']))."', '".$completion_date_timestamp."', '".time()."', 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."')"; $result = db_query($query); if (!$result) @@ -2472,6 +2534,57 @@ function book_proposal_nonaicte_form($form_state) '#maxlength' => 50, '#required' => TRUE, ); + $form['city'] = array( + '#type' => 'textfield', + '#title' => t('City/Village'), + '#size' => 50, + '#maxlength' => 50, + '#required' => TRUE, + ); + $form['states'] = array( + '#type' => 'select', + '#title' => t('State'), + '#options' => array ( + 'Andhra Pradesh' => 'Andhra Pradesh', + 'Arunachal Pradesh' => 'Arunachal Pradesh', + 'Assam' => 'Assam', + 'Bihar' => 'Bihar', + 'Chhattisgarh' => 'Chhattisgarh', + 'Goa' => 'Goa', + 'Gujarat' => 'Gujarat', + 'Haryana' => 'Haryana', + 'Himachal Pradesh' => 'Himachal Pradesh', + 'Jammu & Kashmir' => 'Jammu & Kashmir', + 'Jharkhand' => 'Jharkhand', + 'Karnataka' => 'Karnataka', + 'Kerala' => 'Kerala', + 'Madhya Pradesh' => 'Madhya Pradesh', + 'Maharashtra' => 'Maharashtra', + 'Manipur' => 'Manipur', + 'Meghalaya' => 'Meghalaya', + 'Mizoram' => 'Mizoram', + 'Nagaland' => 'Nagaland', + 'Odisha' => 'Odisha', + 'Punjab' => 'Punjab', + 'Rajasthan' => 'Rajasthan', + 'Sikkim' => 'Sikkim', + 'Tamil Nadu' => 'Tamil Nadu', + 'Telangana' => 'Telangana', + 'Tripura' => 'Tripura', + 'Uttarakhand' => 'Uttarakhand', + 'Uttar Pradesh'=> 'Uttar Pradesh', + 'West Bengal' => 'West Bengal', + 'Andaman & Nicobar' => 'Andaman & Nicobar', + 'Chandigarh' => 'Chandigarh', + 'Dadra and Nagar Haveli' => 'Dadra and Nagar Haveli', + 'Daman & Diu' => 'Daman & Diu', + 'Delhi' => 'Delhi', + 'Lakshadweep' => 'Lakshadweep', + 'Puducherry' => 'Puducherry', + 'Others' => 'Others', + ), + '#required' => TRUE, + ); $form['faculty'] = array( '#type' => 'hidden', '#value' => 'None', @@ -2637,7 +2750,15 @@ function book_proposal_nonaicte_form($form_state) } return $form; } - +function book_proposal_nonaicte_form_validate($form, &$form_state) +{ +if($form_state['values']['city']== ''){ + form_set_error('city', t('Invalid city/village')); + } + if($form_state['values']['state']== ''){ + form_set_error('state', t('Invalid state')); + } +} function book_proposal_nonaicte_form_submit($form, &$form_state) { @@ -2682,7 +2803,7 @@ function book_proposal_nonaicte_form_submit($form, &$form_state) } $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']))."', '".$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."')"; + (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']."', '".$form_state['values']['city']."','".$form_state['values']['state']."' ,'".ucwords(strtolower($form_state['values']['faculty']))."', '".ucwords(strtolower($form_state['values']['reviewer']))."', '".$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) |