$query_data = array('order_by' => $v['order_by']); cw_array2update('accounting_categories', $query_data, "accounting_category_id='" . $k . "'"); } $path = cw_accounting_category_get_subcategory_ids(array_keys($posted_data)); if (!empty($path)) { cw_accounting_category_recalc_subcat_count($path); } $top_message['content'] = cw_get_langvar_by_name("msg_adm_categories_upd"); $top_message['type'] = "I"; cw_header_location("index.php?target={$target}&cat={$cat}"); } if ($action == "delete") { $categories_to_delete =& cw_session_register('categories_to_delete', array()); if ($confirmed == "Y") { if (is_array($categories_to_delete)) { foreach ($categories_to_delete as $cat) { $parent_category_id = cw_accounting_category_delete($cat); } } $top_message['content'] = cw_get_langvar_by_name('msg_adm_category_del'); $top_message['type'] = 'I'; cw_header_location("index.php?target={$target}&cat={$parent_category_id}"); } else { $categories_to_delete = is_array($delete_arr) ? array_keys($delete_arr) : ""; cw_header_location("index.php?target={$target}&cat={$cat_org}&mode=delete"); } } $smarty->assign('subcategories', cw_accounting_get_subcategories($cat)); $smarty->assign('current_category', cw_accounting_get_category_data($cat)); $smarty->assign('cat', $cat); $smarty->assign('js_tab', $js_tab);
<?php $saved_current_category =& cw_session_register('saved_current_category', array()); if ($mode == 'edit') { $current_category = cw_accounting_get_category_data($cat); } if ($action == 'update') { if (empty($category_data['category']) || empty($category_data['code'])) { $saved_current_category = $category_data; $top_message = array('content' => cw_get_langvar_by_name('err_filling_form'), 'type' => 'E'); cw_header_location("index.php?target={$target}&mode={$mode}&cat={$cat}" . ($mode == 'add' ? "&accounting_type=" . $accounting_type : "")); } if ($mode == 'add') { $new_cat = cw_array2insert('accounting_categories', array('parent_id' => $cat, 'accounting_type' => $accounting_type)); cw_accounting_category_update_path($new_cat); cw_accounting_category_recalc_subcat_count($cat); $cat = $new_cat; } $to_update = array('category' => $category_data['category'], 'code' => $category_data['code'], 'related_category_id' => $category_data['related_category_id']); cw_array2update('accounting_categories', $to_update, "accounting_category_id='{$cat}'"); if ($category_data['info']) { $category_data['info']['accounting_category_id'] = $cat; if ($mode == 'edit') { $accounting_type = $current_category['accounting_type']; } cw_array2insert('accounting_categories_' . $accounting_type, $category_data['info'], true); } cw_header_location("index.php?target={$target}&mode=edit&cat={$cat}"); } if ($action == 'move') { $old_path = cw_accounting_category_get_path($cat);