<commit_before><?php
global $action;
global $model;

$orders = false;

// show specific order status
if(count($action) > 2) {
	$status = $action[2];

	if($status === "all") {
		$orders = $model->getOrders();
	}
	else {
		$orders = $model->getOrders(array("status" => $status));
	}
}
// show default = 0
else {
	$status = 0;
	$orders = $model->getOrders(array("status" => $status));

}
$selected_status_name = $model->order_statuses[$status];

session()->value("return_to_orderstatus", $status);

?>
<div class="scene i:scene defaultList shopList orderList shopOrderList">
	<h1>Orders</h1>

	<ul class="actions">
		<?//= $HTML->link("New order", "/janitor/admin/shop/order/new", array("class" => "button primary", "wrapper" => "li.new")) ?>
		<?= $HTML->link("Carts", "/janitor/admin/shop/cart/list", array("class" => "button", "wrapper" => "li.carts")) ?>
		<?= $HTML->link("Payments", "/janitor/admin/shop/payment/list", array("class" => "button", "wrapper" => "li.payments")) ?>
	</ul>

<? if($model->order_statuses): ?>
	<ul class="tabs">
		<? foreach($model->order_statuses as $order_status => $order_status_name): ?>
		<?= $HTML->link($order_status_name. " (<span>".$model->getOrderCount(array("status" => $order_status))."</span>)", "/janitor/admin/shop/order/list/".$order_status, array("wrapper" => "li".".".superNormalize($order_status_name).(is_numeric($status) && $order_status == $status ? ".selected" : ""))) ?>
		<? endforeach; ?>
		<?= $HTML->link("All (".$model->getOrderCount().")", "/janitor/admin/shop/order/list/all", array("wrapper" => "li.all".($status === "all" ? ".selected" : ""))) ?>
	</ul>
<? endif; ?>


	<div class="all_items i:defaultList i:orderList filters <?= superNormalize($selected_status_name) ?>">
		<? if($orders): ?>
		<ul class="items orders">
			<? foreach($orders as $order):
				$total_order_price = $model->getTotalOrderPrice($order["id"]);<commit_msg>prevent invalid array access<commit_after><?php
global $action;
global $model;

$orders = false;

// show specific order status
if(count($action) > 2) {
	$status = $action[2];

	if($status === "all") {
		$orders = $model->getOrders();
	}
	else {
		$orders = $model->getOrders(array("status" => $status));
	}
}
// show default = 0
else {
	$status = 0;
	$orders = $model->getOrders(array("status" => $status));

}
$selected_status_name = isset($model->order_statuses[$status]) ? $model->order_statuses[$status] : false;

session()->value("return_to_orderstatus", $status);

?>
<div class="scene i:scene defaultList shopList orderList shopOrderList">
	<h1>Orders</h1>

	<ul class="actions">
		<?//= $HTML->link("New order", "/janitor/admin/shop/order/new", array("class" => "button primary", "wrapper" => "li.new")) ?>
		<?= $HTML->link("Carts", "/janitor/admin/shop/cart/list", array("class" => "button", "wrapper" => "li.carts")) ?>
		<?= $HTML->link("Payments", "/janitor/admin/shop/payment/list", array("class" => "button", "wrapper" => "li.payments")) ?>
	</ul>

<? if($model->order_statuses): ?>
	<ul class="tabs">
		<? foreach($model->order_statuses as $order_status => $order_status_name): ?>
		<?= $HTML->link($order_status_name. " (<span>".$model->getOrderCount(array("status" => $order_status))."</span>)", "/janitor/admin/shop/order/list/".$order_status, array("wrapper" => "li".".".superNormalize($order_status_name).(is_numeric($status) && $order_status == $status ? ".selected" : ""))) ?>
		<? endforeach; ?>
		<?= $HTML->link("All (".$model->getOrderCount().")", "/janitor/admin/shop/order/list/all", array("wrapper" => "li.all".($status === "all" ? ".selected" : ""))) ?>
	</ul>
<? endif; ?>


	<div class="all_items i:defaultList i:orderList filters <?= superNormalize($selected_status_name) ?>">
		<? if($orders): ?>
		<ul class="items orders">
			<? foreach($orders as $order):
				$total_order_price = $model->getTotalOrderPrice($order["id"]);
{'fraction_non_alphanumeric': 0.24727838258164853, 'fraction_numerical': 0.003110419906687403, 'mean_word_length': 5.442404006677796, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 106, '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': '5551689', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1349, 'n_words': 220}