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



class Manual_Query extends CI_Controller {



    var $main_menu_name = "people";

	var $sub_menu_name = "suppliers";



    public function __construct()

    {

        parent::__construct();

        $this->load->model('country_model');
		$this->load->model('Common_Model');
		$this->load->model('Manual_Query_Model');

    }

	

	public function index()

	{

		$data['main_menu_name'] = $this->main_menu_name;

		$data['sub_menu_name'] = $this->sub_menu_name;

		echo "metal items<br/>";
		
		 $data['all_data'] = $this->Manual_Query_Model->get_all_data(3);
		 
		 //print_r($data['all_data']);
		 
		 foreach ($data['all_data'] as $row)
         {
				echo '<br/>category: '.$row['category'];  
				echo '<br/>sub_category: '.$row['sub_category'];  
				echo '<br/>name: '.$row['name'];  
				echo '<br/>cost: '.$row['cost'];  
				echo '<br/>price: '.$row['price'];  
				//insert data to sub cat table
		$data_list=array(
				'cat_id'		=>	$row['category'],
				'sub_cat_id' 	=>	$row['sub_category'],
				'product_name'  =>	$row['name'],
				'product_code'	=>	$this->Common_Model->gen_ref_number('product_id','product','PD'),
				'product_thumb'		=> 'no-image.jpg',
				'product_image'		=> 'no-image.jpg',
				'product_alert_qty' => 2,
				'product_unit' 		=> 6,
				'product_price' 	=> $row['price'],
				'product_cost' 		=> $row['cost']
		 );
			echo "<pre>";
			print_r($data_list);
			$this->Manual_Query_Model->save_data($data_list);        
         }  
		
		//$this->load->view('suppliers',$data);

	}



	public function get_all_country()

	{

        $data['id'] = 1;
		$data['main_menu_name'] = $this->main_menu_name;
		$data['sub_menu_name'] = 'create_supplier';
        $data['all_country'] = $this->country_model->get_all_country();

		

	}

	



}