<style type="text/css">
.f12{font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#333333;}
.f11{font-family:Arial,Helvetica,sans-serif; font-size:11px; color:#333333; line-height:18px;}
.f14{font-family:Arial,Helvetica,sans-serif; font-size:14px; color:#ff0000;w}
.f13{color:#333333; font-family:Arial,Helvetica,sans-serif; font-size:13px; font-weight:bold;}
p{margin-top:7px; margin-bottom:7px; margin-left:0px; margin-right:0px;}
#event_row{background:#fafafa; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; padding:3px; border:#e1dddd 1px solid; box-shadow: 0px 0px 5px 2px rgba(225, 221, 221, 0.95); -moz-box-shadow: 0px 0px 5px 2px rgba(225, 221, 221, 0.95); -webkit-box-shadow: 0px 0px 5px 2px rgba(225, 221, 221, 0.95);}
h1{font:15px Arial,Helvetica,sans-serif; color:#333333;}
</style>

<?php 
session_name('CAKEPHP'); session_start();
$PageSecurity = 11;
include('includes/session.inc');
//include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include("includes/function_lib.php");
include('CRM/functions.php');
?>

<?php 
if($_REQUEST['type']=='to_do'){
    $SQLTODO=DB_query("SELECT * FROM to_do WHERE due_date='".$_REQUEST['date']."' and CompanyId='".$_SESSION['ACGCompanyId']."' ORDER BY  CASE periority WHEN 'High' THEN 1 WHEN 'Medium' THEN 2 ELSE  3 END , date1 DESC ",$db);    
?>
<div align="left"><div style="width:20%; float:left">
  <h1>TO DO</h1>
</div>
<div style="width:33%; float:right;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td valign="bottom" align="left" style="padding-top:8PX;"><h1>Status :</h1></td>
    <td valign="middle" align="left"><div style="width:15px; height:15px; background:#008000;"></div></td>
    <td class="f11" valign="middle" align="left">Confirm</td>
    <td valign="middle" align="left"><div style="width:15px; height:15px; background:#ff0000;"></div></td>
    <td class="f11" valign="middle" align="left">Pending</td>
  </tr>
</table>
</div>
<div style="clear:both;"></div>
</div>
<div style="width:100%; margin-bottom:10px;">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td class="f13">Priority :</td>
    <td><img src="images/login/high.jpg"></td>
    <td class="f11">High</td>
    <td><img src="images/login/medium.jpg"></td>
    <td class="f11">Medium</td>
    <td><img src="images/login/low.jpg"></td>
    <td class="f11">Low</td>
  </tr>
</table>
</div>

<div class="list" >
    <div id="event_row_last" style="margin-bottom:10PX;"><span class="f14"><b>There are currently <?php echo DB_num_rows($SQLTODO); ?> To-Do scheduled.</b></span></div>  
    <?php while($todo_res=DB_fetch_assoc($SQLTODO)) { ?>
    <div id="event_row"><div style="width:100%;"><div style="width:5%; float:left;"><?php if($todo_res['periority']=="High"){ echo '<img src="images/login/high.jpg">'; } else if($todo_res['periority']=="Low"){ echo '<img src="images/login/low.jpg">'; } else if($todo_res['periority']=="Medium"){ echo '<img src="images/login/medium.jpg">'; }?></div><div style="width:90%; float:left; padding-top:5px;"><span class="f13"><?php echo $todo_res['to_do'].' Date: '.date("jS F, Y", strtotime($todo_res['created_date']) ); ?></span></div>
	<div style="width:5%; float:right;"><?php if($todo_res['status1']=="Confirm"){ echo '<div style="width:15px; height:15px; background: green; float:left; margin-left:5px; margin-top:5px;"></div>';  }
    else if($todo_res['status1']=="Pending"){ echo '<div style="width:15px; height:15px; background: red; float:left; margin-left:5px; margin-top:5px;"></div>';  }?></div></div>
	<div align="left" style="margin-top:35px;"><p class="f11"><?php echo $todo_res['description'] ?></p></div>
	<div style="clear:both;"></div>
	</div>
    <br>
    <?php } ?>
</div>
<?php 
} ?>


<?php 
if($_REQUEST['type']=='task'){
    
    $SQLtask=DB_query("SELECT * FROM tsk_taskassignment WHERE start_date='".$_REQUEST['date']."' and user_id='".$_SESSION['UserID']."' and CompanyId='".$_SESSION['ACGCompanyId']."' ORDER BY  CASE status WHEN 'pending' THEN 1 WHEN 'progress' THEN 2 ELSE  3 END  ",$db);    
?>
<h1>TASK </h1>
<div style="width:100%; margin-bottom:10px;">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td class="f13" width="20%">Status :</td>
    <td><div style="width:15px; height:15px; background:#008000;"></div></td>
    <td class="f11">Closed</td>
    <td><div style="width:15px; height:15px; background:#FFFF00;"></div></td>
    <td class="f11">Progress</td>
    <td><div style="width:15px; height:15px; background:#0000FF;;"></div></td>
    <td class="f11">Pending</td>
  </tr>
</table>
</div>
<div class="list">
    <div id="event_row_last" style="margin-bottom:10PX;"><span class="f14"><b>There are currently <?php echo DB_num_rows($SQLtask); ?> Task scheduled.</b></span></div>
    <?php while($SQLtask_res=DB_fetch_assoc($SQLtask)) { ?>
    <div id="event_row"><p class="f11"><span class="f12"><strong>Task :</strong></span> <?php echo $SQLtask_res['task_no']  ?></p> <p class="f11"><span class="f12"><strong>Start Date :</strong></span> <?php echo date("jS F, Y", strtotime($SQLtask_res['start_date']) )  ?></p><p class="f11"><span class="f12"><strong>End Date :</strong></span> <?php echo date("jS F, Y", strtotime($SQLtask_res['end_date']) )  ?><p class="f11"><span class="f12"><strong>Assigned By :</strong></span> <?php echo $s->GetFieldValue('www_users'," id='".$SQLtask_res['assigned_by']."' " ,'realname') ;  ?> </p><span class="f13"><?php echo $SQLtask_res['task_description'] ?></span><br>
    <span class="f13"><?php if($SQLtask_res['status']=="closed"){ echo '<div style="width:15px; height:15px; background: green; float:left; margin-left:5px; margin-top:5px;"></div>';  } else if($SQLtask_res['status']=="progress"){ echo '<div style="width:15px; height:15px; background: yellow; float:left; margin-left:5px; margin-top:5px;"></div>';  } else if($SQLtask_res['status']=="pending"){ echo '<div style="width:15px; height:15px; background: blue; float:left; margin-left:5px; margin-top:5px;"></div>';  } ?></span>
	<div style="clear:both;"></div>
	</div>
    <br>
    <?php } ?>
</div>
<?php 
} ?>

<?php 
if($_REQUEST['type']=='follow_up'){
    
    $SQLfollow=DB_query("SELECT * FROM follow_up WHERE next_followup_date='".$_REQUEST['date']."' ",$db);    
?>
<div align="left"><div style="width:20%; float:left">
  <h1>FOLLOWS UP</h1>
</div>
<div style="width:40%; float:right;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td valign="bottom" align="left" style="padding-top:8PX;"><h1>Type :</h1></td>
    <td valign="middle" align="left"><img src="images/login/telephone.png"></td>
    <td class="f11" valign="middle" align="left">By Telephone</td>
    <td valign="middle" align="left"><img src="images/login/e-mail.png"></td>
    <td class="f11" valign="middle" align="left">E-mail</td>
  </tr>
</table>
</div>
<div style="clear:both;"></div>
</div>
<div class="list">
    <div id="event_row_last" style="margin-bottom:10PX;"><span class="f14"><b>There are currently <?php echo DB_num_rows($SQLfollow); ?> Follow Up scheduled.</b></span></div>
    <?php while($SQLfollow_res=DB_fetch_assoc($SQLfollow)) { ?>
    <div id="event_row"><div align="left"><div style="width:5%; float:left;"><?php if($SQLfollow_res['fillowup_type']=='By Mail') { echo '<img src="images/login/e-mail.png">';  } else if($SQLfollow_res['fillowup_type']=='By Phone') { echo  '<img src="images/login/telephone.png">'; } ?></div><div style="width:95%; float:left;"><span class="f13"><?php echo  $s->GetFieldValue('clientmaster'," id='".$SQLfollow_res['client_id']."' " ,'c_name')  ?></span></div></div>
    <div align="left" style="margin-top:30px;"><p class="f11"><span class="f12"><strong>Comment :</strong> </span><?php echo $SQLfollow_res['comments']  ?><?php echo '<br><strong> Date :</strong> '.date("jS F, Y", strtotime($SQLfollow_res['followup_date']) )  ?> </p></div></div>
    <br>
    <?php } ?>
</div>
<?php 
} ?>



<?php 
if($_REQUEST['type']=='event'){
    
    $SQLevent=DB_query("SELECT * FROM `event` WHERE event_start_date='".$_REQUEST['date']."' and CompanyId='".$_SESSION['ACGCompanyId']."' ORDER BY  CASE periority WHEN 'High' THEN 1 WHEN 'Medium' THEN 2 ELSE  3 END  ",$db);    
?>
<h1>EVENTS </h1>
<div style="width:100%; margin-bottom:10px;">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td class="f13">Priority :</td>
    <td><img src="images/login/high.jpg"></td>
    <td class="f11">High</td>
    <td><img src="images/login/medium.jpg"></td>
    <td class="f11">Medium</td>
    <td><img src="images/login/low.jpg"></td>
    <td class="f11">Low</td>
  </tr>
</table>
</div>
<div style="width:100%; margin-bottom:10px;">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  	<td class="f13" width="37%">Status :</td>
    <td><div style="width:15px; height:15px; background:#ff0000;"></div></td>
    <td class="f11">Pending</td>
    <td><div style="width:15px; height:15px; background:#008000;"></div></td>
    <td class="f11">Confirm</td>
  </tr>
</table>
</div>
<div class="list">
    <div id="event_row_last" style="margin-bottom:10px;"><span class="f14"><b>There are currently <?php echo DB_num_rows($SQLfollow); ?> Events scheduled.</b></span></div>
    <?php while($SQLevent_res=DB_fetch_assoc($SQLevent)) { ?>
    <div id="event_row"><span class="f13"><?php echo $SQLevent_res['event_name'] ?></span><p class="f11"><?php echo $SQLevent_res['description'] ?></p>
	<div align="left"><div style="width:10%; float:left;"><?php if($SQLevent_res['periority']=="High"){ echo '<img src="images/login/high.jpg">'; } else if($SQLevent_res['periority']=="Low"){ echo '<img src="images/login/low.jpg">'; } else if($SQLevent_res['periority']=="Medium"){ echo '<img src="images/login/medium.jpg">'; }?></div>
	<div style="width:90%; float:left;"><p class="f11" style="margin-top:0px;"><span class="f12"><strong>Event Type :</strong></span> <?php echo $SQLevent_res['event_type'] .'<br><span class="f12"><strong> Date: </strong></span>'.date("jS F, Y", strtotime($SQLevent_res['event_start_date']) ); ?></p></div></div>
        <p class="f11"><?php if($SQLevent_res['event_status']=='Pending'){ echo '<div style="width:15px; height:15px; background: red; float:left; margin-left:5px; margin-top:5px;"></div>'; } else if($SQLevent_res['event_status']=='Confirm') { echo '<div style="width:15px; height:15px; background: green; float:left; margin-left:5px; margin-top:5px;"></div>'; }   ?></p>
	<div style="clear:both;"></div>
	</div>
    <br>
    <?php } ?>
</div>
<?php 
} ?>