<?php

if (!defined('APP_START')) {
    die('Access denied');
}
if (!$addons['sn']) {
    cw_header_location('index.php');
}
cw_load('serials');
if ($current_area == 'A') {
    $serial_numbers = cw_get_serial_numbers('', $product_id);
} else {
    $serial_numbers = cw_get_serial_numbers($customer_id, $product_id);
}
if (is_array($print) && is_array($serial_numbers)) {
    foreach ($serial_numbers as $k => $sn) {
        if (!$print[$sn['sn']]) {
            unset($serial_numbers[$k]);
        }
    }
}
$smarty->assign('serial_numbers', $serial_numbers);
    $smarty->assign('memberships', $memberships);
}
$shippings = cw_query("select {$tables['shipping']}.* from {$tables['shipping']}, {$tables['shipping_carriers']} where {$tables['shipping']}.carrier_id={$tables['shipping_carriers']}.carrier_id and active=1 ORDER BY orderby");
$smarty->assign('shippings', $shippings);
$smarty->assign('warranties', cw_get_warranties($edited_language));
$check_sections = array("arrivals", "hot_deals", "clearance", "super_deals", "featured_products");
$sec = array();
foreach ($check_sections as $val) {
    $sec[$val] = cw_query_first("select * from " . $tables[$val] . " where product_id='{$product_id}'" . ($val == 'featured_products' ? " and category_id=0" : ""));
}
$smarty->assign('sec', $sec);
$location[] = array(cw_get_langvar_by_name('lbl_adm_product_management'), 'index.php?target=' . $target);
if ($product_id) {
    $location[] = array(cw_get_langvar_by_name('lbl_product_modify'), 'index.php?target=' . $target . '&mode=details&product_id=' . $product_id);
    $location[] = array($product_info['product'], '');
} else {
    $location[] = array(cw_get_langvar_by_name('lbl_product_add'), '');
}
$smarty->assign('js_tab', $js_tab);
$smarty->assign('last_added_product_type', $last_added_product_type);
cw_load("serials");
if (AREA_TYPE == 'A' || AREA_TYPE == 'V') {
    $serial_numbers = cw_get_serial_numbers('', $product_id, true);
} else {
    $serial_numbers = cw_get_serial_numbers($user_account['warehouse_customer_id'], $product_id);
}
//$smarty->assign("serial_numbers", array_chunk($serial_numbers, $config['sn']['serial_per_row_product']));
$attributes = cw_func_call('cw_attributes_get', array('item_id' => $product_id, 'item_type' => 'P', 'prefilled' => $attributes, 'is_default' => $is_default_attributes, 'language' => $edited_language));
$smarty->assign('attributes', $attributes);
// Suppliers
$smarty->assign('suppliers', cw_user_get_suppliers());