<style>

</style>
<?php $__env->startSection('content'); ?>
    <?php if(count($errors) > 0): ?>
        <div class="alert alert-danger">
            <button aria-label="Close" class="close" data-dismiss="alert" type="button">
                <span aria-hidden="true">&times;</span>
            </button>
            <strong>الاخطاء :</strong>
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>

    <div class="row">
        <div class="col-md-12">
            <div class="card mg-b-20">
                <div class="card-body">
                    <div class="col-12">
                        <a class="btn btn-primary btn-sm pull-left" href="<?php echo e(route('admin.subscriptions.index')); ?>">
                            عودة
                            للخلف</a>
                        <h5 style="min-width: 300px;" class="pull-right alert alert-sm alert-success">
                            إضافة إشتراك جديد لشركة
                        </h5>
                    </div>
                    <div class="clearfix"></div>
                    <br>

                    <form class="parsley-style-1" id="selectForm2" name="selectForm2"
                          action="<?php echo e(route('subscriptions.add.post')); ?>"
                          enctype="multipart/form-data"
                          method="post">
                        <?php echo csrf_field(); ?>
                        <h5 class="col-lg-12 d-block mb-2">البيانات الاساسية</h5>
                        <hr>
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label> الشركة <span class="text-danger">*</span></label>
                                <select class="form-control" name="company_id" id=""  required>
                                    <option value="">اختر الشركة</option>
                                    <?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $company): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($company->id); ?>"><?php echo e($company->company_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-6">
                                <label> الباقة  <span class="text-danger">*</span></label>
                                <select class="form-control" name="package_id" id="package_id"  required>
                                    <option value="">اختر الباقة </option>
                                    <?php $__currentLoopData = $packages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $package): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($package->id); ?>"><?php echo e($package->package_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                        </div>

                        <div class="row mb-3">

                            <div class="col-md-6">
                                <label> نوع الاشتراك <span class="text-danger">*</span></label>
                                <select class="form-control" name="type_id" id="type_id" required>
                                    <option value="">اختر الباقة </option>

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

                        <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                            <button class="btn btn-info pd-x-20" type="submit">تحديث</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script>
    $(document).ready(function () {


        $('#package_id').on('change', function () {
            var package_id = $(this).val();
            if (package_id) {
                $.ajax({
                    url: "<?php echo e(URL::to('admin/get/package-types')); ?>/" + package_id,
                    type: "GET",
                    dataType: "json",
                    success: function (data) {
                        $('#type_id').empty();
                        $.each(data, function (key, value) {
                            $('#type_id').append('<option value="' + value.id + '">' + value.type_name + '</option>');
                        });
                    },
                });
            } else {
                console.log('AJAX load did not work');
            }
        });


    });
    </script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app-main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/barasys/public_html/resources/views/admin/subscriptions/add_subscription_for_company.blade.php ENDPATH**/ ?>