<?php

if (!defined('sugarEntry') || !sugarEntry)
    die('Not A Valid Entry Point');

require_once('include/MVC/View/views/view.list.php');

class EcmFkVatRegistersViewList extends ViewList {

    function listViewProcess() {
        $this->processSearchForm();
        $this->lv->searchColumns = $this->searchForm->searchColumns;

        if (!$this->headers)
            return;

        $_REQUEST['EcmFkVatRegisters2_ECMFKBOOK_ORDER_BY'] = $_REQUEST['EcmFkBooks2_ECMFKBOOK_ORDER_BY'] ? : 'date_document';
        
        $customOrder = array();
        // switch(strtoupper($this->params['orderBy'])) {EcmFkVatRegisters2_ECMFKBOOK_ORDER_BY
        switch(strtoupper($_REQUEST['EcmFkVatRegisters2_ECMFKBOOK_ORDER_BY'])) {
            default:
                $customOrder = array(
                    //
                );
                
                break;
            
            // nr_sys 3
            case 'BOOK_NUMBER':
                $customOrder = array(
                    //
                );
            
                break;
               
            // ident_k 8
            case 'IDENT_K':
                $customOrder = array(
                    //
                );
            
                break;
            
            // sym_dok 4
            case 'BOOK_SYMBOL':
                $customOrder = array(
                    '`ecmfkvatregisters`.`vat_name` DESC',
                    '`ecmfkvatregisters`.`vat_position` DESC',
                );
            
                break;
                
            case 'BOOK_NAME':
                $customOrder = array(
                    //
                );
            
                break;
                
            case 'BOOK_POSITION':
                $customOrder = array(
                    //
                );
            
                break;
            
            // k_syn_wn + k_anal_wn 1
            case 'BOOK_ACC_WN':
                $customOrder = array(
                    '`ecmfkvatregisters`.`miesiac` DESC',
                    '`ecmfkvatregisters`.`date_document` DESC',
                );
            
                break;
                
            // k_syn_ma + k_anal_ma 2
            case 'BOOK_ACC_MA':
                $customOrder = array(
                    '`ecmfkvatregisters`.`miesiac` DESC',
                    '`ecmfkvatregisters`.`date_document` DESC',
                );
            
                break;
                
            // kwota 9
            case 'BOOK_AMOUNT':
                $customOrder = array(
                    //
                );
            
                break;
                
            // id_dok 8
            case 'BOOK_IDENTIFIER':
                $customOrder = array(
                    //
                );
            
                break;
                
            case 'DESCRIPTION':
                $customOrder = array(
                    //
                );
            
                break;
                
            // rezerwa 10
            case 'REZERWA':
                $customOrder = array(
                    //
                );
            
                break;
                
            case 'KWOTA_WAL':
                $customOrder = array(
                    //
                );
            
                break;
                
                
            case 'SYMB_WAL':
                $customOrder = array(
                    //
                );
            
                break;
                
            case 'KURS_WAL':
                $customOrder = array(
                    //
                );
                
                break;
        }
        
        $this->params['custom_order_by'] = (($implodedCustomOrder = implode(', ', $customOrder)) ?  (', ' . $implodedCustomOrder) : '');

        if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
            $this->lv->ss->assign('SEARCH', true);
            $this->lv->setup($this->seed, 'include/ListView/ListViewGeneric.tpl', $this->where, $this->params);

            // useless ?
            //$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);

            echo $this->lv->display();
        }
        
        // dump($GLOBALS);exit;
        // global $ss;
        // $ss->assign('DISPLAY_FK_YEAR', true);
        // $this->lv->assign('DISPLAY_FK_YEAR', true);
        // $this->lv->ss->assign('DISPLAY_FK_YEAR', true);
        
        // dump($this->lv);
        // dump($this->lv->ss);
        // exit;
    }


}
