|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/flavourapps.com/user.flavourapps.com/resources/views/restaurant_key/ |
Upload File : |
@extends('layout')
@section('content')
<!-- begin::main content -->
<style>
.input_upload{
width:100px;
height:35px;
position:absolute;
bottom:-34px;
right:350px;
}
.import-content p{
padding:0;
margin:0;
margin-bottom:8px;
font-size:13px;
}
.filter-form-box{
background-color:#FBFAFA;
padding:10px 24px;
position:absolute;
width:450px;
border:1px solid #ddd;
border-radius:5px;
top:71px;
z-index:20;
}
.filter-form-box input{
height:40px !important;
}
.diamond {
width: 20px;
height: 20px;
background-color: #FBFAFA;
transform: rotate(45deg);
position: relative;
top:-21px;
left:0px;
border-top:1px solid #ddd;
border-left:1px solid #ddd;
}
.seach-input:focus{
outline:none !important;
border-top:1px solid #ddd !important;
border-bottom:1px solid #ddd !important;
}
.seach-input{
height:40px !important;
border-top:1px solid #ddd !important;
border-bottom:1px solid #ddd !important;
border-left:1px solid #ddd !important;
}
</style>
<main class="main-content">
<div class="container">
<div class="toast d-none float-right" >
<div class="toast-body bg-success text-white">
<i class="fa fa-check fa-lg"></i>  Status Update Successfully
</div>
</div>
<!-- begin::page header -->
<div class="page-header">
<h3>{{__('message.licence')}} {{__('message.key')}}</h3>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ asset('dashboard') }}">{{ __('message.dashboard') }}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ __('message.list') }}</li>
</ol>
</nav>
</div>
<!-- end::page header -->
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-md-6 py-3">
<form action="{{asset('licencekey')}}" method="get">
<div class="company-field-box">
<div>
<div class="input-group">
<div class="input-group-prepend">
<button type="button" class="btn border input-group-text filter-company-btn">
<i class="fa fa-filter fa-lg px-2"></i>
</button>
</div>
<input type="search" value="{{isset($_GET['search']) ? $_GET['search'] : null}}" name="search" class="form-control border-right-0 seach-input">
<button class="btn border border-left-0" type="submit" style="margin-left:-5px;">
<i class="fa fa-search fa-lg"></i>
</button>
</div>
<div class="filter-form-box d-none">
<div class="diamond"></div>
<form method="get" action="{{asset('licencekey')}}">
<div class="form-group">
<label>{{__('message.licence')}} {{__('message.key')}} </label>
<input value="{{isset($_GET['licence_key']) ? $_GET['licence_key'] : null}}" type="text" name="licence_key" class="form-control" id="licence_key">
</div>
<div class="form-group">
<label> {{__('message.created')}} </label>
<input type="date" name="created_date" value="{{isset($_GET['created_date']) ? $_GET['created_date'] : null}}" class="form-control" id="created_date">
</div>
<div class="form-group">
<label> {{__('message.activation')}} {{__('message.date')}}</label>
<input type="date" name="activation_date" value="{{isset($_GET['activation_date']) ? $_GET['activation_date'] : null}}" class="form-control" id="activation_date">
</div>
<div class="row">
<div class="form-group col-6">
<label>{{__('message.start')}} {{__('message.date')}}</label>
<input type="date" name="start_date" value="{{isset($_GET['start_date']) ? $_GET['start_date'] : null}}" class="form-control" id="start_date">
</div>
<div class="form-group col-6">
<label>{{__('message.end')}} {{__('message.date')}}</label>
<input type="date" name="end_date" value="{{isset($_GET['end_date']) ? $_GET['end_date'] : null}}" class="form-control" id="end_date">
</div>
</div>
<div class="row">
<div class="form-group col-12">
<button type="submit" class="btn btn-success-lux mr-5 px-4 apply-button">{{__('message.apply')}}</button>
<a href="{{asset('licencekey')}}" class="btn btn-primary-lux px-5 clear-button text-white">{{__('message.clear')}}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</form>
</div>
<div class="col-md-6 py-3 px-4">
<div class="row">
<div class="col-1"></div>
<div class="col-4 pt-1 d-flex justify-content-end">
<button class="btn btn-outline-success all-sells-btn d-none">
Sell Licences
</button>
</div>
<div class="col-4 pt-1">
<form action="{{asset('licencekey')}}" class="filter-form" method="get">
<?php
$filter = isset($_GET['filter_by']) ? $_GET['filter_by'] : '';
?>
<select class="form-control filter_by_sells" style="height:40px;" name="filter_by">
<option value="all" <?php echo $filter === "all" ? 'selected' : ''; ?>>--ALL--</option>
<option value="sold" <?php echo $filter === "sold" ? 'selected' : ''; ?> >Sold</option>
<option value="buy" <?php echo $filter === "buy" ? 'selected' : ''; ?>>Buy</option>
</select>
</form>
</div>
<div class="col-3">
<a data-toggle="tooltip" data-original-title="Export Restaurant"
href="{{ asset('export-licencekey') }}"
class="btn btn-white-lux text-uppercase mr-2"><i
class="fa fa-download pr-2"></i>
{{__('message.export')}}
</a>
</div>
</div>
</div>
</div>
</div>
<div class="card-body">
@if (isset($licencekey))
<div class="table-responsive">
<table class="table table-bordered" >
<thead style="background-color:#E9EEF1">
<tr>
<th> Select Licence
<div class="d-flex justify-content-center">
<button class="border-0 p-0 py-2">
<input type="checkbox" id="all-sells-input">
</button>
</div>
</th>
<th >{{__('message.sno')}}</th>
<th >{{__('message.licence')}} {{__('message.key')}}</th>
<th>{{ __('message.created') }}</th>
<th>{{ __('message.activation') }} {{ __('message.date') }}</th>
<th>{{ __('message.duration') }} /{{ __('message.time') }}</th>
<th>{{ __('message.price') }}</th>
<th>{{ __('message.discount') }}</th>
<th>{{ __('message.activation') }} {{ __('message.status') }}</th>
<th>{{ __('message.sales') }} {{ __('message.status') }}</th>
<th>{{ __('message.action') }}</th>
</tr>
</thead>
<tbody>
@if (!empty($licencekey))
@foreach ($licencekey as $key=>$value)
<tr>
<td>
@if($value->sell_status)
<div class="d-flex justify-content-center">
<input disabled type="checkbox" />
</div>
@else
<div class="d-flex justify-content-center">
<input type="checkbox" name="licence[]" class="licence_id" value="{{$value->id}}" />
</div>
@endif
</td>
<td>{{++$key}}</td>
<td class="no-wrap">{{$value->licence_key}}</td>
<td class="no-wrap">{{$value->created_date}}</td>
<td class="no-wrap">{{$value->activation_date}}</td>
<td>{{$value->duration}} days</td>
<td class="no-wrap">
@if($value->currency=="rupee")
₹ {{$value->price}}
@else
$ {{$value->price}}
@endif
</td>
<td>
@if($value->discount_type=="percentage")
{{$value->discount}}%
@else
{{$value->discount}}
@endif
</td>
<td>
<div class="d-flex justify-content-center">
<label class="switch">
<input type="checkbox" name="theme_mode" value="{{$value->id}}" class="custom-control-input change-status-btn" {{$value->status == 'ACTIVATE' ? 'checked' : ''}}>
<span class="slider round"></span>
</label>
</div>
</td>
<td>
@if($value->sell_status)
<button disabled type="button" class="btn btn-outline-success btn-sm">
Sold
</button>
@else
<button disabled type="button" class="btn btn-outline-danger btn-sm">
Sell
</button>
@endif
</td>
<td>
<div class="btn-group">
@if (Auth::user()->can('edit-restaurant') || Auth::user()->type=="employee" || Auth::user()->type=="distributor")
@if($value->sell_status)
<button disabled type="button" class="btn btn-sm btn-outline-info single-sell-btn"
data-original-title="Sell Licence" licence_id="{{$value->id}}" employee_id="{{Auth::user()->id}}">
Sold
</button>
@else
<button type="button" class="btn btn-sm btn-outline-info single-sell-btn"
data-original-title="Sell Licence" licence_id="{{$value->id}}" employee_id="{{Auth::user()->id}}">
Sell Now
</button>
@endif
@endif
</div>
</td>
</tr>
@endforeach
@else
<h1>No Record Found!!</h1>
@endif
</tbody>
</table>
</div>
<div class="d-flex justify-content-center pagination-box">{{$licencekey->links()}}</div>
@endif
</div>
</div>
</div>
<!-- The Modal -->
<div class="modal" id="sellModal">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header bg-primary rounded-0">
<h4 class="modal-title">Distributor </h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<form class="licence-sell-form">
<div class="form-group">
<label>{{__('message.dealer')}} / {{__('message.partner')}}</label>
<input type="hidden" value="{{Auth::user()->id}}" class="employee_id">
<select class="form-control distributor_id" name="distributor_id" >
<option disabled selected>--SELECT--</option>
@foreach($distributor as $value)
<option value="{{$value->id}}">{{$value->name}}</option>
@endforeach
</select>
</div>
<div class="d-flex justify-content-end">
<button type="submit" class="btn btn-outline-primary" >Sell Now</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal footer -->
</div>
</div>
</div>
</main>
<!-- end::main content -->
@endsection
@push('footer-script')
<!-- begin::dataTable -->
<!-- end::dataTable -->
<script>
$(document).ready(function() {
$("#checkAll").click(function() {
$('.userids:checkbox').not(this).prop('checked', this.checked);
var length = $('.userids[type="checkbox"]:checked').length;
if($(".multiple-delete-btn").hasClass('d-none'))
{
$(".multiple-delete-btn").removeClass("d-none");
$(".multiple-delete-btn").html('<span class="pt-1">Delete ('+length+")</span>");
}
else
{
$(".multiple-delete-btn").addClass("d-none");
}
});
$("#all-sells-input").click(function(){
$('.licence_id:checkbox').not(this).prop('checked', this.checked);
var length = $('.licence_id[type="checkbox"]:checked').length;
if($(".all-sells-btn").hasClass('d-none'))
{
$(".all-sells-btn").removeClass("d-none");
$(".all-sells-btn").html('<span class="pt-1">Sell Licence ('+length+")</span>");
}
if(length===0)
{
$(".all-sells-btn").addClass("d-none");
}
});
$('.licence_id').each(function(){
var licence_ids = [];
$(this).click(function(){
var length = $('.licence_id[type="checkbox"]:checked').length;
$(".all-sells-btn").removeClass("d-none");
$(".all-sells-btn").html('<span class="pt-1">Sell Licence ('+length+")</span>");
if(length == 0)
{
$(".all-sells-btn").addClass("d-none");
}
$('.licence_id:checkbox:checked').each(function() {
licence_ids.push($(this).val());
});
//console.log(licence_ids);
});
});
$(".all-sells-btn").click(function(){
$("#sellModal").modal("show");
var licence_ids = [];
$('.licence_id:checkbox:checked').each(function() {
licence_ids.push($(this).val());
});
//console.log(licence_ids);
$(".licence-sell-form").submit(function(e){
e.preventDefault();
var distributor_id = $(".distributor_id").val();
var employee_id = $(".employee_id").val();
console.log(distributor_id);
distributorSell(licence_ids,distributor_id,employee_id);
});
});
$(".single-sell-btn").click(function(){
$("#sellModal").modal("show");
var licence_ids = [];
var employee_id = $(this).attr("employee_id");
var licence_id = $(this).attr("licence_id");
$(".licence-sell-form").submit(function(e){
e.preventDefault();
var distributor_id = $(".distributor_id").val();
licence_ids.push(licence_id);
//console.log(distributor_id);
distributorSell(licence_ids,distributor_id,employee_id);
});
});
//sell licence key ajax code
function distributorSell(licence_ids,distributor_id,employee_id)
{
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: "post",
data: {
"licence_ids": licence_ids,
"distributor_id":distributor_id,
"employee_id": employee_id
},
url: "{{asset('sell-licence-key')}}",
dataType: "html",
success: function(result) {
$("#sellModal").modal("hide");
swal("success!", "Successfully Sell Licence !", "success");
window.location.reload();
},
error:function(xhr,status,error)
{
$("#sellModal").modal("hide");
var err = JSON.parse(xhr.responseText);
swal("failed!", err.message, "error");
window.location.reload();
}
});
}
//end sell licence key ajax
//filter by sell
$(".filter_by_sells").on("change",function(){
var filter_value = $(this).val();
$(".filter-form").submit();
});
});
$(".apply-button").click(function(){
$(".filter-form-box").addClass("d-none");
});
//filter company code
$(".filter-company-btn").click(function(){
if($(".filter-form-box").hasClass("d-none"))
{
$(".filter-form-box").removeClass("d-none");
}
else
{
$(".filter-form-box").addClass("d-none");
}
});
$(".change-status-btn").click(function(){
var btn = $(this);
var licence_id = $(this).val();
//var status = $(this).attr("status");
var status = "INACTIVE";;
if( $(this).is(":checked"))
{
status = "ACTIVE";
}
$.ajax({
type: "post",
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: "{{asset('change-sales-status')}}",
data:{
licence_id:licence_id,
status:status
},
dataType: "html",
success: function(result)
{ console.log(result);
var allData = JSON.parse(result);
if(allData.message=="success")
{
$('.toast').removeClass('d-none');
$('.toast').toast('show');
}
else
{
var div = `
<div class="toast-body bg-danger text-white">
<i class="fa fa-times-circle-o fa-lg"></i>  Status Update Failed
</div>
`;
$('.toast').removeClass('d-none');
$('.toast').toast('show');
$('.toast').html(div);
}
},
error:function(xhr,status,error)
{
console.log(error);
var div = `
<div class="toast-body bg-danger text-white">
<i class="fa fa-times-circle-o fa-lg"></i>  Status Update Failed
</div>
`;
$('.toast').removeClass('d-none');
$('.toast').toast('show');
$('.toast').html(div);
}
});
});
</script>
@endpush