IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>@if(isset($quotation))Edit @else Add @endif Quotation</strong></h2>
</div>
<div class="body">
@if(isset($quotation))
{!! Form::model($quotation, ['method' => 'PATCH', 'action' => ['School\Stock\QuotationController@update', $quotation->idQuotation], 'class' => 'form-horizontal','files'=>true]) !!}
@else
{!! Form::open(['url' => 'school/quotations', 'class' => 'form-horizontal','id'=>'form','files'=>true]) !!}
@endif
<div class="row clearfix">
<div class="col-sm-3 form-control-label required">
<label for="classname">Date</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('quotationDate',null,['class' => 'form-control datepicker','required'=>'required']) !!}
@if ($errors->has('quotationDate'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('quotationDate') }}</strong>
</label>
@endif
</div>
</div>
<div class="col-sm-3 form-control-label required">
<label for="classname">Expected Delivery Date</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('expDeliveryDate',null,['class' => 'form-control datepicker','required'=>'required']) !!}
@if ($errors->has('expDeliveryDate'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('expDeliveryDate') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3 form-control-label required">
<label for="classname">Shipment Preference</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::text('shipmentPreference',null,['class' => 'form-control','required'=>'required']) !!}
@if ($errors->has('shipmentPreference'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('shipmentPreference') }}</strong>
</label>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6">
<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th>Item</th>
<th>Quantity</th>
<th></th>
</tr>
</thead>
<tbody id="optional_list">
@if(isset($quotation))
<?php $j =1;?>
@foreach($quotation->details as $var)
<tr>
<td class="sno">{{$j}}</td>
<td>
{!! Form::select('products['.$j.'][idProduct]',$products,$var->idProduct,['class' => 'form-control select2 show-tick ms','required'=>'required']) !!}
<input type="hidden" name="products[{{$j}}][idQuotationDetail]" value="{{$var->idQuotationDetail}}">
<div id="prod_error"></div>
</td>
<td>
{!! Form::text('products['.$j.'][quantity]',$var->quantity,['class' => 'form-control']) !!}
</td>
<td></td>
</tr>
<?php $j++ ; ?>
@endforeach
@else
<?php $i =1;?>
<tr>
<td class="sno">{{$i}}</td>
<td>
{!! Form::select('products[1][idProduct]',$products,null,['class' => 'form-control select2 show-tick ms','required'=>'required','onchange'=>'checkOthers(this,1)']) !!}
<p>Not in List? <a href="{{url('/school/products')}}" target="_blank">Add New</a></p>
<div id="newproduct1" style="display: none">
{!! Form::text('products[1][newproduct]',null, ['class' => 'form-control','maxlength'=>'200','minlength'=>'2','autocomplete'=>'off','placeholder'=>'Enter Product Name']) !!}
</div>
</td>
<td>
{!! Form::text('products[1][quantity]',null,['class' => 'form-control','required'=>'required']) !!}
</td>
<td></td>
</tr>
<?php $i++ ; ?>
@endif
</tbody>
<tr>
<td colspan="4" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
<div class="col-sm-3 form-control-label required">
<label for="classname">Select Vendor/Supplier</label>
</div>
<div class="col-sm-2">
<div class="form-group">
@if(isset($quotation))
{!! Form::select('idSupplier',$suppliers,null,['class' => 'form-control select2 show-tick ms','required'=>'required']) !!}
@if ($errors->has('idSupplier'))
<label id="minmaxlength-error" class="error" for="minmaxlength">
<strong>{{ $errors->first('idSupplier') }}</strong>
</label>
@endif
@else
<div style="border:1px solid #ccc; width:200px; height: 150px; overflow-y: scroll;">
@foreach($suppliers as $key=>$value)
<div class="checkbox-inline" style="padding-left:10px;padding-top:5px;">
<input type="checkbox" name="suppliers[]" value="{{$key}}" >
<label>{{$value}}</label>
</div>
@endforeach
</div>
<div id="vendor_error"></div>
@endif
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-8 offset-sm-2">
@if(isset($quotation))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
@else
{!! Form::submit('Save',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
@endif
<a href="{{url('/school/quotations')}}" class="btn btn-raised btn-danger btn-round waves-effect">CANCEL</a>
</div>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Quotations</strong></h2>
</div>
<div class="body table-responsive">
{!! Form::open(['method' => 'GET', 'action' => ['School\Stock\QuotationController@index'], 'class' => 'form-horizontal']) !!}
<div class="row clearfix">
<div class="col-sm-2"></div>
<div class="col-sm-2 form-control-label">
<label for="classname">Financial Year</label>
</div>
<div class="col-sm-3">
<div class="form-group">
{!! Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']) !!}
</div>
</div>
<div class="col-sm-2">
{!! Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']) !!}
</div>
</div>
{!! Form::close() !!}
<br>
<table class="table table-bordered table-striped table-hover js-basic-example dataTable">
<thead>
<tr>
<th>S. No.</th>
<th>Request Date</th>
<th>Expected Delivery Date</th>
<th>Shipment Preference</th>
<th>Vendor/Supplier</th>
<th>Communication</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach($quotations as $value)
<tr>
<th scope="row">{{$i}}</th>
<td>{{$value->quotationDate}}</td>
<td>{{$value->expDeliveryDate}}</td>
<td>{{$value->shipmentPreference}}</td>
<td>{{$value->supplier->bussinessName}}</td>
<td>
<a href="https://web.whatsapp.com/send?phone=+91{{$value->supplier->contactNo}}&text={{urlencode('Hello, Good day .Please we will like to know the price and availability of the following item in this link https://online-login.online/api/quotations/QO1201'.$value->idQuotation.'. We await your quick response. Kind Regards, Team')}}" target="_blank" class="btn btn-raised btn-warning waves-effect btn-round">Send WhatsApp</a>
<form method="POST" action="{{url('/school/quotations-mail')}}">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<input type="hidden" name="id" value="{{$value->idQuotation}}"/>
<button class="btn btn-raised btn-success waves-effect btn-round" type="submit">Send Mail</button>
</form>
</td>
<td>
<a href="{{ url('school/quotations/' . $value->idQuotation) }}" target="_blank" class="btn btn-raised btn-warning waves-effect btn-round">View </a>
<a href="{{ url('school/quotations/' . $value->idQuotation . '/edit') }}" class="btn btn-raised btn-info waves-effect btn-round">Edit </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idQuotation}}" data-type="confirm">DELETE</button>
</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
var i = $('.sno:last').text();
$(".add-row").click(function(){
i++;
var markup = '<tr><td class="sno">'+i+'</td>\
<td><select name="products['+i+'][idProduct]" class = "form-control select2 show-tick ms" onchange="checkOthers(this,'+i+');" required="required">@foreach($products as $key=>$value)<option value="{{$key}}">{{$value}}</option>@endforeach</select>\n\
<p>Not in List? <a href="{{url('/school/products')}}" target="_blank">Add New</a></p><div id="newproduct'+i+'" style="display: none"><input type="text" name="products['+i+'][newproduct]" class="form-control" maxlength="200" minlength="2" autocomplete="off" placeholder = "Enter Product Name"></div></td>\n\
\n\ <td><input class="form-control" type="text" name="products['+i+'][quantity]" required ="required"></td>\n\
<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
$("#optional_list").append(markup);
});
$('#optional_list').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
i = $('.sno:last').text();
});
//Add Input field if others is selecyted
});
function checkOthers(selected,keyid){
var val = selected.value;
if(val == 'new'){
$('#newproduct'+keyid).show();
$('#newproduct').attr("required", "true");
}else{
$('#newproduct'+keyid).hide();
}
}
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Quotation!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/quotations/')}}" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Quotation has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('school/quotations') }}",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "{{url('school/quotations')}}";
}
else { //False Case: With error msg
$("#msg").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
$("#submit-btn").prop('disabled', false);
var errors = data.responseJSON.errors;
var errorHtml = '<div class="alert alert-danger"><ul>';
$('#formerrors').html(errorHtml);
if(errors['idSupplier']=== undefined){
$( '#vendor_error' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idSupplier']+'</strong></span>';
$( '#vendor_error' ).html( errorname );
}
if(errors['idProduct']=== undefined){
$( '#prod_error' ).empty();
}else{
errorname = '<span class="help-block"><strong>'+errors['idProduct']+'</strong></span>';
$( '#prod_error' ).html( errorname );
}
}
}
});
return false;
});
</script>
@stop
Copyright © 2021 -