<?php
session_start();

	include("connect.php");
	
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
				
	
		$_SESSION['frompage']="dashboard";

	$cmpmid=$_SESSION['linkarisecmpmid'];
	$cmptype=$_SESSION['linkarisecmptype'];
	date_default_timezone_set("Asia/Singapore");
	$mdate= date('Y/m/d');
	$mdate2= date('Y-m-d');
	$mdate1= date('Y-m-d H:i:sa');
		    
	
	$lower = date('Y-m-d', strtotime($mdate));
	$upper = date('Y-m-d', strtotime($mdate)+2);
	
	
	//--Today Date
	$mdate2= date('Y-m-d');
	//--Yesterday Date
	$mdate3= date('Y-m-d',strtotime("-1 days"));
	//--Last 7 Days Date
	$mdate4= date('Y-m-d',strtotime("-7 days"));
	//--This Month Date
	$startdate = date('Y-m-01',strtotime(date('Y-m-d')));
	$enddate =  date('Y-m-t',strtotime(date('Y-m-d')));
	//--Last Month Date
	$prevstartdate = date('Y-m-01', (strtotime(date('Y-m-d')) - 2400000));
	$prevenddate = date('Y-m-t', (strtotime(date('Y-m-d')) - 2400000));
	
	
				date_default_timezone_set("Asia/Singapore");
				$mdate1= date('Y-m-d H:i:s');
				
			$cmpname="";
				 $eve71="select * from res_company_master where companymid=$cmpmid";
					$re71 = mysqli_query($conn, $eve71);
					while($rt71 = mysqli_fetch_assoc($re71))
					{
						$cmpname=$rt71['companyname'];
						
						
					}	


	
	
?>
<!DOCTYPE html>
<!--
Author: Keenthemes
Product Name: Metronic - Bootstrap 5 HTML, VueJS, React, Angular. Laravel, Asp.Net Core, Ruby on Rails, Spring Boot, Blazor, Django, Express Node.js & Flask Admin Dashboard Theme
Purchase: https://1.envato.market/EA4JP
Website: http://www.keenthemes.com
Contact: support@keenthemes.com
Follow: www.twitter.com/keenthemes
Dribbble: www.dribbble.com/keenthemes
Like: www.facebook.com/keenthemes
License: For each use you must have a valid license purchased only from above link in order to legally use the theme for your project.
-->
<html lang="en">
<head>
    <title>Dashboard</title>
    <meta charset="utf-8"/>
    <link rel="shortcut icon" href="assets/media/logos/iwashlogo.jpg"/>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700"/>
    <link href="assets/plugins/custom/fullcalendar/fullcalendar.bundle.css" rel="stylesheet" type="text/css"/>
    <link href="assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css"/>
    <link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
    <link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css"/>
	
</head>
<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true"
      data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true"
      data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true"
      data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">
<script>var defaultThemeMode = "light";
    var themeMode;
    if (document.documentElement) {
        if (document.documentElement.hasAttribute("data-bs-theme-mode")) {
            themeMode = document.documentElement.getAttribute("data-bs-theme-mode");
        } else {
            if (localStorage.getItem("data-bs-theme") !== null) {
                themeMode = localStorage.getItem("data-bs-theme");
            } else {
                themeMode = defaultThemeMode;
            }
        }
        if (themeMode === "system") {
            themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
        }
        document.documentElement.setAttribute("data-bs-theme", themeMode);
    }</script>
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
    <div class="app-page flex-column flex-column-fluid" id="kt_app_page">
        <?php include('header2.php'); ?>
        <div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
            <?php include('sidebar2.php'); ?>
            <div class="app-main flex-column flex-row-fluid" id="kt_app_main">
                <div class="d-flex flex-column flex-column-fluid">
                    <div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
                    </div>
                    <div id="kt_app_content" class="app-content flex-column-fluid">
                        <div id="kt_app_content_container" class="app-container container-fluid">
                            <div class="row g-5 g-xl-10 mb-5 mb-xl-10">
                                <!--begin::Col-->
                                <div class="col-xl-12 mb-xl-10">
                                    <!--begin::Lists Widget 19-->
                                    <div class="card card-flush h-xl-100">
                                        <!--begin::Heading-->
                                        <div class="card-header rounded bgi-no-repeat bgi-size-cover bgi-position-y-top bgi-position-x-center align-items-start h-250px"
                                             style="background-image:url('assets/media/svg/shapes/top-green.png"
                                             data-theme="light">
                                            <!--begin::Title-->
                                            <h3 class="card-title align-items-start flex-column text-white pt-15">
                                                <span class="fw-bold fs-2x mb-3"><?php echo $cmptype.": ".$cmpname;?></span>
                                                <div class="fs-4 text-white">

                                                </div>
                                            </h3>
                                            <!--end::Title-->
                                        </div>
                                        <!--end::Heading-->
                                        <!--begin::Body-->
                                        <div class="card-body mt-n20">
                                            <!--begin::Stats-->
                                            <div class="mt-n20 position-relative">
                                                <!--begin::Row-->
                                                <div class="row g-3 g-lg-6">
                                                    <!--begin::Col-->
                                                    <div class="col-6">
                                                        <!--begin::Items-->
                                                        <div class="bg-gray-100 bg-opacity-70 rounded-2 px-6 py-5">
                                                            <!--begin::Symbol-->
                                                            <div class="symbol symbol-30px me-5 mb-8">
																<span class="symbol-label">
																	<!--begin::Svg Icon | path: icons/duotune/medicine/med005.svg-->
																	<span class="svg-icon svg-icon-1 svg-icon-primary">
																		<svg width="24" height="24" viewBox="0 0 24 24"
                                                                             fill="none"
                                                                             xmlns="http://www.w3.org/2000/svg">
																			<path opacity="0.3"
                                                                                  d="M17.9061 13H11.2061C11.2061 12.4 10.8061 12 10.2061 12C9.60605 12 9.20605 12.4 9.20605 13H6.50606L9.20605 8.40002V4C8.60605 4 8.20605 3.6 8.20605 3C8.20605 2.4 8.60605 2 9.20605 2H15.2061C15.8061 2 16.2061 2.4 16.2061 3C16.2061 3.6 15.8061 4 15.2061 4V8.40002L17.9061 13ZM13.2061 9C12.6061 9 12.2061 9.4 12.2061 10C12.2061 10.6 12.6061 11 13.2061 11C13.8061 11 14.2061 10.6 14.2061 10C14.2061 9.4 13.8061 9 13.2061 9Z"
                                                                                  fill="currentColor"/>
																			<path d="M18.9061 22H5.40605C3.60605 22 2.40606 20 3.30606 18.4L6.40605 13H9.10605C9.10605 13.6 9.50605 14 10.106 14C10.706 14 11.106 13.6 11.106 13H17.8061L20.9061 18.4C21.9061 20 20.8061 22 18.9061 22ZM14.2061 15C13.1061 15 12.2061 15.9 12.2061 17C12.2061 18.1 13.1061 19 14.2061 19C15.3061 19 16.2061 18.1 16.2061 17C16.2061 15.9 15.3061 15 14.2061 15Z"
                                                                                  fill="currentColor"/>
																		</svg>
																	</span>
                                                                    <!--end::Svg Icon-->
																</span>
                                                            </div>
                                                            <!--end::Symbol-->
                                                            <!--begin::Stats-->
                                                            <div class="m-0">
                                                                <!--begin::Number-->
																<?php
																if($_SESSION['linkarisecmptype']=="Hotel"){  
                                                                $eve1 = "SELECT SUM(d.trolleynetweight) AS dirtycloth
FROM res_jobwork_detail AS d
INNER JOIN res_jobwork_master AS m ON d.jobworkmid = m.jobworkmid
WHERE m.fromcompanymid = $cmpmid";
				
				 $re1 = mysqli_query($conn, $eve1);
				 if(mysqli_num_rows($re1) > 0)
				   {
						 while($rt1 = mysqli_fetch_assoc($re1))
						 {
							 //$jobworkmid = $rt1['jobworkmid'];
							 $dirtycloth = $rt1['dirtycloth'];
							$cleancloth=0;
							  $eve11 = "select sum(trolleynetweight) as cleancloth from res_jobwork_detail where jobworkmid in (select jobworkmid from res_jobwork_master where tocompanymid=$cmpmid and jobworkstatus='Received')";
				
				 $re11 = mysqli_query($conn, $eve11);
				 if(mysqli_num_rows($re11) > 0)
				   {
						 while($rt11 = mysqli_fetch_assoc($re11))
						 {
							 
							 $cleancloth = $rt11['cleancloth'];
							 
						 } 
				   }
						 }
				   }
				   }
				   else{
					    $eve1 = "SELECT SUM(d.trolleynetweight) AS dirtycloth
FROM res_jobwork_detail AS d
INNER JOIN res_jobwork_master AS m ON d.jobworkmid = m.jobworkmid
WHERE m.tocompanymid =$cmpmid
AND m.jobworkstatus = 'Received'";
				
				 $re1 = mysqli_query($conn, $eve1);
				 if(mysqli_num_rows($re1) > 0)
				   {
						 while($rt1 = mysqli_fetch_assoc($re1))
						 {
							 //$jobworkmid = $rt1['jobworkmid'];
							 $dirtycloth = $rt1['dirtycloth'];
							$cleancloth=0;
							  $eve11 = "select sum(trolleynetweight) as cleancloth from res_jobwork_detail where jobworkmid in (select jobworkmid from res_jobwork_master where fromcompanymid=$cmpmid)";
				
				 $re11 = mysqli_query($conn, $eve11);
				 if(mysqli_num_rows($re11) > 0)
				   {
						 while($rt11 = mysqli_fetch_assoc($re11))
						 {
							 
							 $cleancloth = $rt11['cleancloth'];
							 
						 } 
				   }
						 }
				   }
				   }
				   ?>
                                                                <span class="text-gray-700 fw-bolder d-block fs-2qx lh-1 ls-n1 mb-1"><?php echo number_format($dirtycloth,2,'.','')." &nbsp;Kgs"; ?></span>
                                                                <!--end::Number-->
                                                                <!--begin::Desc-->
                                                                <span class="text-gray-500 fw-semibold fs-6">Total Dirty Clothes</span>
                                                                <!--end::Desc-->
                                                            </div>
                                                            <!--end::Stats-->
                                                        </div>
                                                        <!--end::Items-->
                                                    </div>
                                                    <!--end::Col-->
                                                    <!--begin::Col-->
                                                    <div class="col-6">
                                                        <!--begin::Items-->
                                                        <div class="bg-gray-100 bg-opacity-70 rounded-2 px-6 py-5">
                                                            <!--begin::Symbol-->
                                                            <div class="symbol symbol-30px me-5 mb-8">
																<span class="symbol-label">
																	<!--begin::Svg Icon | path: icons/duotune/finance/fin001.svg-->
																	<span class="svg-icon svg-icon-1 svg-icon-primary">
																		<svg width="24" height="24" viewBox="0 0 24 24"
                                                                             fill="none"
                                                                             xmlns="http://www.w3.org/2000/svg">
																			<path opacity="0.3"
                                                                                  d="M17.9061 13H11.2061C11.2061 12.4 10.8061 12 10.2061 12C9.60605 12 9.20605 12.4 9.20605 13H6.50606L9.20605 8.40002V4C8.60605 4 8.20605 3.6 8.20605 3C8.20605 2.4 8.60605 2 9.20605 2H15.2061C15.8061 2 16.2061 2.4 16.2061 3C16.2061 3.6 15.8061 4 15.2061 4V8.40002L17.9061 13ZM13.2061 9C12.6061 9 12.2061 9.4 12.2061 10C12.2061 10.6 12.6061 11 13.2061 11C13.8061 11 14.2061 10.6 14.2061 10C14.2061 9.4 13.8061 9 13.2061 9Z"
                                                                                  fill="currentColor"/>
																			<path d="M18.9061 22H5.40605C3.60605 22 2.40606 20 3.30606 18.4L6.40605 13H9.10605C9.10605 13.6 9.50605 14 10.106 14C10.706 14 11.106 13.6 11.106 13H17.8061L20.9061 18.4C21.9061 20 20.8061 22 18.9061 22ZM14.2061 15C13.1061 15 12.2061 15.9 12.2061 17C12.2061 18.1 13.1061 19 14.2061 19C15.3061 19 16.2061 18.1 16.2061 17C16.2061 15.9 15.3061 15 14.2061 15Z"
                                                                                  fill="currentColor"/>
																		</svg>
																	</span>
                                                                    <!--end::Svg Icon-->
																</span>
                                                            </div>
                                                            <!--end::Symbol-->
                                                            <!--begin::Stats-->
                                                                <div class="m-0">
                                                                <!--begin::Number-->
                                                               
                                                                <span class="text-gray-700 fw-bolder d-block fs-2qx lh-1 ls-n1 mb-1"><?php echo number_format($cleancloth,2,'.','')." &nbsp;Kgs"; ?></span>
                                                                <!--end::Number-->
                                                                <!--begin::Desc-->
                                                                <span class="text-gray-500 fw-semibold fs-6">Total Cleaned Clothes</span>
                                                                <!--end::Desc-->
                                                            </div>
                                                            <!--end::Stats-->
                                                        </div>
                                                        <!--end::Items-->
                                                    </div>
                                                    <!--end::Col-->
                                                  
			
                                                </div>
                                                <!--end::Row-->

                                            </div>
                                            <!--end::Stats-->
                                        </div>
                                        <!--end::Body-->
                                    </div>
                                    <!--end::Lists Widget 19-->
                                </div>
                                <!--end::Col-->
                            </div>
                            <!--end::Row-->
           
	
            </div>
        </div>
        <?php include('footer.php'); ?>
    </div>
</div>
<script>var hostUrl = "assets/";</script>
<script src="assets/plugins/global/plugins.bundle.js"></script>
<script src="assets/js/scripts.bundle.js"></script>
<script src="assets/plugins/custom/fullcalendar/fullcalendar.bundle.js"></script>
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
<script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
<script src="https://cdn.amcharts.com/lib/5/radar.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
<script src="https://cdn.amcharts.com/lib/5/map.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/continentsLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/usaLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldTimeZonesLow.js"></script>
<script src="https://cdn.amcharts.com/lib/5/geodata/worldTimeZoneAreasLow.js"></script>
<script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
<script src="assets/js/widgets.bundle.js"></script>
<script src="assets/js/custom/widgets.js"></script>
<script src="assets/js/custom/apps/chat/chat.js"></script>
<script src="assets/js/custom/utilities/modals/upgrade-plan.js"></script>
<script src="assets/js/custom/utilities/modals/create-app.js"></script>
<script src="assets/js/custom/utilities/modals/new-target.js"></script>
<script src="assets/js/custom/utilities/modals/users-search.js"></script>
	<script src="assets/js/custom/apps/calendar/calendar.js"></script>


	
</body>
</html>