<?php $__env->startSection('content'); ?>

<div class="card">
    <div class="card-header">
        <?php echo e(trans('global.create')); ?> <?php echo e(trans('cruds.amcContract.title_singular')); ?>

    </div>

    <div class="card-body">
        <form method="POST" action="<?php echo e(route("admin.amc-contracts.store")); ?>" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="form-group">
                <label class="required" for="client_id"><?php echo e(trans('cruds.amcContract.fields.client')); ?></label>
                <select class="form-control select2 <?php echo e($errors->has('client') ? 'is-invalid' : ''); ?>" name="client_id" id="client_id" required>
                    <?php $__currentLoopData = $clients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($id); ?>" <?php echo e(old('client_id') == $id ? 'selected' : ''); ?>><?php echo e($entry); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php if($errors->has('client')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('client')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.client_helper')); ?></span>
            </div>
            <div class="form-group">
                <label class="required" for="assets"><?php echo e(trans('cruds.amcContract.fields.asset')); ?></label>
                <div style="padding-bottom: 4px">
                    <span class="btn btn-info btn-xs select-all" style="border-radius: 0"><?php echo e(trans('global.select_all')); ?></span>
                    <span class="btn btn-info btn-xs deselect-all" style="border-radius: 0"><?php echo e(trans('global.deselect_all')); ?></span>
                </div>
                <select class="form-control select2 <?php echo e($errors->has('assets') ? 'is-invalid' : ''); ?>" name="assets[]" id="assets" multiple required>
                    <?php $__currentLoopData = $assets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $asset): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($id); ?>" <?php echo e(in_array($id, old('assets', [])) ? 'selected' : ''); ?>><?php echo e($asset); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php if($errors->has('assets')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('assets')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.asset_helper')); ?></span>
            </div>
            <div class="form-group">
                <label class="required" for="amc_start_date"><?php echo e(trans('cruds.amcContract.fields.amc_start_date')); ?></label>
                <input class="form-control date <?php echo e($errors->has('amc_start_date') ? 'is-invalid' : ''); ?>" type="text" name="amc_start_date" id="amc_start_date" value="<?php echo e(old('amc_start_date')); ?>" required>
                <?php if($errors->has('amc_start_date')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('amc_start_date')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.amc_start_date_helper')); ?></span>
            </div>
            <div class="form-group">
                <label class="required" for="amc_expiry_date"><?php echo e(trans('cruds.amcContract.fields.amc_expiry_date')); ?></label>
                <input class="form-control date <?php echo e($errors->has('amc_expiry_date') ? 'is-invalid' : ''); ?>" type="text" name="amc_expiry_date" id="amc_expiry_date" value="<?php echo e(old('amc_expiry_date')); ?>" required>
                <?php if($errors->has('amc_expiry_date')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('amc_expiry_date')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.amc_expiry_date_helper')); ?></span>
            </div>
            <div class="form-group">
                <label for="amc_document"><?php echo e(trans('cruds.amcContract.fields.amc_document')); ?></label>
                <div class="needsclick dropzone <?php echo e($errors->has('amc_document') ? 'is-invalid' : ''); ?>" id="amc_document-dropzone">
                </div>
                <?php if($errors->has('amc_document')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('amc_document')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.amc_document_helper')); ?></span>
            </div>
            <div class="form-group">
                <label for="assigned_team_id"><?php echo e(trans('cruds.amcContract.fields.assigned_team')); ?></label>
                <select class="form-control select2 <?php echo e($errors->has('assigned_team') ? 'is-invalid' : ''); ?>" name="assigned_team_id" id="assigned_team_id">
                    <?php $__currentLoopData = $assigned_teams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($id); ?>" <?php echo e(old('assigned_team_id') == $id ? 'selected' : ''); ?>><?php echo e($entry); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <?php if($errors->has('assigned_team')): ?>
                    <div class="invalid-feedback">
                        <?php echo e($errors->first('assigned_team')); ?>

                    </div>
                <?php endif; ?>
                <span class="help-block"><?php echo e(trans('cruds.amcContract.fields.assigned_team_helper')); ?></span>
            </div>
            <div class="form-group">
                <button class="btn btn-danger" type="submit">
                    <?php echo e(trans('global.save')); ?>

                </button>
            </div>
        </form>
    </div>
</div>



<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
    Dropzone.options.amcDocumentDropzone = {
    url: '<?php echo e(route('admin.amc-contracts.storeMedia')); ?>',
    maxFilesize: 100, // MB
    maxFiles: 1,
    addRemoveLinks: true,
    headers: {
      'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>"
    },
    params: {
      size: 100
    },
    success: function (file, response) {
      $('form').find('input[name="amc_document"]').remove()
      $('form').append('<input type="hidden" name="amc_document" value="' + response.name + '">')
    },
    removedfile: function (file) {
      file.previewElement.remove()
      if (file.status !== 'error') {
        $('form').find('input[name="amc_document"]').remove()
        this.options.maxFiles = this.options.maxFiles + 1
      }
    },
    init: function () {
<?php if(isset($amcContract) && $amcContract->amc_document): ?>
      var file = <?php echo json_encode($amcContract->amc_document); ?>

          this.options.addedfile.call(this, file)
      file.previewElement.classList.add('dz-complete')
      $('form').append('<input type="hidden" name="amc_document" value="' + file.file_name + '">')
      this.options.maxFiles = this.options.maxFiles - 1
<?php endif; ?>
    },
     error: function (file, response) {
         if ($.type(response) === 'string') {
             var message = response //dropzone sends it's own error messages in string
         } else {
             var message = response.errors.file
         }
         file.previewElement.classList.add('dz-error')
         _ref = file.previewElement.querySelectorAll('[data-dz-errormessage]')
         _results = []
         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
             node = _ref[_i]
             _results.push(node.textContent = message)
         }

         return _results
     }
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/newrhytha2/public_html/sfm.fusionengg.in/resources/views/admin/amcContracts/create.blade.php ENDPATH**/ ?>