<?php
loadcontroller('base/module');

class ControllerTotalDescontoAutomatico extends ControllerBaseModule {
    protected $referencePathFile = 'total/descontoautomatico';

    protected function loadModel()
    {
        parent::loadModel();
        $this->load->dmodel('design/layout');
    }

    protected function loadData()
    {
        parent::loadData();

        $this->dataVue['TypesForJs'] = array (
            Type_Status::getTypeForJs(),
        );
    }

    protected function validate()
    {

        $this->loadLanguage();

        $this->load->helper('ftr_geral');
        $this->load->helper('ftr_validacao');

        extract($this->request->post);
        $errors = array();
        $validators = ['descontoautomatico_status' => [
            'value' => $descontoautomatico_status,
            'validates' => ['isEmpty', 'isEnabledOrDisabled'],
        ]];

        if ($descontoautomatico_status == Type_Status::Tp_Habilitado) {
            $validators['descontoautomatico_sort_order'] = [
                'value' => $descontoautomatico_sort_order,
                'validates' => ['isEmpty', 'isIntegerNumber'],
            ];
        }

        $errors = $this->validate->execute($validators);

        return $errors;

    }
}