216 lines
6.5 KiB
PHP
216 lines
6.5 KiB
PHP
@extends('layout.tokomain')
|
|
@section('activenav', '4')
|
|
@section('head-content-title', 'Pesanan')
|
|
@section('head-back-nav')
|
|
<li class="breadcrumb-item active"><a href="{{url('toko/pesanan')}}">Pesanan</a></li>
|
|
<li class="breadcrumb-item active">Data Pesanan</li>
|
|
@endsection
|
|
@section("container")
|
|
<!-- Main content -->
|
|
<section class="content">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form id="tablesaya">
|
|
@php
|
|
|
|
MyForm::hidden("id_pesanan", $id_pesanan);
|
|
|
|
MyForm::set_db('akun');
|
|
MyForm::set_select([
|
|
"title" => "Pilih Barang"
|
|
,"id" => "id_barang"
|
|
,"name" => "id_barang"
|
|
,"class" => "form-control"
|
|
,"option" => [
|
|
"value" => "id_akun"
|
|
,"text" => "nama_akun"
|
|
]
|
|
,"kondisi" => [
|
|
['perusahaan', '=', Session::get("toko-user")['nama_perusahaan']]
|
|
]
|
|
]);
|
|
MyForm::print_select();
|
|
|
|
MyForm::input([
|
|
"title"=> "Banyak Pesanan"
|
|
,"name"=> "banyak_barang"
|
|
,"id"=> "banyak_barang"
|
|
,"type"=> "number"
|
|
,"autocomplete" => "off"
|
|
,"class"=> "form-control"
|
|
,"placeholder"=> "isikan banyak pesanan"
|
|
]);
|
|
|
|
@endphp
|
|
<button type="sumbit" id="mysubmit" class="btn btn-primary">Simpan</button>
|
|
</form>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-12">
|
|
<div class="row">
|
|
<div class="col-12 col-sm-6 col-md-3">
|
|
<div class="info-box">
|
|
<span class="info-box-icon bg-info elevation-1"><i class="fas fa-money-check-alt"></i></span>
|
|
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">Total Pembayaran</span>
|
|
<span class="info-box-number" id="total-bayar">
|
|
|
|
</span>
|
|
</div>
|
|
<!-- /.info-box-content -->
|
|
</div>
|
|
<!-- /.info-box -->
|
|
</div>
|
|
<div class="col-12 col-sm-6 col-md-3">
|
|
<a href="{{url('toko/struk/pesanan/'.$id_pesanan)}}">
|
|
<div class="info-box">
|
|
<span class="info-box-icon bg-info elevation-1"><i class="fas fa-money-check-alt"></i></span>
|
|
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">cetak struk</span>
|
|
<span class="info-box-number">
|
|
pdf
|
|
</span>
|
|
</div>
|
|
<!-- /.info-box-content -->
|
|
</div>
|
|
</a>
|
|
|
|
<!-- /.info-box -->
|
|
</div>
|
|
@php
|
|
|
|
$nama_perus = Session::get("toko-user")["nama_perusahaan"];
|
|
|
|
$bayar = "SELECT * FROM pesanan WHERE id_pesanan = '$id_pesanan' AND perusahaan = '$nama_perus'";
|
|
|
|
$bayar = DB::select($bayar)[0]->bayar;
|
|
|
|
@endphp
|
|
<div class="col-12 col-sm-6 col-md-3">
|
|
<div class="form-group">
|
|
<label for="">Bayar</label>
|
|
<input id="bayar-transaksi" type="number" class="form-control" value="{{$bayar}}">
|
|
</div>
|
|
|
|
<!-- /.info-box -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
{!! html_entity_decode($datatable) !!}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content')
|
|
}
|
|
})
|
|
|
|
|
|
$("body").on("keyup", "#bayar-transaksi", function(){
|
|
|
|
let nilaiB = $(this).val();
|
|
|
|
$.ajax({
|
|
url: '{{url('toko/bayar_pesanan')}}',
|
|
type: 'POST',
|
|
dataType: 'text',
|
|
data: {
|
|
id: '{{$id_pesanan}}',
|
|
bayar: nilaiB
|
|
},
|
|
})
|
|
.done(function(res) {
|
|
})
|
|
|
|
});
|
|
|
|
|
|
// console.log(id_barang+' - '+nilai);
|
|
function pembayaranTotal(){
|
|
$.ajax({
|
|
url: '{{url("toko/pesanan/total_pembayaran")}}',
|
|
type: 'POST',
|
|
dataType: 'text',
|
|
data: {
|
|
idBarang: "{{ $id_pesanan }}"
|
|
},
|
|
})
|
|
.done(function(response) {
|
|
$("#total-bayar").text(response);
|
|
})
|
|
}
|
|
|
|
pembayaranTotal();
|
|
|
|
// cek barang tersedia, jika tersidia do action jika tidak ada matikan action
|
|
|
|
$("#banyak_barang").keyup(function() {
|
|
let id_barang = $("#id_barang").val();
|
|
let nilai = $(this).val();
|
|
// console.log(id_barang+' - '+nilai);
|
|
$.ajax({
|
|
url: '{{url("toko/pesanan/cek")}}',
|
|
type: 'POST',
|
|
dataType: 'text',
|
|
data: {
|
|
idBarang: id_barang
|
|
,banyakBarang: nilai
|
|
},
|
|
})
|
|
.done(function(response) {
|
|
if (response == "kurang") {
|
|
$("#mysubmit").attr('type', 'button').removeClass('btn-primary').addClass('btn-default');
|
|
}else{
|
|
$("#mysubmit").attr('type', 'submit').removeClass('btn-default').addClass('btn-primary');
|
|
}
|
|
})
|
|
});
|
|
|
|
//Program a custom submit function for the form
|
|
$("form#tablesaya").submit(function(event){
|
|
|
|
//disable the default form submission
|
|
event.preventDefault();
|
|
|
|
//grab all form data
|
|
var formData = new FormData($(this)[0]);
|
|
|
|
$.ajax({
|
|
url: '{{url("toko/pesanan/simpan_data")}}',
|
|
type: 'POST',
|
|
data: formData,
|
|
async: false,
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (returndata) {
|
|
$("select[name=id_barang] option:nth-child(1)").prop('selected', 'selected');
|
|
$("input[name=banyak_barang]").val('');
|
|
tableku.ajax.reload();
|
|
pembayaranTotal();
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
</script>
|
|
|
|
@endsection |