<!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Enter form details
                        </div>
                        <div class="panel-body">
                            
                                    <?php 
$mode = $_REQUEST['mode'];
$demographic_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "demographics";
$tbl_id = "study_id";
$db = new db_transactions();
if ($mode == "demographics") {
    $study_id = $_POST['study_id'];
    $abs_date = $_POST['abs_date'];
    $facility_id = $_POST['facility_id'];
    $anc_id = $_POST['anc_id'];
    $psc_id = $_POST['psc_id'];
    $visit_count = $_POST['visit_count'];
    $anc_visit_date = $_POST['anc_visit_date'];
    $birth_date = $_POST['birth_date'];
    $residence = $_POST['residence'];
    $parity = $_POST['parity'];
    $gravida = $_POST['gravida'];
    $gestational_period = $_POST['gestational_period'];
    $lmp_date = strtotime($_POST['lmp']);
    //make text field date database friendly
<?php

require_once "c_transactions.php";
$db = new db_transactions();
?>
<!DOCTYPE html>
    <!--
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    -->
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <form method="post">
                <button type="submit" name="btn_export">Data Export</button>
                <button type="submit" name="btn_import">Data Import</button>
            </form>
            <?php 
$host = "localhost";
$uname = "root";
$pass = "";
$database = "demo";
//Change Your Database Name
$conn = new mysqli($host, $uname, $pass, $database) or die("No Connection");
echo mysql_error();
//MYSQL MYADDMINPHP TO CSV
if (isset($_REQUEST['btn_export'])) {
<?php

require_once "c_transactions.php";
$db = new db_transactions();
$sql = "SELECT \nvariables_id AS VariableID, \nv_study_id AS StudyID,\ntb_status AS TB_Status, \npreg_status AS Preg_Status,\nedd AS EDD,\nfp_status AS FP_status, \ndisclosure AS HIV_Disclosure,\nnext_visit_date AS Next_visit_date\nFROM variables";
$data = $db->getAssoArray($sql);
$results = array("sEcho" => 1, "iTotalRecords" => count($data), "iTotalDisplayRecords" => count($data), "aaData" => $data);
/*while($row = $result->fetch_array(MYSQLI_ASSOC)){
  $results["data"][] = $row ;
}*/
echo json_encode($results);
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Enter form details 
                        </div>
                        <div class="panel-body">
                            
                           <?php 
$mode = $_REQUEST['mode'];
$adherence_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "adherence";
$tbl_id = "adherence_id";
$db = new db_transactions();
$art_effect = getArtSideEffect();
//echo $art_effect;
if ($mode == "adherence") {
    $a_study_id = $_POST['a_study_id'];
    $visit = $_POST['visit_date'];
    $haart_change = $_POST['haart_change'];
    $haart_change_date = $_POST['haart_change_date'];
    $haart_regimen = $_POST['haart_regimen'];
    //$art_effect = $_POST['art_effect'];
    $self_art_adherence = $_POST['self_art_adherence'];
    $self_ctx_adherence = $_POST['self_ctx_adherence'];
    $cd4_taken = $_POST['cd4_taken'];
    if ($cd4_taken == "NA" || $cd4_taken == "N" || $cd4_taken == "NV") {
        $cd4_count = 'NULL';
    } else {
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Enter form details
                        </div>
                        <div class="panel-body">
                            
                                    <?php 
$mode = $_REQUEST['mode'];
$anc_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "anc_followup";
$tbl_id = "anc_id";
$db = new db_transactions();
if ($mode == "anc_followup") {
    $anc_study_id = $_POST['anc_study_id'];
    $abs_date = $_POST['abs_date'];
    $visit_count = $_POST['visit_count'];
    $anc_visit_date = $_POST['anc_visit_date'];
    $gestational_period = $_POST['gestational_period'];
    $haart_change = $_POST['haart_change'];
    $haart_regimen = $_POST['haart_regimen'];
    $haart_change_date = $_POST['haart_change_date'];
    $counselling = $_POST['counselling'];
    $hiv_status_partner = $_POST['hiv_status_partner'];
    $return_date = $_POST['return_date'];
    $btn = $_POST['btn'];
    $anc_followup = array($anc_study_id, $abs_date, $visit_count, $anc_visit_date, $gestational_period, $haart_change, $haart_regimen, $haart_change_date, $counselling, $hiv_status_partner, $return_date);
    if ($btn == "submit") {
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Infant Diagnosis form</h1>
                    <div class="panel panel-default">
                        
                        <!-- /.panel-heading -->
                        <?php 
$mode = $_REQUEST['mode'];
$Diag_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$hei_id = $_REQUEST['hei_id'];
$table = "infant_diagnosis";
$tbl_id = "diagnosis_id";
$db = new db_transactions();
$immunization = getImmunizations();
if ($mode == "diagnosis") {
    $hei_id = $_POST['hei_id'];
    $visit_date = $_POST['visit_date'];
    $weight = $_POST['weight'];
    $height = $_POST['height'];
    $tb_contact = $_POST['tb_contact'];
    $tb_ass_outcome = $_POST['tb_ass_outcome'];
    $inf_milestones = $_POST['inf_milestones'];
    $feeding_6wks = $_POST['feeding_6wks'];
    $feeding_10wks = $_POST['feeding_10wks'];
    $feeding_14wks = $_POST['feeding_14wks'];
    $feeding_6mths = $_POST['feeding_6mths'];
    $feeding_9mths = $_POST['feeding_9mths'];
    $feeding_12mths = $_POST['feeding_12mths'];
                <div class="col-lg-8">
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                            Enter form details 
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-8">
                               <?php 
$mode = $_REQUEST['mode'];
$user_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "system_users";
$table_role = "role";
$tbl_id = "u_userid";
$db = new db_transactions();
if ($mode == "user") {
    $usn = $_POST['u_username'];
    $pwd = $_POST['u_password'];
    $role_code = $_POST['u_rolecode'];
    $name = $_POST['u_name'];
    $btn = $_POST['btn'];
    $user = array($usn, $pwd, $role_code, $name);
    if ($btn == "u_submit") {
        if ($db->insertUser($user) > 0) {
            echo '<label class="control-label" for="inputSuccess">New user created successfully</label> <br \\> Return to <a href="dashboard.php" >Dashboard</a>';
        } else {
            echo '<label class="control-label" for="inputError">New user was not created.</label><br \\>Return to <a href="dashboard.php" >Dashboard</a>';
        }
    } else {
        if ($btn == "u_update") {
<?php

require_once "c_transactions.php";
$db = new db_transactions();
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$csv = array();
// SQL statements
$sql_demographics = "INSERT INTO demographics (study_id, abs_date, facility_id, anc_id, psc_id, visit_count, " . "anc_visit_date, birth_date, residence, parity, gravida, gestational_period, lmp, edd," . " marital_status, hiv_status, initial_hiv_status, hiv_retest, woman_haart, haart_regimen, " . "counselling, hiv_status_partner, return_date, user_initial) ";
$sql_infant_registration = "INSERT INTO infant_registration(hei_id, d_study_id, birth_date, birth_weight, " . "sex, delivery_place, arv_prophylaxis, arv_pro_other, enrol_date, enrol_age, user_initial) ";
$sql_adherence = "INSERT INTO adherence(a_study_id, visit_date, haart_start_date, haart_regimen, art_effect, " . "self_art_adherence, self_ctx_adherence, cd4_taken, cd4_count, cd4_date, vl_taken, viral_load, " . "viral_date, who_stage, user_initial, next_visit_date) ";
$sql_variables = "INSERT INTO variables(v_study_id, visit_date, weight, height, hb_taken, hemoglobin, " . "hemoglobin_date, tb_status, preg_status, edd, fp_status, fp_method, disclosure, patner_tested, " . "user_initial, next_visit_date) ";
$sql_retention = "INSERT INTO retention (r_study_id, hiv_visit, next_visit, user_initial) ";
$sql_infant_diagnosis = "INSERT INTO infant_diagnosis(i_hei_id, visit_date, weight, height, " . "tb_contact, tb_ass_outcome, inf_milestones, imm_history, next_appointment, first_sample_collection, first_results_collected," . "first_results, second_sample_collection, second_results_collected, second_results, third_sample_collection, " . " third_results_collected, third_results, forth_sample_collection, forth_results_collected, forth_results," . "fifth_sample_collection, fifth_results_collected, fifth_results, sixth_sample_collection, sixth_results_collected," . "sixth_results, hei_outcome, exit_date, feeding_6wks, feeding_10wks, " . "feeding_14wks, feeding_9mths, feeding_12mths, feeding_15mths, feeding_18mths, " . "user_initial) ";
$sql_anc_followup = "INSERT INTO anc_followup (anc_study_id, abs_date, visit_count, " . "anc_visit_date, gestational_period, haart_regimen, counselling, " . "hiv_status_partner, return_date, user_initial)";
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Summary of participant's visit</title>
    <!-- Bootstrap Core CSS -->
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<?php

//require_once("c_role.php");
require_once "c_transactions.php";
//$role = new Role();
$db = new db_transactions();
$db->setMenuSession();
$inactive = 600;
if (!isset($_SESSION['timeout'])) {
    header("Location: logout.php");
} else {
    $session_life = time() - $_SESSION['timeout'];
    if ($session_life > $inactive) {
        header("Location: logout.php");
    }
}
$_SESSION['timeout'] = time();
?>
  
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>OBP Dashboard</title>
    <!-- Bootstrap Core CSS -->
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
//women variable variables
$women_variables_table = "variables";
$women_variables_table_id = "v_study_id";
//women retention variables
$women_retention_table = "retention";
$women_retention_table_id = "r_study_id";
//women adherence variables
$women_adherence_table = "adherence";
$women_adherence_table_id = "a_study_id";
//women anc followup variables
$women_anc_followup_table = "anc_followup";
$women_anc_followup_table_id = "anc_study_id";
//infant registration variables
$infant_registration_table = "infant_registration";
$infant_registration_table_id = "d_study_id";
$db = new db_transactions();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Summary of participant's visit</title>
    <!-- Bootstrap Core CSS -->
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
    header("Location: logout.php");
} else {
    $session_life = time() - $_SESSION['timeout'];
    if ($session_life > $inactive) {
        header("Location: logout.php");
    }
}
$_SESSION['timeout'] = time();
//infant registration variables
$infant_registation_id = $_REQUEST["id"];
$infant_registration_table = "infant_registration";
$infant_registration_table_id = "id";
//infant diagnosis variables
$infant_diagnosis_table = "infant_diagnosis";
$infant_diagnosis_table_id = "i_hei_id";
$db = new db_transactions();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Summary of participant's visit</title>
    <!-- Bootstrap Core CSS -->
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Enter form details 
                        </div>
                           <div class="col-lg-6">
                                    <?php 
$mode = $_REQUEST["mode"];
$retention_id = $_REQUEST["id"];
$action = $_REQUEST["action"];
$table = "retention";
$tbl_id = "retention_id";
$db = new db_transactions();
if ($mode == "retention") {
    $studyid = $_POST['studyid'];
    $hiv_visit = $_POST['hiv_visit'];
    $next_visit = $_POST['next_visit'];
    $btn = $_POST['btn'];
    $retention = array($studyid, $hiv_visit, $next_visit);
    if ($btn == "submit") {
        if ($db->insertRentention($retention) > 0) {
            echo '<label class="control-label" for="inputSuccess">Women Retention recorded successfully</label> <br \\> Return to <a href="dashboard.php" >Dashboard</a>';
        } else {
            echo '<label class="control-label" for="inputError">Women Retention was not recorded.</label><br \\>Return to <a href="dashboard.php" >Dashboard</a>';
        }
    } else {
        if ($btn == "update") {
            if ($db->editRentention($retention, $retention_id) > 0) {
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Enter form details
                        </div>
                        <div class="panel-body">
                            
                       <?php 
$mode = $_REQUEST['mode'];
$variables_id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "variables";
$tbl_id = "variables_id";
$db = new db_transactions();
$fp_method = getFpMethods();
if ($mode == "variables") {
    $v_study_id = $_POST['v_study_id'];
    $visit = $_POST['visit_date'];
    $weight = $_POST['weight'];
    $height = $_POST['height'];
    $hb_taken = $_POST['hb_taken'];
    if ($hb_taken == "NA" || $hb_taken == "N") {
        $hemoglobin = 'NULL';
    } else {
        $hemoglobin = $_POST['hemoglobin'];
    }
    $hemoglobin_date = $_POST['hemoglobin_date'];
    $tb_status = $_POST['tb_status'];
    $preg_status = $_POST['preg_status'];
        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Infant Registration form</h1>
                    <div class="panel panel-default">
                        
                        <!-- /.panel-heading -->
                        <?php 
$mode = $_REQUEST['mode'];
$reg_id = $_REQUEST['reg_id'];
$id = $_REQUEST['id'];
$action = $_REQUEST['action'];
$table = "infant_registration";
$tbl_id = "id";
$db = new db_transactions();
if ($mode == "registration") {
    $hei_id = $_POST['hei_id'];
    $d_study_id = $_POST['d_study_id'];
    $birth_date = $_POST['birth_date'];
    $birth_weight = $_POST['birth_weight'];
    $sex = $_POST['sex'];
    $delivery_place = $_POST['delivery_place'];
    $arv_prophylaxis = $_POST['arv_prophylaxis'];
    $arv_pro_other = $_POST['arv_pro_other'];
    $enrol_date = $_POST['enrol_date'];
    $enrol_age = $_POST['enrol_age'];
    $participant_outcome = $_POST['participant_outcome'];
    $outdate = $_POST['outdate'];
    $btn = $_POST['btn'];
    $registration = array($hei_id, $d_study_id, $birth_date, $birth_weight, $sex, $delivery_place, $arv_prophylaxis, $arv_pro_other, $enrol_date, $enrol_age, $participant_outcome, $outdate);