"state": {"key": "cat_products_tree_data"},
"core": {
data: $cat_pro,
"check_callback": function(operation, node, node_parent, node_position, more) {
// operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node'
// in case of 'rename_node' node_position is filled with the new node name
// Check if node is dragged from same tree
if (operation == "move_node")
{
$destination_category = node_parent.li_attr["class"];
$parent_tree_value = node.id.substr(0, 2);
// Preventing Internal Drag n Drop
if ($parent_tree_value == "j1")
return false;
// Preventing Internal Drag n Drop
if ($destination_category != "category" && $destination_category != "product")
return false;
else
{
// Get Product's ID where items are been dropped
$pro_id = node_parent.li_attr["pro_id"];
// Gets Node where items are been dropped
$node_id = node_parent.id;
this.deselect_all();
this.select_node(node_parent.id);
this.open_node(node_parent.id);
return true;
}
}
else if (operation == "delete_node")
{
$destination_category = node.li_attr["class"];
if ($destination_category != "supplier" && $destination_category != "category")
{
if (node.li_attr.item_qty == null)
{
return false;
}
if (confirm("Do you really want to delete \n" + $destination_category + " : '" + this.get_node(node.id).text + "' !") == true)
{
$node_pro_id = node.li_attr.pro_id;
$node_sku = node.li_attr.item_sku;
$node_qty = node.li_attr.item_qty;
// Call AJAX function for deleting the item from c_products_has_items
koolajax.callback(delete_pro_item($node_pro_id, $node_sku, $node_qty));
return true;
}
else {
return false;
}
}
else
return false;
}
else if (operation == "copy_node")
{
$item_sku = node.li_attr.item_sku;
$item_id = node.li_attr.item_id;
node.li_attr.pro_id = $pro_id;
if ($item_sku == "" || $item_sku == null)
{
alert("SKU for this item is missing!");
return false;
}
// Add this item in c_products_has_items table with 1 qty
if ($pro_id != 0 || $pro_id != "")
{
koolajax.callback(new_item_pro_qty($pro_id, $item_id, $item_sku, "1"));
}
return true;
}
},
"expand_selected_onload": true,
"themes": {"stripes": true}
},
"plugins": ["dnd", "state", "contextmenu"]
});