/** * Constructor * * @param mixed $id Set this ID for this model on startup, can also be an array of options, see above. * @param string $table Name of database table to use. * @param string $ds DataSource connection name. * @return void */ public function __construct($id = false, $table = null, $ds = null) { $this->validate = array('product_model' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please enter a product Model Class', true), 'allowEmpty' => false, 'required' => true, 'last' => false), 'maxlength' => array('rule' => array('maxlength', 100), 'message' => __d('invoices', 'The product Model Class should not exceed 100 characters', true))), 'product_id' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please enter a product id', true), 'allowEmpty' => false, 'required' => true)), 'product_name' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please enter a product name', true), 'allowEmpty' => false, 'required' => true)), 'excl_tax_price' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('invoices', 'Please a decimal value for ecl. tax price', true), 'allowEmpty' => false, 'required' => true)), 'tva_price' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('invoices', 'Please enter a decimal value for tva price', true), 'allowEmpty' => false, 'required' => true)), 'tva_rate' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('invoices', 'Please enter a decimal value for tva rate', true), 'allowEmpty' => false, 'required' => true))); parent::__construct($id, $table, $ds); }
/** * Constructor * * @param mixed $id Set this ID for this model on startup, can also be an array of options, see above. * @param string $table Name of database table to use. * @param string $ds DataSource connection name. * @return void */ public function __construct($id = false, $table = null, $ds = null) { $this->validate = array('name' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please, write a name.'), 'allowEmpty' => false, 'required' => true)), 'value' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please, write a value.'), 'allowEmpty' => false, 'required' => true)), 'tag' => array('notempty' => array('rule' => array('notempty'), 'message' => __d('invoices', 'Please, write a tag.'), 'allowEmpty' => false, 'required' => true, 'last' => false), 'isUnique' => array('rule' => array('isUnique'), 'message' => __d('invoices', 'The tag must be unique.')))); parent::__construct($id, $table, $ds); }
/** * Add key for range * * @param array $data Criteria of key->value pairs from post/named parameters * @return array Array of conditions that express the conditions needed for the search. */ public function parseCriteria($data) { if (!empty($data['min_price']) || !empty($data['max_price'])) { $data['price'] = true; } return parent::parseCriteria($data); }