first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<?php
/**
* SOTESHOP/stCurrencyPlugin
*
* Ten plik należy do aplikacji stCurrencyPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCurrencyPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
* @version $Id: actions.class.php 10373 2011-01-20 11:27:26Z pawel $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* stCurrencyBackend actions.
*
* @package stCurrencyPlugin
* @subpackage actions
*/
class stCurrencyBackendActions extends autostCurrencyBackendActions
{
public function validateEdit()
{
$ok = true;
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$request = $this->getRequestParameter('currency');
$config = stConfig::getInstance(null, 'stCurrencyPlugin');
if ($request['shortcut'] != $config->get('default_currency'))
{
$validator = new sfNumberValidator();
$validator->initialize($this->getContext(), array('nan_error' => 'Niepoprawny format liczbowy kursu (przykładowy format: 10, 10.1234)', 'min_error' => 'Wartość kursu musi być większa od 0', 'min' => '0.0001'));
if (!$validator->execute($request['exchange'], $error))
{
$this->getRequest()->setError('currency{exchange}', $error);
$ok = false;
}
elseif (floatval($request['exchange']) == 1)
{
$this->getRequest()->setError('currency{exchange}', 'Wartość kursu nie może być równa 1');
$ok = false;
}
}
$validator = new sfPropelUniqueValidator();
$validator->initialize($this->getContext(), array('class' => 'Currency', 'column' => 'shortcut'));
if (!$validator->execute($request['shortcut'], $error))
{
if ($request['edit_iso_code'] != '')
{
$this->getRequest()->setError('currency{edit_iso_code}', 'Wybrana waluta już istnieje...');
}
else
{
$this->getRequest()->setError('currency{shortcut}', 'Waluta z podanym kodem ISO już istnieje...');
}
$ok = false;
}
}
return $ok;
}
protected function saveConfig()
{
parent::saveConfig();
stFastCacheManager::clearCache();
}
protected function loadConfigOrCreate()
{
$config = stConfig::getInstance('stCurrencyPlugin', array('culture' => $this->getRequestParameter('culture', stLanguage::getOptLanguage())));
if ($config->isEmpty())
{
$config->set('inverse', '');
}
return $config;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/**
* SOTESHOP/stCurrencyPlugin
*
* Ten plik należy do aplikacji stCurrencyPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCurrencyPlugin
* @subpackage actions
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
* @version $Id: components.class.php 13226 2011-05-30 14:29:24Z marcin $
*/
/**
* Komponenty dla modułu stCurrencyBackend
*
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*
* @package stCurrencyPlugin
* @subpackage actions
*/
class stCurrencyBackendComponents extends autostCurrencyBackendComponents
{
public function executeEditIsoCode()
{
$this->currencies = sfConfig::get('app_stCurrencyPlugin_currency_list');
$currency_options = array();
$this->system_default = $this->currency->getConfiguration()->get('default_currency');
foreach ($this->currencies as $iso => $currency)
{
$currency_options[$iso] = $iso . ' - ' . __($currency['label']);
}
asort($currency_options);
$this->currency_options = array('' => __('Nowa waluta')) + $currency_options;
$this->selected = $this->currency->getEditIsoCode();
}
}

View File

@@ -0,0 +1,71 @@
generator:
class: stAdminGenerator
param:
model_class: Currency
theme: simple
head:
package: stCurrencyPlugin
applications: [stProduct, stOrder, stDelivery]
documentation:
pl: https://www.sote.pl/docs/waluty
en: https://www.soteshop.com/docs/currencies
list:
menu:
display: [list]
fields:
list: {name: Waluty, action: "@stCurrencyPlugin"}
filters:
name: {filter_field: currency_i18n.name}
title: Waluty
description: Zarządzanie walutami, ustalanie kursów
display: [=name, shortcut, exchange_backend, active, main]
peer_method: doSelectWithI18n
peer_count_method: doCountWithI18n
object_actions:
_edit: -
_delete: -
fields:
name: {name: Nazwa, type: input_tag, params: size=30}
shortcut: {name: Kod ISO}
exchange_backend: {name: Kurs, sort_field: currency.exchange}
active: {name: Aktywna}
main: {name: Domyślna}
actions:
_create: {name: Dodaj}
filters:
exchange_backend: {filter_field: currency.exchange}
edit:
title: Edycja waluty
description: Zarządzanie walutami, ustalanie kursów
menu:
fields:
_edit: {name: Edycja waluty}
display: [active, _edit_main, ~edit_iso_code, name, _exchange, _prefix_sign, _postfix_sign, _shortcut]
fields:
name: {name: Nazwa, params: size=28 disabled=false}
edit_iso_code: {name: Waluta}
prefix_sign: {name: Symbol przed, params: size=10}
exchange:
name: Kurs
params: size=28
postfix_sign: {name: Symbol za, params: size=10}
active: {name: Aktywna, type: checkbox_tag}
edit_main: {name: Domyślna, help: Domyślna waluta sklepu}
shortcut:
name: Kod ISO
actions:
_list: {name: Lista}
_save: {name: Zapisz}
_save_and_add: {name: Zapisz i dodaj nowy}
_delete: {name: Usuń}
config:
menu: {use: list.menu}
title: Konfiguracja
display: [inverse]
fields:
inverse: {name: Odwrotny kurs, type: checkbox, help: "Obce waluty będą przeliczane względem odwrotnego kursu."}
actions:
_save: {name: Zapisz}
create:
title: Dodaj walutę

View File

@@ -0,0 +1,2 @@
soap:
is_secure: off

View File

@@ -0,0 +1,88 @@
<?php
/**
* SOTESHOP/stWebApiPlugin
*
* Ten plik należy do aplikacji stWebApiPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stWebApiPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
* @version $Id: stModuleWebApi.class.php 16567 2011-12-21 13:38:08Z piotr $
* @author Michal Prochowski <michal.prochowski@sote.pl>
**/
define('WEBAPI_CURRENCY_INCORRECT_SHORTCUT', 'Błędny parametr SHORTCUT.');
/**
* Klasa StCurrencyBackendWebApi
*
* @package stWebApiPlugin
* @subpackage libs
**/
class stCurrencyBackendWebApi extends autoStCurrencyBackendWebApi {
/**
* Aktualizacja danych
*
* @param object $object obiekt z parametrami
* @return object obiekt z true
* @throws WEBAPI_INCORRECT_ID WEBAPI_UPDATE_ERROR WEBAPI_REQUIRE_ERROR
* @todo dodać walidacje danych
**/
public function UpdateCurrencyExchangeByShortcut($object) {
stWebApi::getLogin($object->_session_hash, 'webapi_write');
$this->TestAndValidateUpdateCurrencyExchangeByShortcutFields($object);
$c = new Criteria();
$c->add(CurrencyPeer::SHORTCUT, $object->shortcut);
$item = CurrencyPeer::doSelectOne($c);
if ($item) {
$this->setFieldsForUpdateCurrencyExchangeByShortcut($object, $item);
//Zapisywanie danych do bazy
try {
$item->save();
} catch (Exception $e) {
throw new SoapFault('2', sprintf($this->__(WEBAPI_UPDATE_ERROR), $e->getMessage()));
}
// Zwracanie danych
$object = new StdClass();
$object->_update = 1;
return $object;
} else {
throw new SoapFault('1', $this->__(WEBAPI_CURRENCY_INCORRECT_SHORTCUT));
}
}
/**
* Pobieranie danych
*
* @param object $object obiekt z parametrami
* @return object okiekt z danymi
* @throws WEBAPI_INCORRECT_ID WEBAPI_REQUIRE_ERROR
**/
public function GetCurrencyByShortcut($object) {
if (isset($object->_culture)) $this->__setCulture($object->_culture);
stWebApi::getLogin($object->_session_hash, 'webapi_read');
$this->TestAndValidateGetCurrencyByShortcutFields($object);
$c = new Criteria();
$c->add(CurrencyPeer::SHORTCUT, $object->shortcut);
$item = CurrencyPeer::doSelectOne($c);
if ($item) {
$object = new StdClass();
$this->getFieldsForGetCurrencyByShortcut($object, $item);
return $object;
} else {
throw new SoapFault('1', $this->__(WEBAPI_CURRENCY_INCORRECT_SHORTCUT));
}
}
}

View File

@@ -0,0 +1,48 @@
<?php echo input_hidden_tag('currency[edit_iso_code]', $currency->getEditIsoCode(), array('id' => 'currency_edit_iso_code_hidden')) ?>
<?php echo select_tag('currency[edit_iso_code]', options_for_select($currency_options, $selected), array('disabled' => !$currency->isNew())) ?>
<script type="text/javascript">
var currencies = <?php echo json_encode($currencies) ?>;
$('currency_edit_iso_code').observe('change', function() {
var currency_shortcut = $('currency_shortcut');
var currency_exchange = $('currency_exchange');
var currency_front_symbol = $('currency_prefix_sign');
var currency_back_symbol = $('currency_postfix_sign');
var system_default = '<?php echo $system_default ?>';
if (this.selectedIndex > 0)
{
var selected = this.options[this.selectedIndex];
var data = currencies[selected.value];
$('currency_name').value = data.label;
if (data[0] != system_default)
{
currency_exchange.enable();
}
else
{
currency_exchange.disable();
}
currency_shortcut.value = selected.value;
currency_front_symbol.value = data.prefix == undefined ? '' : data.prefix;
currency_back_symbol.value = data.postfix == undefined ? '' : data.postfix;
}
else
{
currency_exchange.enable();
}
});
</script>

View File

@@ -0,0 +1,2 @@
<?php echo input_hidden_tag('currency[edit_main]', $currency->getMain()) ?>
<?php echo st_admin_checkbox_tag('currency[edit_main]', 1, $currency->getMain(), array('disabled' => $currency->getMain())) ?>

View File

@@ -0,0 +1,6 @@
<?php
use_helper('stPrice');
echo input_hidden_tag('currency[exchange]', $currency->getExchangeBackend(), array('id' => 'currency_exchange_hidden'));
echo input_tag('currency[exchange]', $currency->getExchangeBackend(), array('disabled' => $currency->getIsSystemCurrency()));
echo st_price_add_format_behavior('currency_exchange', 4);
?>

View File

@@ -0,0 +1,12 @@
<?php if ($currency->getSystem()!=1):?>
<?php if ($sf_request->hasError('currency{name}')): ?>
<?php echo form_error('currency{name}', array('class' => 'form-error-msg')) ?>
<?php endif; ?>
<?php $value = object_input_tag($currency, 'getName', array (
'size' => 50,
'control_name' => 'currency[name]',
)); echo $value ? $value : '&nbsp;' ?>
<?php else:?>
<?php echo $currency->getName()?>
<?php echo input_hidden_tag('currency[name]', $currency->getName()) ?>
<?php endif;?>

View File

@@ -0,0 +1 @@
<?php echo input_tag('currency[postfix_sign]', $currency->getPostfixSign(), array('size' => 4)) ?>

View File

@@ -0,0 +1 @@
<?php echo input_tag('currency[prefix_sign]', $currency->getPrefixSign(), array('size' => 4)) ?>

View File

@@ -0,0 +1,4 @@
<?php echo input_tag('currency[shortcut]', $currency->getShortcut(), array('disabled' => $currency->getIsSystemCurrency() && !$currency->isNew() || !$currency->isNew(), 'size' => 4)) ?>
<?php if (!$currency->isNew()): ?>
<?php echo input_hidden_tag('currency[shortcut]', $currency->getShortcut()) ?>
<?php endif; ?>

View File

@@ -0,0 +1,12 @@
fields:
currency{name}:
required:
msg: Podaj nazwę waluty
currency{shortcut}:
required:
msg: Podaj kod ISO
sfStringValidator:
min_error: Kod ISO musi zawierać 3 znaki
max_error: Kod ISO musi zawierać 3 znaki
min: 3
max: 3