123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- /**
- * KataoOrder form base class.
- *
- * @package form
- * @subpackage katao_order
- * @version SVN: $Id: sfPropelFormGeneratedTemplate.php 15484 2009-02-13 13:13:51Z fabien $
- */
- class BaseKataoOrderForm extends BaseFormPropel
- {
- public function setup()
- {
- $this->setWidgets(array(
- 'id' => new sfWidgetFormInputHidden(),
- 'katao_supplier_id' => new sfWidgetFormPropelSelect(array('model' => 'KataoSupplier', 'add_empty' => false)),
- 'katao_period_id' => new sfWidgetFormPropelSelect(array('model' => 'KataoPeriod', 'add_empty' => false)),
- 'katao_node_id' => new sfWidgetFormPropelSelect(array('model' => 'KataoNode', 'add_empty' => false)),
- 'status' => new sfWidgetFormInput(),
- 'is_simulated' => new sfWidgetFormInput(),
- 'supplier_name' => new sfWidgetFormInput(),
- 'supplier_email' => new sfWidgetFormInput(),
- 'supplier_address1' => new sfWidgetFormInput(),
- 'supplier_address2' => new sfWidgetFormInput(),
- 'supplier_zip' => new sfWidgetFormInput(),
- 'supplier_city' => new sfWidgetFormInput(),
- 'katao_name' => new sfWidgetFormInput(),
- 'katao_address' => new sfWidgetFormTextarea(),
- 'katao_siret_number' => new sfWidgetFormInput(),
- 'katao_rcs_number' => new sfWidgetFormInput(),
- 'katao_capital' => new sfWidgetFormInput(),
- 'delivery_address' => new sfWidgetFormTextarea(),
- 'created_at' => new sfWidgetFormDateTime(),
- 'updated_at' => new sfWidgetFormDateTime(),
- 'katao_supplier_invoice_order_list' => new sfWidgetFormPropelSelectMany(array('model' => 'KataoSupplierInvoice')),
- ));
- $this->setValidators(array(
- 'id' => new sfValidatorPropelChoice(array('model' => 'KataoOrder', 'column' => 'id', 'required' => false)),
- 'katao_supplier_id' => new sfValidatorPropelChoice(array('model' => 'KataoSupplier', 'column' => 'id')),
- 'katao_period_id' => new sfValidatorPropelChoice(array('model' => 'KataoPeriod', 'column' => 'id')),
- 'katao_node_id' => new sfValidatorPropelChoice(array('model' => 'KataoNode', 'column' => 'id')),
- 'status' => new sfValidatorInteger(),
- 'is_simulated' => new sfValidatorInteger(array('required' => false)),
- 'supplier_name' => new sfValidatorString(array('max_length' => 255)),
- 'supplier_email' => new sfValidatorString(array('max_length' => 255)),
- 'supplier_address1' => new sfValidatorString(array('max_length' => 255)),
- 'supplier_address2' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
- 'supplier_zip' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
- 'supplier_city' => new sfValidatorString(array('max_length' => 255)),
- 'katao_name' => new sfValidatorString(array('max_length' => 255)),
- 'katao_address' => new sfValidatorString(array('required' => false)),
- 'katao_siret_number' => new sfValidatorString(array('max_length' => 14)),
- 'katao_rcs_number' => new sfValidatorString(array('max_length' => 255)),
- 'katao_capital' => new sfValidatorInteger(),
- 'delivery_address' => new sfValidatorString(array('required' => false)),
- 'created_at' => new sfValidatorDateTime(array('required' => false)),
- 'updated_at' => new sfValidatorDateTime(array('required' => false)),
- 'katao_supplier_invoice_order_list' => new sfValidatorPropelChoiceMany(array('model' => 'KataoSupplierInvoice', 'required' => false)),
- ));
- $this->widgetSchema->setNameFormat('katao_order[%s]');
- $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
- parent::setup();
- }
- public function getModelName()
- {
- return 'KataoOrder';
- }
- public function updateDefaultsFromObject()
- {
- parent::updateDefaultsFromObject();
- if (isset($this->widgetSchema['katao_supplier_invoice_order_list']))
- {
- $values = array();
- foreach ($this->object->getKataoSupplierInvoiceOrders() as $obj)
- {
- $values[] = $obj->getKataoSupplierInvoiceId();
- }
- $this->setDefault('katao_supplier_invoice_order_list', $values);
- }
- }
- protected function doSave($con = null)
- {
- parent::doSave($con);
- $this->saveKataoSupplierInvoiceOrderList($con);
- }
- public function saveKataoSupplierInvoiceOrderList($con = null)
- {
- if (!$this->isValid())
- {
- throw $this->getErrorSchema();
- }
- if (!isset($this->widgetSchema['katao_supplier_invoice_order_list']))
- {
- // somebody has unset this widget
- return;
- }
- if (is_null($con))
- {
- $con = $this->getConnection();
- }
- $c = new Criteria();
- $c->add(KataoSupplierInvoiceOrderPeer::KATAO_ORDER_ID, $this->object->getPrimaryKey());
- KataoSupplierInvoiceOrderPeer::doDelete($c, $con);
- $values = $this->getValue('katao_supplier_invoice_order_list');
- if (is_array($values))
- {
- foreach ($values as $value)
- {
- $obj = new KataoSupplierInvoiceOrder();
- $obj->setKataoOrderId($this->object->getPrimaryKey());
- $obj->setKataoSupplierInvoiceId($value);
- $obj->save();
- }
- }
- }
- }
|