<?php
/**
 * Система управления сайтом HostCMS v. 5.xx
 * Copyright © 2005-2010 ООО "Хостмэйк" (Hostmake LLC), http://www.hostcms.ru
 *
 * Форма добаления/редактирования валют.
 * 
 * Файл: /admin/shop/action/form_edit_add_currency.php
 * 
 * @author Hostmake LLC
 * @version 5.x
 */ 
if (isset($id)) 
{
	$edit_currency = to_int($id);
}
else 
{
	$edit_currency = 0;
}

$form_params = array();
$form_params['title'] = $edit_currency==0?$GLOBALS['MSG_shops']['currency_add_form_title']:$GLOBALS['MSG_shops']['currency_edit_form_title'];
$form_params['form_attribs']['method'] = 'post';
$form_params['form_attribs']['action'] = '/admin/shop/shop.php';
$form_params['form_attribs']['name'] = 'EditAddCurrency';
$shop = & singleton('shop');

$admin_forms_fields = new admin_forms_fields();

$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', '', 54, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', '', 54, 'load_data'),
'name' => $GLOBALS['MSG_shops']['header_admin__list_forms']);

$new_path_array[] = array(
'link' => $admin_forms_fields->GetHtmlCallDoLoadAjax('/admin/shop/shop.php', '', 56, 'load_data'),
'onclick' => $admin_forms_fields->GetOnClickCallDoLoadAjax('/admin/shop/shop.php', '', 56, 'load_data'),
'name' => $GLOBALS['MSG_shops']['currency_add_form_link']);

// Передаем в массив для констурктора хлебные крошки
$form_params['path_array'] = $new_path_array;

$admin_forms_fields->admin_forms_fields($form_params);

$DataBase = & singleton('DataBase');

// Редактировние налога
if ($edit_currency)
{
	$type = 1;

	$result = $shop->GetCurrency($edit_currency);

	$shop_currency_name = $result['shop_currency_name'];
	
	$shop_currency_international_name = $result['shop_currency_international_name'];
	
	$shop_currency_value_in_basic_currency = $result['shop_currency_value_in_basic_currency'];
	
	$shop_currency_is_default = $result['shop_currency_is_default'];
	$shop_currency_order = $result['shop_currency_order'];
}
// Добавление налога
else
{
	$shop_currency_name = '';
	
	$shop_currency_international_name = '';
	
	$shop_currency_value_in_basic_currency = '';
	
	$shop_currency_is_default = 0;
	$shop_currency_order = 0;
}


// Параметры.
$tab_id = $admin_forms_fields->AddTab($GLOBALS['MSG_shops']['tab']);

// Имя валюты
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'currency_name';
$param['caption'] = $GLOBALS['MSG_shops']['currency_add_form_name'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $shop_currency_name;
$param['attributes']['class'] = 'large';
$param['attributes']['style'] = 'width: 300px;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Ставка
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'currency_value_in_basic_currency';
$param['caption'] = $GLOBALS['MSG_shops']['currency_add_form_value_in_basic_currency'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $shop_currency_value_in_basic_currency;
$param['attributes']['style'] = 'width: 300px;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Интернациональное название валюты
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'currency_international_name';
$param['caption'] = $GLOBALS['MSG_shops']['currency_add_form_international_name'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $shop_currency_international_name;
$param['attributes']['style'] = 'width: 300px;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Порядок сортировки
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'shop_currency_order';
$param['caption'] = $GLOBALS['MSG_shops']['currency_order'];
$param['type'] = 0; // Поле ввода.
$param['value'] = $shop_currency_order;
$param['attributes']['style'] = 'width: 300px;';
$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// Входит в цену
$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'currency_is_default';
$param['caption'] = $GLOBALS['MSG_shops']['currency_is_default'];
$param['type'] = 1; // checkbox
$param['value'] = $shop_currency_is_default;

$admin_forms_fields->AddField($param);

// Разделитель.
$admin_forms_fields->AddSeparator($tab_id);

// передеам скрытое поле с идентификатором адреса если он есть
if ($edit_currency)
{
	$param = array();
	$param['tab_id'] = $tab_id;
	$param['name'] = 'edit_currency';
	$param['caption'] = '';
	$param['type'] = 4; // hidden.
	$param['value'] = $edit_currency;
	$admin_forms_fields->AddField($param);
}

$param = array();
$param['tab_id'] = $tab_id;
$param['name'] = 'action';
$param['caption'] = '';
$param['type'] = 4; // hidden.
$param['value'] = 'show_currency';
$admin_forms_fields->AddField($param);

// Кнопка "Сохранить".
$param = array();
$param['name'] = 'save_currency';
$param['caption'] = $GLOBALS['MSG_shops']['save'];
$param['attributes']['onclick'] = "return SendForm('{$admin_forms_fields->GetWindowId()}', '{$admin_forms_fields->AAction}', '{$admin_forms_fields->AAdditionalParams}', this, ".to_int($_REQUEST['admin_forms_id']).", 'load_data', " . to_int($admin_forms_fields->form_params['current_page']) . ", " . to_int($admin_forms_fields->form_params['on_page']) . " )";
$param['attributes']['type'] = 'button';
$admin_forms_fields->AddButton($param);

// Кнопка "Применить".
$param = array();
$param['name'] = 'add_currency';
$param['caption'] = $GLOBALS['MSG_shops']['apply'];
$param['image'] = '/admin/images/add.gif';
$param['attributes']['onclick'] = "return SendForm('{$admin_forms_fields->GetWindowId()}', '{$admin_forms_fields->AAction}', '{$admin_forms_fields->AAdditionalParams}', this, ".to_int($_REQUEST['admin_forms_id']).", 'load_data', " . to_int($admin_forms_fields->form_params['current_page']) . ", " . to_int($admin_forms_fields->form_params['on_page']) . " )";
$param['attributes']['type'] = 'submit';
$admin_forms_fields->AddButton($param);

// Отображение формы.
$admin_forms_fields->ShowForm();
?>