summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprashantsinalkar2017-01-28 21:39:43 +0530
committerprashantsinalkar2017-01-28 21:39:43 +0530
commit75e5048dbbdec6a5f401999cace110c925835787 (patch)
tree16ba28c9f90d307290551bba7e8643940f61793c
parent6df626312cf0a3719e197e4c2730294bfda4ff95 (diff)
downloadtextbook_companion_fixer-75e5048dbbdec6a5f401999cace110c925835787.tar.gz
textbook_companion_fixer-75e5048dbbdec6a5f401999cace110c925835787.tar.bz2
textbook_companion_fixer-75e5048dbbdec6a5f401999cace110c925835787.zip
added sub category hide show on checkbox action
-rwxr-xr-xtextbook_companion_fixer.module58
-rw-r--r--textbook_companion_fixer_edit_book_category.inc190
2 files changed, 64 insertions, 184 deletions
diff --git a/textbook_companion_fixer.module b/textbook_companion_fixer.module
index 199b354..b7a8c3e 100755
--- a/textbook_companion_fixer.module
+++ b/textbook_companion_fixer.module
@@ -64,6 +64,11 @@ function textbook_companion_fixer_menu()
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
+ $items["textbook_companion_fixer/ajax/edit-book-category"] = array(
+ "page callback" => "textbook_companion_fixer_edit_book_category_ajax",
+ "access callback" => TRUE,
+ "type" => MENU_CALLBACK
+ );
/* for admin */
$items['admin/settings/textbook_companion_fixer_settings'] = array(
'title' => 'textbook companion fixer Settings',
@@ -801,9 +806,32 @@ function _textbook_companion_fixer_list_of_category($category_id = NULL)
} //$category_list_data = $category_list->fetchObject()
return $category;
}
-function _textbook_companion_fixer_list_of_category_checkboxes()
-
+function textbook_companion_fixer_edit_book_category_ajax($item,$key){
+ if ($item == "edit_book_category") {
+ $data .= "Updated";
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('textbook_companion_from_email', '');
+ $bcc = variable_get('textbook_companion_fixer_bcc_emails', '');
+ $cc = variable_get('textbook_companion_fixer_cc_emails', '');
+ $params['category_updated']['pref_id'] = $pref_id;
+ $params['category_updated']['user_id'] = $user->uid;
+ $params['category_updated']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ 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)
+ }
+}
+function _textbook_companion_fixer_list_of_category_checkboxes()
{
$query = db_select('list_of_category');
$query->fields('list_of_category');
@@ -816,32 +844,25 @@ function _textbook_companion_fixer_list_of_category_checkboxes()
{
$categoryname=$category_list_data->main_category;
if($categoryname!=null||strlen($categoryname)!=0){
- $category[$category_list_data->category_id] = $category_list_data->main_category;
+ //$category[$category_list_data->category_id] = $category_list_data->main_category;
+
+ $category .= "<input type='checkbox' name='ids[]' value='".$category_list_data->category_id."' class='main-category-chk-".$category_list_data->category_id."' >".$category_list_data->main_category."<br>
+ <select class='main-subcategory-".$category_list_data->category_id."'>"._textbook_companion_fixer_list_of_subcategory($category_list_data->category_id)."</select><br><br><hr>";
} //$category_list_data = $category_list->fetchObject()
}
return $category;
}
function _textbook_companion_fixer_list_of_subcategory($category_id)
{
-
- if ($category_id == NULL)
- {
$query = db_select('list_of_subcategory');
$query->fields('list_of_subcategory');
- $query->orderBy('id', 'ASC');
- $subcategory_list = $query->execute();
- } //$category_id == NULL
- else
- {
- $query = db_select('list_of_subcategory');
- $query->fields('list_of_subcategory');
- $query->condition('main_category', $category_id);
- $query->orderBy('id', 'ASC');
- $subcategory_list = $query->execute();
- }
+ $query->condition('main_category', $category_id);
+ $query->orderBy('id', 'ASC');
+ $subcategory_list = $query->execute();
+ $subcategory .= "<option value='0'> Please select a subcategory </option>";
while ($subcategory_list_data = $subcategory_list->fetchObject())
{
- $category[$subcategory_list_data->id] = $subcategory_list_data->subcategory;
+ $subcategory .= "<option value='".$subcategory_list_data->id."' data-name='".$subcategory_list_data->subcategory."'>".$subcategory_list_data->subcategory."</option>";
} //$category_list_data = $category_list->fetchObject()
return $subcategory;
}
@@ -849,6 +870,7 @@ function textbook_companion_fixer_init()
{
drupal_add_css(drupal_get_path("module", "textbook_companion_fixer") . "/css/textbook_companion_fixer.css");
drupal_add_js(drupal_get_path("module", "textbook_companion_fixer") . "/js/textbook_companion_fixer.js");
+ drupal_add_js(drupal_get_path("module", "textbook_companion_fixer") . "/js/textbook_companion_fixer_edit_category.js");
//drupal_add_js(drupal_get_path("module", "scilab_fixer") . "/js/jquery-noconfilct.js");
drupal_add_js(drupal_get_path("module", "textbook_companion_fixer") . "/js/selection.js");
}
diff --git a/textbook_companion_fixer_edit_book_category.inc b/textbook_companion_fixer_edit_book_category.inc
index 4cf42c9..88311c5 100644
--- a/textbook_companion_fixer_edit_book_category.inc
+++ b/textbook_companion_fixer_edit_book_category.inc
@@ -50,93 +50,6 @@ function textbook_companion_fixer_edit_book_proposal_all()
));
return $output;
}
-/*
-function _edit_category_all(){
- // get pending proposals to be approved
- $preference_rows = array();
- //$preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status = 1 ORDER BY id DESC");
- $query = db_select('textbook_companion_preference');
- $query->fields('textbook_companion_preference');
- $query->condition('approval_status', 1);
- $query->orderBy('id', 'DESC');
- $preference_q = $query->execute();
- while ($preference_data = $preference_q->fetchObject())
- {
- switch ($preference_data->category)
- {
- case 0:
- $category_data = 'Not Selected';
- break;
- case 1:
- $category_data = 'Fluid Mechanics';
- break;
- case 2:
- $category_data = 'Control Theory & Control Systems';
- break;
- case 3:
- $category_data = 'Chemical Engineering';
- break;
- case 4:
- $category_data = 'Thermodynamics';
- break;
- case 5:
- $category_data = 'Mechanical Engineering';
- break;
- case 6:
- $category_data = 'Signal Processing';
- break;
- case 7:
- $category_data = 'Digital Communications';
- break;
- case 8:
- $category_data = 'Electrical Technology';
- break;
- case 9:
- $category_data = 'Mathematics & Pure Science';
- break;
- case 10:
- $category_data = 'Analog Electronics';
- break;
- case 11:
- $category_data = 'Digital Electronics';
- break;
- case 12:
- $category_data = 'Computer Programming';
- break;
- case 13:
- $category_data = 'Others';
- break;
- default:
- $category_data = 'Unknown';
- break;
- } //$preference_data->category
- $preference_rows[] = array(
- $preference_data->book . "<br> <i>by " . $preference_data->author . "</i>",
- $preference_data->isbn,
- $preference_data->publisher,
- $preference_data->edition,
- $preference_data->year,
- $category_data,
- l('Edit', 'manage_proposal/category/edit/' . $preference_data->id)
- );
- } //$preference_data = $preference_q->fetchObject()
- $preference_header = array(
- 'Book',
- 'ISBN',
- 'Publisher',
- 'Edition',
- 'Year',
- 'Category',
- 'Status'
- );
- $output = theme('table', array(
- 'header' => $preference_header,
- 'rows' => $preference_rows
- ));
- return $output;
-
-}
-*/
/******************************************************************************/
/**************************** CATEGORY EDIT FORM ******************************/
/******************************************************************************/
@@ -155,122 +68,67 @@ function textbook_companion_fixer_category_edit_form($form, &$form_state)
drupal_goto('manage_proposal/category');
return;
} //!$preference_data
- $form['book'] = array(
+ $form["wrapper"] = array(
+ "#type" => "fieldset",
+ "#title" => "Edit the existing book category to new category",
+ "#prefix" => "<div id='fix-tbc-category-form'>",
+ "#suffix" => "</div>"
+ );
+ $form["wrapper"]['book'] = array(
'#type' => 'item',
'#title' => t('Title of the book'),
'#markup' => $preference_data->book
);
- $form['author'] = array(
+ $form["wrapper"]['author'] = array(
'#type' => 'item',
'#title' => t('Author Name'),
'#markup' => $preference_data->author
);
- $form['isbn'] = array(
+ $form["wrapper"]['isbn'] = array(
'#type' => 'item',
'#title' => t('ISBN No'),
'#markup' => $preference_data->isbn
);
- $form['publisher'] = array(
+ $form["wrapper"]['publisher'] = array(
'#type' => 'item',
'#title' => t('Publisher & Place'),
'#markup' => $preference_data->publisher
);
- $form['edition'] = array(
+ $form["wrapper"]['edition'] = array(
'#type' => 'item',
'#title' => t('Edition'),
'#markup' => $preference_data->edition
);
- $form['year'] = array(
+ $form["wrapper"]['year'] = array(
'#type' => 'item',
'#title' => t('Year of pulication'),
'#markup' => $preference_data->year
);
- //main_category = _textbook_companion_fixer_list_of_category_checkboxes();
- $query = db_select('list_of_category');
- $query->fields('list_of_category');
- //$query->fields(array('category_id','main_category'));
- $query->orderBy('category_id', 'ASC');
- $category_list = $query->execute();
-
-
- while ($category_list_data = $category_list->fetchObject())
- {
- $categoryname = $category_list_data->main_category;
- if($categoryname!=null||strlen($categoryname)!=0){
- $category[$category_list_data->category_id] = $category_list_data->main_category;
+ $form["wrapper"]['main_category']= array(
+ "#markup" => _textbook_companion_fixer_list_of_category_checkboxes(),
+ );
- $form['main_category'.$category_list_data->category_id]= array(
- '#type' => 'checkbox',
- '#title' => $category_list_data->main_category,
- '#ajax' => array(
- 'wrapper' => 'ajax-subcategory-list-replace-'. $category_list_data->category_id,
- 'callback' => 'ajax_subcategory_list_callback_'.$category_list_data->category_id
+ $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>"
);
- $form['main_subcategory_'. $category_list_data->category_id]= array(
- '#type' => 'select',
- '#options' => $category_list_data->main_category,
- '#prefix' => '<div id="ajax-subcategory-list-replace-'. $category_list_data->category_id.'">',
- '#suffix' => '</div>',
- );
-
- } //$category_list_data = $category_list->fetchObject()
- }
-
- /* orm['main_category'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Main category'),
- '#options' => $main_category,
- '#required' => TRUE
- );*/
-
- $form['category'] = array(
- '#type' => 'select',
- '#title' => t('Category'),
- '#options' => _tbc_list_of_category(),
- '#required' => TRUE,
- '#default_value' => $preference_data->category
- );
- $form['submit'] = array(
+ $form["wrapper"]['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
- $form['cancel'] = array(
+ $form["wrapper"]['cancel'] = array(
'#type' => 'markup',
'#value' => l(t('Cancel'), 'textbook_companion_fixer/edit_book_category')
);
return $form;
}
-function textbook_companion_fixer_category_edit_form_submit($form, &$form_state)
-{
- // get current proposal
- $preference_id = (int) arg(3);
- //preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $preference_id);
- $preference_data = db_fetch_object($preference_q);
- $query = db_select('textbook_companion_preference');
- $query->fields('textbook_companion_preference');
- $query->condition('id', $preference_id);
- $preference_q = $query->execute();
- $preference_data = $preference_q->fetchObject();
- if (!$preference_data)
- {
- drupal_set_message(t('Invalid book selected. Please try again.'), 'error');
- drupal_goto('textbook_companion_fixer/edit_book_category');
- return;
- } //!$preference_data
- //db_query("UPDATE {textbook_companion_preference} SET category = %d WHERE id = %d", $form_state['values']['category'], $preference_data->id);
- $query = db_update('textbook_companion_preference');
- $query->fields(array(
- 'category' => $form_state['values']['category']
- ));
- $query->condition('id', $preference_data->id);
- $num_updated = $query->execute();
- drupal_set_message(t('Book Category Updated'), 'status');
- drupal_goto('textbook_companion_fixer/edit_book_category');
-}
-
/********************* Ajax callback ***************************/
function ajax_subcategory_list_callback_1($form, $form_state)