where('CustomerEmail', $text); } else { return $this ->where('Series', 'like', "%$text%", 'series') ->where('Customer', 'like', "%$text%", 'customer') ->where('CustomerIdentification', 'like', "%$text%", 'customer_id') ->where('ContactPerson', 'like', "%$text%", 'contact_person') ->where('CustomerEmail', 'like', "%$text%", 'customer_email') ->combine(array('series', 'customer', 'customer_id', 'contact_person', 'customer_email'), 'or', 'invoice_conditions'); } } public function withTags($tags) { if ($tags !== null) { $taggings = TagPeer::getTaggings($tags, array('model' => $this->getClass())); if (isset($taggings[$this->getClass()])) { return $this->where('Id', 'in', $taggings[$this->getClass()]); } else { return $this->where('Id', 'in', null); } } return $this; } /** * @param array $search * Common parameters to all invoiceable objects: * 'query' => Text to find in text fields * 'tags' => Tags that all invoiceables must have * @return DbFinder's same instance */ protected function commonSearch($search) { if (isset($search['tags'])) { $tags = strlen($tags = trim($search['tags'])) ? explode(',', $tags) : null; $this->withTags($tags); } if (isset($search['query'])) { $this->question($search['query']); } return $this; } public function sort($search) { if (isset($search['sort']) && count($search['sort'])) { if ($search['sort'][0] == 'Status') { $this->selectStatus($search); } $this->orderBy($search['sort'][0], isset($search['sort'][1]) ? $search['sort'][1] : 'asc'); } return $this; } /** * a fake selectStatus function. This must be implemented * on subclasses to get the correct status on each case * * @return DbFinder same instance * @author Enrique Martinez **/ protected function selectStatus($search) { return $this->withColumn("upper('status')", 'Status'); } /** * undocumented function * * @return void * @author Carlos Escribano **/ public function isDraft($is = true) { return $this->where('Draft', '=', $is ? '1' : '0'); } }