<?php include 'connection.php';
session_start(); 
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
	$query2job = "select * from check_month";
$resultjob = mysql_query($query2job,$conn);
while($rowmonth=mysql_fetch_array($resultjob))
{
$check_month = $rowmonth['check_month'];
}

date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today2 = date("Y-m-d");
$today1 = date("d/m");
$currentmonth = date(m);
date_default_timezone_set('Asia/Calcutta');
$today = date("Y-m-d");
 
							  
$month1=date("m");
if($month1>$check_month)
  {
  $currentyear = date("Y");
 $curr_full_year=date("Y");
$curr_short_year=date("y");
$future=$curr_short_year+1;
} else {
$currentyear1 = date("Y");
$currentyear = $currentyear1-1;
$curr_full_year1=date("Y");
 $curr_full_year=$curr_full_year1-1;
 $curr_short_year1=date("y");

$curr_short_year=$curr_short_year1-1;
$future=$curr_short_year+1;
}
?>


<?   $curr_fy=$currentyear .'-'. $future;?>

 <? include('sahavas_dropdown_function.php');?>

 <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>shigmoda.com</title>
  <!-- Tell the browser to be responsive to screen width -->
 <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"><link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
  <!-- daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="plugins/iCheck/all.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="plugins/colorpicker/bootstrap-colorpicker.min.css">
  <!-- Bootstrap time Picker -->
  <link rel="stylesheet" href="plugins/timepicker/bootstrap-timepicker.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="plugins/select2/select2.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
		<script src="jquery.table2excel.min.js"></script><link rel="stylesheet" href="jquery-ui.css">

  <script src="jquery-ui.js"></script>
  <?php 

$query = "select * from users where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
//echo $query;
$result = mysql_query($query,$conn);
while($row=mysql_fetch_array($result))
	                                              	{
													  $staff_name = $row['full_name'];$staff_name = $row['full_name'];
													  $full_name = $row['full_name'];
													  $avatar = $row['avatar'];
													  $department_name = $row['department_name'];
													  $staff_id  = $row['id'];
													  $username = $row['username'];
													  $our_company = $row['our_company'];
													  $designation = $row['designation'];
													  $sales_group = $row['sales_group'];
													  $head = $row['head'];
													  $region = $row['region'];
													  $district = $row['district'];
													  $email = $row['email'];
													  $mobile_no = $row['mobile_no'];
													  $staff_id_self  = $row['id'];
													  $sales_region = $row['region'];
													  
													  $back_office_login=$row['back_office_login'];
													  $back_office_head=$row['back_office_head'];
													  $back_office_region=$row['back_office_region'];
													  $back_office_group=$row['back_office_group'];
													  $active_login = $row['active_login'];

													  
													  //echo $Branch;
													  }	
													   ?>	
<?php $querylogin = "select * from staff_login where username = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
$resultlogin = mysql_query($querylogin,$conn);
while($row=mysql_fetch_array($resultlogin))
{
$Designation = $row['designation'];
$staff_name = $row['staff_name'];

}
?>
<?php
	require_once("perpage.php");	
	require_once("dbcontroller.php");
	$db_handle = new DBController();
	
	$our_company_name = "";
	$datepicker = "";
	$datepicker1 = "";
	$customer_name = "";
	$inv_no ="";
	$inv_type = '';
	
	$queryCondition = "";
	if(!empty($_POST["search"])) {
		foreach($_POST["search"] as $k=>$v){
			if(!empty($v)) {

$queryCases = array("our_company_name","datepicker","datepicker1","customer_name","inv_no","inv_type");
				if(in_array($k,$queryCases)) {
					if(!empty($queryCondition)) {
						$queryCondition .= " AND ";
						
					} else {
						$queryCondition .= " WHERE ";
					}
				}
				switch($k) {
						case "our_company_name":
						$our_company_name = $v;
						$queryCondition .= "our_company_name LIKE '" . $v . "%'";
						break;
						
						case "datepicker":
						$datepicker = $v;
						$queryCondition .= "inv_date BETWEEN";
						case "datepicker1":
						$datepicker1 = $v;
						$queryCondition .= "'" . $v . "'";
						break;
						
												
												
						case "customer_name":
						$customer_name = $v;
						$queryCondition .= "customer_name LIKE '%" . $v . "%'";
						break;
						
						
						case "inv_type":
						$inv_type = $v;
						$queryCondition .= "inv_type LIKE '" . $v . "%'";
						break;
						
						case "inv_no":
						$inv_no = $v;
						$queryCondition .= "inv_no LIKE '%" . $v . "%'";
						break;
						
						
						
				}
			}
		}
	}
	
	?>
	<? 
if($queryCondition!='') { 
	$orderby = "  ORDER BY main_id Desc  "; 
	$sql = "SELECT * FROM main_job_details " . $queryCondition ."";
	} else {
		$sql = "SELECT * FROM main_job_details ORDER BY main_id Desc";
	}
	
	$resultnote = mysql_query($sql);

	$num_rownote = mysql_num_rows($resultnote);

	//echo $sql ;
	$href = 'view_all_jobs.php';					
		
	$perPage = 500; 
	$page = 1;
	if(isset($_POST['page'])){
		$page = $_POST['page'];
	}
	$start = ($page-1)*$perPage;
	if($start < 0) $start = 0;
		
	$query =  $sql . $orderby .  " limit " . $start . "," . $perPage; 
	$result = $db_handle->runQuery($query);
	
	if(!empty($result)) {
		$result["perpage"] = showperpage($sql, $perPage, $href);
	}
?>

   <style>
  table {
  border: 1px solid #ccc;
  border-collapse: collapse;
  margin: 0;
  padding: 0;
  table-layout: fixed;
}
table caption {
  font-size: 1.2em;
  margin: .5em 0 .75em;
}
table tr {
  
  border: 1px solid #ddd;
  padding: .35em;
}
table th,
table td {
  padding: .625em;
  
}
table th {
  font-size: 13px;; font-family:Arial, Helvetica, sans-serif;
  text-transform: capitalize; margin-right:5px;
}
@media screen and (max-width: 600px) {
  table {
    border: 0;
  }
  table caption {
    font-size: 1.2em;
  }
  table thead {
    border: none;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }
  table tr {
    border-bottom: 3px solid #ddd;
    display: block;
    margin-bottom: .625em;
  }
  table td {
    border-bottom: 1px solid #ddd;
    display: block;
    font-size: .9em;
    
  }
  table td:before {
    /*
    * aria-label has no advantage, it won't be read inside a table
    content: attr(aria-label);
    */
    content: attr(data-label);
    float: left;
    font-weight: bold;
    text-transform: uppercase;
  }
  table td:last-child {
    border-bottom: 0;
  }
}

  .style1 {color: #000066}
  </style> 


</head><link rel="stylesheet" href="jquery-ui.css">
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<?php depat_check($department_name,$designation);;?>

	
<div class="content-wrapper">
    <!-- Content Header (Page header) --->

<section class="content-header">
      <h1>
Invoice  Report  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<? back_toindex($department_name,$designation);?>
        
      </h1>
	  </section>
   
	
			
<section class="content"> 
<div class="row">
 <div>
		
					
			<div class="col-sm-12" id="squareboxcontent1" style="">
				<div class="filter-view">
					<div class="table-responsive">
						<form name="frmSearch" method="post" action="view_all_direct_invoice.php">
						<div class="search-box">

			</div>



			<table class="table2excel table table-striped table-bordered table-hover" data-tableName="Test Table 1">
		
			<div class="search-header" style="padding-top:3px;">
						<div><?php echo $pagination;?>
						
						<div class="col-xs-12" style="background:#3C8DBC;">
							<h5 style="color:#FFFFFF">
								<span class="glyphicon glyphicon-map-marker"></span>&nbsp;View All Jobs Details&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#FFFFFF"> No Of Account ( <? echo $num_rownote;?> ) </span></h5>	
					  </div>
						</div>
				  </div>
			
      <thead>
	 
  <tr>
     <th>Customer Name</th>
	 <th>Main Job No</th>
	 <th>Job Date</th>
	 <th>Ref No.</th>
	 <th>Account Of</th>
	  <th>Inv Type</th>
	  <th>#</th>
                </tr>
      </thead>
				<tbody>
					<?php
						foreach($result as $k=>$v) {
						if(is_numeric($k)) {
						$customer_id =$result[$k]['customer_id'];
$main_job_no=$result[$k]['main_job_no'];
$ref_no =$result[$k]['ref_no'];
$account_of =$result[$k]['account_of'];
$inv_type =$result[$k]['inv_type'];
$job_date =$result[$k]['job_date'];


	
?>

		 <tr>
    <th><?php echo $result[$k]["customer_name"]; ?></th>
    <th><?php echo $result[$k]["main_job_no"]; ?></th>
	  <th><?php echo $result[$k]["job_date"]; ?></th>
	
    <th><?php echo $result[$k]["ref_no"]; ?></th>
      
  <th><?php echo $result[$k]["account_of"]; ?></th>

   
     <th><?php echo $result[$k]["inv_type"]; ?></th>
    <th>  <a href="make_challan_master.php?main_id=<?php echo $result[$k]["main_id"]?>" target="_blank"> Make Challan </a>   </th>
    <th> <a href="make_direct_trans_step1.php?main_id=<?php echo $result[$k]["main_id"]?>" target="_blank">Make Transport Invoice</a> </th>
  </tr>	
<?php
						}
						}
					?>
				 
				<tbody>
			</table>
			
			
			</form>
					</div>
				</div>
			</div>
</div>
	</div></section></div>
    <? include'footer.php'; ?>
