

<?php $__env->startSection('title'); ?>
    Generate Voucher
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
    <ol class="breadcrumb pull-right">
        <li><a href="<?php echo e(route('home')); ?>"><i class="fa fa-dashboard"></i> Home</a></li>

        <li class="active">Vouchers</li>
    </ol>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('css'); ?>

    <link href="<?php echo e(asset('plugins/components/bootstrap-daterangepicker/daterangepicker.css')); ?>" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

    <style type="text/css">
        .h30 {
            /* height: 30px;*/
        }

        .table>tbody>tr>td,
        .table>tbody>tr>th {
            font-size: 14px;
            text-align: left;
        }
    </style>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>


    <div class="container-fluid">

        <!--.row-->
        <div class="row">


            <?php if($customer_tax_receipt): ?>

                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Receipt Information</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Receipt #</td>
                                        <td><?php echo e($customer_tax_receipt->receipt_no); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Date</td>
                                        <td><?php echo e(date('d-m-Y', strtotime($customer_tax_receipt->receipt_date))); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Customer</td>
                                        <td><?php echo e($customer_tax_receipt->customerPropertyTax->statement->receipt->customer->name); ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Unit No.</td>
                                        <td> <?php echo e($customer_tax_receipt->customerPropertyTax->statement->receipt->property->inventory->unit_number); ?>

                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Payment Head</td>
                                        <td>
                                            <?php if($customer_tax_receipt->customerPropertyTax->statement->receipt->payment_head == \App\Receipt::down_payment): ?>
                                                Down Payment
                                            <?php elseif($customer_tax_receipt->customerPropertyTax->statement->receipt->payment_head == \App\Receipt::installment): ?>
                                                Installment
                                            <?php elseif($customer_tax_receipt->customerPropertyTax->statement->receipt->payment_head == \App\Receipt::others): ?>
                                                Others
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Payment Mode</td>
                                        <?php if($customer_tax_receipt->payment_method == \App\Receipt::cash): ?>
                                            <td>Cash</td>
                                        <?php elseif($customer_tax_receipt->payment_method == \App\Receipt::bank): ?>
                                            <td>Bank transfer
                                                <br>
                                                <b>Depositor bank:</b>

                                                <?php echo e($customer_tax_receipt->DepositorBank ? $customer_tax_receipt->DepositorBank->name : ''); ?>


                                                <br>
                                                <b>Company bank:</b>

                                                <?php echo e($customer_tax_receipt->companyAccount ? $customer_tax_receipt->companyAccount->name : ''); ?>



                                            </td>
                                        <?php elseif($customer_tax_receipt->payment_method == \App\Receipt::cheque): ?>
                                            <td>Cheque</td>
                                        <?php elseif($customer_tax_receipt->payment_method == \App\Receipt::adjustment): ?>
                                            <td>Adjustment</td>
                                        <?php endif; ?>
                                    </tr>


                                    <?php if(
                                        $customer_tax_receipt->payment_method == \App\Receipt::cheque ||
                                            $customer_tax_receipt->payment_method == \App\Receipt::bank): ?>
                                        <tr>
                                            <td>Instrument No </td>
                                            <td><?php echo e($customer_tax_receipt->instrument_no); ?></td>
                                        </tr>
                                    <?php endif; ?>

                                    <tr>
                                        <td>Net Amount</td>
                                        <?php if($customer_tax_receipt->tax_paid_by == \App\Receipt::company): ?>
                                            <td><?php echo e(number_format($customer_tax_receipt->receipt_amount)); ?></td>
                                        <?php else: ?>
                                            <td><?php echo e(number_format($customer_tax_receipt->receipt_amount)); ?></td>
                                        <?php endif; ?>
                                    </tr>



                                    <tr>
                                        <td>Tax Payment Received</td>
                                        <td>
                                            <?php if($customer_tax_receipt->customerPropertyTax->statement->receipt->tax_payment_received): ?>
                                                YES
                                            <?php else: ?>
                                                NO
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Notes</td>
                                        <td><?php echo e($customer_tax_receipt->note); ?></td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>

            <?php endif; ?>


            <?php if($receipt): ?>

                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Receipt Information</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Receipt #</td>
                                        <td><?php echo e($receipt->receipt_no); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Date</td>
                                        <td><?php echo e(date('d-m-Y', strtotime($receipt->receipt_date))); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Customer</td>
                                        <td><?php echo e($receipt->customer->name); ?> </td>
                                    </tr>
                                    <tr>
                                        <td>Unit No.</td>
                                        <td> <?php echo e($receipt->property->inventory ? $receipt->property->inventory->unit_number : ''); ?>

                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Payment Head</td>
                                        <td>
                                            <?php if($receipt->payment_head == \App\Receipt::down_payment): ?>
                                                Down Payment
                                            <?php elseif($receipt->payment_head == \App\Receipt::installment): ?>
                                                Installment
                                            <?php elseif($receipt->payment_head == \App\Receipt::others): ?>
                                                Others
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Payment Mode</td>
                                        <?php if($receipt->payment_method == \App\Receipt::cash): ?>
                                            <td>Cash</td>
                                        <?php elseif($receipt->payment_method == \App\Receipt::bank): ?>
                                            <td>Bank transfer
                                                <br>
                                                <b>Depositor bank:</b>

                                                <?php echo e($receipt->DepositorBank ? $receipt->DepositorBank->name : ''); ?>


                                                <br>
                                                <b>Company bank:</b>

                                                <?php echo e($receipt->companyAccount ? $receipt->companyAccount->name : ''); ?>



                                            </td>
                                        <?php elseif($receipt->payment_method == \App\Receipt::cheque): ?>
                                            <td>Cheque</td>
                                        <?php elseif($receipt->payment_method == \App\Receipt::adjustment): ?>
                                            <td>Adjustment</td>
                                        <?php endif; ?>
                                    </tr>

                                    <?php if($receipt->payment_method == \App\Receipt::cheque || $receipt->payment_method == \App\Receipt::bank): ?>
                                        <tr>
                                            <td>Instrument No </td>
                                            <td><?php echo e($receipt->cheque_number); ?></td>
                                        </tr>
                                    <?php endif; ?>

                                    <tr>
                                        <td>Gross Amount</td>
                                        <td><?php echo e(number_format($receipt->amount)); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Tax Amount</td>
                                        <td>
                                            <?php if($receipt->tax_paid_by == \App\Receipt::company): ?>
                                                <?php echo e(number_format($receipt->tax_amount)); ?>

                                            <?php else: ?>
                                                <?php echo e(number_format(0)); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Net Amount</td>
                                        <?php if($receipt->tax_paid_by == \App\Receipt::company): ?>
                                            <td><?php echo e(number_format($receipt->amount + $receipt->tax_amount)); ?></td>
                                        <?php else: ?>
                                            <td><?php echo e(number_format($receipt->amount)); ?></td>
                                        <?php endif; ?>
                                    </tr>

                                    <tr>
                                        <td>Tax Pay By</td>
                                        <td>
                                            <?php if($receipt->tax_paid_by == \App\Receipt::customer): ?>
                                                Customer
                                            <?php else: ?>
                                                Company
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Tax Payment Received</td>
                                        <td>
                                            <?php if($receipt->tax_payment_received): ?>
                                                YES
                                            <?php else: ?>
                                                NO
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Notes</td>
                                        <td><?php echo e($receipt->notes); ?></td>
                                    </tr>


                                    <?php if($receipt->payment_method == \App\Receipt::adjustment): ?>
                                        <tr>
                                            <td>Adjustment Detail</td>
                                            <td><?php echo e($receipt->adjustment_detail); ?></td>
                                        </tr>

                                        <?php if($receipt->dealer_adjustment_unit_id): ?>
                                            <tr>
                                                <td>Rebate Detail</td>
                                                <td>Adjust againt <?php echo e($receipt->rebate->property->inventory->unit_number); ?>

                                                </td>
                                            </tr>
                                        <?php endif; ?>

                                    <?php endif; ?>



                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>

            <?php endif; ?>


            <?php if($property): ?>


                <div class="col-lg-12">
                    <div class="white-box">
                        <h4 class="box-title " style=" color: white; background-color:#1c3752;line-height: 30px">
                            &nbsp;&nbsp;Unit's Details</h4>

                        <div class="table-responsive pull-left">
                            <table class="table bottom-table">

                                <tbody>
                                    <tr>
                                        <td style="font-weight: 600;">Floor:</td>
                                        <td>
                                            <?php if($property->inventory->floor): ?>
                                                <?php echo e($property->inventory->floor->name); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Category:</td>
                                        <td>
                                            <?php $__currentLoopData = $property->inventory->categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($loop->last): ?>
                                                    <?php echo e($c->category->name); ?> (<?php echo e($c->category->percent); ?> )
                                                <?php else: ?>
                                                    <?php echo e($c->category->name); ?> (<?php echo e($c->category->percent); ?> ),
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Size:</td>
                                        <td>
                                            <?php echo e($property->inventory->size->name); ?> <?php echo e(env('SIZE')); ?>

                                        </td>

                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Total Price:</td>
                                        <td> <?php echo e(number_format($property->inventory->total_price - $property->inventory->extra_amount)); ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Net Amt.:</td>
                                        <td> <?php echo e(number_format($property->net_pay)); ?> </td>
                                    </tr>

                                    <?php if($property->down_payment_note): ?>
                                        <tr class="no-print">
                                            <td style="font-weight: 600;">Notes:</td>
                                            <td><?php echo e($property->down_payment_note); ?></td>
                                        </tr>
                                    <?php endif; ?>
                                    <tr class="no-print">
                                        <td style="font-weight: 600;">Automatic Sms Alerts</td>
                                        <?php if($property->sms_alert == true): ?>
                                            <td>On</td>
                                        <?php else: ?>
                                            <td>Off</td>
                                        <?php endif; ?>
                                    </tr>
                                    <tr class="no-print">
                                        <td style="font-weight: 600;">Automatic Email Alerts</td>
                                        <?php if($property->email_alert == true): ?>
                                            <td>On</td>
                                        <?php else: ?>
                                            <td>Off</td>
                                        <?php endif; ?>
                                    </tr>






                                    <!-- <tr>
                                                <td>Discount:</td>
                                                <td> <?php echo e($property->discount); ?> </td>
                                            </tr> -->

                                </tbody>
                            </table>
                        </div>
                        <div class="table-responsive pull-right">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td style="font-weight: 600;">Unit #:</td>
                                        <td><?php echo e($property->inventory->unit_number); ?></td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Unit Type:</td>
                                        <td><?php echo e($property->inventory->type->name); ?></td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Area:</td>
                                        <td><?php echo e($property->inventory->area); ?></td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Discount:</td>
                                        <td> <?php echo e($property->discount); ?> </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Category Cost:</td>
                                        <td> <?php echo e(number_format($property->inventory->extra_amount)); ?> </td>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Booking Type : </td>
                                        <?php if($property->booking_type == \App\CustomerProperty::normal): ?>
                                            <td>Installment</td>
                                        <?php elseif($property->booking_type == \App\CustomerProperty::full_payment): ?>
                                            <td>Full Payment</td>
                                        <?php endif; ?>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Booking Date:</td>
                                        <?php if($property->inventory->registration): ?>
                                            <?php if($property->inventory->registration->booking_date): ?>
                                                <td> <?php echo e(date('d-m-Y', strtotime($property->inventory->registration->booking_date))); ?>

                                                </td>
                                            <?php else: ?>
                                                <td> <?php echo e(date('d-m-Y', strtotime($property->booking_date))); ?></td>
                                            <?php endif; ?>
                                        <?php else: ?>
                                            <td> <?php echo e(date('d-m-Y', strtotime($property->booking_date))); ?></td>
                                        <?php endif; ?>
                                    </tr>
                                    <tr>
                                        <td style="font-weight: 600;">Schedule Start Date:</td>
                                        <td>
                                            <?php if($property->schedule_start_date): ?>
                                                <?php echo e(date('d-m-Y', strtotime($property->schedule_start_date))); ?>

                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>

            <?php endif; ?>

            <?php if($rebate): ?>

                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Rebate Information</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Dealer</td>
                                        <td><?php echo e($rebate->dealer->name); ?></td>
                                    </tr>

                                    <tr>
                                        <td>Unit #</td>
                                        <td>
                                            <?php if($rebate->property): ?>
                                                <?php if($rebate->property->inventory): ?>
                                                    <?php echo e($rebate->property->inventory->unit_number); ?>

                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Date</td>
                                        <td><?php echo e(date('d-m-Y', strtotime($rebate->date))); ?></td>
                                    </tr>

                                    <tr>
                                        <td>Payment Mode</td>
                                        <?php if($rebate->payment_method == \App\Receipt::cash): ?>
                                            <td>Cash</td>
                                        <?php else: ?>
                                            <td>Bank transfer</td>
                                        <?php endif; ?>

                                    </tr>

                                    <tr>
                                        <td>Gross Amount</td>
                                        <td><?php echo e(number_format($rebate->amount - $rebate->tax_amount)); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Tax Amount</td>
                                        <td><?php echo e(number_format($rebate->tax_amount)); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Net Amount</td>
                                        <td><?php echo e(number_format($rebate->amount)); ?></td>
                                    </tr>

                                    <tr>
                                        <td>Description</td>
                                        <td><?php echo e($rebate->description); ?></td>
                                    </tr>


                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>


            <?php endif; ?>

            <?php if($pending_rebate): ?>

                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Pending Rebate Information</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Dealer</td>
                                        <td><?php echo e($pending_rebate->dealer->name); ?></td>
                                    </tr>

                                    <tr>
                                        <td>Unit #</td>
                                        <td>
                                            <?php if($pending_rebate->property): ?>
                                                <?php if($pending_rebate->property->inventory): ?>
                                                    <?php echo e($pending_rebate->property->inventory->unit_number); ?>

                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </td>
                                    </tr>


                                    <tr>
                                        <td>Rebate </td>
                                        <td><?php echo e(number_format($pending_rebate->amount)); ?></td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>


            <?php endif; ?>

            <?php if($pending_refund): ?>
                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Pending Refund Information</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Project</td>
                                        <td> 
                                            <?php echo e($pending_refund->multiProject?$pending_refund->multiProject->name:'None'); ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Member Name</td>
                                        <td> 
                                            <?php echo e($pending_refund->customer?$pending_refund->customer->name:'None'); ?>

                                        </td>
                                    </tr>

                                    <tr>
                                        <td>Unit #</td>


                                        
                                        <td> 
                                            <?php echo e($pending_refund->property ?  $pending_refund->property->inventory ? $pending_refund->property->inventory->unit_number : '' : ''); ?></td>

                                         
                                    </tr>

                                    
                                    <tr>
                                        <td>Total Refund </td>
                                        <td><?php echo e(number_format($pending_refund->property->unitRefundHistory->total_refund)); ?> PKR</td>
                                    </tr>
                                    <tr>
                                        <td>Total Deduction </td>
                                        <td><?php echo e(number_format($pending_refund->amount)); ?>  PKR</td>
                                    </tr>
                                    
                                    <tr>
                                        <td> Date </td>
                                        <td>  <?php echo e(date('d-m-Y', strtotime($pending_refund->receipt_date))); ?>

                                        </td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            <?php endif; ?>


            <?php if($pending_open_file_package): ?>
                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Dealer Open File Package Buy Detail</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Receipt #</td>
                                        <td> <?php echo e($pending_open_file_package->receipt_no); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Receipt Date</td>
                                        <td> <?php echo e($pending_open_file_package->receipt_date); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Dealer Code</td>
                                        <td> <?php echo e($pending_open_file_package->dealerPackage->dealer->code); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Dealer Name</td>
                                        <td> <?php echo e($pending_open_file_package->dealerPackage->dealer->name); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Package Name</td>
                                        <td> <?php echo e($pending_open_file_package->dealerPackage->package->name); ?></td>
                                    </tr>



                                    <tr>
                                        <td>Receipt Amount </td>
                                        <td><?php echo e($pending_open_file_package->amount); ?> pkr </td>
                                    </tr>




                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            <?php endif; ?>

            <?php if($pending_refund_openfile): ?>
                <div class="col-sm-12">
                    <div class="white-box">
                        <h3 class="box-title">Dealer Open File Unit Buy Detail</h3>
                        <hr>
                        <div class="table-responsive">
                            <table class="table">
                                <tbody>
                                    <tr>
                                        <td>Project</td>
                                        <td> 
                                            <?php echo e($pending_refund_openfile->multiProject?$pending_refund_openfile->multiProject->name:'None'); ?>

                                        </td>
                                        <td>Open File Inventory Number:</td>
                                        <td> 
                                            <?php echo e($pending_refund_openfile->openFileDealerInfo->inventory->unit_number); ?>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Dealer </td>
                                        <td>
                                            <?php echo e($pending_refund_openfile->openFileDealerInfo->dealer->code); ?> ---
                                            <?php echo e($pending_refund_openfile->openFileDealerInfo->dealer->name); ?></td>
                                    </tr>
                                    <tr>
                                        <td>Total Refund </td>
                                        <td><?php echo e(number_format($pending_refund_openfile->openFileDealerInfo->cancelOpenFile->openFileRefunded->total_refund)); ?> PKR</td>
                                    </tr>
                                    <tr>
                                        <td>Total Deduction </td>
                                        <td><?php echo e(number_format($pending_refund_openfile->amount)); ?>  PKR</td>
                                    </tr>
                                    <tr>
                                        <td> Date </td>
                                        <td> <?php echo e(date('d-m-Y', strtotime($pending_refund_openfile->created_at))); ?></td>
                                    </tr>

                                </tbody>
                            </table>
                        </div>

                    </div>
                </div>
            <?php endif; ?>
            <?php if($pending_cancel_closeunit): ?>
            <div class="col-sm-12">
                <div class="white-box">
                    <h3 class="box-title"> Cancel Unit Detail</h3>
                    <hr>
                    <div class="table-responsive">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td>Project</td>
                                    <td> 
                                        <?php echo e($pending_cancel_closeunit->multiProject?$pending_cancel_closeunit->multiProject->name:'None'); ?>

                                    </td>
                                    
                                </tr>
                                <tr>
                                    <td>Unit Number:</td>
                                    <td> 
                                    <?php echo e($pending_cancel_closeunit->property ? ($pending_cancel_closeunit->property->inventory ? $pending_cancel_closeunit->property->inventory->unit_number : '') : ''); ?>

                                          
                                    </td>
                                </tr>
                                <tr>
                                    <td>Payment Method:</td>
                                      
                                        <?php if($pending_cancel_closeunit->payment_method == \App\Receipt::cash): ?>
                                        <td>Cash</td>
                                    <?php elseif($pending_cancel_closeunit->payment_method == \App\Receipt::bank): ?>
                                        <td>Bank</td>
                                    <?php elseif($pending_cancel_closeunit->payment_method == \App\Receipt::adjustment): ?>
                                        <td>Adjustment</td>
                                    <?php elseif($pending_cancel_closeunit->payment_method == \App\Receipt::cheque): ?>
                                        <td>Cheque</td>
                                    <?php elseif($pending_cancel_closeunit->payment_method == \App\Receipt::merging): ?>
                                        <td>Merging</td>
                                    <?php else: ?>
                                        <td></td>
                                    <?php endif; ?>
                                     
                                </tr>

                                <tr>
                                    <td>Received Amount :</td>
                                      
                                    <?php if($pending_cancel_closeunit->tax_paid_by == \App\Receipt::company): ?>
                                    <td><?php echo e(number_format($pending_cancel_closeunit->amount + $pending_cancel_closeunit->tax_amount)); ?> PKR</td>
                                <?php else: ?>
                                    <td><?php echo e(number_format($pending_cancel_closeunit->amount)); ?> PKR</td>
                                <?php endif; ?>
                               
                                     
                               
                            </tr>
                            <tr>
                                <td>Date :</td>

                            <td> <?php echo e(date('d-m-Y', strtotime($pending_cancel_closeunit->receipt_date))); ?></td>
                            </tr>
                             <tr>
                                <td>Status :</td>
                                <?php if($pending_cancel_closeunit->is_approved == true): ?>
                                <td>
                                    <span class="label label-success">
                                        Approved
                                    </span>
                                </td>
                            <?php else: ?>
                                
                                    <td>
                                        <span class="label label-warning">
                                            Pending
                                        </span>
                                    </td>
                                <?php endif; ?>
                             </tr>
                                
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        <?php endif; ?>
        <?php if($pending_cancel_openfile): ?>
        <div class="col-sm-12">
            <div class="white-box">
                <h3 class="box-title"> Cancel Open Unit Detail</h3>
                <hr>
                <div class="table-responsive">
                    <table class="table">
                        <tbody>
                            <tr>
                                <td>Project</td>
                                <td> 
                                    <?php echo e($pending_cancel_openfile->multiProject?$pending_cancel_openfile->multiProject->name:'None'); ?>

                                </td>
                                
                            </tr>
                            <tr>
                                <td>Unit Number:</td>
                                
                                <td><?php echo e($pending_cancel_openfile->openFileDealerInfo ? ($pending_cancel_openfile->openFileDealerInfo->inventory ? $pending_cancel_openfile->openFileDealerInfo->inventory->unit_number : '') : ''); ?>

                                </td>

                            </tr>
                            <tr>
                                <td>Payment Method:</td>
                                  
                                <?php if($pending_cancel_openfile->payment_method == \App\Receipt::cash): ?>
                                <td>Cash</td>
                            <?php elseif($pending_cancel_openfile->payment_method == \App\Receipt::bank): ?>
                                <td>Bank</td>
                            <?php elseif($pending_cancel_openfile->payment_method == \App\Receipt::adjustment): ?>
                                <td>Adjustment</td>
                            <?php elseif($pending_cancel_openfile->payment_method == \App\Receipt::cheque): ?>
                                <td>Cheque</td>
                            <?php elseif($pending_cancel_openfile->payment_method == \App\Receipt::merging): ?>
                                <td>Merging</td>
                            <?php else: ?>
                                <td></td>
                            <?php endif; ?>
                                 
                            </tr>

                            <tr>
                                <td>Received Amount :</td>
                                  
                                <?php if($pending_cancel_openfile->tax_paid_by == \App\Receipt::company): ?>
                                <td><?php echo e(number_format($pending_cancel_openfile->amount + $pending_cancel_openfile->tax_amount)); ?> PKR</td>
                            <?php else: ?>
                                <td><?php echo e(number_format($pending_cancel_openfile->amount)); ?> PKR</td>
                            <?php endif; ?>
                           
                        </tr>
                        <tr>
                            <td>Date :</td>

                            <td> <?php echo e(date('d-m-Y', strtotime($pending_cancel_openfile->receipt_date))); ?></td>
                                                  
                        </tr>
                         <tr>
                            <td>Status :</td>
                            <?php if($pending_cancel_openfile->is_approved == true): ?>
                            <td>
                                <span class="label label-success">
                                    Approved
                                </span>
                            </td>
                        <?php else: ?>
                            
                                <td>
                                    <span class="label label-warning">
                                        Pending
                                    </span>
                                </td>
                            <?php endif; ?>
                         </tr>
                            
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    <?php endif; ?>



            <div class="col-md-12">
                <div class="panel panel-info">
                    <div class="panel-heading">Make Voucher</div>
                  
                    <div class="panel-wrapper collapse in" aria-expanded="true">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('isSuperAdmin')): ?>
                        <?php echo $__env->make('partial.multiproject_forinsert', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                        <?php endif; ?>
                        <div class="panel-body" style="    margin-bottom: 36px;">


                            <hr>
                            <form id="form-div">

                                <?php echo e(csrf_field()); ?>


                                <?php if($transaction_type == \App\GeneralJournalEntry::booking): ?>
                                    <b>Voucher Type</b> &nbsp;&nbsp;&nbsp;<input disabled="" type="radio"
                                        name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::BPV); ?>" required=""> BPV
                                    &nbsp;&nbsp;&nbsp; <input disabled="" type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::CPV); ?>" required=""> CPV &nbsp;&nbsp;&nbsp;
                                    <input disabled="" type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::BRV); ?>" required=""> BRV &nbsp;&nbsp;&nbsp;
                                    <input disabled="" type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::CRV); ?>" required=""> CRV
                                    &nbsp;&nbsp;&nbsp;
                                    <input type="radio" checked="" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::JV); ?>" required=""> JV &nbsp;&nbsp;&nbsp;
                                <?php elseif($transaction_type == \App\GeneralJournalEntry::receipt): ?>
                                    <b>Voucher Type</b> &nbsp;&nbsp;&nbsp;<input disabled="" type="radio"
                                        name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::BPV); ?>"> BPV
                                    &nbsp;&nbsp;&nbsp; <input disabled="" type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::CPV); ?>"> CPV &nbsp;&nbsp;&nbsp; <input
                                        type="radio" name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::BRV); ?>">
                                    BRV &nbsp;&nbsp;&nbsp; <input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::CRV); ?>"> CRV &nbsp;&nbsp;&nbsp;
                                    <input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::JV); ?>"> JV &nbsp;&nbsp;&nbsp;
                                <?php elseif(
                                    $transaction_type == \App\GeneralJournalEntry::bill ||
                                        $transaction_type == \App\GeneralJournalEntry::payment ||
                                        $transaction_type == \App\GeneralJournalEntry::massPayment): ?>
                                    <b>Voucher Type</b> &nbsp;&nbsp;&nbsp;<input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::BPV); ?>"> BPV &nbsp;&nbsp;&nbsp; <input
                                        type="radio" name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::CPV); ?>">
                                    CPV &nbsp;&nbsp;&nbsp; <input disabled="" type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::BRV); ?>"> BRV &nbsp;&nbsp;&nbsp; <input
                                        type="radio" name="voucher_type" disabled=""
                                        value="<?php echo e(\App\GeneralJournalEntry::CRV); ?>"> CRV &nbsp;&nbsp;&nbsp;
                                    <input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::JV); ?>"> JV &nbsp;&nbsp;&nbsp;
                                <?php else: ?>
                                    <b>Voucher Type</b> &nbsp;&nbsp;&nbsp;<input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::BPV); ?>"> BPV &nbsp;&nbsp;&nbsp;<input
                                        type="radio" name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::CPV); ?>">
                                    CPV &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::BRV); ?>"> BRV &nbsp;&nbsp;&nbsp; <input
                                        type="radio" name="voucher_type" value="<?php echo e(\App\GeneralJournalEntry::CRV); ?>">
                                    CRV &nbsp;&nbsp;&nbsp; <input type="radio" name="voucher_type"
                                        value="<?php echo e(\App\GeneralJournalEntry::JV); ?>"> JV &nbsp;&nbsp;&nbsp;
                                <?php endif; ?>


                                <br><br>
                                <input type="hidden" id="transaction_id" name="transaction_id"
                                    value="<?php echo e($transaction_id); ?>">

                                <input type="hidden" id="transaction_type" name="transaction_type"
                                    value="<?php echo e($transaction_type); ?>">

                                
                                <br><br>
                                <div class="row">

                                    <div class="col-md-5">
                                        Bank Name &nbsp;&nbsp;<input style="background-color: #f7fafc; width: 400px;" type="text"
                                            name="bank_name" id="bank_name">

                                    </div>

                                    <div class="col-md-5">
                                        Ins. # &nbsp;&nbsp;<input style="background-color: #f7fafc;  width: 400px;" type="text"
                                            id="cheaque_no" name="cheaque_no" style="width: 400px;">

                                    </div>

                                </div>

                                <br><br>

                                <div class="row">
                                    <div class="col-md-5">
                                        DATE &nbsp;&nbsp;<input style="background-color: #f7fafc; width: 400px; margin-left: 40px;" type="date"
                                            id="date" name="date" value="<?php echo date('Y-m-d'); ?>">

                                    </div>






                                    <div class="col-md-3">
                                        <input type="checkbox" style="background-color: #f7fafc;" name="adjusting_entry"
                                            id="adjusting_entry" value="1"> &nbsp;&nbsp;ADJUSTING ENTRY
                                    </div>

                                    <br>

                                    <br> <br>

                                    <div class=col-md-12 style="overflow-y:auto;height:381px;">
                                        <table class="table table-bordered table-responsive-md table-striped text-center">
                                            <thead>
                                                <tr>

                                                    <th class="text-center">ACCOUNT</th>
                                                    <th class="text-center">DEBIT</th>
                                                    <th class="text-center">CREDIT</th>

                                                    <th class="text-center">NAME</th>


                                                </tr>

                                            </thead>
                                            <tbody id="tbody_data">
                                                <?php for($i =0 ; $i<10; $i++) {?>
                                                <tr height="2px" id="account_tr_<?php echo e($i); ?>"
                                                    data-id="<?php echo e($i); ?>">

                                                    <td class="pt-3-half account" style="width: 40%"
                                                        contenteditable="true">


                                                        <select class="form-control chosen-select us_acnt"
                                                            style="width: 80%;height: 26px;font-size: 11px;padding: 0px;padding-left: 18px;cursor: pointer;"
                                                            name="account[]">
                                                            <option value="0">None</option>
                                                            <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <?php if($leafAccount[$a->id]): ?>
                                                                    <?php if($a->sub_account_id): ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>">
                                                                            &nbsp;&nbsp;&nbsp;<?php echo e($a->number); ?> -
                                                                            <?php echo e($a->name); ?></option>
                                                                    <?php else: ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>">
                                                                            <?php echo e($a->number); ?> - <?php echo e($a->name); ?>

                                                                        </option>
                                                                    <?php endif; ?>
                                                                <?php else: ?>
                                                                    <?php if($a->sub_account_id): ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>" disabled="">
                                                                            &nbsp;&nbsp;&nbsp;<?php echo e($a->number); ?> -
                                                                            <?php echo e($a->name); ?></option>
                                                                    <?php else: ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>" disabled="">
                                                                            <?php echo e($a->number); ?> - <?php echo e($a->name); ?>

                                                                        </option>
                                                                    <?php endif; ?>
                                                                <?php endif; ?>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </td>
                                                    <td class="pt-3-half debit" onfocusout="return setZeroBydefault(this)"
                                                        onkeyup="addDebit(this)" contenteditable="true">0</td>
                                                    <td class="pt-3-half credit"
                                                        onfocusout="return setZeroBydefault(this)"
                                                        onkeyup="addCredit(this)" contenteditable="true">0</td>


                                                    <td class="pt-3-half name" contenteditable="true">
                                                        <select class="form-control chosen-select"
                                                            style="    width: 80%;height: 26px;font-size: 11px;padding: 0px;padding-left: 18px;cursor: pointer;"
                                                            name="name1[]">
                                                            <option value="0">None</option>
                                                            <?php $__currentLoopData = $names; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $n): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option style="font-size: 11px;"
                                                                    value="<?php echo e($n->id); ?>"><?php echo e($n->name); ?>

                                                                </option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                        </select>
                                                    </td>

                                                    <td class="pt-3-half name">
                                                        <button type="button"
                                                            class="btn btn-sm btn-success btn-sm addRowBtn"
                                                            data-id="<?php echo e($i); ?>" onclick="addNewRow(this)"><i
                                                                class="fa fa-plus"></i></button>
                                                        <button type="button" class="btn btn-sm btn-danger btn-sm"
                                                            onclick="removeParentDiv(this)"><i
                                                                class="fa fa-times"></i></button>
                                                    </td>

                                                </tr>

                                                <tr id="narration_tr_<?php echo e($i); ?>"
                                                    class="tr_<?php echo e($i); ?>">
                                                    <td colspan="4"
                                                        style="text-align: center;width: 90%; padding-left:50px;padding-right:30px">
                                                        <input class="form-control h30" type="text"
                                                            name="line_narration[]" id="line_narration[]"
                                                            placeholder="Line Narration">
                                                    </td>
                                                </tr>

                                                <?php } ?>



                                                <tr height="2px" id="account_tr_<?php echo e($i + 1); ?>"
                                                    data-id="<?php echo e($i + 1); ?>" style="display:none;">

                                                    <td class="pt-3-half account" style="width: 40%"
                                                        contenteditable="true">


                                                        <select class="form-control chosen-select us_acnt"
                                                            style="width: 80%;height: 26px;font-size: 11px;padding: 0px;padding-left: 18px;cursor: pointer;"
                                                            name="account[]">
                                                            <option value="0">None</option>
                                                            <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $a): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <?php if($leafAccount[$a->id]): ?>
                                                                    <?php if($a->sub_account_id): ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>">
                                                                            &nbsp;&nbsp;&nbsp;<?php echo e($a->number); ?> -
                                                                            <?php echo e($a->name); ?></option>
                                                                    <?php else: ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>">
                                                                            <?php echo e($a->number); ?> - <?php echo e($a->name); ?>

                                                                        </option>
                                                                    <?php endif; ?>
                                                                <?php else: ?>
                                                                    <?php if($a->sub_account_id): ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>" disabled="">
                                                                            &nbsp;&nbsp;&nbsp;<?php echo e($a->number); ?> -
                                                                            <?php echo e($a->name); ?></option>
                                                                    <?php else: ?>
                                                                        <option style="font-size: 11px;"
                                                                            value="<?php echo e($a->id); ?>" disabled="">
                                                                            <?php echo e($a->number); ?> - <?php echo e($a->name); ?>

                                                                        </option>
                                                                    <?php endif; ?>
                                                                <?php endif; ?>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </td>
                                                    <td class="pt-3-half debit" onfocusout="return setZeroBydefault(this)"
                                                        onkeyup="addDebit(this)" contenteditable="true"></td>
                                                    <td class="pt-3-half credit"
                                                        onfocusout="return setZeroBydefault(this)"
                                                        onkeyup="addCredit(this)" contenteditable="true"></td>


                                                    <td class="pt-3-half name" contenteditable="true">
                                                        <select class="form-control chosen-select name1"
                                                            style="width: 80%;height: 26px;font-size: 11px;padding: 0px;padding-left: 18px;cursor: pointer;">
                                                            <option value="0">None</option>
                                                            <?php $__currentLoopData = $names; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $n): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option style="font-size: 11px;"
                                                                    value="<?php echo e($n->id); ?>"><?php echo e($n->name); ?>

                                                                </option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                        </select>
                                                    </td>

                                                    <td class="pt-3-half name">
                                                        <button type="button"
                                                            class="btn btn-sm btn-success btn-sm  addRowBtn"
                                                            onclick="addNewRow(this)"><i class="fa fa-plus"></i></button>
                                                        <button type="button" class="btn btn-sm btn-danger btn-sm"
                                                            onclick="removeParentDiv(this)"><i
                                                                class="fa fa-times"></i></button>
                                                    </td>

                                                </tr>

                                                <tr id="narration_tr_<?php echo e($i + 1); ?>" style="display:none;">
                                                    <td colspan="4"
                                                        style="text-align: center;width: 90%; padding-left:50px;padding-right:30px">
                                                        <input class="form-control h30 line_narration" type="text"
                                                            id="line_narration[]" placeholder="Line Narration">
                                                    </td>
                                                </tr>

                                            </tbody>
                                        </table>
                                    </div>
                                    <table class="table">
                                        <tr>
                                            <th style="text-align: right;width: 41%;">Totals</th>
                                            <th style="text-align: center; width: 17%; font-size: 16px;font-weight: 600;"
                                                id="debit-total">0</th>
                                            <th style="text-align: center;width: 16%; font-size: 16px; font-weight: 600;"
                                                id="credit-total">0</th>
                                            <th></th>
                                            <th></th>
                                        </tr>
                                    </table>

                                    <div class="col-md-4">
                                        Narration : &nbsp;&nbsp;
                                        <textarea class="form-control" name="memo" id="memo"></textarea>
                                    </div>



                                    <div class="form-actions">

                                        <button style="float: right;margin-right: 20px;" type="button"
                                            class="btn btn-success search-customer" id="search" disabled=""> <i
                                                class="fa fa-check"></i> Save </button>

                                        <!--<button style="float: right;margin-right: 20px;" type="button" class="btn btn-info" onclick="return addNewRow(this)"> <i class="fa fa-plus" ></i> Add </button>-->


                                    </div>
                            </form>


                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--./row-->




    </div>
    <!-- /.container-fluid -->

<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>

    <script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>

    <script>
        function removeParentDiv(self) {
            var id = $(self).closest('tr').data("id");

            $('#account_tr_' + id).remove()
            $('#narration_tr_' + id).remove()
        }

        $('.us_acnt').on('change', function() {

            if (($(this).closest('tr').find('.debit').html() > 0 || $(this).closest('tr').find('.credit').html() >
                    0) && $(this).val() == 0) {
                $("#search").prop("disabled", true);
            } else if (($(this).closest('tr').find('.debit').html() > 0 || $(this).closest('tr').find('.credit')
                    .html() > 0) && $(this).val() > 0) {
                $("#search").prop("disabled", false);
            }


            if (($('#debit-total').html() > 0 && $('#credit-total').html() > 0) && ($('#credit-total').html() != $(
                    '#debit-total').html())) {
                $("#search").prop("disabled", true);
            }


        });




        function addNewRow(self) {
            $(".chosen-select").chosen("destroy");

            var narration_row = $('#narration_tr_<?php echo e($i + 1); ?>').html();
            var account_row = $('#account_tr_<?php echo e($i + 1); ?>').html();
            var rand_id = Math.floor(Math.random() * 100);
            var tr_id = $(self).data("id");

            $('.tr_' + tr_id).after('<tr  id="account_tr_' + rand_id + '"  data-id="' + rand_id + '" >' + account_row +
                '</tr> <tr id="narration_tr_' + rand_id + '"   class="tr_' + rand_id + '">' + narration_row + '</tr>');
            $("#account_tr_" + rand_id).find('.debit').text(0)
            $("#account_tr_" + rand_id).find('.credit').text(0)
            $("#account_tr_" + rand_id).find('.name1').attr('name', 'name1[]');
            $("#account_tr_" + rand_id).find('.addRowBtn').data('id', rand_id);
            $("#narration_tr_" + rand_id).find('.line_narration').attr('name', 'line_narration[]');

            $("#narration_tr_" + rand_id).show();
            $("#account_tr_" + rand_id).show();

            $(".chosen-select").chosen();

            return false;
        }

        $(function() {
            $('#myTable').DataTable({
                'pageLength': 50,
                'ordering': false,
            });
        });

        function setZeroBydefault(self) {
            if ($(self).text().length == 0) {
                $(self).text('0');
            }
        }

        const year = new Date().getFullYear();

        const this_fiscal_year_start_date = new Date(year + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_START); ?> + '-01');

        const this_fiscal_year_end_date = new Date((year + 1) + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_END); ?> + '-30');

        const last_fiscal_year_start_date = new Date((year - 1) + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_START); ?> +
            '-01');

        const last_fiscal_year_end_date = new Date(year + '-' + <?php echo e(\App\ChartOfAccount::FISCAL_YEAR_END); ?> + '-30');




        $('#daterange-btn').daterangepicker({
                ranges: {
                    'Today': [moment(), moment()],
                    'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                    'This Month': [moment().startOf('month'), moment().endOf('month')],
                    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf(
                        'month')],
                    'This Fiscal Year': [this_fiscal_year_start_date, this_fiscal_year_end_date],
                    'Last Fiscal Year': [last_fiscal_year_start_date, last_fiscal_year_end_date]
                },
                startDate: moment().subtract(29, 'days'),
                endDate: moment()
            },
            function(start, end) {
                $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
            }
        );

        $('.update-record').on('click', function() {

            $('.preloader').fadeIn();

            date_range = $('#daterange-btn').val();
            account = $('#c_account').val();
            name = $('#c_name').val();


            var data = {
                'date_range': date_range,
                'account': account,
                'name': name
            };
            $.get('/general-journal-entries/update-entries', data, function(data) {
                document.getElementById('update-table').innerHTML = data;

                $('#myTable').DataTable({
                    'paging': false,
                    'searching': false,
                    'info': true
                });
                toastr.success("Report updated.");
            });

            $('.preloader').fadeOut();
        });


        window.setInterval(function() {

            $('.debit').each(function() {
                if (this.innerHTML === "") {
                    this.innerHTML = 0;
                }
            });


            $('.credit').each(function() {
                if (this.innerHTML === "") {
                    this.innerHTML = 0;
                }
            });


            $('.line_narration').each(function() {
                if (!$(this).attr("name")) {
                    $(this).attr('name', 'line_narration[]')
                }
            });


            $('.name1').each(function() {
                if (!$(this).attr("name")) {
                    $(this).attr('name', 'name1[]')
                }
            });


            $('#account_tr_<?php echo e($i + 1); ?>').find('.name1').removeAttr('name', 'name1[]');
            $('#narration_tr_<?php echo e($i + 1); ?>').find('.line_narration').removeAttr('name', 'line_narration[]');


        }, 1000);

        function addDebit() {
            sum = 0;
            $response = 1;
            $('.debit').each(function() {
                if (this.innerHTML) {
                    sum += parseInt(this.innerHTML);
                }
            });
            document.getElementById('debit-total').innerHTML = sum;
            if ($(self).closest('tr').find('.us_acnt').val() == 0) {
                $response = 0;
            }


            if ($response == 1) {
                checkTotal();
            } else {
                $("#search").prop("disabled", true);
            }
        }

        function addCredit() {
            sum = 0;
            $response = 1;
            $('.credit').each(function() {
                if (this.innerHTML) {
                    sum += parseInt(this.innerHTML);
                }
            });
            document.getElementById('credit-total').innerHTML = sum;

            if ($(self).closest('tr').find('.us_acnt').val() == 0) {
                $response = 0;
            }


            if ($response == 1) {
                checkTotal();
            } else {
                $("#search").prop("disabled", true);
            }
        }

        function checkTotal() {

            debit = parseInt(document.getElementById('debit-total').innerHTML);
            credit = parseInt(document.getElementById('credit-total').innerHTML);
            if (debit == credit) {
                $("#search").prop("disabled", false);

                document.getElementById('debit-total').style.color = 'black';
                document.getElementById('credit-total').style.color = 'black';
                $("#update").prop("disabled", false);
            } else {
                $("#search").prop("disabled", true);

                document.getElementById('debit-total').style.color = 'red';
                document.getElementById('credit-total').style.color = 'red';
                $("#update").prop("disabled", false);
            }

        }

        $('#search').click(function() {

            document.getElementById("search").disabled = true;

            date = $('#date').val();

            adjusting_entry = 0;
            if ($('#adjusting_entry').prop("checked") == true) {
                adjusting_entry = 1;
            }
            account = [];
            $('select[name="account[]"]').each(function() {
                if ($(this).val() != 0)
                    account.push($(this).val());

            });

            name1 = [];
            $('select[name="name1[]"]').each(function() {
                name1.push($(this).val());

            });

            class_id = [];
            $('select[name="class_id[]"]').each(function() {
                class_id.push($(this).val());

            });

            debit = [];
            $('.debit').each(function() {
                if (this.innerHTML) {
                    debit.push(parseInt(this.innerHTML));
                }
            });

            credit = [];
            $('.credit').each(function() {
                if (this.innerHTML) {
                    credit.push(parseInt(this.innerHTML));
                }
            });

            memo = $('#memo').val();

            var line_narration = $("input[name='line_narration[]']")
                .map(function() {
                    return $(this).val();
                }).get();

            voucher_type = $("input[type='radio'][name='voucher_type']:checked").val();

            if (!voucher_type) {
               
                Swal.fire({
                    icon: 'error',
                    title: 'Oops...',
                    text: 'Voucher type required!',
                   
                })
                document.getElementById("search").disabled = false;

                return false;

            }

            transaction_id = $('#transaction_id').val();
            transaction_type = $('#transaction_type').val();

            bank_name = $('#bank_name').val();
            cheaque_no = $('#cheaque_no').val();
            multi_project_id = $('#multipro').val();
            // if (!multi_project_id) {
            //     Swal.fire({
            //         icon: 'error',
            //         title: 'Oops...',
            //         text: 'Please Select Project first!',
                   
            //     })

            //     return false;

            // }

            data = {
                "_token": "<?php echo e(csrf_token()); ?>",
                'date': date,
                'adjusting_entry': adjusting_entry,
                'account': account,
                'debit': debit,
                'credit': credit,
                'memo': memo,
                'name': name1,
                'class_id': class_id,
                'voucher_type': voucher_type,
                'transaction_id': transaction_id,
                'transaction_type': transaction_type,
                'bank_name': bank_name,
                'cheaque_no': cheaque_no,
                'line_narration': line_narration,
                'multipro_id':multi_project_id
            };

           
            $.post('/general-journal-entries/create-vouchers', data)
    .done(function(data) {
        // Success callback function
        if(data.success == false){
                    Swal.fire({
                    icon: 'error',
                    title: 'Oops...',
                    text: "Please Select Project first",
                   
                });
                document.getElementById("search").disabled = false;

                }
                else{
if (data == 'date_error') {
                    toastr.error("Invalid date!");
                    document.getElementById("search").disabled = false;
                } else {

                    toastr.success("Entry added successfully.");

                    window.location.href = '/general-journal-entries/voucher-detail/' + data.entry_no;
                }
                }

               

                
    })
    .fail(function(jqXHR, textStatus, errorThrown) {
        // Error callback function
        
            Swal.fire({
                icon: 'error',
                title: 'Oops...',
                text: 'An error occurred:',
            });
        
    });

        });
        // $('#search').click(function() {

        //     document.getElementById("search").disabled = true;

        //     date = $('#date').val();
        //     var documents = $('#documents').prop('files').length;


        //     adjusting_entry = 0;
        //     if ($('#adjusting_entry').prop("checked") == true) {
        //         adjusting_entry = 1;
        //     }
        //     account = [];
        //     $('select[name="account[]"]').each(function() {
        //         if ($(this).val() != 0)
        //             account.push($(this).val());
        //     });
        //     name1 = [];
        //     $('select[name="name1[]"]').each(function() {
        //         name1.push($(this).val());
        //     });

        //     class_id = [];
        //     $('select[name="class_id[]"]').each(function() {
        //         class_id.push($(this).val());
        //     });

        //     debit = [];
        //     $('.debit').each(function() {
        //         if (this.innerHTML) {
        //             debit.push(parseInt(this.innerHTML));
        //         }
        //     });

        //     credit = [];
        //     $('.credit').each(function() {
        //         if (this.innerHTML) {
        //             credit.push(parseInt(this.innerHTML));
        //         }
        //     });

        //     memo = $('#memo').val();

        //     var line_narration = $("input[name='line_narration[]']")
        //         .map(function() {
        //             return $(this).val();
        //         }).get();

        //     voucher_type = $("input[type='radio'][name='voucher_type']:checked").val();

        //     if (!voucher_type) {
        //         alert('voucher type required.');
        //         document.getElementById("search").disabled = false;
        //         return false;
        //     }

        //     transaction_id = $('#transaction_id').val();
        //     transaction_type = $('#transaction_type').val();
        //     bank_name = $('#bank_name').val();
        //     cheaque_no = $('#cheaque_no').val();


        //     var formData = new FormData($('#form-div')[0]);

        //     for (var i = 0; i < documents; i++) {
        //         formData.append(i, $('#documents').prop('files')[i]);
        //     }

        //     formData.append('date', date);
        //     formData.append('adjusting_entry', adjusting_entry);
        //     formData.append('account', account);
        //     formData.append('debit', debit);
        //     formData.append('credit', credit);
        //     formData.append('memo', memo);
        //     formData.append('name', name1);
        //     formData.append('class_id', class_id);
        //     formData.append('voucher_type', voucher_type);
        //     formData.append('transaction_id', transaction_id);
        //     formData.append('transaction_type', transaction_type);
        //     formData.append('bank_name', bank_name);
        //     formData.append('line_narration', line_narration);
        //     formData.append('cheaque_no', cheaque_no);
        //     formData.append('file_length', documents);


        //     $.ajax({
        //         type: 'POST',
        //         url: '/general-journal-entries/create-vouchers',
        //         cache: false,
        //         processData: false,
        //         contentType: false,
        //         data: formData,
        //         success: function(data) {
        //             if (data == 'date_error') {
        //                 toastr.error("Invalid date!");
        //                 document.getElementById("search").disabled = false;
        //             } else if (data == 'invalid_document') {
        //                 toastr.error("Invalid Document Type");
        //                 document.getElementById("search").disabled = false;
        //             } else {

        //                 toastr.success("Entry added successfully.");

        //                 window.location.href = '/general-journal-entries/voucher-detail/' + data
        //                     .entry_no;
        //             }
        //         }
        //     });

        // });
    </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\erpv7\resources\views/general-entry/create-voucher.blade.php ENDPATH**/ ?>