<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$title}</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
<link href="../menu/css/dropdown/dropdown.css" media="all" rel="stylesheet" type="text/css" />
<link href="../menu/css/dropdown/themes/default/default.advanced.css" media="all" rel="stylesheet" type="text/css" />
<!--[if lt IE 7]>
<script type="text/javascript" src="../menu/js/jquery/jquery.js"></script>
<script type="text/javascript" src="../menu/js/jquery/jquery.dropdown.js"></script>
<![endif]-->
<!-- Initialize Dojo -->
{literal}
<script src='../dojo/dojo/dojo.js' type='text/javascript'></script>
<script type='text/javascript'>
//<!--
// The following function submits the data from the 'post-form' form
// to a PHP script located at
// 'http://www.dojoforum.com/demo-0.9/xhr/parse_form.php'
// The PHP script simply outputs a string in the format of
// 'Hello $name!', which is then put in the <div> w/ the id
// of 'response'.
//
// NOTE: As with xhrGet, you can also use handleAs to accept
// JSON objects in your load() function.
//dojo.require("dojo.style");
function addCat() {
category_name = document.getElementById("category_name").value;
category_description = document.getElementById("category_description").value;
parent_cat_id = document.getElementById("parent_cat_id").value;
//alert(category_name);
dojo.xhrPost ({
// The page that parses the POST request
url: 'add_cat.php?btn_create=Create&parent_cat_id='+parent_cat_id+'&category_name='+category_name+'&category_description='+category_description,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_cat_box').innerHTML = data;
updateCatListSelect();
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function updateCatListSelect(){
dojo.xhrPost ({
// The page that parses the POST request
url: 'cat_list.php',
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('cat_list_select').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function listAllCat(category_id, category_name) {
//alert("S");
dojo.xhrPost ({
// The page that parses the POST request
url: 'list_all_cat.php?category_id='+category_id+'&category_name='+category_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_cat_box').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function showSubCat(category_id, category_name) {
dojo.xhrPost ({
// The page that parses the POST request
url: 'get_sub_cat.php?category_id='+category_id+'&category_name='+category_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_all_cat_box').innerHTML = data;
//alert("s");
listAllCat(category_id, category_name);
document.getElementById('main_cat_name').innerHTML = category_name;
document.getElementById('tips_box').style.display="";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function addSubCat(category_id, parent_cat_id, parent_cat_name){
dojo.xhrPost ({
// The page that parses the POST request
url: 'add_sub_cat.php?category_id='+category_id+'&parent_cat_id='+parent_cat_id+'&parent_cat_name='+parent_cat_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_all_cat_box').innerHTML = data;
//listAllCat();
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function addToSubCat(category_id, parent_cat_id, parent_cat_name) {
dojo.xhrPost ({
// The page that parses the POST request
url: 'set_sub_cat.php?category_id='+category_id+'&parent_cat_id='+parent_cat_id+'&parent_cat_name='+parent_cat_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_sub_cat_box').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function showSelectedSubCat(parent_cat_id, parent_cat_name) {
dojo.xhrPost ({
// The page that parses the POST request
url: 'set_sub_cat.php?mode=showsubcat&parent_cat_id='+parent_cat_id+'&parent_cat_name='+parent_cat_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_sub_cat_box').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}
function delCat(cat_id) {
if (confirm("Are you sure that you want to delete this category? This will also delete all products under this category")){
dojo.xhrPost ({
// The page that parses the POST request
url: 'del_cat.php?mode=delete&category_id='+cat_id,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_cat_box').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}// end confirm
}
function delSubCat(cat_id, parent_cat_id, parent_cat_name) {
if (confirm("Are you sure that you want to de-select this sub category?")){
dojo.xhrPost ({
// The page that parses the POST request
url: 'del_sub_cat.php?mode=delete&category_id='+cat_id+'&parent_cat_id='+parent_cat_id+'&parent_cat_name='+parent_cat_name,
// Name of the Form we want to submit
//form: 'login',
// Loads this function if everything went ok
load: function (data) {
// Put the data into the appropriate <div>
//document.getElementById('loader2').style.display="";
dojo.byId('update_all_cat_box').innerHTML = data;
//document.getElementById('loader2').style.display="none";
},
// Call this function if an error happened
error: function (error) {
console.error ('Error: ', error);
}
});
}// end confirm
}
function initmsg(){
document.getElementById('msg_sub_cat').innerHTML = "Please select parent category";
}
//-->
</script>
{/literal}
</head>
<body onload="initmsg()">
<div id="page_container">
<div id="admin_header">{include file='admin_header.tpl'}</div>
<div id="admin_nav">{include file='admin_navigation.tpl'}</div>
<div id="contents">
<!-- Manage category controls -->
<div id="manage_cat_box">
<h3>Manage Categories</h3>
{include file='create_cat_form.tpl'}
<br />
{$msg}<br />
<h3>Manage sub-categories</h3>
<div style="width:700px;">
<div style="width:35%; float:left;">
<div id="update_cat_box">
{include file='show_cat.tpl'}
</div>
</div>
<div style="width:30%; float:left;">
<div id="update_all_cat_box">
{include file='show_sub_cat.tpl'}
</div>
</div>
<div style="width:35%; float:right;">
<div id="tips_box" style="display:none">
<div id="tip_add_sub_cat" style="background-color:#FFFFCA; font-size:15px; padding:30px;">Use <img src="images/icons/bullet_go.png" align="absmiddle" /> to add sub-category into <strong><span id="main_cat_name" style="font-size:24px; font-weight:bold;"></span></strong></div>
</div>
</div>
</div>
</div>
<!-- end manage categories -->
<!-- <div id="section_info_box">
<h4>Why to select image</h4>
</div>
-->
<div style="clear:both;"></div>
</div>
<div id="admin_footer">{include file='admin_footer.tpl'}</div>
</div>
</body>
</html>