function on_add_cart(&$cart, $added_product)
{
    global $smarty;
    cw_load('ajax', 'product');
    $product_id = $cart['products'][$added_product['productindex']]['product_id'];
    $product = cw_func_call('cw_product_get', array('id' => $product_id, 'info_type' => 0 | 128));
    $product = cw_array_merge($product, $added_product);
    $smarty->assign('product', $product);
    cw_add_ajax_block(array('id' => 'add2cart_popup', 'action' => 'update', 'template' => 'addons/ajax_add2cart/add2cart_popup.tpl'), 'add2cart_popup');
    cw_add_ajax_block(array('id' => 'script', 'content' => 'sm("add2cart_popup",add2cart_popup_width,add2cart_popup_height, true, "' . $added_product['added_amount'] . ($added_product['added_amount'] > 1 ? ' items' : ' item') . ' added to cart")'), 'add2cart_popup_script');
}
    if ($customer_id) {
        $bookmarks = cw_query_first_cell("SELECT count(*) FROM {$tables['bookmarks']} WHERE customer_id='" . intval($customer_id) . "' AND url='{$_GET['url']}'");
    } else {
        $bookmarks = cw_query_first_cell("SELECT count(*) FROM {$tables['bookmarks']} WHERE sess_id='{$APP_SESS_ID}-" . AREA_TYPE . "' AND url='{$_GET['url']}'");
    }
    $name = preg_replace('/(\\s-\\s)*' . $location[0][0] . '(\\s-\\s)*/', '', $name);
    $breadcrumbs = explode('-', $name);
    $name = trim(array_pop($breadcrumbs));
    if ($bookmarks == 0) {
        $data = array('customer_id' => $customer_id, 'sess_id' => $APP_SESS_ID . '-' . AREA_TYPE, 'url' => $_GET['url'], 'name' => $_GET['name'], 'pos' => 0);
        cw_array2insert('bookmarks', $data);
    }
    $action = 'get';
}
if ($action == 'delete') {
    if ($customer_id) {
        $bookmarks = db_query("DELETE FROM {$tables['bookmarks']} WHERE customer_id='" . intval($customer_id) . "' AND md5(url)='{$_GET['id']}'");
    } else {
        $bookmarks = db_query("DELETE FROM {$tables['bookmarks']} WHERE sess_id='{$APP_SESS_ID}-" . AREA_TYPE . "' AND md5(url)='{$_GET['id']}'");
    }
    $action = 'get';
}
if ($action == 'get') {
    if ($customer_id) {
        $bookmarks = get_by_customer($customer_id);
    } else {
        $bookmarks = get_by_session($APP_SESS_ID . '-' . AREA_TYPE);
    }
    $smarty->assign('bookmarks', $bookmarks);
    cw_add_ajax_block(array('id' => 'bm_content', 'template' => 'addons/' . addon_name . '/panel.tpl'));
}
<?php

cw_load('export');
// get objects count
if ($action == 'getcount') {
    $count = cw_objects_get_count();
    cw_add_ajax_block(array('id' => 'count_for_export', 'action' => 'update', 'content' => cw_get_langvar_by_name('add_to_export') . ' [' . $count . ']'));
    cw_add_ajax_block(array('id' => 'widget_set_container', 'action' => 'update', 'content' => $count ? $count . ' ' . cw_get_langvar_by_name('lbl_lc_products') . ' | <a href="javascript:resetSet();">' . cw_get_langvar_by_name('lbl_clear') . '</a>' : cw_get_langvar_by_name('lbl_all_products')));
}
// reset objects set
if ($action == 'reset') {
    $count = cw_objects_get_count();
    $result = cw_objects_reset();
    if ($result) {
        $count = 0;
    }
    cw_add_ajax_block(array('id' => 'count_for_export', 'action' => 'update', 'content' => cw_get_langvar_by_name('add_to_export') . ' [' . $count . ']'));
    cw_add_ajax_block(array('id' => 'widget_set_container', 'action' => 'update', 'content' => $count ? $count . ' ' . cw_get_langvar_by_name('lbl_lc_products') . ' | <a href="javascript:resetSet();">' . cw_get_langvar_by_name('lbl_clear') . '</a>' : cw_get_langvar_by_name('lbl_all_products')));
}
// add object to set
if ($action == 'add') {
    if (!empty($set_ids)) {
        $objects = explode(",", $set_ids);
        $result = cw_objects_add_to_set($objects);
        if ($result) {
            $count = cw_objects_get_count();
            cw_add_ajax_block(array('id' => 'count_for_export', 'action' => 'update', 'content' => cw_get_langvar_by_name('add_to_export') . ' [' . $count . ']'));
            cw_add_ajax_block(array('id' => 'widget_set_container', 'action' => 'update', 'content' => $count ? $count . ' ' . cw_get_langvar_by_name('lbl_lc_products') . ' | <a href="javascript:resetSet();">' . cw_get_langvar_by_name('lbl_clear') . '</a>' : cw_get_langvar_by_name('lbl_all_products')));
        }
    }
}
    $product_info['amount'] = 1;
    $config['General']['apply_default_country'] = 'Y';
    $config['Shipping']['enable_all_shippings'] = 'N';
    $cart_tmp['products'] = array($product_info);
    $shippings = cw_func_call('cw_shipping_get_list', array('cart' => $cart_tmp, 'products' => array($product_info), 'userinfo' => $userinfo, 'warehouse_customer_id' => $warehouse));
    // Supplier delivery time
    if ($product_info['system']['supplier_customer_id']) {
        $supplier_fields = cw_user_get_custom_fields($product_info['system']['supplier_customer_id'], 0, '', 'field');
        if ($supplier_fields['min_delivery_time'] == $supplier_fields['max_delivery_time']) {
            $product_info['supplier']['delivery_time'] = $supplier_fields['min_delivery_time'];
        } else {
            $product_info['supplier']['delivery_time'] = $supplier_fields['min_delivery_time'] . '-' . $supplier_fields['max_delivery_time'];
        }
    }
    $smarty->assign('shippings', $shippings);
}
$smarty->assign('zipcode', $zipcode);
$smarty->assign('country', $country ? $country : $user_account['country']);
$smarty->assign('product', $product_info);
if (defined('IS_AJAX') && constant('IS_AJAX')) {
    cw_add_ajax_block(array('id' => 'estimate_shipping_container', 'action' => 'replace', 'template' => 'customer/products/estimate-fields.tpl'));
} else {
    $avails = cw_warehouse_get_avails_customer($product_id);
    $smarty->assign('avails', $avails);
    $smarty->assign('count_avails', count($avails));
    $location[] = array(cw_get_langvar_by_name('lbl_estimate_ship_note'), '');
    $smarty->assign('home_style', 'popup');
    $smarty->assign('current_main_dir', 'addons/shipping_system');
    $smarty->assign('current_section_dir', 'customer');
    $smarty->assign('main', 'popup-shipping');
}
<?php

if (constant('IS_AJAX') && is_numeric($doc_id)) {
    global $tables;
    $remind_products = cw_query("\n        SELECT DISTINCT di.product_id, ui.customer_id\n        FROM {$tables['docs']} d\n        LEFT JOIN {$tables['docs_items']} di ON di.doc_id = d.doc_id\n        LEFT JOIN {$tables['docs_user_info']} ui ON ui.doc_info_id = d.doc_info_id\n        WHERE d.doc_id = {$doc_id}\n    ");
    if (!empty($remind_products) && is_array($remind_products)) {
        $customer_products = array();
        foreach ($remind_products as $_r) {
            $customer_products[$_r['customer_id']][] = $_r['product_id'];
        }
        cw_review_send_order_review_reminder_email($customer_products);
        $lbl_name = 'lbl_email_sent_successfully';
    } else {
        $lbl_name = 'lbl_email_not_sent';
    }
    cw_add_ajax_block(array('id' => 'additional_doc_action', 'action' => 'update', 'content' => cw_get_langvar_by_name($lbl_name, NULL, FALSE, TRUE)));
}
function view_shipping_estimator()
{
    cw_add_ajax_block(array('id' => 'script', 'content' => 'sm("shipping_estimator_dialog", 0, 0, true, "Estimate shipping")'));
}
    $smarty->assign('sort_direction', 0);
    $orderby = "ORDER BY sending_date DESC";
    if (!empty($sort_field)) {
        $orderby = "ORDER BY " . $sort_field;
        $navigation['script'] .= "&sort_field=" . $sort_field;
        $smarty->assign('sort_field', $sort_field);
    }
    if ($sort_direction != "") {
        if (!empty($orderby)) {
            $orderby .= $sort_direction ? " ASC" : " DESC";
        }
        $navigation['script'] .= "&sort_direction=" . $sort_direction;
        $smarty->assign('sort_direction', abs($sort_direction - 1));
    }
    $smarty->assign('navigation', $navigation);
    $get_count = FALSE;
    $limit = " LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}";
    $messages_list = cw_call('cw_messages_get_messages_list', array($customer_id, $mode, $get_count, $where, $orderby, $limit));
    $smarty->assign('messages_list', $messages_list);
}
$smarty->assign('mode', $mode);
if (defined('IS_AJAX')) {
    cw_load('ajax');
    $addon_app_area = APP_AREA == 'customer' ? APP_AREA : 'admin';
    cw_add_ajax_block(array('id' => 'contents_messages_list', 'action' => 'update', 'template' => 'addons/' . messaging_addon_name . '/' . $addon_app_area . '/messages.tpl'));
} else {
    $avail_langvar_modes = array('show' => 'lbl_message', 'new' => 'lbl_new_message', 'incoming' => 'lbl_avail_type_incoming', 'sent' => 'lbl_sent', 'archive' => 'lbl_archive');
    $location[] = array(cw_get_langvar_by_name($avail_langvar_modes[$mode]), '');
    $smarty->assign('main', 'message_box');
    $smarty->assign('current_section_dir', 'message_box');
}
if ($mode == 'email') {
    cw_load('mail');
    if ($action == 'clean_spool') {
        db_query("DELETE FROM {$tables['mail_spool']}");
    }
    if ($action == 'delete_email') {
        foreach ($_POST['delete'] as $mail_id => $v) {
            db_query("DELETE FROM {$tables['mail_spool']} WHERE mail_id='{$mail_id}'");
        }
    }
    if ($action == 'check_email' && !empty($_POST['email'])) {
        cw_call('cw_send_mail', array($config['Company']['site_administrator'], $_REQUEST['email'], 'mail/' . $_REQUEST['subject'], 'mail/' . $_REQUEST['body']));
    }
    if ($action == 'pause_email_send') {
        db_query("REPLACE {$tables['config']} (name, config_category_id, value) values ('pause_email_sending', 1, '{$pause_email_value}')");
        cw_add_ajax_block(array('id' => 'pause_email_sending_container', 'action' => 'append', 'content' => ''));
        return;
    }
    cw_header_location("index.php?target={$target}");
}
$mail_templates = cw_files_get_dir($app_dir . $app_skin_dir . '/mail', 1, true);
foreach ($mail_templates as $mt) {
    $mt = str_replace($app_dir . $app_skin_dir . '/mail/', '', $mt);
    if (strpos($mt, '_subj.tpl') !== false) {
        $subjects[] = $mt;
    } else {
        $bodies[] = $mt;
    }
}
$mail_spool_total = cw_query_first_cell("SELECT count(*) FROM {$tables['mail_spool']}");
$mail_spool = cw_query("SELECT mail_id, mail_to, subject, body FROM {$tables['mail_spool']} ORDER BY mail_id DESC LIMIT 20");
<?php

global $current_location;
$result = cw_clean_url_delete_url_by_id_and_get_data($url_id);
$content = "No urls";
$url_list = cw_clean_url_get_url_list_from_history($result['item_id'], $result['item_type']);
if (count($url_list)) {
    $content = "";
    foreach ($url_list as $url) {
        $content .= $url['url'] . '&nbsp;';
        $content .= '<a href="javascript:delete_clean_url(\'' . $url['id'] . '\');">';
        $content .= '<img src="' . $current_location . '/skins/images/delete_cross.gif" alt="Delete from history" title="Delete from history">';
        $content .= '</a><br>';
    }
}
cw_add_ajax_block(array('id' => 'clean_urls_container', 'action' => 'update', 'content' => $content));
<?php

global $smarty, $tables;
if (defined('IS_AJAX') && !empty($review_id)) {
    cw_load('ajax');
    $review = cw_review_get_management_reviews("WHERE {$tables['products_reviews']}.review_id=" . $review_id, "", "");
    $smarty->assign('review_item', $review[0]);
    cw_add_ajax_block(array('id' => 'review_item_record_' . $review_id, 'action' => 'update', 'template' => 'addons/estore_products_review/admin_reviews_management_item.tpl'));
}
$review_session_data =& cw_session_register('review_session_data', array());
$top_message =& cw_session_register('top_message');
$review_data['page'] = $review_session_data['page'] = !empty($page) ? $page : 1;
$review_data['sort_field'] = "";
$review_data['sort_direction'] = "";
$where = "";
$orderby = "ORDER BY {$tables['products_reviews']}.ctime";
$limit = "";
if ($action == 'add_reviews') {
    if (!empty($review_new['message'])) {
        cw_call('cw_review_add_new_review_manual', array($review_new, 0));
        $top_message = array('content' => cw_get_langvar_by_name('msg_adm_products_reviews_upd'), 'type' => 'I');
    }
    cw_header_location("index.php?target=estore_reviews_management&action=process");
}
if ($action == 'delete') {
    if (!empty($checked_review)) {
        foreach ($checked_review as $review_id => $_review) {
            cw_review_delete_review($review_id);
        }
        $top_message = array('content' => cw_get_langvar_by_name('txt_review_nas_been_deleted'), 'type' => 'I');
        cw_header_location("index.php?target=estore_reviews_management&action=process");
                    cw_array2insert('products_votes', array('remote_ip' => $review_data['remote_ip'], 'vote_value' => $vote, 'product_id' => $review_data['product_id'], 'customer_id' => $review_data['customer_id'], 'review_id' => $review_id, 'attribute_id' => $attr_id));
                }
                cw_review_recalculate_avg_rating($review_data['product_id'], $attr_id);
            }
            cw_review_recalculate_avg_rating($review_data['product_id']);
            // if some changed
            if ($review_data['email'] != $review['email'] || $review_data['message'] != $review['message']) {
                $status = $config['estore_products_review']['status_created_reviews'];
            }
            // update review
            $update_review_data = array();
            $update_review_data['email'] = $review['email'];
            $update_review_data['message'] = $review['message'];
            $update_review_data['status'] = $status;
            cw_array2update('products_reviews', $update_review_data, "review_id = '{$review_id}'");
        }
    }
    cw_add_ajax_block(array('id' => 'review_management_container', 'action' => 'append', 'content' => ''));
}
$review = array();
if (!empty($review_id) && !empty($product_id) && $config['estore_products_review']['customer_reviews'] == 'Y' && cw_review_avail_by_settings($product_id, $_customer_id, $extended_review_customer_id)) {
    $review = cw_query_first("SELECT  * FROM {$tables['products_reviews']} r  WHERE r.review_id='{$review_id}' AND r.customer_id='{$_customer_id}'");
    if ($config['estore_products_review']['customer_voting'] == 'Y') {
        $attribute_votes = cw_review_get_attribute_vote_values($review);
    }
}
$smarty->assign('review', $review);
$smarty->assign('attribute_votes', $attribute_votes);
$smarty->assign('current_section_dir', 'main');
$smarty->assign('main', 'estore_review_management');
$smarty->assign('home_style', 'popup');
function delete_file()
{
    global $current_location;
    cw_load('files');
    $_file = trim($_GET['file']);
    $_filename = addon_files_location_path . $_file;
    if (!empty($_file) && cw_allow_file($_filename)) {
        unlink($_filename);
    }
    $content = "No files";
    $files = cw_ebay_get_avail_export_files_list();
    if (count($files)) {
        $content = "";
        foreach ($files as $file) {
            $content .= '<a href="' . $file['path'] . '">' . $file['name'] . '</a>&nbsp;<a href="javascript:delete_export_file(\'' . $file['name'] . '\');"><img src="' . $current_location . '/skins/images/delete_cross.gif"></a><br>';
        }
    }
    cw_add_ajax_block(array('id' => 'export_files_container', 'action' => 'update', 'content' => $content));
}
    cw_header_location("index.php?target={$target}");
}
if ($action == 'login_reseller') {
    global $action, $current_area;
    $action = 'login';
    $current_area = 'R';
    cw_include('include/login.php');
    cw_header_location("index.php?target={$target}");
}
if ($action == 'logout') {
    cw_include('include/login.php');
}
if ($mode == 'need_login' && defined('IS_AJAX')) {
    $usertype = 'C';
    cw_add_ajax_block(array('id' => 'login_dialog', 'template' => 'customer/acc_manager/login_customer.tpl'));
    cw_add_ajax_block(array('id' => 'script', 'content' => "sm('login_dialog', need_login_width, need_login_height, true, 'Need login');"));
    $remember_data =& cw_session_register("remember_data");
    $remember_data['URL'] = $redirect_to;
}
if ($is_ajax) {
    global $user, $user_to_modify;
    $user_to_modify = $user = $customer_id;
    $self_modification = 1;
    cw_include('include/users/modify.php');
} elseif ($mode == 'delete') {
    cw_include('include/users/modify.php');
} elseif (empty($customer_id)) {
    $location[] = array(cw_get_langvar_by_name('lbl_acc_manager'), '');
    $location[] = array(cw_get_langvar_by_name('lbl_register'), '');
    $smarty->assign('main', 'acc_manager');
} else {
<?php

global $smarty;
if ($mode == "delete_from_stop_list" && is_numeric($review_id)) {
    cw_review_delete_from_stop_list($review_id);
    $stop_list = cw_review_get_stop_list();
    $smarty->assign('stop_list', $stop_list);
    cw_add_ajax_block(array('id' => 'estore_container_id', 'action' => 'update', 'template' => 'addons/estore_products_review/admin_stop_list_item.tpl'));
} else {
    $stop_list = cw_review_get_stop_list();
    $smarty->assign('stop_list', $stop_list);
    $smarty->assign('current_section_dir', 'main');
    $smarty->assign('main', 'estore_stop_list');
}
<?php

cw_load('map');
$name = $_GET['name'];
$country = $_GET['country'];
$state = $_GET['state'];
include_once $app_main_dir . '/include/templater/plugins/modifier.id.php';
$name = str_ends_with($name, '[country]') ? substr($name, 0, strlen($name) - 9) : $name;
if (empty($country)) {
    $country = $config['General']['default_country'];
}
$countries = cw_call('cw_map_get_countries', array($name));
$smarty->assign('countries', $countries);
$smarty->assign('name', $name . '[country]');
$smarty->assign('default', $country);
cw_add_ajax_block(array('id' => smarty_modifier_id($name) . 'country', 'action' => 'replace', 'content' => cw_display('main/map/_countries.tpl', $smarty, false)));
$states = cw_map_get_states($country);
$smarty->assign('states', $states);
$smarty->assign('name', $name . '[state]');
$smarty->assign('default', $state);
cw_add_ajax_block(array('id' => smarty_modifier_id($name) . 'state', 'action' => 'replace', 'content' => cw_display('main/map/_states.tpl', $smarty, false)));
        $address = cw_user_get_address($user, $address_id);
    }
    $smarty->assign('address', $address);
    $smarty->assign('address_id', $address_id);
    //    $smarty->assign('is_main', $is_main);
    $smarty->assign('name_prefix', 'update_fields[address][' . (in_array($address_type, array('main', 'current'), true) ? $address_type : $address_id) . ']');
    cw_add_ajax_block(array('id' => in_array($address_type, array('main', 'current'), true) ? $address_type . '_address' : 'address', 'action' => 'update', 'template' => 'main/users/sections/address_modify.tpl'), $address_type . '_address');
}
if ($action == 'set_main' || $action == 'set_current') {
    $field = $action == 'set_main' ? 'main' : 'current';
    Customer\Address\setAddressType($user, $field, $address_id);
    cw_user_check_addresses($user);
    // For correct shipping cost calculate after address changing
    cw_load('user');
    $user_address =& cw_session_register('user_address');
    $user_address = array();
    global $userinfo;
    $userinfo['current_address'] = cw_user_get_address_by_type('current');
    cw_add_top_message('Address has been updated');
}
$smarty->assign('address_type', $address_type);
$smarty->assign('user', $user);
if (defined('IS_AJAX')) {
    if ($user) {
        $addresses = cw_user_get_addresses(intval($user));
    }
    $smarty->assign('addresses', $addresses);
    cw_add_ajax_block(array('id' => 'address_book', 'action' => 'replace', 'template' => 'main/users/address_book.tpl'), 'address_book');
} else {
    cw_header_location("index.php?target={$target}&user={$user}");
}
    }
    $smarty->assign('navigation', $navigation);
    $get_count = FALSE;
    $limit = " LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}";
    $url_list = cw_clean_url_get_clean_urls_list_data($get_count, $where, $orderby, $limit);
    $smarty->assign('clean_urls_list', $url_list);
    $smarty->assign('clean_urls_data', $clean_urls_data);
}
if (defined('IS_AJAX')) {
    cw_load('ajax');
    $template = "list_list.tpl";
    $ajax_id = "contents_clean_urls_list";
    if ($mode == "history") {
        // for history list tab
        $template = "list_history_list.tpl";
        $ajax_id = "contents_history_clean_urls_list";
    }
    cw_add_ajax_block(array('id' => $ajax_id, 'action' => 'update', 'template' => 'addons/clean_urls/' . $template));
} else {
    if (!empty($top_message)) {
        $smarty->assign('top_message', $top_message);
        $top_message = array();
    }
    $smarty->assign('h_sort_field', "");
    $smarty->assign('h_sort_direction', 0);
    $orderby = "ORDER BY h.ctime";
    $clean_urls_history_list = cw_clean_url_get_clean_urls_history_list_data($orderby);
    $smarty->assign('clean_urls_history_list', $clean_urls_history_list);
    $location[] = array(cw_get_langvar_by_name('lbl_clean_urls_list'), '');
    $smarty->assign('main', 'clean_urls_list');
}
<?php

cw_load('ajax');
if (defined('IS_AJAX') && constant('IS_AJAX')) {
    global $config;
    if ($_GET['get_top_minicart']) {
        cw_add_ajax_block(array('id' => 'microcart_content', 'action' => 'update', 'template' => 'addons/ajax_add2cart/top_minicart.tpl'));
    } else {
        if ($config['Appearance']['place_where_display_minicart'] == 0) {
            // Update minicart
            cw_add_ajax_block(array('id' => 'minicart', 'action' => 'update', 'template' => 'addons/ajax_add2cart/minicart.tpl'));
        }
        cw_add_ajax_block(array('id' => 'microcart', 'action' => 'replace', 'template' => 'customer/menu/microcart.tpl'));
    }
    cw_event('on_minicart_update');
}
cw_load('addons');
if ($action == 'update' && is_array($upd_addons)) {
    db_query("update {$tables['addons']} set active='0' where status>'" . constant('ADDON_TYPE_CORE') . "'");
    foreach ($upd_addons as $addon => $val) {
        db_query("update {$tables['addons']} set active='1' where addon='{$addon}'");
    }
    $disabled = cw_query_column("select addon from {$tables['addons']} where active = 0");
    db_query("update {$tables['addons']} set active=0 where parent in ('" . implode("', '", $disabled) . "')");
    cw_header_location("index.php?target={$target}&mode=addons");
}
if ($action == 'ajax_update') {
    db_query("update {$tables['addons']} set active=abs(active-1) where addon='{$addon}' and status>'" . constant('ADDON_TYPE_CORE') . "'");
    $active = cw_query_first_cell("select active from {$tables['addons']} where addon='{$addon}'");
    cw_add_ajax_block(array('id' => 'script', 'content' => '$("#' . $addon . '").removeClass("on").removeClass("off").addClass("' . ($active == 1 ? 'on' : 'off') . '");'));
    cw_add_ajax_block(array('id' => 'script', 'content' => '$("[parent=' . $addon . ']").parent().removeClass("addon_locked")' . ($active == 1 ? '' : '.addClass("addon_locked")') . ';'));
}
$addon = $_GET['addon'];
if (!empty($addon) && $mode == 'addons') {
    # kornev, TOFIX generally this should be removed
    if (is_file($app_main_dir . '/addons/' . $addon . '/admin/settings.php')) {
        cw_include('addons/' . $addon . '/admin/settings.php');
    }
    if ($REQUEST_METHOD == 'POST') {
        cw_header_location("index.php?target={$target}&mode=addons&addon={$addon}");
    }
    $smarty->assign('addon', $addon);
    $smarty->assign('addon_name', cw_get_langvar_by_name('addon_name_' . $addon));
    $location[] = array(cw_get_langvar_by_name('lbl_addons'), 'index.php?target=' . $target);
    $location[] = array($addon, '');
    $smarty->assign('main', 'addon_settings');
<?php

cw_load('ajax', 'email', 'product', 'user');
$product_info = cw_func_call('cw_product_get', array('id' => $product_id, 'user_account' => $user_info, 'info_type' => 0));
// get oswner id
$user_owner_id = cw_query_first_cell("\n    SELECT creation_customer_id\n    FROM {$tables['products_system_info']}\n    WHERE product_id = '{$product_id}'\n");
$user_owner_email = "";
if (!empty($user_owner_id)) {
    $user_owner_info = cw_call('cw_user_get_info', array('customer_id' => $user_owner_id, 'info_type' => 0));
    $user_owner_email = $user_owner_info['email'];
}
// send notification email to product owner and admin
$from = $config['Company']['site_administrator'];
$to = !empty($config['Company']['inventory_department']) ? $config['Company']['inventory_department'] : $config['Company']['site_administrator'];
$mail_subject = "The notification about reported sold out product";
$mail_body = '<b>You have received this notification from <a href="' . $current_location . '">';
$mail_body .= $config['Company']['company_name'] . '</a></b><br />';
$mail_body .= 'A user reports that the product <a href="' . $current_location . '/index.php?target=product&product_id=';
$mail_body .= $product_id . '">' . $product_info['product'] . '</a> is sold out.<br />';
cw_send_simple_mail($from, $to, $mail_subject, $mail_body);
if (!empty($user_owner_email) && $to != $user_owner_email) {
    cw_send_simple_mail($from, $user_owner_email, $mail_subject, $mail_body);
}
cw_add_ajax_block(array('id' => 'report_about_sold', 'action' => 'update', 'content' => cw_get_langvar_by_name('lbl_reported')));