<div class="sign-in">
    <div class="input-panel">
        <div class="title-panel">
            <h3><?=$title?></h3>
        </div>
        <!------------------------------Start  Form  ------------------------>
        <form method="post" action="<?=base_url('session/save')?>" enctype="multipart/form-data">
            <?php if($id): ?>
            <input type="hidden" name="id" value=<?=$id?>>
            <?php endif; ?>
            <div class="input-fields">
    <!--------------------- The First column ---------------->
                <div class="section-one">
                    <label for="name">Title</label>
                    <input type="text" required name="title" value="<?=(isset($data))?($data['title']):('')?>">
                    <label for="surname">Venue</label>
                    <input type="text" required name="venue" value="<?=(isset($data))?($data['venue']):('')?>">
                    <label for="surname">Description</label>
                    <textarea name="description"><?=(isset($data))?($data['description']):('')?></textarea>
                </div>
    <!--------------------- The second column ---------------->
                <div class="section-two">
                    <label for="select">Start Date</label>
                    <input type="date" required name="start" value="<?=(isset($data))?($data['start']):('')?>">
                    <label for="select">End Date</label>
                    <input type="date" required name="end" value="<?=(isset($data))?($data['start']):('')?>">                    
                    
                    
                    <label for="admins">Admin(s)</label>
                    <select name=admins[] multiple>
                        <?php foreach($admins as $admin): ?>
                            <option <?=(isset($data) && array_search($admin['id'], $data['admins'])!==false)?(" selected "):("")?> value=<?=$admin['id']?>><?=$admin['username']?></option>
                        <?php endforeach; ?>
                    </select>
                    
                    <label for="agents">Agent(s)</label>
                    <select name=agents[] multiple>
                        <?php foreach($agents as $agent): ?>
                            <option <?=(isset($data) && array_search($agent['id'], $data['agents'])!==false)?(" selected "):("")?> value=<?=$agent['id']?>><?=$agent['username']?></option>
                        <?php endforeach; ?>
                    </select>
                    
                    <label for="checkers">Checker(s)</label>
                    <select name=checkers[] multiple>
                        <?php foreach($checkers as $checker): ?>
                            <option <?=(isset($data) && array_search($checker['id'], $data['checkers'])!==false)?(" selected "):("")?> value=<?=$checker['id']?>><?=$checker['username']?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>          
            
            <div class="submit">
                
                <?php
                if(isset($id)):
                ?>
                <div class="edit remove">
                <a class="removeBtn" onclick="return confirm('Are you sure you want to remove?')" href="<?=base_url('session/remove/' . $id)?>">Remove</a>
                </div>
                <?php
                endif;
                ?>                
            <div class="options">
                <?php foreach($event_functions as $key => $value): ?>               
              <label for="checkbox<?=$key?>">
                <input type="checkbox" id="checkbox<?=$key?>" name="functions[]" value="<?=$key?>" <?=(isset($data) && in_array($key, $data['functions'])?(' checked '):(''))?>> Enable <?=$value?>
              </label>
              <?php endforeach; ?>
            </div>
                <input type="submit" name="submit">
                
                
                </div>
        </form>
        <!------------------------------End  Form  ------------------------>
    </div>
</div>
