<?php
$this->session = \Config\Services::session();
$forwardUrl = !empty($forward)? $forward: get_user_dashboard($this, $this->session->get('__user_id'));
?>
<!DOCTYPE html>
<html>

<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="<?php echo base_url();?>/favicon.ico" type="image/x-icon">
    <link rel="icon" href="<?php echo base_url();?>/favicon.ico" type="image/x-icon">

    <title><?php echo SITE_TITLE;?>:
        <?php echo !empty($id)? (!empty($action) && $action=='view'? 'View':'Edit'): 'New';?> School</title>

    <!-- Stylesheets -->
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/jquery-ui.css" />
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.css" />
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.mobile.css" media="(max-width:790px)" />
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.tablet.css"
        media="(min-width:791px) and (max-width: 900px)" />
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.desktop.css" media="(min-width:901px)" />

    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.list.css" />
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/tmis.menu.css" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-uWxY/CJNBR+1zjPWmfnSnVxwRheevXITnMqoEIeG1LJrdI0GlVs/9cVSyPYXdcSF" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/updated.css" />

    <!-- Javascript -->
    <script src="" integrity="sha384-kQtW33rZJAHjgefvhyyzcGF3C5TFyBQBA13V1RKPf4uH+bwyzQxZ6CmMZHmNBEfJ" crossorigin="anonymous"></script>
    <script type='text/javascript' src='<?php echo base_url();?>/assets/js/jquery-2.1.1.min.js'></script>
    <script type='text/javascript' src='<?php echo base_url();?>/assets/js/jquery-ui.js'></script>
    <script type='text/javascript' src='<?php echo base_url();?>/assets/js/jquery.form.js'></script>
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/tmis.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/tmis.callout.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/tmis.fileform.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/tmis.menu.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>/assets/js/tmis.responsive.js"></script>

    <script type="text/javascript">
    var logout_timer = 0;

    function set_logout_interval() {
        // the interval 'timer' is set as soon as the page loads
        logout_timer = setInterval("auto_logout()", 600000);
        // the figure '600000' above indicates how many milliseconds (10 Minutes) the timer be set to.

    }

    function reset_logout_interval() {
        //After events on a page like click,scroll,page load, keystroke
        if (logout_timer != 0) {
            clearInterval(logout_timer);
            logout_timer = 0;
            // second step: implement the timer again
            logout_timer = setInterval("auto_logout()", 600000);
            // completed the reset of the timer
        }
    }

    function auto_logout() {

        // this function will redirect the user to the logout script
        window.location.href = "<?php echo base_url();?>/Account/logout";
    }
    <?php echo !empty($id) && !empty($result['boolean']) && $result['boolean']?"window.top.location.href = '".$forwardUrl."';": "";?>
    </script>
</head>

<body onload="set_logout_interval()" onmousemove="reset_logout_interval()" onclick="reset_logout_interval()" onkeypress="reset_logout_interval()" onscroll="reset_logout_interval()" style="margin:0px;">
    <?php echo view("addons/secure_header");?>

    <div class="container-fluid mx-auto mt-5 pt-5 px-0 app-area">
        <aside class="app-area-sidebar px-3 py-4 bg-primary">
            <nav id="menucontainer" class="nav flex-column">
                <?php echo view("addons/menu");?>
            </nav>
        </aside>
        <main class="app-area-content p-3 pt-5 bg-light">
            <section class="d-flex justify-content-between align-items-center app-area-content-intro">
                <h3><?php echo !empty($id)? (!empty($action) && $action=='view'? 'View':'Edit'): 'New';?>School</h3>
                <?php echo !empty($msg)?"<tr><td>".format_notice($this, $msg)."</td></tr>": "";?>
            </section>
            <section class="app-area-content-body mt-3 px-3 py-3 bg-white">
                <form id="school_data" method="post" autocomplete="off"
                                            action="<?php echo base_url().'/School/add'.(!empty($id)? '/id/'.$id: '');?>"
                                            class='simplevalidator'>
                                            <table border="0" cellspacing="0" cellpadding="10">

                                                <tr>
                                                    <td class="label">Name:</td>
                                                    <td style="padding-right:42px;"><?php if (!empty($id) && $this->session->get('schoolname') || (!empty($action) && $action=='view')) {
    echo "<div class='value'>".$this->session->get('schoolname')."</div>";
} else {?><input type="text" id="schoolname" name="schoolname" title="School Name" class="textfield"
                                                            value="<?php echo $this->session->get('schoolname');?>" /><?php }?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label">School Type:</td>
                                                    <td><?php if (!empty($id) && $this->session->get('schooltype__schooltypes') || (!empty($action) && $action=='view')) {
    echo "<div class='value'>".$this->session->get('schooltype__schooltypes')."</div>";
} else {?><input type="text" id="schooltype__schooltypes" name="schooltype__schooltypes" title="School Type"
                                                            placeholder="Select School Type"
                                                            class="textfield selectfield"
                                                            value="<?php echo $this->session->get('schooltype__schooltypes');?>" /><?php }?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Date Registered:</td>
                                                    <td><?php if (!empty($id) && $this->session->get('dateschoolregistered') || (!empty($action) && $action=='view')) {
    echo "<div class='value'>".date('d-M-Y', strtotime($this->session->get('dateschoolregistered')))."</div>";
} else {?><input type="text" id="dateschoolregistered" name="dateschoolregistered" title="Date Registered"
                                                            class="textfield datefield history"
                                                            value="<?php echo $this->session->get('dateschoolregistered')? date('d-M-Y', strtotime($this->session->get('dateschoolregistered'))):'';?>" /><?php }?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Email Address:</td>
                                                    <td><input type="text" id="schoolemailaddress"
                                                            name="schoolemailaddress" title="School Email Address"
                                                            placeholder="Optional" class="textfield email optional"
                                                            value="<?php echo $this->session->get('schoolemailaddress');?>" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Telephone:</td>
                                                    <td><?php if (!empty($action) && $action=='view') {
    echo "<div class='value'>".$this->session->get('schooltelephone')."</div>";
} else {?><input type="text" id="schooltelephone" name="schooltelephone" title="School Telephone"
                                                            placeholder="(e.g: 0782123456)" maxlength="10"
                                                            class="textfield numbersonly telephone"
                                                            value="<?php echo $this->session->get('schooltelephone');?>" /><?php }?>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label top">Address:</td>
                                                    <td><?php if (!empty($id) && $this->session->get('schooladdress__addressline') || (!empty($action) && $action=='view')) {
    echo "<div class='value'>".
        $this->session->get('schooladdress__addressline')." ".$this->session->get('schooladdress__county')." <br>".$this->session->get('schooladdress__district').", ".$this->session->get('schooladdress__country')."</div>";
} else {?><input type="text" id="schooladdress" name="schooladdress" title="School Address"
                                                            class="textfield placefield physical"
                                                            value="<?php echo $this->session->get('schooladdress__addressline');?>" /><?php }?>
                                                    </td>
                                                </tr>
                                                <?php if (!(!empty($action) && $action=='view')) {?>
                                                <tr>
                                                    <td>&nbsp;</td>
                                                    <td><button type="submit" name="save" id="save"
                                                            class="btn">SAVE</button><?php
    echo !empty($id)? "<input type='hidden' id='schoolid' name='schoolid' value='".$id."' />": "";
    echo "<input type='hidden' id='forward' name='forward' value='school/lists".(!empty($action) && $action!='view'? '/action/'.$action: '')."' />";
    ?></td>
                                                </tr>
                                                <?php }?>
                                            </table>
                                        </form>
            </section>
        </main>
    </div>
        <?php echo view("addons/secure_footer");?>
</body>

</html>