<?php

/**
 * Offer filter form base class.
 *
 * @package    sf
 * @subpackage filter
 * @author     Atma
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseOfferFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'inner_id'             => new sfWidgetFormFilterInput(),
      'quantity_type_select' => new sfWidgetFormChoice(array('choices' => array('' => '', 'm2' => 'm2', 'sheet' => 'sheet', 'piece' => 'piece'))),
      'price'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'product_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Product'), 'add_empty' => true)),
      'img'                  => new sfWidgetFormFilterInput(),
      'is_delete'            => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'is_wholesale'         => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'sort'                 => new sfWidgetFormFilterInput(),
      'discount_available'   => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'created_at'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
    ));

    $this->setValidators(array(
      'inner_id'             => new sfValidatorPass(array('required' => false)),
      'quantity_type_select' => new sfValidatorChoice(array('required' => false, 'choices' => array('m2' => 'm2', 'sheet' => 'sheet', 'piece' => 'piece'))),
      'price'                => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'product_id'           => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Product'), 'column' => 'id')),
      'img'                  => new sfValidatorPass(array('required' => false)),
      'is_delete'            => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'is_wholesale'         => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'sort'                 => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'discount_available'   => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'created_at'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('offer_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Offer';
  }

  public function getFields()
  {
    return array(
      'id'                   => 'Number',
      'inner_id'             => 'Text',
      'quantity_type_select' => 'Enum',
      'price'                => 'Number',
      'product_id'           => 'ForeignKey',
      'img'                  => 'Text',
      'is_delete'            => 'Boolean',
      'is_wholesale'         => 'Boolean',
      'sort'                 => 'Number',
      'discount_available'   => 'Boolean',
      'created_at'           => 'Date',
      'updated_at'           => 'Date',
    );
  }
}
