<commit_before><?php
	include_once 'Connect.php';

	function PurchaseItemInsert($receiptId, $upc){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		if($sql->query("INSERT INTO PurchaseItem VALUES ('$receiptId', '$upc')") === FALSE){
			return 2;
		}
		Close($sql);
		return 0;
	}
	
	function PurchaseItemDelete($receiptId, $upc){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		if($sql->query("DELETE FROM PurchaseItem WHERE receiptId = '$receiptId' AND upc = '$upc'") === FALSE){
			return 2;
		}
		Close($sql);
		return 0;
	}
	
	function PurchaseItemDisplay(){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		$result = $sql->query("SELECT * FROM PurchaseItem");
		$table = array();
		while($row = mysqli_fetch_array($result)){
			$table[] = $row;
		}
		Close($sql);
		return $table;
	}
?><commit_msg>added DailyReport function to PurchaseItem.php<commit_after><?php
	include_once 'Connect.php';

	function PurchaseItemInsert($receiptId, $upc){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		if($sql->query("INSERT INTO PurchaseItem VALUES ('$receiptId', '$upc')") === FALSE){
			return 2;
		}
		Close($sql);
		return 0;
	}
	
	function PurchaseItemDelete($receiptId, $upc){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		if($sql->query("DELETE FROM PurchaseItem WHERE receiptId = '$receiptId' AND upc = '$upc'") === FALSE){
			return 2;
		}
		Close($sql);
		return 0;
	}
	
	function PurchaseItemDisplay(){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		$result = $sql->query("SELECT * FROM PurchaseItem");
		$table = array();
		while($row = mysqli_fetch_array($result)){
			$table[] = $row;
		}
		Close($sql);
		return $table;
	}
	
	//returns table rows with report info and the total price in last element of array
	function DailyReport($date){
		$sql = Connect();
		if ($sql->connect_error) {
			return 1;
		}
		//$date format must be yyyy-mm-dd
		$result = $sql->query("SELECT upc, category, SUM(price), SUM(quantity) 
							   FROM Item 
							   INNER JOIN PurchaseItem 
							   ON Item.upc=PurchaseItem.upc 
							   INNER JOIN Order 
							   ON PurchaseItem.receiptId=Order.receiptId
							   WHERE DATE(`date`) = '$date';
							   GROUP BY upc");
		$table = array()
		while($row = mysqli_fetch_array($result)){
			$table[] = $row;
		}
		Close($sql);
		$totalPrice = 0;
		for($i = 0; $i < count($table); $i++){
			$totalPrice = $totalPrice + $table[i][2];
		}
		$table[] = $totalPrice;
		return $table;
	}
?>
{'fraction_non_alphanumeric': 0.1735374950922654, 'fraction_numerical': 0.007067137809187279, 'mean_word_length': 3.415944540727903, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 19, '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': '6396115', 'n_tokens_mistral': 1094, 'n_tokens_neox': 885, 'n_words': 215}