<?php
$this->session = \Config\Services::session();
$forward = check_access($this, 'publish_job_notices', 'boolean', false)? '/vacancy/lists/action/publish': 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)? 'Edit': 'New';?> Job</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 rel="stylesheet" href="<?php echo base_url();?>/assets/css/trumbowyg.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>
    <?php echo minify_js('vacancy-new_vacancy', array('jquery-2.1.1.min.js', 'jquery-ui.js', 'jquery.form.js', 'tmis.js', 'tmis.fileform.js', 'tmis.menu.js', 'tmis.responsive.js', 'trumbowyg.js'));?>
    <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 = '".base_url().$forward."';": "";?>
    </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)? 'Edit': 'New';?> Job</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="user_data" method="post" autocomplete="off"
                                            action="<?php echo base_url().'/Vacancy/add'.(!empty($id)? '/id/'.$id: '');?>"
                                            class='simplevalidator'>
                                            <table border="0" cellspacing="0" cellpadding="10">
                                                <tr>
                                                    <td class="label">Institution:</td>
                                                    <td style="padding-right:42px;"><?php if (!empty($id) && $this->session->get('institution__institutions')) {
    echo "<div class='value'>".$this->session->get('institution__institutions')."</div>";
} else {?><input type="text" id="institution__institutions" name="institution__institutions"
                                                            title="Select or Search for Instution"
                                                            placeholder="Select or Search for Institution"
                                                            class="textfield selectfield searchable"
                                                            value="<?php echo $this->session->get('institution__institutions');?>"
                                                            style="width:97%;" /><?php }?></td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Duty:</td>
                                                    <td style="padding-right:42px;"><?php if (!empty($id) && $this->session->get('role__jobroles')) {
    echo "<div class='value'>".$this->session->get('role__jobroles')."</div>";
} else {?><input type="text" id="role__jobroles" name="role__jobroles" title="Select Duty"
                                                            placeholder="Select Job Duty" class="textfield selectfield"
                                                            value="<?php echo $this->session->get('role__jobroles');?>"
                                                            style="width:97%;" /><?php }?></td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Headline:</td>
                                                    <td><input type="text" id="headline" name="headline"
                                                            title="Headline" class="textfield" style="width:97%;"
                                                            value="<?php echo $this->session->get('headline');?>" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label top">Summary:</td>
                                                    <td><textarea id="summary" name="summary" title="Job Summary"
                                                            class="textfield"
                                                            style="width:97%; height:60px;"><?php echo $this->session->get('summary');?></textarea>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label top">Details:</td>
                                                    <td style="padding-top:0px;"><textarea id="details" name="details"
                                                            title="Job Details" class="textfield"
                                                            placeholder="Enter the job details here."><?php echo $this->session->get('details');?></textarea>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="label">Publish Duration:</td>
                                                    <td>
                                                        <div class="nextdiv"><input type="text" id="publishstart"
                                                                name="publishstart" title="Start Date"
                                                                placeholder="Start Date" maxlength="20"
                                                                class="textfield datefield"
                                                                value="<?php echo $this->session->get('publishstart');?>" />
                                                        </div>
                                                        <div class="nextdiv"><input type="text" id="publishend"
                                                                name="publishend" title="End Date"
                                                                placeholder="End Date" maxlength="20"
                                                                class="textfield datefield"
                                                                value="<?php echo $this->session->get('publishend');?>" />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>&nbsp;</td>
                                                    <td><input type="submit" name="save" id="save" class="btn"
                                                            value="SAVE" /><?php echo !empty($id)? "<input type='hidden' id='vacancyid' name='vacancyid' value='".$id."' />": "";
    
    echo  empty($id)? "<input type='hidden' id='forwardurl' name='forwardurl' value='".$forward."' />": "";?></td>
                                                </tr>
                                            </table>
                                        </form>
            </section>
        </main>
    </div>
        <?php echo view("addons/secure_footer");?>

    <script type="text/javascript">
    $(function() {
        var btnsGrps = jQuery.trumbowyg.btnsGrps;
        $('#details').trumbowyg({
            btns: ['formatting',
                '|', btnsGrps.design,
                '|', 'link',
                '|', btnsGrps.justify,
                '|', btnsGrps.lists,
                '|', 'insertHorizontalRule'
            ]
        });
    });
    </script>
</body>

</html>