? Fallagassrini

Fallagassrini Bypass Shell

echo"
Fallagassrini
";
Current Path : /home1/savoy/public_html/savoyglobal.net/sibs_draft/system/application/controllers/

Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
Upload File :
Current File : /home1/savoy/public_html/savoyglobal.net/sibs_draft/system/application/controllers/master.php

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php

class Master extends BaseController {

    function Master() {
        parent::BaseController();
        $this->load->model('mastermodel');
        $this->load->model('customermodel');
        $this->load->model('accountingsmodel');
        $this->load->model('settingsmodel');
        $this->load->model('documentsmodel');
        $this->load->model('hrmodel');
        $this->load->library('Fpaginate');
    }

    function index($menuid = "", $modid = "") {


        $ret = $this->mastermodel->chk_url_permission($menuid);
        if ($ret != 1) {
            $menuid = "";
            $modid = "";
        }
        if (empty($modid)) {
            $data['modname'] = 'Home';
        } else {
            $mod_id = $this->mastermodel->get_data('modules', $modid, 'module_id', 'sort');
            foreach ($mod_id as $id) {
                $modname = $id['module_name'];
            }
            $data['modname'] = $modname;
        }
        if (empty($menuid)) {
            $tart = 'index';
            $data['menuname'] = '';
            $data['men_id'] = $menuid;
            $data['modulelist'] = $this->mastermodel->getmoduledata();
        } else {
            $tar = $this->mastermodel->get_data('menu', $menuid, 'menu_id');

            foreach ($tar as $target) {
                $tart = $target['target'];

                $data['menuname'] = $target['caption'];
            }
        }

        $_SESSION['current_mode'] = $menuid;
        $_SESSION['modename'] = $data['modname'];
        // $data['men_id']=$menuid;
        $data['actilist'] = $this->mastermodel->Get_today_activity(1);
        $data['reminderlist'] = $this->mastermodel->Get_today_reminder();
        $data['schedulde'] = $this->mastermodel->Get_today_schedulde();
        $data['modules'] = $this->settingsmodel->buildModule();
        $data['menus'] = $this->settingsmodel->buildMenu($modid);

        $this->load->view('' . $data['modname'] . '/' . $tart . '', $data);

        //}
    }

    function insurancetypes($menuid = "") {

        $this->load->view('Master/insurancetypes');
    }

    function ajaxload($page, $table = "", $pagenum = "") {
        $data['property'] = 'view';
        $data['perpage'] = '6';

        $data['count'] = $this->mastermodel->count_all('' . $table . '');
        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $data['norecords'] = $this->mastermodel->norecords('' . $table . '');
        $data['viewinfo'] = $this->mastermodel->view('' . $table . '', $data['pagenum'], $data['perpage']);
        $data['country'] = $this->mastermodel->getdatas('country');
        $data['segment'] = $this->mastermodel->getdatas('segment_insurances');
        $data['cover_insurance'] = $this->mastermodel->getdatas('covers');
        $data['directory'] = $this->mastermodel->getdatas('directory');
        $data['action'] = 'add';
        $this->load->view('Master/' . $page . '', $data);
    }

    function ajaxloadcovertype($page, $arg1) {
        $data['coverlist'] = $this->mastermodel->get_data('covers', $arg1, 'segment_id');
        $this->load->view('Master/' . $page . '', $data);
    }

    function ajaxloadtype($page, $arg1) {
        $data['typelist'] = $this->mastermodel->get_data('segment_insurances', $arg1, 'branch_id');
        $this->load->view('Master/' . $page . '', $data);
    }

    function ajaxloadcountrycity($page, $field) {
        $data['citylist'] = $this->mastermodel->get_data('city', $field, 'country_id');
        $this->load->view('Master/' . $page . '', $data);
    }

    function addsegment() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('segment', 'Segment Type', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('1', '3');
        } else {

            $res = $this->mastermodel->add('segment_insurances');
            //$this->index('1', '3');
            redirect('master/index/1/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addcover() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Segment Type', 'required');
        $this->form_validation->set_rules('cover', 'Cover Type', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('1', '3');
        } else {

            $res = $this->mastermodel->addcover('covers');
            // $this->index('1', '3');
            redirect('master/index/1/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addcountry() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('countryname', 'Country Name', 'required');
        $this->form_validation->set_rules('countrycode', 'Country Code', 'required');
        $this->form_validation->set_rules('countryisd', 'Country ISD Code', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('2', '3');
        } else {

            $res = $this->mastermodel->add('country');

            redirect('master/index/2/3');

            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addcity() {


        $this->load->library('form_validation');
        $this->form_validation->set_rules('country_id', 'Country', 'required');
        $this->form_validation->set_rules('cityname', 'City Name', 'required');


        if ($this->form_validation->run() == FALSE) {

            $this->index('2', '3');
        } else {


            $res = $this->mastermodel->addcity();

            //$this->index('2', '3');

            if ($res == 1) {
                $this->load->view('Master/success');
            }
            redirect('master/index/2/3');
        }
    }

    function addwarranty() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('warranty', 'Warranty', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('5', '3');
        } else {

            $res = $this->mastermodel->insertwarranty();
            redirect('master/index/5/3');
            //$this->index('5', '3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addcondition() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('condition', 'Condition', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('6', '3');
        } else {

            $res = $this->mastermodel->insertcondition();
            // $this->index('6', '3');
            redirect('master/index/6/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addexclusion() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('exclusion', 'Exclusion', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('7', '3');
        } else {

            $res = $this->mastermodel->insertexclusion();
            // $this->index('7', '3');
            redirect('master/index/7/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addextension() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('extension', 'Extension', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('8', '3');
        } else {

            $res = $this->mastermodel->insertextension();
            redirect('master/index/8/3');
            //$this->index('8', '3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addexcess() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('excess', 'Excess', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('9', '3');
        } else {

            $res = $this->mastermodel->insertexcess();
            redirect('master/index/9/3');
            //$this->index('9', '3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function adddeductible() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('deductible', 'deductible', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('10', '3');
        } else {

            $res = $this->mastermodel->insertdeductible();
            redirect('master/index/10/3');
            // $this->index('10', '3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addspcondition() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('specialcondition', 'Special Condition', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('13', '3');
        } else {

            $res = $this->mastermodel->insertspcondition();
            redirect('master/index/13/3');
            //$this->index('13', '3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function addinsurance() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('company_name', 'Company Name', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('3', '3');
        } else {

            $res = $this->mastermodel->addinsurance();
            //$this->index('3', '3');
            redirect('master/index/3/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function edit($page, $table, $field, $id) {
        $data['viewinfo'] = $this->mastermodel->get_data($table, $id, $field);
        $data['action'] = 'update';
        $data['id'] = $id;


        $data['segment'] = $this->mastermodel->getdatas('segment_insurances');
        $data['country'] = $this->mastermodel->getdatas('country');
        $data['cover'] = $this->mastermodel->getdatas('covers');

        $this->load->view('Master/' . $page . '', $data);
    }

    function singlecity($page, $table, $field, $id) {
        $data['viewinfo'] = $this->mastermodel->get_data($table, $id, $field);
        $data['id'] = $id;
        $data['tablename'] = 'city_files';
        $data['fieldname'] = 'cityid';

        $this->load->view('Master/' . $page . '', $data);
    }

    function editcover() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Segment Type', 'required');
        $this->form_validation->set_rules('cover', 'Cover Type', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('1', '3');
        } else {

            $res = $this->mastermodel->updatecover();
            // $this->index('1', '3');
            redirect('master/index/1/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editsegment() {

        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment', 'Type Of Insurance', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('1', '3');
        } else {

            $res = $this->mastermodel->updatesegment();
            // $this->index('1', '3');
            redirect('master/index/1/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editcountry() {

        $this->load->library('form_validation');
        $this->form_validation->set_rules('countryname', 'Country Name', 'required');
        $this->form_validation->set_rules('countrycode', 'Currency Code', 'required');
        $this->form_validation->set_rules('countryisd', 'Country ISD', 'required');
        $this->form_validation->set_rules('currencyname', 'Currency Name', 'required');
        $this->form_validation->set_rules('currencycode', 'Currency Code', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('2', '3');
        } else {

            $res = $this->mastermodel->updatecountry('country');
            // $this->index('2', '3');
            redirect('master/index/2/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editcity() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('cityname', 'City Name', 'required');
        $this->form_validation->set_rules('citycode', 'City Code', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('2', '3');
        } else {




            $res = $this->mastermodel->updatecity();
            // $this->index('2', '3');
            redirect('master/index/2/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editcondition() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('condition', 'Condition', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('6', '3');
        } else {

            $res = $this->mastermodel->updatecondition('conditions');
            // $this->index('6', '3');
            redirect('master/index/6/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editspcondition() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('specialcondition', 'Special Condition', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('13', '3');
        } else {

            $res = $this->mastermodel->updatespcondition('specialconditions');
            // $this->index('13', '3');
            redirect('master/index/13/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editextension() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('extension', 'Extension', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('8', '3');
        } else {

            $res = $this->mastermodel->updateextension('extension');
            // $this->index('8', '3');
            redirect('master/index/8/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editexclusion() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('exclusion', 'Exclusion', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('7', '3');
        } else {

            $res = $this->mastermodel->updateexclusion('exclusion');
            // $this->index('7', '3');
            redirect('master/index/7/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editdeductible() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('deductible', 'deductible', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('10', '3');
        } else {

            $res = $this->mastermodel->updatedeductible('deductible');
            // $this->index('10', '3');
            redirect('master/index/10/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editexcess() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('excess', 'Excess', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('9', '3');
        } else {

            $res = $this->mastermodel->updateexcess('excess');
            //$this->index('9', '3');
            redirect('master/index/9/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function editwarranty() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('warranty', 'Warranty', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('5', '3');
        } else {

            $res = $this->mastermodel->updatewarranty('warranty');
            //$this->index('5', '3');
            redirect('master/index/5/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function delete($table, $id, $menu) {


        $data = $this->mastermodel->check_permissions(3);
        if (!$data) {

            $this->index($menu, '3');
            $this->load->view('Master/nopermission');
        } else {

            try {
                $res = $this->mastermodel->deletedata($table, $id);
                ;

                if ($res != 1) {
                    throw new Exception("Error");
                }
                $this->index($menu, '3');
            } catch (Exception $exception) {

                $this->index($menu, '3');
                $this->load->view('Master/checkexist');
            }
        }
    }

    function viewcompany($page, $field, $id) {
        $data['viewcompany'] = $this->mastermodel->get_data_srow('insurance_company', $id, $field);
        $data['viewinsurance_contact'] = $this->mastermodel->get_data('insurance_contact', $id, 'company_id', 'department');
        $data['viewinsurance_gross'] = $this->mastermodel->get_data('insurance_grosspremium', $id, 'company_id');
        $data['insurance_files'] = $this->mastermodel->get_data_scoloumn('insurance_files', $id, 'company_id', 'fileid');
        $data['action'] = 'view';
        $data['id'] = $id;
        $data['tablename'] = 'insurance_files';
        $data['fieldname'] = 'company_id';

        $data['country'] = $this->mastermodel->getdatas('country');

        $this->load->view('Master/' . $page . '', $data);
    }

    function editinsurance() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('company_name', 'Company Name', 'required');
        if ($this->form_validation->run() == FALSE) {

            $this->index('3', '3');
        } else {
            $path = $this->input->post('subpathname');

            $config['upload_path'] = './uploads/' . $path . ''; // server directory
            // $data=array_filter($_FILES['userfile']['name']);
            $config['allowed_types'] = 'gif|jpg|png|doc|pdf|txt|xls|csv|docx'; // by extension, will check for whether it is an image
            $config['max_size'] = '100000'; // in kb
            $config['max_width'] = '1024';
            $config['max_height'] = '768';

            $this->load->library('upload', $config);
            $this->load->library('Multi_upload');

            $files = $this->multi_upload->go_upload();




            $res = $this->mastermodel->editinsurance($files, $path);
            // $this->index('3', '3');
            redirect('master/index/3/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function createdir($dirName = "") {

        if (empty($dirName)) {
            echo "No Directory Name Specified";
        } else {
            $path = './uploads/';
            if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) {
                // We have a valid directory:
                if (!is_dir($path . $dirName)) {
                    // We are good to create this directory:
                    if (mkdir($path . $dirName, 0775)) {
                        $this->mastermodel->adddirectory($dirName);
                        $success = "Your directory has been created succesfully!";
                        echo $success;
                    } else {
                        $error = "Unable to create dir {$dirName}.";
                        echo $error;
                    }
                } else {
                    $error = "Directory {$dirName} already exists.";
                    echo $error;
                }
            } else {
                // Invalid data, htmlenttie them incase < > were used.
                $dirName = htmlentities($dirName);
                $error = "You have invalid values in {$dirName}.";
                echo $error;
            }
        }
    }

    function createsubdir($diid, $fieldid, $subdir = "") { // this function needs default value to be in sub_directory table as , id=1, parendir=0 and subdirname=uploads
        if (empty($subdir)) {
            echo "No SubDirectory Name Specified";
        } else {

            if ($diid == 1) {
                $dirName = $subdir;
            } else {


                $tempid = $diid;
                $plocation = $this->tracepath($tempid);
                $dirName = $plocation . '/' . $subdir;
            }



            $path = './uploads/';
            if ($subdir !== false && preg_match('~([^A-Z0-9]+)~i', $subdir, $matches) === 0) {
                // We have a valid directory:
                if (!is_dir($path . $dirName)) {
                    // We are good to create this directory:
                    if (mkdir($path . $dirName, 0775)) {
                        $this->mastermodel->addsubdirectory($diid, $fieldid, $subdir);
                        $success = "Your directory has been created succesfully!";
                        echo $success;
                    } else {
                        $error = "Unable to create dir {$dirName}.";
                        echo $error;
                    }
                } else {
                    $error = "Directory {$dirName} already exists.";
                    echo $error;
                }
            } else {
                // Invalid data, htmlenttie them incase < > were used.
                $dirName = htmlentities($dirName);
                $error = "You have invalid values in {$dirName}.";
                echo $error;
            }
        }
    }

    function deletedirectory($table, $dirid) {


        $tempid = $dirid;
        $plocation = $this->tracepath($tempid);
        $dirName = $plocation;
        $path = './uploads/';
        $fname = $this->mastermodel->get_data_srow('sub_directory', $dirid, 'id');

        $n = $this->findextension($fname->subdirname);
        if (!empty($n)) {
            $res = $this->mastermodel->checkfileowner($table, $dirid);
            if ($res > 0) {
                $dirName = substr_replace($dirName, "", -1);
                if (unlink($path . $dirName)) {
                    $this->mastermodel->deletedata('sub_directory', $dirid);
                    $this->mastermodel->deletefiles($table, $dirid);
                    $success = "Your File has been deleted succesfully!";
                    echo $success;
                } else {
                    $error = "Unable to delete File {$dirName}.";
                    echo $error;
                }
            } else {
                echo "This File is not created from this module! ";
            }
        } else {



            if (is_dir($path . $dirName)) {
                // We are good to create this directory:

                if (rmdir($path . $dirName)) {
                    $this->mastermodel->deletedata('sub_directory', $dirid);
                    $success = "Your directory has been deleted succesfully!";
                    echo $success;
                } else {
                    $error = "Unable to delete dir {$dirName}.";
                    echo $error;
                }
            } else {
                $error = "Directory {$dirName} does not exists.";
                echo $error;
            }
        }
    }

    function addtemplate() {
        $this->load->library('form_validation');

        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('template_id', 'Template Type', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('12', '3');
        } else {

            $res = $this->mastermodel->inserttemplate();
            // $this->index('12', '3');
            redirect('master/index/12/3');
            if ($res == 1) {
                $this->load->view('Master/success');
            }
        }
    }

    function edittemplate() {
        $this->load->library('form_validation');


        $this->form_validation->set_rules('segment_id', 'Type Of Insurance', 'required');
        $this->form_validation->set_rules('cover_id', 'Type Of Cover', 'required');
        $this->form_validation->set_rules('name', 'Name', 'required');

        if ($this->form_validation->run() == FALSE) {

            $this->index('12', '3');
        } else {

            $res = $this->mastermodel->updatetemplate();
            // $this->index('12', '3');
            redirect('master/index/12/3');
            if ($res == 1) {
                $this->load->view('Master/updatesuccess');
            }
        }
    }

    function search_data($page, $seloption, $pagenum = "", $searchtext = "") {

        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['property'] = 'search';
        $data['perpage'] = '10';
        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['searchoption'] = $seloption;
        $data['searchtxt'] = $searchtext;
        $data['nooflist'] = '4';
        $data['count'] = $this->mastermodel->search_data($seloption, $searchtext, 'true');

        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $arr = $this->fpaginate->paginate($data['pagenum'], $data['pages'], $data['nooflist']);
        $data['startpage'] = $arr[0];
        $data['endpage'] = $arr[1];
        $data['viewinfo'] = $this->mastermodel->search_data($seloption, $searchtext, 'false', $data['pagenum'], $data['perpage']);
        $this->load->view('Master/' . $page . '', $data);
    }

    function search_insurance($page, $seloption, $pagenum = "", $searchtext = "") {
        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['property'] = 'search';
        $data['perpage'] = '10';
        $_SESSION['pagenum'] = $pagenum;
        $_SESSION['searchoption'] = $seloption;
        $_SESSION['searchtxt'] = $searchtext;
        $data['searchoption'] = $seloption;
        $data['searchtxt'] = $searchtext;
        $data['nooflist'] = '4';
        $data['count'] = $this->mastermodel->search_insurance($seloption, $searchtext, 'true');

        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $arr = $this->fpaginate->paginate($data['pagenum'], $data['pages'], $data['nooflist']);
        $data['startpage'] = $arr[0];
        $data['endpage'] = $arr[1];

        $data['viewinfo'] = $this->mastermodel->search_insurance($seloption, $searchtext, 'false', $data['pagenum'], $data['perpage']);
        $this->load->view('Master/' . $page . '', $data);
    }

    function search_address($page, $seloption, $pagenum = "", $searchtext = "") {
        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['property'] = 'search';
        $data['perpage'] = '10';
        $data['searchoption'] = $seloption;
        $data['searchtxt'] = $searchtext;
        $data['nooflist'] = '4';

        $data['count'] = $this->mastermodel->search_address($seloption, $searchtext, 'true');

        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $arr = $this->fpaginate->paginate($data['pagenum'], $data['pages'], $data['nooflist']);
        $data['startpage'] = $arr[0];
        $data['endpage'] = $arr[1];
        $data['viewinfo'] = $this->mastermodel->search_address($seloption, $searchtext, 'false', $data['pagenum'], $data['perpage']);
        $this->load->view('Master/' . $page . '', $data);
    }

    function search_company($page, $seloption, $pagenum = "", $searchtext = "") {


        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['property'] = 'search';
        $data['perpage'] = '10';
        $data['searchoption'] = $seloption;
        $data['searchtxt'] = $searchtext;
        $data['nooflist'] = '4';
        $_SESSION['pagenum'] = $pagenum;
        $_SESSION['searchoption'] = $seloption;
        $_SESSION['searchtxt'] = $searchtext;
        $data['count'] = $this->mastermodel->search_company($seloption, $searchtext, 'true');

        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $arr = $this->fpaginate->paginate($data['pagenum'], $data['pages'], $data['nooflist']);
        $data['startpage'] = $arr[0];
        $data['endpage'] = $arr[1];
        $data['viewinfo'] = $this->mastermodel->search_company($seloption, $searchtext, 'false', $data['pagenum'], $data['perpage']);
        $this->load->view('Master/' . $page . '', $data);
    }

    function search_template($page, $seloption, $pagenum = "", $searchtext = "") {
        $searchtext = str_replace("~", " ", $searchtext);
        $searchtext = str_replace("_", "/", $searchtext);
        $data['property'] = 'search';
        $data['perpage'] = '10';
        $data['searchoption'] = $seloption;
        $data['searchtxt'] = $searchtext;
        $data['nooflist'] = '4';
        $_SESSION['pagenum'] = $pagenum;
        $_SESSION['searchoption'] = $seloption;
        $_SESSION['searchtxt'] = $searchtext;
        $data['count'] = $this->mastermodel->search_template($seloption, $searchtext, 'true');

        $data['pages'] = ceil($data['count'] / $data['perpage']);
        $data['pagenum'] = $pagenum;
        if ($data['pagenum'] == 1)
            $data['id'] = 1;
        else
            $data['id'] = (($data['pagenum'] - 1) * $data['perpage']) + 1;
        $arr = $this->fpaginate->paginate($data['pagenum'], $data['pages'], $data['nooflist']);
        $data['startpage'] = $arr[0];
        $data['endpage'] = $arr[1];
        $data['viewinfo'] = $this->mastermodel->search_template($seloption, $searchtext, 'false', $data['pagenum'], $data['perpage']);
        $this->load->view('Master/' . $page . '', $data);
    }

    function viewsingleremind($id) {
        $data['singlereminder'] = $this->mastermodel->GetSingleReminder($id);
        $this->load->view('Home/viewsingle-reminder', $data);
    }

    function viewsinglesche($id) {
        $data['singlesche'] = $this->mastermodel->get_data('activities', $id, 'id');
        $this->load->view('Home/viewsingle-sche', $data);
    }

    function viewsingleactivity($id) {

        $data['viewactivity'] = $this->mastermodel->get_data('events', $id, 'id');
        $this->load->view('Home/viewsingleactivity', $data);
    }

    function viewschedulde($pageno = 1) {
        $data['schlist'] = $this->mastermodel->Get_today_activity($pageno);
        $data['currpage'] = $pageno;


        $data['totrecord'] = $this->settingsmodel->count_alls('activities', 'date', '2010-07-26');
        $this->load->view('Home/viewmore-schedule', $data);
    }

    function listSearchcustomerm($searchBy = "", $pageNo = "", $custname = "") {
        $custname = urldecode($custname);
        $searchBy = urldecode($searchBy);
        $pageSize = 10;

        $data['cust_permis'] = $this->mastermodel->ret_cust_private();
        $dat['viewinfo'] = $this->customermodel->ListofCustomers($custname, $searchBy, $pageNo, $pageSize);

        $data['MaxPage'] = $dat['viewinfo']['maxpage'];
        $data['viewinfo'] = $dat['viewinfo']['result'];
        $data['staffids'] = $this->mastermodel->tracestaff();
        $data['custname'] = $custname;
        $data['searchBy'] = $searchBy;
        $data['currentpage'] = $pageNo;
        if ($pageNo != 1) {
            $data['sno'] = ($pageNo - 1) * $pageSize + 1;
        } else {
            $data['sno'] = $pageNo;
        }
        $this->load->view('Home/customerlist', $data);
    }

    function getfolderlist($page, $parentid = "") {
        $data['folderlist'] = $this->mastermodel->getfolderlistmodel($parentid);
        if ($parentid == "") {
            $parentid = '0';
        }
        $data['parid'] = $this->customermodel->getSingleFieldValue('sub_directory', 'parentdir', 'id', $parentid);
        $data['folderpath'] = $this->tracepath($parentid);
        $this->load->view('Master/' . $page . '', $data);
    }

    function renamefolder($dirid, $dirName) {
        if (empty($dirName)) {
            echo "No  Name Specified";
        } else {
            $tempid = $dirid;
            $plocation = $this->tracepath($tempid);
            $plocaarray = explode('/', $plocation);
            $plocaarray = array_filter($plocaarray);
            array_pop($plocaarray);
            $oldpath = implode('/', $plocaarray);
            $path = './uploads/';
            $fname = $this->mastermodel->get_data_srow('sub_directory', $dirid, 'id');
            $n = $this->findextension($fname->subdirname);
            if (empty($n)) {
                if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) {
                    if (is_dir($path . $plocation)) {
                        // We are good to create this directory:
                        if (rename($path . $plocation, $path . $oldpath . '/' . $dirName)) {
                            $this->mastermodel->renamefolder($dirid, $dirName);
                            $success = "Your directory has been renamed succesfully!";
                            echo $success;
                        } else {
                            $error = "Unable to rename dir {$dirName}.";
                            echo $error;
                        }
                    } else {
                        $error = "Directory {" . $path . $plocation . "} does not exists.";
                        echo $error;
                    }
                } else {
                    // Invalid data, htmlenttie them incase < > were used.
                    $dirname = htmlentities($dirName);
                    $error = "You have invalid values in {$dirName}.";
                    echo $error;
                }
            } else {
                echo "You cannot rename a file";
            }
        }
    }

    function tracepath($tempid) {
        $plocation = "";
        while ($tempid != 1) {
            $directname = $this->mastermodel->get_data_srow('sub_directory', $tempid, 'id');

            $diName = $directname->subdirname;
            $tempid = $directname->parentdir;
            $plocation = $diName . '/' . $plocation;
        }
        return $plocation;
    }

    function downloadfile($tempid) {
        $file = $this->tracepath($tempid);
        $path = './uploads/';

        $file = substr_replace($file, "", -1);
        // die();
        if ((isset($file)) && (file_exists($path . $file))) {
            header("Content-type: application/force-download");
            header('Content-Disposition: inline; filename="' . $path . $file . '"');
            header("Content-Transfer-Encoding: Binary");
            header("Content-length: " . filesize($path . $file));
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . $file . '"');
            readfile("$path$file");
            exit(0);
        } else {
            echo "No file selected";
        }
    }

    function tracepathcomp($tempid) {
        $plocation = "";
        while ($tempid != 1) {
            $directname = $this->mastermodel->get_data_srow('sub_directory', $tempid, 'id');
            $diName = $directname->id;
            $tempid = $directname->parentdir;
            $plocation = $diName . '/' . $plocation;
        }
        return $plocation;
    }

    function uploadpathfind($tempid) {
        echo $this->tracepath($tempid);
    }

    function findextension($dname) {
        $filename = strtolower($dname);
        $exts = split("[/\\.]", $filename);
        $n = count($exts) - 1;
        $exts = $exts[$n];
        return $n;
    }

    function Todaysreminder() {


        $data['remlist'] = $this->mastermodel->Get_today_reminder();
        $this->load->view('Home/todayreminderpage', $data);
    }

    function todaysactivities() {
        $data['remlist'] = $this->mastermodel->Get_today_activity(1);
        $this->load->view('Home/todaysactivitypage', $data);
    }

    function paymentschedule() {
        $data['schlist'] = $this->mastermodel->Get_today_schedulde();
        $this->load->view('Home/paymentschedulepage', $data);
    }

    function showcovercommission($page) {
        $data['covergp'] = $this->mastermodel->getcoverdata();
        $this->load->view('Master/' . $page . '', $data);
    }

    function showcovercommissioncompany($page, $cid) {
        $data['covergp'] = $this->mastermodel->getcompanycoverdata($cid);
        $data['action'] = 'edit';

        $this->load->view('Master/' . $page . '', $data);
    }

    function showcovercommissioncompanyview($page, $cid) {
        $data['covergp'] = $this->mastermodel->getcompanycoverdata($cid);
        $data['action'] = 'view';

        $this->load->view('Master/' . $page . '', $data);
    }

    function check_permissions($check) {
        $data = $this->mastermodel->check_permissions($check);
        if (!$data) {
            $this->load->view('Master/nopermission');
        } else {
            echo $data;
        }
    }

    function viewourbranch($pageno = 1, $field, $value = '') {
        $value = str_replace("~", " ", $value);
        $value = str_replace("_", "/", $value);
        if ($field == 'all') {
            $field = 'branchname';
            $value = '%';
        }
        $data['bralist'] = $this->mastermodel->GetOurBranch($pageno, $field, $value);


        $data['currpage'] = $pageno;
        $data['totrecord'] = $this->settingsmodel->count_alls('ourbranch', $field, $value);
        $data['field1'] = $field;
        $data['text'] = $value;
        $this->load->view('Master/ourbranchpage', $data);
    }

    function addourbranchpage() {
        $data['countrys'] = $this->mastermodel->getdatas('country');
        $this->load->view('Master/addourbranch', $data);
    }

    function addourbranch() {
        $res = $this->mastermodel->addtomybranch();
        redirect('master/index/87/3');
    }

    function Get_editourbranch($id, $pageno, $field, $text = "") {
        //the argument pageno is current page no and  id is reminder id
        $data['countrys'] = $this->mastermodel->getdatas('country');
        $data['company'] = $this->mastermodel->Get_ourbranch_data($id);
        $data['currpage'] = $pageno;
        $data['field1'] = $field;
        $data['text'] = $text;
        $this->load->view('Master/edit-ourbranch-page', $data);
    }

    function viewourbranchdata($id, $pageno, $field, $text = "") {
        //the argument pageno is current page no and  id is reminder id
        $data['company'] = $this->mastermodel->Get_ourbranch_data($id);
        $data['currpage'] = $pageno;
        $data['field1'] = $field;
        $data['text'] = $text;
        $this->load->view('Master/viewourbranch-page', $data);
    }

    function editourbranch() {
        $this->mastermodel->updateourbranch();
        redirect('master/index/87/3');
    }

    function viewmycompany() {


        $data['company'] = $this->mastermodel->getdatas('mycompany');
        $data['mycompany_contact'] = $this->mastermodel->getdatas('mycompany_contact');
        $this->load->view('Master/companypage', $data);
    }

    function addmycompany() {
        $this->load->view('Master/addmycompany');
    }

    function insertmycompany() {


        $config['upload_path'] = './logo/';
        $config['allowed_types'] = 'jpg|png'; // by extension, will check for whether it is an image
        $config['max_size'] = '100000'; // in kb

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('logoup')) {



            $error = array('error' => $this->upload->display_errors());
        } else {

            $data = array('upload_data' => $this->upload->data());
        }


        $res = $this->mastermodel->addtomycompany();
        redirect('master/index/86/3');
    }

    function get_company($id) {


        $data['company'] = $this->mastermodel->Get_mycompany($id);
        $data['mycompany_contact'] = $this->mastermodel->get_data('mycompany_contact', $id, 'mycompany_id');
        $this->load->view('Master/edit_mycompanypage', $data);
    }

    function deletemycompany($id) {

        $oldlogo = $this->customermodel->getSingleFieldValue('mycompany', 'filename', 'id', $id);
        if (file_exists('./logo/' . $oldlogo))
            unlink('./logo/' . $oldlogo);
        $res = $this->mastermodel->deletemycompanydata('mycompany', $id);
    }

    function editmycompany() {


        $config['upload_path'] = './logo/';
        $config['allowed_types'] = 'jpg|png|gif'; // by extension, will check for whether it is an image
        $config['max_size'] = '100000'; // in kb

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('logoup')) {



            $error = array('error' => $this->upload->display_errors());
        } else {

            $data = array('upload_data' => $this->upload->data());
        }
        $this->mastermodel->updatemycompany();

        redirect('master/index/86/3');
    }

    function loadcitydiv($id) {
        $data['cityname'] = $this->mastermodel->get_data('city', $id, 'country_id', '');
        $this->load->view('Master/city_div', $data);
    }

    function showuploadform($id, $table, $fieldname) {
        $data['id'] = $id;
        $data['tablename'] = $table;
        $data['fieldname'] = $fieldname;
        $this->load->view('Master/showuploadform', $data);
    }

    function adduploadform() {
        $path = $this->input->post('subpathname');
        $dname = $this->input->post('documentname');
        $fieldid = $this->input->post('fieldid');
        $table = $this->input->post('tablename');
        $config['upload_path'] = './uploads/' . $path . ''; // server directory
        // var_dump($_FILES['userfile']);
        //$data=array_filter($_FILES['userfile']['name']);
        $config['allowed_types'] = 'gif|jpg|png|doc|pdf|txt|xls|csv|docx|xlsx'; // by extension, will check for whether it is an image
        $config['max_size'] = '100000'; // in kb
        $config['max_width'] = '1024';
        $config['max_height'] = '768';

        $this->load->library('upload', $config);
        $this->load->library('Multi_upload');

        $files = $this->multi_upload->go_upload();
        //var_dump($files);

        if (empty($files)) {
            echo "<center><b>No File Selected</b></center>";
        } else {

            $res = $this->mastermodel->uploadform($files, $path, $fieldid, $table, $dname);
            if ($res == 1) {
                echo "<center><b>File Uploaded Successfully</b></center>";
            } else {
                echo "<center><b>Server Busy ! Please Try Again Later</b></center>";
            }
        }
    }

    function checkcovercodeexist($coverid) {
        $data = $this->mastermodel->checkcovercodeexist($coverid);
        echo $data;
    }

    function autosuggestemployee() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_data('staffpersonaldetails', 'Employee', 'type', 'id');
        foreach ($employee_list as $items) {
            $name = $items['name'];
            $emp_no = $items['employeeid'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name . '-' . $emp_no . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($emp_no), $q) !== false) {
                echo '' . $name . '-' . $emp_no . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestemployeename() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_data('staffpersonaldetails', 'Employee', 'type', 'id');
        foreach ($employee_list as $items) {
            $name = $items['name'];
            $emp_no = $items['employeeid'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($emp_no), $q) !== false) {
                echo '' . $name . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestemployeecode() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_data('staffpersonaldetails', 'Employee', 'type', 'id');
        foreach ($employee_list as $items) {
            $name = $items['name'];
            $emp_no = $items['employeeid'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '#' . $name . '#' . $emp_no;
                echo "\n";
            } else if (strpos(strtolower($emp_no), $q) !== false) {
                echo '#' . $name . '#' . $emp_no;
                echo "\n";
            }
        }
    }

    function autosuggestagent() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_data('staffpersonaldetails', 'Agent', 'type', 'id');
        foreach ($employee_list as $items) {
            $name = $items['name'];
            $emp_no = $items['employeeid'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name . '-' . $emp_no . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($emp_no), $q) !== false) {
                echo '' . $name . '-' . $emp_no . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestagentcode() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_data('staffpersonaldetails', 'Agent', 'type', 'id');
        foreach ($employee_list as $items) {
            $name = $items['name'];
            $emp_no = $items['employeeid'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '#' . $name . '#' . $emp_no;
                echo "\n";
            } else if (strpos(strtolower($emp_no), $q) !== false) {
                echo '#' . $name . '#' . $emp_no;
                echo "\n";
            }
        }
    }

    function autosuggestcustomer() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $customer_list = $this->mastermodel->getcustomers();
        foreach ($customer_list as $items) {
            $name = $items['insured'];
            $customer_no = $items['code'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name . '-' . $customer_no . '#' . $items['customer_id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($customer_no), $q) !== false) {
                echo '' . $name . '-' . $customer_no . '#' . $items['customer_id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestcustomername() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $customer_list = $this->mastermodel->getcustomers();
        foreach ($customer_list as $items) {
            $name = $items['insured'];
            $customer_no = $items['code'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name . '#' . $items['customer_id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($customer_no), $q) !== false) {
                echo '' . $name . '#' . $items['customer_id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestinsuranceconame() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $ins_list = $this->mastermodel->getdatas('insurance_company', 'id');
        foreach ($ins_list as $items) {
            $name = $items['company_name'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '' . $name;
                echo "\n";
            }
        }
    }

    function autosuggestcustomercode() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $customer_list = $this->mastermodel->getcustomers();
        foreach ($customer_list as $items) {
            $name = $items['insured'];
            $customer_no = $items['code'];
            if (strpos(strtolower($name), $q) !== false) {
                echo '#' . $name . '#' . $customer_no;
                echo "\n";
            } else if (strpos(strtolower($customer_no), $q) !== false) {
                echo '#' . $name . '#' . $customer_no;
                echo "\n";
            }
        }
    }

    function autosuggestpolicyno() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $policy_list = $this->mastermodel->getdatas('policynote', 'policyno');
        foreach ($policy_list as $items) {
            $policyno = $items['policyno'];
            $quotation_ref = $items['quotation_ref'];
            if (strpos(strtolower($policyno), $q) !== false) {
                echo '' . $policyno . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($quotation_ref), $q) !== false) {
                echo '' . $policyno . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestaccount() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $account_list = $this->mastermodel->getdatas('chart_master', 'account_code');
        foreach ($account_list as $items) {
            $accountno = $items['account_code'];
            $account_name = $items['account_name'];
            if (strpos(strtolower($accountno), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($account_name), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestmainaccount() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $account_list = $this->mastermodel->get_data('chart_master', 0, 'parent');
        foreach ($account_list as $items) {
            $accountno = $items['account_code'];
            $account_name = $items['account_name'];
            if (strpos(strtolower($accountno), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $items['id'] . '#';
                echo "\n";
            } else if (strpos(strtolower($account_name), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $items['id'] . '#';
                echo "\n";
            }
        }
    }

    function autosuggestmainaccount_c() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $account_list = $this->mastermodel->get_data('chart_master', 0, 'parent');
        foreach ($account_list as $items) {
            $accountno = $items['account_code'];
            $account_name = $items['account_name'];
            if (strpos(strtolower($accountno), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#';
                echo "\n";
            } else if (strpos(strtolower($account_name), $q) !== false) {
                echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#';
                echo "\n";
            }
        }
    }

    function autosuggestsubofmainaccount($parent = 0) {
        if ($parent != 0) {
            $q = strtolower($_POST["q"]);
            if (!$q)
                return;
            $account_list = $this->mastermodel->get_data('chart_master', $parent, 'parent');
            foreach ($account_list as $items) {
                $accountno = $items['account_code'];
                $account_name = $items['account_name'];
                if (strpos(strtolower($accountno), $q) !== false) {
                    echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#';
                    echo "\n";
                } else if (strpos(strtolower($account_name), $q) !== false) {
                    echo '' . $accountno . '-' . $account_name . '#' . $accountno . '#';
                    echo "\n";
                }
            }
            die();
        }
    }

    function autosuggestcovercode() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $cover_list = $this->mastermodel->getdatas('covers', 'cover');
        foreach ($cover_list as $items) {
            $cover = $items['cover'];
            $cover_id = $items['id'];
            if (strpos(strtolower($cover), $q) !== false) {
                echo '#' . $cover . '#' . $cover_id;
                echo "\n";
            } else if (strpos(strtolower($cover_id), $q) !== false) {
                echo '#' . $cover . '#' . $cover_id;
                echo "\n";
            }
        }
    }

    function autosuggestcover() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $cover_list = $this->mastermodel->getdatas('covers', 'cover');
        foreach ($cover_list as $items) {
            $cover = $items['cover'];
            $cover_id = $items['id'];
            if (strpos(strtolower($cover), $q) !== false) {
                echo $cover . '-' . $cover_id . '#' . $cover_id . '#';
                echo "\n";
            } else if (strpos(strtolower($cover_id), $q) !== false) {
                echo $cover . '-' . $cover_id . '#' . $cover_id . '#';
                echo "\n";
            }
        }
    }

    function autosuggestqref() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $qref_list = $this->mastermodel->getdatas('broking_slip', 'id');
        foreach ($qref_list as $items) {
            $qref = $items['quotation_ref'];
            if (strpos(strtolower($qref), $q) !== false) {
                echo $qref;
                echo "\n";
            }
        }
    }
function autosuggestaccounts() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $chart_master_list = $this->mastermodel->listchartofaccounts();
        foreach ($chart_master_list as $items) {
            $code = $items['account_code'];
            $chart_account_name = $items['account_name'];
            if (strpos(strtolower($code), $q) !== false) {
                echo '' . $code . '-' . $chart_account_name . '#' . $code . '#';
                echo "\n";
            } else if (strpos(strtolower($chart_account_name), $q) !== false) {
                echo '' . $code . '-' . $chart_account_name . '#' . $code . '#';
                echo "\n";
            }
        }
    }
    function autosuggestcustomeraccounts() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $chart_master_list = $this->mastermodel->listcustomeraccounts();
        foreach ($chart_master_list as $items) {
            $code = $items['account_code'];
            $chart_account_name = $items['account_name'];
            if (strpos(strtolower($code), $q) !== false) {
                echo '' . $code . '-' . $chart_account_name . '#' . $code . '#';
                echo "\n";
            } else if (strpos(strtolower($chart_account_name), $q) !== false) {
                echo '' . $code . '-' . $chart_account_name . '#' . $code . '#';
                echo "\n";
            }
        }
    }

    function autosuggestemployeeattendance() {
        $q = strtolower($_POST["q"]);
        if (!$q)
            return;
        $employee_list = $this->mastermodel->get_employees_for_attendance();
        // var_dump($employee_list);
        foreach ($employee_list as $items) {
                $name = $items['employee_name'];
                $emp_no = $items['employee_no'];
                if (strpos(strtolower($name), $q) !== false) {
                    echo '' . $name . '-' . $emp_no . '#' . $items['employee_id'] . '#';
                    echo "\n";
                } else if (strpos(strtolower($emp_no), $q) !== false) {
                    echo '' . $name . '-' . $emp_no . '#' . $items['employee_id'] . '#';
                    echo "\n";
                }
            }
       
    }

    function post_device_attendance() {
        echo $this->mastermodel->insert_device_attendance();
    }

}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net