Commit c8fd5491 authored by Яков's avatar Яков
Browse files

two

parent 48680c56
<?php <?php
/** /**
* offerTranslation filter form. * OfferTranslation filter form.
* *
* @package sf * @package sf
* @subpackage filter * @subpackage filter
* @author Atma * @author Atma
* @version SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ * @version SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/ */
class offerTranslationFormFilter extends BaseofferTranslationFormFilter class OfferTranslationFormFilter extends BaseOfferTranslationFormFilter
{ {
public function configure() public function configure()
{ {
......
<?php
/**
* Discount form.
*
* @package sf
* @subpackage form
* @author Atma
* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class DiscountForm extends BaseDiscountForm
{
public function configure()
{
$this->useFields(array('title', 'utm', 'comment', 'url'));
}
}
<?php
/**
* DiscountPhone form.
*
* @package sf
* @subpackage form
* @author Atma
* @version SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class DiscountPhoneForm extends BaseDiscountPhoneForm
{
public function configure()
{
$this->useFields(array('phone', 'discount_id', 'order_id'));
}
public function isValid()
{
$is_valid = parent::isValid();
if ($is_valid) {
$dp = Doctrine_Query::create()
->from("DiscountPhone dp")
->where("dp.phone = ?", $this->getValue('phone'))
->andWhere("dp.id != ?", $this->getValue('id'))
->andWhere("dp.order_id is null")
->count();
if($dp > 0) {
$is_valid = false;
$this->getErrorSchema()->addError(new sfValidatorError($this->getValidator('phone'), 'Пользователь уже добавил скидку'), 'phone');
}
}
return $is_valid;
}
}
...@@ -13,7 +13,7 @@ class OfferForm extends BaseOfferForm ...@@ -13,7 +13,7 @@ class OfferForm extends BaseOfferForm
public function configure() public function configure()
{ {
$this->embedI18n(array('ru', 'en')); $this->embedI18n(array('ru', 'en'));
$this->useFields(array('ru', 'en', 'quantity_type_select', 'price', 'sort', 'discount_available', 'img', 'product_id')); $this->useFields(array('ru', 'en', 'quantity_type_select', 'price', 'sort', 'is_wholesale', 'img', 'product_id'));
$parentId = sfContext::getInstance()->getRequest()->getParameter('parentId'); $parentId = sfContext::getInstance()->getRequest()->getParameter('parentId');
if($parentId){ if($parentId){
...@@ -22,7 +22,7 @@ class OfferForm extends BaseOfferForm ...@@ -22,7 +22,7 @@ class OfferForm extends BaseOfferForm
$this->setDefault('product_id', $parentId); $this->setDefault('product_id', $parentId);
} }
} }
$this->widgetSchema['discount_available'] = new sfWidgetFormInputCheckbox(array('label' => 'Доступен со скидкой?'), array("required" => true)); $this->widgetSchema['is_wholesale'] = new sfWidgetFormInputCheckbox(array('label' => 'Чужой товар'), array("required" => true));
$this->widgetSchema['product_id'] = new sfWidgetFormInputHidden(); $this->widgetSchema['product_id'] = new sfWidgetFormInputHidden();
$this->widgetSchema['ru']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255, "required" => true)); $this->widgetSchema['ru']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255, "required" => true));
$this->widgetSchema['en']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255, "required" => true)); $this->widgetSchema['en']['title'] = new sfWidgetFormInputText(array("label" => "Название"), array("size" => 64, "maxlength" => 255, "required" => true));
......
<?php
/**
* Discount form base class.
*
* @method Discount getObject() Returns the current form's model object
*
* @package sf
* @subpackage form
* @author Atma
* @version SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
*/
abstract class BaseDiscountForm extends BaseFormDoctrine
{
public function setup()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(array(), array()),
'title' => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255, "required" => true)),
'utm' => new sfWidgetFormInputText(array(), array("size" => 64, "maxlength" => 255, "required" => true)),
'comment' => new sfWidgetFormTextarea(array(), array("rows" => 5, "cols" => 70)),
'url' => new sfWidgetFormInputText(array(), array("size" => 20, "maxlength" => 20)),
'created_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
'updated_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
));
$this->setValidators(array(
'id' => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
'title' => new sfValidatorString(array('max_length' => 255)),
'utm' => new sfValidatorString(array('max_length' => 255)),
'comment' => new sfValidatorString(array('max_length' => 1000, 'required' => false)),
'url' => new sfValidatorString(array('max_length' => 20, 'required' => false)),
'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(),
));
$this->widgetSchema->setNameFormat('discount[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
public function getModelName()
{
return 'Discount';
}
}
<?php
/**
* DiscountPhone form base class.
*
* @method DiscountPhone getObject() Returns the current form's model object
*
* @package sf
* @subpackage form
* @author Atma
* @version SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
*/
abstract class BaseDiscountPhoneForm extends BaseFormDoctrine
{
public function setup()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(array(), array()),
'phone' => new sfWidgetFormInputText(array(), array("size" => 20, "maxlength" => 20, "required" => true)),
'discount_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Discount'), 'add_empty' => false), array("required" => true)),
'order_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BasketOrder'), 'add_empty' => true), array()),
'active_discount' => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8, "required" => true)),
'created_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
'updated_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
));
$this->setValidators(array(
'id' => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
'phone' => new sfValidatorString(array('max_length' => 20)),
'discount_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Discount'))),
'order_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BasketOrder'), 'required' => false)),
'active_discount' => new sfValidatorInteger(array('required' => false)),
'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(),
));
$this->widgetSchema->setNameFormat('discount_phone[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setupInheritance();
parent::setup();
}
public function getModelName()
{
return 'DiscountPhone';
}
}
...@@ -24,7 +24,6 @@ abstract class BaseOfferForm extends BaseFormDoctrine ...@@ -24,7 +24,6 @@ abstract class BaseOfferForm extends BaseFormDoctrine
'is_delete' => new sfWidgetFormInputCheckbox(array(), array("required" => true)), 'is_delete' => new sfWidgetFormInputCheckbox(array(), array("required" => true)),
'is_wholesale' => new sfWidgetFormInputCheckbox(array(), array("required" => true)), 'is_wholesale' => new sfWidgetFormInputCheckbox(array(), array("required" => true)),
'sort' => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8)), 'sort' => new sfWidgetFormInputText(array(), array("size" => 8, "maxlength" => 8)),
'discount_available' => new sfWidgetFormInputCheckbox(array(), array()),
'created_at' => new sfWidgetFormDateTime(array(), array("required" => true)), 'created_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
'updated_at' => new sfWidgetFormDateTime(array(), array("required" => true)), 'updated_at' => new sfWidgetFormDateTime(array(), array("required" => true)),
)); ));
...@@ -39,7 +38,6 @@ abstract class BaseOfferForm extends BaseFormDoctrine ...@@ -39,7 +38,6 @@ abstract class BaseOfferForm extends BaseFormDoctrine
'is_delete' => new sfValidatorBoolean(array('required' => false)), 'is_delete' => new sfValidatorBoolean(array('required' => false)),
'is_wholesale' => new sfValidatorBoolean(array('required' => false)), 'is_wholesale' => new sfValidatorBoolean(array('required' => false)),
'sort' => new sfValidatorInteger(array('required' => false)), 'sort' => new sfValidatorInteger(array('required' => false)),
'discount_available' => new sfValidatorBoolean(array('required' => false)),
'created_at' => new sfValidatorDateTime(), 'created_at' => new sfValidatorDateTime(),
'updated_at' => new sfValidatorDateTime(), 'updated_at' => new sfValidatorDateTime(),
)); ));
......
...@@ -22,6 +22,9 @@ class wwwBasketOrderForm extends BaseBasketOrderForm ...@@ -22,6 +22,9 @@ class wwwBasketOrderForm extends BaseBasketOrderForm
$this->validatorSchema['delivery_type'] = new sfValidatorChoice(array('choices' => array(0 => 'Самовывоз', 1 => 'Доставка по адресу'), 'required' => true)); $this->validatorSchema['delivery_type'] = new sfValidatorChoice(array('choices' => array(0 => 'Самовывоз', 1 => 'Доставка по адресу'), 'required' => true));
$this->validatorSchema['phone'] = new sfValidatorString(array('max_length' => 24, 'required' => true)); $this->validatorSchema['phone'] = new sfValidatorAnd(array(
new sfValidatorNumber(array('required' => true)),
new sfValidatorString(array('max_length' => 24, 'required' => true))
));
} }
} }
<?php
/**
* Discount
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package sf
* @subpackage model
* @author Atma
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
class Discount extends BaseDiscount
{
public function save(Doctrine_Connection $conn = null) {
$save = parent::save($conn);
if ($this->getUrl() == '') {
$rand = Page::generate_rand_string(20);
$this->setUrl($rand);
}
return parent::save($conn);
}
}
<?php
/**
* DiscountPhone
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @package sf
* @subpackage model
* @author Atma
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
class DiscountPhone extends BaseDiscountPhone
{
}
<?php
class DiscountPhoneTable extends Doctrine_Table
{
public static function getInstance()
{
return Doctrine_Core::getTable('DiscountPhone');
}
}
\ No newline at end of file
<?php
class DiscountTable extends Doctrine_Table
{
public static function getInstance()
{
return Doctrine_Core::getTable('Discount');
}
}
\ No newline at end of file
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* @property boolean $is_confirm_admin * @property boolean $is_confirm_admin
* @property boolean $is_payed * @property boolean $is_payed
* @property boolean $is_given * @property boolean $is_given
* @property DiscountPhone $DiscountPhone
* @property Doctrine_Collection $Basket * @property Doctrine_Collection $Basket
* *
* @method string getUsername() Returns the current record's "username" value * @method string getUsername() Returns the current record's "username" value
...@@ -32,7 +31,6 @@ ...@@ -32,7 +31,6 @@
* @method boolean getIsConfirmAdmin() Returns the current record's "is_confirm_admin" value * @method boolean getIsConfirmAdmin() Returns the current record's "is_confirm_admin" value
* @method boolean getIsPayed() Returns the current record's "is_payed" value * @method boolean getIsPayed() Returns the current record's "is_payed" value
* @method boolean getIsGiven() Returns the current record's "is_given" value * @method boolean getIsGiven() Returns the current record's "is_given" value
* @method DiscountPhone getDiscountPhone() Returns the current record's "DiscountPhone" value
* @method Doctrine_Collection getBasket() Returns the current record's "Basket" collection * @method Doctrine_Collection getBasket() Returns the current record's "Basket" collection
* @method BasketOrder setUsername() Sets the current record's "username" value * @method BasketOrder setUsername() Sets the current record's "username" value
* @method BasketOrder setPhone() Sets the current record's "phone" value * @method BasketOrder setPhone() Sets the current record's "phone" value
...@@ -46,7 +44,6 @@ ...@@ -46,7 +44,6 @@
* @method BasketOrder setIsConfirmAdmin() Sets the current record's "is_confirm_admin" value * @method BasketOrder setIsConfirmAdmin() Sets the current record's "is_confirm_admin" value
* @method BasketOrder setIsPayed() Sets the current record's "is_payed" value * @method BasketOrder setIsPayed() Sets the current record's "is_payed" value
* @method BasketOrder setIsGiven() Sets the current record's "is_given" value * @method BasketOrder setIsGiven() Sets the current record's "is_given" value
* @method BasketOrder setDiscountPhone() Sets the current record's "DiscountPhone" value
* @method BasketOrder setBasket() Sets the current record's "Basket" collection * @method BasketOrder setBasket() Sets the current record's "Basket" collection
* *
* @package sf * @package sf
...@@ -129,11 +126,6 @@ abstract class BaseBasketOrder extends sfDoctrineRecord ...@@ -129,11 +126,6 @@ abstract class BaseBasketOrder extends sfDoctrineRecord
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->hasOne('DiscountPhone', array(
'local' => 'id',
'foreign' => 'order_id',
'onDelete' => 'SET NULL'));
$this->hasMany('Basket', array( $this->hasMany('Basket', array(
'local' => 'id', 'local' => 'id',
'foreign' => 'basket_order_id')); 'foreign' => 'basket_order_id'));
......
<?php
/**
* BaseDiscount
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property string $title
* @property string $utm
* @property string $comment
* @property string $url
* @property Doctrine_Collection $DiscountPhone
*
* @method string getTitle() Returns the current record's "title" value
* @method string getUtm() Returns the current record's "utm" value
* @method string getComment() Returns the current record's "comment" value
* @method string getUrl() Returns the current record's "url" value
* @method Doctrine_Collection getDiscountPhone() Returns the current record's "DiscountPhone" collection
* @method Discount setTitle() Sets the current record's "title" value
* @method Discount setUtm() Sets the current record's "utm" value
* @method Discount setComment() Sets the current record's "comment" value
* @method Discount setUrl() Sets the current record's "url" value
* @method Discount setDiscountPhone() Sets the current record's "DiscountPhone" collection
*
* @package sf
* @subpackage model
* @author Atma
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseDiscount extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('discount');
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'notnull' => true,
'length' => 255,
));
$this->hasColumn('utm', 'string', 255, array(
'type' => 'string',
'notnull' => true,
'length' => 255,
));
$this->hasColumn('comment', 'string', 1000, array(
'type' => 'string',
'notnull' => false,
'length' => 1000,
));
$this->hasColumn('url', 'string', 20, array(
'type' => 'string',
'length' => 20,
));
}
public function setUp()
{
parent::setUp();
$this->hasMany('DiscountPhone', array(
'local' => 'id',
'foreign' => 'discount_id'));
$timestampable0 = new Doctrine_Template_Timestampable();
$this->actAs($timestampable0);
}
}
\ No newline at end of file
<?php
/**
* BaseDiscountPhone
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property string $phone
* @property integer $discount_id
* @property string $order_id
* @property integer $active_discount
* @property BasketOrder $BasketOrder
* @property Discount $Discount
*
* @method string getPhone() Returns the current record's "phone" value
* @method integer getDiscountId() Returns the current record's "discount_id" value
* @method string getOrderId() Returns the current record's "order_id" value
* @method integer getActiveDiscount() Returns the current record's "active_discount" value
* @method BasketOrder getBasketOrder() Returns the current record's "BasketOrder" value
* @method Discount getDiscount() Returns the current record's "Discount" value
* @method DiscountPhone setPhone() Sets the current record's "phone" value
* @method DiscountPhone setDiscountId() Sets the current record's "discount_id" value
* @method DiscountPhone setOrderId() Sets the current record's "order_id" value
* @method DiscountPhone setActiveDiscount() Sets the current record's "active_discount" value
* @method DiscountPhone setBasketOrder() Sets the current record's "BasketOrder" value
* @method DiscountPhone setDiscount() Sets the current record's "Discount" value
*
* @package sf
* @subpackage model
* @author Atma
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class BaseDiscountPhone extends sfDoctrineRecord
{
public function setTableDefinition()
{
$this->setTableName('discount_phone');
$this->hasColumn('phone', 'string', 20, array(
'type' => 'string',
'notnull' => true,
'length' => 20,
));
$this->hasColumn('discount_id', 'integer', null, array(
'type' => 'integer',
'notnull' => true,
));
$this->hasColumn('order_id', 'string', 255, array(
'type' => 'string',
'notnull' => false,
'length' => 255,
));
$this->hasColumn('active_discount', 'integer', null, array(
'type' => 'integer',
'notnull' => true,
'default' => 3,
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('BasketOrder', array(
'local' => 'order_id',
'foreign' => 'id',
'onDelete' => 'SET NULL'));
$this->hasOne('Discount', array(
'local' => 'discount_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
$timestampable0 = new Doctrine_Template_Timestampable();
$this->actAs($timestampable0);
}
}
\ No newline at end of file
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
* @property boolean $is_delete * @property boolean $is_delete
* @property boolean $is_wholesale * @property boolean $is_wholesale
* @property integer $sort * @property integer $sort
* @property boolean $discount_available
* @property Product $Product * @property Product $Product
* @property Doctrine_Collection $BasketOffer * @property Doctrine_Collection $BasketOffer
* *
...@@ -29,7 +28,6 @@ ...@@ -29,7 +28,6 @@
* @method boolean getIsDelete() Returns the current record's "is_delete" value * @method boolean getIsDelete() Returns the current record's "is_delete" value
* @method boolean getIsWholesale() Returns the current record's "is_wholesale" value * @method boolean getIsWholesale() Returns the current record's "is_wholesale" value
* @method integer getSort() Returns the current record's "sort" value * @method integer getSort() Returns the current record's "sort" value
* @method boolean getDiscountAvailable() Returns the current record's "discount_available" value
* @method Product getProduct() Returns the current record's "Product" value * @method Product getProduct() Returns the current record's "Product" value
* @method Doctrine_Collection getBasketOffer() Returns the current record's "BasketOffer" collection * @method Doctrine_Collection getBasketOffer() Returns the current record's "BasketOffer" collection
* @method Offer setInnerId() Sets the current record's "inner_id" value * @method Offer setInnerId() Sets the current record's "inner_id" value
...@@ -42,7 +40,6 @@ ...@@ -42,7 +40,6 @@
* @method Offer setIsDelete() Sets the current record's "is_delete" value * @method Offer setIsDelete() Sets the current record's "is_delete" value
* @method Offer setIsWholesale() Sets the current record's "is_wholesale" value * @method Offer setIsWholesale() Sets the current record's "is_wholesale" value
* @method Offer setSort() Sets the current record's "sort" value * @method Offer setSort() Sets the current record's "sort" value
* @method Offer setDiscountAvailable() Sets the current record's "discount_available" value
* @method Offer setProduct() Sets the current record's "Product" value * @method Offer setProduct() Sets the current record's "Product" value
* @method Offer setBasketOffer() Sets the current record's "BasketOffer" collection * @method Offer setBasketOffer() Sets the current record's "BasketOffer" collection
* *
...@@ -103,10 +100,6 @@ abstract class BaseOffer extends sfDoctrineRecord ...@@ -103,10 +100,6 @@ abstract class BaseOffer extends sfDoctrineRecord
'type' => 'integer', 'type' => 'integer',
'default' => 0, 'default' => 0,
)); ));
$this->hasColumn('discount_available', 'boolean', null, array(
'type' => 'boolean',
'default' => false,
));
} }
public function setUp() public function setUp()
......
...@@ -222,7 +222,6 @@ class exchangeDeleteimageTask extends sfBaseTask ...@@ -222,7 +222,6 @@ class exchangeDeleteimageTask extends sfBaseTask
} }
$error = array(); $error = array();
$countDel = 0; $countDel = 0;
if (count($allImageInDir) > 0 ) {
foreach ($allImageInDir as $item) { foreach ($allImageInDir as $item) {
if (file_exists($item)) { if (file_exists($item)) {
chmod($item, 0777); chmod($item, 0777);
...@@ -232,8 +231,6 @@ class exchangeDeleteimageTask extends sfBaseTask ...@@ -232,8 +231,6 @@ class exchangeDeleteimageTask extends sfBaseTask
$error[] = 'file not found:' . $item; $error[] = 'file not found:' . $item;
} }
} }
}
print_r($allImageInDir); print_r($allImageInDir);
$this->log('Count delete image: ' . $countDel); $this->log('Count delete image: ' . $countDel);
......
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
get('/discount/index')->
with('request')->begin()->
isParameter('module', 'discount')->
isParameter('action', 'index')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '!/This is a temporary page/')->
end()
;
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
get('/discount_phone/index')->
with('request')->begin()->
isParameter('module', 'discount_phone')->
isParameter('action', 'index')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '!/This is a temporary page/')->
end()
;
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
get('/discount/index')->
with('request')->begin()->
isParameter('module', 'discount')->
isParameter('action', 'index')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '!/This is a temporary page/')->
end()
;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment