first commit
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stsoteshopPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stsoteshopPlugin opartej na licencji (Professional License 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 stsoteshopPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: actions.class.php 5661 2010-06-21 12:04:42Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stSoteshopXmlExportBackendActions
|
||||
*
|
||||
* @package stsoteshopPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stSoteshopXmlBackendActions extends autostSoteshopXmlBackendActions
|
||||
{
|
||||
public function initialize($context)
|
||||
{
|
||||
$result = parent::initialize($context);
|
||||
|
||||
$this->checkSubscriptionTypes('stSoteshopXmlPlugin', [stCommunication::SUBSCRIPTION_STANDARD, stCommunication::SUBSCRIPTION_PRO, stCommunication::SUBSCRIPTION_VIP], [
|
||||
'block_actions' => ['addAll', 'deleteAll', 'generateCustom'],
|
||||
'install_version' => '7.4.4'
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function executeProductEnable()
|
||||
{
|
||||
$ids = $this->getRequestParameter('soteshop_xml[selected]', array());
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$c = new Criteria();
|
||||
$c->add(SoteshopXmlPeer::PRODUCT_ID, $id);
|
||||
$soteshop = SoteshopXmlPeer::doSelectOne($c);
|
||||
|
||||
if (null === $soteshop) {
|
||||
$soteshop = new SoteshopXml();
|
||||
$soteshop->setProductId($id);
|
||||
}
|
||||
|
||||
$soteshop->setActive(true);
|
||||
$soteshop->save();
|
||||
}
|
||||
|
||||
return $this->redirect('stSoteshopXmlBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
public function executeProductDisable()
|
||||
{
|
||||
$ids = $this->getRequestParameter('soteshop_xml[selected]', array());
|
||||
|
||||
/**
|
||||
* @var soteshop $soteshop
|
||||
*/
|
||||
foreach (SoteshopXmlPeer::retrieveByPKs(array_values($ids)) as $soteshop){
|
||||
$soteshop->delete();
|
||||
}
|
||||
|
||||
return $this->redirect('stSoteshopXmlBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
protected function addFiltersCriteria($c)
|
||||
{
|
||||
if (isset($this->filters['code_is_empty'])) {
|
||||
$criterion = $c->getNewCriterion(ProductPeer::CODE, '');
|
||||
$criterion->addOr($c->getNewCriterion(ProductPeer::CODE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['code']) && $this->filters['code'] !== '') {
|
||||
if (method_exists($this, 'filterCriteriaByProductCode')) {
|
||||
$filter_anyway = !$this->filterCriteriaByProductCode($c, $this->filters['code']);
|
||||
} else {
|
||||
$filter_anyway = true;
|
||||
}
|
||||
|
||||
if ($filter_anyway) {
|
||||
$c->add(ProductPeer::CODE, '%' . $this->filters['code'] . '%', Criteria::LIKE);
|
||||
}
|
||||
}
|
||||
if (isset($this->filters['product_is_empty'])) {
|
||||
$criterion = $c->getNewCriterion(ProductPeer::OPT_NAME, '');
|
||||
$criterion->addOr($c->getNewCriterion(ProductPeer::OPT_NAME, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['product']) && $this->filters['product'] !== '') {
|
||||
if (method_exists($this, 'filterCriteriaByProductOptName')) {
|
||||
$filter_anyway = !$this->filterCriteriaByProductOptName($c, $this->filters['product']);
|
||||
} else {
|
||||
$filter_anyway = true;
|
||||
}
|
||||
|
||||
if ($filter_anyway) {
|
||||
$c->add(ProductPeer::OPT_NAME, '%' . $this->filters['product'] . '%', Criteria::LIKE);
|
||||
}
|
||||
}
|
||||
if (isset($this->filters['active_is_empty'])){
|
||||
$criterion = $c->getNewCriterion(SoteshopXmlPeer::ACTIVE, '');
|
||||
$criterion->addOr($c->getNewCriterion(SoteshopXmlPeer::ACTIVE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['active']) && $this->filters['active'] !== '') {
|
||||
if ($this->filters['active'] == null || $this->filters['active'] == 0){
|
||||
$criterion = $c->getNewCriterion(SoteshopXmlPeer::ACTIVE, '');
|
||||
$criterion->addOr($c->getNewCriterion(SoteshopXmlPeer::ACTIVE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
}
|
||||
|
||||
if ($this->filters['active'] == 1){
|
||||
$c->add(SoteshopXmlPeer::ACTIVE, $this->filters['active']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->filters){
|
||||
$c->add(SoteshopXmlPeer::PRODUCT_ID, 0, Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'autostSoteshopXmlBackendActions.addFiltersCriteria', array('criteria' => $c)));
|
||||
}
|
||||
|
||||
public function executeAddAll()
|
||||
{
|
||||
SoteshopXmlPeer::doDeleteAll();
|
||||
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$con->executeQuery(sprintf(
|
||||
"INSERT INTO %s(%s, %s) (SELECT %s, 1 FROM %s)",
|
||||
SoteshopXmlPeer::TABLE_NAME,
|
||||
SoteshopXmlPeer::PRODUCT_ID,
|
||||
SoteshopXmlPeer::ACTIVE,
|
||||
ProductPeer::ID,
|
||||
ProductPeer::TABLE_NAME
|
||||
));
|
||||
|
||||
return $this->redirect('stSoteshopXmlBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
public function executeDeleteAll()
|
||||
{
|
||||
SoteshopXmlPeer::doDeleteAll();
|
||||
|
||||
return $this->redirect('stSoteshopXmlBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
protected function getSoteshopXmlOrCreate($id = 'id')
|
||||
{
|
||||
$soteshop = SoteshopXmlPeer::retrieveByProduct($this->related_object);
|
||||
|
||||
if (null === $soteshop) {
|
||||
if ($this->hasRequestParameter('id')){
|
||||
return $this->redirect('@stSoteshopXmlPlugin?action=create&product_id=' . $this->related_object->getId().'&view=default');
|
||||
} else {
|
||||
$soteshop = new SoteshopXml();
|
||||
$soteshop->setProduct($this->related_object);
|
||||
}
|
||||
}
|
||||
|
||||
return $soteshop;
|
||||
}
|
||||
|
||||
public function executeGenerateCustom()
|
||||
{
|
||||
parent::executeGenerateCustom();
|
||||
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
$this->getBreadcrumbsBuilder()->getDefaultBreadcrumbs()->add($i18n->__('Generowanie pliku'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stNokautPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stNokautPlugin opartej na licencji (Professional License 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 stNokautPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: components.class.php 10 2009-08-24 09:32:18Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stSoteshopXmlExportBackendComponents
|
||||
*
|
||||
* @package stNokautPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stSoteshopXmlBackendComponents extends autostSoteshopXmlBackendComponents
|
||||
{
|
||||
/**
|
||||
* Generowanie pliku xml
|
||||
*/
|
||||
public function executeGenerateXml()
|
||||
{
|
||||
$this->generate = false;
|
||||
if ($this->getRequest()->hasParameter('generate')) $this->generate = true;
|
||||
|
||||
$stNokaut = new stSoteshopXml();
|
||||
$this->steps = $stNokaut->getStepsCount();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
generator:
|
||||
class: stAdminGenerator
|
||||
param:
|
||||
model_class: SoteshopXml
|
||||
theme: simple
|
||||
|
||||
head:
|
||||
package: stSoteshopXmlPlugin
|
||||
|
||||
|
||||
list:
|
||||
title: Lista produktów
|
||||
description: Zarządzanie porównywarką cen Nokaut
|
||||
max_per_page: 20
|
||||
display: [_code, _product, active]
|
||||
peer_method: doSelectRightJoinProduct
|
||||
peer_count_method: doCountRightJoinProduct
|
||||
actions:
|
||||
_deletes: {name: Wypisz wszystkie, action: deleteAll, icon: delete}
|
||||
_add: {name: Przypisz wszystkie, action: addAll}
|
||||
_generate: {name: Generuj plik xml z przypisanych, action: "@stSoteshopXmlPlugin?action=generateCustom&generate=1", icon: export}
|
||||
object_actions: -
|
||||
select_actions:
|
||||
display:
|
||||
"Ustaw przypisane:": [product_enabled, product_disabled]
|
||||
actions:
|
||||
product_enabled: {name: Tak, confirm: "Ustaw przypisane: Tak", action: productEnable, i18n: stSoteshopXmlBackend}
|
||||
product_disabled: {name: Nie, confirm: "Ustaw przypisane: Nie", action: productDisable, i18n: stSoteshopXmlBackend}
|
||||
filters:
|
||||
code: {filter_field: product.code}
|
||||
product: {filter_field: product.opt_name}
|
||||
fields:
|
||||
code: {name: Kod, sort_field: product.code, params: size=50}
|
||||
product: {name: Nazwa, sort_field: product.opt_name, params: size=50}
|
||||
active: {name: Przypisany}
|
||||
menu:
|
||||
display: [list, generate, config]
|
||||
fields:
|
||||
list: {name: Lista produktów, action: @stSoteshopXmlPluginDefault}
|
||||
generate: {name: Generowanie pliku, action: stSoteshopXmlBackend/generateCustom}
|
||||
config: {name: Konfiguracja, action: stSoteshopXmlBackend/config}
|
||||
object_actions:
|
||||
_edit: {action: @stSoteshopXmlPlugin?action=edit&id=%%id%%&product_id=%%product_id%%&view=default}
|
||||
create:
|
||||
title: Edycja
|
||||
|
||||
edit:
|
||||
menu: {use: list.menu}
|
||||
display: [active]
|
||||
|
||||
fields:
|
||||
active: {name: Przypisany}
|
||||
actions:
|
||||
_list: {name: Lista}
|
||||
_save: {name: Zapisz}
|
||||
forward_parameters: [product_id, view]
|
||||
build_options:
|
||||
related_id: forward_parameters.product_id
|
||||
related_class: Product
|
||||
|
||||
generate_model_class: SoteshopXml
|
||||
|
||||
custom_actions:
|
||||
custom: [generate]
|
||||
|
||||
generate_custom:
|
||||
menu: {use: list.menu}
|
||||
title: Generowanie pliku
|
||||
|
||||
config:
|
||||
title: Konfiguracja
|
||||
display:
|
||||
"Ustawienia generowania pliku xml": [none_active, none_stock, none_whoolesale]
|
||||
|
||||
fields:
|
||||
none_active: {name: Nie eksportuj nieaktywnych produktów, checked: false, type: checkbox}
|
||||
none_stock: {name: Nie eksportuj produktów z zerowym stanem magazynowym, checked: false, type: checkbox}
|
||||
none_whoolesale: {name: Dodaj ceny hurtowe, checked: false, type: checkbox}
|
||||
|
||||
actions:
|
||||
_list: {name: Lista}
|
||||
_save: {name: Zapisz}
|
||||
menu: {use: list.menu}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class stSoteshopXmlBackendBreadcrumbsBuilder extends autoStSoteshopXmlBackendBreadcrumbsBuilder
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
if ($soteshop_xml->getProductId()): ?>
|
||||
<?php echo st_link_to($soteshop_xml->getProduct()->getCode(), 'product/edit?id='.$soteshop_xml->getProductId()); ?>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php use_helper('stProgressBar'); ?>
|
||||
|
||||
<div class="admin_form">
|
||||
<fieldset >
|
||||
|
||||
<div class="content" style="text-align: center;">
|
||||
|
||||
<?php
|
||||
if ($generate): ?>
|
||||
<div id="generateXml">
|
||||
<?php echo progress_bar('stSoteshopXmlGenerateXml', 'stSoteshopXml', 'generate', $steps); ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<?php echo __('Wciśnij przycisk "Generuj plik", aby rozpocząć proces tworzenia pliku exportu danych o produktach sklepu w formacie XML.'); ?> <br>
|
||||
<?php echo __('Może to potrwać nawet kilka minut w zależności od ilości produktów.'); ?>
|
||||
<br><br>
|
||||
|
||||
<?php echo st_get_admin_button('file', __('Generuj plik'), 'soteshopxml/generateCustom?generate=1', array ('name' => 'sample_file', 'style' => 'text-align:center;')) ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php use_helper('stAdminGenerator'); ?>
|
||||
<?php $stWebRequest = new stWebRequest(); ?>
|
||||
<br />
|
||||
<?php echo __('Plik został wygenerowany i znajduje się pod adresem:') ?>
|
||||
<br>
|
||||
|
||||
<a href="http://<?php echo $stWebRequest->getHost() ?>/uploads/soteshopxml.xml" target="_blank">
|
||||
http://<?php echo $stWebRequest->getHost() ?>/uploads/soteshopxml.xml
|
||||
<a>
|
||||
|
||||
<br><br>
|
||||
|
||||
<?php echo st_get_admin_button('file', __('Pobierz'), '/uploads/soteshopxml.xml', array('download'=>null)); ?>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
if ($soteshop_xml->getProductId()): ?>
|
||||
<?php echo st_link_to($soteshop_xml->getProduct()->getName(), 'product/edit?id='.$soteshop_xml->getProductId()); ?>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user