Beispiel #1
0
 /**
  * Sets the id
  * @param int|Object $arg0
  */
 function setId($arg0)
 {
     if ($this->getIdType() == self::ID_TYPE_MONGO) {
         if (is_string($arg0) && \MongoId::isValid($arg0)) {
             parent::setId(new \MongoId($arg0));
         } else {
             if ($arg0 instanceof \MongoId) {
                 parent::setId($arg0);
             } else {
                 if (is_null($arg0)) {
                     parent::setId($arg0);
                 } else {
                     if (is_string($arg0) && trim($arg0) == '') {
                         parent::setId(null);
                     } else {
                         if (is_int($arg0) && $arg0 == 0) {
                             parent::setId(null);
                         } else {
                             try {
                                 throw new \Exception('Invalid ID set: ' . var_export($arg0, true));
                             } catch (\Exception $e) {
                                 \Mojavi\Logging\LoggerManager::error(__METHOD__ . " :: " . $e->getTraceAsString());
                             }
                             parent::setId(null);
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->getIdType() == self::ID_TYPE_STRING) {
             if (is_string($arg0)) {
                 parent::setId($arg0);
             } else {
                 if ($arg0 instanceof \MongoId) {
                     parent::setId((string) $arg0);
                 } else {
                     if (is_null($arg0)) {
                         parent::setId($arg0);
                     } else {
                         if (is_string($arg0) && trim($arg0) == '') {
                             parent::setId(null);
                         } else {
                             if (is_int($arg0) && $arg0 == 0) {
                                 parent::setId(null);
                             } else {
                                 try {
                                     throw new \Exception('Invalid ID set: ' . var_export($arg0, true));
                                 } catch (\Exception $e) {
                                     \Mojavi\Logging\LoggerManager::error(__METHOD__ . " :: " . $e->getTraceAsString());
                                 }
                                 parent::setId(null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function configure()
 {
     unset($this['number'], $this['created_at'], $this['updated_at']);
     // we unset paid_amount so the system don't "nullify" the field on every invoice editing.
     unset($this['paid_amount']);
     $this->number = $this->getObject()->getNumber();
     $this->widgetSchema['issue_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['due_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['draft'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['closed']->setLabel('Force to be closed');
     $this->widgetSchema['sent_by_email']->setLabel('Sent by email');
     $this->setDefaults(array('issue_date' => time(), 'draft' => 0));
     $this->widgetSchema->setNameFormat('invoice[%s]');
     parent::configure();
 }
 public function configure()
 {
     unset($this['created_at'], $this['updated_at'], $this['occurrences'], $this['last_execution_date'], $this['desync'], $this['closed']);
     $this->widgetSchema['starting_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['finishing_date'] = new sfWidgetFormI18nJQueryDate($this->JQueryDateOptions);
     $this->widgetSchema['period'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['period_type'] = new sfWidgetFormSelect(array('choices' => RecurringInvoiceTable::$period_types));
     $this->widgetSchema['max_occurrences'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['days_to_due'] = new sfWidgetFormInputText(array(), array('size' => 3));
     $this->widgetSchema['year'] = new sfWidgetFormI18nDateDMY(array('use' => 'years', 'culture' => $this->culture, 'empty_value' => 'any'));
     $this->widgetSchema['month'] = new sfWidgetFormI18nDateDMY(array('use' => 'months', 'culture' => $this->culture, 'empty_value' => 'any'));
     $this->widgetSchema->setDefault('enabled', '0');
     $this->widgetSchema->setNameFormat("invoice[%s]");
     $this->validatorSchema['starting_date'] = new sfValidatorDate(array('required' => true));
     $this->validatorSchema['period']->setMessage('invalid', 'Invalid Period');
     $this->validatorSchema['period']->setMessage('required', 'Period required');
     $this->setValidator('period_type', new sfValidatorChoice(array('choices' => array_keys(RecurringInvoiceTable::$period_types))));
     $vd = new sfValidatorSchema(array('period_type' => $this->getValidator('period_type'), 'period' => $this->getValidator('period')));
     $this->validatorSchema->setPostValidator(new SiwappConditionalValidator(array('control_field' => 'enabled', 'validator_schema' => $vd)));
     $this->widgetSchema->setLabels(array('max_occurrences' => 'Maximum number of occurrences', 'period' => 'Create every', 'period_type' => ' '));
     parent::configure();
 }
 protected function setupInheritance()
 {
     parent::setupInheritance();
     $this->widgetSchema->setNameFormat('recurring_invoice[%s]');
 }
 protected function setupInheritance()
 {
     parent::setupInheritance();
     $this->widgetSchema->setNameFormat('estimate[%s]');
 }
Beispiel #6
0
 /**
  * 添加联系人页面
  */
 public function actionAddcontacts()
 {
     if ($_GET['id']) {
         $model = MakeContacts::model()->findByPk($_GET['id']);
     } else {
         $model = new MakeContacts();
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'make-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     CommonForm::Add('MakeContacts', 'contacts');
     $this->render('addcontacts', array('model' => $model));
 }