<?php 
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Обработчик добавления/редактирования компании.
 * 
 * Файл: /admin/shop/action/add_company.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */
$param = array();
$shop = & singleton('shop');

/* Проверяем существует ли идентификатор */
if (isset($_REQUEST['shop_company_id']))
{
	$param['shop_company_id'] = to_int($_REQUEST['shop_company_id']);
}

/* Устанавливаем параметры */
$param['shop_company_name'] = to_str($_REQUEST['shop_company_name']);
$param['shop_company_description'] = to_str($_REQUEST['shop_company_description']);
$param['shop_company_inn'] = to_str($_REQUEST['shop_company_inn']);
$param['shop_company_kpp'] = to_str($_REQUEST['shop_company_kpp']);
$param['shop_company_ogrn'] = to_str($_REQUEST['shop_company_ogrn']);
$param['shop_company_okpo'] = to_str($_REQUEST['shop_company_okpo']);
$param['shop_company_okved'] = to_str($_REQUEST['shop_company_okved']);
$param['shop_company_bik'] = to_str($_REQUEST['shop_company_bik']);
$param['shop_company_account'] = to_str($_REQUEST['shop_company_account']);
$param['shop_company_corr_account'] = to_str($_REQUEST['shop_company_corr_account']);
$param['shop_company_bank_name'] = to_str($_REQUEST['shop_company_bank_name']);
$param['shop_company_bank_address'] = to_str($_REQUEST['shop_company_bank_address']);
$param['shop_company_fio'] = to_str($_REQUEST['shop_company_fio']);
$param['shop_company_accountant_fio'] = to_str($_REQUEST['shop_company_accountant_fio']);
$param['shop_company_address'] = to_str($_REQUEST['shop_company_address']);
$param['shop_company_phone'] = to_str($_REQUEST['shop_company_phone']);
$param['shop_company_fax'] = to_str($_REQUEST['shop_company_fax']);
$param['shop_company_site'] = to_str($_REQUEST['shop_company_site']);
$param['shop_company_email'] = to_str($_REQUEST['shop_company_email']);
$param['shop_company_guid'] = to_str($_REQUEST['shop_company_guid']);

if ($company = $shop->InsertCompany($param))
{
	$admin_forms = new admin_forms();
	$window_id = $admin_forms->GetWindowId();
	?><script type="text/javascript">
	$.appendInput('<?php echo $window_id?>', 'EditAddCompany', 'shop_company_id', '<?php echo $company?>');
	</script><?php

	if (isset($_REQUEST['shop_company_id'])) 
	{
		show_message($GLOBALS['MSG_shops']['company_edit_success']);
	}
	else 
	{
		show_message($GLOBALS['MSG_shops']['company_insert_success']);
	}
}
else
{
	if (isset($_REQUEST['shop_company_id'])) 
	{
		show_error_message($GLOBALS['MSG_shops']['company_edit_error']);
	}
	else 
	{
		show_error_message($GLOBALS['MSG_shops']['company_insert_error']);
	}
}
?>