<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
 
  
			if(isset($_POST['submitF']))
			{       
			     
                $stmt=$conn->prepare("select *  from UI__DailyROIGene  where custId=:cuurentId");    
                $stmt->bindValue(':cuurentId', $_POST['refId'], PDO::PARAM_STR);  
                $stmt->execute();  
                $Result = $stmt->fetch(PDO::FETCH_OBJ);     
                for($i=1;$i<=$_POST['noOfDays'];$i++)
                {  
                    $Tdy = date ('d-M-Y', strtotime('+'.$i.' days'));  
        			$stmt=$conn->prepare("insert into UI__DailyROIGene (custId,amount,Tdate,paidStatus,PaidDate) values(:custId,:amount,:Tdate,:paidStatus,:PaidDate)  "); 
                    $stmt->bindValue(':custId',$_POST['refId'], PDO::PARAM_STR); 
                    $stmt->bindValue(':amount',  $Result->amount, PDO::PARAM_STR); 
                    $stmt->bindValue(':Tdate', $Tdy, PDO::PARAM_STR); 
                    $stmt->bindValue(':paidStatus', 1, PDO::PARAM_STR); 
                    $stmt->bindValue(':PaidDate', date("d-M-Y H:i"), PDO::PARAM_STR);  
                    $stmt->execute();  
                } 
				header("Location: custPid.php ");  
				die;
			}    
        
            $stmt=$conn->prepare("select  * from  UI__Rgst where id=:id ");  
            $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
            $stmt->execute(); 
            $AllUsers = $stmt->fetch(PDO::FETCH_OBJ);   
            $sr = 1;    
		 
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  


 <script>
	$(function() {
		$( "#datepicker" ).datepicker(); 
	}); 
  
	$(document).ready(function()
	{   

	
	$("#product_frm").validate({
		
		errorElement:'div',
		rules:{ 
			city:{
				required:true				 
			} 
			
			
			
		},
		messages:{				
			 
			 city:{
				required:"Enter city name"				 
			} 
		}
	});
	
	
	
	        


	});    
</script>  
	

<script> 
$(document).ready(function()
{   
    var URL =  "<?php echo ROOTPATH;?>";
      
        
        $( "#refId" ).change(function() 
        {
                 
              $.ajax({	
                    type: "POST",
                    url: URL+"/ajax/default.php",
                    data: {userDatacheck:1,Data:$(this).val()},
                    beforeSend: function(){ 
                    },
                    success: function(data)
                        {     
                             $("#AvailbleId").html("<span style='color:green;'>"+data+"</span>"); 
                        }
                    }); 
                        
             
        });
                 
}); 
</script>
		 
		 <div class="col-md-10">

	  			<div class="row">
	  				<div class="col-md-12">
	  					<div class="content-box-large">
							<div class="panel-heading">
								<div class="panel-title"> <h3> Custom Records</h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='registered_users.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm"> 
							   	 <div class="form-group">
							   	     
								    <label for="inputEmail3" class="col-sm-2 control-label">Id</label>
								    <div class="col-sm-6">
								      <input name="refId" class="form-control"   id="refId" placeholder="UserId"   required     >
								      <span id="AvailbleId"></span>
								    </div>
								 </div>
								 <hr>
								  
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">No of Days</label>
								    <div class="col-sm-6">
								      <input name="noOfDays" class="form-control"   type="number" placeholder="Days"  required    >
								    </div>
								 </div>
								 <hr>  
								 
								 
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Add Record</label>
										<div class="col-sm-6">
										  <input type="submit"    class="btn btn-primary"  name="submitF" value="Add Now">
										</div>
								  </div>   
								</form>  
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


	  		<!--  Page content -->
		  </div>
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';	?>    