EVOLUTION-NINJA
Edit File: sample_request_preview.php
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <title>Deco-Textil</title> <link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.min.css');?>" /> <link rel="stylesheet" href="<?php echo base_url('assets/css/font-awesome.min.css');?>" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script> <script type="text/javascript" src="<?php echo base_url('assets/js/jquery-3.2.1.min.js');?>"></script> <script type="text/javascript" src="<?php echo base_url('assets/js/bootstrap.min.js');?>"></script> <style type="text/css"> td{ border:1px solid silver; } tr, td{ border-spacing: 0 !important; } .close-right a { border: 1px solid; /* padding-left: 15px; */ /* padding-right: 15px; */ background: rgb(72,91,127); color: white; /* padding-bottom: 7px; */ text-decoration: none; /* padding-top: 3px; */ padding: 10px 16px; border-radius: 6px; } </style> </head> <body> <div class="container"> <div class="row" style=" text-align: right;margin-top:20px;margin-bottom:20px;"> <button class="btn btn-success " type="button" id="booking_print" style=" padding-top: 4px; padding-bottom: 0px; padding-left: 15px; padding-right: 15px; background: rgb(72,91,127); color: white; border: initial !important; padding: 8px 16px; ">Print </button> <?php if($indent_p == 'indent_preview') { ?> <span class="close-right" ><a href="<?php echo base_url(); ?>request/sample_request_form?prop_id=1" style="">Back</a></span> <?php } else if($indent_p == 'today_preview') { ?> <span class="close-right" ><a href="<?php echo base_url(); ?>request/sample_request_form?prop_id=2" style="">Back</a></span> <?php } else if($indent_p == 'monthly_preview') { ?> <span class="close-right" ><a href="<?php echo base_url(); ?>request/sample_request_form?prop_id=3" style="">Back</a></span> <?php } else if($indent_p == 'year_preview') { ?> <span class="close-right" ><a href="<?php echo base_url(); ?>request/sample_request_form?prop_id=4" style="">Back</a></span> <?php } ?> <button type="button" id="generate_pdf_btn" style="margin-left: 4px;background: rgb(72,91,127);float: right;margin-right: 5px;border-radius: 6px;padding: 7px 16px;" class="btn btn-primary" >Export to PDF</button> <button type="button" onclick="tableToExcel('excelexport', 'W3C Example Table')" style="margin-left: 4px;background: rgb(72,91,127);float: right;margin-right: 5px;border-radius: 6px;padding: 7px 16px;" class="btn btn-primary" >Export to Excel</button> </div> <table id="print_report" border="0" class="table table-responsive" style="font-family:calibri; border-spacing: 0 !important;background-color:white;"> <thead> </thead> <tbody> <tr> <td colspan="3" style="border:transparent !important;"> <img src="<?php echo base_url('assets/img/preview_logo.png');?>" class="img-responsive" style="width:150px;"> </td> <td colspan="6" style="border:transparent !important; padding-top: 5%;"> <h3 style="text-align:center;padding-left:20px;">SAMPLE REQUEST</h3> </td> <td colspan="4" style="border:transparent !important; padding-top: 5%;"> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> Customer: <?php echo $fetch_main->customer_name; ?> </td> <td colspan="6" rowspan="5" style="border:1px solid silver;"> </td> <td colspan="2" style="border:1px solid silver;"> Date:<?php echo $day.'-'.$month.'-'.$year; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> Customer Id: <?php echo $fetch_main->customer_id; ?> </td> <td style="border:1px solid silver;"> TERMS </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->terms; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> REFERENCE #: <?php echo $fetch_main->reference; ?> </td> <td style="border:1px solid silver;"> CURRENCY </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->currency; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"></td> <td style="border:1px solid silver;"> MIN QTY </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->min_quality; ?> </td> </tr> <tr style="height: 33px;"> <td colspan="3" style="border:1px solid silver;"></td> <td style="border:1px solid silver;"></td> <td style="border:1px solid silver;"></td> </tr> <tr> <td style="border:1px solid silver;"> Sl.No. </td> <td style="border:1px solid silver;"> Product Type </td> <td style="border:1px solid silver;"> Size / Width </td> <td style="border:1px solid silver;"> Article </td> <td style="border:1px solid silver;"> QUALITY </td> <td style="border:1px solid silver;"> DESCRIPTION </td> <td style="border:1px solid silver;"> Design </td> <td style="border:1px solid silver;"> Color </td> <td style="border:1px solid silver;"> Price Mtr/ Pcs </td> <td style="border:1px solid silver;"> Weight in GSM </td> <td style="border:1px solid silver;"> Composition </td> </tr> <?php $a=1; foreach($fetch as $fetch){ ?> <tr> <td style="border:1px solid silver;"> <?php echo $a++; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->product_type; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->size; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->article; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->quality; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->description; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->design; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->color; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->price." ".$fetch->currency; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->weight; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->composition; ?> </td> </tr> <?php } ?> <tr> <td style="border:1px solid silver;"> </td> <td colspan="10" style="border:1px solid silver;"> NOTES: <?php echo $fetch_main->note; ?> </td> </tr> </tbody> </table> </div> </body> </html> <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.5/xlsx.full.min.js"></script> <script> function tableToExcel(tableId, filename) { // Get the table element var table = document.getElementById(tableId); // Convert the table element to a workbook var wb = XLSX.utils.table_to_book(table, {sheet: "Sheet1"}); // Write the workbook to binary var wbout = XLSX.write(wb, {bookType: 'xlsx', type: 'binary'}); // Convert binary string to ArrayBuffer function s2ab(s) { var buf = new ArrayBuffer(s.length); var view = new Uint8Array(buf); for (var i = 0; i < s.length; i++) { view[i] = s.charCodeAt(i) & 0xFF; } return buf; } // Create a Blob and trigger a download var blob = new Blob([s2ab(wbout)], {type: "application/octet-stream"}); var link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = filename + ".xlsx"; document.body.appendChild(link); link.click(); document.body.removeChild(link); } </script> <table id="excelexport" border="0" class="table table-responsive" style="font-family:calibri; border-spacing: 0 !important;background-color:white;display:none;"> <thead> </thead> <tbody> <tr> <td colspan="2" rowspan="" style="width:25%;height:100px;border-right:1px solid transparent;border-bottom:1px solid transparent;"><img src="https://drive.google.com/uc?export=view&id=0B6tsz21Ma0kFbUMybjRSSzhDc19wZ0FXdHRXTDRJZVJENmZv" class="img-responsive"></td> <td colspan="6" style="border:transparent !important; padding-top: 5%;"> <h3 style="text-align:center;padding-left:20px;">SAMPLE REQUEST</h3> </td> <td colspan="4" style="border:transparent !important; padding-top: 5%;"> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> Customer: <?php echo $fetch_main->customer_name; ?> </td> <td colspan="6" rowspan="5" style="border:1px solid silver;"> </td> <td colspan="2" style="border:1px solid silver;"> Date:<?php echo $day.'-'.$month.'-'.$year; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> Customer Id: <?php echo $fetch_main->customer_id; ?> </td> <td style="border:1px solid silver;"> TERMS </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->terms; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"> REFERENCE #: <?php echo $fetch_main->reference; ?> </td> <td style="border:1px solid silver;"> CURRENCY </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->currency; ?> </td> </tr> <tr> <td colspan="3" style="border:1px solid silver;"></td> <td style="border:1px solid silver;"> MIN QTY </td> <td style="border:1px solid silver;"> <?php echo $fetch_main->min_quality; ?> </td> </tr> <tr style="height: 33px;"> <td colspan="3" style="border:1px solid silver;"></td> <td style="border:1px solid silver;"></td> <td style="border:1px solid silver;"></td> </tr> <tr> <td style="border:1px solid silver;"> Sl.No. </td> <td style="border:1px solid silver;"> Product Type </td> <td style="border:1px solid silver;"> Size / Width </td> <td style="border:1px solid silver;"> Article </td> <td style="border:1px solid silver;"> QUALITY </td> <td style="border:1px solid silver;"> DESCRIPTION </td> <td style="border:1px solid silver;"> Design </td> <td style="border:1px solid silver;"> Color </td> <td style="border:1px solid silver;"> Price Mtr/ Pcs </td> <td style="border:1px solid silver;"> Weight in GSM </td> <td style="border:1px solid silver;"> Composition </td> </tr> <?php $a=1; foreach($fetch_xsl as $fetch){ ?> <tr> <td style="border:1px solid silver;"> <?php echo $a++; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->product_type; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->size; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->article; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->quality; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->description; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->design; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->color; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->price." ".$fetch->currency; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->weight; ?> </td> <td style="border:1px solid silver;"> <?php echo $fetch->composition; ?> </td> </tr> <?php } ?> <tr> <td style="border:1px solid silver;"> </td> <td colspan="10" style="border:1px solid silver;"> NOTES: <?php echo $fetch_main->note; ?> </td> </tr> </tbody> </table> <style> .close-right { text-align: right; margin-top: 16px; } </style> <script> $(document).ready(function(){ $("#booking_print").click(function(){ $('#generate_pdf_btn').toggle(); var divToPrint=document.getElementById("print_report"); newWin= window.open(""); newWin.document.write(divToPrint.outerHTML); newWin.print(); newWin.close(); }); }); </script> <script> $ = jQuery; $( "#generate_pdf_btn" ).click(function() { // alert(); make_product_sheet(); }); function make_product_sheet() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); var d = dd + '/' + mm + '/' + yyyy; console.log("#generate_pdf_btn clicked"); var pdf = new jsPDF('p', 'pt', 'a4'); pdf.addHTML(document.getElementById("print_report"), function() { ps_filename = "Sample-Request-"+d; pdf.save(ps_filename+'.pdf'); }); } </script>