IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Purchase Order List</strong></h2>
</div>
<div class="body table-responsive">
<?php echo Form::open(['method' => 'GET', 'action' => ['School\Stock\PurchaseOrderController@viewPO'], '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">
<?php echo Form::select('idFinancialYear',fys(),null,['class' => 'form-control show-tick ms']); ?>
</div>
</div>
<div class="col-sm-2">
<?php echo Form::submit('Search',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
</div>
</div>
<?php echo Form::close(); ?>
<br>
<table class="table table-bordered table-striped table-hover dataTable js-basic-example">
<thead>
<tr>
<th>S. No.</th>
<th>Date</th>
<th>Purchase Order No.</th>
<th>Reference</th>
<th>Vendor Name</th>
<th>Product</th>
<th>Received</th>
<th>Status</th>
<th>Total Amount</th>
<th>Paid Amount</th>
<th>Balance Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php $__currentLoopData = $purchase_orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $var): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<th scope="row"><?php echo e($i); ?></th>
<td><?php echo e($var->purchaseDate); ?></td>
<td><?php echo e($var->poNo); ?></td>
<td><?php echo e($var->reference); ?></td>
<td><?php echo e($var->supplier->bussinessName); ?></td>
<?php
$products = App\PurchaseOrderDetail::join('products','purchase_order_details.idProduct','=','products.idProduct')->select('quantity','productName')->where('idPurchaseOrder',$var->idPurchaseOrder)->get();
?>
<td>
<?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<p><?php echo e($product->productName); ?> - (x<?php echo e($product->quantity); ?>)</p>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</td>
<?php
$products = \App\ProductReceived::join('product_received_details','product_received.idProductReceived','=','product_received_details.idProductReceived')
->join('products','product_received_details.idProduct','=','products.idProduct')
->select('quantity','productName')->where('idPurchaseOrder',$var->idPurchaseOrder)->get();
?>
<td>
<?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<p><?php echo e($product->productName); ?> - (x<?php echo e($product->quantity); ?>)</p>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</td>
<td><?php echo e($var->status); ?></td>
<td>
<?php
$received = \App\ProductReceived::where('idPurchaseOrder', '=', $var->idPurchaseOrder)
->first();
if ($received) {
$pr_payment = \App\ProductPayment::where('idProductReceived', '=', $received->idProductReceived)
->select(DB::raw('SUM(amountPaid) as amountPaid'))->first();
if ($pr_payment) {
$balance = $var->totalAmount - $pr_payment->amountPaid;
if($balance < 0) $balance = 0;
}
}
?>
<?php echo e($var->totalAmount); ?>
</td>
<?php
$paidAmount = \App\ProductReceived::join('product_payment','product_received.idProductReceived','=','product_payment.idProductReceived')->where('idPurchaseOrder', '=', $var->idPurchaseOrder)->sum('amountPaid');
?>
<td><?php echo e($paidAmount); ?></td>
<td><?php echo e($var->totalAmount - $paidAmount); ?></td>
<td>
<?php if($var->status == 'Closed'): ?>
<a href="<?php echo e(url('school/purchaseorder/'.$var->idPurchaseOrder.'/pay')); ?>" target="_blank" class="btn btn-sm btn-success btn-round">Select</a>
<?php else: ?>
<a href="<?php echo e(url('school/purchaseorder/'.$var->idPurchaseOrder.'/details')); ?>" class="btn btn-sm btn-warning">Enter Received Items</a>
<?php endif; ?>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
$(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 Purchase Order!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "<?php echo e(url('/school/purchaseorder/')); ?>" +"/"+id
})
.done(function(data) {
if(data.success == "FAILED"){
swal({
title: "Cannot be deleted",
text: "Failed to delete PO as relation exists",
type: "error"
},function() {
});
}else{
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;
});
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -