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

class Product extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->library('form_validation');
		$this->load->model('m_product','product');
		$this->load->model('M_metal','metal');
		$this->load->model('m_stone','stone');
	}

	public function index()
	{
		$this->load->model('m_product_category','product_category');//load model for get product category to fill dropdown box
		$view_data['product_categories']=$this->product_category->get_product_category();
		$view_data['metals']=$this->metal->get_metals();
		$view_data['stones']=$this->stone->get_stones();
		$data['title'] = "Products";
        $data['content'] = $this->load->view('pages/products/product_view',$view_data, true);
        $this->parser->parse('template/page_template', $data);

	}
	public function add()
	{
		$master['status'] = True;
        $data = array();
        $master = array();
		$this->form_validation->set_rules('model_no', 'Model Number', 'trim|required|max_length[64]');
		$this->form_validation->set_rules('category', 'Category', 'trim|required');
		$this->form_validation->set_rules('grossweight', 'Net weight', 'trim|required');
		$this->form_validation->set_rules('netweight', 'price', 'trim');
		$this->form_validation->set_rules('price', 'price', 'trim');
		if ($this->form_validation->run() == TRUE) 
		{
			$this->db->trans_start();

			/*insert product and return product id*/
			$product_id=$this->product->insert_product();

			/*insert metal details*/
			$metal=$_POST['metal'];
			$weight=$_POST['weight'];
			if($metal)
			{
				foreach ($metal as $key=>$value) {
					$data=array(
						'metal_id'=>$value,
						'product_id'=>$product_id,
						'weight'=>$weight[$key]
						);
					$this->db->insert('tbl_metal_details',$data);
				}
			}

			/*insert stone details*/
			$stone=$_POST['stone'];
			$pcs=$_POST['pcs'];
			$cts=$_POST['cts'];
			if($stone)
			{
				foreach ($stone as $key => $value) {
					
					$data=array(
						'stone_id'=>$value,
						'product_id'=>$product_id,
						'pcs'=>$pcs[$key],
						'cts'=>$cts[$key]
						);
					$this->db->insert('tbl_stone_details',$data);
				}<commit_msg>product add form completed<commit_after><?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Product extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->library('form_validation');
		$this->load->model('m_product','product');
		$this->load->model('M_metal','metal');
		$this->load->model('m_stone','stone');
	}

	public function index()
	{
		$this->load->model('m_product_category','product_category');//load model for get product category to fill dropdown box
		$view_data['product_categories']=$this->product_category->get_product_category();
		$view_data['metals']=$this->metal->get_metals();
		$view_data['stones']=$this->stone->get_stones();
		$data['title'] = "Products";
        $data['content'] = $this->load->view('pages/products/product_view',$view_data, true);
        $this->parser->parse('template/page_template', $data);

	}
	public function add()
	{
		$master['status'] = True;
        $data = array();
        $master = array();
		$this->form_validation->set_rules('model_no', 'Model Number', 'trim|required|max_length[64]');
		$this->form_validation->set_rules('category', 'Category', 'trim|required');
		$this->form_validation->set_rules('grossweight', 'Net weight', 'trim|required');
		$this->form_validation->set_rules('netweight', 'price', 'trim');
		$this->form_validation->set_rules('price', 'price', 'trim');
		if ($this->form_validation->run() == TRUE) 
		{
			$this->db->trans_start();

			/*insert product and return product id*/
			$product_id=$this->product->insert_product();

			/*insert metal details*/
			$metal=$_POST['metal'];
			$weight=$_POST['weight'];
			if($metal)
			{
				foreach ($metal as $key=>$value) {
					if($value)
					{
						$data=array(
						'metal_id'=>$value,
						'product_id'=>$product_id,
						'weight'=>$weight[$key]
						);
						$this->db->insert('tbl_metal_details',$data);
					}
				}
			}

			/*insert stone details*/
			$stone=$_POST['stone'];
			$pcs=$_POST['pcs'];
			$cts=$_POST['cts'];
			if($stone)
			{
				foreach ($stone as $key => $value) {
					
					if($value)
					{
						$data=array(
						'stone_id'=>$value,
						'product_id'=>$product_id,
						'pcs'=>$pcs[$key],
						'cts'=>$cts[$key]
						);
						$this->db->insert('tbl_stone_details',$data);
					}
				}
{'fraction_non_alphanumeric': 0.21029572836801752, 'fraction_numerical': 0.0008762322015334064, 'mean_word_length': 4.272517321016166, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1347271', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1512, 'n_words': 231}