<?php echo $header; ?><?php echo $column_left; ?>
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
            <div class="pull-right">
                <button type="submit" form="form-special" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
                <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
            <h1><?php echo $heading_title; ?></h1>

        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_form; ?></h3>
        </div>
        <div class="panel-body">
            <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-special" class="form-horizontal">
                <div class="container-fluid">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $tab_option_special; ?></a></li>
                    </ul>
                    <div class="tab-pane" id="tab-data">
                        <table id="option_special" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <td class="text-center">Группа гостей</td>
                                <td class="text-center">Приоритет</td>
                                <td class="text-center">Процент</td>
                                <td class="text-center">Дата начала</td>
                                <td class="text-center">Дата окончания</td>
                                <td class="text-center">пн</td>
                                <td class="text-center">вт</td>
                                <td class="text-center">ср</td>
                                <td class="text-center">чт</td>
                                <td class="text-center">пт</td>
                                <td class="text-center">сб</td>
                                <td class="text-center">вс</td>
                                <td class="text-center"></td>
                            </tr>
                            </thead>
                            <tbody>
                            <?php $special_row = 0; ?>
                            <?php foreach ($product_option_special_info as $option_special) {?>
                                <tr id="option-value-row<?php echo $special_row; ?>">
                                    <td class="text-center">
                                        <select  name="option_special[<?php echo $special_row; ?>][customer_group_id]" class="form-control">
                                        <?php foreach ($customer_groups as $customer_group) { ?>
                                            <?php if ($customer_group['customer_group_id'] == $option_special['customer_group_id']) { ?>
                                                <option value="<?php echo $customer_group['customer_group_id']; ?>" selected="selected"><?php echo $customer_group['name']; ?></option>
                                            <?php } else { ?>
                                                <option value="<?php echo $customer_group['customer_group_id']; ?>"><?php echo $customer_group['name']; ?></option>
                                            <?php } ?>
                                        <?php } ?>
                                        </select></td>
                                    <td class="text-center">
                                        <input type="text" name="option_special[<?php echo $special_row; ?>][priority]" value="<?php echo $option_special['priority']; ?>" placeholder="<?php echo $entry_priority; ?>"  class="form-control" />
                                    </td>
                                    <td class="text-center"><input type="text" name="option_special[<?php echo $special_row; ?>][percent]" value="<?php echo $option_special['percent']; ?>" placeholder="<?php echo $entry_percent; ?>"  class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <div class="input-group date">
                                            <input type="text" name="option_special[<?php echo $special_row; ?>][date_start]" value="<?php echo $option_special['date_start']; ?>" placeholder="<?php echo $entry_date_start; ?>" data-date-format="YYYY-MM-DD" class="form-control" />
                                            <span class="input-group-btn">
                                            <button class="btn btn-default" type="button">
                                                <i class="fa fa-calendar"></i>
                                            </button>
                                         </span>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <div class="input-group date">
                                            <input type="text" name="option_special[<?php echo $special_row; ?>][date_end]" value="<?php echo $option_special['date_end']; ?>" placeholder="<?php echo $entry_date_end; ?>" data-date-format="YYYY-MM-DD" class="form-control" />
                                            <span class="input-group-btn">
                                          <button class="btn btn-default" type="button">
                                              <i class="fa fa-calendar"></i>
                                          </button>
                                        </span>
                                        </div>
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day1]" value="1" <?php if($option_special['disable_day1']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day2]" value="1" <?php if($option_special['disable_day2']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day3]" value="1" <?php if($option_special['disable_day3']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day4]" value="1" <?php if($option_special['disable_day4']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day5]" value="1" <?php if($option_special['disable_day5']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day6]" value="1" <?php if($option_special['disable_day6']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <input type="checkbox" name="option_special[<?php echo $special_row; ?>][disable_day7]" value="1" <?php if($option_special['disable_day7']){echo 'checked="checked"';} ?>" class="form-control" />
                                    </td>
                                    <td class="text-center">
                                        <button onclick="$('#option-value-row<?php echo $special_row; ?>').remove();" title="Удалить" class="btn btn-danger" data-original-title="Удалить"><i class="fa fa-minus-circle"></i></button>
                                    </td>
                                </tr>
                                <?php $special_row++; ?>
                            <?php } ?>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="12"></td>
                                <td class="text-center"><button type="button" onclick="addSpecial();" data-toggle="tooltip" title="<?php echo $button_special_add; ?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
                            </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <?php echo $footer; ?>
    <script>
        var special_row = <?php echo $special_row; ?>;

        function addSpecial() {
            html  = '<tr id="option-value-row'+special_row+'">';
            html += '  <td class="text-left"><select name="option_special[' + special_row + '][customer_group_id]" class="form-control">';
            <?php foreach ($customer_groups as $customer_group) { ?>
            html += '      <option value="<?php echo $customer_group['customer_group_id']; ?>"><?php echo addslashes($customer_group['name']); ?></option>';
            <?php } ?>
            html += '  </select></td>';
            html +='<td class="text-center"><input type="text" name="option_special[' + special_row + '][priority]" value="" placeholder="<?php echo $entry_priority ?>" class="form-control" /></td>';
            html +='<td class="text-center"><input type="text" name="option_special[' + special_row + '][percent]" value="" placeholder="<?php echo $entry_price; ?>" class="form-control" /></td>';
            html +='<td class="text-center"><div class="input-group date"><input type="text" name="option_special[' + special_row + '][date_start]" value="" placeholder="<?php echo $entry_date_start; ?>" data-date-format="YYYY-MM-DD" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div></td>';
            html +='<td class="text-center"><div class="input-group date"><input type="text" name="option_special[' + special_row + '][date_end]" value="" placeholder="<?php echo $entry_date_end; ?>" data-date-format="YYYY-MM-DD" class="form-control" /><span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span></div></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day1]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day2]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day3]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day4]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day5]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day6]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><input type="checkbox" name="option_special[' + special_row + '][disable_day7]" value="1" checked="checked" class="form-control" /></td>';
            html +='<td class="text-center"><button onclick="$(\'#option-value-row'+special_row+'\').remove();" title="Удалить" class="btn btn-danger" data-original-title="Удалить"><i class="fa fa-minus-circle"></i></button> </td>';

            html += '</tr>';

            $('#option_special tbody').append(html);

            $('.date').datetimepicker({
                pickTime: false
            });

            special_row++;
        }
        $(document).ready(function(){
            document.title = "Скидка опции";
        });



    </script>
