<meta charset="utf-8">
<?php
    require('conn/conn_mssql.php');
    $VCID =$_GET['VCID'];
	
 function moneytotext($m){
    If ($m == ""){
        return "";
	}
	$m=str_replace(",", "", $m);
	if(! is_numeric($m)){
		return "";
	}
    $mtext = number_format($m, 2, '.', '');
    $totdigit = strlen($mtext) - 3;
    $outtext = "";
    //หน้าทศนิยม
    for ($i=$totdigit;$i>=1;$i--){
        $c = substr($mtext, $i-1, 1);
        $cdigit = $totdigit + 1 - $i;
        //ตัวเลข
        switch ($c){
        case "0":
            if ($cdigit == 7 and $totdigit > 7 ){
                $t = "ศูนย์";
			}else{
                $t = "";
			}
			break;
        case "1":
            if ($cdigit == 1 and $totdigit > 1 or $cdigit == 7 and $totdigit > 7 ){
                $t = "เอ็ด";
			}else{
                $t = "หนึ่ง";
            }
			break;
        case "2":
            if ($cdigit == 2 or $cdigit == 8){
                $t = "ยี่";
			}else{
                $t = "สอง";
			}
			break;
		case "3":
            $t = "สาม";
			break;
        case "4":
            $t = "สี่";
			break;
        case "5":
            $t = "ห้า";
			break;
        case "6":
            $t = "หก";
			break;
        case "7":
            $t = "เจ็ด";
			break;
        case "8":
            $t = "แปด";
			break;
        case "9":
            $t = "เก้า";
			break;
        default :
            $t = "";
        }
        //หลัก
        if ($t <> ""){
            switch ($cdigit){
            case 1:  //หน่วย
                $d = "";
				break;
            case 2:  //สิบ
                if ($t == "หนึ่ง"){
                    $t = "";
				}
                $d = "สิบ";
				break;
            case 3:  //ร้อย
                $d = "ร้อย";
				break;
            case 4:  //พัน
                $d = "พัน";
				break;
            case 5:  //หมื่น
                $d = "หมื่น";
				break;
            case 6:  //แสน
                $d = "แสน";
				break;
            case 7:  //ล้าน
                if ($t == "ศูนย์"){
                    $t = "";
				}
                $d = "ล้าน";
				break;
            case 8:  //สิบล้าน
                if ($t == "หนึ่ง"){
                    $t = "";
				}
                $d = "สิบ";
				break;
            case 9: //ร้อยล้าน
                $d = "ร้อย";
				break;
            case 10: //พันล้าน
                $d = "พัน";
				break;
            default :
                $d = "";
            }
        }
		else{
            $d = "";
		}	
        $outtext = $t.$d.$outtext;
	}
    if ($outtext <> ""){
        $outtext = $outtext ."บาท";
	}
    
    //หลัง ทศนิยม ตำแหน่งที่ 1
    switch (substr($mtext, strlen($mtext) - 2, 1)){
        case "1":
            $d01 = "สิบ";
			break;
        case "2":
            $d01 = "ยี่สิบ";
			break;
        case "3":
            $d01 = "สามสิบ";
			break;
        case "4":
            $d01 = "สี่สิบ";
			break;
        case "5";
            $d01 = "ห้าสิบ";
			break;
        case "6":
            $d01 = "หกสิบ";
			break;
        case "7":
            $d01 = "เจ็ดสิบ";
			break;
        case "8":
            $d01 = "แปดสิบ";
			break;
        case "9":
            $d01 = "เก้าสิบ";
			break;
        default:
            $d01 = "";
    }
    //ทศนิยม ตำแหน่งที่ 2
    switch (substr($mtext, strlen($mtext)-1, 1)){
        case "1":
            if ($d01 <> ""){
                $d02 = "เอ็ด";
			}else{
                $d02 = "หนึ่ง";
            }
			break;
        case "2":
            $d02 = "สอง";
			break;
        case "3":
            $d02 = "สาม";
			break;
        case "4":
            $d02 = "สี่";
			break;
        case "5":
            $d02 = "ห้า";
			break;
        case "6":
            $d02 = "หก";
			break;
        case "7":
            $d02 = "เจ็ด";
			break;
        case "8":
            $d02 = "แปด";
			break;
        case "9":
            $d02 = "เก้า";
			break;
        default:
            $d02 = "";
    }
    if ($d01.$d02 <> ""){
        $d02 = $d02 ."สตางค์";
    }
    
    if ($d01.$d02 <> ""){
        $outtext = $outtext.$d01.$d02;
	}
    else{
        $outtext = $outtext."ถ้วน";
    }
    return $outtext;
 }
	
	
	
function format_dateD($fulldate1){
    $day = substr($fulldate1,-2,2);
   // $month = substr($fulldate1,-5,2);
   // $year = substr($fulldate1,-10,4);
   //$fulldate1 = $day ."/".$month."/".$year ;
    $fulldate1 = $day  ;
    return $fulldate1;
}
function format_dateM($fulldate1){
   // $day = substr($fulldate1,-2,2);
     $month = substr($fulldate1,-5,2);
   // $year = substr($fulldate1,-10,4);
   //$fulldate1 = $day ."/".$month."/".$year ;
    $fulldate1 = $month  ;
    return $fulldate1;
}

function format_dateY($fulldate1){
   // $day = substr($fulldate1,-2,2);
   //  $month = substr($fulldate1,-5,2);
    $year = substr($fulldate1,-10,4);
   //$fulldate1 = $day ."/".$month."/".$year ;
    $fulldate1 = $year  ;
    return $fulldate1;
}
	
function format_dateDMY($fulldate1){
    $day = substr($fulldate1,-2,2);
    $month = substr($fulldate1,-5,2);
    $year = substr($fulldate1,-10,4);
    $fulldate1 = $day ."/".$month."/".$year ;
   // $fulldate1 = $year  ;
    return $fulldate1;
}	
	
	
 $sql_code="select   *    from   vw_VCPrint    where   VCID    like  '$VCID'     order by  VCID Desc ";
 $query_code=$conn->prepare($sql_code);
 $query_code->execute();
 $result_code = $query_code->fetch( PDO::FETCH_ASSOC);
	
$VCID =   $result_code['VCID'] ;
$VCDate  = $result_code['VCDate'] ;	
$VCDealerName = $result_code['VCDealerName'] ;	
$VCAddr   = $result_code['DealerAddr1']." ".$result_code['DealerAddr2']."  โทร.".$result_code['DealerPhone'] ;	
$VCDealerBranchName = 	$result_code['VCDealerBranchName'] ;	
	

	
//$txtDRepTax   = "ภาษีหัก ณ ที่จ่าย  ".number_format($TaxPercent,2)."% เป็นเงิน  ".number_format($dat['TotalTaxBath'],2)                                   ;	
	
	
	
	
	
	
	
	
	
//$sql_code="select   *    from   vw_VCPrint    where   VCID    like  '$VCID'     order by  VCID Desc ";
//$query_code=$conn->prepare($sql_code);
//$query_code->execute();
//while($result_code = $query_code->fetch( PDO::FETCH_ASSOC)){


//$VCID =   $result_code['VCID'] ;
//$VCDate  = $result_code['VCDate'] ;


//}	
	

	
	?>
	
	
<?php
$html = '
<!--mpdf
<html>
<head>
<style>
body{
    font-family: "Garuda";
    font-size: 9pt;
}
.thai2{
    font-family: "Garuda";
}


p {	margin: 0pt; }
table.items {
	border: 0.1mm solid #000000;
}
td { vertical-align: top; }
.items td {
	border-left: 0.1mm solid #000000;
	border-right: 0.1mm solid #000000;
}
table thead td { background-color: #EEEEEE;
	text-align: center;
	border: 0.1mm solid #000000;
	font-variant: small-caps;
}
.items td.blanktotal {
	background-color: #EEEEEE;
	border: 0.1mm solid #000000;
	background-color: #FFFFFF;
	border: 0mm none #000000;
	border-top: 0.1mm solid #000000;
	border-right: 0.1mm solid #000000;
}
.items td.totals {
	text-align: right;
	border: 0.1mm solid #000000;
}
.items td.cost {
	text-align: "." center;
}
</style>
</head>
<body>

<!--mpdf

<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
<td width="50%" style="color:#0000BB; "><span style="font-weight: bold; font-size: 14pt;">Acme Trading Co.</span><br />123 Anystreet<br />Your City<br />GD12 4LP<br /><span style="font-family:dejavusanscondensed;">&#9742;</span> 01777 123 567</td>
<td width="50%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;">0012345</span></td>
</tr></table>
</htmlpageheader>

<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>

<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
<table width="100%" style="font-family: serif;" cellpadding="10"><tr>
<td width="45%" style="border: 0.1mm solid #888888; "><span style="font-size: 7pt; color: #555555; font-family: sans;">SOLD TO:</span><br /><br />345 Anotherstreet<br />Little Village<br />Their City<br />CB22 6SO</td>
<td width="10%">&nbsp;</td>
<td width="45%" style="border: 0.1mm solid #888888;"><span style="font-size: 7pt; color: #555555; font-family: sans;">SHIP TO:</span><br /><br />345 Anotherstreet<br />Little Village<br />Their City<br />CB22 6SO</td>
</tr></table>

<br />




<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
<thead>
<tr>
<td width="15%">Ref. No.</td>
<td width="10%">Quantity</td>
<td width="45%">Description</td>
<td width="15%">Unit Price</td>
<td width="15%">Amount</td>
</tr>
</thead>
<tbody>
<!-- ITEMS HERE -->
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<tr>
<td align="center">MF1234567</td>
<td align="center">10</td>
<td>Large pack Hoover bags</td>
<td class="cost">&pound;2.56</td>
<td class="cost">&pound;25.60</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>

<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>

<tr>
<td align="center">MX37801982</td>
<td align="center">1</td>
<td>Womans waterproof jacket<br />Options - Red and charcoal.</td>
<td class="cost">&pound;102.11</td>
<td class="cost">&pound;102.11</td>
</tr>
<tr>
<td align="center">MR7009298</td>
<td align="center">25</td>
<td>Steel nails; oval head; 30mm x 3mm. Packs of 1000.</td>
<td class="cost">&pound;12.26</td>
<td class="cost">&pound;325.60</td>
</tr>
<!-- END ITEMS HERE -->
<tr>
<td class="blanktotal" colspan="3" rowspan="6"></td>
<td class="totals">Subtotal:</td>
<td class="totals cost">&pound;1825.60</td>
</tr>
<tr>
<td class="totals">Tax:</td>
<td class="totals cost">&pound;18.25</td>
</tr>
<tr>
<td class="totals">Shipping:</td>
<td class="totals cost">&pound;42.56</td>
</tr>
<tr>
<td class="totals"><b>TOTAL:</b></td>
<td class="totals cost"><b>&pound;1882.56</b></td>
</tr>
<tr>
<td class="totals">Deposit:</td>
<td class="totals cost">&pound;100.00</td>
</tr>
<tr>
<td class="totals"><b>Balance due:</b></td>
<td class="totals cost"><b>&pound;1782.56</b></td>
</tr>
</tbody>
</table>


<div style="text-align: center; font-style: italic;">Payment terms: payment due in 30 days</div>


</body>
</html>




';


?>

<?php
		include_once 'mpdf/vendor/autoload.php';
		
		
		include("mpdf/mpdf.php");
		
		
		/*
		 $mpdf = new mPDF(   '',    // mode - default ''
                '',    // format - A4, for example, default ''
                0,     // font size - default 0
                '',    // default font family
                15,    // margin_left
                15,    // margin right
                58,     // margin top
                60,    // margin bottom
                6,     // margin header
                0,     // margin footer
                'L' );  // L - landscape, P - portrait
		*/
		//$mpdf = new mPDF('c');
	//	$mpdf=new mPDF(''); 
		//$stylesheet = file_get_contents('vendor/bootstrap/css/bootstrap.css');
		
		
		//$mpdf->SetDisplayMode('fullpage');
	//	$mpdf->list_indent_first_level = 0;  // 1 or 0 - whether to indent the first level of a list
		
		
		
	  // $stylesheet = file_get_contents('css/mpdfstyleA4.css');
     //  $mpdf->WriteHTML($stylesheet,1);	// The parameter 1 tells that this is css/style only and no body/html/text
		
		
		
		
     	
    //    $mpdf->SetHTMLFooter();
	//	$mpdf->allow_charset_conversion=true;
	//	$mpdf->charset_in='UTF-8';
		//$mpdf->WriteHTML($stylesheet,1);
		//$mpdf->SetHTMLHeader($header);
		


		
		
	//	$mpdf->WriteHTML($html);  
	//	$mpdf->Output(); 
		
		
		
		
		
		
		
		
//$mpdf = new mPDF('c','A4','','',20,15,48,25,10,10);
//$mpdf->SetProtection(array('print'));
//$mpdf->SetTitle("Acme Trading Co. - Invoice");
//$mpdf->SetAuthor("Acme Trading Co.");
//$mpdf->SetWatermarkText("Paid");
//$mpdf->showWatermarkText = true;
//$mpdf->watermark_font = 'DejaVuSansCondensed';
//$mpdf->watermarkTextAlpha = 0.1;
//$mpdf->SetDisplayMode('fullpage');



$mpdf->WriteHTML($html);
$mpdf->Output(); 		
		
		
		
		
		/* $mpdf->Output('doc/PDF/Quotation_'.$order_id.'_'.$tele.'.pdf','F'); */
?>

