			<?php


include("../php/configi.php");
			


$queryac2r="SELECT * FROM " . $_COOKIE['phxcrmclient_id'] . "_client_recurr WHERE uid_client = " . $uid_client . " order by r_type, r_descr" ;

//echo $queryac2r;
$resultac2r=mysqli_query($conn, $queryac2r);

//mysql_close();                
?>

<div  class="table-responsive nomargin">
	<table class="table table-bordered table-striped">
<?
$iac = 0;

$numrowsr = mysqli_num_rows($resultac2r);

//echo "numrows is " . $numrows;

if ($numrowsr == 0){
	
	echo "<label>There are no recurring products or services for this Client</label>";
	
	
}else{
	
		?>	
		
		

        <thead>
            <tr style="max-height: 10px">
			<th>
			</th>

			<th >ITEM CODE:</th>
			<th >DESCRIPTION:</th>
			<th >CHARGE:</th>
			<th >UNIT:</th>
						<th >QTY:</th>
			<th >TOTAL:</th>

		    </tr>
        </thead>
		
				        <tbody>

<?php
	

 while($rowac2r=mysqli_fetch_array($resultac2r)) { 
 
 
	$uid_r				 = $rowac2r['uid_r']; 
	$sel_uid			 = $rowac2r["sel_uid"];
	$r_qty				 = $rowac2r["r_qty"];
	$r_unit				 = $rowac2r["r_unit"];
	$r_line_amt			 = $rowac2r["r_line_amt"];
	$r_status			 = $rowac2r["r_status"];	
	$r_item_code		 = $rowac2r["r_item_code"];
	$r_descr			 = $rowac2r["r_descr"];
	$r_type				 = $rowac2r["r_type"];	
//		$queryac2rp="SELECT * FROM " . $_COOKIE['phxcrmclient_id'] . "_client_recurr WHERE uid_client = " . $uid_client ;
		//echo $queryac2r;
//		$resultac2rp=mysqli_query($conn, $queryac2rp);

	//	while($rowac2rp=mysqli_fetch_array($resultac2rp)) { 
		
	//		$title				 = $rowac2rp["title"];
 
	//	}

	
	//lookup product based on sel_uid

	
	?>
	
           <tr >
		   <td style="width: 12px; padding-left: 2px; padding-right: 2px;">
				 <button type="button" onclick="javascript: del_custrecurr(<?php echo $uid_r?>,<?php echo $uid_client?>)"  class="btn btn-link" >Del </button>
			</td>

			<td style="width: 150px; font-size: 12px; padding-left: 2px; padding-right: 2px;"><input id="r_item_code" style="font-size: 12px;" class="form-control" onchange="javascript: update_field_contact_recurr('r_item_code', 'input', this.value,<?php echo $uid_r; ?> )" type="text" value="<?php echo htmlspecialchars($r_item_code);?>"></td>
			<td style=" font-size: 12px; padding-left: 2px; padding-right: 2px;"><textarea id="r_descr"  onchange="javascript: update_field_contact_recurr('r_descr', 'input', this.value,<?php echo $uid_r; ?> )"   data-height="150" data-lang="en-US" name="r_descr" rows="3" class='form-control'><?php echo $r_descr; ?></textarea>	</td>
			<td style=" font-size: 12px;">
			
													<?

	
include("../php/configi.php");

$querycyct="SELECT * FROM " . $_COOKIE['phxcrmclient_id'] . "_code_lookup where code_type = 'chargetype'";
//echo $querycy;
$resultcyct=mysqli_query($conn, $querycyct);

?>
		<select    class="form-control" style="font-size: 12px; width: 80px; padding-left: 2px; padding-right: 2px;"  id = "r_type" name="r_type"  onchange="javascript: update_field_contact_recurr('r_type', 'input', this.options[this.selectedIndex].value, <?php echo $uid_r;?>)"  >

<?php

 while($rowcyct=mysqli_fetch_array($resultcyct)) {

?>
		<option 
		<?php if ($rowcyct['code_value'] == $r_type){echo " selected ";} ?> 
		value="<? echo $rowcyct["code_value"]; ?>"><? echo $rowcyct["code_value"]; ?></option>

		<?


}


	 
?>
</select>

			
			
			
			</td>
			<td style="font-size: 12px; padding-left: 2px; padding-right: 2px;">
				<input style="font-size: 12px; width: 100px; text-align: right; padding-left: 2px; padding-right: 2px;" id="r_unit_<?php echo $uid_r;?>" type="text" onchange="javascript: update_field_contact_recurr('r_unit', 'inputdouble', this.value,<?php echo $uid_r; ?> )"  class="form-control" value="<?php echo htmlspecialchars($r_unit);?>">
			</td>
			<td style="font-size: 12px; padding-left: 2px; padding-right: 2px;">
			<?php
						if ($r_type == "Fixed"){
?>
				<input style="font-size: 12px; width: 100px; text-align: right; padding-left: 2px; padding-right: 2px;" id="r_qty_<?php echo $uid_r;?>" type="text" onchange="javascript: update_field_contact_recurr('r_qty', 'inputdouble', this.value,<?php echo $uid_r; ?> )"  class="form-control" value="<?php echo htmlspecialchars($r_qty);?>">
<?php
						}
?>						

	</td>
			<td style="font-size: 12px; padding-left: 2px; padding-right: 2px;">
			<?php
						if ($r_type == "Fixed"){
?>

				<input readonly disabled style="font-size: 12px; width: 100px; text-align: right; padding-left: 2px; padding-right: 2px;" id="r_line_amt_<?php echo $uid_r;?>" type="text" onchange="javascript: update_field_contact_recurr('r_line_amt', 'inputdouble', this.value,<?php echo $uid_r; ?> )"  class="form-control" value="<?php echo htmlspecialchars($r_line_amt);?>">
<?php
						}
?>						

			</td>
		
            </tr>


		



	<?php
	
	$iac = $iac + 1;
}

}
	

?>



</table>
</div>