<commit_before><?php

class orders {

	protected $id;
	protected $user_id;
	protected $cart;
	protected $date;
	protected $date_update;
	protected $status = false;

	public function __construct() {

	}

	public function setContent() {

	}

	public function setId($i) {
		$this->id = $i;
	}

	public function setUserId($w) {
		$this->user_id = $w;
	}

	public function setCart($ba = null, $da = null, $l = []) {
		if (count($l) > 0) {
			return false;
		}

		$product_template = "%s[/]%s[/]%s[/]%s\n"; // template para info do produto
		$toSave_template = "%s[/]%s[spr]%s[spr]%s[/]%s[spr]%s";

		$total = 0;
		$vat = 0;
		$list = null; // lista compilada
		foreach ($l as $item) {
			$list .= sprintf($product_template,
							 $item["id"],
							 $item["quantity"],
							 $item["id"],
							 (($item["discount"] !== 0) ? $item["price"] : $item["discount"]),
							 $item["vat"]
							);
			$total += (($item["discount"] !== 0) ? $item["price"] : $item["discount"]);
			$vat += (($item["discount"] !== 0) ? $item["price"] : $item["discount"]) * ($item["vat"] / 100)
		}

		// remover o último \n
		if (strlen($list) > 2) {
			$list = substr($list, 0, -2);
		}

		// gravar a informação na variavel
		$this->cart = sprintf($toSave_template, $ba, $da, $list, $total, $vat);

		return true;
	}

	public function setDate($d = null) {
		$this->date = ($d !== null) ? $d : date("Y-m-d H:i:s", time());
	}

	public function setDateUpdate($d = null) {
		$this->date_update = ($d !== null) ? $d : date("Y-m-d H:i:s", time());
	}

	public function insert($u, $c) {
		global $configuration, $mysqli;

		$query[0] = sprintf("INSERT INTO %s_orders (user_id, cart, date, date_update) VALUES ('%s', '%s', '%s', '%s')", $configuration["mysql-prefix"], $this->user_id, $this->cart, $this->date, $this->date_update);

		return $mysqli->query($query[0]);
	}

	public function update() {
		global $configuration, $mysqli;
	}

	public function delete() {
		global $configuration, $mysqli;
	}

	public function returnObject() {
		return array();
	}

	public function returnOneOrder() {
		global $configuration, $mysqli;

		$query[0] = sprintf("SELECT * FROM %s_orders WHERE id = '%s'", $configuration["mysql-prefix"], $this->id);
		$source[0] = $mysqli->query($query[0]);<commit_msg>new version<commit_after><?php

class orders {

	protected $id;
	protected $user_id;
	protected $cart;
	protected $date;
	protected $date_update;
	protected $status = false;

	public function __construct() {

	}

	public function setContent() {

	}

	public function setId($i) {
		$this->id = $i;
	}

	public function setUserId($w) {
		$this->user_id = $w;
	}

	public function setCart($ba = null, $da = null, $l = [], $p = null) {
		if (count($l) <= 0) {
			return false;
		}

		$product_template = "%s[/]%s[/]%s[/]%s\n"; // template para info do produto
		$toSave_template = "%s[/]%s[spr]%s[spr]%s[/]%s[spr]%s";

		$total = 0;
		$vat = 0;
		$list = null; // lista compilada
		foreach ($l as $item) {
			$list .= sprintf($product_template,
							 $item["id"],
							 $item["quantity"],
							 $item["id"],
							 (($item["discount"] !== 0) ? $item["price"] : $item["discount"]),
							 $item["vat"]
							);
			$total += (($item["discount"] !== 0) ? $item["price"] : $item["discount"]);
			$vat += (($item["discount"] !== 0) ? $item["price"] : $item["discount"]) * ($item["vat"] / 100);
		}

		// remover o último \n
		if (strlen($list) > 2) {
			$list = substr($list, 0, -2);
		}

		// gravar a informação na variavel
		$this->cart = sprintf($toSave_template, $ba, $da, $list, $total, $vat, $p);

		return true;
	}

	public function setDate($d = null) {
		$this->date = ($d !== null) ? $d : date("Y-m-d H:i:s", time());
	}

	public function setDateUpdate($d = null) {
		$this->date_update = ($d !== null) ? $d : date("Y-m-d H:i:s", time());
	}

	public function insert() {
		global $configuration, $mysqli;

		$query[0] = sprintf("INSERT INTO %s_orders (user_id, cart, date, date_update) VALUES ('%s', '%s', '%s', '%s')", $configuration["mysql-prefix"], $this->user_id, $this->cart, $this->date, $this->date_update);

		return $mysqli->query($query[0]);
	}

	public function update() {
		global $configuration, $mysqli;
	}

	public function delete() {
		global $configuration, $mysqli;
	}

	public function returnObject() {
		return array();
	}

	public function returnOneOrder() {
		global $configuration, $mysqli;

		$query[0] = sprintf("SELECT * FROM %s_orders WHERE id = '%s'", $configuration["mysql-prefix"], $this->id);
		$source[0] = $mysqli->query($query[0]);
{'fraction_non_alphanumeric': 0.22109667474124642, 'fraction_numerical': 0.007487337590839022, 'mean_word_length': 3.6970010341261634, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 30, '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': '3181237', 'n_tokens_mistral': 1916, 'n_tokens_neox': 1683, 'n_words': 392}