328 lines
22 KiB
PHP
328 lines
22 KiB
PHP
<?php
|
|
|
|
// echo "<pre>";
|
|
// print_r($fields);
|
|
// exit();
|
|
?>
|
|
|
|
@extends('layouts.vertical', ['page_title' => 'Add & Edit Products'])
|
|
|
|
@section('css')
|
|
<!-- third party css -->
|
|
<link href="{{ asset('assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />
|
|
<link href="{{ asset('assets/libs/multiselect/multiselect.min.css') }}" rel="stylesheet" type="text/css" />
|
|
<link href="{{ asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet"
|
|
type="text/css" />
|
|
<link href="{{ URL::asset('assets/libs/dropify/dropify.min.css') }}" rel="stylesheet" type="text/css" />
|
|
<!-- third party css end -->
|
|
@endsection
|
|
|
|
@section('content')
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
<!-- end page title -->
|
|
@if (session()->has('message'))
|
|
<div class="alert alert-success mt-3">
|
|
{{ session()->get('message') }}
|
|
</div>
|
|
@endif
|
|
<div class="row mt-3">
|
|
<div class="col-xl-12">
|
|
<div class="card">
|
|
<form method="post" id="form-availiblity" enctype="multipart/form-data">
|
|
@csrf
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<h4 class="page-title">Add / Edit {{ $title }}</h4>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<div class="float-end">
|
|
<a href="{{ $base_url }}s"
|
|
class="btn btn-dark waves-effect waves-light">Back</a>
|
|
<button type="submit"
|
|
class="btn btn-success waves-effect waves-light">Submit</button>
|
|
</div>
|
|
</div>
|
|
@foreach ($fields as $field => $props)
|
|
@if ($props['type'] != 'hidden')
|
|
<div class="col-md-{{ isset($props['fullwidth']) ? '12' : '6' }} mb-3">
|
|
<label for="field-{{ $field }}" class="form-label">{{ $props['title'] }}
|
|
{!! isset($props['required']) && $props['required'] ? '<span class="text-danger">*</span>' : '' !!} </label>
|
|
@endif
|
|
@switch($props['type'])
|
|
@case('hidden')
|
|
<input type="{{ $props['type'] }}" id="field-{{ $field }}"
|
|
name="{{ $field }}" value="{{ $mode == 'edit' ? $item->{$field} : '' }}">
|
|
@break
|
|
|
|
@case('text')
|
|
@case('email')
|
|
|
|
@case('number')
|
|
@case('tel')
|
|
<input type="{{ $props['type'] }}" id="field-{{ $field }}"
|
|
name="{{ $field }}" class="form-control"
|
|
placeholder="Enter {{ $props['title'] }}"
|
|
value="{{ $mode == 'edit' && isset($item->{$field})
|
|
? $item->{$field}
|
|
: (isset($item->credentials->{$field})
|
|
? $item->credentials->{$field}
|
|
: (isset($item->limits->limits->{$field})
|
|
? $item->limits->limits->{$field}
|
|
: '')) }}"
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
@break
|
|
|
|
@case('date')
|
|
<input type="text" id="field-{{ $field }}" name="{{ $field }}"
|
|
class="form-control" placeholder="Enter {{ $props['title'] }}"
|
|
value="{{ $mode == 'edit' && isset($item->{$field}) ? $item->{$field} : '' }}"
|
|
data-provide="datepicker" data-date-autoclose="true" data-date-format="mm/dd/yyyy"
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
@break
|
|
|
|
@case('textarea')
|
|
<textarea id="field-{{ $field }}" name="{{ $field }}" class="form-control"
|
|
placeholder="Enter {{ $props['title'] }}" {{ isset($props['required']) && $props['required'] ? 'required' : '' }}>{{ $mode == 'edit' ? $item->{$field} : '' }}</textarea>
|
|
@break
|
|
|
|
@case('select')
|
|
<select class="form-control" id="field-{{ $field }}" name="{{ $field }}"
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
<option value=""> -- Select {{ $props['title'] }} -- </option>
|
|
@foreach ($props['values'] as $k => $v)
|
|
<option value="{{ $k }}"
|
|
{{ $mode == 'edit' && isset($item->{$field}) && $item->{$field} == $k ? 'selected="selected"' : '' }}>
|
|
{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
|
|
@case('multiselect')
|
|
<select class="form-control select2-multiple" data-toggle="select2" data-width="100%"
|
|
multiple="multiple" data-placeholder="Choose {{ $props['title'] }}"
|
|
id="field-{{ $field }}" name="{{ $field }}[]"
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
<option value=""> -- Select {{ $props['title'] }} -- </option>
|
|
@foreach ($props['values'] as $k => $v)
|
|
<option value="{{ $k }}"
|
|
{{ $mode == 'edit' && isset($item->{$field}) && in_array($k, $item->{$field}) ? 'selected="selected"' : '' }}>
|
|
{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
|
|
@case('bigmultiselect')
|
|
<select multiple="multiple" class="bigmultiselect multi-select"
|
|
id="field-{{ $field }}" name="{{ $field }}[]"
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
@foreach ($props['values'] as $k => $v)
|
|
<option value="{{ $k }}"
|
|
{{ $mode == 'edit' && in_array($k, $item->{$field}) ? 'selected="selected"' : '' }}>
|
|
{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
@break
|
|
|
|
@case('yesno')
|
|
<div>
|
|
<div class="form-check mb-2 form-check-success form-check-inline">
|
|
<input class="form-check-input" type="radio" name="{{ $field }}"
|
|
id="field-{{ $field }}-yes" value="yes"
|
|
{{ $mode == 'edit' && $item->{$field} == 'yes' ? 'checked' : '' }}
|
|
{{ isset($props['required']) && $props['required'] ? 'required' : '' }}>
|
|
<label class="form-check-label" for="field-{{ $field }}-yes">Yes</label>
|
|
</div>
|
|
<div class="form-check mb-2 form-check-danger form-check-inline">
|
|
<input class="form-check-input" type="radio" name="{{ $field }}"
|
|
id="field-{{ $field }}-no" value="no"
|
|
{{ $mode == 'edit' && $item->{$field} == 'no' ? 'checked' : '' }}>
|
|
<label class="form-check-label" for="field-{{ $field }}-no">No</label>
|
|
</div>
|
|
</div>
|
|
@break
|
|
|
|
@case('image')
|
|
<div class="mt-3" id="file_wrapper">
|
|
<input type="file" name="{{ $field }}" class="dropify"
|
|
data-default-file="{{ $mode == 'edit' ? $item->{$field} : '' }}"
|
|
data-allowed-file-extensions="png jpg jpeg gif" />
|
|
<p class="text-muted text-center mt-2 mb-0">500MB Max File size</p>
|
|
</div>
|
|
@break
|
|
|
|
@case('file')
|
|
<div class="mt-3" id="file_wrapper">
|
|
<input type="file" name="{{ $field }}" class="dropify"
|
|
data-default-file="{{ $mode == 'edit' ? $item->{$field} : '' }}"
|
|
data-allowed-file-extensions="png jpg jpeg gif mp4 pdf mp3 zip" />
|
|
<p class="text-muted text-center mt-2 mb-0">1GB Max File size</p>
|
|
</div>
|
|
@break
|
|
|
|
@case('mapping')
|
|
<div><button type="button" class="btn btn-info btn-xs float-end"
|
|
id="btn-add-mapping">Add Participant</button></div>
|
|
<table class="table mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th>Type</th>
|
|
<th>Team (if team)</th>
|
|
<th>Position/Person (Emp or Pos Code)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@if ($mode == 'edit')
|
|
@foreach ($item->{$field} as $map)
|
|
<tr>
|
|
<td>
|
|
<select class="form-control" name="participants[type][]"
|
|
required>
|
|
<option value=""> -- Select Type -- </option>
|
|
@foreach ($props['types'] as $v)
|
|
<option value="{{ $v }}"
|
|
{{ $map->type == $v ? 'selected="selected"' : '' }}>
|
|
{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" name="participants[team][]">
|
|
<option value=""> -- Select Type -- </option>
|
|
@foreach ($props['teams'] as $k => $v)
|
|
<option value="{{ $k }}"
|
|
{{ $map->target == $k ? 'selected="selected"' : '' }}>
|
|
{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
</td>
|
|
<td><input type="text" name="participants[person][]"
|
|
class="form-control"
|
|
value="{{ $map->type != 'Team' ? $map->target : '' }}">
|
|
</td>
|
|
<th><button type="button"
|
|
class="btn btn-danger waves-effect waves-light btn-remove"><i
|
|
class="mdi mdi-close"></i></button></th>
|
|
</tr>
|
|
@endforeach
|
|
@else
|
|
<tr>
|
|
<td>
|
|
<select class="form-control" name="participants[type][]" required>
|
|
<option value=""> -- Select Type -- </option>
|
|
@foreach ($props['types'] as $v)
|
|
<option value="{{ $v }}">{{ $v }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" name="participants[team][]">
|
|
<option value=""> -- Select Type -- </option>
|
|
@foreach ($props['teams'] as $k => $v)
|
|
<option value="{{ $k }}">{{ $v }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</td>
|
|
<td><input type="text" name="participants[person][]"
|
|
class="form-control" value=""></td>
|
|
<th><button type="button"
|
|
class="btn btn-danger waves-effect waves-light btn-remove"><i
|
|
class="mdi mdi-close"></i></button></th>
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
@break
|
|
@endswitch
|
|
@if ($props['type'] != 'hidden')
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
|
|
<div class="col-md-12 mb-3">
|
|
<div class="float-end">
|
|
<a href="{{ $base_url }}s" class="btn btn-dark waves-effect waves-light">Back</a>
|
|
<button type="submit"
|
|
class="btn btn-success waves-effect waves-light">Submit</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> <!-- end card-body -->
|
|
</form>
|
|
</div> <!-- end card-->
|
|
</div> <!-- end col -->
|
|
</div>
|
|
</div>
|
|
<style type="text/css">
|
|
.ms-container {
|
|
max-width: 100%
|
|
}
|
|
|
|
.dropify-wrapper .dropify-message span.file-icon {
|
|
font-size: 20px;
|
|
color: #CCC;
|
|
}
|
|
</style>
|
|
@endsection
|
|
|
|
@section('script')
|
|
<script src="{{ asset('assets/libs/select2/select2.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/multiselect/multiselect.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
|
|
<script src="{{ URL::asset('assets/libs/dropify/dropify.min.js') }}"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('[data-toggle="select2"]').select2();
|
|
$('.dropify').dropify({
|
|
messages: {
|
|
'default': 'Drag and drop a file here or click',
|
|
'replace': 'Drag and drop or click to replace',
|
|
'remove': 'Remove',
|
|
'error': 'Ooops, something wrong appended.'
|
|
},
|
|
error: {
|
|
'fileSize': 'The file size is too big (500MB max).'
|
|
}
|
|
});
|
|
|
|
@if (isset($fields['participants']))
|
|
$('#btn-add-mapping').click(function() {
|
|
$('table tbody').append(`<tr>
|
|
<td>
|
|
<select class="form-control" name="participants[type][]" required>
|
|
<option value=""> -- Select Type -- </option>
|
|
<option value="Team"> Team </option>
|
|
<option value="Position"> Position </option>
|
|
<option value="User"> User </option>
|
|
</select>
|
|
</td>
|
|
<td>
|
|
<select class="form-control" name="participants[team][]">
|
|
<option value=""> -- Select Type -- </option>
|
|
@foreach ($fields['participants']['teams'] as $k => $v)
|
|
<option value="{{ $k }}">{{ $v }}</option>
|
|
@endforeach
|
|
</select>
|
|
</td>
|
|
<td><input type="text" name="participants[person][]" class="form-control" value=""></td>
|
|
<th><button type="button" class="btn btn-danger waves-effect waves-light btn-remove"><i class="mdi mdi-close"></i></button></th>
|
|
</tr>`);
|
|
|
|
$('.btn-remove').unbind();
|
|
$('.btn-remove').click(function() {
|
|
$(this).parent().parent().remove();
|
|
});
|
|
$('.cust-date').unbind();
|
|
$('.cust-date').flatpickr();
|
|
});
|
|
$('.btn-remove').click(function() {
|
|
$(this).parent().parent().remove();
|
|
});
|
|
@endif
|
|
});
|
|
</script>
|
|
@endsection
|