<?php
/*
Generated by OutputBooks Team
*/

defined("\102\101\123\x45\x50\101\124\x48") or exit("\x4e\x6f\x20\x64\x69\x72\x65\x63\x74\x20\163\143\x72\x69\160\x74\40\x61\143\143\x65\x73\x73\40\141\x6c\x6c\157\167\x65\144");
class Fields extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model("\x66\x69\145\x6c\x64\163\115\x6f\x64\145\x6c");
    }
    public function listing($page = 1)
    {
        goto z2Qb3;
        z2Qb3:
        $data = $this->request->post();
        goto XS06p;
        p1QaF:
        $this->response->success();
        goto VBmi6;
        S0Riz:
        $this->response->set_data($result);
        goto tP11n;
        ZHiDi:
        return true;
        goto IjIEH;
        tP11n:
        $this->response->write();
        goto ZHiDi;
        XS06p:
        $result = $this->fieldsModel->get_list($data);
        goto p1QaF;
        VBmi6:
        if (!empty($result["\151\164\x65\x6d\163"])) {
            $this->response->set_data("\151\164\145\155\163", $result["\x69\x74\x65\155\163"], true);
            unset($result["\x69\x74\x65\155\163"]);
        }
        goto S0Riz;
        IjIEH:
    }
    public function saveorder()
    {
        goto RHFQG;
        YlkSL:
        $this->response->success("\x4f\x72\144\x65\162\40\163\x61\166\145\x64\x20\163\165\143\143\x65\163\x73\x66\165\x6c\x6c\171");
        goto f19ZR;
        f19ZR:
        $this->response->write();
        goto Ss4Dt;
        RHFQG:
        $postData = $this->request->post();
        goto dCsAR;
        ri18n:
        $result = $this->fieldsModel->saveorder($postData);
        goto YlkSL;
        Ss4Dt:
        return true;
        goto nkTVz;
        dCsAR:
        if (empty($postData)) {
            goto k5Kd3;
            CHqii:
            $this->response->write();
            goto uRRa0;
            k5Kd3:
            $this->response->error("\111\116\126\x41\x4c\111\104\x5f\x52\105\x51\x55\105\x53\x54");
            goto CHqii;
            uRRa0:
            return false;
            goto G1Nwi;
            G1Nwi:
        }
        goto ri18n;
        nkTVz:
    }
    public function save()
    {
        goto FiVAs;
        XouUm:
        if ($id) {
            $this->response->success("\x53\125\103\103\105\x53\123\137\123\101\126\x45");
            $this->response->set_data("\x69\x64", $id);
        } else {
            $this->response->error($this->fieldsModel->message);
        }
        goto GvTBf;
        XcrDv:
        return true;
        goto YLFrY;
        nXAio:
        $this->load->library("\x66\157\162\155\x5f\166\x61\154\x69\144\141\164\x69\x6f\x6e");
        goto t133U;
        N4exz:
        if ($this->form_validation->run() == FALSE) {
            goto OahR0;
            w04Ow:
            return false;
            goto Xp79W;
            OahR0:
            $this->response->error(validation_errors());
            goto H4hFH;
            H4hFH:
            $this->response->write();
            goto w04Ow;
            Xp79W:
        }
        goto r7yj0;
        t133U:
        $this->form_validation->set_rules("\x66\x4e\141\155\145", "\x46\x69\145\x6c\x64\x20\156\141\155\145", "\164\x72\151\155\174\162\145\x71\165\151\x72\x65\x64");
        goto N4exz;
        FiVAs:
        $_POST = $postData = $this->request->post();
        goto nXAio;
        r7yj0:
        $id = $this->fieldsModel->save($postData);
        goto XouUm;
        GvTBf:
        $this->response->write();
        goto XcrDv;
        YLFrY:
    }
    public function listingOptionalValues($cusFieldId = 0)
    {
        goto LlyMA;
        pWkmr:
        return true;
        goto AJXC7;
        JcNld:
        $result["\151\x74\145\x6d\x73"] = $this->fieldsModel->getOptionalValues($postData);
        goto Q6eKx;
        UFNLd:
        $postData["\151\144"] = $cusFieldId;
        goto JcNld;
        uKfPL:
        $this->response->write();
        goto pWkmr;
        Q6eKx:
        $this->response->success();
        goto weh4o;
        weh4o:
        $this->response->set_data($result);
        goto uKfPL;
        LlyMA:
        $postData = $this->request->post();
        goto UFNLd;
        AJXC7:
    }
    public function saveOptionalValues()
    {
        goto nC_CD;
        nC_CD:
        $postData = $this->request->post();
        goto Wm2mJ;
        Qraxb:
        if ($ret) {
            $this->response->success("\x53\125\103\103\105\123\123\137\123\x41\x56\x45");
        }
        goto g86BF;
        Wm2mJ:
        $ret = $this->fieldsModel->saveOptionalValues($postData);
        goto Qraxb;
        g86BF:
    }
    public function delete($id = '', $confirm = false)
    {
        goto cTCu2;
        cTCu2:
        if (empty($id)) {
            goto u3vAn;
            u3vAn:
            $this->response->error("\x49\144\x20\115\x69\x73\x73\x69\x6e\x67\x2e");
            goto yRhco;
            ukNRt:
            return;
            goto OfNaP;
            yRhco:
            $this->response->write();
            goto ukNRt;
            OfNaP:
        }
        goto QMTn3;
        wdNTV:
        $this->response->write();
        goto xIAIi;
        mjlet:
        if (is_array($ret) && $ret["\x63\x6e\164"]) {
            goto ztGwP;
            exLJX:
            $this->response->set_data("\155\x73\147", sprintf(lang("\103\x55\123\124\x4f\x4d\x5f\x43\116\124"), $ret["\143\156\164"]));
            goto FFgEa;
            ztGwP:
            $this->response->set_data("\144\x75\x70\x5f\143\x6f\156\x66\151\162\155", $ret["\143\156\x74"]);
            goto exLJX;
            FFgEa:
            $this->response->write();
            goto x8_Hj;
            x8_Hj:
            return false;
            goto IeFqq;
            IeFqq:
        }
        goto YPlmv;
        QMTn3:
        $ret = $this->fieldsModel->delete($id, $confirm);
        goto mjlet;
        YPlmv:
        if ($ret === true) {
            $this->response->success("\104\105\114\x45\x54\105\x5f\x53\125\x43\103\x45\x53\x53");
        } else {
            $this->response->error($this->fieldsModel->message);
            if ($ret) {
                $this->response->set_data("\144\x61\164\141", $ret);
            }
        }
        goto wdNTV;
        xIAIi:
    }
    public function search()
    {
        goto dRuhx;
        EhKw2:
        $result = $this->fieldsModel->search($postData);
        goto jQEAW;
        PsCIV:
        $this->response->write();
        goto nYNqL;
        e3eSl:
        $this->response->success($this->fieldsModel->message);
        goto BnJ0s;
        nYNqL:
        return true;
        goto cvJSU;
        jQEAW:
        if ($result === false) {
            goto yYwMu;
            dX00D:
            return false;
            goto X_ym2;
            yYwMu:
            $this->response->error($this->fieldsModel->message);
            goto xSxPv;
            xSxPv:
            $this->response->write();
            goto dX00D;
            X_ym2:
        }
        goto e3eSl;
        BnJ0s:
        $this->response->set_data(array("\151\164\x65\155\x73" => $result));
        goto PsCIV;
        dRuhx:
        $postData = $this->request->post();
        goto EhKw2;
        cvJSU:
    }
    public function async()
    {
        goto vqHaH;
        cVKmu:
        return false;
        goto pbZ6_;
        RZk__:
        $file = APPPATH . "\x74\x68\x69\162\144\137\x70\x61\x72\x74\x79\x2f" . $cId . "\x2d\143\x6c\x69\x65\x6e\x74\x2e\x70\x68\x70";
        goto rryqe;
        VxKMb:
        $postData = $this->request->post();
        goto gnvA7;
        vqHaH:
        $cId = get_company("\x63\111\144", false);
        goto VxKMb;
        sdngs:
        $this->response->error("\x4e\x6f\40\x46\x69\154\x65\x73\x20\146\157\x75\x6e\x64\40\146\157\x72\40\x66\x69\145\154\144");
        goto zPey7;
        gnvA7:
        if (empty($postData)) {
            goto CWELt;
            CWELt:
            $this->response->error("\x52\x65\x71\165\151\162\x65\144\40\x66\151\145\154\144\x20\x6d\x69\x73\163\x69\156\147");
            goto HpqZ_;
            ZiELX:
            return false;
            goto EQx1Y;
            HpqZ_:
            $this->response->write();
            goto ZiELX;
            EQx1Y:
        }
        goto RZk__;
        rryqe:
        if (file_exists($file)) {
            goto ZK3MC;
            SoVij:
            $obClient = new OB_Client($postData);
            goto iMzc3;
            IkPe0:
            if (!empty($result)) {
                goto ejSMF;
                uTpov:
                if (!empty($result["\143\165\163\164\157\x6d\x65\x72"])) {
                    goto e7Eg9;
                    IYtwf:
                    $customer = $this->contactsModel->customer_search(array("\x73\x74\162" => $result["\x63\x75\x73\x74\157\x6d\x65\x72"], "\x74\x79\x70\x65" => "\x43"));
                    goto vw8j_;
                    e7Eg9:
                    $this->load->model("\143\x6f\x6e\x74\x61\x63\x74\163\115\157\x64\145\154");
                    goto IYtwf;
                    vw8j_:
                    if (!empty($customer) && count($customer) == 1) {
                        goto CvRTT;
                        F_OdR:
                        unset($result["\143\165\x73\164\x6f\x6d\x65\162"]["\143\157\156\x74\x61\x63\164\x73"]);
                        goto KBOwk;
                        CvRTT:
                        $result["\143\165\163\x74\157\x6d\x65\162"] = $this->contactsModel->get_details($customer[0]["\151\x64"]);
                        goto QQzc3;
                        QQzc3:
                        $result["\x63\x75\x73\x74\157\155\145\162"]["\143\157\156\x74\141\x63\x74"] = $result["\143\165\163\x74\x6f\155\x65\162"]["\x63\157\156\164\141\143\x74\163"];
                        goto F_OdR;
                        KBOwk:
                    }
                    goto tzzum;
                    tzzum:
                }
                goto QuiTf;
                QuiTf:
                $this->response->set_data($result);
                goto a6r4o;
                ejSMF:
                if (!empty($result["\x64\145\x74\141\151\x6c\x73"])) {
                    goto jLUjn;
                    yyAKb:
                    $ret = array();
                    goto xlADh;
                    jLUjn:
                    $this->load->model("\x69\164\145\155\x73\115\157\x64\x65\154");
                    goto yyAKb;
                    xlADh:
                    foreach ($result["\x64\x65\164\x61\x69\x6c\x73"] as $key => $val) {
                        goto yg0kp;
                        yg0kp:
                        if (empty($val["\163\x65\141\162\x63\150\x54\x65\170\164"])) {
                            goto pwZQb;
                        }
                        goto CWrVq;
                        HBl_2:
                        $this->db->where("\x63\x49\144", $cId);
                        goto FMzK3;
                        FMzK3:
                        $this->db->like("\x6e\141\x6d\x65", $search_text, "\141\x66\164\x65\162");
                        goto I8P9a;
                        huLHV:
                        $this->db->select("\x2a")->from("\x69\x74\145\155\163");
                        goto HBl_2;
                        I8P9a:
                        $this->db->or_like("\x53\x4b\125", $search_text, "\141\146\164\145\x72");
                        goto exNvK;
                        exNvK:
                        $this->db->or_like("\x48\x53", $search_text, "\x61\146\164\145\x72");
                        goto OLQ1O;
                        YbTQn:
                        if (!empty($res)) {
                            goto azgrt;
                            XzTM2:
                            $result["\x64\145\164\x61\x69\154\163"][$key] = $ret;
                            goto yltEQ;
                            J0C9q:
                            $ret["\162\145\x6c\x5f\x75\x6e\151\164\163"] = $this->itemsModel->get_rel_units($res["\x69\164\145\155\111\144"]);
                            goto XzTM2;
                            azgrt:
                            $ret = array("\x64\x65\164\x61\151\154\x73" => array_merge($res, $val));
                            goto J0C9q;
                            yltEQ:
                        }
                        goto uR9jS;
                        OLQ1O:
                        $this->db->order_by("\162\141\156\x6b", "\x44\105\123\103");
                        goto f7k2a;
                        uR9jS:
                        pwZQb:
                        goto uYzRp;
                        CWrVq:
                        $search_text = $val["\x73\x65\x61\162\143\x68\124\145\x78\164"];
                        goto huLHV;
                        f7k2a:
                        $res = $this->db->limit(1)->get()->row_array();
                        goto YbTQn;
                        uYzRp:
                    }
                    goto OXPTf;
                    OXPTf:
                    NMyCM:
                    goto NIdX9;
                    NIdX9:
                }
                goto uTpov;
                a6r4o:
            } else {
                if (!empty($obClient->message)) {
                    $this->response->error($obClient->message);
                }
            }
            goto xM5oM;
            uSSmI:
            if (!class_exists("\x4f\x42\137\103\x6c\x69\x65\156\x74")) {
                goto Qn2F1;
                wL_pg:
                $this->response->write();
                goto E7Q5e;
                E7Q5e:
                return false;
                goto kulLK;
                Qn2F1:
                $this->response->error("\103\x6c\x61\x73\x73\x20\x6e\157\164\40\x66\x6f\165\x6e\144");
                goto wL_pg;
                kulLK:
            }
            goto SoVij;
            ZK3MC:
            require_once $file;
            goto uSSmI;
            iMzc3:
            $result = $obClient->result();
            goto IkPe0;
            xM5oM:
            $this->response->write();
            goto iZrNf;
            iZrNf:
            return;
            goto GhKZi;
            GhKZi:
        }
        goto sdngs;
        zPey7:
        $this->response->write();
        goto cVKmu;
        pbZ6_:
    }
}
