<?php $this->load->view('site/layout'); ?>
<?php
if ($this->session->userdata('language') == "english") {
    $language_set = "arabic";
} else {
    $language_set = "english";
}
if ($language_set == "english") {
    ?>
    <link href="<?php echo base_url() ?>public/plugins/custom/fullcalendar/fullcalendar.bundle.rtl.css" rel="stylesheet" type="text/css" />
<?php } else { ?>
    <link href="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
    

<?php } ?>
<?php $this->load->view('site/navbar'); ?>
<div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">

    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><a href="<?= base_url('announcement/') ?>"><?php echo $this->lang->line('announcement') ?></a></span>
            </div>

        </div>
    </div>
    <div class="kt-portlet">
        <div class="kt-portlet__head">
            <div class="kt-portlet__head-label">
                <h3 class="kt-portlet__head-title">
                    <?php echo $this->lang->line('add') ?> <?php echo $this->lang->line('announcement') ?>
                </h3>
            </div>
        </div>

        <?php echo form_open_multipart(base_url('' . $thispage . '/add/'.$ann)); ?>
        <!-- <form class="kt-form kt-form--label-right"> -->
        <div class="kt-portlet__body">
            <?php if (isset($msg) || validation_errors() !== ''): ?>
                <div class="form-group form-group-last">
                    <div class="alert alert-secondary" role="alert">
                        <div class="alert-icon"><i class="flaticon-warning kt-font-brand"></i></div>
                        <div class="alert-text">
                            <?= validation_errors(); ?>
                            <?= isset($msg) ? $msg : ''; ?>
                        </div>
                    </div>
                </div>
            <?php endif; ?><div class="form-group row">
                <div class="form-group row">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('content') ?></label>
                    <div class="col-10">
                        <textarea class="form-control" placeholder="<?php echo $this->lang->line('enter') ?> <?php echo $this->lang->line('content') ?>" name="content" required autofocus ></textarea>
                    </div>
                </div>

                <div class="form-group row">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('start-date') ?></label>
                    <div class="col-10">
                        <input type="text" class="form-control datepicker_d" placeholder="<?php echo $this->lang->line('select') ?> <?php echo $this->lang->line('start-date') ?>" name="start_date" required />
                    </div>
                </div>

                <div class="form-group row">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('end-date') ?></label>
                    <div class="col-10">
                        <input type="text" class="form-control datepicker_d" placeholder="<?php echo $this->lang->line('select') ?> <?php echo $this->lang->line('end-date') ?>" name="end_date" required />
                    </div>
                </div>
                
                <div class="form-group row ">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('product') ?></label>
                    <div class="col-10">
                        <select class="form-control" name="product">
                            <?php foreach ($products as $product) { ?>
                                <option value="<?= $product->id ?>"><?= $product->name ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>

            <!-- <div class="form-group row">
                    <label for="example-text-input" class="col-2 col-form-label"><?php //echo $this->lang->line('type') ?></label>
                    <div class="col-10">
                        <input type="radio" name="type" value="0" class="type" id="general" /> <?//= $this->lang->line('general') ?> &nbsp;&nbsp;
                        <input type="radio" name="type" value="1" class="type" id="private" /> <?//= $this->lang->line('private') ?>
                    </div>
                </div>  -->

                

                <div class="form-group row private_ann">
                    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('student') ?></label>
                    <div class="col-9">
                        <select multiple data-multi-select-plugin name="username[]" class="topnav form-control" >
                            <?php
                            foreach ($username as $value) {
                                $selected = '';
                                if (!empty($this->input->post('username'))) {
                                    if (in_array($value->username, $this->input->post('username'))) {
                                        $selected = 'selected';
                                    }
                                }
                                ?>
                                <option <?= $selected ?> value="<?php echo $value->username ?>"><?php echo $value->username ?></option>
                            <?php } ?>
                        </select> 
                    </div>
                </div>

            </div>

        </div>
        <div class="kt-portlet__foot">
            <div class="kt-form__actions">
                <div class="row">
                    <div class="col-2">
                    </div>
                    <div class="col-10">
                        <button type="submit" class="btn btn-primary" name="submit" value="pl"><?php echo $this->lang->line('add') ?></button>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <?php $this->load->view('site/footer_2'); ?>

    <script>
    
        $(function () {
        <?php if($ann == 1){ ?>
            $(".private_ann").hide();
    <?php } ?>
            
            $(".datepicker_d").datepicker({format: 'yyyy-mm-dd'});

            $(".type").change(function () {
                if ($("#private").prop('checked')) {
                    $(".private_ann").show();
                } else if ($("#general").prop('checked')) {
                    $(".private_ann").hide();
                }
            });
        });
    </script>
