<?php 
include('includes/SQL_CommonFunctions.inc');
include('CRM/functions.php');
//************************INCLUDE ROOT FILES********************START HERE***********AMIT SINGH*****16-10-2012**************** 


//***********************INCLUDE ROOT FILES********************START HERE***********AMIT SINGH*******16-10-2012**************    

$site_sql=DB_query("Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')",$db);
$site_row=DB_fetch_array($site_sql);// GET BRANCH

$month=array("Jan","Feb","March","Apr","May","Jun","July","Aug","Sept","Oct","Nov","Dec","Jan","Feb","March");


$s=new db_query();
$deptid=  $s->GetFieldValue('www_users'," id='".$_SESSION['UserID']."' " ,'mst_dpt_heirarchy');
$LowerDeptList=GETLowerDeptUser($_SESSION['UserID'],$deptid,$_SESSION['ACGCompanyId']);
$lowerlist=  UserDeptList($LowerDeptList);
 if(count($lowerlist)>0)
$lowerlist=implode(",",$lowerlist).",".$_SESSION['UserID'];
else
$lowerlist="'".$_SESSION['UserID']."'";
?>


<script type="text/javascript" language="javascript">
function showsalesdata()	
{
	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("divdata").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","getsaleorderpending.php",true);
	xmlhttp.send();	
}




function showpendingordapproval()
{
//alert("hiiiii");
	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("divdata").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","GetpendingordapprovalExe.php",true);
	xmlhttp.send();	
}


function showhighestsale()
{
//alert("hiiiii");
	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("divdata2").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","GethighestsaleExe.php",true);
	xmlhttp.send();	
}
</script>


<script>
	$(document).ready(function() {
		$('#navigation > li > a').click(function(event){
		event.preventDefault();//stop browser to take action for clicked anchor
 
		//get displaying tab content jQuery selector
		var active_tab_selector = $('#navigation > li.active > a').attr('href');					
 
		//find actived navigation and remove 'active' css
		var actived_nav = $('#navigation > li.active');
		actived_nav.removeClass('active');
 
		//add 'active' css into clicked navigation
		$(this).parents('li').addClass('active');
 
		//hide displaying tab content
		$(active_tab_selector).removeClass('active');
		$(active_tab_selector).addClass('hide');
 
		//show target tab content
		var target_tab_selector = $(this).attr('href');
		$(target_tab_selector).removeClass('hide');
		$(target_tab_selector).addClass('active');
	     });
	  });
	</script>
<link href="css/dashboard1.css" rel="stylesheet" type="text/css" />
<script src="ui/jquery.ui.timepicker.js"></script>
<link rel="stylesheet" href="css/new_mxerp.css">
 <style type="text/css">

* {
	margin: 0;
	padding: 0;
	outline: none;	
}

ul {
	list-style: none;	
}

#navigation {
background-color:#FFFFFF;
padding-top:10px;
padding-bottom:10px;
	font: bold 12px/18px "Helvetica Neue", Helvetica, Arial, sans-serif;
	text-transform: uppercase;
	color: #444;
	width:98%;
	float:left;
	padding-left:20px;
}

#navigation:after {
	clear: both;
    content: ".";
    display: block;
    height: 0;
    visibility: hidden;
}

#navigation ul {	
	float: left;

    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.07);
	-webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

#navigation li {
	margin-left:5px;
	float: left;
	border-style: solid; 
	border-width: 1px;
    border-color: #BABABA #BABABA #BABABA #BABABA;
	box-shadow: 0 1px rgba(255,255,255,1) inset;
	-webkit-box-shadow: 0 1px rgba(255,255,255,1) inset;
	background: #EDEDED; /* Old browsers */
	background: -moz-linear-gradient(top, #EDEDED 0%, #dad8d8 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#EDEDED), color-stop(100%,#dad8d8)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top, #EDEDED 0%,#dad8d8 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top, #EDEDED 0%,#dad8d8 100%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top, #EDEDED 0%,#dad8d8 100%); /* IE10+ */
	background: linear-gradient(top, #EDEDED 0%,#dad8d8 100%); /* W3C */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#EDEDED', endColorstr='#dad8d8',GradientType=0 ); /* IE6-9 */	
	border-radius: 5px;
	moz-border-radius: 5px;
	webkit-border-radius: 5px;
}

#navigation li:hover, #navigation li.current {
	box-shadow: 0 1px rgba(255,255,255,0.2) inset;
	-webkit-box-shadow: 0 1px rgba(255,255,255,0.2) inset;
	border-color: #262626 !important;
	background: #4D4D4D; /* Old browsers */
	background: -moz-linear-gradient(top, #4D4D4D 0%, #262626 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4D4D4D), color-stop(100%,#262626)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* IE10+ */
	background: linear-gradient(top, #4D4D4D 0%,#262626 100%); /* W3C */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4D4D4D', endColorstr='#262626',GradientType=0 ); /* IE6-9 */
}

#navigation a {
	display: block;
	padding: 10px 12px;
	color: #444;
	text-decoration: none;
	text-shadow: 0 1px #FFF;
}

#navigation a:hover, #navigation li.current a {
	color: #FFF;
	text-shadow: 0 0px #fff;
}

#navigation li:first-child {
	border-left-color: #BABABA;
}

#navigation li:last-child {

}
.tab-content.active{
				display: block;
	
			}
 
			.tab-content.hide{
				display: none;
			}
.style1 {font-style: italic}

.nav {

			}
 
			.nav > li > a {
	
			}
 
			.nav-tabs{
		
			}
 
			.nav-tabs:before,
			.nav-tabs:after {
			 
			}
 
			.nav-tabs:after {
	
			}
 
			.nav-tabs > li {
			  float: left;
			}
 
			.nav-tabs > li > a {
			 
			}
 
			.nav-tabs {
			
			}
 
			.nav-tabs > li {
			
			}
 
			.nav-tabs > li > a {
		
		
			}
 
			.nav-tabs > li > a:hover {
			
			}
 
			.nav-tabs > .active > a,
			.nav-tabs > .active > a:hover {
				box-shadow: 0 1px rgba(255,255,255,0.2) inset;
	-webkit-box-shadow: 0 0px rgba(255,255,255,0.2) inset;
	background: #4D4D4D; /* Old browsers */
	background: -moz-linear-gradient(top, #4D4D4D 0%, #262626 100%); /* FF3.6+ */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4D4D4D), color-stop(100%,#262626)); /* Chrome,Safari4+ */
	background: -webkit-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* Chrome10+,Safari5.1+ */
	background: -o-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* Opera 11.10+ */
	background: -ms-linear-gradient(top, #4D4D4D 0%,#262626 100%); /* IE10+ */
	background: linear-gradient(top, #4D4D4D 0%,#262626 100%); /* W3C */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4D4D4D', endColorstr='#262626',GradientType=0 );
	border-radius: 5px;
	moz-border-radius: 5px;
	webkit-border-radius: 5px;
	 /* IE6-9 */
	
	 /* IE6-9 */
			}
 
			li {
			  line-height: 18px;
			}
 
			.tab-content.active{
				display: block;
				color:#FFFFFF;
			}
 
			.tab-content.hide{
				display: none;
			}
 </style>
  <!--<h1 style="font-size:18px; border-bottom:#666666 solid 1px; color:#003333; padding-bottom:5px;">Employee Portal</h1>
-->



<div class="maindiv" style="width:960px;">
	<!--insert table 1 start -->
	<div>
<nav>
		<ul id="navigation">
			<li class="active"><a href="#tab1">Dashboard</a></li>
			<li><a href="#tab2">Task Assignment</a></li>
			<li><a href="#tab3">Task Execution</a></li>
			<li><a href="#tab4">To Do</a></li>
			<li><a href="#tab5">Follow Ups</a></li>
			<li><a href="#tab6">Meetings</a></li>
			<li><a href="#">Leave Management</a></li>
			<li><a href="#">Email</a></li>
			<li><a href="#">My Calender</a></li>
			<li><a href="#tab7">TA DA CLAIM</a></li>
		</ul>
	</nav>

	</div><!--insert table 1 close -->
	<!--insert table 2 start --><!--insert table 2 close -->
	<section id="tab1" class="tab-content active">
    <div id="body_part">
	<!-- left part of main body -->	
	  <div class="body_left" style="width:450px;">
		<h1>Assigned Task Status </h1>	  
		<div style="margin-top:3px;margin-bottom:5px; overflow:auto; height:184px;">
			<?php 
$SQLTask=DB_query("SELECT * FROM tsk_taskassignment where assigned_by in($lowerlist)",$db);
?>
<table width="100%" cellpadding="3" cellspacing="0" border="1">
	<tr class="row1">
		 <td class="tabledata">Branch</td>
          <td class="tabledata">Task No.</td>
		  <td class="tabledata">Start Date</td>
          <td class="tabledata">End Date</td>
		  <td class="tabledata">Assigned To</td>
		  <td class="tabledata">Task</td>
		  <td class="tabledata">Status</td>
	</tr>
<?php while($TaskView=DB_fetch_array($SQLTask)) {?>
	<tr class="row1">
		<td><?php  echo $s->GetFieldValue('locations',"loccode='".$TaskView['branch']."'",'locationname'); ?></td>
		<td><?php echo $TaskView['task_no']; ?></td>
		<td><?php echo ConvertSQLDate($TaskView['start_date']); ?></td>
		<td><?php echo ConvertSQLDate($TaskView['end_date']); ?></td>
		<td><?php if($TaskView['assign_to']=='user'){echo $s->getField('www_users','id',$TaskView['user_id'],'realname');;} else{echo $TaskView['assign_to'];} ?></td>
		
		<td><?php echo $TaskView['task_description']; ?></td>
		<td><?php echo $TaskView['status']; ?></td>
	</tr>
<?php }?>
</table>
		</div>
	
		
		<h1>Task Execution Status  </h1>	  
		<div style="margin-top:3px;margin-bottom:5px; overflow:auto; height:155px;">
		<div id="divdata">
			<?php 
$SQLTask=DB_query("SELECT * FROM tsk_taskassignment where assigned_by in($lowerlist)",$db);
?>
<table width="100%" cellpadding="3" cellspacing="0" border="1">
	<tr class="row1">
		 <td class="tabledata">Branch</td>
          <td class="tabledata">Task No.</td>
		  <td class="tabledata">Start Date</td>
          <td class="tabledata">End Date</td>
		  <td class="tabledata">Assigned By</td>
		  <td class="tabledata">Task</td>
		  <td class="tabledata">Status</td>
	</tr>
<?php while($TaskView=DB_fetch_array($SQLTask)) {?>
	<tr class="row1">
		<td><?php  echo $s->GetFieldValue('locations',"loccode='".$TaskView['branch']."'",'locationname'); ?></td>
		<td><?php echo $TaskView['task_no']; ?></td>
		<td><?php echo ConvertSQLDate($TaskView['start_date']); ?></td>
		<td><?php echo ConvertSQLDate($TaskView['end_date']); ?></td>
		<td><?php if($TaskView['assign_to']=='user'){echo $s->getField('www_users','id',$TaskView['assigned_by'],'realname');;} else{echo $TaskView['assign_to'];} ?></td>
		
		<td><?php echo $TaskView['task_description']; ?></td>
		<td><?php echo $TaskView['status']; ?></td>
	</tr>
<?php }?>
</table>
			</div>
		</div>
	  </div>	<!-- left part of main body close -->	
       	<!-- right part of main body -->		
	  <div class="body_right" style="width:450px;">
  		<h1>To Do Calender</h1>	  
		<div style="margin-top:3px;margin-bottom:5px; overflow:auto; height:185px;">
		
		
		 <strong></strong>
		 <div id="calenderdata">
		   <span class="style1">
		   
		   <?php include('Activity_calander.php'); ?>
	      </span>         </div>
		</div>
		
		  		<h1>My Leave </h1>	  
				<div style="margin-top:3px;margin-bottom:5px; overflow:auto; height:150px;">
				<div id="divdata2">
			<table border="1" width="100%" cellpadding="3" cellspacing="3">
<tr class="row1">
	<td class="tabledata"><strong>Leave Type</strong></td>
	<td class="tabledata"><strong>Allowed Leave</strong></td>
	<td class="tabledata"><strong>Leave Taken</strong></td>
	<td class="tabledata"><strong>Remaining Leave</strong></td>
	<td class="tabledata"><strong>Detailed View</strong></td>
</tr>
<?php 
function leave_calculation($empid,$type)
{
	 global $db;
	
 
     $calLeaveRecord = "Select sum(total_days) as total from emp_leave_apply where empid='".$empid."' and leave_type='".$type."' group by leave_type  ";	   
   $ResultData = DB_query($calLeaveRecord,$db);
  // echo DB_num_rows($ResultData);
    $RowData = DB_fetch_array($ResultData);
    if($RowData['total']=='')
	return 0;
	else
	return($RowData['total']);
}
 $GetEmpLeave = "SELECT * FROM emp_leave WHERE emp_id='".$_SESSION['UserID']."'";	   
$ResultEmpLeave = DB_query($GetEmpLeave,$db);
while($RowEmpLeave=DB_fetch_array($ResultEmpLeave)){?>
<tr >cxbvcx
	<td><?php echo $s->getField('leavemaster','leavecode',$RowEmpLeave['leave_type'],'leavename');
	echo "( ".$RowEmpLeave['leave_type']." )";?> </td>
	<td><?php  echo $RowEmpLeave['leave_days']?> </td>
	<td> <?php echo $leaves= leave_calculation($_SESSION['UserID'],$RowEmpLeave['leave_type'])?></td>
	<td><?php echo $RowEmpLeave['leave_days']-$leaves;?> </td>
	<td><a href="<?php echo $viewrurl; ?>&empid=<?php echo $RowData['id']; ?>&leave_type=<?php echo $RowEmpLeave['leave_type']?>">View</a></td>
</tr>
<?php } ?>				
</table>
			</div>
		</div>
	  </div><!-- left part of main body close -->	
	  <div class="cl"></div>
	<div style="height:15px;"></div>
<!-- Table 3 -4 Start here -->
<!-- Table 3 Start herer -->
<!--<div class="body_left">
		<h1>Potentials</h1>	  
		<div style="margin-top:3px;margin-bottom:5px; overflow:auto; height:150px;">
			<table width="100%" border="1" cellspacing="0" cellpadding="3">
  <tr>
    <td class="tabledata">Month</td>
    <td class="tabledata">Party</td>
    <td class="tabledata">Expected Order</td>
  </tr>
  <tr>
    <td class="tabledata_fist">2-3 - Dichloro Benzoyl Chloride</td>
    <td class="tabledata1">300.00</td>
    <td class="tabledata1">&nbsp;</td>
  </tr>

  <tr>
    <td class="tabledata_fist">1-(2,3 Dichloro Phenyl) Piperazine HCL</td>
    <td class="tabledata1">750.00</td>
    <td class="tabledata1">&nbsp;</td>
  </tr>
  <tr>
    <td class="tabledata_fist">2-3, Dichloro Benzolc acid</td>
    <td class="tabledata1">25.00</td>
    <td class="tabledata1">&nbsp;</td>
  </tr>
  <tr>
    <td class="tabledata_fist">2,3-Dichloro Benzoyl Cyanide</td>
    <td class="tabledata1">1.00</td>
    <td class="tabledata1">&nbsp;</td>
  </tr>
</table>
		</div>
	  </div>	<!-- Table 3 Close herer -->
		<!-- Table 4 Start herer -->
	  <!--<div class="body_right">
	  </div>--><!-- Table 4 Start herer -->

<!-- Table 3 -4 Start Close -->	  
	  <div class="cl"></div>	  
    </div>
	
	</section>
	<section id="tab2" class="tab-content hide">
	<form action="" method="post" name="myform" >
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td class="tabledata1">Branch</td>
	<td colspan="3"><select name="site"  style="width:150px;">
<?php $Sitesql="select * from locations where  CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
	$SiteRes=DB_query($Sitesql,$db);
	while($SiteRow=DB_fetch_array($SiteRes)){?>
            <option value="<?php  echo $SiteRow['loccode'];?>" <?php  echo $_REQUEST['site']==$SiteRow['loccode']?'selected':''?> >
            <?php  echo $SiteRow['locationname'];?>
            </option>
<?php }?>
          </select>
	</td>
</tr>
<tr class="row1">
	<td class="tabledata1">From:</td>
	<td><input name="fromdate" type="text" style="width:150px;"  class="datepicker"/></td>
	<td class="tabledata1">To:</td>
	<td><input name="todate" type="text" style="width:150px;"  class="datepicker"/></td>
</tr>
<tr class="row1">
	<td style="text-align:center;" colspan="4">
	<input name="Search" type="submit" class="search"  value="Search"/>
	</td>
</tr>
<tr class="row1">
	<td colspan="4"><a href="<?php echo "index.php?route=TaskMgt/task_assign".$rurl.'&action=AddNew'?>">
				<input type="button" name="Create" value="Assign Task" class="search" /></a>
				<input type="submit" name="Delete" value="Delete" class="search" />
				<?php if($_REQUEST['Search']){ ?><a href="TaskMgt/TicketExp.php">
				<input type="button" name="Export" value="Export" class="search"  /></a>
	<?php }?>
	</td>
</tr>
<tr class="row1">
	<td colspan="4">
	<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
          <td class="tabledata"><input name="leadid" type="checkbox"   id="leadid" onclick="LeadData()"    /></td>
          <td class="tabledata">Branch</td>
          <td class="tabledata">Task No.</td>
		  <td class="tabledata">Start Date</td>
          <td class="tabledata">End Date</td>
		  <td class="tabledata">Assigned To</td>
		   <td class="tabledata">Task</td>
		  <td class="tabledata">Status</td>
 		 <td class="tabledata">Action</td>
</tr>
		<?php 
		$query = "SELECT * FROM tsk_taskassignment where assigned_by in($lowerlist) and CompanyId='".$_SESSION['ACGCompanyId']."'";
		$query .= " ORDER BY start_date desc";
		$gettt = DB_query($query,$db);
		$_SESSION['Ticket']=$query;
		$i=0;
		while($row_quotes = DB_fetch_array($gettt)){?>
		<tr class="row1">
			<td style="white-space:nowrap;" valign="top">
			<?php
			 $SOURL="index.php?route=TaskMgt/task_assign&action=Edit&id=".$row_quotes['id'].$rurl;
			 $REURL="index.php?route=TaskMgt/task_assign&action=SHRem&id=".$row_quotes['id'].$rurl;
			 //$SO_VIEW="index.php?route=TaskMgt/task_assign&action=View&ttid=".$row_quotes['id'].$rurl;
			?>
			   <input name="leadid[]" type="checkbox" id="leadid_<?php echo $i+1; ?>"   value="<?php  echo $row_quotes['id']?>"  />
			 <a href="<?php echo $SOURL ;?>"><img src="images/icon_edit.gif" width="10px"  height="10" /></a>
			 <!--<a href="<?php //echo $SO_VIEW?>" ><img src="images/search.gif" width="10px"  height="10" /></a>-->
		  </td>
          <td valign="top" ><?php  echo $s->GetFieldValue('locations',"loccode='".$row_quotes['branch']."'",'locationname'); ?></td>
          <td valign="top" style="white-space:nowrap"><?php echo $row_quotes['task_no'];?> </td>
          <td valign="top" style="white-space:nowrap"><?php echo ConvertSQLDate($row_quotes['start_date']);?> </td>
		  <td valign="top" ><?php echo ConvertSQLDate($row_quotes['end_date']);?></td>
          <td valign="top"><?php  if($row_quotes['assign_to']=='user'){echo $s->getField('www_users','id',$row_quotes['user_id'],'realname');;} else{echo $row_quotes['assign_to'];}//echo $s->GetFieldValue('www_users',"id='".$row_quotes['createdBy']."'",'userid'); ?></td>
		  <td valign="top"><?php echo $row_quotes['task_description'];?> </td>
			 <td valign="top"><?php echo $row_quotes['status'];?> </td>
			 <td valign="top"><a href="<?php echo $REURL ;?>">Show Remarks</a></td>
        </tr>
		<?php $i++;} ?>
        
      </table>
	</td>
</tr>
</table>
  </form>
	</section>
	
		<section id="tab3" class="tab-content hide">
   <form action="" method="post" name="myform" >
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td class="tabledata1">Branch</td>
	<td colspan="3"><select name="site"  style="width:150px;">
            <option value="0">--All--</option>
	<?php $Sitesql="select * from locations where  CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
	$SiteRes=DB_query($Sitesql,$db);
	while($SiteRow=DB_fetch_array($SiteRes)){?>
            <option value="<?php  echo $SiteRow['loccode'];?>" <?php  echo $_REQUEST['site']==$SiteRow['loccode']?'selected':''?> >
            <?php  echo $SiteRow['locationname'];?></option>
<?php }?>
       </select></td>
</tr>
<tr class="row1">
	<td class="tabledata1">From: </td>
	<td><input name="fromdate" type="text" style="width:150px;"  class="datepicker"/></td>
	<td class="tabledata1">To: 
	<td><input name="todate" type="text" style="width:150px;"  class="datepicker"/></td>
</tr>
<tr class="row1">
	<td colspan="4" style="text-align:center;"><input name="Search" type="submit"  value="Search" class="search"/></td>
</tr>
<?php if($_REQUEST['Search']){ ?>
<tr class="row1">
	<td colspan="4"><a href="TicketExp.php">
                <input type="button" name="Export" value="Export" class="search" /></a>
	</td>
</tr>
<?php }?>

<tr class="row1">
	<td colspan="4">
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
          <td class="tabledata"><input name="salesid" type="checkbox"   id="salesid" onClick="LeadData()" /></td>
          <td class="tabledata">Branch</td>
          <td class="tabledata">Task No.</td>
		  <td class="tabledata">Start Date</td>
          <td class="tabledata">End Date</td>
		  <td class="tabledata">Assigned By</td>
		   <td class="tabledata">Task</td>
		  <td class="tabledata">Status</td>
 		 <td class="tabledata" colspan="2"><div align="center">Action</div></td>
</tr>
		<?php 
		$query = "SELECT * FROM tsk_taskassignment where assigned_by in($lowerlist) and CompanyId='".$_SESSION['ACGCompanyId']."'";
		$query .= " ORDER BY start_date desc";
		$gettt = DB_query($query,$db);
		$_SESSION['Ticket']=$query;
		while($row_quotes = DB_fetch_array($gettt)){?>
		<tr bgcolor="#c1c1c1">
			<td style="white-space:nowrap;" valign="top">
			<?php
			 $SOURL="index.php?route=TaskMgt/task_assign&action=Edit&id=".$row_quotes['id'].$rurl;
			 $REURL="index.php?route=TaskMgt/task_assign&action=AddRem&id=".$row_quotes['id'].$rurl;
			 $CLURL="index.php?route=TaskMgt/task_assign&action=AddRem&CL=1&id=".$row_quotes['id'].$rurl;
			 //$SO_VIEW="index.php?route=TaskMgt/task_assign&action=View&ttid=".$row_quotes['id'].$rurl;
			?>
			   <input name="salesid[]" type="checkbox" id="salesid_<?php echo $i; ?>"   value="<?php  echo $row_quotes['id']?>"  />
			 <a href="<?php echo $SOURL ;?>"><img src="images/icon_edit.gif" width="10px"  height="10" /></a>
			 <!--<a href="<?php //echo $SO_VIEW?>" ><img src="images/search.gif" width="10px"  height="10" /></a>-->
		  </td>
          <td valign="top" ><?php  echo $s->GetFieldValue('locations',"loccode='".$row_quotes['branch']."'",'locationname'); ?></td>
          <td valign="top" style="white-space:nowrap"><?php echo $row_quotes['task_no'];?> </td>
          <td valign="top" style="white-space:nowrap"><?php echo ConvertSQLDate($row_quotes['start_date']);?> </td>
		  <td valign="top" ><?php echo ConvertSQLDate($row_quotes['end_date']);?></td>
          <td valign="top"><?php  echo $s->getField('www_users','id',$row_quotes['assigned_by'],'realname');//echo $s->GetFieldValue('www_users',"id='".$row_quotes['createdBy']."'",'userid'); ?></td>
		  <td valign="top"><?php echo $row_quotes['task_description'];?> </td>
			 <td valign="top"><?php echo $row_quotes['status'];?> </td>
			 <td valign="top"><?php if($row_quotes['status']=='pending'){?><a href="<?php echo $REURL ;?>">Add Remarks</a><?php } else echo "Add Remarks"; ?></td>
			  <td valign="top"><?php if($row_quotes['status']=='pending'){?><a href="<?php echo $CLURL ;?>">Close</a><?php }else {echo "Close";} ?></td>
        </tr>
		<?php } ?>
        
      </table>
	</td>
</tr>
</table>
  </form>
	
	</section>
	<section id="tab4" class="tab-content hide">
	<a href="<?php echo "index.php?route=TaskMgt/TODO".$rurl.'&action=AddNew'?>">
				<input type="button" name="Create" value="Add To Do" class="search" /></a>
	<?php 
$SQLTODO=DB_query("select * from to_do",$db);
?>

<table width="100%" cellpadding="3" cellspacing="0" border="1">
	<tr class="row1">
		<td class="tabledata">To Do</td>
		<td class="tabledata">ToDo Description</td>
		<td class="tabledata">Status</td>
		<td class="tabledata">Date</td>
	</tr>
<?php while($TODOView=DB_fetch_array($SQLTODO)) {?>
	<tr class="row1">
		<td><?php echo $TODOView['to_do']; ?></td>
		<td><?php echo $TODOView['description']; ?></td>
		<td><?php echo $TODOView['status1']; ?></td>
		<td><?php echo ConvertSQLDate($TODOView['due_date']); ?></td>
	</tr>
<?php }?>
</table>
	</section>
	
	<section id="tab5" class="tab-content hide">
	<?php 
$SQLFollow=DB_query("select * from follow_up",$db);
?>
<a href="<?php echo "index.php?route=TaskMgt/FollowUp".$rurl.'&action=AddNew'?>">
				<input type="button" name="Create" value="Add Follow Up" class="search" /></a>
<table width="100%" cellpadding="3" cellspacing="0" border="1">
	<tr class="row1">
		<td class="tabledata">Client</td>
		<td class="tabledata">FollowUp Type</td>
		<td class="tabledata">FollowUp Date</td>
		<td class="tabledata">Comments</td>
	</tr>
<?php while($FollowView=DB_fetch_array($SQLFollow)) {?>
	<tr class="row1">
		<td><?php echo $FollowView['client_id']; ?></td>
		<td><?php echo $FollowView['fillowup_type']; ?></td>
		<td><?php echo ConvertSQLDate($FollowView['followup_date']); ?></td>
		<td><?php echo $FollowView['comments']; ?></td>
	</tr>
<?php }?>
</table>
	</section>
	<section id="tab6" class="tab-content hide">
	<?php 
$SQLEV=DB_query("select * from event",$db);
?>
<a href="<?php echo "index.php?route=TaskMgt/Event".$rurl.'&action=AddNew'?>">
				<input type="button" name="Create" value="Add Event" class="search" /></a>
<table width="100%" cellpadding="3" cellspacing="0" border="1">
	<tr class="row1">
		<td class="tabledata">Event Type</td>
		<td class="tabledata">Event Name</td>
		<td class="tabledata">Event Location</td>
		<td class="tabledata">Status</td>
		<td class="tabledata">Date</td>
	</tr>
<?php while($EventView=DB_fetch_array($SQLEV)) {?>
	<tr class="row1">
		<td><?php echo $EventView['event_type']; ?></td>
		<td><?php echo $EventView['event_name']; ?></td>
		<td><?php echo $EventView['event_location']; ?></td>
		<td><?php echo $EventView['event_status']; ?></td>
		<td><?php echo ConvertSQLDate($EventView['event_start_date']); ?></td>
	</tr>
<?php }?>
</table>
	</section>
	
	<section id="tab7" class="tab-content hide">

	<?php 
	
$SQLEV=DB_query("select * from event",$db);
?>
<a href="<?php echo "index.php?route=CRM/TA_DA_CLAIM_FORM".$rurl.'&action=AddNew'?>">
				<input name="Addnew" id="Addnew" type="button" value="Addnew" class="search"  /></a>
<table align="center" width="100%;" border="1" cellpadding="3" cellspacing="0">
<tr class="row1"><td class="tabledata" style="text-align:center;" colspan="11">TA DA CLAIM DETAILS</td></tr>
<tr class="row1">
	<td class="tabledata">Sr. No.</td>
    <td class="tabledata">Bill No </td>
    <td class="tabledata">Bill Date </td>
    <td class="tabledata">Client</td>
    <td class="tabledata">Employee</td>
	<td class="tabledata">Grand Total</td>
	<td class="tabledata">Status </td>
	
	<td class="tabledata">Edit</td>
    <td class="tabledata">Delete</td>
    <td class="tabledata">Print</td>
</tr>
  <tbody id="dataTable" >
  <?php $TADASQL="Select * from crm_ta_da_claim_form_main   ";
		$TADADATA=DB_query($TADASQL,$db);
		$count=0;
		while($TADARow=DB_fetch_array($TADADATA))
		{ $count++; ?>
  	<tr class="row1">
<td style="white-space:nowrap;" class="tabledata1"><?php echo $count; ?>
</td>

<td class="tabledata1"><?php echo $TADARow['bill_no'] ?> </td>
<td class="tabledata1"><?php echo $TADARow['bill_date'] ?></td>
<td class="tabledata1" style="white-space:nowrap"><?php echo $s->getField('clientmaster','id',$TADARow['client_name'] ,'c_name');  ?></td>
<td class="tabledata1"><?php echo $s->getField('empmaster','id',$TADARow['employee'] ,'emp_name');  ?></td>
<td class="tabledata1"><?php echo $TADARow['grand_total']; ?></td>
<td class="tabledata1"><?php if($_SESSION['UserID']==$TADARow['approved_by'] && $TADARow['status']==0) { 
?>
<a href="index.php?route=CRM/ta_da_claim_approve&action=approve&tada_id=<?php echo $TADARow['id'].$rurl;?>"><input type="button" name="Approve" value="Approve" class="search" /></a><?php } else if($TADARow['status']==1) { echo "Approved"; } ?> 


</td>
 <?php

 
  if($TADARow['status']==1 &&  $_SESSION['UserID']==$TADARow['prepared_by']  ) { ?>
<td class="tabledata1"><?php echo  "No Permission" ; ?> </td><td class="tabledata1"><?php echo  "No Permission" ; ?></td>
<td class="tabledata1"><a href="#" onclick="popup('bill_report.php?id=<?php echo $TADARow['id']; ?>',1200,600)">Print</a></td>
<?php } else if($TADARow['status']==0 && $_SESSION['UserID']==$TADARow['prepared_by']  ){ 

?>
<td class="tabledata1"> <a href="#"> 
  <img src="images/icon_edit.gif" width="10px"  height="10" onclick="toggle_new('<?php echo $TADARow['id'].$rurl;?>');" /></a></td>
<td class="tabledata1"> <a href="index.php?route=CRM/TA_DA_CLAIM_FORM&action=delete&tada_id=<?php echo $TADARow['id'].$rurl;?>" >
  <img src="images/icon_edit.gif" width="10px"  height="10"  /></a></td>
<td class="tabledata1"><a href="#" onclick="popup('bill_report.php?id=<?php echo $TADARow['id']; ?>',1200,600)">Print</a></td>
<?php } else { ?>
<td class="tabledata1"><?php echo  "No Permission" ; ?> </td><td class="tabledata1"><?php echo  "No Permission" ; ?></td>
<td class="tabledata1"><a href="#" onclick="popup('bill_report.php?id=<?php echo $TADARow['id']; ?>',1200,600)">Print</a></td>
<?php } ?>

</tr>

<?php } ?>

</tbody>
 </table>
	</section>

	
</div>
<script language="javascript" >
function LeadData()
{
	
	myCheckboxArray = document.myform.elements["leadid[]"];
	var t=myCheckboxArray.length;
	//alert(myCheckboxArray);
	if(document.getElementById('leadid').checked==true)
	{	
	if(t==undefined)
	document.getElementById('leadid_'+1).checked=true;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=true;	
	}	
	}
	else
	{
	if(t==undefined)		
	document.getElementById('leadid_'+1).checked=false;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=false;	
	}
	}
}
</script>
