Viewing file: index.blade.php (9.03 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
@extends('layouts.app', ['title' => __('Add User')])
@section('content')
@include('users.partials.header', [
])
<div class="container-fluid mt--7">
<div class="row">
<div class="col">
<div class="card shadow">
<div class="card-header border-0">
<div class="row align-items-center">
<div class="col-8">
<h3 class="mb-0">Users</h3>
</div>
<div class="col-4 text-right">
<a href="{{route('user.add')}} " class="btn btn-sm btn-primary">Add user</a>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="table-responsive">
<table class="table align-items-center">
<thead class="thead-light">
<tr>
<!-- <th class="td_data">Id</th> -->
<th class="td_data">Name</th>
<th class="td_data">Phone</th>
<th class="td_data">Balance</th>
<th class="td_data">Role</th>
<th class="td_data">Due Amount</th>
<th class="td_data"></th>
</tr>
</thead>
<tbody>
@foreach($user as $value)
<tr>
<!-- <td class="td_data">{{$value['id']}}</td> -->
<td class="td_data">
{{$value['name']}}
</td>
<td class="td_data">{{$value['phone']}}</td>
<td class="td_data">{{$value['balance']}}</td>
<td class="td_data">{{$value['role']}}</td>
<td class="td_data">{{$value['amount_due']}}</td>
<!-- <td class="text-right">
<div class="dropdown">
<a class="btn btn-sm btn-icon-only text-light" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
<a class="dropdown-item" href="">Edit</a>
</div>
</div>
</td> -->
<td><button type="button" class="btn btn-info btn" data-toggle="modal" data-target="#balance-modal" id="btn_balance" onclick="balance_modal_open('{{$value["id"]}}','{{ auth()->user()->role }}')" >Balance</button></td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<!-- Start New Customer -->
<div id="balance-modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" >
<h3 >Balance Form</h3>
<a class="close" data-dismiss="modal">×</a>
</div>
<form id="balanceForm" name="balance" role="form">
<div class="modal-body">
<div class="form-group" >
@if(auth()->user()->role!=="Admin")
<h2>Remaining Balance : {{ auth()->user()->balance }}</h2>
@endif
<input type="hidden" id="reseler_balance" value="{{ auth()->user()->balance }}">
</div>
<div class="form-group">
<label for="add_balance">Balance</label>
<input type="text" name="add_balance" id="add_balance" class="form-control">
<p id="err_balance" style="display:none;">Please give some Balance..</p>
</div>
<div class="form-group">
<label for="add_amount">Amount</label>
<input type="text" name="add_amount" id="add_amount" class="form-control">
</div>
<div class="form-group">
<label for="name">Payment Method</label>
<select class="form-control" name="method" id="add_method">
<option value="Cash" selected>cash</option>
<option value="Bkash">Bkash</option>
<option value="Card">Card</option>
</select>
</div>
<p id="low_balance" style="display:none;">You don't Have sufficient Balance..</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-success" id="submit" value="Add">
</div>
</form>
</div>
</div>
</div>
<!-- End New Customer Area -->
<!-- {{--New coustomer modal end--}} -->
<div class="card-footer py-4">
<nav class="d-flex justify-content-end" aria-label="...">
</nav>
</div>
</div>
</div>
</div>
@include('layouts.footers.auth')
</div>
@endsection
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
function balance_modal_open(user_id,reseller_role) {
console.log(user_id);
console.log(reseller_role);
$(document).ready(function(){
$("#balanceForm").submit(function(event){
submitForm(user_id,reseller_role);
return false;
// console.log(user_id);
});
});
function submitForm(user_id,reseller_role){
console.log(user_id);
var add_method=document.getElementById("add_method").value;
var add_balance=document.getElementById("add_balance").value;
var add_amount=document.getElementById("add_amount").value;
// console.log(add_balance);
// console.log(add_amount);
var reseler_balance=document.getElementById("reseler_balance").value;
if (add_balance==="" || add_balance==0) {
// $("#err_balance").value="Please give som Balance...."
// alert("Please give some Balance....");
$("#err_balance").show();
}
else if(add_balance>reseler_balance)
{
if (reseller_role!=="Admin") {
$("#low_balance").show();
}
else{
if (add_amount==="") {
add_amount="0";
console.log(add_method);
}
$.ajax({
type: "get",
url: "{{ url('Alluser') }}/"+user_id+"/"+add_balance+"/"+add_amount+"/"+add_method,
cache:false,
success: function(response){
console.log(response);
document.getElementById("balanceForm").reset();
$("#balance").html(response)
$("#balance-modal").modal('hide');
location.reload();
},
error: function(){
alert("Error");
}
});
}
}
}
}
// console.log($("#btn_balance"));
</script>
|