diff options
author | Jayaram R Pai | 2014-08-13 17:26:23 +0530 |
---|---|---|
committer | Jayaram R Pai | 2014-08-13 17:26:23 +0530 |
commit | 76cacaa12a54e4a41abdca098e7d5d4337345b34 (patch) | |
tree | b2c5954e70e98379b40c8766fd69a08d8678f56e | |
parent | dc6ac35cc79941225aa59ea9dc2ea82e2cbec853 (diff) | |
download | scilab_textbook_companion-76cacaa12a54e4a41abdca098e7d5d4337345b34.tar.gz scilab_textbook_companion-76cacaa12a54e4a41abdca098e7d5d4337345b34.tar.bz2 scilab_textbook_companion-76cacaa12a54e4a41abdca098e7d5d4337345b34.zip |
added aicte report form
-rwxr-xr-x | css/textbook_companion.css | 8 | ||||
-rwxr-xr-x | js/textbook_companion.js | 48 | ||||
-rwxr-xr-x | textbook_companion.module | 63 |
3 files changed, 119 insertions, 0 deletions
diff --git a/css/textbook_companion.css b/css/textbook_companion.css index 6883f5a..e2981b1 100755 --- a/css/textbook_companion.css +++ b/css/textbook_companion.css @@ -109,3 +109,11 @@ fieldset input[type="text"] padding-bottom: 5px; border-bottom: 1px solid #cccccc; } +#textbook-companion-aicte-report-form { + padding: 15px; + background: #ffffff; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + -o-border-radius: 5px; + border-radius: 5px; +} diff --git a/js/textbook_companion.js b/js/textbook_companion.js index 7602bdc..ea607df 100755 --- a/js/textbook_companion.js +++ b/js/textbook_companion.js @@ -108,6 +108,54 @@ $filters.each(function() { }); } }); + +$report_form = $("#textbook-companion-aicte-report-form"); +$("#aicte-report").click(function() { + $("#textbook-companion-aicte-report-form").lightbox_me( { + centered: true + }); }); +/* validate report_form and submit */ +function danger(obj) { + obj.css("border", "2px solid red"); +} +function safe(obj) { + obj.css("border", "2px solid #cccccc"); +} +function validateEmail(email) { + var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return re.test(email); +} +$report_form.submit(function(e) { + var $name = $("#edit-name"); + var $email = $("#edit-email"); + var $number = $("#edit-number"); + var $book = $("#edit-book"); + + var errors = 0; + /* reset errors */ + safe($name); safe($email); safe($number); safe($book); + if(!$name.val()) { + danger($name); + errors = 1; + } + if(!validateEmail($email.val())) { + danger($email); + errors = 1; + } + if(!$number.val()) { + danger($number); + errors = 1; + } + if($book.val() == "0") { + danger($book); + errors = 1; + } + if(!errors) { + $(this).submit(); + } + e.preventDefault(); +}); +}); diff --git a/textbook_companion.module b/textbook_companion.module index 54c7970..c8b1e52 100755 --- a/textbook_companion.module +++ b/textbook_companion.module @@ -619,6 +619,66 @@ function textbook_companion_aicte_proposal_form_submit($form, &$form_state) { drupal_goto("proposal"); } +function textbook_companion_aicte_report_form($form_state) { + $query = " + SELECT * FROM textbook_companion_aicte + WHERE status = 0 + ORDER BY book + "; + $result = db_query($query); + $books = array(); + $books[0] = "Please select a book"; + while($row = db_fetch_object($result)) { + $books[$row->id] = "{$row->book} ({$row->author})"; + } + $form = array(); + $form["name"] = array( + "#type" => "textfield", + "#title" => "Name", + "#description" => t("Please enter your name."), + ); + $form["email"] = array( + "#type" => "textfield", + "#title" => "Email", + "#description" => t("Please enter your valid email id."), + ); + $form["number"] = array( + "#type" => "textfield", + "#title" => "Number", + "#description" => t("Please enter your valid phone number."), + ); + $form["book"] = array( + "#type" => "select", + "#title" => "AICTE Book", + "#description" => t("Please select a book."), + "#options" => $books + ); + $form["comment"] = array( + "#type" => "textarea", + "#title" => "Any other comment?", + "#description" => t("Please enter your query (if any)") + ); + $form["submit"] = array( + "#type" => "submit", + "#value" => "Submit" + ); + return $form; +} + +function textbook_companion_aicte_report_form_submit($form, &$form_state) { + $v = $form_state["values"]; + $query = " + INSERT INTO textbook_companion_aicte_report + (aicte_id, name, number, email, comment) + VALUES + (%d, '%s', '%s', '%s', '%s') + "; + $result = db_query($query, + $v["book"], $v["name"], $v["number"], $v["email"], $v["comment"] + ); + drupal_set_message("Thank you for reporting.", "status"); +} + function textbook_companion_aicte_proposal_all() { global $user; $page_content = ""; @@ -633,6 +693,7 @@ 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>If you are unable to propose any of the books from the below list, please let us know. <a id='aicte-report' href='#'>Click here</a> to report.</li>"; $page_content .= "</ul>"; $page_content .= "<div id='aicte-list-wrapper'>"; $num_rows = mysql_num_rows($result); @@ -662,6 +723,8 @@ function textbook_companion_aicte_proposal_all() { } } $page_content .= "</div>"; + /* adding aicte report form */ + $page_content .= drupal_get_form("textbook_companion_aicte_report_form"); return $page_content; } |