Skip to content

Commit

Permalink
Merge pull request #1341 from HTSolution/issue-1282
Browse files Browse the repository at this point in the history
#1282 added parent_category list in edit report new category
  • Loading branch information
kamaulynder committed Apr 13, 2014
2 parents 99656a7 + 2783b39 commit f3d87a2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
31 changes: 30 additions & 1 deletion application/controllers/admin/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,20 @@ public function save_category()
if ($_POST)
{
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
// HT: New code for category save with parent
$post = arr::extract($_POST, 'parent_id',
'category_title', 'category_description', 'category_color');

// Category instance for the operation
$category = new Category_Model();
if ($category->validate($post)) {
$category->save();
$form_saved = TRUE;

echo json_encode(array("status"=>"saved", "id"=>$category->id));
}
// HT: End of code for category save with parent
/*
$post = Validation::factory($_POST);
// Add some filters
Expand All @@ -1161,7 +1175,7 @@ public function save_category()
$form_saved = TRUE;
echo json_encode(array("status"=>"saved", "id"=>$category->id));
}
}*/
else
{
echo json_encode(array("status"=>"error"));
Expand Down Expand Up @@ -1211,10 +1225,25 @@ public function deleteall() {
// Dynamic categories form fields
private function _new_categories_form_arr()
{
// HT: Parent category list
$parents_array = ORM::factory('category')
->where('parent_id','0')
->where('category_trusted != 1')
->select_list('id', 'category_title');

// add none to the list
$parents_array[0] = "--- Top Level Category ---";

// Put "--- Top Level Category ---" at the top of the list
ksort($parents_array);
// HT: End of Parent category list

return array(
'category_name' => '',
'category_description' => '',
'category_color' => '',
'parent_id' => 0, // HT: new category parent
'category_parent_array' => $parents_array, // HT: new category parent
);
}

Expand Down
6 changes: 6 additions & 0 deletions application/views/admin/reports/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
print '<br/>';
print form::input('category_name', $new_categories_form['category_name'], 'class=""');
print '<br/>';
// HT: Parent category on report edit
print form::label(array("id"=>"parent_id_label", "for"=>"parent_id"), Kohana::lang('ui_main.parent_category'));
print '<br/>';
print form::dropdown('category_parent_id', $new_categories_form['category_parent_array'], $new_categories_form['parent_id'], 'class=""');
print '<br/>';
// HT: End of Parent category on report edit
print form::label(array("id"=>"description_label", "for"=>"description"), Kohana::lang('ui_main.description'));
print '<br/>';
print form::input('category_description', $new_categories_form['category_description'], 'class=""');
Expand Down
4 changes: 2 additions & 2 deletions themes/default/views/reports/submit_edit_js.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ function remove() {
});

// Textbox Hints
$("#location_find").hint();

/* Dynamic categories */
<?php if ($edit_mode): ?>
Expand All @@ -400,6 +399,7 @@ function remove() {
var category_name = $("input#category_name").val();
var category_description = $("input#category_description").val();
var category_color = $("input#category_color").val();
var category_parent_id = $("select#category_parent_id").val(); // HT: Parent category in report edit new category

//trim the form fields
//Removed ".toUpperCase()" from name and desc for Ticket #38
Expand All @@ -421,7 +421,7 @@ function remove() {
}

$.post("<?php echo url::base() . 'admin/reports/save_category/' ?>",
{ category_title: category_name, category_description: category_description, category_color: category_color },
{ category_title: category_name, category_description: category_description, category_color: category_color, parent_id : category_parent_id }, // HT: Parent category in report edit new category
function(data){
if ( data.status == 'saved')
{
Expand Down

0 comments on commit f3d87a2

Please sign in to comment.