<? if($_SESSION['page'] == '4' and $_SESSION['section'] == '1') {

?>
<link href="../admin.css" rel="stylesheet" type="text/css" />

<table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
      <tr>
        <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="Main_Text"><a class="Main_Text">List of Cases</a></td>
            <td width="10%" class="Main_Text"><div align="right"><img src="image/more_info.gif" width="32" height="32" border="0" /></a></div></td>
          </tr>
          <tr>
            <td colspan="2">
            
<? if ($_GET['stat'] == '' ) {?>            
            
                
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="image/subheader_icon.gif" width="12" height="12" /><strong class="text2">&nbsp;&nbsp;Your cases</strong></p>
           
	            <table width="95%" border="0" align="center">

                  <tr>
                    <td class="Main_Text1">Case ID</td>
                    <td height="35" class="Main_Text1">Client</td>
                    <td class="Main_Text1">Customer</td>
                    <td class="Main_Text1">Bucket No.</td>
                    <td class="Main_Text1">prodect</td>
                    <td class="Main_Text1">Account no</td>
                    <td class="Main_Text1">principle amt</td>
                    <td class="Main_Text1">Select</td>
                  </tr>
                  <?
				  $result1 = mysql_query("SELECT * FROM ".$dcm_table_start."case where delete_case =0 and stop_case = 0 and manage_uid = ".$_SESSION['Login_user_id']); 
						while($row = mysql_fetch_array($result1)){ 
							$query1 = mysql_query("SELECT * FROM ".$dcm_table_start."customer where cus_id = ".$row['cus_id']); 		
							$query2 = mysql_query("SELECT * FROM ".$dcm_table_start."client where cli_id = ".$row['cli_id']); 	
							$query3 = mysql_query("select * from ".$dcm_table_start."bucket	where bid = ".$row['bid']); 	
				?>
                  <tr>
                    <td class="Main_Text"><? echo $row['case_id'];?></td>
                    <td class="Main_Text"><? echo mysql_result($query2,0,"cli_name");?></td>
                    <td class="Main_Text"><? echo mysql_result($query1,0,"cus_name");?></td>
                    <td class="Main_Text"><? echo mysql_result($query3,0,"bucket_no");?></td>
                    <td class="Main_Text"><div align="center"><? echo mysql_result($query3,0,"prodect");?></div></td>
                    <td class="Main_Text"><div align="center"><? echo $row['account_no'];?></div></td>
                    <td class="Main_Text"><div align="right"><? echo $row['principle_amt'];?> BD</div></td>
                    <td class="Main_Text"><a href="index.php?stat=select&case_id=<? echo $row['case_id'];?>"><img src="image/edit.gif" width="24" height="24" border="0" /></a></td>
                  </tr>
                  <?
				  	}
					?>
                </table>
              <div align="center">
                <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="image/subheader_icon.gif" width="12" height="12" /><strong class="text2">&nbsp;&nbsp;Your cases Reminder</strong></p>
                
                  <table width="95%" border="0">
                    <tr bordercolor="#6F8992">
                      <td class="Main_Text1_case">case id</td>
                      <td class="Main_Text1_case">Customer</td>
                      <td class="Main_Text1_case">Client</td>
                      <td class="Main_Text1_case">Amout OS</td>
                      <td class="Main_Text1_case">Reminder Type</td>
                      <td class="Main_Text1_case">Reminder Date</td>
                      <td class="Main_Text1_case">Reminder Time</td>
                      <td class="Main_Text1_case">Note</td>
                      <td class="Main_Text1_case"><span class="Main_Text1">Select</span></td>
                      <td class="Main_Text1_case">End Reminder</td>
                    </tr>

		 <?
		 	$date_now   		  = date("Y").'-'.date("m").'-'.date("d"); 
			$result_lest = mysql_query("SELECT * FROM ".$dcm_table_start."call where reminder = 1 and end_reminder = 0 and uid = ".$_SESSION['Login_user_id']." order by reminder_date"); 
			while($row = mysql_fetch_array($result_lest)){ 
							$query = mysql_query("SELECT * FROM ".$dcm_table_start."case where case_id = ".$row['case_id']); 		
							$query1 = mysql_query("SELECT * FROM ".$dcm_table_start."customer where cus_id = ".mysql_result($query,0,"cus_id")); 		
							$query2 = mysql_query("SELECT * FROM ".$dcm_table_start."client where cli_id = ".mysql_result($query,0,"cli_id")); 	
							$query3 = mysql_query("select * from ".$dcm_table_start."bucket	where bid = ".mysql_result($query,0,"bid")); 	
			
		?>
         <tr class="Main_SText_case<? if ($row['reminder_date'] < date("Y-m-d") ) { echo "end";}?>">
           <td><? echo $row['case_id'];?></td>
           <td><? echo mysql_result($query1,0,"cus_name");?></td>
           <td><? echo mysql_result($query2,0,"cli_name");?></td>
           <td><? 
	$query5 = mysql_query("SELECT sum(amount) amount FROM ".$dcm_table_start."call_payment where delete_amount = 0 and status = 1 and case_id =".$row['case_id']); 	
	$collected = mysql_result($query5,0,"amount");
	echo mysql_result($query,0,"principle_amt") - $collected;?> BD</td>
           <td><? 
		   if ( $row['reminder_type'] == 1 ) { echo "Call";}
		   if ( $row['reminder_type'] == 2 ) { echo "Meeting";}
		   if ( $row['reminder_type'] == 3 ) { echo "Visits";}
		   if ( $row['reminder_type'] == 4 ) { echo "Promes to pay";}
		
		   ?></td>
           <td><? echo $row['reminder_date'];?></td>
           <td><? echo $row['reminder_time'];?></td>
           <td><? echo $row['note'];?></td>
           <td><a href="index.php?stat=select&case_id=<? echo $row['case_id'];?>"><img src="image/edit.gif" width="24" height="24" border="0" /></a></td>
           <td><a href="index.php?stat=end_reminder&call_id=<? echo $row['call_id'];?>" class="Main_SText_case<? if ($row['reminder_date'] < date("Y-m-d") ) { echo "end";}?>">End Reminder</a></td>
         </tr>
           <? }	?>                  
           </table>
              </div>
                  <? } ?>            
            </td>
          </tr>
        </table></td>
      </tr>
</table>
 
<? } ?>
