<?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="TaskMgt/ui/jquery.ui.timepicker.js"></script>
<style>
#showdata {
	display: block;
	background: url(TaskMgt/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>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1>Task Assignment</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;">
<?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>
</table>
    <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
      <tr>
        <td class="tabledata" style="width:250px;">Actions</td>
        <td colspan="6"><table  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><a href="<?php echo "TaskMgt/index.php?route=TaskMgt/task_assign".$rurl.'&action=AddNew'?>">
                <input type="button" name="Create" value="Assign Task" style="background-color:#d1d4be; color:#006699; font-weight:800; padding-top:3px; padding-bottom:3px;" />
                </a></td>
              <td></td>
              <td><input type="submit" name="Delete" value="Delete" style="background-color:#d1d4be; color:#FF0000; padding-top:3px; padding-bottom:3px;" /></td>
              <?php if($_REQUEST['Search'])
	{ ?>
              <td><a href="TaskMgt/TicketExp.php">
                <input type="button" name="Export" value="Export" style="background-color:#d1d4be; color:#006699; font-weight:800; padding-top:3px; padding-bottom:3px;" />
                </a></td>
              <?php }?>
            </tr>
          </table></td>
      </tr>
    </table>
    <div style="width:auto; margin-left:auto; margin-right:auto; overflow:auto; background-color:#E2F4F7;" >
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
        <tr>
          <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 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='".$_SESSION['UserID']."' 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=SHRem&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="TaskMgt/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 } ?>
        
      </table>
    </div>
  </form>



</div></div>