

<?php echo form_open_multipart(); ?>
<!-- <form class="kt-form kt-form--label-right"> -->
<?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; ?>
<?php if ($this->session->flashdata('success')): ?>
    <div class="alert alert-success alert-dismissible">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4><i class="icon fa-warning"></i> Success!</h4>
        <?= $this->session->flashdata('success'); ?>
    </div>
<?php endif; ?>
<div class="form-group row">
    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('eng_title') ?></label>
    <div class="col-10">
        <input type="text" class="form-control" id="exampleInputEmail1" placeholder="<?php echo $this->lang->line('enter') ?> <?php echo $this->lang->line('eng_title') ?>" name="eng_title"  >
    </div>
</div>
<div class="form-group row">
    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('ar_title') ?></label>
    <div class="col-10">
        <input type="text" class="form-control" id="exampleInputEmail1" placeholder="<?php echo $this->lang->line('enter') ?> <?php echo $this->lang->line('ar_title') ?>" name="ar_title" >
    </div>
</div>
<div class="form-group row">
    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('choice_type') ?></label>
    <div class="col-10">
        <select name="choice_type" class="form-control">
            <option value="0"><?= $this->lang->line('single_choice') ?></option>
            <option value="1"><?= $this->lang->line('multiple_choice') ?></option>
        </select>
    </div>
</div>
<div class="form-group row">
    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('required') ?></label>
    <div class="col-10">
        <select name="required" class="form-control">
            <option value="1"><?= $this->lang->line('yes') ?></option>
            <option value="0"><?= $this->lang->line('no') ?></option>
        </select>
    </div>
</div>

<div class="form-group row">
    <label for="example-text-input" class="col-2 col-form-label"><?php echo $this->lang->line('filter_by') ?> <?php echo $this->lang->line('group_name') ?></label>
    <div class="col-10">
        <select name="group_name" class="form-control" id="group_name">
            <option value="all"><?= $this->lang->line('all') ?></option>
            <?php foreach ($group_name as $value) { ?>
                <option value="<?= $value->group_name ?>"><?= $value->group_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('options') ?></label>
    <div class="col-10">
        <select name="options[]" class="form-control" id="options" multiple style="width: 100%">
            <?php foreach ($adds as $value) { ?>
                <option value="<?= $value->id ?>"><?= $this->session->userdata('language') == 'english' ? $value->name_en : $value->name_ar ?></option>
            <?php } ?>
        </select>
    </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 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('product_additions') ?>
            </h3>
        </div>
    </div>-->
    <!--        <div class="kt-portlet__body">
                <table
                    class="table table-striped- table-bordered table-hover table-checkable"
                    id="kt_table_1">
                    <thead>
                        <tr>
                            <th><?php echo $this->lang->line('eng_title') ?></th>
                            <th><?php echo $this->lang->line('ar_title') ?></th>
                            <th><?php echo $this->lang->line('choice_type') ?></th>
                            <th><?php echo $this->lang->line('required') ?></th>
                            <th><?php echo $this->lang->line('options') ?></th>
                            <th class="text-center"><?php echo $this->lang->line('action'); ?></th>
                        </tr>
                    </thead>
                    <tbody>     <?php
    $count = 1;
    foreach ($product_adds as $row) {
        ?>
                                <tr>
                                    <td><?= $row->title_en ?></td>
                                    <td><?= $row->title_ar ?></td>
                                    <td><?= $row->choice_type == 0 ? $this->lang->line('single_choice') : $this->lang->line('multiple_choice') ?></td>
                                    <td><?= $row->required == 1 ? '<i class="fa fa-check text-success fa-2x"></i>' : '<i class="fa fa-close text-danger fa-2x"></i>' ?></td>
                                    <td><?= $row->options ?></td>
                                    <td>
                                        <a href="" onclick="alert_box(<?php echo $row->id ?>)"
                                           class="btn btn-icon btn-danger btn-sm"
                                           title="<?php echo $this->lang->line('delete'); ?>"> <i
                                                class="la la-trash"></i>
                                        </a>
                                    </td>
                                </tr>
    <?php } ?>
                    </tbody>
                </table>
    
            </div>-->
<!--</div>-->
<?php $this->load->view('site/footer_2'); ?>
<script>
    $('select').select2();
//        function alert_box(id) {
//            var result = confirm("Are You Confirm!")
//            if (result) {
//                window.location.href = "<?//= base_url('' . $this->thispage . '/delete_product_addition/') ?>" + id + '/' +<?//= $product_id ?>;
//            }
//        }
    $("#group_name").change(function () {
        $.ajax({
            type: "POST",
            url: "<?php echo base_url() ?>producer/filter_additions_by_group_name",
            data: {group_name: $(this).val()},
            dataType: 'JSON',
            success: function (result) {
                $("#options").html('');
                for (var i = 0; i < result.length; i++) {
                    var name = result[i].name_en;
<?php if ($this->session->userdata('language') == 'arabic') { ?>
                        name = result[i].name_ar;
<?php } ?>
                    $("#options").append('<option value="' + result[i].id + '">' + name + '</option>');
                }
            }
        });
    });
</script>