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



	if ($_GET['stat'] == '') { 

//$_SESSION['4_1_case_id']
			  		$query = mysql_query("SELECT * FROM ".$dcm_table_start."case where case_id = ".$_SESSION['4_1_case_id']); 
				
				
					$query1 = mysql_query("SELECT * FROM ".$dcm_table_start."userlist where user_id = ".mysql_result($query,0,"manage_uid")); 	
					$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")); 	
					$query4 = mysql_query("select * from ".$dcm_table_start."customer where cus_id = ".mysql_result($query,0,"cus_id")); 	
					
							$_SESSION['ajax_cus_id'] = mysql_result($query,0,"cus_id");
					
					
?>
<link href="../admin.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />

<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<div align="center">
  <table width="100%" border="0">
    <tr>
      <td><table width="100%" border="0">
        <tr>
          <td width="10%" class="Main_Text1_case">Case Ref No.</td>
          <td class="Main_SText_case"><div align="center"><? echo mysql_result($query,0,"case_id");?> ( <? echo mysql_result($query,0,"manage_uid");?> )</div></td>
          <td class="Main_Text1_case">CPR /CR Number</td>
          <td class="Main_SText_case"><div align="center"><? echo mysql_result($query4,0,"CPR").mysql_result($query4,0,"CR");?></div></td>
          <td class="Main_Text1_case">Customer</td>
          <td class="Main_SText_case"><div align="center"><? echo mysql_result($query4,0,"cus_name");?></div></td>
        </tr>
        <tr>
          <td class="Main_Text1_case">Mobile No.</td>
          <td class="Main_SText_case"><? echo mysql_result($query4,0,"cus_mobile");?></td>
          <td class="Main_Text1_case">fax</td>
          <td class="Main_SText_case"><? echo mysql_result($query4,0,"cus_fax");?></td>
          <td colspan="2" class="Main_Text1_case">
          <form id="form1" name="form1" method="post" action="">
            <input name="ajaxid" type="hidden" id="ajaxid" value="<? echo $_SESSION['ajax_cus_id']?>" />
            <a class="box_main_ajax" onclick="showinfoaddress()">Other Address</a>   /  <a class="box_main_ajax" onclick="showinfophone()">Other phone</a>    /  <a class="box_main_ajax" onclick="hide()">Hide</a> 
            </form></td>
          </tr>
        <tr>
          <td class="Main_Text1_case">Address</td>
          <td colspan="3" class="Main_SText_case"><? echo mysql_result($query4,0,"cus_address");?></td>
          <td colspan="2" class="Main_SText_case"><div id="txtHint"><b></b></div></td>
          </tr>
      </table>
       <hr/>
       <table width="100%" border="0">
         <tr>
           <td valign="top"><table width="100%" border="0" align="center">
             <tr>
               <td width="120" class="Main_Text1_case">Client Name</td>
               <td colspan="3" class="Main_SText_case"><? echo mysql_result($query2,0,"cli_name");?></td>
               <td width="170" class="Main_Text1_case">Account No.</td>
               <td class="Main_SText_case"><? echo mysql_result($query,0,"account_no");?></td>
             </tr>
             <tr>
               <td class="Main_Text1_case">Bucket</td>
               <td class="Main_SText_case"><? echo mysql_result($query3,0,"bucket_no");?></td>
               <td width="130" class="Main_Text1_case">Principle Amt.</td>
               <td class="Main_SText_case"><? echo mysql_result($query,0,"principle_amt");?> BD</td>
               <td class="Main_Text1_case">Last Payment</td>
               <td class="Main_SText_case"><?
               						  $query6 = mysql_query("SELECT amount FROM ".$dcm_table_start."call_payment where status = 1 and delete_amount = 0 and case_id =".$_SESSION['4_1_case_id']." order by pid desc"); 
									  	if (mysql_num_rows($query6) <> "0")
											{
												echo mysql_result($query6,0,"amount");
											}
			   ?> BD</td>
             </tr>
             <tr>
               <td class="Main_Text1_case">Bucket Date</td>
               <td class="Main_SText_case"><? echo mysql_result($query3,0,"Created_Date");?></td>
               <td class="Main_Text1_case">Collected</td>
               <td class="Main_SText_case"><? $collected = mysql_result($query,0,"collected");
			  			   echo $collected;?> BD</td>
               <td class="Main_Text1_case">Balance Amt.</td>
               <td class="Main_SText_case"><? echo mysql_result($query,0,"principle_amt")-$collected ;?> BD</td>
             </tr>
             <tr>
               <td class="Main_Text1_case">Status</td>
               <td class="Main_SText_case"><? 
			   		$_SESSION['status_id_4_2'] =mysql_result($query,0,"status_id");
					$query5 = mysql_query("SELECT * FROM ".$dcm_table_start."status where status_id = ".$_SESSION['status_id_4_2']); 	
			   
			  		echo mysql_result($query5,0,"status_name");?></td>
               <td colspan="2" class="Main_SText"><div align="center"><a href="index.php?stat=chage_status" class="text2">Change Status</a></div></td>
               <td class="Main_Text1_case">Product</td>
               <td class="Main_SText_case"><? echo mysql_result($query3,0,"prodect");?></td>
             </tr>
           </table></td>
           <td width="400" rowspan="2" valign="top"><table width="400" border="1" bordercolor="#6F8992" class="case_text">
             <tr>
               <td colspan="2">
                 <?
				  $total = 0;
				  $totalAmt =0;
			  	$result_4_2 = mysql_query("SELECT * FROM ".$dcm_table_start."case where cus_id = ".$_SESSION['ajax_cus_id']); 
				while($row_4_2 = mysql_fetch_array($result_4_2)){ 
				
					$query1_4_2 = mysql_query("SELECT * FROM ".$dcm_table_start."userlist where user_id = ".$row_4_2['manage_uid']); 	
					$query2_4_2 = mysql_query("SELECT * FROM ".$dcm_table_start."client where cli_id = ".$row_4_2['cli_id']); 	
					$query3_4_2 = mysql_query("select * from ".$dcm_table_start."bucket	where bid = ".$row_4_2['bid']); 	
			?>
                 <p align="left"><? echo $row_4_2['case_id']; ?> - <? echo mysql_result($query2_4_2,0,"cli_name");?> - <? echo $row_4_2['principle_amt'];?> - <? echo mysql_result($query1_4_2,0,"fname");?> <? echo mysql_result($query1_4_2,0,"lname");?> ( <? echo mysql_result($query1_4_2,0,"user_id");?> )</p>
                 
            <? 
			$total = $total +1 ;
			$totalAmt = $totalAmt +$row_4_2['principle_amt'] ;
			} ?>            </td>
                </tr>
             <tr>
               <td width="50%"><div align="left"><strong>Total Cases : </strong> <? echo $total ?></div></td>
                 <td><div align="left"><strong>Total Amt. : </strong><? echo $totalAmt ?> BD</div></td>
               </tr>
           </table></td>
         </tr>
         <tr>
           <td valign="top"><table width="100%" border="0">
             <tr>
               <td width="100" height="20"><form id="form4" name="form2" method="post" action="index.php?stat=call">
                   <div align="center">
                     <input name="button5" type="submit" class="Button1" id="button5" value="    Add Calls     " />
                   </div>
               </form></td>
               <td width="100"><form id="form4" name="form2" method="post" action="index.php?stat=payment">
               		<div align="center">
                   <input name="button3" type="submit" class="Button1" id="button3" value="Add  Payments" />
               </div></form></td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
             </tr>
           </table>             <label></label></td>
          </tr>
       </table>
       <hr/>       <table width="100%" border="1" bordercolor="#6F8992">
         <tr>
           <td class="Main_Text1_case">Call Type</td>
           <td class="Main_Text1_case"><span class="Main_Text1">Telephone</span></td>
           <td class="Main_Text1_case">Call Date</td>
           <td class="Main_Text1_case">Call Time</td>
           <td class="Main_Text1_case">Result</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>
         </tr>
         <?
			$result_lest = mysql_query("SELECT * FROM ".$dcm_table_start."call where case_id=".$_SESSION['4_1_case_id']." order by call_id desc"); 
			while($row = mysql_fetch_array($result_lest)){ 
		?>
         <tr>
           <td class="Main_SText_case"><? if ($row['call_type']==1) { echo "Outgoing"; } else{ echo "Incomming"; } ?></td>
           <td class="Main_SText_case"><? echo $row['telephone'];?></td>
           <td class="Main_SText_case"><? echo $row['call_date'];?></td>
           <td class="Main_SText_case"><? echo $row['call_time'];?></td>
           <td class="Main_SText_case"><?
		  if ($row['call_result_id'] <> "0" ) { 
		   $query = mysql_query("SELECT * FROM ".$dcm_table_start."call_result where call_result_id =".$row['call_result_id']); 		 
		   echo mysql_result($query,0,"result");				
		   }
		   ?></td>
           <td class="Main_SText_case"><? 
		   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 class="Main_SText_case"><? echo $row['reminder_date'];?></td>
           <td class="Main_SText_case"><? echo $row['reminder_time'];?></td>
           <td class="Main_SText_case"><? echo $row['note'];?></td>
         </tr>
           <? }	?>
       </table>       
      </td>
    </tr>
  </table>

<?	}if($_GET['stat'] == 'chage_status') {	?>
        
        		<form id="form2" name="form2" method="post" action="index.php?stat=changestatdb">
                                <p>&nbsp;</p>
                                <table width="60%" border="0" align="center">
                                  <tr>
                                    <td class="Main_Text1_case">Change Status</td>
                                    <td class="Main_SText_case"><span id="spryselect1">
                                      <select name="status_id" id="status_id">
                                      	<option value=""></option>
                                        <?
											$result_lest = mysql_query("SELECT * FROM ".$dcm_table_start."status"); 
											while($row = mysql_fetch_array($result_lest)){ 

										?>
                                        		<option value="<? echo $row['status_id']; ?>" <? if (  $row['status_id'] == $_SESSION['status_id_4_2'] ) { ?>selected="selected" <? } ?>><? echo $row['status_name']; ?></option>
                                        <?
											}
										?>
                                      </select>
                                    <span class="selectRequiredMsg">*</span></span></td>
                                  </tr>
                                </table>
                                <p align="center">
                                  <input name="Submit" type="submit" class="Button1" id="Submit" value="   Save   " />
                                </p>
        </form>
        <?  } if ($_GET['stat'] == 'call' ) { ?>
    	<script type="text/javascript">
			window.addEvent('domready', function() { 
				new vlaDatePicker('call_date', { style: 'apple_widget',separator: '-', format: 'y/m/d'});
				new vlaDatePicker('reminder_date', { style: 'apple_widget',separator: '-', format: 'y/m/d'});
			});	
		</script>

  <form id="form3" name="form3" method="post" action="index.php?stat=savecall">
        <div align="center">
          <table width="80%" border="0" align="center">
            <tr>
              <td class="Main_Text1_case"><div align="left">Call Type</div></td>
              <td class="Main_SText_case"><label>
                <select name="call_type" id="call_type">
                  <option value="1">Outgoing</option>
                  <option value="2">Incomming</option>
                                                </select>
              </label></td>
              <td class="Main_Text1_case"><div align="left">Call Date</div></td>
              <td class="Main_SText_case"><span id="sprytextfield1">
              <label>
              <input type="text" name="call_date" id="call_date" />
              </label>
              <span class="textfieldInvalidFormatMsg">YYYY-MM-DD.</span><span class="textfieldRequiredMsg">*</span></span></td>
            </tr>
            <tr>
              <td class="Main_Text1_case"><div align="left">Call Time</div></td>
              <td class="Main_SText_case"><span id="sprytextfield2">
              <label>
              <input type="text" name="call_time" id="call_time" value="<? echo (date("H")+3).':'.date("i");?>" />
              </label>
              <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></td>
              <td class="Main_Text1_case"><div align="left">Result</div></td>
              <td class="Main_SText_case"><label>
                <select name="call_result_id" id="call_result_id">
                  <option value="0"></option>
                  <?
											$result_lest = mysql_query("SELECT * FROM ".$dcm_table_start."call_result"); 
											while($row = mysql_fetch_array($result_lest)){ 

										?>
                  <option value="<? echo $row['call_result_id']; ?>"><? echo $row['result']; ?></option>
                  <?
											}
										?>
                </select>
              </label></td>
            </tr>
            <tr>
              <td class="Main_Text1_case"><div align="left">Set Reminder</div></td>
              <td class="Main_SText_case"><label>
                <select name="reminder" id="reminder">
                  <option value="1">Yes</option>
                  <option value="2">No</option>
                </select>
              </label></td>
              <td class="Main_Text1_case"><div align="left">Type</div></td>
              <td class="Main_SText_case"><span id="spryselect1">
                <label>
                <select name="reminder_type" id="reminder_type">
                  <option value="0"></option>
                  <option value="1">Call</option>
                  <option value="2">Meeting</option>
                  <option value="3">Visits</option>
                  <option value="4">Promes to pay</option>
                </select>
                </label>
              <span class="selectRequiredMsg">*</span></span></td>
            </tr>
            <tr>
              <td class="Main_Text1_case"><div align="left">Reminder Date</div></td>
              <td class="Main_SText_case"><span id="sprytextfield3">
              <label>
              <input type="text" name="reminder_date" id="reminder_date" />
              </label>
              <span class="textfieldInvalidFormatMsg">*</span></span></td>
              <td class="Main_Text1_case"><div align="left">Reminder Time</div></td>
              <td class="Main_SText_case"><span id="sprytextfield4">
                <label>
                <input type="text" name="reminder_time" id="reminder_time" />
              <span class="textfieldInvalidFormatMsg">*</span>                </label>
              </span></td>
            </tr>
            <tr>
              <td class="Main_Text1_case"><span class="Main_Text1">Telephone</span></td>
              <td class="Main_SText_case"><span id="spryselect2">
                <select name="telephone" id="telephone">
                
                	<option value=""></option>select * from dcm_customer
                    
                    <?
					 $result2 = mysql_query("SELECT * FROM ".$dcm_table_start."case where case_id=".$_SESSION['4_1_case_id']); 
			
				  			  $cus_id   = $_GET['id']; 
				  			  $result1 = mysql_query("SELECT * FROM ".$dcm_table_start."customer where cus_id = ".mysql_result($result2,0,"cus_id")); 
							  while($row = mysql_fetch_array($result1)){ 
				  ?>
                    <option value="<? echo $row['cus_mobile']; ?>"><? echo $row['cus_mobile']; ?></option>
                     <?	}	?>
                    <?
					 $result2 = mysql_query("SELECT * FROM ".$dcm_table_start."case where case_id=".$_SESSION['4_1_case_id']); 
			
				  			  $cus_id   = $_GET['id']; 
				  			  $result1 = mysql_query("SELECT * FROM ".$dcm_table_start."cus_tele where cus_id = ".mysql_result($result2,0,"cus_id")); 
							  while($row = mysql_fetch_array($result1)){ 
				  ?>
                    <option value="<? echo $row['telephone']; ?>"><? echo $row['telephone']; ?></option>
                     <?	}	?>
                </select>
              <span class="selectRequiredMsg">*</span></span></td>
              <td class="Main_SText_case">&nbsp;</td>
              <td class="Main_SText_case">&nbsp;</td>
            </tr>
            <tr>
              <td class="Main_Text1_case"><div align="left">Note</div></td>
              <td colspan="3" class="Main_SText_case">
                <div align="center">
                  <textarea name="note" id="note" cols="60" rows="3"></textarea>
                  </div>             </td>
            </tr>
                                                                                </table>
          <p>
            <label>
            <input name="Submit" type="submit" class="Button1" id="Submit" value="   Save   " />
            </label>
          </p>
    </div>
    
    <div align="center">
  <table width="80%" border="1" bordercolor="#C9C9C9">
    <tr>
      <td class="Main_Text1"><span class="Main_Text1">Telephone</span></td>
      <td class="Main_Text1">Note</td>
    </tr>
			<?
					 $result2 = mysql_query("SELECT * FROM ".$dcm_table_start."case where case_id=".$_SESSION['4_1_case_id']); 
			
				  			  $cus_id   = $_GET['id']; 
				  			  $result1 = mysql_query("SELECT * FROM ".$dcm_table_start."cus_tele where cus_id = ".mysql_result($result2,0,"cus_id")); 
							  while($row = mysql_fetch_array($result1)){ 
				  ?>
                  <tr>
                    
                    <td class="Main_SText">&nbsp;<? echo $row['telephone']; ?></td>
                    <td class="Main_SText">&nbsp;<? echo $row['other_info']; ?></td>
                   
                  </tr>
                <?	}	?>
         </table>
</div>

    
  </form>
  	<? }if ($_GET['stat'] == 'payment' ) { ?>
        	<script type="text/javascript">
			window.addEvent('domready', function() { 
				new vlaDatePicker('payment_date', { style: 'apple_widget',separator: '-', format: 'y/m/d'});
			});	
		</script>

    		<form id="form5" name="form5" method="post" action="index.php?stat=savepayment">
    		  <div align="center">
    		    <table width="80%" border="0">
                  <tr>
                    <td width="20%" class="Main_Text1">Payment Date</td>
                    <td class="Main_SText"><span id="sprytextfield5">
                    <label>
                    <input type="text" name="payment_date" id="payment_date" />
                    </label>
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></td>
                    <td width="20%" class="Main_Text1">Payment Type</td>
                    <td class="Main_SText"><select name="payment_type" id="payment_type">
                      <option value="0"></option>
                      <option value="1">Cash</option>
                      <option value="2">Cheque</option>
                    </select>
                    </td>
                  </tr>
    		      <tr>
    		        <td class="Main_Text1">Payment Where</td>
                    <td class="Main_SText"><span id="spryselect1">
                      <label>
                      <select name="payment_where" id="payment_where">
                      	<option value=""></option>
                        <option value="1">Client</option>
                        <option value="2">Arig</option>
                      </select>
                      </label>
                    <span class="selectRequiredMsg">*</span></span></td>
                    <td class="Main_Text1">Receipt ( client ) </td>
                    <td class="Main_SText"><span id="sprytextfield7">
                      <label>
                      <input type="text" name="receipt" id="receipt" />
                      </label>
                    </span></td>
                  </tr>
    		      <tr>
    		        <td class="Main_Text1">Recipt No.</td>
                    <td class="Main_SText"><span id="sprytextfield8">
                      <label>
                      <input type="text" name="invoice" id="invoice" />
                      </label>
                    </span></td>
                    <td class="Main_Text1">amount</td>
                  <td class="Main_SText"><span id="sprytextfield9">
                  <label>
                  <input type="text" name="amount" id="amount" />
                  </label>
                  <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></td>
                  </tr>
    		      <tr>
    		        <td class="Main_Text1">note</td>
                    <td colspan="3" class="Main_SText"><textarea name="note2" id="note2" cols="70" rows="2"></textarea></td>
                  </tr>
                              </table>
  		    </div>
    		  <p align="center">
    		    <input name="Submit2" type="submit" class="Button1" id="Submit2" value="   Save   " />
  		      </p>
  </form>
<? } ?>
            <script type="text/javascript">
<!--
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd", useCharacterMasking:true});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "time", {useCharacterMasking:true});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "date", {useCharacterMasking:true, format:"yyyy-mm-dd", isRequired:false});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "time", {isRequired:false, useCharacterMasking:true});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "date", {useCharacterMasking:true, format:"yyyy-mm-dd"});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "none", {isRequired:false});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "none", {isRequired:false});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "integer", {useCharacterMasking:true});
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2");
//-->
</script>

  <? } ?>
</div>
