<?php session_name('CAKEPHP'); session_start();	
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Telephonic Order Memo');
include('includes/SQL_CommonFunctions.inc');
include('CRM/functions.php');
$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']."'";


if($_REQUEST['Save']!='')
{
	$data['task_no']=$_REQUEST['task_no'];
	$data['start_date']=FormatDateForSQL($_REQUEST['start_date']);
	$data['start_time']=$_REQUEST['start_time'];
	$data['end_date']=FormatDateForSQL($_REQUEST['end_date']);
	$data['end_time']=$_REQUEST['end_time'];
	$data['repeat_status']=$_REQUEST['repeat_status'];
	$data['reminder_status']=$_REQUEST['reminder_status'];
	$data['reminder_time']=$_REQUEST['reminder_time'];
	$data['time_mode']=$_REQUEST['time_mode'];
	$data['assign_to']=$_REQUEST['assign_to'];
	$data['user_id']=$_REQUEST['user_id'];
	$data['task_description']=$_REQUEST['task_description'];
	$data['assigned_by']=$_SESSION['UserID'];
	$data['created']=date('Y/m/d');
	$data['created_by']=$_SESSION['UserID'];
	
	$sql1=$s->insertRecord('tsk_taskassignment', $data);
	$result1=DB_query($sql1,$db);
}
?>
<script src="ui/jquery.ui.timepicker.js"></script>
<link rel="stylesheet" href="css/new_mxerp.css">
<style>
#showdata {
	display: block;
	background: url(Default.png) no-repeat;
	top: 0px;
	left: 0px;
	width: 300px;
	min-height: 60px;
	z-index:0;
}
#back {
	display: none;
	top: 0px;
	left: 0px;
	width: 300px;
	min-height: 60px;
	z-index:0;
}
</style>
<div class="body_contain">
<div class="tab_div">
<h1>Assigned Task Execution </h1>
  <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>



</div></div>