<?php include ('header1f.php');?>
<script src="js/jquery-3.5.1.min.js"></script>
<?php 
date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today3 = date("Y-m-d");
$today1 = date("d/m");


$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'];
}
?> <?php 
date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today3 = date("Y-m-d");
$today1 = date("d/m");

$startDate = date('Y-m-d', strtotime('monday this week'));

// Define the end date of the week
$endDate = date('Y-m-d', strtotime('sunday this week'));

// Generate an array of days in the week
$daysInWeek = [];
$currentDate = $startDate;
while ($currentDate <= $endDate) {
    $daysInWeek[] = $currentDate;
    $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
}

?>

<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 MEDICATION</h3>
              </div>	
		
			
              <div class="panel-body">
                                    <div class="row"> 

               <form name="frm_add_category"  id="frm_add_category" method="post"action="insert_prescription.php" >	
			   <input  type="hidden" name="appointment" value="<?php echo $_REQUEST['appointment']?>"/>
			   <input  type="hidden" name="case_id"  value="<?php echo $_REQUEST['case_id']?>"/>	
			     <input  type="hidden" name="registration_id"  value="<?php echo $registration_id?>"/>
				  <input  type="hidden" name="call_follow_up_id"  value="<?php echo $call_follow_up_id?>"/>				

                        <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 $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="middle_name" class="control-label">Height</label>
                				<input class="form-control" type="text" name="height" placeholder="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" 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" 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>Noon</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>Night</strong></div> </td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>Bedtime</strong></div></td>
									<td  height="28"valign="middle" nowrap="nowrap" ><div align="left" style="padding-left:5px;"><strong>HOME REMIDIES</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-heading">
<h3 class="panel-title">PANCHAKARMA </h3>
</div>
<div class="panel-body">
<div class="col-sm-3 col-xs-12">
<div class="form-group">
<label><b>Panchakarma  Date</b></label>
<select name="day" class="form-control select2" id="state">
<option value="" selected="selected">Select Date</option>
    <?php
    // Get today's date
    $today = date('Y-m-d');

    // Get the current month and year
    $currentMonth = date('m');
    $currentYear = date('Y');
    $numDays = date('t');

    // Loop through the days of the current month and generate options for each day
    for ($day = 1; $day <= $numDays; $day++) {
        // Format the day with leading zero if necessary
        $formattedDay = sprintf('%02d', $day);
        
        // Get the day of the week for the current date
        $dayOfWeek = date('w', mktime(0, 0, 0, $currentMonth, $day, $currentYear));
        // Convert the day of the week number to its corresponding name
        $dayName = date('l', mktime(0, 0, 0, $currentMonth, $day, $currentYear));
        // Format the date in "DayName, dd-mm-yyyy" format
        $formattedDate = "$dayName, $formattedDay-$currentMonth-$currentYear";
		$formattedDate1 = "$currentYear-$currentMonth-$formattedDay";

        // Check if the date is greater than or equal to today's date
        $dateToCompare = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $day, $currentYear));
        if ($dateToCompare >= $today) {
            echo "<option value='$formattedDate1'>$formattedDate</option>";
        }
    }
?>

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

<div class="col-sm-9 col-xs-12">
<div class="form-group"  id="city">

</div>
</div>







 <div class="clearfix"></div>
 
 <div class="col-sm-3 col-xs-12">
<div class="form-group">
<label><b>Timing</b></label>
<select  class="form-control select2" data-style="py-0" name="timing"  required>
<option value="" selected="selected">Select Time Slot</option>
<?php 
$querynp = "select * from time_slot where status='1' ORDER BY time_id ASC";
$resultmp = mysqli_query($conn,$querynp);
while($row=mysqli_fetch_array($resultmp))
{
$time_slot = $row['time_slot'];
?>
<option value="<?php echo $time_slot ?>"><?php echo $time_slot ?> </option>
<?php 	}?>
</select></div>
</div>


 <div class="col-sm-3 col-xs-12">
<div class="form-group">
<label><b>Therapist Name</b></label>
<select  class="form-control select2" data-style="py-0" name="therapist_id"  required>
<option value="" selected="selected">Select Therapist</option>
<?php 
$querynp1 = "select * from therapist_master";
$resultmp1 = mysqli_query($conn,$querynp1);
while($row=mysqli_fetch_array($resultmp1))
{
$therapist_name = $row['therapist_name'];
$therapist_id = $row['therapist_id'];
?>
<option value="<?php echo $therapist_id ?>"><?php echo $therapist_name ?> </option>
<?php 	}?>
</select></div>
</div>




 <div class="col-sm-3 col-xs-12">
<div class="form-group">
<label><b>Panchakarma Program Name</b></label>
<select  class="form-control select2" name="therapyID"  required>
<option value="" selected="selected">Select Panchakarma Program</option>
<?php 
$querynp2 = "select * from therapy_master";
$resultmp2 = mysqli_query($conn,$querynp2);
while($row=mysqli_fetch_array($resultmp2))
{
$therapy_name = $row['therapy_name'];
$therapyID = $row['therapyID'];
?>
<option value="<?php echo $therapyID ?>"><?php echo $therapy_name ?> </option>
<?php 	}?>
</select></div>
</div>


 <div class="col-sm-3 col-xs-12">
<div class="form-group">
<label><b>Location</b></label>
<select  class="form-control" name="branch_id"  required>
<option value="" selected="selected">Select Location</option>
<?php 
$querynp3 = "select * from branch_master";
$resultmp3 = mysqli_query($conn,$querynp3);
while($row=mysqli_fetch_array($resultmp3))
{
$branch_name = $row['branch_name'];
$branch_id = $row['branch_id'];
?>
<option value="<?php echo $branch_id ?>"><?php echo $branch_name ?> </option>
<?php 	}?>
</select></div>
</div>



<script>
        $(document).ready(function() {
           
			
			
            $("#state").on('change', function() {
                var stateid = $(this).val();
                $.ajax({
                    method: "POST",
                    url: "Tchart.php",
                    data: {
                        sid: stateid
                    },
                    datatype: "html",
                    success: function(data) {
                        $("#city").html(data);

                    }

                });
				
				});
				
		
        });
    </script>
</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="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>

                    </form></div></div>
									
                                        
												
													
<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';
	 nodegend.name = 'herbs'+lineno;
 var opt = nodegend.options;
 opt[opt.length] = new Option('Select','');
 <?php $query21 = "select * from medicines_master where status='1'";
      // echo $query21;
       $result21 = mysqli_query($conn,$query21);
       $total = mysqli_num_rows($result21);
        while($row=mysqli_fetch_array($result21))
           {
$medicines = $row['medicines'];
$medicines_id = $row['medicines_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 = 'noon'+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 = 'night'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell5.appendChild(node);
	
	
	  var cell6 = row.insertCell(6); 
    var node = document.createElement('input');
    node.className = 'form-control';
	 node.name = 'bedtime'+lineno;
	 node.placeholder='';
	 node.value = "";
	 node.id = '';
	 cell6.appendChild(node);
	
	
	
	  var cell7 = row.insertCell(7); 
    var nodegend = document.createElement('select');
    nodegend.className = 'form-control';
	 nodegend.name = 'home_remidies'+lineno;
 var opt = nodegend.options;
 opt[opt.length] = new Option('Select','');
 <?php $query22 = "select * from home_remidies_master where status='1'";
      // echo $query21;
       $result22 = mysqli_query($conn,$query22);
        while($row=mysqli_fetch_array($result22))
           {
$home_remidies = $row['home_remidies'];
 ?>
opt[opt.length] = new Option('<? echo $home_remidies ?>','<? echo $home_remidies ?>');
<? } ?>
cell7.appendChild(nodegend);
	
	 
	
	
		
	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>
    </div>
   	<?php include 'footer1a.php';?>
