ok

Mini Shell

Direktori : /home2/selectio/www/vijay-gases/
Upload File :
Current File : //home2/selectio/www/vijay-gases/purchase-invoice-share.php

<?php  include "header.php";
$ids = $_GET['id'];
$statement = $pdo->prepare("SELECT tbl_purchase.*,tbl_location.name,tbl_location.address,tbl_location.factory_address,tbl_customer.customer_name,tbl_customer.gst_no,tbl_customer.c_name,tbl_customer.mobile_number FROM `tbl_purchase` INNER JOIN tbl_location ON tbl_purchase.location_id=tbl_location.id INNER JOIN tbl_customer ON tbl_purchase.supplier=tbl_customer.id where tbl_purchase.id=".$ids);
$statement->execute();
$emp_data = $statement->fetchAll(PDO::FETCH_ASSOC);
$totalData = $statement->rowCount();


$statement_1 = $pdo->prepare("SELECT tbl_purchase_item.*,tbl_product.cylinder_no as pro_cylinder_no FROM `tbl_purchase_item` INNER JOIN tbl_product ON tbl_purchase_item.product_id=tbl_product.id WHERE tbl_purchase_item.purchase_id=".$ids);
$statement_1->execute();
$purchase_product_data = $statement_1->fetchAll(PDO::FETCH_ASSOC);
$totalData_purchase = $statement_1->rowCount();

?>
<div class="content-wrapper">
        <section class="content-header">
            <h1>Add Purchase</h1>
            <ol class="breadcrumb">
                <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Add Purchase</li>            
            </ol>
        </section>


        <div class="col-lg-12 alerts">
            <div id="custom-alerts" style="display:none;">
                <div class="alert alert-dismissable">
                    <div class="custom-msg"></div>
                </div>
            </div>
            <?php if ($error)  { ?>
            <div class="alert alert-danger alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-ban"></i> Error</h4>
                <?= $error; ?>
            </div>
            <?php $error=0;} if ($warning) { ?>
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-warning"></i> Warning</h4>
                <?= $warning; ?>
            </div>
            <?php  $warning=0;} if ($message) { ?>
            <div class="alert alert-success alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4>    <i class="icon fa fa-check"></i> Success</h4>
                <?= $message; ?>
            </div>
            <?php $message=0; } ?>
        </div>
        <div class="clearfix"></div>







<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary" style="background-color: burlywood;">
                <div class="box-header">
                    <div class="box-header">
                       <div class="row" style="">
                            <div class="col-md-10 col-sm-10 col-xs-8">
                                <div style="list-style: none; padding-inline-start: 0px; padding: 5px 0px 5px 0px;">
                                    <?php include "header/purchase_header.php"; ?>
                                 </div>
                            </div>
                            <div class="col-md-2 col-sm-2 col-xs-4">
                                <?php //include "header/buttons-ui.php"; ?>
                            </div>
                        </div>
                </div>
                </div>
                <div class="box-body">
                    <div class="col-lg-12 canvas_div_pdf">
                            <table style="width:100%;border:1px solid black;border-bottom:none;">
                        <tr>
                            <td style="width:33%;text-align:center;">GST IN : 33AABCV9544Q1ZN</td>
                            <td style="width:50%;text-align:center;"></td>
                            <td style="text-align:right;width:23%;">
                                <table style="text-align:right;width:100%;">
                                    <tr>
                                        <td style="text-align:right;">PH  &nbsp; </td>
                                        <td style="text-align:left;">91501 14330</td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td style="text-align:left;">91501 14331</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" style="text-align:center;"><?=$emp_data[0]['name']?> (P) LTD</td>
                        </tr>
                        <tr>
                            <td colspan="3" style="text-align:center;">Factory : SF NO : <?=$emp_data[0]['address']?>.</td>  
                        </tr>
                        <tr>
                           <td colspan="3" style="text-align:center;">Regd.Office : <?=$emp_data[0]['factory_address']?></td> 
                        </tr>
                        <tr>
                           <td style="">No : CR / <b><?=$emp_data[0]['id']?></b></td> 
                           <td style="padding-left: 103px;"> DELIVERY NOTE FOR INVOICE</td>
                           <td style="">Date : <b><?=date('d-m-Y', strtotime($emp_data[0]["purchase_date"]))?></b></td> 
                        </tr>
                       
                    </table>
                    <table style="width:100%;border:1px solid black;border-top!important:none;border-collapse: collapse;border-bottom:none!important;">
                        <tr>
                             <td colspan="2" style="">
                                 Mr. / M/s. : <b><?=$emp_data[0]['customer_name']?> </b>.
                             </td>
                        </tr>
                         <tr>
                             <td colspan="2" style="">
                                Company Name : <b><?=$emp_data[0]['c_name']?></b>.
                             </td>
                        </tr>
                         <tr>
                             <td colspan="2" style="">
                                 Party's TIN No : <b<?=$emp_data[0]['gst_no']?></b></b>
                             </td>
                        </tr>
                        <tr style="border:1px solid black;">
                            <td style="border:1px solid black;">Your Order No : <b><?=$emp_data[0]['id']?></b></td>
                            <td style="border:1px solid black;">Our Order Date : <b><?=date('d-m-Y', strtotime($emp_data[0]["purchase_date"]))?></b></td>
                        </tr>
                         <tr style="border:1px solid black;border-bottom:none!important;">
                            <td style="border:1px solid black;border-bottom:none!important;">Our Invoice  : <b><?=$emp_data[0]['id']?></b></td>
                            <td style="border:1px solid black;border-bottom:none!important;">Despatched Per : <b>Tamil Nadu</b></td>
                         </tr>
                    </table>
                    <table style="width:100%;border:1px solid black;border-top!important:none;border-collapse: collapse;">
                        <tr>
                            <td style="border:1px solid black;text-align:center;">S.No</td>
                            <td style="border:1px solid black;text-align:center;">Cylinder No</td>
                            <td style="border:1px solid black;text-align:center;">S.No</td>
                            <td style="border:1px solid black;text-align:center;">Cylinder No</td>
                            <td style="border:1px solid black;text-align:center;">S.No</td>
                            <td style="border:1px solid black;text-align:center;">Cylinder No</td>
                            <td style="border:1px solid black;text-align:center;">S.No</td>
                            <td style="border:1px solid black;text-align:center;">Cylinder No</td>
                        </tr>
                        <?php for($i=0;$i<15;$i++){ ?>
                       <tr>
                            <td style="border:1px solid black;text-align:center;"><?=($i+1)?></td>
                            <td style="border:1px solid black;text-align:center;"><?php if(isset($purchase_product_data[$i]['pro_cylinder_no'])){?><?=$purchase_product_data[$i]['pro_cylinder_no']?> <?php } ?></td>
                            <td style="border:1px solid black;text-align:center;"><?=($i+16)?></td>
                            <td style="border:1px solid black;text-align:center;"></td>
                            <td style="border:1px solid black;text-align:center;"><?=($i+31)?></td>
                            <td style="border:1px solid black;text-align:center;"></td>
                            <td style="border:1px solid black;text-align:center;"><?=($i+46)?></td>
                            <td style="border:1px solid black;text-align:center;"></td>
                        </tr>
                        <?php } ?>
                    </table>
                    <table style="width:100%;border:1px solid black;border-top:none;">
                        <tr>
                            <td style="text-align:center;"><b>No.</b></td>
                            <td style="text-align:center;"><b>Cu.M.</b></td>
                            <td style="text-align:center;"><b>No.</b></td>
                            <td style="text-align:center;"><b>Cu.M.</b></td>
                        </tr>
                    </table>
                    <table style="width:100%;border:1px solid black;border-top:none;">
                        <tr>
                            <td style=""><b>A :</b></td>
                            <td style=""><b>B :</b></td>
                        </tr>
                        <tr>
                            <td style=""><b>C :</b></td>
                            <td style=""><b>D :</b></td>
                        </tr>
                    </table>
                    <table style="width:100%;border:1px solid black;border-top:none;">
                        <tr>
                            <td style="">O2 Cylinders : </td>
                        </tr>
                    </table>
                    <table style="width:100%;border:1px solid black;border-top:none;">
                        <tr>
                            <td style="vertical-align:top!important;width:33%;">MO2 Cylinders</td>
                            <td style="text-align:center;width:33%;">
                                <table style="width:100%;border-collapse: collapse;border:1px solid black;">
                                    <tr>
                                        <td rowspan="2" style="border:1px solid black;writing-mode: vertical-rl;">VEHICLE NO</td>
                                        <td style="border:1px solid black;max-height:3px;"> TN 54 AV</td>
                                    </tr>
                                    <tr>
                                        <td style="border:1px solid black;max-height:3px;">6638</td>
                                    </tr>
                                   
                                </table>
                            </td>
                            <td style="text-align:right;width:33%;">Prepared & Delivered by</td>
                        </tr>
                        <tr>
                            <td colspan="3" style="">Received In Good Condition</td>
                        </tr>
                    </table>    
                                
                    </div>
                       
                    <div class="clearfix"></div>
                    <br>
                    <div class="row">
                         <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                             <center><button onclick="getPDF()" class="btn btn-primary btn-sm">Download</button> &nbsp;&nbsp;&nbsp;<a href="https://api.whatsapp.com/send?phone=<?=$emp_data[0]['mobile_number']?>&text=" target="_blank" class="btn btn-success btn-sm "><i class="fa fa-share-alt"></i> Whatsapp </a> &nbsp;&nbsp;&nbsp; </center>
                         </div>
                     </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js" ></script>

<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script type="text/javascript" src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<script>

    $(document).ready(function() {
        console.log("cdn link is working");
    $('.select2').select2();
});

</script>    

<script>
   	function getPDF(){

		var HTML_Width = $(".canvas_div_pdf").width();
		var HTML_Height = $(".canvas_div_pdf").height();
		var top_left_margin = 15;
		var PDF_Width = HTML_Width+(top_left_margin*2);
		var PDF_Height = (PDF_Width*1.5)+(top_left_margin*2);
		var canvas_image_width = HTML_Width;
		var canvas_image_height = HTML_Height;
		
		var totalPDFPages = Math.ceil(HTML_Height/PDF_Height)-1;
		

		html2canvas($(".canvas_div_pdf")[0],{allowTaint:true}).then(function(canvas) {
			canvas.getContext('2d');
			
			console.log(canvas.height+"  "+canvas.width);
			
			
			var imgData = canvas.toDataURL("image/jpeg", 1.0);
			var pdf = new jsPDF('p', 'pt',  [PDF_Width, PDF_Height]);
		    pdf.addImage(imgData, 'JPG', top_left_margin, top_left_margin,canvas_image_width,canvas_image_height);
			
			
			for (var i = 1; i <= totalPDFPages; i++) { 
				pdf.addPage(PDF_Width, PDF_Height);
				pdf.addImage(imgData, 'JPG', top_left_margin, -(PDF_Height*i)+(top_left_margin*4),canvas_image_width,canvas_image_height);
			}
			
		    pdf.save("<?=$emp_data[0]['customer_name']?>.pdf");
        });
	};
</script>

Zerion Mini Shell 1.0