<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 bodyitem">
    <?php if ($this->session->userdata('gkpos_usertype') == 1 || $this->session->userdata('gkpos_usertype') == 2): ?>
        <div class="row no-padding">
            <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12 text-uppercase'>
                <input type="checkbox" class="checkbox-inline" id="showHideAddSpecial" onclick="checkBlock(this.id, 'AddNewSpecialBox')">
                <span style="color: #FFF"><?php echo $this->lang->line('gkpos_add_new_special') ?></span>
            </div>
        </div>
        <div class="row no-padding" id="AddNewSpecialBox">
            <?php echo form_open('gkpos/settings/save_spacial/', array('id' => 'special_form', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal')); ?>
            <div id="config_wrapper">
                <fieldset id="config_info">
                    <div class="form-group form-group-sm">	
                        <?php echo form_label('Name', 'title', array('class' => 'control-label col-lg-4 col-md-4 col-sm-4 col-xs-4 text-uppercase required')); ?>
                        <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
                            <div class="input-group">
                                <span class="input-group-addon" style="background-color: #FF0000;"><a href="#"><i class="fa fa-table" aria-hidden="true"></i></a></span>
                                <input name="title" class="form-control required"  type="text" id="title" value="<?php isset($title) ? print $title : print'' ?>">
                            </div>
                        </div>
                    </div>
                    <div class="form-group form-group-md">	
                        <div class="col-md-offset-4 col-md-8">
                            <ul id="promotion_error_message_box" class="error_message_box"></ul>
                            <?php
                            echo form_submit(array(
                                'name' => 'submit_form',
                                'id' => 'submit_form',
                                'value' => $this->lang->line('gkpos_numpad_key_enter'),
                                'class' => 'btn btn-block btn-danger round btn-sm'));
                            ?>
                        </div>
                    </div>
                </fieldset>
            </div>
            <?php echo form_close(); ?>
            <script type='text/javascript'>
                $(document).ready(function () {
                    keyboard('clientsCTA1');
                    keyboard('clientsCTA');
                    $('#special_form').validate({
                        submitHandler: function () {
                            var myform = document.getElementById('special_form');
                            var formdata = new FormData(myform);
                            $.ajax({
                                url: $('#special_form').attr('action'),
                                data: formdata,
                                cache: false,
                                processData: false,
                                contentType: false,
                                type: 'POST',
                                dataType: 'json',
                                success: function (response) {
                                    if (response.success) {
                                        ALERT_TITLE = 'Success';
                                        alert(response.message);
                                        getSettingPage('<?php echo site_url('gkpos/settings/special') ?>', '<?php echo $this->lang->line('gkpos_system_spacial') ?>')
                                    } else {
                                        ALERT_TITLE = "Error!";
                                        alert(response.message);
                                    }
                                }
                            });
                        },
                        errorClass: "has-error",
                        errorLabelContainer: "#promotion_error_message_box",
                        wrapper: "li",
                        highlight: function (e) {
                            $(e).closest('.form-group').addClass('has-error');
                        },
                        unhighlight: function (e) {
                            $(e).closest('.form-group').removeClass('has-error');
                        },
                        rules: {
                            title: "required"
                        },
                        messages: {
                            title: "<?php echo $this->lang->line('gkpos_special_required'); ?>",
                        }
                    });
                });
            </script>
        </div>
    <?php endif; ?>

    <div class="row voucher-list" style="margin: 10px">
        <div class="modal-header">
            <div class="page-title col-md-12"><?php echo $this->lang->line('gkpos_system_spacial') ?></div>
        </div>
        <div class="clearfix"></div>
        <table class="table table-responsive table-bordered fieldset">
            <tr>
                <th class="text-center text-uppercase"><?php echo $this->lang->line('gkpos_system_spacial_title') ?></th> 
                <th class="text-center text-uppercase"><?php echo $this->lang->line('gkpos_status') ?></th> 
                <?php if ($this->session->userdata('gkpos_usertype') == 1 || $this->session->userdata('gkpos_usertype') == 2): ?>
                    <th class="text-center text-uppercase"><?php echo $this->lang->line('gkpos_action') ?></th> 
                <?php endif; ?>
            </tr>
            <?php if (!empty($voucher_list)): ?>
                <?php foreach ($voucher_list as $voucher): ?> 
                    <tr>
                        <td class="text-center"><?php echo $voucher->title ?></td> 
                        <td class="text-center"><?php $voucher->status == 1 ? print "Active" : print "Inactive" ?></td> 
                        <?php if ($this->session->userdata('gkpos_usertype') == 1 || $this->session->userdata('gkpos_usertype') == 2): ?>
                            <td class="text-center">
                                <a href='javascript:void(0)' onclick="updateSpecial('<?php echo $voucher->id ?>', '<?php echo site_url('gkpos/settings/update_special') ?>', '<?php $voucher->status == 1 ? print'deactivate' : print 'activate' ?>')"><?php $voucher->status == 1 ? print'Deactivate' : print 'Activate' ?> </a>
                                |
                                <a href='javascript:void(0)' onclick="updateSpecial('<?php echo $voucher->id ?>', '<?php echo site_url('gkpos/settings/update_special') ?>', 'delete')">Delete</a> 
                            </td> 
                        <?php endif; ?>
                    </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td colspan="4">No Special modifier found</td> 
                </tr>
            <?php endif; ?>
        </table>                        
    </div>
</div>
<script>
    function updateSpecial(voucher_id, url, action) {
        $.ajax({
            url: url,
            data: {
                id: voucher_id,
                action: action
            },
            dataType: 'json',
            type: "POST",
            success: function (output) {
                if (output.success) {
                    getSettingPage('<?php echo site_url("gkpos/settings/special") ?>', 'Special');
                } else {
                    set_feedback(output.message, 'alert alert-dismissible alert-danger', false);
                }

            },
        });
    }
    $(document).ready(function () {
        if ($('#showHideAddSpecial').is(":checked")) {
            $('#AddNewSpecialBox').show();
        } else {
            $('#AddNewSpecialBox').hide();
        }
    });
</script>