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/symphony-solusi.co.id/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/symphony-solusi.co.id/public_html/application/controllers/Product.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');



class Product extends Public_Controller {



	public function __construct() {

		parent::__construct();

		$this->session->set_userdata('site_lang','indonesian');

	}



	public function get($alias = NULL) { 



		if ($alias == NULL) { show_404(); }



		//check if product exist 

		$this->db->select('*')->from('products')->where('alias', $alias)->where('product_status', 1);

		$count = $this->db->get()->num_rows();

		if ($count == 0) { show_404(); }



		//set url to session, so can be access by cart page, continue shopping link button

		$this->session->set_userdata('productpage_to_cart', base_url() . 'product/' . $alias);



		//get this product data

		$this->db->select('*')->from('products')->where('alias', $alias);

		$data['product'] = $this->db->get()->row(); 



		//get this product details

		$product_id = (int) $data['product']->id_products;

		$this->db->select('*')->from('product_details')->where('product_id', $product_id);

		$data['product_details'] = $this->db->get()->result();  



		//get initial product code (SKU), weight, and stock

		$this->db->select('id_product_details, sku, weight, stock')->from('product_details')->where('product_id', $product_id)->order_by('id_product_details', 'ASC')->limit(1);	

		$product_details = $this->db->get()->row();

		// $data['sku'] = $product_details->sku;

		// $data['weight'] = $product_details->weight;

		// $data['stock'] = $product_details->stock;



		//get product code (SKU), weight, and stock display status

		$this->db->select('show_product_sku, show_product_weight, show_product_stock')->from('configuration')->where('id_configuration', 1);

		$display_status = $this->db->get()->row();

		$data['display_sku'] = $display_status->show_product_sku;

		$data['display_weight'] = $display_status->show_product_weight;

		$data['display_stock'] = $display_status->show_product_stock;



		$this->load->helper('product');

		$category_discount_percentage = category_discount($product_id);



		//INITIAL PRODUCT PRICE 

		if(isset($this->session->userdata('customer')['customer_id'])) {



			//customer is logged in

			//get product detail id (for 1st detail only)

			$this->db->select('id_product_details')->from('product_details')->where('product_id', $product_id)->limit(1);

			$id_product_detail = $this->db->get()->row()->id_product_details;



			//check if customer is a reseller. if reseller use reseller price

			$this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id']);

			$reseller_id = $this->db->get()->row()->reseller_id;



			//check if reseller product price already available (already input by admin). If not, display retail price

			$this->db->select('price')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);

			$count_reseller_price = $this->db->get()->num_rows();



			if($reseller_id != NULL && $count_reseller_price > 0) {

				

				//customer is reseller, and admin already input the reseller product price, use reseller price

				$this->db->select('price, min_quantity')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $id_product_detail);

				$reseller_data = $this->db->get()->row();

				$data['price'] = $reseller_data->price;

				$data['discounted_price'] = 0;

				$data['reseller_min_quantity'] = $reseller_data->min_quantity;



			} elseif($reseller_id == NULL || $count_reseller_price == 0) {

				

				//customer is regular customer, or admin not yet input reseller product price

				if($category_discount_percentage != NULL) {

					//category discount is active

					$this->db->select('price, sku, attributes')->from('product_details')->where('product_id', $product_id)->order_by('id_product_details', 'ASC')->limit(1);

					$prices = $this->db->get()->row(); 

					$data['price'] = $prices->price;

					$data['discounted_price'] = $prices->price - ($prices->price * $category_discount_percentage/100);

				} else {

					//get the initial product retail price from stocks table

					$this->db->select('price, discounted_price, sku, attributes')->from('product_details')->where('product_id', $product_id)->order_by('id_product_details', 'ASC')->limit(1);

					$prices = $this->db->get()->row(); 

					$data['price'] = $prices->price;

					$data['discounted_price'] = $prices->discounted_price;	

				}

			}

		} else {

			//customer is not logged in

			if($category_discount_percentage != NULL) {

				//category discount is active

				$this->db->select('price, sku, attributes')->from('product_details')->where('product_id', $product_id)->order_by('id_product_details', 'ASC')->limit(1);

				$prices = $this->db->get()->row(); 

				$data['price'] = $prices->price;

				$data['discounted_price'] = $prices->price - ($prices->price * $category_discount_percentage/100);

			} else {

				//get the initial product price from stocks table

				$this->db->select('price, discounted_price, sku, attributes')->from('product_details')->where('product_id', $product_id)->order_by('id_product_details', 'ASC')->limit(1);

				$prices = $this->db->get()->row(); 

				// $data['price'] = $prices->price;

				// $data['discounted_price'] = $prices->discounted_price;

			}

		}



		//QUANTITY DISCOUNT

		//check whether quantity_discount_active is no, retail only, reseller only, or both

		$quantity_discount_active = $data['product']->quantity_discount_active;

		//check quantity discount if exist

		$this->db->select('id_quantity_discount')->from('quantity_discount')->where('product_id', $product_id);

		$count_quantity_discount = $this->db->get()->num_rows();



		if(isset($this->session->userdata('customer')['customer_id'])) {

			//customer is loggedin

			//check if customer is a reseller

			$this->db->select('reseller_id')->from('customers')->where('id_customers', $this->session->userdata('customer')['customer_id']);

			$reseller_id = $this->db->get()->row()->reseller_id;



			if($reseller_id != NULL) {

				//this is a reseller

				//display quantity discount

				if($quantity_discount_active == 'reseller' || $quantity_discount_active == 'retail-reseller') {

					if($count_quantity_discount > 0) {

						//quantity discount exist. get quantity discount

						$this->db->select('*')->from('quantity_discount')->where('product_id', $product_id)->order_by('min_quantity', 'ASC');

						$data['quantity_discount'] = $this->db->get()->result();

					}

				}

			} else {

				//this is a regular customer

				//display quantity discount

				if($quantity_discount_active == 'retail' || $quantity_discount_active == 'retail-reseller') {

					if($count_quantity_discount > 0) {

						//quantity discount exist. get quantity discount

						$this->db->select('*')->from('quantity_discount')->where('product_id', $product_id)->order_by('min_quantity', 'ASC');

						$data['quantity_discount'] = $this->db->get()->result();

					}

				}

			}

		} else {

			//customer is not loggedin

			//display quantity discount

			if($quantity_discount_active == 'retail' || $quantity_discount_active == 'retail-reseller') {

				if($count_quantity_discount > 0) {

					//quantity discount exist. get quantity discount

					$this->db->select('*')->from('quantity_discount')->where('product_id', $product_id)->order_by('min_quantity', 'ASC');

					$data['quantity_discount'] = $this->db->get()->result();

				}

			}

		}



		//check if point rewards program is active or not.

		// $this->db->select('*')->from('point_rewards')->where('id_point_rewards', 1);

		// $data['point_rewards'] = $this->db->get()->row();



		//get brand name

		// $this->db->select('brand')->from('brands')->where('id_brands', $data['product']->brand_id);  

		// $data['brand_name'] = $this->db->get()->row()->brand;



		//get all product reviews

		// $this->db->select('*')->from('product_review')->where('product_id', $product_id)->order_by('review_date', 'DESC');

		// $data['product_reviews'] = $this->db->get()->result();



		//get average reviews

		// $this->db->select('rating')->from('product_review')->where('product_id', $product_id);

		// $data['review_ratings'] = $this->db->get()->result();

		// if (count($data['review_ratings']) != 0) {

		// 	$sum_review = 0;

		// 	foreach ($data['review_ratings'] as $rating) {

		// 		$sum_review = $sum_review + $rating->rating; 

		// 	}

		// 	$data['average_rating'] = floor($sum_review / count($data['review_ratings'])); 

		// }



		//get product color link 

        //check if color link is available

        $this->db->select('link_to_product_id')->from('product_link')->where('product_id', $product_id);

		$data['product_links'] = $this->db->get()->result();



		//check the stock. if no stock at all, display no stock.

		$this->db->select('stock')->from('product_details')->where('product_id', $product_id)->where('stock !=', 0);

		$data['count_product_stock'] = $this->db->get()->num_rows(); 



		//LOAD LANGUAGE FILES

		if($this->session->userdata('site_lang') == 'english') {

			$this->lang->load('product_detail', 'english');

			$this->lang->load('product_list', 'english');

		} else {

			$this->lang->load('product_detail', 'indonesian');

			$this->lang->load('product_list', 'indonesian');

		}



		$this->db->select('*');

		$this->db->from('configuration');

		$data['config'] = $this->db->get()->result();



		foreach ($data['config'] as $item) {

			$this->data_header['image'] = $item->logo;

			$this->data_header['icon'] = $item->website_icon;

			$this->data['fax'] = $item->fax;

			$this->data['hp'] = $item->hp;

			$this->data['company_address'] = $item->company_address;

			$this->data_footer['twitter']= $item->twitter;

			$this->data_header['instagram']= $item->instagram;

			$this->data_header['facebook']= $item->facebook;

			$this->data_footer['website_name']= $item->website_name;

		}



		//get SEO

		$this->data_header['browser_title'] = 'Product - ' . ucwords($data['product']->title); 

		$this->data_header['meta_description'] = $data['product']->meta_description;

		$this->data_header['meta_keywords'] = $data['product']->meta_keywords;

		

		$this->load->view('template/header', $this->data_header);

		$this->load->view('product', $data);

		$this->load->view('template/footer', $this->data_footer); 



	}



}

https://t.me/RX1948 - 2025