예제 #1
0
 public function search($record, $extended = false, $fieldprefix = '', DataGrid $grid = null)
 {
     if ($this->getSearchType() == 'number') {
         $attr = new NumberAttribute($this->fieldName());
         return $attr->search($record, $extended, $fieldprefix);
     } else {
         if ($this->getSearchType() == 'date') {
             $attr = new DateAttribute($this->fieldName());
             $attr->m_searchsize = 10;
             return $attr->search($record, $extended, $fieldprefix);
         } else {
             return parent::search($record, $extended, $fieldprefix);
         }
     }
 }
예제 #2
0
 /**
  * Returns a piece of html code that can be used in a form to search values.
  *
  * @param array $record Array with fields
  * @param bool $extended if set to false, a simple search input is
  *                            returned for use in the searchbar of the
  *                            recordlist. If set to true, a more extended
  *                            search may be returned for the 'extended'
  *                            search page. The Attribute does not
  *                            make a difference for $extended is true, but
  *                            derived attributes may reimplement this.
  * @param string $fieldprefix The fieldprefix of this attribute's HTML element.
  * @param DataGrid $grid
  *
  * @return string piece of html code with a checkbox
  */
 public function search($record, $extended = false, $fieldprefix = '', DataGrid $grid = null)
 {
     return parent::search($record, $extended, $fieldprefix);
 }
예제 #3
0
 /**
  * Returns a piece of html code that can be used in a form to search values.
  * Searching is disabled for the date attribute, we only return a space.
  *
  * @param array $record array with 3 fields (year, month, day)
  * @param bool $extended if set to false, a simple search input is
  *                            returned for use in the searchbar of the
  *                            recordlist. If set to true, a more extended
  *                            search may be returned for the 'extended'
  *                            search page. The Attribute does not
  *                            make a difference for $extended is true, but
  *                            derived attributes may reimplement this.
  * @param string $fieldprefix The fieldprefix of this attribute's HTML element.
  * @param DataGrid $grid
  *
  * @return string piece of HTML code
  */
 public function search($record, $extended = false, $fieldprefix = '', DataGrid $grid = null)
 {
     if (!$extended) {
         // plain text search, check if we didn't come from extended search (then current value is an array)
         if (isset($record[$this->fieldName()]) && is_array($record[$this->fieldName()])) {
             // TODO try to set the value
             $record[$this->fieldName()] = null;
         }
         $maxSize = $this->m_maxsize;
         $this->m_maxsize = 25;
         // temporary increase max size to allow from/to dates
         $result = parent::search($record, $extended, $fieldprefix);
         $this->m_maxsize = $maxSize;
         return $result;
     }
     // Set default values to null.
     if (!isset($record[$this->fieldName()]) || empty($record[$this->fieldName()])) {
         $record[$this->fieldName()] = null;
     }
     $id = $this->getHtmlId($fieldprefix);
     $name = $this->getSearchFieldName($fieldprefix);
     $rec = isset($record[$this->fieldName()]['from']) ? array($this->fieldName() => $record[$this->fieldName()]['from']) : $record;
     $res = $this->draw($rec, $id . '_from', $name, 'atksearch_AE_' . $fieldprefix, '_AE_from', 'search');
     $rec = isset($record[$this->fieldName()]['to']) ? array($this->fieldName() => $record[$this->fieldName()]['to']) : $record;
     $res .= ' ' . Tools::atktext('until') . ': ' . $this->draw($rec, $id . '_to', $name, 'atksearch_AE_' . $fieldprefix, '_AE_to', 'search');
     return $res;
 }