summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2017-01-31 17:43:07 +0530
committerprashantsinalkar2017-01-31 17:43:07 +0530
commit02c5b4d8bcbfaf76153c131aa4f3410f2ca092d0 (patch)
treeb97552e9c61c8e65ddc5a8f7c46256808c11ea76
parent75e5048dbbdec6a5f401999cace110c925835787 (diff)
downloadtextbook_companion_fixer-02c5b4d8bcbfaf76153c131aa4f3410f2ca092d0.tar.gz
textbook_companion_fixer-02c5b4d8bcbfaf76153c131aa4f3410f2ca092d0.tar.bz2
textbook_companion_fixer-02c5b4d8bcbfaf76153c131aa4f3410f2ca092d0.zip
added submit function
-rw-r--r--js/textbook_companion_fixer_edit_category.js33
-rwxr-xr-xtextbook_companion_fixer.module23
-rw-r--r--textbook_companion_fixer_edit_book_category.inc50
3 files changed, 52 insertions, 54 deletions
diff --git a/js/textbook_companion_fixer_edit_category.js b/js/textbook_companion_fixer_edit_category.js
index 9c2c4f7..2821382 100644
--- a/js/textbook_companion_fixer_edit_category.js
+++ b/js/textbook_companion_fixer_edit_category.js
@@ -1,15 +1,9 @@
(function($) {
$(document).ready(function() {
var basePath = Drupal.settings.basePath;
+ //var modPath = basePath + "textbook_companion_fixer/";
var modPath = basePath + "textbook_companion_fixer/ajax/edit-book-category/";
$category_form = $("#fix-tbc-category-form");
- $main_category1 = $(".main-category-1");
- $main_category2 = $(".main-category-2");
- $main_category3 = $(".main-category-3");
- $main_category4 = $(".main-category-4");
- $main_category5 = $(".main-category-5");
- $main_category6 = $(".main-category-6");
- $main_category7 = $(".main-category-7");
$(".main-subcategory-1").hide();
$(".main-subcategory-2").hide();
$(".main-subcategory-3").hide();
@@ -18,7 +12,6 @@
$(".main-subcategory-6").hide();
$(".main-subcategory-7").hide();
prop = $('.main-category-chk-1').prop('checked');
- console.log(prop);
$('.main-category-chk-1').change(function() {
if (!this.checked) {
$('.main-subcategory-1').hide();
@@ -76,7 +69,29 @@
}
});
//edit category form submit
- $category_form.submit(function(e) {
+ $("#submit-button-category").click(function(e) {
+ var main_cat_chk_value = [];
+ $("input[name='ids[]']:checked").each(function (){
+ main_cat_chk_value.push(parseInt($(this).val()));
+ });
+ console.log(modPath);
+ $.ajax({
+ url: modPath,
+ type: "POST",
+ data: {
+ pref_id: pref_id,
+ main_category: main_cat_chk_value,
+ subcategory: ""
+ },
+ dataType: "html",
+ success: function(data) {
+ $updating.hide();
+ $done.show();
+ console.log("data: +" + main_cat_chk_value);
+ $done.fadeOut("slow");
+ //alert("ok");
+ }
+ });
e.preventDefault();
});
diff --git a/textbook_companion_fixer.module b/textbook_companion_fixer.module
index b7a8c3e..62350a7 100755
--- a/textbook_companion_fixer.module
+++ b/textbook_companion_fixer.module
@@ -808,8 +808,24 @@ function _textbook_companion_fixer_list_of_category($category_id = NULL)
}
function textbook_companion_fixer_edit_book_category_ajax($item,$key){
- if ($item == "edit_book_category") {
+ $data = "";
+ $item = arg(2);
+
+ if ($item == "edit-book-category") {
$data .= "Updated";
+ foreach($_POST['main_category'] as $main_category && $_POST['sub_category'] as $sub_category) {
+ $query = "
+ INSERT INTO textbook_companion_book_main_subcategories
+ (pref_id, main_category, sub_category)
+ VALUES
+ (:pref_id, :main_category, :subcategory)
+ ";
+ $args = array(
+ ':pref_id' => $_POST['pref_id'],
+ ':main_category' =>$main_category,
+ ':subcategory' => $sub_category,
+ );
+ $result = db_query($query, $args);
/* sending email */
$email_to = $user->mail;
$from = variable_get('textbook_companion_from_email', '');
@@ -829,7 +845,12 @@ function textbook_companion_fixer_edit_book_category_ajax($item,$key){
if (!drupal_mail('textbook_companion_fixer', 'category_updated', $email_to, language_default(), $params, $from, TRUE)) {
$data .= 'Error sending email message.';
} //!drupal_mail('textbook_companion_fixer', 'example_updated', $email_to, language_default(), $params, $from, TRUE)
+ }
+
}
+ $data .= $main_cat;
+ echo $data;
+ exit();
}
function _textbook_companion_fixer_list_of_category_checkboxes()
{
diff --git a/textbook_companion_fixer_edit_book_category.inc b/textbook_companion_fixer_edit_book_category.inc
index 88311c5..56429cc 100644
--- a/textbook_companion_fixer_edit_book_category.inc
+++ b/textbook_companion_fixer_edit_book_category.inc
@@ -1,9 +1,4 @@
<?php
-/*
-function textbook_companion_fixer_edit_book_category(){
-
-}
-*/
function textbook_companion_fixer_edit_book_proposal_all()
{
//get the book count
@@ -104,51 +99,18 @@ function textbook_companion_fixer_category_edit_form($form, &$form_state)
'#title' => t('Year of pulication'),
'#markup' => $preference_data->year
);
-
-
$form["wrapper"]['main_category']= array(
- "#markup" => _textbook_companion_fixer_list_of_category_checkboxes(),
- );
-
- $form["wrapper"]['main_subcategory_'. $category_list_data->category_id] = array(
- "#type" => "select",
- "#title" => t("Please select the subcategory."),
- "#options" => array(
- 0 => "Please select a subcategory ".$category_list_data->category_id
- ),
- "#prefix" => "<div class='select-subcategory-".$category_list_data->category_id."'>",
- "#suffix" => "</div>"
+ "#markup" => _textbook_companion_fixer_list_of_category_checkboxes(),
);
$form["wrapper"]['submit'] = array(
'#type' => 'submit',
- '#value' => t('Submit')
+ '#value' => t('Submit'),
+ '#attributes' => array('id' => 'submit-button-category'),
+ "#prefix" => "<div class='update-button-category'>",
+ "#suffix" => "</div>"
);
$form["wrapper"]['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'textbook_companion_fixer/edit_book_category')
+ '#markup' => l(t('Cancel'), 'textbook_companion_fixer/edit_book_category')
);
return $form;
}
-
-/********************* Ajax callback ***************************/
-function ajax_subcategory_list_callback_1($form, $form_state)
-{
- $category_default_value = 1;
- if ($category_default_value > 0)
- {
- $form['main_subcategory_1']['#options'] = _textbook_companion_fixer_list_of_subcategory($category_default_value);
- $commands[] = ajax_command_replace("#ajax-subcategory-list-replace-1", drupal_render($form['main_subcategory_1']));
-
- } //$category_default_value > 0
- else
- {
- $form['main_subcategory_1']['#options'] = _textbook_companion_fixer_list_of_subcategory();
- $commands[] = ajax_command_replace("#ajax-subcategory-list-replace-1", drupal_render($form['main_subcategory_1']));
-
- }
- return array(
- '#type' => 'ajax',
- '#commands' => $commands
- );
-}
-/*************************************************************************/