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

class Inventory_model extends CI_Model{
	function __construct(){
		parent::__construct();
	}

	public function useingredients(){
		$orderlist = json_decode($this->input->post('orderlist'), true);
		var_dump($orderlist);

		$minuser = 0;
		$counter = 0;

		foreach($orderlist as $key => $value){
			if ($value['ProductName'] == 'Beefy Burger'){
				$minuser = $value['Quantity'];
				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Big Bun'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Beef Patty'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Coleslaw'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Lettuce'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Tomato Pack'";
				$query = $this->db->query($sql);

				$sql = "INSERT into orderhistory(pname, quantity, price, date, time) values('$value', $orderqtylist[$counter], $orderpricelist[$counter], CURRENT_DATE, CURRENT_TIMESTAMP)";
				$query = $this->db->query($sql);

				

			} else if ($value == 'Double Beefy Burger'){
				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter] where itemname='Big Bun'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Beef Patty'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter] where itemname='Coleslaw'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Lettuce'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Tomato Pack'";<commit_msg>Rework INSERT into orderhistory to contain the variable of the respective attributes of the product.<commit_after><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Inventory_model extends CI_Model{
	function __construct(){
		parent::__construct();
	}

	public function useingredients(){
		$orderlist = json_decode($this->input->post('orderlist'), true);
		var_dump($orderlist);

		$name;
		$minuser = 0;
		$price;
		$counter = 0;

		foreach($orderlist as $key => $value){
			if ($value['ProductName'] == 'Beefy Burger'){
				$name = $value['ProductName'];
				$minuser = $value['Quantity'];
				$price = $value['Price'];
				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Big Bun'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Beef Patty'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Coleslaw'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Lettuce'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$minuser where itemname='Tomato Pack'";
				$query = $this->db->query($sql);

				$sql = "INSERT into orderhistory(pname, quantity, price, date, time) values('$name', $minuser, $price, CURRENT_DATE, CURRENT_TIMESTAMP)";
				$query = $this->db->query($sql);

				

			} else if ($value == 'Double Beefy Burger'){
				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter] where itemname='Big Bun'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Beef Patty'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter] where itemname='Coleslaw'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Lettuce'";
				$query = $this->db->query($sql);

				$sql = "UPDATE inventory SET itemcount=itemcount-$orderqtylist[$counter]*2 where itemname='Tomato Pack'";
{'fraction_non_alphanumeric': 0.17023754075454123, 'fraction_numerical': 0.002328830926874709, 'mean_word_length': 4.948753462603878, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '1067101', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1333, 'n_words': 321}