
<?php $__env->startSection('title', __('E-Way Bill')); ?>

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

    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1><?php echo e(__('E-Way Bill'), false); ?></h1>
    </section>


    <style>
    select {
        width: 40%; 
        border-radius: 5px; 
        border: 1px solid #ccc; 
        background-color: #f9f9f9; 
        color: #333; 
        font-size: 14px; 

    /* Hover effect */
    select:hover {
        border-color: #888; 
    }

    select:focus {
        outline: none; 
        border-color: #4a90e2; 
    }
    </style>
     <!-- Main content -->
     <section class="content">
        <div class="row">
            <div class="col-md-12">
                <table class="table">
                    <thead>
                        <tr>
                            <th colspan="18" class="table_3">
                                <span>E-Way Bill System</span></br>
                                <span class="Hedding_text">E-Way Bill System</span></br>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="gstr_1_head">
                            <th colspan="6" class="dateSet" id="dateSet"><img src="<?php echo e(asset('img/dummy.jpg'), false); ?>" alt="Dummmy" height="15%" width="15%"></th>
                        </tr>
                        <tr class="gstr_1_head">
                            <th class="text-center col-4">Customer Name</th>    
                            <td class="text-center">Tirth Electronics</td>
                        </tr>


                        <tr class="gstr_1_head">
                            <th class="text-center col-4">Invoice Number</th>
                            <td class="text-center">
                                <select id="invoiceNumber" value="Select Invoice Number">
                                    <?php $__currentLoopData = $invoiceNumbers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($item, false); ?>"><?php echo e($item, false); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </td>
                        </tr>
                        
                    </tbody>
                </table>
                <div class="text-center">
                    <button type="button" class="WayBill btn btn-danger">Genrate E-Way Bill</button>
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->


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

<?php $__env->startSection('javascript'); ?>
    <script src="<?php echo e(asset('js/report.js?v=' . $asset_v), false); ?>"></script>
<script>
  document.addEventListener('DOMContentLoaded', function() {
    const urlParams = new URLSearchParams(window.location.search);
    const invoiceNo = urlParams.get('invoice_no');
    
    const selectDropdown = document.querySelector('.gstr_1_head select');
    if (invoiceNo) {
        selectDropdown.value = invoiceNo;
    }
    selectDropdown.addEventListener('change', function() {
        const selectedInvoiceNumber = this.value;
        const baseUrl = window.location.origin + window.location.pathname;
        const newUrl = `${baseUrl}?invoice_no=${selectedInvoiceNumber}`;
        window.location.href = newUrl;
    });
});


</script>

<script>
  document.querySelector('.btn-danger').addEventListener('click', generateEWayBill);

function generateEWayBill() {
    // Retrieve the selected invoice number from the dropdown menu
    const selectedInvoiceNumber = document.getElementById('invoiceNumber').value;

    const url = 'https://gstsandbox.charteredinfo.com/ewaybillapi/dec/v1.03/ewayapi?action=GENEWAYBILL';
    const headers = {
        'aspid': '1755272424',
        'password': 'HELLO@123123',
        'gstin': '34AACCC1596Q002',
        'username': 'TaxProEnvPON',
        'authtoken': 'P7Zr8wR5MDXxKM31yZ500jHVW',
        'Content': 'application/json',
        'Content-Type': 'application/json'
    };

    const data = {
        supplyType: 'O',
        subSupplyType: '1',
        subSupplyDesc: 'Transaction',
        docType: 'INV',
        // Use the selected invoice number as the document number
        docNo: selectedInvoiceNumber,
        docDate: '02/11/2020',
        fromGstin: '34AACCC1596Q002',
        fromTrdName: 'welton',
        fromAddr1: '4-9-35, GROUND,1ST, 2ND FLOOR, AURANGPURA',
        fromAddr2: 'GROUND FLOOR OSBORNE ROAD',
        fromPlace: 'FRAZER TOWN',
        fromPincode: 605001,
        actFromStateCode: 34,
        fromStateCode: 34,
        toGstin: '29AACCC1596Q000',
        toTrdName: 'sthuthya',
        toAddr1: 'Shree Nilaya',
        toAddr1: 'GODOWN NO 5 GAT NO 1214/1230',
        toPlace: 'Beml Nagar',
        toPincode: 562160,
        actToStateCode: 29,
        toStateCode: 29,
        transactionType: 4,
        otherValue: '-100',
        totalValue: 0,
        cgstValue: 0,
        sgstValue: 0,
        igstValue: 0,
        cessValue: 0,
        cessNonAdvolValue: 400,
        totInvValue: 0,
        transporterId: '',
        transporterName: '',
        transDocNo: 'DOC/123',
        transMode: '1',
        transDistance: '0',
        transDocDate: '06/05/2022',
        vehicleNo: 'PVC1234',
        vehicleType: 'R',
        itemList: [{
            productName: 'BLAZER-1',
            productDesc: 'BLAZER-1',
            hsnCode: 4421,
            quantity: 25,
            qtyUnit: 'NOS',
            cgstRate: 0,
            sgstRate: 0,
            igstRate: 3,
            cessRate: 3,
            cessNonadvol: 0,
            taxableAmount: 5609889
        }]
    };

    fetch(url, {
        method: 'POST',
        headers: headers,
        body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(data => {
        console.log('E-Way Bill generated successfully:', data);
        // Handle the response data as needed
    })
    .catch(error => {
        console.error('Error generating E-Way Bill:', error);
        // Handle errors as needed
    });
}

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/aror4382/eway-einvoice.netbas.in/resources/views/report/genrate-ewaybill.blade.php ENDPATH**/ ?>