<?php include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today1 = date("d/m");
$currentmonth = date(m);
$query2job = "select * from check_month";
$resultjob = mysql_query($query2job,$conn);
while($rowmonth=mysql_fetch_array($resultjob))
{
$check_month = $rowmonth['check_month'];
}


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

<?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'];
													  $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'];
													  //echo $Branch;
													  }	
													   ?>	
													   
													   <?php
$sql = mysql_query("select * from customer_master where customer_id = '".$_REQUEST['customer_id']."'and id='".$_REQUEST['id']."'"); 
while($row = mysql_fetch_array($sql))
{
$customer_name = $row['customer_name'];
$customer_id = $row['customer_id'];

$comptype = $row['comptype'];
$paccname = $row['paccname'];
$industry = $row['industry'];
$subindustry = $row['subindustry'];

$turnover = $row['turnover'];
$website = $row['website'];
$credittime = $row['credittime'];
$creditlimit = $row['creditlimit'];
$last_modified = $row['last_modified'];
$created_by = $row['created_by'];

$Outstanding = $row['Outstanding'];
$billing_address = $row['billing_address'];
$bcity = $row['bcity'];
$bstate = $row['bstate'];
$bcountry = $row['bcountry'];
$bpin = $row['bpin'];
$bphone = $row['bphone'];
$bfax = $row['bfax'];
$bemail = $row['bemail'];
$description = $row['description'];
$acccode= $row['acccode'];
$dispname = $row['dispname'];
$lsrc = $row['lsrc'];
$assigned_to = $row['assigned_to'];
$last_year_turnover = $row['last_year_turnover'];

$shipping_address = $row['shipping_address'];
$scity = $row['scity'];
$sstate = $row['sstate'];
$scountry = $row['scountry'];
$spin = $row['spin'];
$sphone = $row['sphone'];
$sfax = $row['sfax'];
$semail = $row['semail'];
$city = $row['bcity'];
$scity = $row['scity'];
$bgst_no = $row['bgst_no'];
$sgst_no = $row['sgst_no'];

$sdistrict = $row['sdistrict'];

$bdistrict = $row['bdistrict'];
$tertiary=$row['tertiary'];
$bstate_code=$row['bstate_code'];
$sstate_code=$row['sstate_code'];
$segment=$row['segment'];

$pan_no = $row['pan_no'];

}
?><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>THREESTAR - CRM </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">
  <!-- 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">
  <!-- jvectormap -->
  <link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <style>
  table {
  border: 0px solid #666666;
  border-collapse: collapse;
  margin: 0;
  padding: 0;
  table-layout: fixed;
}
table caption {
  font-size: 1.2em;
  margin: .5em 0 .75em;
}
table tr {
  
  border: 0px solid #ddd;
  padding: .35em;
}
table th,
table td {
  padding: .625em;
  
}
table th {
  font-size: .9em;
  letter-spacing: .0em;
  text-transform: uppercase;
}
@media screen and (max-width: 600px) {
  table {
    border: 0;
  }
  table caption {
    font-size: 1.8em;
  }
  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: 0px solid #ddd;
    display: block;
    margin-bottom: .625em;
  }
  table td {
    border-bottom: 0px 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;
  }
}

</style>												   
<script type="text/javascript" src="jquery.min.js"></script>
   <script src="jquery-ui.js"></script>
   <link rel="stylesheet" href="jquery-ui.css">

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<? depat_check($department_name,$designation);?>

<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Dashboard &nbsp;&nbsp;&nbsp;&nbsp;<a href="view_all_accounts.php?customer_id=<?php echo $_REQUEST['customer_id']?>&&id=<? echo $_REQUEST['id']?>" title="Click To Edit" class="btn btn-success"><span class="glyphicon glyphicon glyphicon-edit"></span>&nbsp;Go Back</a>
        
        
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Dashboard</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <!-- Info boxes -->
      <div class="row">
        <div>
 
			<div class="col-xs-12" id="squareboxcontent1" style="">
		<table  class="table table-bordered">
						    <tbody>
						      <tr>
							  <td><h6 style="width: 100%;">
							<input id="collapsefg" name="collapsefg" value="0" type="hidden">
							<span class="glyphicon glyphicon-search"></span>&nbsp;Account Details
						 </h6></td>
						 <? if($comptype!='Direct') { ?><td width="13%"> 
							  
						<a href="other_sub_customer.php?customer_id=<?php echo $_REQUEST['customer_id']?>&&id=<? echo $_REQUEST['id']?>" title="Click To Edit" class="btn btn-success"><span class="glyphicon glyphicon glyphicon-edit"></span>&nbsp;Add 3rd Party</a>
						
						 
					</td><? } ?>
						 <td width="13%"> 
							  
						<a href="edit_accounts.php?customer_id=<?php echo $_REQUEST['customer_id']?>&&id=<? echo $_REQUEST['id']?>" title="Click To Edit" class="btn btn-success"><span class="glyphicon glyphicon glyphicon-edit"></span>&nbsp;Edit</a>
						
						 
					</td>
							  </tr></tbody></table></div>
			<div class="col-xs-12">
				<div class="filter-view">
					<div>
						<table class="table table-bordered">
							<tbody>
								<tr>
							        <td>
							        	<ul class="list-group">
										  <li class="list-group-item">
										  	<label>Customer &nbsp;ID :&nbsp;
											</label>
											<?php echo $customer_id ?>
										  </li>
										  <li class="list-group-item"><label>Account&nbsp;Name :&nbsp;</label>
											<?php echo $customer_name ?>
											<input name="aname" id="aname" value="<?php echo $customer_name ?>" type="hidden">
										  </li> <li class="list-group-item">
										  	<label>Company Type :&nbsp;</label><?php echo $comptype ?>
  	    									<input name="comptype" id="comptype" value="<?php echo $comptype ?>" type="hidden">
										  </li>
										 
										  
										</ul>
							        </td>
							        <td>
							        	<ul class="list-group"> <li class="list-group-item"><label>Assigned to :&nbsp;</label><?php 

$query = "select * from users where id = '$assigned_to'";
//echo $query;
		                 $result = mysql_query($query,$conn);
						 while($row=mysql_fetch_array($result))
	                                              	{
													   $staff_name11 = $row['full_name'];
													   }
													   ?><?php echo $staff_name11 ?></li>
										   <li class="list-group-item"><label>PAN No  :&nbsp;</label><?php echo $pan_no ?></li>
										
										  
										  <li class="list-group-item">
										  
		<? 								  
$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;?>




<label for="turnover">Turn Over <? echo  $curr_fy=$currentyear .'-'. $future;?>: </label>
 <?php $queryls = "select * from tax_invoice where customer_id ='".$_REQUEST['customer_id']."' and year='$curr_fy'";
		  //echo $queryls;
                   $resultls = mysql_query($queryls,$conn);  
               while($row=mysql_fetch_array($resultls))
                                                {
             $amount = $row['amount'];
             $tot_amt=$tot_amt+$amount;
             
             }
               ?>
							INR <?php echo $tot_amt?>
										  </li>
										  
										</ul>
							        </td>
							        <td>
							        	<ul class="list-group">
							        	
										  	
	<li class="list-group-item"><label>Credit Time :&nbsp;</label><?php echo $credittime ?>&nbsp;Days</li>
										  	<li class="list-group-item">Credit Amt:&nbsp;<?php echo $creditlimit ?></li>
											<li class="list-group-item">Turn over last year:&nbsp;INR <?php echo number_format($last_year_turnover,2) ?></li>
											<?php /*?><li class="list-group-item">Outstanding :&nbsp;INR <?php echo number_format($Outstanding,2) ?></li><?php */?>
										</ul>
						          </td>
								  
								  
								  
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		
		 <!--  Address Information  -->
		 
		<div>
			<div class="col-xs-12" id="squareboxcontent1" style="">
				<div class="search-list">
					<div class="search-header">
						<div class="col-xs-12" style="background:#3C8DBC;">
							<h5 style="color:#FFFFFF"><span class="glyphicon glyphicon-map-marker"></span>&nbsp;Address Information&nbsp;
								 									</h5>
					  </div>
						</div>
					<div>
						<div>
							
						  	
						  	<table class="table table-bordered">
								<tbody>
									<tr>
								        <td>
								        	<div class="panel panel-default">
										      <div class="panel-heading"><b>Billing Addresss</b></div>
										      <div class="panel-body">
												<ul class="list-group">
<li class="list-group-item"><label><span class="glyphicon glyphicon-map-marker"></span>&nbsp;Address :&nbsp;</label><?php echo $billing_address ?>
</li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;Country :&nbsp;</label><?php echo $bcountry ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;State :&nbsp;</label><?php echo $bstate ?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State Code: <? echo $bstate_code?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;District :&nbsp;</label><?php echo $bdistrict ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;City :&nbsp;</label><?php echo $city ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-pushpin"></span>&nbsp;PinCode :&nbsp;</label><?php echo $bpin ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-phone-alt"></span>&nbsp;Phone No :&nbsp;</label><?php echo $bphone ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-print"></span>&nbsp;Fax :&nbsp;</label><?php echo $bfax ?></li>
 <li class="list-group-item"><label><span class="glyphicon glyphicon-envelope"></span>&nbsp;Email:&nbsp;</label>
												  	<a class="btn-link" href="mailto:" target="_top">
											        	<?php echo $bemail ?>
											        </a>
												  </li><li class="list-group-item"><label><span class="glyphicon glyphicon-marker"></span>&nbsp;GST No :&nbsp;</label><?php echo $bgst_no ?></li>

												</ul>
												<input name="bcountry" id="bcountry" value="India" type="hidden">
												<input name="editbstate" id="editbstate" value="Maharashtra" type="hidden">
										      </div>
										    </div>
								        </td>
								        
								        <td>
								        	<div class="panel panel-default">
										      <div class="panel-heading"><b>Shipping Addresss</b></div>
										      <div class="panel-body">
												<ul class="list-group">
<li class="list-group-item"><label><span class="glyphicon glyphicon-map-marker"></span>&nbsp;Address :&nbsp;</label><?php echo $shipping_address ?>
</li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;Country :&nbsp;</label><?php echo $scountry ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;State :&nbsp;</label><?php echo $sstate ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State Code: <? echo $sstate_code?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;District :&nbsp;</label><?php echo $sdistrict ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-road"></span>&nbsp;City :&nbsp;</label><?php echo $scity ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-pushpin"></span>&nbsp;PinCode :&nbsp;</label><?php echo $spin ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-phone-alt"></span>&nbsp;Phone No :&nbsp;</label><?php echo $sphone ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-print"></span>&nbsp;Fax :&nbsp;</label><?php echo $sfax ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-envelope"></span>&nbsp;Email:&nbsp;</label><?php echo $semail ?></li>
<li class="list-group-item"><label><span class="glyphicon glyphicon-marker"></span>&nbsp;GST No :&nbsp;</label><?php echo $sgst_no ?></li>
												</ul>
										      </div>
										    </div>
										    <input name="scountry" id="scountry" value="India" type="hidden">
										    <input name="editsstate" id="editsstate" value="" type="hidden">
								        </td>
								        
									</tr>
								</tbody>
							</table>
							
							 
						</div>	
					</div>
				</div>
			</div>
		</div>
		
		<!--  Statutory Information -->
		<div>
			
		</div>
		
		<div>
			<div id="squareboxcontent1" style="">
				<div class="search-list">
					<div class="search-header">
						<div class="col-sm-12 left">
							<div class="col-xs-12" style="background:#3C8DBC;">
							<h5 style="color:#FFFFFF">
								<span class="glyphicon glyphicon-phone-alt"></span>&nbsp;Contact Details
								</h5>
							</div>
						
						</div>
					</div>
					 <div class="col-xs-12">
						<div>
							<table class="table table-bordered">
							<thead>
								   
								<tr>
							        <th>Name</th>
							        <th>Gender</th>
							        <th>Desg/Dept</th>
							        <th>Social Media</th>
									<th>Mobile No.</th>
							        <th>Phone No.</th>
							  		<th colspan="2">Email</th>
							    	<th>Contact Type</th>
							        <th>B'Day</th>
								</tr>
								
							</thead>
							<tbody>
							 <? 
$query1 = "select * from contact_person where customer_id = '".$_REQUEST['customer_id']."'";
$result1 = mysql_query($query1) or die(mysql_error());
while($row=mysql_fetch_array($result1))
		{
$saul = $row['saul'];  
$name = $row['name'];
$gender = $row['gender'];
$designation = $row['designation'];
$department = $row['department'];
$mobile_no = $row['mobile_no'];
$office_phone = $row['office_phone'];
$email = $row['email'];
$contact_types = $row['contact_types'];
$bday = $row['bday'];	
?>
 								<tr>
							        <td><?php echo $saul ?>&nbsp;<?php echo $name ?></td>
							        <td><?php echo $gender ?></td>
							        <td><?php echo $designation ?> / <?php echo $department ?></td>
							        <td></td>
							        <td><?php echo $mobile_no ?></td>
							        <td><?php echo $office_phone ?></td>
							        <td colspan="2"><?php echo $email ?></td>
							        <td><?php echo $contact_types ?></td>
							        <td><?php echo $bday ?></td>
								</tr>
								<?php } ?>
								 
							</tbody>
						</table>
						</div>	
					</div>
				</div>
			</div>
		</div>
		
		<!--  Activity List  -->
		<div>
			<div id="squareboxcontent1" style="">
				<div class="search-list">
					<div class="search-header">
						<div class="col-sm-12 left">
							<div class="col-xs-12" style="background:#3C8DBC;">
							<h5 style="color:#FFFFFF">
								<span class="glyphicon glyphicon-phone-alt"></span>&nbsp;Activity List
								</h5>
							</div>
						
						</div>
					</div>
		
					
					<div class="col-xs-12">
						<div>
							<table class="table table-bordered">
							<thead>
								<tr>
							        
							        <th>Date</th>
							        <th>Type</th>
							        <th>Contact Name</th>
									<th colspan="2">Conversation</th>
							        <th>Status</th>
							        <th>Assigned To</th>
								</tr>
							</thead>
							<tbody>
<?php 
$sqlac= "SELECT * FROM quotation_follow_up where customer_id = '".$_REQUEST['customer_id']."' and id = '".$_REQUEST['id']."'";
$sqlac1 = mysql_query($sqlac,$conn);

while($curnm = mysql_fetch_array($sqlac1)){
$follow_up_status = $curnm['enquiry_approve_status'];
$quotation_approve_status = $curnm['quotation_approve_status'];
$customer_name = $curnm['customer_name'];
$call_follow_up_id = $curnm['call_follow_up_id'];
$last_date = $curnm['conversation_date'];
$factivitytype = $curnm['factivitytype'];
$login = $curnm['login'];
$sstatus = $curnm['sstatus'];
$contact_person = $curnm['contact_person'];
$conversation_details = $curnm['conversation_details'];

?>
								
								<tr>
							       
							        
							        <td class="center"><?php echo $last_date ?></td>
							        
							        <td><?php echo $factivitytype ?></td>
    
							        <td title=""><?php echo $contact_person; ?></td>
							        
							        <td title="" colspan="2"><div style="padding-left:5px; padding-right:5px;"><? echo $conversation_details;?></div></td>
							        
							        <td><?php echo $sstatus; ?></td>
							        
							        <td><?php echo $login; ?></td>
								</tr>
								 <?php } ?>
							</tbody>
						</table>
					</div>	
					
				</div>
			</div>
		</div>
		
		</div>
		
		<!--  Activity List for delaer -->
		
		
		
		
		
		
		<!--  Quotation List  -->
		<div>
			
	
		</div>
		<!--  SalesOrder List  -->
		
		
	
		
		
		
		
		<!--  Email List  -->
				 
		
	</div>

    </section></div>
    <!-- /.content -->
  <!-- /.content-wrapper -->

     <? include'footer.php'; ?>

