<?php include ('header1f.php');?>
<script src="js/jquery-3.5.1.min.js"></script>
<?php 
ob_start();   
session_start();
include ('connection.php') ;

  if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
	date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today3 = date("Y-m-d");
$today1 = date("d/m");


$tablename = $_REQUEST['tablename'];


$queryls1 = "select * from  appointment_details  where appointment_id='".$_REQUEST['appointment']."'";
$resultls1  = mysqli_query($conn,$queryls1);	
while($row=mysqli_fetch_array($resultls1))
{
$registration_id = $row['registration_id'];
$call_follow_up_id = $row['call_follow_up_id'];
}

$queryls2 = "select * from  $tablename  where ibp_id ='".$_REQUEST['program_id']."'";
$resultls2  = mysqli_query($conn,$queryls2);	
while($row=mysqli_fetch_array($resultls2))
{
$height = $row['height'];
$weight = $row['weight'];
$prescription_date = $row['prescription_date'];
$age = $row['age'];
}
?> 
<div class="content-page">
    <div class="content">
      <div class="container">
	  	  
        
        <div class="row">
          <div class="col-md-12">
            <div class="panel panel-primary">
              <div class="panel-heading">
                <h3 class="panel-title">Add Prescription</h3>
              </div>	
		
			
              <div class="panel-body">
                                    <div class="row"> 

               <form name="frm_add_category"  id="frm_add_category" method="post"action="insert_prescription_gw.php" >	
			   <input  type="hidden" name="program_id" value="<?php echo $_REQUEST['program_id']?>"/>
			   <input  type="hidden" name="program_name"  value="<?php echo $_REQUEST['program_name']?>"/>	
			   <input  type="hidden" name="tablename" value="<?php echo $_REQUEST['tablename']?>"/>
			   <input  type="hidden" name="registration_id"  value="<?php echo $_REQUEST['registration_id']?>"/>	
			   <input  type="hidden" name="appointment_id" value="<?php echo $_REQUEST['appointment']?>"/>			

                        <div class="box-body">
						
							<div class="row">
							
							
							<div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">
							   <div class="form-group">
                                <label for="first_name" class="control-label">Date</label>
               					 <div class="input-group">
                          <input type="text" class="form-control" placeholder="yyyy-mm-dd" id="datepicker-autoclose" name="prescription_date"value="<?php echo $prescription_date; ?>" >
													   <span class="input-group-addon bg-custom b-0"><i class="mdi mdi-calendar text-white"></i></span></div>
                            </div>
</div></div>
							
							<div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">
							   <div class="form-group">
                                <label for="middle_name" class="control-label">Height</label>
                				<input class="form-control" type="text" name="height" placeholder="Height" value="<?php echo $height?>" required/>
                            </div>
</div></div>

<div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">
							   <div class="form-group">
                                <label for="middle_name" class="control-label">AGE</label>
                				<input class="form-control" type="text" name="age" placeholder="Age" value="<?php echo $age?>" required/>
                            </div>
</div></div>
                     
					 <div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">       <div class="form-group">

                               <label for="last_name" class="control-label">Weight</label>
                	<input class="form-control" type="text" name="weight" placeholder="Weight" value="<?php echo $weight?>"required />

                            </div></div></div>
							
							
							 <div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">       <div class="form-group">

                               <label for="last_name" class="control-label">PULSE </label>
                	<input class="form-control" type="text" name="pulse" placeholder="PULSE" required />

                            </div></div></div>
							
							
							
							 <div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">       <div class="form-group">

                               <label for="last_name" class="control-label">H/O</label>
                	<input class="form-control" type="text" name="HO" placeholder="HO" required />

                            </div></div></div>
							
							
							 <div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">       <div class="form-group">

                               <label for="last_name" class="control-label">C/O</label>
                	<input class="form-control" type="text" name="CO" placeholder="CO" required />

                            </div></div></div>
							
							
						
							
							</div>
							
							<div class="row">

                        <div class="col-sm-12">

                            <div class="panel panel-primary">

                                <div class="panel-heading">

                                    <h3 class="panel-title">
									
									<a class="btn btn-success add-more" onClick="callAddContact2();" >+ ADD MEDICATION</a>&nbsp;&nbsp &nbsp;&nbsp;<a class="btn btn-success add-more" style="cursor:pointer; margin-left:20px" onClick="delRow();" title="Click to remove">
								  <span class="glyphicon glyphicon-remove"></span>&nbsp;Del							</a>
								</h3></div>

 <div class="panel-body">

                                    <div class="row">
													
<table class="table table-striped table-bordered table-hover" id="cntTable2">
							<thead>
								<tr>
									<td width="100px" height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Sr.No.</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Herbs</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Morning</strong></div></td>

									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Lunch</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Evening</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Dinner</strong></div> </td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Guidelines with Anupan </strong></div></td>
									
							</tr></thead>
							<tbody>
							</tbody>
						</table> 
						

					  	<input id="allcontypes" name="allcontypes" value="Decision Maker~^~Influencer~^~Recommender~^~User~^~Purchase Officer" type="hidden">
						<input name="cntlnos" id="cntlnos" value="" type="hidden">
						<input name="cntcount2" id="cntcount2" value="" type="hidden">
						<input name="cntdelids" id="cntdelids" value="" type="hidden">


                                    </div>

                                </div>

                            </div>

                        </div>

                    </div>
							
							
							
							
                          
                            <div class="row">
<div class="col-md-12">
<div class="panel panel-primary">

<div class="panel-body">			
						
						<div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">
							   <div class="form-group">
                                <label for="first_name" class="control-label">NEXT FOLLOW UP DATE</label>
               					 <div class="input-group">
                          <input type="text" class="form-control" placeholder="yyyy-mm-dd" id="datepicker" name="next_followup_on"value="<?php echo $today3; ?>" >
													   <span class="input-group-addon bg-custom b-0"><i class="mdi mdi-calendar text-white"></i></span></div>
                            </div>
</div></div>

<div class="col-sm-3 col-xs-12">
                                            <div class="m-t-20">
							   <div class="form-group">
                                <label for="first_name" class="control-label">NEXT FOLLOW UP TIME</label>
               				<input type="time" class="form-control"  name="next_followup_at" >

                            </div>
</div></div> <div class="clearfix"></div>
<div class="col-sm-12 col-xs-12">
<div class="form-group"  id="city1">

</div>
</div>
	
                          
                            <div class="col-sm-12 col-xs-12">
                                           
                                            <div class="m-t-20">
                                                    <div class="form-group">
                                                        <div>
                                                            <button type="submit" class="btn btn-primary waves-effect waves-light" style="float:right"> Submit </button>
							
															
                                                           
                                                        </div>
                                                    </div>
                                               
                                            </div>
                                        </div>

</div></div>
</div>
</div>

</div>

                    </form></div></div>
									
                                           <script>
        $(document).ready(function() {
           
			
			
            $("#datepicker").on('change', function() {
                var stateid = $(this).val();
                $.ajax({
                    method: "POST",
                    url: "appointments1.php",
                    data: {
                        sid: stateid
                    },
                    datatype: "html",
                    success: function(data) {
                        $("#city1").html(data);

                    }

                });
				
				});
				
		
        });
    </script> 
												
													
<script type="text/Javascript">
	function callAddContact2()
	{
	
   var tbl = document.getElementById('cntTable2');
	 var lastRow = tbl.rows.length;
	 // if there's no header row in the table, then iteration = lastRow + 1
	 var iteration = lastRow;
	 var row = tbl.insertRow(lastRow);
	 var node1;
	 var lineno = lastRow;
	 // cell 0
	 var cellLeft = row.insertCell(0);
	 cellLeft.className = "center";
		var node = document.createElement('span');
		node.className = "glyphicon glyphicon-remove";
		node.title="Delete line";
		var link = document.createElement("a");
		link.className = "btn bg-btn-delete";
		link.style.padding = "0px 2px";
		link.href="javascript:callRemoveContact("+lineno+");";
		link.appendChild(node);
		//cellLeft.appendChild(link);
	 
	 node = document.createElement("input");
	 node.type = 'hidden';
	 node.name = 'cid'+lineno;
	 node.value = '';
	 node.id = 'cid'+lineno;
	 cellLeft.appendChild(node);
	 node = document.createElement("input");
	 node.type = 'text';
	 node.style.width = "50px";
	
	 node.name = 'clinenum'+lineno;
	 node.value = lineno;
	 node.id = 'clinenum'+lineno;
	 cellLeft.appendChild(node);
	 
	 
	 

	 
	  var cell1 = row.insertCell(1); 
    var nodegend = document.createElement('select');
    nodegend.className = 'form-control select2';
	 nodegend.name = 'herbs'+lineno;
 var opt = nodegend.options;
 opt[opt.length] = new Option('Select','');
 <?php $query21 = "select * from product_master";
      // echo $query21;
       $result21 = mysqli_query($conn,$query21);
       $total = mysqli_num_rows($result21);
        while($row=mysqli_fetch_array($result21))
           {
$medicines = $row['product_name'];
$medicines_id = $row['product_id'];
 ?>
opt[opt.length] = new Option('<? echo $medicines ?>','<? echo $medicines_id ?>');
<? } ?>
cell1.appendChild(nodegend);


	 
	  var cell2 = row.insertCell(2); 
    var node = document.createElement('input');
    node.className = 'form-control';
	 node.name = 'morning'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 node.style.textTransform='capitalize';
	 cell2.appendChild(node);
	 
	 
	 	 
	  var cell3 = row.insertCell(3); 
    var node = document.createElement('input');
    node.className = 'form-control';
	 node.name = 'lunch'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell3.appendChild(node);
	

	  var cell4 = row.insertCell(4); 
    var node = document.createElement('input');
    node.className = 'form-control';
	 node.name = 'evening'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell4.appendChild(node);
	
	
		
	  var cell5 = row.insertCell(5); 
    var node = document.createElement('input');
    node.className = 'form-control';
	 node.name = 'dinner'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell5.appendChild(node);
	
	
	
	var cell6 = row.insertCell(6); 
    var node = document.createElement('textarea');
    node.className = 'form-control';
	 node.name = 'anupan_guidelines'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell6.appendChild(node);
	
	
	 
	 
	
	
		
	document.getElementById('cntcount2').value = lineno;
	document.getElementById('sigthseeing').style.visibility='visible';
	
}function delRow()
{

    var tableName = document.getElementById('cntTable2');

    var prev = tableName.rows.length;

    if(prev > 1)

{
    

/////////////////////////////////////////////////////////////////////////////////////
   
	 // if there's no header row in the table, then iteration = lastRow + 1
	
	 var row = document.getElementById('cntTable2').deleteRow(prev-1);
	 
	 }
	 var node1;
	  var iteration = lastRow;
	 var lastRow = tableName.rows.length;
	 var lineno = lastRow;
document.getElementById('cntcount2').value = lineno-1;




}
</script>

													
                                                    
                                        
                              </div>
            </div>
          </div>
		  
		  
		  
		  <div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Past History</h3>
</div>
<div class="panel-body">
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr>
<th>Sr.No.</th>
<th>Date</th>
<th>Ht</th>
<th>Wt</th>
<th>Sign</th>
</tr>
</thead>
<tbody>
<?php
$i=1;

$querys = "select * from   patient_activity where program_id ='".$_REQUEST['program_id']."' and tablename='height_Increasing_program'";
$results = mysqli_query($conn,$querys);	
while($row=mysqli_fetch_array($results))
{
$height = $row['height'];
$prescription_date = $row['prescription_date'];
$weight = $row['weight'];

$date = new DateTime($prescription_date);
$formattedDate = $date->format('d-m-y');

?>
<tr>
<td><?php echo $i?></td>
<td><?php echo $formattedDate?></td>
<td><?php echo $height?></td>
<td><?php echo $weight?></td>
<td></td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>
</div>
</div>
</div>
      </div>
    </div>
   	<?php include 'footer1a.php';?>
