<?php
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);

session_start();

date_default_timezone_set("Pacific/Auckland");

if (isset($_SESSION["client_id"])){
}else{
	$_SESSION["client_id"] = 1;
	
	//get sales_id if logged in
	
	
}

if (isset($_COOKIE["t_cont_search_type"])){
	
	
}else{
	
	setcookie("t_cont_search_type", "All", time() + (20 * 365 * 24 * 60 * 60),'/');
	
}


if (isset($_COOKIE["t_cont_sel_id"])){
	
	
}else{
	
	setcookie("t_cont_sel_id", 0, time() + (20 * 365 * 24 * 60 * 60),'/');
	
}

?>
<!doctype html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="theme-color" content="#000000">
    <title>phoenixsoftware.co.nz. Shop POS solutions.</title>
    <meta name="description" content="phoenixsoftware.co.nz. Shop POS solutions.">
    <link rel="icon" type="image/png" href="../images/logo.png" sizes="32x32">
    <link rel="apple-touch-icon" sizes="180x180" href="../images/logo.png">


	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="manifest" href="manifest.json">

</head>

<body class=""  onload="javascript: load_todays_sales()">
    <link rel="stylesheet" href="../assets/css/style.min.css">
			<link rel="stylesheet" type="text/css" href="jquery-ui.css">

	
<link rel="stylesheet" href="//cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">

	

	
	
    <!-- loader -->

    <!-- * loader -->

    <!-- App Header -->
    <div class="appHeader bg-primary scrolled is-active">
        <div class="left">
            <a href="#" class="headerButton" data-toggle="modal" data-target="#sidebarPanel">
                <ion-icon name="menu-outline"></ion-icon>
            </a>
        </div>

        <div  class="center">
		
		<?php
		
		//get 
		
		
		?>
	
	PhoenixCRM - Job List - Current Jobs - Confirmed & WIP


		</div>
    </div>
    <!-- * App Header -->

    <!-- Search Component -->

    <!-- * Search Component -->

    <!-- App Capsule -->
    <div id="appCapsule">
<center>





    <div class="row" style="height: 900px;" >
	


        <div style="border: solid 1px; border-color: #6c757d" class="col-md-12">
                 <div style="" class="section mt-6 mb-6"><br>
				 <table>
				 <tr>
				 <td>
				 <?php
$curdate = date("d-m-Y");

//echo "date is".$curdate;
?>
</td>
<td>
<input  id="date_from" style="display: none; text-align: left; width: 150px;"  class="form-control datepicker"   data-format="dd-mm-yyyy"  data-RTL="false"  type='text'  value='<?php echo htmlspecialchars($curdate)?>'  onchange="javascript: update_field_date('date_from',  this.value)" />

<input  id="sel_tab" type='hidden'  value='1'  />
</td>
<td>
</td>
<td>
<input  id="date_to" style="display: none; text-align: left; width: 150px;"  class="form-control datepicker"  data-format="dd-mm-yyyy" data-lang="en" data-RTL="false"  type='text'  value='<?php echo htmlspecialchars($curdate)?>'  onchange="javascript: update_field_date('date_to',  this.value)" />
	</td>
		<td>
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 </td>
	<td>
	     <button id="printreport" style="display: none" onclick="print_report();"   style="width: 120px" class="btn btn-outline-primary mr-1 mb-1"  type="button">Print Report</button>
		 </td>
</tr>
</table>	
				           <div class="tab-pane fade show active" id="pilled" role="tabpanel">

                <div class="section full mt-1">
                  
                    <div class="wide-block pt-2 pb-2">

                        <ul class="nav nav-tabs lined" role="tablist">
                            <li class="nav-item">
                                <a id="tabcurrentsale" onclick="javascript: load_todays_sales()"  class="nav-link active" data-toggle="tab" href="#confirmedwip" role="tab">
                                    Confirmed / WIP
									                                </a>
								<a id="tabcurrentsale" class="nav-link" onclick="javascript: load_todays_sales_bypymnt()" data-toggle="tab" href="#quotesfollow" role="tab">
                                    Quotes for Follow Up
                                </a>
								<a id="tabcurrentsale" class="nav-link" data-toggle="tab"  onclick="javascript: load_todays_sales_bystaff()" href="#allquotes" role="tab">
                                    All Quotes
                                </a>

                            </li>

        
         
                        </ul>
                        <div class="tab-content mt-2">
                            <div class="tab-pane fade show active" id="confirmedwip" role="tabpanel">
                                
                <div class="section full mt-1">
                    
					
					
					                          <div id="divtodaysalesreport" style="overflow:scroll; height:700px; color: black;">

											 
						  
						  </div>

                    </div>
                </div>
				
	                            <div class="tab-pane fade show" id="quotesfollow"  role="tabpanel">
                                
                <div class="section full mt-1">
                    					<div id="divtodaysalesreportpymnt"  style="overflow:scroll; height:700px; color: black;">
						  
						  </div>

                    </div>
                </div>			
				
		                            <div class="tab-pane fade show" id="allquotes" role="tabpanel">
                                
                <div class="section full mt-1">
                    					<div id="divtodaysalesreportstaff"  style="overflow:scroll; height:700px; color: black;">
						  
						  </div>
                    </div>
                </div>		

				
				
                            </div>

                        </div>

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




        </div>

        </div>


    </div>

</div>




        <!-- app footer -->
        <div  class="section mt-6 mb-6">


		<center>	<small>
 </center>
	<?	
					 	 include '../php/configi.php';
						 
		//	echo "cookie".$_COOKIE['phxcrmclient_id'];			 
						 
						 
	if (isset($_COOKIE['phxcrmclient_id'])){
		 $phxcrmclient_id = $_COOKIE['phxcrmclient_id'];
		 
		 		$queryclient="SELECT * from ".$_COOKIE['phxcrmclient_id']."_client where uid_client = " . $phxcrmclient_id;
	//	echo $queryprod;
		$resultclient=mysqli_query($conn, $queryclient);

		while($rowclient=mysqli_fetch_array($resultclient)) { 

			$comp_name			 				= $rowclient['comp_name'];
			
		}

?>

<?

//echo $_COOKIE['phxcrmclient_id'];

	}else{
		
		
	//	echo $_COOKIE['phxcrmclient_id'];

		
	}
	?>
	<br>

     
            <div class="footer-title">
			<center>
                Copyright © phoenixsoftware.co.nz 2021.<br> All Rights Reserved.
            </center>
			</div>
 


        </div>
        <!-- * app footer -->

    </div>
    <!-- * App Capsule -->
<div class="modal fade dialogbox" id="DialogBasic" data-backdrop="static" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Apply Payment:</h5>
                    </div>
                    <div class="modal-body">
                      

						
                    </div>
                    <div class="modal-footer">
                        <div class="btn-inline">
                            <a href="#" class="btn btn-text-primary" data-dismiss="modal">OK</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
		

		
		        <div class="modal inset fade action-sheet ios-add-to-home" id="ios-add-to-home-screen" tabindex="-1"
            role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Add to Home Screen</h5>
                        <a href="javascript:;" class="close-button" data-dismiss="modal">
                            <ion-icon name="close"></ion-icon>
                        </a>
                    </div>
                    <div class="modal-body">
                        <div class="action-sheet-content text-center">
                            <div class="mb-1"><img src="../images/logo.png" alt="image" class="imaged w48">
                            </div>
                            <h4>phoenixsoftware.co.nz</h4>
                            <div>
                                Install phoenixsoftware.co.nz on your iPhone's home screen.
                            </div>
                            <div>
                                Tap the menu for your browser. Then tap Add to homescreen.
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- * iOS Add to Home Action Sheet -->
        <!-- Android Add to Home Action Sheet -->
        <div class="modal inset fade action-sheet android-add-to-home" id="android-add-to-home-screen" tabindex="-1"
            role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Add to Home Screen</h5>
                        <a href="javascript:;" class="close-button" data-dismiss="modal">
                            <ion-icon name="close"></ion-icon>
                        </a>
                    </div>
                    <div class="modal-body">
                        <div class="action-sheet-content text-center">
                            <div class="mb-1"><img src="../images/logo.png" alt="image" class="imaged w48">
                            </div>
                            <h4>phoenixsoftware.co.nz</h4>
                            <div>
                                Install phoenixsoftware.co.nz on your Android's home screen.
                            </div>
                            <div>
								Click menu for your browser then click "add app" or "install app".<br>If these options are not there - check for "add to home" option.<br> Once install is complete, go to your home screen and there should<br> be a phoenixsoftware.co.nz app installed. 
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <!-- App Bottom Menu -->
    <div class="appBottomMenu">
        <a href="index.php" class="item active">
            <div class="col">
                <ion-icon name="home-outline"></ion-icon>
            </div>
        </a>


		
		
        <a href="javascript:;" class="item" data-toggle="modal" data-target="#sidebarPanel">
            <div class="col">
                <ion-icon name="menu-outline"></ion-icon>
            </div>
        </a>
    </div>
    <!-- * App Bottom Menu -->

    <!-- App Sidebar -->
	<?php include ('../php/sidebar.php'); ?>
    <!-- * App Sidebar -->

    <!-- welcome notification  -->
    <div id="notification-welcome" class="notification-box">
        <div class="notification-dialog android-style">
            <div class="notification-header">
                <div class="in">
                    <img src="../assets/img/icon/72x72.png" alt="image" class="imaged w24">
                    <strong>phoenixsoftware.co.nz</strong>
                    <span>just now</span>
                </div>
                <a href="#" class="close-button">
                    <ion-icon name="close"></ion-icon>
                </a>
            </div>
            <div class="notification-content">
                <div class="in">
                    <h3 class="subtitle">Welcome to phoenixcrm.co.nz</h3>
                    <div class="text">
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
        <div id="toast-login-successful" class="toast-box toast-bottom bg-success">
            <div style="text-align: center;" class="in">
                <div style="text-align: center;" class="text">
					<center>Login Successful</center>
                </div>
            </div>
        </div>
				        <div id="toast-login-failed" class="toast-box toast-bottom bg-danger">
            <div style="text-align: center;" class="in">
                <div style="text-align: center;" class="text">
					<center>Login Failed. Please try again</center>
                </div>
            </div>
        </div>

    <!-- * welcome notification -->

    <!-- ///////////// Js Files ////////////////////  -->
    <!-- Jquery -->
    <script src="../assets/js/lib/jquery-3.4.1.min.js"></script>
    <script src="../js/jquery_print.js"></script>
	
	

	<script src="../js/jquery-ui.min.js"> </script>
	
    <!-- Bootstrap-->
    <script src="../assets/js/lib/popper.min.js"></script>
    <script src="../assets/js/lib/bootstrap.min.js"></script>
    <!-- Ionicons -->
    <script type="module" src="https://unpkg.com/ionicons@5.2.3/dist/ionicons/ionicons.js"></script>
  
    <!-- Base Js File
    <script src="../assets/js/base.js"></script> -->

    
	<script src="//cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
    
	
	<!-- Owl Carousel -->
	
	
    <script src="../assets/js/plugins/owl-carousel/owl.carousel.min.js"></script>
    <!-- jQuery Circle Progress -->
    <script src="../assets/js/plugins/jquery-circle-progress/circle-progress.min.js"></script>

  <script>
	
	
	function getCookie(cname) {
  let name = cname + "=";
  let ca = document.cookie.split(';');
  for(let i = 0; i < ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}



$(function() {
	
//	alert ("hello");
	
		$('#date_from').datepicker({
			dateFormat: "dd-mm-yy",
			onSelect: function(dateText) {
				
				change_date_report();
				
			//	alert("Selected date: " + dateText + "; input's current value: " + this.value);
			}
		});

		$('#date_to').datepicker({
			dateFormat: "dd-mm-yy",
						onSelect: function(dateText) {

				change_date_report();

			//	alert("Selected date: " + dateText + "; input's current value: " + this.value);
			}

		});

});

           



    </script>

    <script>





function logout_staff(){



	window.location.replace("logout.php");

//	alert ("logout staff");

	
}



function change_date_report(){

	sel_tab = document.getElementById('sel_tab').value;
	
	if (sel_tab == 1){
		
		load_todays_sales();
		
	}else if (sel_tab == 2){
		
		load_todays_sales_bypymnt();

	}else if (sel_tab == 3){
		
		load_todays_sales_bystaff();

	}else if (sel_tab == 4){
		
		load_todays_sales_byitem();
		
	}else if (sel_tab == 5){
		
		load_todays_sales_summary();
	}

	
}





	  function load_todays_sales() {
			
		//	return false;
		
		var type = "wip";
		
			
		//		var e =  document.getElementById('Outlet_ID');
		//		var outlet_id =  e.options[e.selectedIndex].value;
		
		document.getElementById('sel_tab').value = 1;
		
		document.getElementById("divtodaysalesreport").innerHTML = "loading ... ";
		
		var date_from = document.getElementById('date_from').value;
		var date_to = document.getElementById('date_to').value;
		
		var outlet_id = 1;

				var currentTime = new Date();

		        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		         document.getElementById("divtodaysalesreport").innerHTML = xmlhttp.responseText;
			}
        }
        xmlhttp.open("GET", "../php/getjoblist.php?type="+type+"&reqtime="+currentTime, true);
        xmlhttp.send();
	
}



	  function load_todays_sales_bypymnt() {
		  
		  var type = "currquote";
		  
		var date_from = document.getElementById('date_from').value;
		var date_to = document.getElementById('date_to').value;

		document.getElementById('sel_tab').value = 2;
		
		document.getElementById("divtodaysalesreportpymnt").innerHTML = "loading ... ";

		  
	//	  alert ("xmlhttp.responseText");
			
		//		var e =  document.getElementById('Outlet_ID');
		//		var outlet_id =  e.options[e.selectedIndex].value;
		
		var outlet_id = 1;

				var currentTime = new Date();

		        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			//	alert (xmlhttp.responseText);
		         document.getElementById("divtodaysalesreportpymnt").innerHTML = xmlhttp.responseText;
			}
        }
        xmlhttp.open("GET", "../php/getjoblist.php?type="+type+"&reqtime="+currentTime, true);
        xmlhttp.send();
	
}



	  function load_todays_sales_bystaff() {
		  
		  		  var type = "allquote";
		  
  		document.getElementById('sel_tab').value = 3;
		
		document.getElementById("divtodaysalesreportstaff").innerHTML = "loading ... ";

		var date_from = document.getElementById('date_from').value;
		var date_to = document.getElementById('date_to').value;
		  
	//	  alert ("xmlhttp.responseText");
			
		//		var e =  document.getElementById('Outlet_ID');
		//		var outlet_id =  e.options[e.selectedIndex].value;
		
		var outlet_id = 1;

				var currentTime = new Date();

		        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp = new XMLHttpRequest();
				}
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			//	alert (xmlhttp.responseText);
		         document.getElementById("divtodaysalesreportstaff").innerHTML = xmlhttp.responseText;
			}
        }
        xmlhttp.open("GET", "../php/getjoblist.php?type="+type+"&reqtime="+currentTime, true);
        xmlhttp.send();
	
}









	function set_search(cookie_name, value){
		
		 setCookie(cookie_name, value, 365);
		 
		 $('#example').DataTable().ajax.reload();
		
		
	}
	
	function setCookie(cname, cvalue, exdays) {
  const d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  let expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"+ ";Secure";
}


function update_field_date(date_type, date_value){
	
//	alert (date_type+" "+date_value);
	
	
}


		function printDiv(divName){
			
			var divContents = document.getElementById(divName).innerHTML;
			
			var a = window.open('', '', 'width=500');
            a.document.write('<html> <style type="text/css" media="print"> @page { size: auto;   /* auto is the current printer page size */ margin: 0mm;  /* this affects the margin in the printer settings */} body { background-color:#FFFFFF; border: solid 1px black ; margin: 0px;  /* the margin on the content before printing */} </style>');
	
            a.document.write('<body>');
            a.document.write(divContents);
            a.document.write('</body></html>');
            a.print();
            a.document.close();
			
		}
		
		
		function print_report(){
			
			
			sel_tab = document.getElementById('sel_tab').value;
	
			if (sel_tab == 1){
		
				$('#divtodaysalesshopprint').print()
		
			}else if (sel_tab == 2){
		
				$('#divtodaysalesreportpymntprint').print(/*options*/)

			}else if (sel_tab == 3){
		
				$('#divtodaysalesreportstaffprint').print(/*options*/)

			}else if (sel_tab == 4){
						
				$('#divtodaysalesreportitemprint').print(/*options*/)
				
			}else if (sel_tab == 5){
						
				$('#divtodaysalessummaryprint').print(/*options*/)


			}
			
		
		
			
		}
		
		
			
	function open_job(job_id){
		
		event.preventDefault();
	
	//	alert (job_id);	
		
		sessionStorage.setItem('sel_job_id',job_id);
		
		<?php
		if ($phxcrmclient_id == 100){
		?>
		
		window.location.href = "../jobsf";

		<?php
		}else{
		?>
		window.location.href = "../job";

		<?php
		}
		?>

	
	//	alert ("done");
	}

    </script>

</body>

</html>