104 lines
5.3 KiB
PHP
104 lines
5.3 KiB
PHP
@extends('layouts.app')
|
|
@section('title', __('supplychain::lang.create_rfq'))
|
|
@section('content')
|
|
@include('supplychain::layouts.nav')
|
|
<section class="content-header">
|
|
<h1>@lang('supplychain::lang.create_rfq')</h1>
|
|
</section>
|
|
<section class="content">
|
|
<div class="box box-primary">
|
|
{!! Form::open(['url' => action([\Modules\SupplyChain\Http\Controllers\RfqController::class, 'store']), 'method' => 'post', 'id' => 'sc_rfq_form']) !!}
|
|
<div class="box-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
{!! Form::label('title', __('supplychain::lang.title').':') !!}
|
|
{!! Form::text('title', null, ['class' => 'form-control', 'required']) !!}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
{!! Form::label('due_date', __('supplychain::lang.due_date').':') !!}
|
|
{!! Form::date('due_date', null, ['class' => 'form-control']) !!}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
{!! Form::label('status', __('supplychain::lang.status').':') !!}
|
|
{!! Form::select('status', ['draft' => __('supplychain::lang.rfq_status_draft'), 'open' => __('supplychain::lang.rfq_status_open')], 'draft', ['class' => 'form-control']) !!}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
{!! Form::label('supplier_ids', __('supplychain::lang.invite_suppliers').':') !!}
|
|
{!! Form::select('supplier_ids[]', $suppliers, null, ['class' => 'form-control select2', 'multiple', 'placeholder' => __('messages.please_select')]) !!}
|
|
</div>
|
|
<div class="form-group">
|
|
{!! Form::label('notes', __('supplychain::lang.notes').':') !!}
|
|
{!! Form::textarea('notes', null, ['class' => 'form-control', 'rows' => 2]) !!}
|
|
</div>
|
|
|
|
<hr>
|
|
<h4>@lang('supplychain::lang.lines')</h4>
|
|
<table class="table table-bordered" id="sc_rfq_lines_table">
|
|
<thead>
|
|
<tr>
|
|
<th>@lang('supplychain::lang.product')</th>
|
|
<th>@lang('supplychain::lang.variation')</th>
|
|
<th>@lang('supplychain::lang.qty')</th>
|
|
<th>@lang('supplychain::lang.specs')</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr class="sc-rfq-line-row">
|
|
<td>{!! Form::select('lines[0][product_id]', $products, null, ['class' => 'form-control select2', 'required']) !!}</td>
|
|
<td>{!! Form::number('lines[0][variation_id]', null, ['class' => 'form-control', 'placeholder' => 'Optional']) !!}</td>
|
|
<td>{!! Form::number('lines[0][qty]', 1, ['class' => 'form-control', 'required', 'min' => '0.0001', 'step' => 'any']) !!}</td>
|
|
<td>{!! Form::text('lines[0][specs]', null, ['class' => 'form-control']) !!}</td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<button type="button" class="btn btn-default btn-sm" id="sc_add_line"><i class="fa fa-plus"></i> @lang('supplychain::lang.add_line')</button>
|
|
</div>
|
|
<div class="box-footer">
|
|
<button type="submit" class="btn btn-primary">@lang('messages.save')</button>
|
|
<a href="{{ action([\Modules\SupplyChain\Http\Controllers\RfqController::class, 'index']) }}" class="btn btn-default">@lang('messages.cancel')</a>
|
|
</div>
|
|
{!! Form::close() !!}
|
|
</div>
|
|
</section>
|
|
@endsection
|
|
|
|
@section('javascript')
|
|
<script>
|
|
$(function() {
|
|
var lineIndex = 1;
|
|
var productOptions = @json(collect($products)->map(fn($name, $id) => ['id' => $id, 'text' => $name])->values());
|
|
|
|
$('#sc_add_line').on('click', function() {
|
|
var optionsHtml = '<option value="">@lang('messages.please_select')</option>';
|
|
productOptions.forEach(function(p) {
|
|
optionsHtml += '<option value="' + p.id + '">' + p.text + '</option>';
|
|
});
|
|
var row = '<tr class="sc-rfq-line-row">' +
|
|
'<td><select name="lines[' + lineIndex + '][product_id]" class="form-control" required>' + optionsHtml + '</select></td>' +
|
|
'<td><input type="number" name="lines[' + lineIndex + '][variation_id]" class="form-control" placeholder="Optional"></td>' +
|
|
'<td><input type="number" name="lines[' + lineIndex + '][qty]" class="form-control" value="1" required min="0.0001" step="any"></td>' +
|
|
'<td><input type="text" name="lines[' + lineIndex + '][specs]" class="form-control"></td>' +
|
|
'<td><button type="button" class="btn btn-xs btn-danger sc-remove-line"><i class="fa fa-trash"></i></button></td>' +
|
|
'</tr>';
|
|
$('#sc_rfq_lines_table tbody').append(row);
|
|
lineIndex++;
|
|
});
|
|
|
|
$(document).on('click', '.sc-remove-line', function() {
|
|
if ($('#sc_rfq_lines_table tbody tr').length > 1) {
|
|
$(this).closest('tr').remove();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|