first commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
class stEservice2BackendActions extends stActions
|
||||
{
|
||||
|
||||
public function initializeParameters()
|
||||
{
|
||||
$this->config = stConfig::getInstance('stEservice2Backend');
|
||||
$this->labels = $this->getLabels();
|
||||
}
|
||||
|
||||
public function executeIndex()
|
||||
{
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$modules = PaymentTypePeer::doSelectByModuleName('stEservice2');
|
||||
|
||||
if (!$modules)
|
||||
{
|
||||
$modules = PaymentTypePeer::doSelectByModuleName('stEservice');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var PaymentType $module
|
||||
*/
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
$module->setModuleName('stEservice2');
|
||||
$module->setIsActive($this->config->get('enabled'));
|
||||
$module->save();
|
||||
}
|
||||
|
||||
if ($this->config->get('enabled'))
|
||||
{
|
||||
$config = stConfig::getInstance('stEserviceBackend');
|
||||
$config->set('enabled', false);
|
||||
$config->save();
|
||||
}
|
||||
|
||||
$this->config->save();
|
||||
|
||||
$this->setFlash('notice', $this->getContext()->getI18n()->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
||||
|
||||
return $this->redirect($this->getRequest()->getReferer());
|
||||
}
|
||||
|
||||
if ($this->config->get('enabled')!=1) {
|
||||
$this->setFlash('info', '<a target="_parent" href="https://www.eservice.pl/kontakt?branza=eCommerce?utm_source=&utm_medium=Sote">'.$this->getContext()->getI18n()->__('Zarejestruj się w eService, aby utworzyć konto.').'</a>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function validateIndex()
|
||||
{
|
||||
$this->initializeParameters();
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$this->config->setFromRequest('config');
|
||||
|
||||
$api = new stEservice2();
|
||||
|
||||
if (!$this->config->get('enabled'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (['client_id', 'password'] as $field)
|
||||
{
|
||||
if (empty($this->config->get($field)))
|
||||
{
|
||||
$this->getRequest()->setError('config{'.$field.'}', $i18n->__('Proszę uzupełnić pole.'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->getRequest()->hasErrors() && !$api->validatePaymentConfiguration())
|
||||
{
|
||||
$this->getRequest()->setError('api', $i18n->__('Wystąpił błąd podczas weryfikacji danych dostępowych. Sprawdź czy podane dane są prawidłowe.'));
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->getRequest()->hasErrors();
|
||||
}
|
||||
|
||||
public function handleErrorIndex()
|
||||
{
|
||||
$this->initializeParameters();
|
||||
|
||||
return sfView::SUCCESS;
|
||||
}
|
||||
|
||||
protected function getLabels()
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
|
||||
return array(
|
||||
'api' => 'eService',
|
||||
'config{client_id}' => $i18n->__('Identyfikator sprzedawcy'),
|
||||
'config{password}' => $i18n->__('Hasło')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class stEservice2BackendComponents extends sfComponents
|
||||
{
|
||||
|
||||
public function executeListMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="list-menu">
|
||||
<ul>
|
||||
|
||||
<li class="selected">
|
||||
<?php echo link_to(__('eService'),'stEservice2Backend/index')?>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
|
||||
<a href="https://www.sote.pl/docs/eservice" target="_blank"><?php echo __('Dokumentacja'); ?></a>
|
||||
<?php else: ?>
|
||||
<a href="https://www.soteshop.com/docs/eservice" target="_blank"><?php echo __('Documentation'); ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="clr"></div>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php use_helper('I18N', 'stAdminGenerator', 'Validation') ?>
|
||||
<?php echo st_get_admin_head('stEservice2Plugin', __('eService - Nowe API'), array('culture' => null), array('stPayment')) ?>
|
||||
|
||||
<?php st_view_slot_start('application-menu') ?>
|
||||
<?php st_include_component('stEservice2Backend', 'listMenu') ?>
|
||||
<?php st_view_slot_end() ?>
|
||||
|
||||
<?php st_include_partial('stAdminGenerator/message', array('labels' => $labels, 'i18n_catalogue' => 'stEservice2Backend')); ?>
|
||||
|
||||
<?php echo form_tag('@stEservice2Plugin?action=index', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form', 'class' => 'admin_form'));?>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php echo st_admin_get_form_field('config[enabled]', __('Włącz'), 1, 'checkbox_tag', array('checked' => $config->get('enabled'))) ?>
|
||||
<?php echo st_admin_get_form_field('config[autoredirect]', __('Automatyczne przekierowanie', null, 'stPayment'), 1, 'checkbox_tag', array('checked' => $config->get('autoredirect'), 'help' => __('Przekieruj automatycznie na stronę płatności po złożeniu zamówienia', null, 'stPayment'))) ?>
|
||||
<?php echo st_admin_get_form_field('config[test]', __('Tryb testowy'), 1, 'checkbox_tag', array('checked' => $config->get('test'))) ?>
|
||||
<?php echo st_admin_get_form_field('config[client_id]', __('Identyfikator sprzedawcy'), $config->get('client_id'), 'input_tag', array('required' => true)) ?>
|
||||
<?php echo st_admin_get_form_field('config[password]', __('Hasło'), $config->get('password'), 'input_password_tag', array('required' => true, 'autocomplete' => 'new-password')) ?>
|
||||
<?php echo st_admin_get_form_field('config[brand_id]', __('Identyfikator marki'), $config->get('brand_id'), 'input_tag', array('required' => false)) ?>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"') ?>
|
||||
<?php echo st_get_admin_action('save', __('Zapisz', array(), 'stAdminGeneratorPlugin'), null, array('name' => 'save')) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
</form>
|
||||
|
||||
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
Reference in New Issue
Block a user