Skip to content

Commit f3d87a2

Browse files
committed
Merge pull request #1341 from HTSolution/issue-1282
#1282 added parent_category list in edit report new category
2 parents 99656a7 + 2783b39 commit f3d87a2

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

application/controllers/admin/reports.php

+30-1
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,20 @@ public function save_category()
11391139
if ($_POST)
11401140
{
11411141
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
1142+
// HT: New code for category save with parent
1143+
$post = arr::extract($_POST, 'parent_id',
1144+
'category_title', 'category_description', 'category_color');
1145+
1146+
// Category instance for the operation
1147+
$category = new Category_Model();
1148+
if ($category->validate($post)) {
1149+
$category->save();
1150+
$form_saved = TRUE;
1151+
1152+
echo json_encode(array("status"=>"saved", "id"=>$category->id));
1153+
}
1154+
// HT: End of code for category save with parent
1155+
/*
11421156
$post = Validation::factory($_POST);
11431157
11441158
// Add some filters
@@ -1161,7 +1175,7 @@ public function save_category()
11611175
$form_saved = TRUE;
11621176
11631177
echo json_encode(array("status"=>"saved", "id"=>$category->id));
1164-
}
1178+
}*/
11651179
else
11661180
{
11671181
echo json_encode(array("status"=>"error"));
@@ -1211,10 +1225,25 @@ public function deleteall() {
12111225
// Dynamic categories form fields
12121226
private function _new_categories_form_arr()
12131227
{
1228+
// HT: Parent category list
1229+
$parents_array = ORM::factory('category')
1230+
->where('parent_id','0')
1231+
->where('category_trusted != 1')
1232+
->select_list('id', 'category_title');
1233+
1234+
// add none to the list
1235+
$parents_array[0] = "--- Top Level Category ---";
1236+
1237+
// Put "--- Top Level Category ---" at the top of the list
1238+
ksort($parents_array);
1239+
// HT: End of Parent category list
1240+
12141241
return array(
12151242
'category_name' => '',
12161243
'category_description' => '',
12171244
'category_color' => '',
1245+
'parent_id' => 0, // HT: new category parent
1246+
'category_parent_array' => $parents_array, // HT: new category parent
12181247
);
12191248
}
12201249

application/views/admin/reports/edit.php

+6
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@
169169
print '<br/>';
170170
print form::input('category_name', $new_categories_form['category_name'], 'class=""');
171171
print '<br/>';
172+
// HT: Parent category on report edit
173+
print form::label(array("id"=>"parent_id_label", "for"=>"parent_id"), Kohana::lang('ui_main.parent_category'));
174+
print '<br/>';
175+
print form::dropdown('category_parent_id', $new_categories_form['category_parent_array'], $new_categories_form['parent_id'], 'class=""');
176+
print '<br/>';
177+
// HT: End of Parent category on report edit
172178
print form::label(array("id"=>"description_label", "for"=>"description"), Kohana::lang('ui_main.description'));
173179
print '<br/>';
174180
print form::input('category_description', $new_categories_form['category_description'], 'class=""');

themes/default/views/reports/submit_edit_js.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ function remove() {
391391
});
392392

393393
// Textbox Hints
394-
$("#location_find").hint();
395394

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

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

423423
$.post("<?php echo url::base() . 'admin/reports/save_category/' ?>",
424-
{ category_title: category_name, category_description: category_description, category_color: category_color },
424+
{ 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
425425
function(data){
426426
if ( data.status == 'saved')
427427
{

0 commit comments

Comments
 (0)