<?php
/*
Generated by OutputBooks Team
*/

defined("\x42\x41\123\x45\x50\101\x54\110") or exit("\116\157\x20\144\151\162\145\143\x74\40\163\143\x72\x69\x70\x74\x20\x61\x63\x63\145\x73\x73\40\141\154\x6c\x6f\167\x65\144");
class Coupons extends MY_Controller
{
    public function __construct()
    {
        goto y4JH1;
        aGmGv:
        $this->cId = get_company("\151\x64");
        goto zBM0N;
        y4JH1:
        parent::__construct();
        goto Udjh8;
        Udjh8:
        $this->load->model("\x63\157\165\160\x6f\x6e\x73\115\157\x64\145\154");
        goto aGmGv;
        zBM0N:
    }
    public function index()
    {
        $this->load->page("\x68\157\x6d\145");
    }
    public function listing($page = 1)
    {
        goto WbgxM;
        oBwgD:
        $result = array();
        goto iFBSC;
        ozzVV:
        return true;
        goto Vp4jh;
        WbgxM:
        $params = $this->request->post();
        goto Mjoka;
        iFBSC:
        $result = $this->couponsModel->get_list($params);
        goto K4x5T;
        fYesj:
        $params["\146\x72\x6f\x6d"] = ($page - 1) * $params["\160\141\147\x65\137\154\151\x6d\151\x74"];
        goto oBwgD;
        Mjoka:
        $params["\x70\141\147\145\137\x6c\151\x6d\151\164"] = $this->config->item("\160\141\147\145\x5f\x6c\151\155\x69\x74");
        goto fYesj;
        qi9bl:
        $this->response->write();
        goto ozzVV;
        K4x5T:
        $this->response->success();
        goto ucWQR;
        ucWQR:
        if (!empty($result["\151\164\145\x6d\163"])) {
            $this->response->set_data("\x69\x74\x65\x6d\x73", $result["\x69\x74\145\155\x73"], true);
        }
        goto qi9bl;
        Vp4jh:
    }
    public function details($id)
    {
        goto cNU7F;
        c5cQY:
        $params["\x69\x73\104\x65\164\x61\x69\154\x73"] = true;
        goto AEdvA;
        uPTza:
        $this->response->set_data("\151\x74\145\x6d", $result);
        goto ZS6tM;
        VmVq2:
        if (empty($params)) {
            if (empty($id)) {
                goto dj1u7;
                oHLPC:
                return false;
                goto KaDIf;
                wWz5l:
                $this->response->write();
                goto oHLPC;
                dj1u7:
                $this->response->error("\120\141\162\141\155\x65\164\145\x72\x73\40\122\145\x71\x75\151\x72\145\x64");
                goto wWz5l;
                KaDIf:
            }
            $params["\x69\144"] = $id;
        }
        goto c5cQY;
        AEdvA:
        $result = $this->couponsModel->get_coupon_details($params);
        goto uPTza;
        cNU7F:
        $params = $this->request->post();
        goto VmVq2;
        ZS6tM:
        $this->response->write();
        goto wwoZw;
        wwoZw:
        return true;
        goto fI5v3;
        fI5v3:
    }
    public function exists()
    {
        goto ljlwp;
        zc3iY:
        $this->form_validation->set_rules("\143\157\165\x70\x6f\156\137\x63\157\x64\x65", "\143\157\165\x70\157\x6e\x5f\x63\x6f\144\145", "\x74\x72\151\155\174\x72\145\x71\x75\151\x72\x65\x64\174\x75\156\x69\161\165\x65\145\137\x74\157\137\143\x6f\x6d\160\x61\156\x79\133\145\x63\x5f\144\151\x73\143\157\x75\156\164\x2e\143\157\165\160\x6f\x6e\137\x63\x6f\x64\145\x5d");
        goto sR_dw;
        DZEfE:
        $this->form_validation->set_data($postdata);
        goto zc3iY;
        T9QMB:
        $this->load->library("\146\x6f\x72\155\x5f\x76\141\154\151\144\141\x74\x69\157\x6e");
        goto DZEfE;
        sR_dw:
        if ($this->form_validation->run() == FALSE) {
            goto XkiD7;
            PqO6w:
            return false;
            goto C04Ev;
            XkiD7:
            $this->response->set_data("\151\x73\x55\x6e\151\x71\165\x65", 0);
            goto DG3Ju;
            DG3Ju:
            $this->response->write();
            goto PqO6w;
            C04Ev:
        } else {
            goto lcRQW;
            eB1xu:
            return true;
            goto AnDlK;
            ohesH:
            $this->response->write();
            goto eB1xu;
            lcRQW:
            $this->response->set_data("\x69\x73\x55\x6e\x69\161\x75\145", 1);
            goto ohesH;
            AnDlK:
        }
        goto w1mTI;
        ljlwp:
        $postdata = $this->request->post();
        goto T9QMB;
        w1mTI:
    }
    public function save()
    {
        goto WGBBG;
        Qj1H9:
        $validFrom = strtotime($data["\166\141\x6c\x69\x64\x46\x72\x6f\155"]);
        goto NNF5V;
        hexjZ:
        $this->response->success("\103\157\165\x70\157\156\40\163\x61\166\x65\x64\40\x73\165\x63\x63\x65\163\163\146\x75\154\x6c\x79");
        goto ce0_9;
        JZK6W:
        if ($datediff > 0) {
            $data["\x65\x78\160\x69\x72\x65\144\117\x6e"] = $data["\166\141\154\x69\144\x46\162\x6f\x6d"];
        }
        goto JxvfA;
        WSnrr:
        if (empty($data["\x69\x64"])) {
            goto RJWa2;
            mJGrt:
            $this->form_validation->set_rules("\143\157\165\160\157\x6e\x5f\x63\x6f\144\x65", "\x63\x6f\x75\x70\x6f\x6e\137\143\x6f\x64\145", "\164\162\x69\x6d\x7c\x72\145\161\x75\151\162\145\x64\174\x75\156\151\x71\165\145\145\137\x74\157\x5f\x63\157\155\160\x61\156\x79\x5b\x65\x63\137\x64\151\163\x63\157\165\x6e\164\x2e\x63\157\165\160\157\x6e\x5f\143\x6f\144\x65\x5d");
            goto cKlmp;
            RJWa2:
            $this->load->library("\146\157\162\155\137\x76\141\154\x69\x64\141\164\151\x6f\156");
            goto ATQpK;
            cKlmp:
            if ($this->form_validation->run() == FALSE) {
                goto PDLTN;
                jQmAY:
                $this->response->write();
                goto AIilK;
                AIilK:
                return false;
                goto MatUC;
                PDLTN:
                $this->response->error("\103\157\x75\160\157\156\x20\143\x6f\x64\x65\40\141\x6c\x72\145\141\144\x79\40\145\x78\151\x73\164\x73", 0);
                goto jQmAY;
                MatUC:
            }
            goto BwWHS;
            ATQpK:
            $this->form_validation->set_data($data);
            goto mJGrt;
            BwWHS:
        }
        goto G23_X;
        NNF5V:
        $datediff = $validFrom - $endDate;
        goto I5IqB;
        FNvAH:
        $this->response->write();
        goto suReY;
        JxvfA:
        $result = $this->couponsModel->save_coupons($data);
        goto hexjZ;
        ce0_9:
        $this->response->set_data("\151\164\x65\x6d\163", $result);
        goto FNvAH;
        I5IqB:
        $datediff = round($datediff / (60 * 60 * 24));
        goto JZK6W;
        aF4b0:
        if (empty($data)) {
            goto B_6xd;
            B_6xd:
            $this->response->error("\x44\141\164\x61\x20\x6d\151\x73\163\x69\156\x67\56");
            goto zX6TK;
            RKGmH:
            return false;
            goto ETrLa;
            zX6TK:
            $this->response->write();
            goto RKGmH;
            ETrLa:
        }
        goto WSnrr;
        WGBBG:
        $data = $this->request->post();
        goto aF4b0;
        suReY:
        return true;
        goto JNTvK;
        G23_X:
        $endDate = strtotime($data["\145\170\160\151\162\x65\x64\117\156"]);
        goto Qj1H9;
        JNTvK:
    }
    public function validate()
    {
        goto n697c;
        KAuR0:
        $this->response->success($this->couponsModel->message);
        goto bMiC2;
        n697c:
        $data = $this->request->post();
        goto PlcXR;
        kKBM3:
        return true;
        goto L7tdc;
        bMiC2:
        $this->response->set_data("\x69\164\145\x6d\163", $result);
        goto L_Oze;
        PlcXR:
        if (empty($data)) {
            goto YVAvV;
            YVAvV:
            $this->response->error("\x44\141\x74\x61\x20\155\x69\x73\163\x69\156\x67\56");
            goto aRUSn;
            aRUSn:
            $this->response->write();
            goto B5Jf_;
            B5Jf_:
            return false;
            goto YRqBW;
            YRqBW:
        }
        goto OC5Rf;
        L_Oze:
        $this->response->write();
        goto kKBM3;
        RLGQZ:
        if (!$result) {
            goto WwWJ0;
            zlGxJ:
            $this->response->write();
            goto biKkY;
            biKkY:
            return false;
            goto YOJ2x;
            WwWJ0:
            $this->response->error($this->couponsModel->message);
            goto zlGxJ;
            YOJ2x:
        }
        goto KAuR0;
        OC5Rf:
        $result = $this->couponsModel->validate($data);
        goto RLGQZ;
        L7tdc:
    }
    public function delete_coupons()
    {
        goto fCD0s;
        fCD0s:
        $postdata = $this->request->post();
        goto oUNT3;
        GfF9N:
        if ($result) {
            $this->response->success("\104\x45\114\105\124\x45\137\x53\125\103\x43\x45\x53\x53");
            $this->response->write();
        } else {
            $this->response->success("\104\105\x4c\x45\124\x45\137\x45\122\122\x4f\x52");
            $this->response->write();
        }
        goto dyQ51;
        oUNT3:
        $result = $this->couponsModel->delete_coupons($postdata);
        goto GfF9N;
        dyQ51:
    }
}
