<?php 
session_start();
include_once '../config.php';
$user_id = $_SESSION['Admin']['id'];
if($_REQUEST['action'] == 'Save'){
$Treatment = addslashes(trim($_REQUEST['Treatment']));
$TreatType1 = addslashes(trim($_REQUEST['TreatType1']));
$TreatName1 = addslashes(trim($_REQUEST['TreatName1']));
$TreatDose1 = addslashes(trim($_REQUEST['TreatDose1']));
$TreatFreq1 = addslashes(trim($_REQUEST['TreatFreq1']));
$TreatDur1 = addslashes(trim($_REQUEST['TreatDur1']));
$TreatEye1 = addslashes(trim($_REQUEST['TreatEye1']));

$TreatType2 = addslashes(trim($_REQUEST['TreatType2']));
$TreatName2 = addslashes(trim($_REQUEST['TreatName2']));
$TreatDose2 = addslashes(trim($_REQUEST['TreatDose2']));
$TreatFreq2 = addslashes(trim($_REQUEST['TreatFreq2']));
$TreatDur2 = addslashes(trim($_REQUEST['TreatDur2']));
$TreatEye2 = addslashes(trim($_REQUEST['TreatEye2']));

$TreatType3 = addslashes(trim($_REQUEST['TreatType3']));
$TreatName3 = addslashes(trim($_REQUEST['TreatName3']));
$TreatDose3 = addslashes(trim($_REQUEST['TreatDose3']));
$TreatFreq3 = addslashes(trim($_REQUEST['TreatFreq3']));
$TreatDur3 = addslashes(trim($_REQUEST['TreatDur3']));
$TreatEye3 = addslashes(trim($_REQUEST['TreatEye3']));

$TreatType4 = addslashes(trim($_REQUEST['TreatType4']));
$TreatName4 = addslashes(trim($_REQUEST['TreatName4']));
$TreatDose4 = addslashes(trim($_REQUEST['TreatDose4']));
$TreatFreq4 = addslashes(trim($_REQUEST['TreatFreq4']));
$TreatDur4 = addslashes(trim($_REQUEST['TreatDur4']));
$TreatEye4 = addslashes(trim($_REQUEST['TreatEye4']));

$TreatType5 = addslashes(trim($_REQUEST['TreatType5']));
$TreatName5 = addslashes(trim($_REQUEST['TreatName5']));
$TreatDose5 = addslashes(trim($_REQUEST['TreatDose5']));
$TreatFreq5 = addslashes(trim($_REQUEST['TreatFreq5']));
$TreatDur5 = addslashes(trim($_REQUEST['TreatDur5']));
$TreatEye5 = addslashes(trim($_REQUEST['TreatEye5']));

$TreatType6 = addslashes(trim($_REQUEST['TreatType6']));
$TreatName6 = addslashes(trim($_REQUEST['TreatName6']));
$TreatDose6 = addslashes(trim($_REQUEST['TreatDose6']));
$TreatFreq6 = addslashes(trim($_REQUEST['TreatFreq6']));
$TreatDur6 = addslashes(trim($_REQUEST['TreatDur6']));
$TreatEye6 = addslashes(trim($_REQUEST['TreatEye6']));

$TreatType7 = addslashes(trim($_REQUEST['TreatType7']));
$TreatName7 = addslashes(trim($_REQUEST['TreatName7']));
$TreatDose7 = addslashes(trim($_REQUEST['TreatDose7']));
$TreatFreq7 = addslashes(trim($_REQUEST['TreatFreq7']));
$TreatDur7 = addslashes(trim($_REQUEST['TreatDur7']));
$TreatEye7 = addslashes(trim($_REQUEST['TreatEye7']));

$TreatType8 = addslashes(trim($_REQUEST['TreatType8']));
$TreatName8 = addslashes(trim($_REQUEST['TreatName8']));
$TreatDose8 = addslashes(trim($_REQUEST['TreatDose8']));
$TreatFreq8 = addslashes(trim($_REQUEST['TreatFreq8']));
$TreatDur8 = addslashes(trim($_REQUEST['TreatDur8']));
$TreatEye8 = addslashes(trim($_REQUEST['TreatEye8']));

$TreatType9 = addslashes(trim($_REQUEST['TreatType9']));
$TreatName9 = addslashes(trim($_REQUEST['TreatName9']));
$TreatDose9 = addslashes(trim($_REQUEST['TreatDose9']));
$TreatFreq9 = addslashes(trim($_REQUEST['TreatFreq9']));
$TreatDur9 = addslashes(trim($_REQUEST['TreatDur9']));
$TreatEye9 = addslashes(trim($_REQUEST['TreatEye9']));

$TreatType10 = addslashes(trim($_REQUEST['TreatType10']));
$TreatName10 = addslashes(trim($_REQUEST['TreatName10']));
$TreatDose10 = addslashes(trim($_REQUEST['TreatDose10']));
$TreatFreq10 = addslashes(trim($_REQUEST['TreatFreq10']));
$TreatDur10 = addslashes(trim($_REQUEST['TreatDur10']));
$TreatEye10 = addslashes(trim($_REQUEST['TreatEye10']));

$TreatType11 = addslashes(trim($_REQUEST['TreatType11']));
$TreatName11 = addslashes(trim($_REQUEST['TreatName11']));
$TreatDose11 = addslashes(trim($_REQUEST['TreatDose11']));
$TreatFreq11 = addslashes(trim($_REQUEST['TreatFreq11']));
$TreatDur11 = addslashes(trim($_REQUEST['TreatDur11']));
$TreatEye11 = addslashes(trim($_REQUEST['TreatEye11']));

$TreatType12 = addslashes(trim($_REQUEST['TreatType12']));
$TreatName12 = addslashes(trim($_REQUEST['TreatName12']));
$TreatDose12 = addslashes(trim($_REQUEST['TreatDose12']));
$TreatFreq12 = addslashes(trim($_REQUEST['TreatFreq12']));
$TreatDur12 = addslashes(trim($_REQUEST['TreatDur12']));
$TreatEye12 = addslashes(trim($_REQUEST['TreatEye12']));

$TreatType13 = addslashes(trim($_REQUEST['TreatType13']));
$TreatName13 = addslashes(trim($_REQUEST['TreatName13']));
$TreatDose13 = addslashes(trim($_REQUEST['TreatDose13']));
$TreatFreq13 = addslashes(trim($_REQUEST['TreatFreq13']));
$TreatDur13 = addslashes(trim($_REQUEST['TreatDur13']));
$TreatEye13 = addslashes(trim($_REQUEST['TreatEye13']));

$CreatedDate = date('Y-m-d');
$Chk = 1;
$ModifiedBy = 0;
$ModifiedDate = null;

$sql = "SELECT * FROM tbl_treatments WHERE Treatment='$Treatment'";
$rncnt = getRow($sql);
if($rncnt > 0){
  try {
$sql1 = "UPDATE tbl_treatments SET TreatChk1='1',TreatType1='$TreatType1',TreatName1='$TreatName1',TreatDose1='$TreatDose1',TreatFreq1='$TreatFreq1',TreatDur1='$TreatDur1',TreatEye1='$TreatEye1',TreatChk2='1',TreatType2='$TreatType2',TreatName2='$TreatName2',TreatDose2='$TreatDose2',TreatFreq2='$TreatFreq2',TreatDur2='$TreatDur2',TreatEye2='$TreatEye2',TreatChk3='1',TreatType3='$TreatType3',TreatName3='$TreatName3',TreatDose3='$TreatDose3',TreatFreq3='$TreatFreq3',TreatDur3='$TreatDur3',TreatEye3='$TreatEye3',TreatChk4='1',TreatType4='$TreatType4',TreatName4='$TreatName4',TreatDose4='$TreatDose4',TreatFreq4='$TreatFreq4',TreatDur4='$TreatDur4',TreatEye4='$TreatEye4',TreatChk5='1',TreatType5='$TreatType5',TreatName5='$TreatName5',TreatDose5='$TreatDose5',TreatFreq5='$TreatFreq5',TreatDur5='$TreatDur5',TreatEye5='$TreatEye5',TreatChk6='1',TreatType6='$TreatType6',TreatName6='$TreatName6',TreatDose6='$TreatDose6',TreatFreq6='$TreatFreq6',TreatDur6='$TreatDur6',TreatEye6='$TreatEye6',TreatChk7='1',TreatType7='$TreatType7',TreatName7='$TreatName7',TreatDose7='$TreatDose7',TreatFreq7='$TreatFreq7',TreatDur7='$TreatDur7',TreatEye7='$TreatEye7',TreatChk8='1',TreatType8='$TreatType8',TreatName8='$TreatName8',TreatDose8='$TreatDose8',TreatFreq8='$TreatFreq8',TreatDur8='$TreatDur8',TreatEye8='$TreatEye8',TreatChk9='1',TreatType9='$TreatType9',TreatName9='$TreatName9',TreatDose9='$TreatDose9',TreatFreq9='$TreatFreq9',TreatDur9='$TreatDur9',TreatEye9='$TreatEye9',TreatChk10='1',TreatType10='$TreatType10',TreatName10='$TreatName10',TreatDose10='$TreatDose10',TreatFreq10='$TreatFreq10',TreatDur10='$TreatDur10',TreatEye10='$TreatEye10',TreatChk11='1',TreatType11='$TreatType11',TreatName11='$TreatName11',TreatDose11='$TreatDose11',TreatFreq11='$TreatFreq11',TreatDur11='$TreatDur11',TreatEye11='$TreatEye11',TreatChk12='1',TreatType12='$TreatType12',TreatName12='$TreatName12',TreatDose12='$TreatDose12',TreatFreq12='$TreatFreq12',TreatDur12='$TreatDur12',TreatEye12='$TreatEye12',TreatChk13='1',TreatType13='$TreatType13',TreatName13='$TreatName13',TreatDose13='$TreatDose13',TreatFreq13='$TreatFreq13',TreatDur13='$TreatDur13',TreatEye13='$TreatEye13',ModifiedBy='$user_id',ModifiedDate='$CreatedDate' WHERE Treatment='$Treatment'";
$conn->query($sql1);
  echo "<script>alert('Record Saved Successfully!');window.location.href='../treatmentmaster.php';</script>";
} 
catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
}
else{
/*$sql = "INSERT INTO tbl_treatments SET Treatment='$Treatment',TreatChk1='1',TreatType1='$TreatType1',TreatName1='$TreatName1',TreatDose1='$TreatDose1',TreatFreq1='$TreatFreq1',TreatDur1='$TreatDur1',TreatEye1='$TreatEye1',TreatChk2='1',TreatType2='$TreatType2',TreatName2='$TreatName2',TreatDose2='$TreatDose2',TreatFreq2='$TreatFreq2',TreatDur2='$TreatDur2',TreatEye2='$TreatEye2',TreatChk3='1',TreatType3='$TreatType3',TreatName3='$TreatName3',TreatDose3='$TreatDose3',TreatFreq3='$TreatFreq3',TreatDur3='$TreatDur3',TreatEye3='$TreatEye3',TreatChk4='1',TreatType4='$TreatType4',TreatName4='$TreatName4',TreatDose4='$TreatDose4',TreatFreq4='$TreatFreq4',TreatDur4='$TreatDur4',TreatEye4='$TreatEye4',TreatChk5='1',TreatType5='$TreatType5',TreatName5='$TreatName5',TreatDose5='$TreatDose5',TreatFreq5='$TreatFreq5',TreatDur5='$TreatDur5',TreatEye5='$TreatEye5',TreatChk6='1',TreatType6='$TreatType6',TreatName6='$TreatName6',TreatDose6='$TreatDose6',TreatFreq6='$TreatFreq6',TreatDur6='$TreatDur6',TreatEye6='$TreatEye6',TreatChk7='1',TreatType7='$TreatType7',TreatName7='$TreatName7',TreatDose7='$TreatDose7',TreatFreq7='$TreatFreq7',TreatDur7='$TreatDur7',TreatEye7='$TreatEye7',TreatChk8='1',TreatType8='$TreatType8',TreatName8='$TreatName8',TreatDose8='$TreatDose8',TreatFreq8='$TreatFreq8',TreatDur8='$TreatDur8',TreatEye8='$TreatEye8',TreatChk9='1',TreatType9='$TreatType9',TreatName9='$TreatName9',TreatDose9='$TreatDose9',TreatFreq9='$TreatFreq9',TreatDur9='$TreatDur9',TreatEye9='$TreatEye9',TreatChk10='1',TreatType10='$TreatType10',TreatName10='$TreatName10',TreatDose10='$TreatDose10',TreatFreq10='$TreatFreq10',TreatDur10='$TreatDur10',TreatEye10='$TreatEye10',TreatChk11='1',TreatType11='$TreatType11',TreatName11='$TreatName11',TreatDose11='$TreatDose11',TreatFreq11='$TreatFreq11',TreatDur11='$TreatDur11',TreatEye11='$TreatEye11',TreatChk12='1',TreatType12='$TreatType12',TreatName12='$TreatName12',TreatDose12='$TreatDose12',TreatFreq12='$TreatFreq12',TreatDur12='$TreatDur12',TreatEye12='$TreatEye12',TreatChk13='1',TreatType13='$TreatType13',TreatName13='$TreatName13',TreatDose13='$TreatDose13',TreatFreq13='$TreatFreq13',TreatDur13='$TreatDur13',TreatEye13='$TreatEye13',CreatedBy='$user_id',CreatedDate='$CreatedDate'";
$conn->query($sql);*/

try {
   $sql = "INSERT INTO tbl_treatments (Treatment,TreatChk1,TreatType1,TreatName1,TreatDose1,TreatFreq1,TreatDur1,TreatEye1,TreatChk2,TreatType2,TreatName2,TreatDose2,TreatFreq2,TreatDur2,TreatEye2,
       TreatChk3,TreatType3,TreatName3,TreatDose3,TreatFreq3,TreatDur3,TreatEye3,TreatChk4,TreatType4,TreatName4,TreatDose4,TreatFreq4,TreatDur4,TreatEye4,TreatChk5,TreatType5,TreatName5,TreatDose5,TreatFreq5,TreatDur5,TreatEye5,TreatChk6,TreatType6,TreatName6,TreatDose6,TreatFreq6,TreatDur6,TreatEye6,TreatChk7,TreatType7,TreatName7,TreatDose7,TreatFreq7,TreatDur7,TreatEye7,
       TreatChk8,TreatType8,TreatName8,TreatDose8,TreatFreq8,TreatDur8,TreatEye8,
       TreatChk9,TreatType9,TreatName9,TreatDose9,TreatFreq9,TreatDur9,TreatEye9,
       TreatChk10,TreatType10,TreatName10,TreatDose10,TreatFreq10,TreatDur10,TreatEye10,
       TreatChk11,TreatType11,TreatName11,TreatDose11,TreatFreq11,TreatDur11,TreatEye11,
       TreatChk12,TreatType12,TreatName12,TreatDose12,TreatFreq12,TreatDur12,TreatEye12,
       TreatChk13,TreatType13,TreatName13,TreatDose13,TreatFreq13,TreatDur13,TreatEye13,

       CreatedBy,CreatedDate,ModifiedBy,ModifiedDate) VALUES (:Treatment,:TreatChk1,:TreatType1,:TreatName1,:TreatDose1,:TreatFreq1,:TreatDur1,:TreatEye1,:TreatChk2,:TreatType2,:TreatName2,:TreatDose2,:TreatFreq2,:TreatDur2,:TreatEye2,
       :TreatChk3,:TreatType3,:TreatName3,:TreatDose3,:TreatFreq3,:TreatDur3,:TreatEye3,:TreatChk4,:TreatType4,:TreatName4,:TreatDose4,:TreatFreq4,:TreatDur4,:TreatEye4,:TreatChk5,:TreatType5,:TreatName5,:TreatDose5,:TreatFreq5,:TreatDur5,:TreatEye5,:TreatChk6,:TreatType6,:TreatName6,:TreatDose6,:TreatFreq6,:TreatDur6,:TreatEye6,:TreatChk7,:TreatType7,:TreatName7,:TreatDose7,:TreatFreq7,:TreatDur7,:TreatEye7,
       :TreatChk8,:TreatType8,:TreatName8,:TreatDose8,:TreatFreq8,:TreatDur8,:TreatEye8,
       :TreatChk9,:TreatType9,:TreatName9,:TreatDose9,:TreatFreq9,:TreatDur9,:TreatEye9,
       :TreatChk10,:TreatType10,:TreatName10,:TreatDose10,:TreatFreq10,:TreatDur10,:TreatEye10,
       :TreatChk11,:TreatType11,:TreatName11,:TreatDose11,:TreatFreq11,:TreatDur11,:TreatEye11,
       :TreatChk12,:TreatType12,:TreatName12,:TreatDose12,:TreatFreq12,:TreatDur12,:TreatEye12,
       :TreatChk13,:TreatType13,:TreatName13,:TreatDose13,:TreatFreq13,:TreatDur13,:TreatEye13,
       :CreatedBy,:CreatedDate,:ModifiedBy,:ModifiedDate)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':Treatment', $Treatment);
$stmt->bindParam(':TreatChk1', $Chk);
$stmt->bindParam(':TreatType1', $TreatType1);
$stmt->bindParam(':TreatName1', $TreatName1);
$stmt->bindParam(':TreatDose1', $TreatDose1);
$stmt->bindParam(':TreatFreq1', $TreatFreq1);
$stmt->bindParam(':TreatDur1', $TreatDur1);
$stmt->bindParam(':TreatEye1', $TreatEye1);
$stmt->bindParam(':TreatChk2', $Chk);
$stmt->bindParam(':TreatType2', $TreatType2);
$stmt->bindParam(':TreatName2', $TreatName2);
$stmt->bindParam(':TreatDose2', $TreatDose2);
$stmt->bindParam(':TreatFreq2', $TreatFreq2);
$stmt->bindParam(':TreatDur2', $TreatDur2);
$stmt->bindParam(':TreatEye2', $TreatEye2);
$stmt->bindParam(':TreatChk3', $Chk);
$stmt->bindParam(':TreatType3', $TreatType3);
$stmt->bindParam(':TreatName3', $TreatName3);
$stmt->bindParam(':TreatDose3', $TreatDose3);
$stmt->bindParam(':TreatFreq3', $TreatFreq3);
$stmt->bindParam(':TreatDur3', $TreatDur3);
$stmt->bindParam(':TreatEye3', $TreatEye3);
$stmt->bindParam(':TreatChk4', $Chk);
$stmt->bindParam(':TreatType4', $TreatType4);
$stmt->bindParam(':TreatName4', $TreatName4);
$stmt->bindParam(':TreatDose4', $TreatDose4);
$stmt->bindParam(':TreatFreq4', $TreatFreq4);
$stmt->bindParam(':TreatDur4', $TreatDur4);
$stmt->bindParam(':TreatEye4', $TreatEye4);
$stmt->bindParam(':TreatChk5', $Chk);
$stmt->bindParam(':TreatType5', $TreatType5);
$stmt->bindParam(':TreatName5', $TreatName5);
$stmt->bindParam(':TreatDose5', $TreatDose5);
$stmt->bindParam(':TreatFreq5', $TreatFreq5);
$stmt->bindParam(':TreatDur5', $TreatDur5);
$stmt->bindParam(':TreatEye5', $TreatEye5);
$stmt->bindParam(':TreatChk6', $Chk);
$stmt->bindParam(':TreatType6', $TreatType6);
$stmt->bindParam(':TreatName6', $TreatName6);
$stmt->bindParam(':TreatDose6', $TreatDose6);
$stmt->bindParam(':TreatFreq6', $TreatFreq6);
$stmt->bindParam(':TreatDur6', $TreatDur6);
$stmt->bindParam(':TreatEye6', $TreatEye6);
$stmt->bindParam(':TreatChk7', $Chk);
$stmt->bindParam(':TreatType7', $TreatType7);
$stmt->bindParam(':TreatName7', $TreatName7);
$stmt->bindParam(':TreatDose7', $TreatDose7);
$stmt->bindParam(':TreatFreq7', $TreatFreq7);
$stmt->bindParam(':TreatDur7', $TreatDur7);
$stmt->bindParam(':TreatEye7', $TreatEye7);

$stmt->bindParam(':TreatChk8', $Chk);
$stmt->bindParam(':TreatType8', $TreatType8);
$stmt->bindParam(':TreatName8', $TreatName8);
$stmt->bindParam(':TreatDose8', $TreatDose8);
$stmt->bindParam(':TreatFreq8', $TreatFreq8);
$stmt->bindParam(':TreatDur8', $TreatDur8);
$stmt->bindParam(':TreatEye8', $TreatEye8);

$stmt->bindParam(':TreatChk9', $Chk);
$stmt->bindParam(':TreatType9', $TreatType9);
$stmt->bindParam(':TreatName9', $TreatName9);
$stmt->bindParam(':TreatDose9', $TreatDose9);
$stmt->bindParam(':TreatFreq9', $TreatFreq9);
$stmt->bindParam(':TreatDur9', $TreatDur9);
$stmt->bindParam(':TreatEye9', $TreatEye9);

$stmt->bindParam(':TreatChk10', $Chk);
$stmt->bindParam(':TreatType10', $TreatType10);
$stmt->bindParam(':TreatName10', $TreatName10);
$stmt->bindParam(':TreatDose10', $TreatDose10);
$stmt->bindParam(':TreatFreq10', $TreatFreq10);
$stmt->bindParam(':TreatDur10', $TreatDur10);
$stmt->bindParam(':TreatEye10', $TreatEye10);

$stmt->bindParam(':TreatChk11', $Chk);
$stmt->bindParam(':TreatType11', $TreatType11);
$stmt->bindParam(':TreatName11', $TreatName11);
$stmt->bindParam(':TreatDose11', $TreatDose11);
$stmt->bindParam(':TreatFreq11', $TreatFreq11);
$stmt->bindParam(':TreatDur11', $TreatDur11);
$stmt->bindParam(':TreatEye11', $TreatEye11);

$stmt->bindParam(':TreatChk12', $Chk);
$stmt->bindParam(':TreatType12', $TreatType12);
$stmt->bindParam(':TreatName12', $TreatName12);
$stmt->bindParam(':TreatDose12', $TreatDose12);
$stmt->bindParam(':TreatFreq12', $TreatFreq12);
$stmt->bindParam(':TreatDur12', $TreatDur12);
$stmt->bindParam(':TreatEye12', $TreatEye12);

$stmt->bindParam(':TreatChk13', $Chk);
$stmt->bindParam(':TreatType13', $TreatType13);
$stmt->bindParam(':TreatName13', $TreatName13);
$stmt->bindParam(':TreatDose13', $TreatDose13);
$stmt->bindParam(':TreatFreq13', $TreatFreq13);
$stmt->bindParam(':TreatDur13', $TreatDur13);
$stmt->bindParam(':TreatEye13', $TreatEye13);
$stmt->bindParam(':CreatedBy', $user_id);
$stmt->bindParam(':CreatedDate', $CreatedDate);
$stmt->bindParam(':ModifiedBy', $ModifiedBy);
$stmt->bindParam(':ModifiedDate', $ModifiedDate);
if ($stmt->execute()) {
  echo "<script>alert('Record Saved Successfully!');window.location.href='../treatmentmaster.php';</script>";
}
} 
catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
}
/*echo "<script>alert('Record Saved Successfully!');window.location.href='../treatmentmaster.php';</script>";*/
}


if($_REQUEST['action'] == 'getRecords'){
  $Treatment = addslashes(trim($_REQUEST['Treatment']));
  $sql = "SELECT * FROM tbl_treatments WHERE Treatment='$Treatment'";
  $rncnt = getRow($sql);
  $row = getRecord($sql);
  if($rncnt > 0){
    echo json_encode($row);
  }
  else{
    echo 0;
  }

  }

if($_REQUEST['action'] == 'deleteTreatment'){
  $Treatment = addslashes(trim($_REQUEST['Treatment']));
  $sql = "DELETE FROM tbl_treatments WHERE Treatment='$Treatment'";
  $conn->query($sql);
  echo "Record Deleted Successfully!";
  } 


    if($_REQUEST['action'] == 'addMore'){
    $i = 2;
    ?>
    <tr id="row<?php echo $i;?>">
                                                  
                                                        <!--<td>
                                                            <input class="form-control" type="text" list="Treat_Type1" name="TreatType1[]"  id="TreatType1">
                                                                <datalist id="Treat_Type1">
                                                                    <?php $sql = "SELECT DISTINCT(TreatType1) As TreatType1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatType1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                         </td>-->
                                                          <td><input class="form-control" type="text" name="ShortKey1[]" list="Short_Key1" id="ShortKeynv<?php echo $i;?>" oninput="checkShortKey3(<?php echo $i;?>)">
                                                            <datalist id="Short_Key1">
                                                                <?php $sql = "SELECT ShortKey FROM tbl_drugs";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['ShortKey']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                          </td>
                                                        <td>
                                                           <input class="form-control" list="Treat_Name1" type="text" name="TreatName1[]"  id="TreatNamenv<?php echo $i;?>" required>
                                                             <datalist id="Treat_Name1">
                                                                <?php $sql = "SELECT DISTINCT(TreatName1) As TreatName1 FROM tbl_consultant_treatments UNION ALL SELECT DISTINCT(TreatName1) As TreatName1 FROM tbl_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatName1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                               
                                                        </td>
                                                        <!-- <td>
                                                            <input class="form-control" type="text" list="Treat_Dose1" name="TreatDose1[]"  id="TreatDose1">
                                                                <datalist id="Treat_Dose1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDose1) As TreatDose1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDose1']; ?>">
                                                                <?php } ?>
                                                                    
                                                                </datalist>
                                                        </td> -->
                                                        <td>
                                                            <input class="form-control" type="text" list="Treat_Freq1" name="TreatFreq1[]"  id="TreatFreq1">
                                                                <datalist id="Treat_Freq1">
                                                                <?php $sql = "SELECT FreqName As TreatFreq1 FROM tbl_freq";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatFreq1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td>
                                                       <!--  <td>
                                                            <input class="form-control" type="text" list="Treat_Dur1" name="TreatDur1[]"  id="TreatDur1">
                                                                <datalist id="Treat_Dur1">
                                                                <?php $sql = "SELECT DISTINCT(TreatDur1) As TreatDur1 FROM tbl_consultant_treatments";
                                                                    $row = getList($sql);
                                                                    foreach($row as $result){?>    
                                                                <option value="<?php echo $result['TreatDur1']; ?>">
                                                                <?php } ?>
                                                                </datalist>
                                                        </td> -->
                                                        
                                                         <td align="center" valign="top"> <button class="btn btn-danger btn_remove" type="button" id="<?php echo $i;?>"><i class="feather icon-x"></i></button>
                                                           </td>

                                                    </tr>

  <?php }
?>