From 237172fbbd89e594128ebad8ebfc6d732b89e660 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Thu, 18 Aug 2016 12:19:50 +0530 Subject: formated the code --- cheque_contact.inc | 1347 ++++++++++++++++++++++++++-------------------------- 1 file changed, 670 insertions(+), 677 deletions(-) (limited to 'cheque_contact.inc') diff --git a/cheque_contact.inc b/cheque_contact.inc index c623ef4..093d040 100755 --- a/cheque_contact.inc +++ b/cheque_contact.inc @@ -1,336 +1,337 @@ fields('textbook_companion_paper'); - $query->condition('proposal_id', $proposal_id); - $preference4_q = $query->execute(); - - $form1=0; - $form2=0; - $form3=0; - $form4=0; - if($data = $preference4_q->fetchObject()) - { - $form1 = $data->internship_form; - $form2 = $data->copyright_form; - $form3 = $data->undertaking_form; - $form4 = $data->reciept_form; - } - else - { - $query = "Insert into {textbook_companion_paper} (proposal_id) values (:proposal_id)"; - $args = array( - ":proposal_id"=>$proposal_id, - ); - $result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID)); - } - $form['proposal_id'] =array( - '#type' => 'hidden', - '#default_value' => $proposal_id, - ); - $form['internshipform'] = array( - '#type' => 'checkbox', - '#title' => t('Recieved Internship Application'), - '#description' => t('Check if the Internship Application has been recieved.'), - '#default_value' => $form1, - ); - $form['copyrighttransferform'] = array( - '#type' => 'checkbox', - '#title' => t('Recieved Copyright Transfer Form'), - '#description' => t('Check if the Copyright Transfer Form has been recieved.'), - '#default_value' => $form2, - ); - $form['undertakingform'] = array( - '#type' => 'checkbox', - '#title' => t('Recieved Undertaking Form'), - '#description' => t('Check if the Undertaking Form has been recieved.'), - '#default_value' => $form3, - ); - $form['recieptform'] = array( - '#type' => 'checkbox', - '#title' => t('Recieved Reciept Form'), - '#description' => t('Check if the Reciept Form has been recieved.'), - '#default_value' => $form4, - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Send Email') - ); - $form['cancel'] = array( - '#type' => 'markup', - '#value' => l(t('Cancel'), 'manage_proposal/all'), + global $user; + $proposal_id = arg(2); + /* get current proposal */ + /*$preference4_q = db_query("SELECT * FROM {textbook_companion_paper} WHERE proposal_id=".$proposal_id);*/ + $query = db_select('textbook_companion_paper'); + $query->fields('textbook_companion_paper'); + $query->condition('proposal_id', $proposal_id); + $preference4_q = $query->execute(); + $form1 = 0; + $form2 = 0; + $form3 = 0; + $form4 = 0; + if ($data = $preference4_q->fetchObject()) + { + $form1 = $data->internship_form; + $form2 = $data->copyright_form; + $form3 = $data->undertaking_form; + $form4 = $data->reciept_form; + } //$data = $preference4_q->fetchObject() + else + { + $query = "Insert into {textbook_companion_paper} (proposal_id) values (:proposal_id)"; + $args = array( + ":proposal_id" => $proposal_id ); + $result = db_query($query, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); + } + $form['proposal_id'] = array( + '#type' => 'hidden', + '#default_value' => $proposal_id + ); + $form['internshipform'] = array( + '#type' => 'checkbox', + '#title' => t('Recieved Internship Application'), + '#description' => t('Check if the Internship Application has been recieved.'), + '#default_value' => $form1 + ); + $form['copyrighttransferform'] = array( + '#type' => 'checkbox', + '#title' => t('Recieved Copyright Transfer Form'), + '#description' => t('Check if the Copyright Transfer Form has been recieved.'), + '#default_value' => $form2 + ); + $form['undertakingform'] = array( + '#type' => 'checkbox', + '#title' => t('Recieved Undertaking Form'), + '#description' => t('Check if the Undertaking Form has been recieved.'), + '#default_value' => $form3 + ); + $form['recieptform'] = array( + '#type' => 'checkbox', + '#title' => t('Recieved Reciept Form'), + '#description' => t('Check if the Reciept Form has been recieved.'), + '#default_value' => $form4 + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Send Email') + ); + $form['cancel'] = array( + '#type' => 'markup', + '#value' => l(t('Cancel'), 'manage_proposal/all') + ); return $form; } - function paper_submission_form_submit($form, &$form_state) { - - /*$query ="UPDATE {textbook_companion_paper} SET internship_form = ".$form_state['values']['internshipform'].", copyright_form = ".$form_state['values']['copyrighttransferform'].", undertaking_form= ".$form_state['values']['undertakingform'].", reciept_form= ".$form_state['values']['recieptform']." WHERE proposal_id = ".$form_state['values']['proposal_id']; - db_query($query);*/ - + /*$query ="UPDATE {textbook_companion_paper} SET internship_form = ".$form_state['values']['internshipform'].", copyright_form = ".$form_state['values']['copyrighttransferform'].", undertaking_form= ".$form_state['values']['undertakingform'].", reciept_form= ".$form_state['values']['recieptform']." WHERE proposal_id = ".$form_state['values']['proposal_id']; + db_query($query);*/ $query = db_update('textbook_companion_paper'); $query->fields(array( - 'internship_form' => $form_state[ values ][ internshipform ], - 'copyright_form' => $form_state[ values ][ copyrighttransferform ], - 'undertaking_form' => $form_state[ values ][ undertakingform ], - 'reciept_form' => $form_state[ values ][ recieptform ], + 'internship_form' => $form_state[values][internshipform], + 'copyright_form' => $form_state[values][copyrighttransferform], + 'undertaking_form' => $form_state[values][undertakingform], + 'reciept_form' => $form_state[values][recieptform] )); $query->condition('proposal_id', $form_state['values']['proposal_id']); $num_updated = $query->execute(); - - /************************************************ - Check For the Internship Form is checked or not - ************************************************/ - if ($form_state['values']['internshipform'] == 1) - { - /* sending email */ - $book_user = user_load($proposal_data->uid); - $param['proposal_completed']['proposal_id'] = $proposal_id; - $param['proposal_completed']['user_id'] = $proposal_data->uid; - $email_to = $book_user->mail; - if (!drupal_mail('textbook_companion', 'internship_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Internship Form for Book proposal has been recieved. User has been notified .', 'status'); - } - else - { - if (!drupal_mail('textbook_companion', 'internship_form_not', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + /************************************************ + Check For the Internship Form is checked or not + ************************************************/ + if ($form_state['values']['internshipform'] == 1) + { + /* sending email */ + $book_user = user_load($proposal_data->uid); + $param['proposal_completed']['proposal_id'] = $proposal_id; + $param['proposal_completed']['user_id'] = $proposal_data->uid; + $email_to = $book_user->mail; + if (!drupal_mail('textbook_companion', 'internship_form', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Internship Form for Book proposal has been recieved. User has been notified .', 'status'); + } //$form_state['values']['internshipform'] == 1 + else + { + if (!drupal_mail('textbook_companion', 'internship_form_not', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) drupal_set_message('Error sending email message.', 'error'); drupal_set_message('Internship Form for Book proposal has not been recieved. User has been notified .', 'status'); - } - - /************************************************ - Check For the Copyright Form is checked or not - ************************************************/ + } + /************************************************ + Check For the Copyright Form is checked or not + ************************************************/ + if ($form_state['values']['copyrighttransferform'] == 1) + { + /* sending email */ + $book_user = user_load($proposal_data->uid); + $param['proposal_completed']['proposal_id'] = $proposal_id; + $param['proposal_completed']['user_id'] = $proposal_data->uid; + $email_to = $book_user->mail; + if (!drupal_mail('textbook_companion', 'copyrighttransfer_form', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Copyright Form for Book proposal has been recieved. User has been notified .', 'status'); + } //$form_state['values']['copyrighttransferform'] == 1 + else + { + if (!drupal_mail('textbook_companion', 'copyrighttransfer_form_not', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Copyright Transfer Form for Book proposal has not been recieved. User has been notified .', 'status'); + } + /************************************************ + Check For the Undertaking Form is checked or not + ************************************************/ + if ($form_state['values']['undertakingform'] == 1) + { + /* sending email */ + $book_user = user_load($proposal_data->uid); + $param['proposal_completed']['proposal_id'] = $proposal_id; + $param['proposal_completed']['user_id'] = $proposal_data->uid; + $email_to = $book_user->mail; + if (!drupal_mail('textbook_companion', 'undertakingform_form', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Undertaking Form for Book proposal has been recieved. User has been notified .', 'status'); + } //$form_state['values']['undertakingform'] == 1 + else + { + if (!drupal_mail('textbook_companion', 'undertakingform_form_not', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) + drupal_set_message('Error sending email message.', 'error'); + drupal_set_message('Undertaking Form for Book proposal has not been recieved. User has been notified .', 'status'); + } + drupal_set_message(t('Proposal Updated'), 'status'); +} +/*function proposal_edit_form_validate($form, &$form_state) +{ +/* mobile */ +/*if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile'])) +form_set_error('mobile', t('Invalid mobile number')); - if ($form_state['values']['copyrighttransferform'] == 1) - { - /* sending email */ - $book_user = user_load($proposal_data->uid); - $param['proposal_completed']['proposal_id'] = $proposal_id; - $param['proposal_completed']['user_id'] = $proposal_data->uid; - $email_to = $book_user->mail; - if (!drupal_mail('textbook_companion', 'copyrighttransfer_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Copyright Form for Book proposal has been recieved. User has been notified .', 'status'); - } - else - { - if (!drupal_mail('textbook_companion', 'copyrighttransfer_form_not', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Copyright Transfer Form for Book proposal has not been recieved. User has been notified .', 'status'); - } - - /************************************************ - Check For the Undertaking Form is checked or not - ************************************************/ +/* date of completion */ +/*if (!preg_match('/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/', $form_state['values']['completion_date'])) +form_set_error('completion_date', t('Invalid expected date of completion')); - if ($form_state['values']['undertakingform'] == 1) - { - /* sending email */ - $book_user = user_load($proposal_data->uid); - $param['proposal_completed']['proposal_id'] = $proposal_id; - $param['proposal_completed']['user_id'] = $proposal_data->uid; - $email_to = $book_user->mail; - if (!drupal_mail('textbook_companion', 'undertakingform_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Undertaking Form for Book proposal has been recieved. User has been notified .', 'status'); - } - else - { - if (!drupal_mail('textbook_companion', 'undertakingform_form_not', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); - drupal_set_message('Undertaking Form for Book proposal has not been recieved. User has been notified .', 'status'); - } +list($d, $m, $y) = explode('-', $form_state['values']['completion_date']); +$d = (int)$d; $m = (int)$m; $y = (int)$y; -drupal_set_message(t('Proposal Updated'), 'status'); -} +if (!checkdate($m, $d, $y)) +form_set_error('completion_date', t('Invalid expected date of completion')); +if (mktime(0, 0, 0, $m, $d, $y) <= time()) +form_set_error('completion_date', t('Expected date of completion should be in future')); -/*function proposal_edit_form_validate($form, &$form_state) -{ - /* mobile */ - /*if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile'])) - form_set_error('mobile', t('Invalid mobile number')); +/* 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')); - /* date of completion */ - /*if (!preg_match('/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/', $form_state['values']['completion_date'])) - form_set_error('completion_date', t('Invalid expected date of completion')); +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')); - list($d, $m, $y) = explode('-', $form_state['values']['completion_date']); - $d = (int)$d; $m = (int)$m; $y = (int)$y; - - if (!checkdate($m, $d, $y)) - form_set_error('completion_date', t('Invalid expected date of completion')); - - if (mktime(0, 0, 0, $m, $d, $y) <= time()) - form_set_error('completion_date', t('Expected date of completion should be in future')); +/* 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')); - /* 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 (!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-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')); +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 */ - /*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')); +/* year of publication */ +/*$cur_year = date('Y'); +if ((int)$form_state['values']['year1'] > $cur_year) +form_set_error('year1', t('Year of pulication should be not in the future for Book Preference 1')); - 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 ((int)$form_state['values']['year2'] > $cur_year) +form_set_error('year2', t('Year of pulication should be not in the future 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')); +if ((int)$form_state['values']['year3'] > $cur_year) +form_set_error('year3', t('Year of pulication should be not in the future for Book Preference 3')); - /* year of publication */ - /*$cur_year = date('Y'); - if ((int)$form_state['values']['year1'] > $cur_year) - form_set_error('year1', t('Year of pulication should be not in the future for Book Preference 1')); - - if ((int)$form_state['values']['year2'] > $cur_year) - form_set_error('year2', t('Year of pulication should be not in the future for Book Preference 2')); - - if ((int)$form_state['values']['year3'] > $cur_year) - form_set_error('year3', t('Year of pulication should be not in the future for Book Preference 3')); +/* isbn */ +/*if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1'])) +form_set_error('isbn1', t('Invalid ISBN for Book Preference 1')); - /* isbn */ - /*if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1'])) - form_set_error('isbn1', t('Invalid ISBN for Book Preference 1')); - - 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')); +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; }*/ - - function cheque_contct_form() { global $user; - /*$preference4_q = db_query("SELECT id FROM {textbook_companion_proposal} WHERE uid=".$user->uid);*/ - $query = db_select('textbook_companion_proposal'); - $query->fields('textbook_companion_proposal', array('id')); + $query->fields('textbook_companion_proposal', array( + 'id' + )); $query->condition('uid', $user->uid); $result = $query->execute(); $data = $result->fetchObject(); - - $form1 = $data->id; - - if($user->uid) - { + $form1 = $data->id; + if ($user->uid) + { $form['#redirect'] = FALSE; - $form['search'] = array( '#type' => 'textfield', '#title' => t('Search'), - '#size' => 48, + '#size' => 48 ); - $form['submit'] = array( '#type' => 'submit', '#value' => t('Search') ); - $form['cancel'] = array( '#type' => 'markup', - '#value' => l(t('Cancel'), ''), + '#value' => l(t('Cancel'), '') ); - $form['submit2'] = array( '#type' => 'markup', '#value' => l(t('Generate Report'), 'cheque_contct/report'), - '#attributes' => array('id' => 'perm_report'), + '#attributes' => array( + 'id' => 'perm_report' + ) ); - /*$search_q = db_query("SELECT * FROM textbook_companion_proposal p,textbook_companion_cheque c WHERE c.address_con = 'Submitted' AND (p.id = c.proposal_id)");*/ $query = db_select('textbook_companion_proposal', 'p'); - $query->join('textbook_companion_cheque','c','p.id = c.proposal_id'); + $query->join('textbook_companion_cheque', 'c', 'p.id = c.proposal_id'); $query->fields('p'); $query->fields('c'); - $query->condition('c.address_con','Submitted'); + $query->condition('c.address_con', 'Submitted'); $search_q = $query->execute(); - while ($search_data = $search_q->fetchObject()) - { - $search_rows[] = array(l($search_data->full_name, 'cheque_contct/status/' . $search_data->proposal_id),$search_data->address_con,$search_data->cheque_no,$search_data->cheque_dispatch_date); - } + { + $search_rows[] = array( + l($search_data->full_name, 'cheque_contct/status/' . $search_data->proposal_id), + $search_data->address_con, + $search_data->cheque_no, + $search_data->cheque_dispatch_date + ); + } //$search_data = $search_q->fetchObject() if ($search_rows) { - $search_header = array('Name Of The Student', 'Application Form Status', 'Cheque No', 'Cheque Clearance Date'); - $output .= theme('table',array('header'=>$search_header, 'rows'=>$search_rows)); + $search_header = array( + 'Name Of The Student', + 'Application Form Status', + 'Cheque No', + 'Cheque Clearance Date' + ); + $output .= theme('table', array( + 'header' => $search_header, + 'rows' => $search_rows + )); $form['search_results'] = array( '#type' => 'item', - '#title' => $_POST['search'] , - '#markup' => $output, + '#title' => $_POST['search'], + '#markup' => $output ); - } + } //$search_rows else { $form['search_results'] = array( '#type' => 'item', '#title' => t('Search results for "') . $_POST['search'] . '"', - '#markup' => 'No results found', + '#markup' => 'No results found' ); } if ($_POST) - { + { $output = ''; $search_rows = array(); $search_quert = ''; - /*$search_q = db_query("SELECT * FROM textbook_companion_proposal p,textbook_companion_cheque c WHERE c.address_con = 'Submitted' AND (p.id = c.proposal_id) AND (p.full_name LIKE '%%%s%%')", $_POST['search']);*/ $query = db_select('textbook_companion_proposal', 'p'); - $query->join('textbook_companion_cheque','c','p.id = c.proposal_id'); + $query->join('textbook_companion_cheque', 'c', 'p.id = c.proposal_id'); $query->fields('p'); $query->fields('c'); $query->condition('c.address_con', 'Submitted'); - $query->condition('p.full_name', '%%'.$_POST['search'].'%%', 'LIKE'); + $query->condition('p.full_name', '%%' . $_POST['search'] . '%%', 'LIKE'); $result = $query->execute(); - - while ($search_data = $result->fetchObject()) { - $search_rows[] = array(l($search_data->full_name, 'cheque_contct/status/' . $search_data->proposal_id),$search_data->address_con,$search_data->cheque_no,$search_data->cheque_dispatch_date); - } + $search_rows[] = array( + l($search_data->full_name, 'cheque_contct/status/' . $search_data->proposal_id), + $search_data->address_con, + $search_data->cheque_no, + $search_data->cheque_dispatch_date + ); + } //$search_data = $result->fetchObject() if ($search_rows) - { - $search_header = array('Name Of The Student', 'Application Form Status', 'Cheque No', 'Cheque Clearance Date'); - $output .= theme('table',array('header'=>$search_header,'rows'=>$search_rows)); - $form['search_results'] = array( - '#type' => 'item', - '#title' => t('Search results for "') . $_POST['search'] . '"', - '#markup' => $output, - ); - } + { + $search_header = array( + 'Name Of The Student', + 'Application Form Status', + 'Cheque No', + 'Cheque Clearance Date' + ); + $output .= theme('table', array( + 'header' => $search_header, + 'rows' => $search_rows + )); + $form['search_results'] = array( + '#type' => 'item', + '#title' => t('Search results for "') . $_POST['search'] . '"', + '#markup' => $output + ); + } //$search_rows else { - $form['search_results'] = array( - '#type' => 'item', - '#title' => t('Search results for "') . $_POST['search'] . '"', - '#markup' => 'No results found', - ); + $form['search_results'] = array( + '#type' => 'item', + '#title' => t('Search results for "') . $_POST['search'] . '"', + '#markup' => 'No results found' + ); } - } - return $form; - } + } //$_POST + return $form; + } //$user->uid else { /*$preference5_q = db_query("SELECT * FROM {textbook_companion_paper} WHERE proposal_id=".$form1); @@ -339,91 +340,90 @@ function cheque_contct_form() $query->fields('textbook_companion_paper'); $query->condition('proposal_id', $form1); $result = $query->execute(); - $data1=$result->fetchObject(); - + $data1 = $result->fetchObject(); $form2 = $data1->internship_form; $form3 = $data1->copyright_form; $form4 = $data1->undertaking_form; $form5 = $data1->reciept_form; - /*$chq_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id=".$form1); $data_chq = db_fetch_object($chq_q);*/ - $query = db_select('textbook_companion_proposal'); $query->fields('textbook_companion_proposal'); $query->condition('id', $form1); $result = $query->execute(); - $data_chq=$result->fetchObject(); - + $data_chq = $result->fetchObject(); $form9 = $data_chq->full_name; $form8 = $data->how_project; $form10 = $data_chq->mobile; $form11 = $data_chq->course; $form12 = $data_chq->branch; $form13 = $data_chq->university; - if($form2&&$form3&&$form4&&$form5) + if ($form2 && $form3 && $form4 && $form5) { $form['full_name'] = array( '#type' => 'textfield', '#title' => t('Full Name'), '#size' => 30, '#maxlength' => 50, - '#default_value' => $form9, + '#default_value' => $form9 ); $form['mobile'] = array( '#type' => 'textfield', '#title' => t('Mobile No.'), '#size' => 30, '#maxlength' => 15, - '#default_value' => $form10, + '#default_value' => $form10 ); $form['how_project'] = array( '#type' => 'select', '#title' => t('How did you come to know about this project'), - '#options' => array('Scilab Website' => 'Scilab Website', + '#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'), - '#default_value' => $form8, + 'Others' => 'Others' + ), + '#default_value' => $form8 ); $form['course'] = array( '#type' => 'textfield', '#title' => t('Course'), '#size' => 30, '#maxlength' => 50, - '#default_value' => $form11, + '#default_value' => $form11 ); $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'), - '#default_value' => $form12, - ); - + '#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' + ), + '#default_value' => $form12 + ); $form['university'] = array( '#type' => 'textfield', '#title' => t('University/Institute'), '#size' => 30, '#maxlength' => 100, - '#default_value' => $form13, + '#default_value' => $form13 ); $form['addressforcheque'] = array( '#type' => 'textfield', '#title' => t('Address For Mailing Cheque'), //'#required' => TRUE, '#size' => 30, - '#maxlength' => 100, + '#maxlength' => 100 ); $form['submit'] = array( '#type' => 'submit', @@ -433,168 +433,158 @@ function cheque_contct_form() '#type' => 'markup', '#value' => t('Cancel') ); - } + } //$form2 && $form3 && $form4 && $form5 if (!$form2) - { + { drupal_set_message(t('Internship Form has not been recieved.'), 'error'); - } - if(!$form3) - { + } //!$form2 + if (!$form3) + { drupal_set_message(t('Copyright Form has not been recieved.'), 'error'); - } - if(!$form4) - { + } //!$form3 + if (!$form4) + { drupal_set_message(t('Undertaking Form has not been recieved.'), 'error'); - } - return $form; + } //!$form4 + return $form; } } - - function cheque_status_form($form_state, $proposal_id) { global $user; - /* get current proposal */ $proposal_id = arg(2); - /*$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id =".$proposal_id);*/ - $query = db_select('textbook_companion_proposal'); - $query->fields('textbook_companion_proposal'); - $query->condition('id', $proposal_id); - $proposal_q = $query->execute(); - + $query = db_select('textbook_companion_proposal'); + $query->fields('textbook_companion_proposal'); + $query->condition('id', $proposal_id); + $proposal_q = $query->execute(); /*$proposal_q1 = db_query("SELECT * FROM {textbook_companion_cheque} WHERE proposal_id =".$proposal_id);*/ - $query = db_select('textbook_companion_cheque'); - $query->fields('textbook_companion_cheque'); - $query->condition('proposal_id', $proposal_id); - $proposal_q1 = $query->execute(); - - + $query = db_select('textbook_companion_cheque'); + $query->fields('textbook_companion_cheque'); + $query->condition('proposal_id', $proposal_id); + $proposal_q1 = $query->execute(); $proposal_data1 = $proposal_q1->fetchObject(); if (!$proposal_data = $proposal_q->fetchObject()) { drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error'); drupal_goto('manage_proposal'); return; - } - $form['proposal_id'] =array( + } //!$proposal_data = $proposal_q->fetchObject() + $form['proposal_id'] = array( '#type' => 'hidden', - '#default_value' => $proposal_id, + '#default_value' => $proposal_id ); - /*$empty = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = ".$proposal_id);*/ - $query = db_select('textbook_companion_proposal'); - $query->fields('textbook_companion_proposal'); - $query->condition('id', $proposal_id); - $empty = $query->execute(); - - if(!$empty) + $query = db_select('textbook_companion_proposal'); + $query->fields('textbook_companion_proposal'); + $query->condition('id', $proposal_id); + $empty = $query->execute(); + if (!$empty) { /*$prop =db_query("insert into {textbook_companion_cheque} (proposal_id) values(%d)",$proposal_id);*/ - $query = "insert into {textbook_companion_cheque} (proposal_id) values (:proposal_id)"; $args = array( - ":proposal_id"=>$proposal_id, - ); - $result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID)); - } + ":proposal_id" => $proposal_id + ); + $result = db_query($query, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); + } //!$empty $form['candidate_detail'] = array( '#type' => 'fieldset', '#title' => t('Candidate Details'), '#collapsible' => TRUE, '#collapsed' => FALSE, - '#attributes' => array('id' => 'candidate_detail'), + '#attributes' => array( + 'id' => 'candidate_detail' + ) ); $form['candidate_detail']['full_name'] = array( '#type' => 'item', '#markup' => $proposal_data->full_name, - '#title' => t('Contributor Name'), + '#title' => t('Contributor Name') ); $form['candidate_detail']['email'] = array( '#type' => 'item', '#markup' => user_load($proposal_data->uid)->mail, - '#title' => t('Email'), + '#title' => t('Email') ); $form['candidate_detail']['mobile'] = array( '#type' => 'item', '#markup' => $proposal_data->mobile, - '#title' => t('Mobile'), + '#title' => t('Mobile') ); $form['candidate_detail']['alt_mobile'] = array( '#type' => 'item', '#markup' => $proposal_data1->alt_mobno, - '#title' => t('Alternate Mobile No.'), + '#title' => t('Alternate Mobile No.') ); /*$form_q=db_query("SELECT * FROM {textbook_companion_paper} WHERE proposal_id =".$proposal_id); $form_data=db_fetch_object($form_q);*/ - $query = db_select('textbook_companion_paper'); $query->fields('textbook_companion_paper'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $form_data=$result->fetchObject(); - + $form_data = $result->fetchObject(); /* get book preference */ $preference_html = ''; $form['book_preference_f'] = array( '#type' => 'fieldset', '#title' => t('Book Preferences/Application Status'), '#collapsible' => FALSE, '#collapsed' => FALSE, - '#attributes' => array('id' => 'book_preference_f'), + '#attributes' => array( + 'id' => 'book_preference_f' + ) ); $form['book_preference_f']['book_preference'] = array( '#type' => 'item', '#markup' => $preference_html, - '#title' => t('Book Preferences'), + '#title' => t('Book Preferences') ); - /*$chq_q=db_query("SELECT * FROM {textbook_companion_cheque} WHERE proposal_id = %d", $proposal_id); $chq_data=db_fetch_object($chq_q);*/ $query = db_select('textbook_companion_cheque'); $query->fields('textbook_companion_cheque'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $chq_data=$result->fetchObject(); - + $chq_data = $result->fetchObject(); $form_html .= '', 'error'); - $x = $user->uid; - /*$query2 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid=".$x); - $data2 = db_fetch_object($query2);*/ - + /*$query2 = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid=".$x); + $data2 = db_fetch_object($query2);*/ $query = db_select('textbook_companion_proposal'); $query->fields('textbook_companion_proposal'); $query->condition('uid', $x); $result = $query->execute(); - $data2=$result->fetchObject(); - - - if(!$data2) + $data2 = $result->fetchObject(); + if (!$data2) { drupal_set_message('Fill Up The Book Proposal Form', 'error'); return ''; - } + } //!$data2 /*$query3 = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status=1 AND proposal_id=".$data2->id); $data3 = db_fetch_object($query3);*/ - $query = db_select('textbook_companion_preference'); $query->fields('textbook_companion_preference'); $query->condition('approval_status', 1); $query->condition('proposal_id', $data2->id); $result = $query->execute(); - $data3=$result->fetchObject(); - - if(!$data3->approval_status) + $data3 = $result->fetchObject(); + if (!$data3->approval_status) { drupal_set_message('Book Proposal Has Not Been Accpeted .', 'error'); return ''; - } - + } //!$data3->approval_status $proposal_id = $data2->id; - /*$comment_qx = db_query("SELECT * FROM textbook_companion_cheque c WHERE proposal_id =".$proposal_id); $commentv = db_fetch_object($comment_qx);*/ - $query = db_select('textbook_companion_cheque', 'c'); $query->fields('c'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $commentv=$result->fetchObject(); - - $form16 = $commentv->commentf; + $commentv = $result->fetchObject(); + $form16 = $commentv->commentf; $mob_no = $data2->mobile; $full_name = $data2->full_name; - /*$query1 = db_query("SELECT * FROM {textbook_companion_cheque} WHERE proposal_id=".$proposal_id);*/ $query = db_select('textbook_companion_cheque'); $query->fields('textbook_companion_cheque'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $form1 = 0; $form2 = 0; $form3 = 0; @@ -1116,226 +1102,224 @@ function contact_details($form_state) $form12 = 0; $form13 = 0; $form14 = 0; - $form15 = 0; - - if($data = $result->fetchObject()) + $form15 = 0; + if ($data = $result->fetchObject()) { $form1 = $data->address; $form8 = $data->alt_mobno; - $form9 = $data->perm_city; + $form9 = $data->perm_city; $form10 = $data->perm_state; $form11 = $data->perm_pincode; - $form12 = $data->temp_chq_address; + $form12 = $data->temp_chq_address; $form13 = $data->temp_city; $form14 = $data->temp_state; - $form15 = $data->temp_pincode; - } - else - { + $form15 = $data->temp_pincode; + } //$data = $result->fetchObject() + else + { /*db_query("insert into {textbook_companion_cheque} (proposal_id) values(%d)",$proposal_id);*/ - $query = "insert into {textbook_companion_cheque} (proposal_id) values (:proposal_id)"; $args = array( - ":proposal_id"=>$proposal_id, - ); - $result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID)); + ":proposal_id" => $proposal_id + ); + $result = db_query($query, $args, array( + 'return' => Database::RETURN_INSERT_ID + )); } $form['candidate_detail'] = array( - '#type' => 'fieldset', - '#value' => $form_html, - '#title' => t('Candidate Detail'), - '#attributes' => array('id' => 'candidate_detail'), + '#type' => 'fieldset', + '#value' => $form_html, + '#title' => t('Candidate Detail'), + '#attributes' => array( + 'id' => 'candidate_detail' + ) + ); + $form['proposal_id'] = array( + '#type' => 'hidden', + '#default_value' => $proposal_id ); - $form['proposal_id'] =array( - '#type' => 'hidden', - '#default_value' => $proposal_id, - ); $form['candidate_detail']['fullname'] = array( - '#type' => 'textfield', - '#title' => t('Full Name'), - '#size' => 48, - '#default_value' => $full_name, - ); - $form['candidate_detail']['email'] = array( - '#type' => 'textfield', - '#title' => t('Email'), - '#size' => 48, - '#value' => $user->mail, - '#disabled' => TRUE, - ); + '#type' => 'textfield', + '#title' => t('Full Name'), + '#size' => 48, + '#default_value' => $full_name + ); + $form['candidate_detail']['email'] = array( + '#type' => 'textfield', + '#title' => t('Email'), + '#size' => 48, + '#value' => $user->mail, + '#disabled' => TRUE + ); $form['candidate_detail']['mobileno1'] = array( - '#type' => 'textfield', - '#title' => t('Mobile No'), - '#size' => 48, - '#default_value' => $mob_no, - ); - - $form['candidate_detail']['mobileno2'] = array( - '#type' => 'textfield', - '#title' => t('Alternate Mobile No'), - '#size' => 48, - '#default_value' => $form8, - ); - + '#type' => 'textfield', + '#title' => t('Mobile No'), + '#size' => 48, + '#default_value' => $mob_no + ); + $form['candidate_detail']['mobileno2'] = array( + '#type' => 'textfield', + '#title' => t('Alternate Mobile No'), + '#size' => 48, + '#default_value' => $form8 + ); /*$chq_q=db_query("SELECT * FROM {textbook_companion_cheque} WHERE proposal_id=".$proposal_id); - $chq_data=db_fetch_object($chq_q);*/ - + $chq_data=db_fetch_object($chq_q);*/ $query = db_select('textbook_companion_cheque'); $query->fields('textbook_companion_cheque'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $chq_data=$result->fetchObject(); - - - /*$q_form = db_query("SELECT * FROM {textbook_companion_paper} WHERE proposal_id=".$proposal_id); - $q_data = db_fetch_object($q_form);*/ - + $chq_data = $result->fetchObject(); + /*$q_form = db_query("SELECT * FROM {textbook_companion_paper} WHERE proposal_id=".$proposal_id); + $q_data = db_fetch_object($q_form);*/ $query = db_select('textbook_companion_paper'); $query->fields('textbook_companion_paper'); $query->condition('proposal_id', $proposal_id); $result = $query->execute(); - $q_data=$result->fetchObject(); - - $form_html .= '