EVOLUTION-NINJA
Edit File: invoice_print.php
<html> <head> <script type="text/javascript" src="<?php echo base_url('public/assets/admin_dashboard/js/jquery.min.js');?>"></script> <script type="text/javascript" src="<?php echo base_url('public/assets/admin_dashboard/js/bootstrap.min.js');?>"></script> </head> <body style="width:700px;display:block;margin:auto;"> <div class="row print_div" id="print_div"> <div style="text-align:center;" class="part_one"> <?php if (!empty($details) && isset($details->holder_name)) { ?> <?php if ($details->holder_name == 'GSS') { ?> <h3>GSS PROJECT CONSULTANTS PVT LTD</h3> <p>REGD OFF: 407, 8TH B MAIN, JAYANAGAR 4TH BLOCK, BANGALORE-560011</p> <p>GSTIN :29AAACG3912G1ZT</p> <?php } else { ?> <h3><?php echo htmlspecialchars($details->holder_name); ?></h3> <p><?php echo htmlspecialchars($details->holder_address ?? 'Address Not Available'); ?></p> <p>PAN NO: <?php echo htmlspecialchars($details->pan_no ?? 'PAN Not Available'); ?></p> <?php } ?> <?php } else { ?> <p>No invoice details found.</p> <?php } ?> <h2 style='text-transform:uppercase'><?php if(!empty($details)) { echo $details->invoice_type ;}?></h2> </div> <?php if (date('m') <= 3) {//Upto June 2014-2015 $financial_year = (date('y')-1) . '-' . date('y'); } else {//After June 2015-2016 $financial_year = date('y') . '-' . (date('y') + 1); } ?> <div class="part_two"> <table> <tr> <td style="width:75%;">Date:<?php $date= new DateTime('now', new DateTimeZone('Asia/Kolkata')); $today= $date->format('d-m-Y'); echo $today; ?></td> <td style="width:25%;">Invoice No: GSS/<?php echo $financial_year;?>/<?php if(!empty($details->invoice_number)) { echo $details->invoice_number; } else { ?> <input type="text" class="incoice_no" name="incoice_no" id="invoice_no_input" placeholder="...." style="outline: none; border: none;width: 105px;"> <?php }?></td> </tr> <tr> <td>To: <?php if(!empty($details)) { echo $details->invoice_to ;}?></td> <td></td> <td></td> </tr> </table> </div> <div class="part_three"> <table style="border: 1px solid black;border-collapse: collapse;"> <tr> <th style="width:15%;border: 1px solid black;border-collapse: collapse;">SI.No</th> <th style="width:40%;border: 1px solid black;border-right: none !important;border-collapse: collapse;">Particulars</th> <th style="width:20%;border: 1px solid black;border-left: none !important;border-collapse: collapse;"></th> <th style="width:25%;border: 1px solid black;border-collapse: collapse;">Amount</th> </tr> <tr> <td style="text-align:center;">1</td> <td style="padding:0 5px;" colspan="2"> Commission for providing professional services in marketing, follow-ups, and other allied services for Project <?php if (!empty($details) && isset($details->project_name)) { echo htmlspecialchars($details->project_name); } else { echo 'Project name not available'; } ?> <br> Site Nos. <?php if (!empty($details) && isset($details->site_numbers)) { $decode_sites = json_decode($details->site_numbers); if (is_array($decode_sites) && !empty($decode_sites)) { foreach ($decode_sites as $value) { if (!empty($value)) { echo htmlspecialchars($value) . ' '; } } } else { echo 'No site numbers available'; } } else { echo 'Site numbers not available'; } ?> </td> <td></td> </tr> <tr style="height:50px;"> <td></td> <td style="padding:0 5px;" colspan="1">Total Sqft</td> <td style="padding:0 5px;" colspan="1"><?php if(!empty($details)) { echo $details->total_sqft;}?></td> <td style="text-align:right;" colspan="1"><?php if(!empty($details)) { echo $details->without_gst_total_amt;}?></td> </tr> <!--<tr style="height:50px;"> <td></td> <td style="padding:0 5px;" colspan="1">Rate Per Sqft</td> <td style="padding:0 5px;" colspan="2"><?php if(!empty($details)) { echo $details->rate_per_sqft;}?></td> </tr> --><!--<tr> <td></td> <td></td> <td style="padding:0 5px;" colspan="0">Amount</td> <td style="text-align:right;padding:0 5px;"><?php if(!empty($details)) { echo $details->without_gst_total_amt;}?></td> </tr>--> <tr> <td></td> <td></td> <td>CGST @ <?php if(!empty($details)) { echo $details->cgst;}?> %</td> <td style="text-align:right;padding:0 5px; border-top: 1px solid #000;"> <?php if(!empty($details)) { echo $details->total_cgst;}?></td> </tr> <tr> <td></td> <td></td> <td>SGST @ <?php if(!empty($details)) { echo $details->sgst;}?> %</td> <td style="text-align:right;padding:0 5px;"><?php if(!empty($details)) { echo $details->total_sgst;}?></td> </tr> <tr> <td></td> <td></td> <td style="text-align:right;">Total Rs.</td> <td style="text-align:right;padding:5px 5px; border-top: 1px solid #000;"><?php if(!empty($details)) { echo round($details->with_gst_total_amt);}?></td> </tr> </table> <p>(Rupees <span id="word"></span> only)</p> <?php if (!empty($details) && isset($details->holder_name)) { if ($details->holder_name == 'GSS') { echo '<p id="gss">for GSS PROJECT CONSULTANTS PRIVATE LIMITED</p>'; } } else { // You can display a fallback message here, or leave it empty echo '<p>No holder name available</p>'; } ?> <p style="padding:30px 0px 10px;"> <?php if (!empty($details) && isset($details->holder_name)) { if ($details->holder_name != 'GSS') { echo $details->holder_name; } elseif ($details->holder_name == 'GSS') { echo 'Authorised Signatory'; } } else { // You can display a fallback message here, or leave it empty echo 'No holder name available'; // This can be customized } ?> </p> <?php if (!empty($details) && isset($details->holder_name) && $details->holder_name == 'GSS') { ?> <p id="address" style="margin-bottom:0px;">Marketing Off: 1104, First Floor, Udayaravi Road, Kuvempunagar, Mysore-570 023.</p> <p id="pan" style="margin-top:0px;"><strong>PAN: AAACG3912G</strong></p> <?php } ?> <!-- <p style="margin-top:0px;"><strong>Bank Details :</strong></p>--> Bank Name: <?php if(!empty($details)) { echo $details->bank_name;}?></br> A/C No.: <?php if (!empty($details) && isset($details->acc_no)) { echo $details->acc_no; } else { echo 'N/A'; } ?> </br> IFSC Code: <?php if (!empty($details) && isset($details->ifsc)) { echo $details->ifsc; } else { echo 'N/A'; } ?></br> Branch: <?php if (!empty($details) && isset($details->bank_branch)) { echo $details->bank_branch; } else { echo 'N/A'; } ?> </div> </div> <button style='background-color:gray;margin-left:auto;margin-right:auto;display:block;margin-top:1%;margin-bottom:0%;padding:5px;' type="button" class="clik_button" onclick="print_update_page();"> PRINT </button> </body> </html> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css');?>"> <script src="<?php echo base_url('public/assets/toastr/toastr.min.js');?>"></script> <style> .part_one { text-align:center; } .part_one p { margin-bottom: 0px; margin-top: 0px; } .part_one h2 { border-bottom:1px solid #000; border-top:1px solid #000; padding:5px 0px; } .part_three { padding-top:10%; } .part_three table { width:100%; } .part_three table, .part_three th{ border: 1px solid black; border-collapse: collapse; } </style> <script> $(document).ready(function (){ word_amount(); word_amount(); <?php if(!empty($details) && isset($details->holder_name) && $details->holder_name == 'SriRam'){?> $('#gss').hide(); $('#address').hide(); $('#pan').hide(); <?php } elseif(!empty($details) && isset($details->holder_name) && $details->holder_name == 'Karthi SriRam') { ?> $('#gss').hide(); $('#address').hide(); $('#pan').hide(); <?php } else { ?> $('#gss').show(); $('#address').show(); $('#pan').show(); <?php } ?> }); function word_amount(){ var amount_old=<?php if(!empty($details)) { echo $details->with_gst_total_amt;} else { echo '0'; }?> ; var amount=amount_old.toFixed(0); var words = new Array(); words[0] = ''; words[1] = 'One'; words[2] = 'Two'; words[3] = 'Three'; words[4] = 'Four'; words[5] = 'Five'; words[6] = 'Six'; words[7] = 'Seven'; words[8] = 'Eight'; words[9] = 'Nine'; words[10] = 'Ten'; words[11] = 'Eleven'; words[12] = 'Twelve'; words[13] = 'Thirteen'; words[14] = 'Fourteen'; words[15] = 'Fifteen'; words[16] = 'Sixteen'; words[17] = 'Seventeen'; words[18] = 'Eighteen'; words[19] = 'Nineteen'; words[20] = 'Twenty'; words[30] = 'Thirty'; words[40] = 'Forty'; words[50] = 'Fifty'; words[60] = 'Sixty'; words[70] = 'Seventy'; words[80] = 'Eighty'; words[90] = 'Ninety'; amount = amount.toString(); var atemp = amount.split("."); var number = atemp[0].split(",").join(""); var n_length = number.length; var words_string = ""; if (n_length <= 9) { var n_array = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0); var received_n_array = new Array(); for (var i = 0; i < n_length; i++) { received_n_array[i] = number.substr(i, 1); } for (var i = 9 - n_length, j = 0; i < 9; i++, j++) { n_array[i] = received_n_array[j]; } for (var i = 0, j = 1; i < 9; i++, j++) { if (i == 0 || i == 2 || i == 4 || i == 7) { if (n_array[i] == 1) { n_array[j] = 10 + parseInt(n_array[j]); n_array[i] = 0; } } } value = ""; for (var i = 0; i < 9; i++) { if (i == 0 || i == 2 || i == 4 || i == 7) { value = n_array[i] * 10; } else { value = n_array[i]; } if (value != 0) { words_string += words[value] + " "; } if ((i == 1 && value != 0) || (i == 0 && value != 0 && n_array[i + 1] == 0)) { words_string += "Crores "; } if ((i == 3 && value != 0) || (i == 2 && value != 0 && n_array[i + 1] == 0)) { words_string += "Lakh "; } if ((i == 5 && value != 0) || (i == 4 && value != 0 && n_array[i + 1] == 0)) { words_string += "Thousand "; } if (i == 6 && value != 0 && (n_array[i + 1] != 0 && n_array[i + 2] != 0)) { words_string += "Hundred and "; } else if (i == 6 && value != 0) { words_string += "Hundred "; } } var str = words_string.split(" ").join(" "); $('#word').append(str); } } function print_update_page() { var invoice_no = $('.incoice_no').val(); console.log(invoice_no); var id = <?php echo !empty($details) && isset($details->in_id) ? $details->in_id : 'null'; ?>; // var id=10; if (invoice_no !== '') { $.ajax({ type: 'post', url: '<?php echo site_url("update-invoice-number") ?>', data: { 'id': id, 'invoice_no': invoice_no }, success: function(response) { console.log(response); if (response.result == 1) { // Update the value in the print div before printing $('#invoice_no_display').text('GSS/<?php echo $financial_year; ?>/' + invoice_no); print_page(); } else { toastr["error"](response.message); } } }); } else { toastr["error"]('Please Enter invoice Number'); } } function print_page() { var divToPrint=document.getElementById('print_div'); newWin= window.open(""); newWin.document.write('<html><head><title>GSS</title>'); newWin.document.write('</head>'); newWin.document.write(divToPrint.outerHTML); newWin.document.write('</html>'); newWin.print(); document.getElementById('print_div').style.display=''; newWin.close(); window.location.href = "<?php echo site_url('invoice-form');?>"; } </script>