render('vwIndex'); $this->load->model('Common_function_model', 'common'); $this->load->model('Site_settings_model', 'siteSettings'); $this->data['is_CKEditor'] = FALSE; $this->data['is_GRID'] = TRUE; $this->load->model('Site_settings_model', 'setting'); $this->data['setting'] = $this->setting->get(1); /* Get a site setting */ $this->load->model('Main_category_model', 'main_category'); $this->data['main_categorys'] = $this->main_category->get_main_category(); $this->load->model('Product_model', 'product'); $this->data['menus']=$this->product->get_all_products_menu(); $this->data['siteSettings'] = $this->siteSettings->get_site_by_id(1,'*'); $this->autologin(); $this->data['totalItem']=0; $this->data['totalAmount']=0; $product_data = array(); if($this->session->userdata('f_id')) { $product_data = $this->common->check_to_cart($this->session->userdata('f_id')); } else { if(isset($_COOKIE['cart_items'])) { $product_data = unserialize($_COOKIE['cart_items']); } } $total_cost=0; $gran_total=0; if($product_data!="") { foreach ($product_data as $product) { $total_cost = $product['price']* $product['quantity']; /* $total_cost = $product['shipping_cost']; $total_cost = $product['price']* $product['quantity']; if($total_cost < 300) { $total_cost = $total_cost+$product['shipping_cost']; }*/ $gran_total= $gran_total+$total_cost; //($total_cost*1.05); } } $this->data['totalAmount'] =$gran_total; $this->data['totalItem'] = count($product_data); //$this->data['recaptcha'] = $this->recaptcha->getWidget(); //$this->data['recaptcha_script'] = $this->recaptcha->getScriptTag(); } protected function render($the_view = NULL, $template = 'front_master') { // if ($the_view == "vwHome") // { // $template="index_master"; // } if ($template == 'json' || $this->input->is_ajax_request()) { $this->output->set_content_type("application/json")->set_status_header(200)->set_output($this->data); } elseif (is_null($template)) { $this->load->view($the_view, $this->data); } else { $this->data['view_content'] = (is_null($the_view)) ? '' : $this->load->view($the_view, $this->data, TRUE); $this->load->view('templates/' . $template . '_view', $this->data); } } /** set a page title */ public function setPageTitle($page_title) { $this->data['page_title'] = $page_title; } // protected function getSql() // { // return $sql_details = array( // 'user' => $this->db->username, // 'pass' => $this->db->password, // 'db' => $this->db->database, // 'host' => $this->db->hostname // ); // } public function autologin() { if (!$this->session->userdata('f_id')) { $email = $this->input->cookie('user_email'); $pass = $this->input->cookie('user_password'); $remember_me = $this->input->cookie('remember_me'); if ($remember_me) { $result = $this->db->get_where('user', array( 'email' => $email, 'is_active' => 1 ))->result_object(); if (!empty($result) && count($result)) { $result = $result[0]; $dbPass = $this->encryption->decrypt($result->password); if ($dbPass == $pass) { $user_data = array( 'f_id' => $result->id, 'f_name' => $result->first_name, 'f_email' => $result->email, 'f_phone_number' => $result->phone_number, 'f_is_login' => true ); $this->session->set_userdata($user_data); } } } } } } class Auth_Controller extends MY_Controller { //protected $data = array(); public function __construct() { parent::__construct(); $this->load->library('form_validation'); $this->load->model('Site_settings_model', 'setting'); /** get iste setting */ $this->data['setting'] = $this->setting->get(1); /* Get a site setting */ } protected function render($the_view = NULL, $template = 'admin_master') { parent::render($the_view, $template); } } class Admin_Controller extends MY_Controller { protected $data = array(); public function __construct() { parent::__construct(); if(!$this->ion_auth->logged_in()) { redirect('admin','refresh'); } $this->load->library('form_validation'); $this->load->model('Site_settings_model', 'setting'); /** get iste setting */ $this->data['setting'] = $this->setting->get(1); /* Get a site setting */ } protected function render($the_view = NULL, $template = 'admin_master') { parent::render($the_view, $template); } } data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->data['banners'] = $this->db->order_by('display_order', 'asc')->get_where('banner', array('is_active' => 1))->result_object(); $this->render('vwHome'); } public function aboutUs() { $pageInfo = get_page('About Us'); $this->data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->data['about'] = $pageInfo; $this->data['teams'] = $this->db->order_by('display_order', 'asc')->get_where('team', array('is_active' => 1))->result_object(); $this->data['clients'] = $this->db->order_by('display_order', 'asc')->get_where('clients', array('is_active' => 1))->result_object(); $this->render('vwAboutUs'); } public function news($slug='') { if (!empty($slug)) { /* display news detail page & check if slug is correct */ $newsDetail = $this->db->get_where('news', array('is_active' => 1, 'blog_slug' => $slug))->row(); if (!empty($newsDetail)) { $this->data['title'] = $newsDetail->blog_title; $this->data['mTitle'] = $newsDetail->meta_title; $this->data['keyword'] = $newsDetail->meta_keyword; $this->data['desc'] = $newsDetail->meta_description; $this->data['news'] = $newsDetail; $this->render('vwNewsDetail'); } else { redirect(base_url('news'),'refresh'); } } else { //display news listing page $pageInfo = get_page('News'); $this->data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->data['news'] = $this->db->order_by('blog_date', 'desc')->get_where('news', array('is_active' => 1))->result_object(); $this->render('vwNewsListing'); } } public function contact() { $pageInfo = get_page('Contact Us'); $this->data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->render('vwContact'); } public function careers() { $pageInfo = get_page('Careers'); $this->data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->data['careers'] = $pageInfo; $this->render('vwCareer'); } public function contactEnquiry() { $status = array(); if ($this->input->is_ajax_request()) { $this->form_validation->set_rules('name', 'name', 'trim|required|xss_clean'); $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean'); $this->form_validation->set_rules('number', 'number', 'trim|required|numeric|xss_clean'); $this->form_validation->set_rules('message', 'message', 'trim|required|xss_clean'); // $this->form_validation->set_rules('g-recaptcha-response', 'google recaptcha', 'trim|xss_clean|required|callback_check_captcha'); if ($this->form_validation->run() === FALSE) { $status = array('error' => true, 'type' => 'field'); $status = array_merge($this->form_validation->error_array(), $status); } else { $object = array( 'enquiry_name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'phone_number' => $this->input->post('number'), 'message' => $this->input->post('message'), 'created_at' => date('Y-m-d H:i:s'), ); $this->db->insert('enquiry', $object); if ($this->db->affected_rows()) { $isMailSend = $this->Email_sending->contact(); $status = array( 'error' => false, 'mail' => $isMailSend, 'msg' => 'Thank you! We will revert back to you asap.' ); } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } } } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } echo json_encode($status); } public function careerEnquiry() { $status = array(); if ($this->input->is_ajax_request()) { $this->form_validation->set_rules('name', 'name', 'trim|required|xss_clean'); $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean'); $this->form_validation->set_rules('phone', 'phone', 'trim|required|numeric|xss_clean'); $this->form_validation->set_rules('uploadcv', 'cv', 'trim|xss_clean|callback_check_upload_cv'); $this->form_validation->set_rules('message', 'message', 'trim|required|xss_clean'); // $this->form_validation->set_rules('g-recaptcha-response', 'google recaptcha', 'trim|xss_clean|required|callback_check_captcha'); if ($this->form_validation->run() === FALSE) { $status = array('error' => true, 'type' => 'field'); $status = array_merge($this->form_validation->error_array(), $status); } else { $object = array( 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'phone_number' => $this->input->post('phone'), 'message' => $this->input->post('message'), 'created_at' => date('Y-m-d H:i:s'), ); $uploadPath = './uploads/cv'; if ($_FILES['uploadcv']['size']) { $fileName = 'cv_'.time().'.'.pathinfo($_FILES['uploadcv']['name'], PATHINFO_EXTENSION); if (move_uploaded_file($_FILES['uploadcv']['tmp_name'], $uploadPath.'/'.$fileName)) { $object['cv_path'] = $uploadPath.'/'.$fileName; } } $this->db->insert('careers_enquiry', $object); if ($this->db->affected_rows()) { $isMailSend = $this->Email_sending->career($object['cv_path']); $status = array( 'error' => false, 'mail' => $isMailSend, 'msg' => 'Thank you! We will revert back to you asap.' ); } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } } } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } echo json_encode($status); } public function newsletter() { $status = array(); if ($this->input->is_ajax_request()) { $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|xss_clean'); // $this->form_validation->set_rules('g-recaptcha-response', 'google recaptcha', 'trim|xss_clean|required|callback_check_captcha'); if ($this->form_validation->run() === FALSE) { $status = array('error' => true, 'type' => 'field'); $status = array_merge($this->form_validation->error_array(), $status); } else { //check if email exist $email = $this->input->post('email'); $isEmailExist = $this->db->get_where('subscription', array('email_address' => $email))->num_rows(); if (!$isEmailExist) { $object = array( 'email_address' => $this->input->post('email'), 'is_active' => 1, 'created_at' => date('Y-m-d H:i:s'), ); $this->db->insert('subscription', $object); if ($this->db->affected_rows()) { //$isMailSend = $this->Email_sending->contact(); $isMailSend = true; $status = array( 'error' => false, 'mail' => $isMailSend, 'msg' => 'Thank you for subscribing.' ); } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Email is already subscribed' ); } } } else { $status = array( 'error' => true, 'type' => 'final', 'msg' => 'Something went wrong' ); } echo json_encode($status); } public function services() { $pageInfo = get_page('Services'); $this->data['title'] = $pageInfo->page_title; $this->data['mTitle'] = $pageInfo->meta_title; $this->data['keyword'] = $pageInfo->meta_keyword; $this->data['desc'] = $pageInfo->meta_description; $this->data['servicePage'] = $pageInfo; $this->data['serviceCat'] = $this->db->query("SELECT a.*, (SELECT count(*) FROM services as b WHERE b.service_id = a.id) as totalCount FROM service_categories as a WHERE a.is_active = 1 HAVING totalCount > 0 ORDER BY display_order")->result_object(); $this->render('vwServices'); } public function check_upload_cv() { // $allowedExts = array("jpeg", "jpg", "png", "JPG", "JPEG", "PNG"); // $allowedTypes = array(IMAGETYPE_PNG, IMAGETYPE_JPEG); $allowedExts = array("pdf", "PDF", "doc", "DOC", "docx", "DOCX"); $allowedTypes = array('application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'); if ($_FILES['uploadcv']['size']) { //if image selected $extension = pathinfo($_FILES["uploadcv"]["name"], PATHINFO_EXTENSION); $detectedType = mime_content_type($_FILES['uploadcv']['tmp_name']); $type = $_FILES['uploadcv']['type']; if (!in_array($detectedType, $allowedTypes)) { $this->form_validation->set_message('check_upload_cv', 'The CV content is invalid'); return FALSE; } elseif (filesize($_FILES['uploadcv']['tmp_name']) > 2000000) { $this->form_validation->set_message('check_upload_cv', 'The CV file size shoud not exceed 2MB!'); return FALSE; } elseif (!in_array($extension, $allowedExts)) { $this->form_validation->set_message('check_upload_cv', "The CV file extension is invalid"); return FALSE; } else { return TRUE; } } else { $this->form_validation->set_message('check_upload_cv', "Please select your CV"); return FALSE; } } public function check_captcha($str) { $secret = captcha_secret_key; $verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$str}"); $captcha_success=json_decode($verify); if ($captcha_success->success==false) { $this->form_validation->set_message('check_captcha', "Please select captcha again"); return FALSE; } else { return TRUE; } } /*public function send_email() { $res = $this->Email_sending->test(array( 'to' => 'alfaizm19@gmail.com', 'from' => 'alfaizm19@gmail.com', 'name' => "Alfaiz", 'email' => 'alfaizm19@gmail.com', 'phone' => '9876543210', 'msg' => 'test msg' )); echo "
";
        print_r($res);
    }*/
}

?>
config->load('assets', TRUE);
        $path = $ci->config->item($prifix);


        if (isset($css) && !empty($css) && !is_null($path)) {
            if (is_array($css)) {
                foreach ($css as $css_key => $css_value) {
                    $get_css .= '' . "\n";
                }
            } else {
                $get_css .= '' . "\n";
            }
        }
        return $get_css;
    }

}


if (!function_exists('get_js')) {

    /**
     * Create a link from a js array or string
     * HTTP_ASSETS_PATH_ADMIN_JS set a base path of js folder ex assets/client/js admin or client as u want
     * @param Array $js accept a array
     * @param Sting $js accept a  signal string
     * @param String $prifix use both of them admin and client admin/client as u want
     * @return void
     */
    function get_js($js = NULl, $prifix = 'client') {
        // $CI =& get_instance();
        $get_js = "";
        //$path  = ($prifix == 'admin') ? HTTP_ASSETS_PATH_ADMIN_JS : HTTP_ASSETS_PATH_CLIENT_JS ;
        $ci = & get_instance();
        $ci->config->load('assets', TRUE);
        $path = $ci->config->item($prifix);
        if (isset($js) && !empty($js)) {
            if (is_array($js)) {
                foreach ($js as $js_key => $js_value) {
                    $get_js .= '' . "\n";
                }
            } else {
                $get_js .= '' . "\n";
            }
        }
        return $get_js;
    }

}


if (!function_exists('get_input')) {

    /**
     * When server side validation is used , redirect to curent page to refill to input value to used
     * postdata key to use a session
     * @param String $key input name
     * @param string $default input defalult value
     */
    function get_input($key = NULl, $default = '') {
        $ci = & get_instance();
        $ci->load->library('session');


        $poatdata = $ci->session->flashdata('postdata');

        if (array_key_exists($key, $ci->input->post())) {
            return $ci->input->post($key);
        }

        if ($key !== NULL AND ! empty($poatdata)) {
            if (array_key_exists($key, $poatdata)) {
                return $poatdata[$key];
            }
        }

        return $default;
    }

}


if (!function_exists('get_checkbox')) {

    /**
     * Rechecked a check box
     * @param String $key input name
     * @param string $value checkbox box value
     * @return void
     */
    function get_checkbox($key = NULl, $value = '', $default = '') {

        $ci = & get_instance();
        $ci->load->library('session');
        $poatdata = $ci->session->flashdata('postdata');

        if ($default) {
            return "checked";
        }

        if (!isset($poatdata[$key]) && !isset($_POST[$key])) {
            return FALSE;
        }

        if ((is_array($poatdata[$key]) && in_array($value, $poatdata[$key], TRUE) ) OR isset($_POST[$key])) {
            return "checked";
        } else {
            if ($key !== NULL AND ! empty($poatdata)) {
                if (array_key_exists($key, $poatdata) AND $poatdata[$key] !== "" AND ! is_array($poatdata[$key])) {
                    return "checked";
                }
            }
        }
        /** if $default is true then is checked */
        return $default;
    }

}


if (!function_exists('has_error')) { /**
 * Check a server side form validation and input need to display a error
 * @param  String $key as input name
 * @param  String $default
 * @return NUll
 */

    function has_error($key = NULl, $default = NULL) {
        $ci = & get_instance();
        $ci->load->library('session');
        $errors = $ci->session->flashdata('error');

        if (is_array($errors) && !empty($errors)) {
            if (array_key_exists($key, $errors)) {
                return $errors[$key];
            }
        }
        return $default;
    }

}


if (!function_exists('display_flash')) {

    /**
     * Get a flash message from name
     * @param String $name
     * @return void
     */
    function display_flash($name) {
        $CI = & get_instance();
        if ($CI->session->flashdata($name)) {
            $flash = $CI->session->flashdata($name);
            if (is_array($flash['message'])) {
                $msg = '';
            } else {
                return '';
            }
        }
    }

}

if (!function_exists('set_flash')) {

    /**
     * set a falsh message
     * @param String $name
     * @param String $message_type calss name ex danger,success,info,warning
     * @param String $message Only singale OR multipal as array message
     * @param Array  $message Only singale string OR multipal as array message
     * @return void
     */
    function set_flash($name, $message_type, $message) {
        $CI = & get_instance();
        $CI->session->set_flashdata($name, array('message_type' => $message_type, 'message' => $message));
    }

}

if (!function_exists('is_menu_active')) {

    /**
     * Set a active class fore curen controller
     * @param String $controller
     * @return void
     */
    function is_menu_active($controller, $class = NUll) {
        $CI = & get_instance();

        if (is_array($controller) && in_array($CI->router->fetch_class(), $controller)) {
            $controller_class = $CI->router->fetch_class();
            return ($controller_class == array_key_exists($controller_class, $controller)) ? config_item('active_class') . ' ' . $class : '';
        }

        $controller_class = $CI->router->fetch_class();


        return ($controller_class == $controller) ? config_item('active_class') . ' ' . $class : '';
    }

}

if (!function_exists('get_subnav')) {

    /**
     * Set a active class fore curen controller
     * @param String $controller
     * @return void
     */
    function get_subnav($method, $text = NUll) {
        $CI = & get_instance();
        $controller_class = $CI->router->fetch_class();
        $li = '
		
		';
        return $li;
    }

}



if (!function_exists('is_active')) {

    /**
     * Set a active in grid
     * @param String $is_active is a string array of id and activer
     * @return void
     */
    function is_active($row, $method = "is_active") {
        if ($row['is_active'] == 1) {
            return '
'; } else { return '
'; } } } if (!function_exists('get_delete_all')) { /** * Set a active in grid * @param String $_id is id of curent row * @return void */ function get_delete_all($_id) { return ''; } } if (!function_exists('get_edit')) { /** * Set a active in grid * @param String $_id is id of curent row * @return void */ function get_edit($_id, $url) { return "
"; } } if (!function_exists('get_delete')) { /** * Set a active in grid * @param String $_id is id of curent row * @return void */ function get_delete($_id) { return '
'; } } if (!function_exists('get_image_path')) { /** * Set a active in grid * @param String $_id is id of curent row * @return void */ function get_image_path($image_path, $width = 75) { return "
"; } function get_video_path($image_path, $width = 75) { return "
"; } } if (!function_exists('get_display_order')) { /** * Set a active disply order * @param String $_id is id of curent row * @return void */ function get_display_order($display_order) { return "
"; } } if (!function_exists('get_display_order_home')) { /** * Set a active disply order * @param String $_id is id of curent row * @return void */ function get_display_order_home($display_order_data) { return "
"; } } if (!function_exists('get_format_date')) { /** * Set a date formate * @param array $_data is array of curent row or data * @return void */ function get_format_date($date) { if ($date['date_format'] == "0000-00-00") { return '
'; } else { return '
' . date("d M Y", strtotime($date['date_format'])) . '
'; } } } if (!function_exists('get_view')) { /* set view link */ function get_view($id, $url) { return "
"; } } if (!function_exists('get_total_image_count')) { /* set total image count row wise */ function get_total_image_count($image_count) { return "
" . $image_count["image_count"] . "
"; } } if (!function_exists('get_total_comment_count')) { /* set total image count row wise */ function get_total_comment_count($data) { return "
" . $data["image_count"] . "
"; } } if (!function_exists('get_total_category_count')) { /* set total image count row wise */ function get_total_category_count($category_count) { return "
" . $category_count["category_count"] . "
"; } } if (!function_exists('get_category_details')) { /* set total image count row wise */ function get_category_details($categoryId) { $CI = & get_instance(); $categoryDetails = $CI->db->where('id',$categoryId)->get('main_category_new')->row(); return $categoryDetails; } } if (!function_exists('get_total_gift_count')) { /* set total image count row wise */ function get_total_gift_count($image_count) { return "
" . $image_count["image_count"] . "
"; } } if (!function_exists('get_media_promo')) { function get_media_promo($news_media_path, $width) { $media = explode('#', $news_media_path); if ($media[3] == 1) { return "
"; } else if ($media[3] == 3) { return "
" . $media[1] . "
"; } else if ($media[3] == 2) { return "
"; } } } if (!function_exists('get_media')) { function get_media($news_media_path, $width) { $media = explode('#', $news_media_path); if ($media[3] == 1) { return "
"; } else if ($media[3] == 3) { return "
"; } else if ($media[3] == 2) { return "
" . $media[1] . "
"; } } } if (!function_exists('get_is_status')) { function get_is_status($is_status) { if ($is_status == 1) { return "
Sent
"; } else { return "
Draft
"; } } } /* * This function create watermark image. */ if (!function_exists('create_watermark_image')) { // Ex call :: create_watermark_image($this->images->getdata('banner_image'),$this->data['setting']->website_frontend_logo, $padding = 0, $width = 0, $hight = 0); function create_watermark_image($main_image_path, $watermark_image, $padding = 0, $width = 0, $hight = 0) { if ($main_image_path != '' && $watermark_image != '') { $CI = & get_instance(); $configWatermark = array(); $CI->load->library('image_lib'); $configWatermark['image_library'] = 'gd2'; $configWatermark['source_image'] = $main_image_path; $configWatermark['wm_type'] = 'overlay'; $configWatermark['wm_overlay_path'] = $watermark_image; $configWatermark['wm_vrt_alignment'] = 'bottom'; $configWatermark['wm_hor_alignment'] = 'right'; $configWatermark['wm_padding'] = $padding; $CI->image_lib->initialize($configWatermark); if (!$CI->image_lib->watermark()) { echo $CI->image_lib->display_errors(); } $CI->image_lib->clear(); } } } /* * This function create thumb image. */ if (!function_exists('create_thumb_image')) { // Ex call :: create_thumb_image($this->images->getdata('banner_image'), $thumb_dir, $width = 200, $height = 200); function create_thumb_image($main_image_path, $thumb_dir, $width = 100, $height = 100) { if ($main_image_path != '' && $thumb_dir != '') { if (!is_dir($thumb_dir)) { mkdir($thumb_dir, 0755); } $CI = & get_instance(); $CI->load->library('image_lib'); $configThumb = array(); $configThumb['image_library'] = 'gd2'; $configThumb['source_image'] = $main_image_path; $configThumb['new_image'] = $thumb_dir; $configThumb['maintain_ratio'] = FALSE; $configThumb['width'] = $width; $configThumb['height'] = $height; $CI->image_lib->initialize($configThumb); if (!$CI->image_lib->resize()) { echo $CI->image_lib->display_errors(); } $CI->image_lib->clear(); return str_replace("./", "", $thumb_dir . $main_image_path); } } } /* * This function get user ipaddress. */ if (!function_exists('getUserIpAddr')) { function getUserIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //ip from share internet $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //ip pass from proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $_SERVER['REMOTE_ADDR']; } } /* * This function get days,months And years. */ if (!function_exists('get_day_ago')) { function get_day_ago($date) { $CI = & get_instance(); $datetime1 = new DateTime($date); $datetime2 = new DateTime("now"); $interval = $datetime1->diff($datetime2); if ($interval->format('%R%a') == 0) { echo 'Today'; } else if ($interval->format('%R%a') == 1) { echo 'A day ago'; } else if ($interval->format('%R%a') == -1) { echo 'After ' . $interval->format('%a') . ' day'; } else if ($interval->format('%R%a') < 30) { echo $interval->format('%a') . ' days ago'; } else if ($interval->format('%R%y') == 1) { echo $interval->format('%y') . ' year ago'; } else if ($interval->format('%R%y') > 1) { echo $interval->format('%y') . ' years ago'; } else if ($interval->format('%R%y%m') == 1) { echo $interval->format('%m') . ' month ago'; } else if ($interval->format('%R%y%m') > 1) { echo $interval->format('%m') . ' months ago'; } else { echo 'After ' . $interval->format('%a') . ' days'; } //return $date; } } /* * This function get admin image. */ function file_exists_admin($filename) { $filename_url = base_url(); if (file_exists($filename) && $filename != '') { $admin_image = $filename; } else { $admin_image = ADMIN_IMAGE; } return $filename_url . $admin_image; } if (!function_exists('get_related_products')) { function get_related_products($cheked_ids) { $ids = $cheked_ids; $CI = & get_instance(); $CI->db->where_in('id', $ids); $CI->db->order_by("display_order", "asc"); $result = $CI->db->get('product'); return $result->result_array(); } } if (!function_exists('get_package_features')) { function get_package_features($cheked_ids) { $ids = $cheked_ids; $CI = & get_instance(); $CI->db->where_in('id', $ids); $CI->db->order_by("display_order", "asc"); $result = $CI->db->get('package_features'); return $result->result_array(); } } if (!function_exists('get_all_blog_media_front')) { function get_all_blog_media_front($id) { $CI = & get_instance(); $CI->db->where('blog_id', $id); $result = $CI->db->get('blog_media'); return ($result->num_rows() > 0) ? $result->result_array() : ''; } } if (!function_exists('get_all_news_media_front')) { function get_all_news_media_front($id) { $CI = & get_instance(); $CI->db->where('blog_id', $id); $result = $CI->db->get('news_media'); return ($result->num_rows() > 0) ? $result->result_array() : ''; } } if (!function_exists('google_analytics')) { function google_analytics() { $CI = & get_instance(); $CI->db->where('id', 1); $result = $CI->db->get('google_analytics'); $data = $result->row(); if (!empty($data)) { return $data->google_analytics_code; } else { return false; } } } if (!function_exists('isSubscriber')) { function isSubscriber($userEmail) { $CI = & get_instance(); $CI->db->where('email_address', $userEmail); $result = $CI->db->get('subscription'); return $result->row(); } } if (!function_exists('get_related_colors')) { function get_related_colors($cheked_ids) { $ids = $cheked_ids; $CI = & get_instance(); $CI->db->where_in('id', $ids); $result = $CI->db->get('color'); return $result->result_array(); } } if (!function_exists('get_related_occassions')) { function get_related_occassions($cheked_ids) { $ids = $cheked_ids; $CI = & get_instance(); $CI->db->where_in('id', $ids); $result = $CI->db->get('occassion'); return $result->result_array(); } } // if (!function_exists('check_num')) { // function check_num($num) { // if (is_float($num)) { // return $num; // } else { // return number_format($num); // } // } // } if (!function_exists('count_cart')) { function count_cart() { $CI = & get_instance(); $tempCartId = $CI->input->cookie('my_cookie',true); if(!$tempCartId) { $cookie = array('name' => 'my_cookie', 'value' => md5(time()), 'expire' => '360000'); $CI->input->set_cookie($cookie); } $userSess = $CI->session->userdata('user_sess'); if (!empty($userSess)) { $userId = $userSess['userId']; $CI->db->where_in('user_id', $userId); } else { $tempCartId = $CI->input->cookie('my_cookie',true); $CI->db->where_in('temp_cart_id', $tempCartId); } $result = $CI->db->get('cart'); if ($result->num_rows()) { if (!empty($userSess) OR !empty($tempCartId)) { return $result->num_rows(); } else { return 0; } } else { return 0; } } } if (!function_exists('tour_price')) { function tour_price($tourId, $optId, $type, $curr) { $CI = & get_instance(); $result = $CI->db->get_where('tour_options', array( 'id' => $optId, 'tour_id' => $tourId )); if ($result->num_rows()) { $data = $result->row(); $transfer_cost_aed = 0; $transfer_cost_usd = 0; $guest_limit = 0; if ($type == 'without_transfer') { $adult_aed = $data->adult_aed; $adult_usd = $data->adult_usd; $child_aed = $data->child_aed; $child_usd = $data->child_usd; $dis = $data->discount; } elseif ($type == 'sharing_transfer') { $adult_aed = $data->st_adult_aed; $adult_usd = $data->st_adult_usd; $child_aed = $data->st_child_aed; $child_usd = $data->st_child_usd; $dis = $data->st_discount; } else { $adult_aed = $data->pt_adult_aed; $adult_usd = $data->pt_adult_usd; $child_aed = $data->pt_child_aed; $child_usd = $data->pt_child_usd; $dis = $data->pt_discount; $transfer_cost_aed = $data->transfer_cost; $transfer_cost_usd = $data->transfer_cost_usd; $guest_limit = $data->guest_limit; } if ($dis > 0) { $adult_aed = $adult_aed - ($adult_aed*$dis/100); $adult_usd = $adult_aed - ($adult_aed*$dis/100); $child_aed = $child_aed - ($child_aed*$dis/100); $child_usd = $child_aed - ($child_aed*$dis/100); } if ($curr == 'AED') { return array( 'adult' => $adult_aed, 'child' => $child_aed, 'transfer_cost' => $transfer_cost_aed, 'guest_limit' => $guest_limit ); } else { //USD return array( 'adult' => $adult_usd, 'child' => $child_usd, 'transfer_cost' => $transfer_cost_usd, 'guest_limit' => $guest_limit ); } } else { return 0; } } } if (!function_exists('get_currency')) { function get_currency() { $CI = & get_instance(); $curr = $CI->input->cookie('currency',true); if (!empty($curr)) { return $curr; } else { return 'AED'; } } } if (!function_exists('set_cart_cookie')) { $CI = & get_instance(); $tempCartId = $CI->input->cookie('my_cookie',true); function set_cart_cookie() { global $tempCartId; $CI = & get_instance(); if(!$tempCartId) { $cookie = array('name' => 'my_cookie', 'value' => md5(time()), 'expire' => '360000'); $CI->input->set_cookie($cookie); } } if (empty($tempCartId)) { set_cart_cookie(); } } if (!function_exists('get_cart_stock')) { function get_cart_stock($pId) { $CI = & get_instance(); $tempCartId = $CI->input->cookie('my_cookie',true); $userSess = $CI->session->userdata('user_sess'); if (!empty($userSess)) { $userId = $userSess['userId']; $qty = $CI->db->get_where('cart', array( 'user_id' => $userId, 'product_id' => $pId ))->row('quantity'); } else { $qty = $CI->db->get_where('cart', array( 'temp_cart_id' => $tempCartId, 'product_id' => $pId ))->row('quantity'); } if (!empty($qty)) { return $qty; } else { return 0; } } } if (!function_exists('get_cart_id')) { function get_cart_id($pId) { $CI = & get_instance(); $tempCartId = $CI->input->cookie('my_cookie',true); $userSess = $CI->session->userdata('user_sess'); if (!empty($userSess)) { $userId = $userSess['userId']; $id = $CI->db->get_where('cart', array( 'user_id' => $userId, 'product_id' => $pId ))->row('id'); } else { $id = $CI->db->get_where('cart', array( 'temp_cart_id' => $tempCartId, 'product_id' => $pId ))->row('id'); } return $id; } } if (!function_exists('user_info')) { function user_info($id) { $CI = & get_instance(); $data = $CI->db->get_where('user', array( 'id' => $id ))->row(); if (!empty($data)) { return $data; } else { return false; } } } if (!function_exists('cart_weight_subTotal')) { function cart_weight_subTotal($updatedTempCartId='') { $CI = & get_instance(); $curr = get_currency(); if (!empty($updatedTempCartId)) { $tempCartId = $updatedTempCartId; } else { $tempCartId = $CI->input->cookie('my_cookie',true); } $userSess = $CI->session->userdata('user_sess'); if (!empty($userSess)) { $userId = $userSess['userId']; $products = $CI->db->query("SELECT a.*, b.product_name, b.slug, b.sku_code, b.stock, b.price_aed, b.price_usd, b.image_path, b.weight FROM cart as a INNER JOIN product as b ON a.product_id = b.id WHERE b.is_active = 1 AND a.user_id = '".$userId."' ")->result_object(); } else { $products = $CI->db->query("SELECT a.*, b.product_name, b.slug, b.sku_code, b.stock, b.price_aed, b.price_usd, b.image_path, b.weight FROM cart as a INNER JOIN product as b ON a.product_id = b.id WHERE b.is_active = 1 AND a.temp_cart_id = '".$tempCartId."' ")->result_object(); } $weight = 0; $sub_total = 0; if (!empty($products)) { foreach ($products as $prod) { if ($prod->type == 'product') { $weight += $prod->quantity * $prod->weight; } if ($curr == 'AED') { $sub_total += $prod->quantity * $prod->price_aed; } else { $sub_total += $prod->quantity * $prod->price_usd; } } return array( 'weight' => $weight, 'sub_total' => $sub_total ); } else { return array( 'weight' => $weight, 'sub_total' => $sub_total ); } } } if (!function_exists('update_cart_user_id')) { function update_cart_user_id($userId) { $CI = & get_instance(); $tempCartId = $CI->input->cookie('my_cookie',true); $CI->db->where('temp_cart_id', $tempCartId); $CI->db->update('cart', array( 'user_id' => $userId )); } } if (!function_exists('get_page')) { function get_page($pageName) { $CI = & get_instance(); if (!empty($pageName)) { $data = $CI->db->get_where('page', array( 'page_name' => $pageName ))->row(); if (!empty($data)) { return $data; } else { return false; } } else { return false; } } } if (!function_exists('get_country_iso')) { function get_country_iso($countryId) { $CI = & get_instance(); if (!empty($countryId)) { $data = $CI->db->get_where('country', array( 'id' => $countryId ))->row('iso'); if (!empty($data)) { return $data; } else { return false; } } else { return false; } } } if (!function_exists('get_province')) { function get_province($province) { $CI = & get_instance(); if (!empty($province)) { $data = $CI->db->get_where('province', array( 'id' => $province ))->row('province'); if (!empty($data)) { return $data; } else { return false; } } else { return false; } } } if (!function_exists('check_num')) { function check_num($int) { if (round($int, 0) == $int) { return number_format($int); } else { return $int; } } } if (!function_exists('count_comment')) { function count_comment($blogId) { $CI = & get_instance(); if (!empty($blogId)) { $data = $CI->db->get_where('blog_comment', array( 'blog_id' => $blogId, 'is_active' => 1 ))->num_rows('province'); return $data; } else { return 0; } } }

A PHP Error was encountered

Severity:

Message:

Filename:

Line Number:

Backtrace:

File:
Line:
Function:

A PHP Error was encountered

Severity:

Message:

Filename:

Line Number:

Backtrace:

File:
Line:
Function:

Database Error