<?php echo $__env->make("messages", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
$required = "";
$types = Config::get('params.packages_types');
$currency = Config::get('params.currency');
$size = Config::get('params.best_boiler_image_size');

$action = "packages";
?>

<div class="row">
    <ul id="tabsJustified" class="nav nav-tabs">
        <li class="nav-item"><a href="#_" data-target="#information" data-toggle="tab" class="nav-link small text-uppercase active">Information</a></li>
        <li class="nav-item"><a href="#_" data-target="#prices" data-toggle="tab" class="nav-link small text-uppercase ">Prices</a></li>
        <li class="nav-item"><a href="#_" data-target="#facilities" data-toggle="tab" class="nav-link small text-uppercase ">What Covered</a></li>
        <li class="nav-item"><a href="#_" data-target="#meta" data-toggle="tab" class="nav-link small text-uppercase ">Meta</a></li>
        <li class="nav-item"><a href="#_" data-target="#not-covered" data-toggle="tab" class="nav-link small text-uppercase ">Not Covered</a></li>
        <li class="nav-item"><a href="#_" data-target="#download" data-toggle="tab" class="nav-link small text-uppercase ">Download</a></li>
        <li class="nav-item"><a href="#_" data-target="#faqs" data-toggle="tab" class="nav-link small text-uppercase ">Faqs</a></li>
        <li class="nav-item"><a href="#_" data-target="#extra" data-toggle="tab" class="nav-link small text-uppercase ">Extra</a></li>
    </ul>
</div>

<div id="tabsJustifiedContent" class="tab-content">
    <div id="information" class="tab-pane fade active show">
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <?php echo Form::label('Title'); ?>

                    <?php echo Form::text('title', null , array('class' => 'form-control',$required) ); ?>

                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <?php echo Form::label('Categories'); ?>

                    <?php echo Form::select('category_id', $categories,null,['class' => 'form-control','name'=>'category_id',$required]); ?>

                </div>
            </div>

            <div class="col-sm-12">
                <div class="form-group">
                    <?php echo Form::label('tagline'); ?>

                    <?php echo Form::text('tagline', null , array('class' => 'form-control',$required) ); ?>

                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group">
                    <?php echo Form::label('tagline 2'); ?>

                    <?php echo Form::text('tagline2', null , array('class' => 'form-control',$required) ); ?>

                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group">
                    <?php echo Form::label('URL'); ?>

                    <?php echo Form::text('url', null , array('class' => 'form-control',$required) ); ?>

                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group">
                    <?php echo Form::label('shortDescription'); ?>

                    <?php echo Form::textarea('shortDescription', null, ['class'=>'form-control ckeditor','id'=>'shortDescription', 'rows' => 1, 'cols' => 3, 'style' => '']); ?>

                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group">
                    <?php echo Form::label('description'); ?>

                    <?php echo Form::textarea('description', null, ['class'=>'form-control ckeditor','id'=>'description', 'rows' => 3, 'cols' => 3, 'style' => '']); ?>

                </div>
            </div>

            <div class="col-sm-4">
                <div class="form-group">
                    <?php echo Form::label('position'); ?>

                    <?php echo Form::text('position', null , array('class' => 'form-control',$required) ); ?>

                </div>
            </div>
            <div class="col-sm-4">
                <div class="d-flex justify-content-start flex-wrap">
                    <div class="custom-control custom-switch custom-switch-success mr-2 mb-1">
                        <p class="mb-0">Popular</p>
                        <input type="checkbox" 
                               <?php if(isset($model->popular) && $model->popular==1): ?>
                               checked 
                               <?php endif; ?>
                               class="custom-control-input" name="popular" id="popular" value="1">
                               <label class="custom-control-label" for="popular"></label>
                    </div>
                </div>
            </div>

            <div class="col-sm-4">
                <div class="d-flex justify-content-start flex-wrap">
                    <div class="custom-control custom-switch custom-switch-success mr-2 mb-1">
                        <p class="mb-0">Status</p>
                        <input type="checkbox" 
                               <?php if(isset($model->status) && $model->status==1): ?>
                               checked 
                               <?php endif; ?>
                               class="custom-control-input" name="status" id="status" value="1">
                               <label class="custom-control-label" for="status"></label>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">

            <div class="col-sm-12">
                <div class="row form-group">
                    <label class="col-xl-2 col-lg-2 col-form-label"> Image</label>
                    <div class="col-lg-6 col-xl-6">
                        <input   value="<?php echo isset($model->image) ? $model->image : ""; ?>"  placeholder="Upload Image" id="image" name="image" type="text" class="form-control "  readonly="">
                        <br clear="all"/>
                        Best Image Size(<?php echo $size; ?>)
                    </div>
                    <div class="col-lg-2 col-xl-2">
                        <button type="button" class="btn btn-warning btn-label-brand btn-md mediaModel" data-toggle="modal" data-target="#media-model" data-control="image">Browse</button>
                    </div>
                    <div class="col-lg-1 col-xl-1 ">

                        <p id="removeImage" class="btn btn-outline-warning mr-1 mb-1 waves-effect waves-light float-right">Remove</p>

                    </div>
                </div>
            </div>   
        </div>
    </div>

    <div id="prices" class="tab-pane fade">

        <div class="row">
            <div class="col-md-8">


                <?php
                foreach ($types as $key => $type) {
                    ?>

                    <h3><?php echo $type ?></h3>
                    <table cellspacing="0" class="table" id="media_gallery_content_grid" width="80%">
                        <thead>
                            <tr class="headings">
                                <th>Excess</th>
                                <th>Price(<?php echo $currency["symbol"] ?>)</th>
                                <th>VAT(%)</th>
                                <th>Total</th>
                            </tr>
                        </thead>
                        <tbody id="media_gallery_content_list">
                            <?php foreach ($excesses as $excess) { ?>

                                <tr class="body">
                                    <td><?php echo $excess->title ?></td>
                                    <td><input type="text" class="form-control" name="prices[<?php echo $key ?>][<?php echo $excess->id ?>][price]" value="<?php
                                        echo
                                        isset($prices[$key][$excess->id]["price"]) ? $prices[$key][$excess->id]["price"] : null
                                        ?>"></td>
                                    <td><input type="text" class="form-control" name="prices[<?php echo $key ?>][<?php echo $excess->id ?>][vat]" value="<?php
                                        echo
                                        isset($prices[$key][$excess->id]["price"]) ? $prices[$key][$excess->id]["vat"] : 20
                                        ?>"></td>
                                    <td>
                                        <?php if (isset($prices[$key][$excess->id]["price"]) && isset($prices[$key][$excess->id]["vat"])) { ?>

                                            <?php echo $currency["symbol"] ?> <?php
                                            $add = $prices[$key][$excess->id]["price"] * ($prices[$key][$excess->id]["vat"] / 100);
                                            $total = $prices[$key][$excess->id]["price"] + $add;
                                            echo numberformat($total, 2);
                                            ?>

                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                <?php } ?>


            </div>
        </div>


    </div>

    <div id="facilities" class="tab-pane fade">

        <div class="row">
            <div class="col-md-12">

                <table cellspacing="0" class="table" id="media_gallery_content_grid" width="80%">
                    <thead>
                        <tr class="headings">
                            <th>Facilities</th>
                            <th>Effect on price</th>
                            <th>Price(<?php echo $currency["symbol"] ?>)</th>
                        </tr>
                    </thead>
                    <tbody id="media_gallery_content_list">
                        <?php
                        foreach ($facilities as $facility) {
                            $checked = "";
                            $priceChecked = "";
                            if (key_exists($facility->id, $packageFacilities)) {
                                $hasPrice = $packageFacilities[$facility->id]["has_price"];
                                $checked = "checked=checked";
                                if ($hasPrice == 1) {
                                    $priceChecked = "checked=checked";
                                }
                                $price = $packageFacilities[$facility->id]["price"];
                            } else {
                                $hasPrice = 0;
                                $price = null;
                            }
                            ?>
                            <tr class="body">
                                <td>
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" name="facilities[<?php echo e($facility->id); ?>][available]" class="custom-control-input facilities" id="facilities_<?php echo e($facility->id); ?>" value="<?php echo e($facility->id); ?>" <?php echo e($checked); ?>  >
                                        <label class="custom-control-label" for="facilities_<?php echo e($facility->id); ?>"><?php echo e($facility->title); ?></label>
                                    </div>
                                </td>
                                <td>
                                    <div class="custom-control custom-checkbox">
                                        <input type="checkbox" name="facilities[<?php echo e($facility->id); ?>][has_price]" class="custom-control-input has-price" id="facilities_has_price_<?php echo e($facility->id); ?>"  value="1" <?php echo e($priceChecked); ?> >
                                        <label class="custom-control-label" for="facilities_has_price_<?php echo e($facility->id); ?>">Effect on price</label>
                                    </div>
                                </td>
                                <td>
                                    <label class="form-control-label" for="facilities_price_<?php echo e($facility->id); ?>">Price</label>
                                    <input type="text" name="facilities[<?php echo e($facility->id); ?>][price]" class="form-control-input price" id="facilities_price_<?php echo e($facility->id); ?>" value="<?php echo $price; ?>" >
                                </td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>


    <div id="meta" class="tab-pane fade">

        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('metaTitle'); ?>

                <?php echo Form::text('metaTitle', null , array('class' => 'form-control',$required) ); ?>

            </div>
        </div>
        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('metaDescription'); ?>

                <?php echo Form::textarea('metaDescription', null , array('class' => 'form-control','rows' => 3, 'cols' => 3, 'style' => '',$required) ); ?>

            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <?php echo Form::label('keywords'); ?>

                <?php echo Form::text('keywords', null , array('class' => 'form-control',$required) ); ?>

            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <?php echo Form::label('tags'); ?>

                <?php echo Form::text('tags', null , array('class' => 'form-control',$required) ); ?>

            </div>
        </div>

    </div>

    <div id="not-covered" class="tab-pane fade">
        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('not Covered Title'); ?>

                <?php echo Form::text('notCoveredTitle', null , array('class' => 'form-control',$required) ); ?>

            </div>
        </div>
        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('not Covered Text'); ?>

                <?php echo Form::textarea('notCoveredText', null , array('id' => 'notCoveredText','class' => 'form-control ckeditor','rows' => 3, 'cols' => 3, 'style' => '',$required) ); ?>

            </div>
        </div>

    </div>
    <div id="download" class="tab-pane fade">
        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('File Download Text'); ?>

                <?php echo Form::text('fileDownloadText', null , array('class' => 'form-control',$required) ); ?>

            </div>
        </div>

        <?php if($model->file): ?>
        <div class="col-sm-6">
            <a class="btn btn-success mr-1 mb-1 waves-effect waves-light" href="<?php echo e(url("/")); ?>/<?php echo Config("params.dir_packages_downloads"); ?>/<?php echo $model->file; ?>" target="_blank">Download</a>
        </div>
        <?php endif; ?>
        <div class="col-sm-6">
            <div class="form-group">
                <?php echo Form::label('file'); ?>

                <?php echo Form::file('file', null,array('class'=>'form-control')); ?>

                <br clear="all"/>
                Only .pdf is allowed
            </div>
        </div>

    </div>
    <div id="extra" class="tab-pane fade">


        <div class="col-sm-12">
            <div class="form-group">
                <?php echo Form::label('Review text'); ?>

                <?php echo Form::textarea('reviews', null , array('id' => 'reviews','class' => 'form-control ckeditor','rows' => 3, 'cols' => 3, 'style' => '',$required) ); ?>

            </div>
        </div>
    </div>

    <div id="faqs" class="tab-pane fade">
        <?php echo $__env->make("admin.common.faqs_form", \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    </div>

    <br clear="all" />


    <div class="row">
        <div class="col-md-6">
            <?php echo Form::hidden('_token', csrf_token(),array("id"=>"_token")); ?>

            <button type="button" class="btn btn-primary mr-1 mb-1 waves-effect waves-light save">Save</button>
            <a href="<?php echo e(url('admin/')); ?>/<?php echo e($action); ?>" class="btn btn-outline-warning mr-1 mb-1 waves-effect waves-light">Cancel</a>
        </div>
    </div>

</div>


<?php echo $__env->make('vendor_script', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->startSection('myscript'); ?>

<script>
    $(document).ready(function () {

        CKEDITOR.config.allowedContent = true;
        CKEDITOR.replace("ckeditor", {filebrowserImageBrowseUrl: '/file-manager/ckeditor',
        });

    });
        $( "#removeImage" ).click(function() {
            $("#image").val(" ");
            
          });

    $(".save").click(function () {

        var url = $("#form").attr('action');

        var type = "POST";
        var dataType = "json";
        var data = new FormData($('#form')[0]);
        data.append('description', CKEDITOR.instances['description'].getData());
        data.append('shortDescription', CKEDITOR.instances['shortDescription'].getData());
        data.append('notCoveredText', CKEDITOR.instances['notCoveredText'].getData());
        data.append('reviews', CKEDITOR.instances['reviews'].getData());

        var callBack = function (response) {
            if (response.error === 1) {
                displayErrors(response, "errors");
            } else
            {
                window.top.location.href = "<?php echo url("admin/$action") ?>";
            }
        };

        var errorCallBack = function (response) {
            alertMessage('success');
        };

        ajaxRequest(url, type, dataType, data, callBack, errorCallBack);

    });

</script>

<?php $__env->stopSection(); ?><?php /**PATH /home/seolocaj/public_html/homefloltd/resources/views/admin/packages/form.blade.php ENDPATH**/ ?>