#########################################
#  Author  : D3W4 & SAHAT               #
#  Created : Jan 3, 2012 10:59:04 PM    #
#########################################
use_class('products_minierp');
$class_pm = new products_minierp();
$products_id = tep_db_prepare_input($_GET['products_id']);
$designs_id = tep_db_prepare_input($_GET['designs_id']);
$accessed = strpos($_SERVER['HTTP_REFERER'], 'designs-manage') !== false || !empty($designs_id) ? CONST_ACCESS_DESIGNS_MANAGEMENT : '';
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'PRODUCTELUSED') {
        $result = $class_pm->templateElementsUsed('?open=designs-products-elements-used&products_id=' . $_POST['products_id'] . '&hidemenu=true&designs_id=' . $designs_id);
        echo $result;
        exit;
    } elseif ($_POST['me_action'] == 'ELEMENTSUSEDADD') {
        $class_pm->templateAddElementsUsed();
    } elseif ($_POST['me_action'] == 'ELEMENTSUSEDUPDATE') {
        $class_pm->templateUpdateElementsUsed();
    } elseif ($_POST['me_action'] == 'ELEMENTSUSEDOVR') {
        $class_pm->templateOverrideElementsUsed();
    }
}
$content = '<div id="area-el-used"></div>';
$title = "Product {$products_id} - Manage Elements Used";
$javascript = '
            var accessed = "' . $accessed . '";
            var designs_id = "' . $designs_id . '";
            document.reloadFocusedTab = function(){
                if(accessed != "undefined" && accessed == "' . CONST_ACCESS_DESIGNS_MANAGEMENT . '") window.parent.document.reloadFocusedTab(' . $designs_id . ');
                $("#area-el-used").html(img_ajax_load_1);
                $.post(url, { me_action: "PRODUCTELUSED", act:"LOAD", products_id: ' . $products_id . ' }, productElUsedLoaded, "html");