<?php
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
if(!isset($_SESSION['is_login']) ){
header("location: login.php");
?>
<script>
window.location="login.php";
</script>
<?php
}
?>

<?php
$permission  = explode(',',$_SESSION['permission_id']);
if(!in_array(26,$permission) && !in_array(1,$permission)  ){

?>
<script>
window.location="starter.php";
</script>
<?php
}
?>
		<!-- Main content -->
		
		<div class="row">
					
					
			<div class="col-sm-6 col-md-12">
				<div class="panel panel-body">
					<div class="media no-margin">
						<div class="media-body">
							
							<div class="col-sm-4">
								
							
								
								<select name="year_filter" id="year_filter" class="form-control col-sm-3" data-live-search="true">
									<option class="multi_lang" value="">تحديد السنة</option>
									<option class="multi_lang" value="2015">2015</option>
									<option class="multi_lang" value="2016">2016</option>
									<option class="multi_lang" value="2017">2017</option>
									<option class="multi_lang" value="2018">2018</option>
									<option class="multi_lang" value="2019">2019</option>
									<option class="multi_lang" value="2020">2020</option>
									<option class="multi_lang" value="2021">2021</option>
									<option class="multi_lang" value="2022">2022</option>
									<option class="multi_lang" value="2023">2023</option>
									<option class="multi_lang" value="2024">2024</option>
									<option class="multi_lang" value="2025">2025</option>
									<option class="multi_lang" value="2026">2026</option>
									<option class="multi_lang" value="2027">2027</option>
									<option class="multi_lang" value="2028">2028</option>
									<option class="multi_lang" value="2029">2029</option>
									<option class="multi_lang" value="2030">2030</option>
									
								</select>

							</div>

							<div class="col-sm-4">
								
							
								
								<select name="month_filter" id="month_filter" class="form-control col-sm-3" data-live-search="true">
									
									<option value="" >تحديد الشهر</option>
									<option value="1" >كانون الثاني</option>
									<option value="2" >شباط</option>
									<option value="3" >اذار</option>
									<option value="4" >نيسان</option>
									<option value="5" >ايار</option>
									<option value="6" >حزيران</option>
									<option value="7" >تموز</option>
									<option value="8" >اب</option>
									<option value="9" >ايلول</option>
									<option value="10" >تشرين الاول</option>
									<option value="11" >تشرين الثاني</option>
									<option value="12" >كانون الاول</option>
									
								</select>

							</div>

							<div class="col-sm-4">
								
							
								
								<select name="day_filter" id="day_filter" class="form-control col-sm-3" data-live-search="true">
									
									<option value="" selected="selected">تحديد اليوم</option>
									<option value="1" >يوم 1</option>
									<option value="2" >يوم 2</option>
									<option value="3" >يوم 3</option>
									<option value="4" >يوم 4</option>
									<option value="5" >يوم 5</option>
									<option value="6" >يوم 6</option>
									<option value="7" >يوم 7</option>
									<option value="8" >يوم 8</option>
									<option value="9" >يوم 9</option>
									<option value="10" >يوم 10</option>
									<option value="11" >يوم 11</option>
									<option value="12" >يوم 12</option>
									<option value="13" >يوم 13</option>
									<option value="14" >يوم 14</option>
									<option value="15" >يوم 15</option>
									<option value="16" >يوم 16</option>
									<option value="17" >يوم 17</option>
									<option value="18" >يوم 18</option>
									<option value="19" >يوم 19</option>
									<option value="20" >يوم 20</option>
									<option value="21" >يوم 21</option>
									<option value="22" >يوم 22</option>
									<option value="23" >يوم 23</option>
									<option value="24" >يوم 24</option>
									<option value="25" >يوم 25</option>
									<option value="26" >يوم 26</option>
									<option value="27" >يوم 27</option>
									<option value="28" >يوم 28</option>
									<option value="29" >يوم 29</option>
									<option value="30" >يوم 30</option>
									<option value="31" >يوم 31</option>
									
								</select>

							</div>
							
							<div class="col-sm-4" style="margin-top: 10px;">

								

								<button id="filter_btn" type="button" class="btn bg-teal-400 btn-labeled btn-block"><b><i class="icon-filter4"> </i></b> <span id="inv_filter">تطبيق الفلتر</span> </button>
								
							</div>

							

							<div class="col-sm-4" style="margin-top: 10px;">

								

								<a href="index.php?p=dashboard"  class="btn bg-pink-400 btn-labeled btn-block"><b><i class="icon-close2"> </i></b> <span id="inv_filter">ازالة الفلتر</span> </a>
								
							</div>

							



						</div>

						
					</div>
				</div>
			</div>

			

			
			
		</div>


			
		<!-- Quick stats boxes -->
		<div class="row">

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_sells">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">المجموع الكلي للمبيعات</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-cash icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_sells_raw">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang"> مجموع مبيعات  مواد جملة</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-cash icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_sells_plural">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع مبيعات ستائر الجملة</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-cash icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_sells_single">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع مبيعات ستائر المفرد</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-cash icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_shop_capital">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع راس المال</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-safe icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_factory_capital">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع القروض والديون</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-city icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-success-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_payments">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع الدفعات</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-coins  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_discount">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع خصومات الحساب</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-grab icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_return">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع المبالغ المسترجعة</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-grab icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>

			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_remained">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع المبالغ المتبقية</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-grab icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>


			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_purchase">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">المجموع الكلي لمشتريات المواد</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-cart-add2 icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>


			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_expenses">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">المجموع الكلي للمصاريف</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-wallet  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>


			


			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-info-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_product">0 </h3>
							<span class="text-uppercase text-size-lg multi_lang">عدد المواد </span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-users4  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>


			<div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-info-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_supplier">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">مجموع الكلي لتسديد الموردين</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-users4  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>


			<!-- <div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-danger-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_sallary">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">Total Sallary</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-users4  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div> -->
			
			<!-- <div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-info-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_reward">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">Total Reward</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-users4  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div> -->


			<!-- <div class="col-sm-6 col-md-3">
				<div class="panel panel-body bg-info-400 has-bg-image">
					<div class="media no-margin">
						<div class="media-body">
							<h3 class="no-margin text-black" id="total_penalty">0 $</h3>
							<span class="text-uppercase text-size-lg multi_lang">Total Penalty</span>
						</div>

						<div class="media-right media-middle">
							<i class="icon-users4  icon-3x opacity-75"></i>
						</div>
					</div>
				</div>
			</div>
 -->
			
		

		</div>
		<!-- /quick stats boxes -->

		<!-- echart -->
		<div class="row">
			<!-- Nightingale roses width visible labels -->
			<div class="panel panel-flat col-sm-6">
				<div class="panel-heading">
					<h5 class="panel-title">نسب الطلبيات حسب الاشهر للسنة</h5>
					<div class="heading-elements">
						<ul class="icons-list">
	                		<li><a data-action="collapse"></a></li>
	                		<li><a data-action="reload"></a></li>
	                		<li><a data-action="close"></a></li>
	                	</ul>
	            	</div>
				</div>

				<div class="panel-body">
					<div class="chart-container has-scroll">
						<div class="chart has-fixed-height has-minimum-width" id="rose_diagram_visible"></div>
					</div>
				</div>
			</div>
			<!-- /nightingale roses width hidden labels -->


			<!-- Nightingale roses width visible labels -->
			<div class="panel panel-flat col-sm-6">
				<div class="panel-heading">
					<h5 class="panel-title">نسب المبيعات حسب الاشهر للسنة</h5>
					<div class="heading-elements">
						<ul class="icons-list">
	                		<li><a data-action="collapse"></a></li>
	                		<li><a data-action="reload"></a></li>
	                		<li><a data-action="close"></a></li>
	                	</ul>
	            	</div>
				</div>

				<div class="panel-body">
					<div class="chart-container has-scroll">
						<div class="chart has-fixed-height has-minimum-width" id="rose_diagram_visible_sells"></div>
					</div>
				</div>
			</div>
			<!-- /nightingale roses width hidden labels -->

		</div>


		<div class="row">
			<!-- Nightingale roses width visible labels -->
			<div class="panel panel-flat col-sm-6">
				<div class="panel-heading">
					<h5 class="panel-title">نسب المصاريف حسب الاشهر للسنة</h5>
					<div class="heading-elements">
						<ul class="icons-list">
	                		<li><a data-action="collapse"></a></li>
	                		<li><a data-action="reload"></a></li>
	                		<li><a data-action="close"></a></li>
	                	</ul>
	            	</div>
				</div>

				<div class="panel-body">
					<div class="chart-container has-scroll">
						<div class="chart has-fixed-height has-minimum-width" id="rose_diagram_visible_expenses"></div>
					</div>
				</div>
			</div>
			<!-- /nightingale roses width hidden labels -->


			<!-- Nightingale roses width visible labels -->
			<div class="panel panel-flat col-sm-6">
				<div class="panel-heading">
					<h5 class="panel-title">نسب مشتريات المواد حسب الاشهر للسنة</h5>
					<div class="heading-elements">
						<ul class="icons-list">
	                		<li><a data-action="collapse"></a></li>
	                		<li><a data-action="reload"></a></li>
	                		<li><a data-action="close"></a></li>
	                	</ul>
	            	</div>
				</div>

				<div class="panel-body">
					<div class="chart-container has-scroll">
						<div class="chart has-fixed-height has-minimum-width" id="rose_diagram_visible_purchase"></div>
					</div>
				</div>
			</div>
			<!-- /nightingale roses width hidden labels -->

		</div>
		

		<!-- End echart -->

		<!-- Dashboard Daily Tables -->
		<div class="row">

			<div class="col-lg-6">
				<!-- Daily sales -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h6 class="panel-title">Daily Invoices stats</h6>
						<div class="heading-elements" dir="ltr">
							<span class="heading-text">Balance: <span class="text-bold text-danger-600 position-right"  id="Balance_invoice_id">$0,00</span></span>
							
						</div>
					</div>

					<div class="panel-body">
						<div id="sales-heatmap"></div>
					</div>

					<div class="table-responsive pre-scrollable">
						<table class="table text-nowrap">
							<thead>
								<tr>
									<th>#</th>
									<th>Invoice #</th>
									<th>Customer</th>
									<th>Time</th>
									<th>Price</th>
									<th>Discount</th>
								</tr>
							</thead>
							<tbody id="Table_invoice">
								
							</tbody>
						</table>
					</div>
				</div>
				<!-- /daily sales -->

			</div>

			<div class="col-lg-6">
				<!-- Daily sales -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h6 class="panel-title">Daily Expenses stats</h6>
						<div class="heading-elements" dir="ltr">
							<span class="heading-text">Balance: <span class="text-bold text-danger-600 position-right" id="Balance_expenses_id">$0,00</span></span>
							
						</div>
					</div>

					<div class="panel-body">
						<div id="sales-heatmap"></div>
					</div>

					<div class="table-responsive pre-scrollable">
						<table class="table text-nowrap">
							<thead>
								<tr>
									<th>#</th>
									<th>Name</th>
									<th>Bill No.</th>
									<th>Bill</th>
									<th>Time</th>
									<th>Price</th>
								</tr>
							</thead>
							<tbody id="Table_expenses">
								
							</tbody>
						</table>
					</div>
				</div>
				<!-- /daily sales -->

			</div>
		</div>

		<div class="row">	
			

			<div class="col-lg-12">
				<!-- Daily sales -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h6 class="panel-title">Purchase stats</h6>
						<div class="heading-elements" dir="ltr">
							<span class="heading-text">Balance: <span class="text-bold text-danger-600 position-right" id="Balance_purchase_id">$0,00</span></span>
							
						</div>
					</div>

					<div class="panel-body">
						<div id="sales-heatmap"></div>
					</div>

					<div class="table-responsive pre-scrollable">
						<table class="table text-nowrap">
							<thead>
								<tr>
									<th>#</th>
									<th>Purchase #</th>
									<th>Supplier</th>
									<th>Transaction</th>
									<th>Time</th>
									<th>Price</th>
								</tr>
							</thead>
							<tbody id="Table_purchase">
								
							</tbody>
						</table>
					</div>
				</div>
				<!-- /daily sales -->

			</div>

		</div>


		<div class="row">	
			

			<div class="col-lg-12">
				<!-- Daily sales -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h6 class="panel-title">ORDERS Stats</h6>
						<div class="heading-elements" dir="ltr">
							<span class="heading-text">No: <span class="text-bold text-danger-600 position-right" id="Balance_order_id">0</span></span>
							
						</div>
					</div>

					<div class="panel-body">
						<div id="sales-heatmap"></div>
					</div>

					<div class="table-responsive pre-scrollable">
						<table class="table ">
							<thead>
								<tr>
									<th>#</th>
									<th>Order #</th>
									<th>Customer</th>
									<th>اسم المشتري</th>
									<th>Date</th>
									<th>Delivery Date</th>
									<th width="20%">Status</th>
								</tr>
							</thead>
							<tbody id="Table_order">
								
							</tbody>
						</table>
					</div>
				</div>
				<!-- /daily sales -->

			</div>

		</div>

		<div class="row" style="display: none;">	
			<div class="col-lg-12">

				<!-- Marketing campaigns -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h6 class="panel-title">Staff Activity</h6>
						<div class="heading-elements">
							<span class="label bg-success heading-text" id="user_active">0 active</span>
							
	          </div>
					</div>

					

					<div class="table-responsive">
						<table class="table text-nowrap">
							<thead>
								<tr>
									<th>Staff Name</th>
									<th class="col-md-2">Quantity</th>
									<th class="col-md-2">Sells Ratio</th>
									<th class="col-md-2">Budget</th>
									<th class="col-md-2">Status</th>
								</tr>
							</thead>
							<tbody id="today">
								<tr class="active border-double">
									<td colspan="5">Today</td>
									<td class="text-right">
										<span class="progress-meter" id="today-progress" data-progress="30"></span>
									</td>
								</tr>


								<tr class="active border-double">
									<td colspan="5">Yesterday</td>
									<td class="text-right">
										<span class="progress-meter" id="yesterday-progress" data-progress="65"></span>
									</td>
								</tr>
								
								
								
							</tbody>
						</table>
					</div>
				</div>
				<!-- /marketing campaigns -->


				


			</div>

			
		</div>
		<!-- /dashboard content -->


			<!-- /main content -->
<script type="text/javascript" src="controllers/dashboard.js?random=<?php echo uniqid(); ?>"></script>