Example #1
0
 /**
  * Sets the sortorder options for this attribute which is used in recordlists
  * and search actions.
  *
  * @param ColumnConfig $columnConfig The config that contains options for
  *                                   extended sorting and grouping to a
  *                                   recordlist.
  * @param string $fieldprefix The prefix of the attribute on HTML forms
  * @param DataGrid $grid The grid that this attribute lives on.
  *
  * @return string HTML
  */
 public function sortOrder($columnConfig, $fieldprefix = '', $grid = null)
 {
     $fieldname = $this->fieldName();
     $currentOrder = $columnConfig->getOrder($fieldname);
     $res = '';
     if ($currentOrder > 0) {
         $direction = $columnConfig->getSortDirection($this->fieldName()) == 'desc' ? 'asc' : 'desc';
         if ($grid == null) {
             $res = Tools::href(Config::getGlobal('dispatcher') . '?' . $columnConfig->getUrlCommand($fieldname, $direction), Tools::atktext('column_' . $direction)) . ' ';
         } else {
             $call = $grid->getUpdateCall($columnConfig->getUrlCommandParams($fieldname, $direction));
             $res = '<a href="javascript:void(0)" onclick="' . htmlentities($call) . '">' . $this->text('column_' . $direction) . '</a>';
         }
     }
     $res .= '<select class="form-control select-standard" name="atkcolcmd[][setorder][' . $fieldprefix . $fieldname . ']">';
     $res .= '<option value="">';
     for ($i = 1; $i < 6; ++$i) {
         $selected = $currentOrder == $i ? 'selected' : '';
         $res .= '<option value="' . $i . '" ' . $selected . '>' . $i;
     }
     $res .= '</select>';
     return $res;
 }