167 lines
5.0 KiB
PHP
167 lines
5.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* SOTESHOP/stProductGroup
|
|
*
|
|
* Ten plik należy do aplikacji stProductGroup 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 stProductGroup
|
|
* @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 17601 2012-03-30 11:05:39Z krzysiek $
|
|
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>, Paweł Byszewski <pawel.byszewski@sote.pl>
|
|
*/
|
|
|
|
/**
|
|
* Akcje grupy produktów.
|
|
*
|
|
* @package stProductGroup
|
|
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>, Paweł Byszewski <pawel.byszewski@sote.pl>
|
|
*/
|
|
|
|
class stProductGroupActions extends autostProductGroupActions
|
|
{
|
|
protected $configGroup;
|
|
|
|
public function executeDelete()
|
|
{
|
|
ProductGroupPeer::cleanCache();
|
|
parent::executeDelete();
|
|
}
|
|
|
|
public function executeProductAddGroup()
|
|
{
|
|
try
|
|
{
|
|
parent::executeProductAddGroup();
|
|
}
|
|
catch (sfStopException $e)
|
|
{
|
|
ProductGroupPeer::cleanCache();
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
|
|
public function executeProductRemoveGroup()
|
|
{
|
|
try
|
|
{
|
|
parent::executeProductRemoveGroup();
|
|
}
|
|
catch (sfStopException $e)
|
|
{
|
|
ProductGroupPeer::cleanCache();
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
public function addProductFiltersCriteria($c)
|
|
{
|
|
parent::addProductFiltersCriteria($c);
|
|
|
|
if (isset($this->filters['list_image']) && $this->filters['list_image'] !== '')
|
|
{
|
|
$c->add(ProductPeer::OPT_IMAGE, null, $this->filters['list_image'] ? Criteria::ISNOTNULL : Criteria::ISNULL);
|
|
}
|
|
|
|
if (isset($this->filters['list_assigned']) && $this->filters['list_assigned'] !== '')
|
|
{
|
|
$c->addJoin(ProductPeer::ID, sprintf("%s AND %s = %d", ProductGroupHasProductPeer::PRODUCT_ID, ProductGroupHasProductPeer::PRODUCT_GROUP_ID, $this->forward_parameters['product_group_id']), Criteria::LEFT_JOIN);
|
|
|
|
if ($this->filters['list_assigned'])
|
|
{
|
|
$c->add(ProductGroupHasProductPeer::ID, null, Criteria::ISNOTNULL);
|
|
}
|
|
else
|
|
{
|
|
$c->add(ProductGroupHasProductPeer::ID, null, Criteria::ISNULL);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function saveConfig()
|
|
{
|
|
parent::saveConfig();
|
|
stFastCacheManager::clearCache();
|
|
}
|
|
|
|
protected function saveProductGroup($product_group)
|
|
{
|
|
if (!$this->getRequest()->hasErrors() && $this->hasRequestParameter('product_group[delete_image]'))
|
|
{
|
|
$currentFile = sfConfig::get('sf_upload_dir') . "/product_group/" . $product_group->getImage();
|
|
$product_group->setImage('');
|
|
if (is_file($currentFile))
|
|
{
|
|
unlink($currentFile);
|
|
}
|
|
}
|
|
|
|
if (!$this->getRequest()->hasErrors() && $this->hasRequestParameter('product_group[label]'))
|
|
{
|
|
$product_group->setLabel($this->getRequestParameter('product_group[label]'));
|
|
}
|
|
|
|
parent::saveProductGroup($product_group);
|
|
|
|
$this->saveProductGroupImage($product_group);
|
|
|
|
ProductGroupPeer::cleanCache();
|
|
stFastCacheManager::clearCache();
|
|
}
|
|
|
|
protected function saveProductGroupImage($product_group)
|
|
{
|
|
if ($this->getRequest()->getFileError('product_group[image]') == UPLOAD_ERR_OK)
|
|
{
|
|
$filename = $this->getRequest()->getFileName('product_group[image]');
|
|
|
|
// dodaj zdjecie
|
|
if (!$this->getRequest()->hasErrors() && $this->getRequest()->getFileSize('product_group[image]'))
|
|
{
|
|
$currentFile = sfConfig::get('sf_upload_dir') . "/product_group/" . $filename;
|
|
|
|
if (is_file($currentFile))
|
|
{
|
|
unlink($currentFile);
|
|
}
|
|
|
|
$this->getRequest()->moveFile('product_group[image]', sfConfig::get('sf_upload_dir') . "/product_group/" . $filename);
|
|
|
|
$product_group->setImage($filename);
|
|
}
|
|
|
|
$product_group->save();
|
|
}
|
|
}
|
|
|
|
public function executeFixOptProductGroup()
|
|
{
|
|
}
|
|
|
|
protected function addFiltersCriteria($c)
|
|
{
|
|
$c->add(ProductGroupPeer::FROM_BASKET_VALUE, null, Criteria::ISNULL);
|
|
|
|
parent::addFiltersCriteria($c);
|
|
}
|
|
|
|
protected function getProductGroupOrCreate($id = 'id')
|
|
{
|
|
$productGroup = parent::getProductGroupOrCreate($id);
|
|
|
|
if ($productGroup->getProductGroup() != 'NEW')
|
|
{
|
|
$this->hideField('new_type');
|
|
$this->hideField('new_product_date');
|
|
}
|
|
|
|
return $productGroup;
|
|
}
|
|
}
|