<?php if (empty($total)) { ?>
    <div class="alert alert-danger" role="alert">
        <button class="close" data-dismiss="alert"></button>
        <strong><?php print CommonLanguage::getMessage('year_permission'); ?> </strong>
    </div>
    <?php die();
}?>
<link href="<?php echo THEME_PATH; ?>css/style.css" rel="stylesheet" type="text/css"/>
<link href="<?php echo THEME_PATH; ?>css/style-responsive.css" rel="stylesheet">


<script src="<?php echo VIEWS; ?>files/towords.js"></script>


<!--body wrapper start-->
<div class="wrapper">
    <div class="panel invoice">
        <div class="panel-body">
            <div class="row">
                <div class="col-xs-3">
                    
                </div>
                <div class="col-xs-5">
                    <h1><?php print CommonLanguage::getMessage('invoice');?></h1>
                </div>
<!--                <div class="col-xs-4">
                    <div class="total-purchase">
                        <?php print CommonLanguage::getMessage('total');?>
                    </div>
                    <div class="amount">
                        <strong><span class='CurrencyIndicator'><?php echo $total[0]['Currency_Symbol'];?></span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($total[0]["Net_Total"]);?></span></strong>
                    </div>
                </div>-->
            </div>
            <br/>
            <br/>
            <br/>
            <div class="row">
               <?php  if($IsVendor){ ?>
                <div class="col-xs-4">

                    <strong><?php print CommonLanguage::getMessage('From');?></strong>
                    <br/><?php print CommonLanguage::getMessage('Name');?>: <?php echo $From_Details[0]["Supplier_Name"]?>
                    <br/><?php print CommonLanguage::getMessage('address');?>: <?php echo $From_Details[0]["Country_Name"] .'-'. $From_Details[0]["Name"].'-'. $From_Details[0]["Supplier_Address"]?>
                    <br/><?php print CommonLanguage::getMessage('Email');?>: <?php echo $From_Details[0]["Supplier_Email"] ?>
                    <br/><?php print CommonLanguage::getMessage('Phone');?>: <?php echo $From_Details[0]["Supplier_Phone"] ?>
                </div>
               <?php }else{ ?>
                <div class="col-xs-4">
                    <strong>
                        <?php print CommonLanguage::getMessage('To');?>
                    </strong>
                    <br/><?php print CommonLanguage::getMessage('Name');?>: <?php echo $To_Details ? $To_Details[0]["Customer_Name"] : CommonLanguage::getMessage('road_customer'); ?>
                    <br/><?php print CommonLanguage::getMessage('address');?>: <?php echo $To_Details ? ($To_Details[0]["Country_Name"]  .'-'.  $To_Details[0]["Name"] .'-'. $To_Details[0]["Customer_Address"]) : "-- --";?>
                    <br/><?php print CommonLanguage::getMessage('Email');?>: <?php echo $To_Details ? $To_Details[0]["Customer_Email"] : "-- --"; ?>
                    <br/><?php print CommonLanguage::getMessage('Phone');?>: <?php echo $To_Details ? $To_Details[0]["Customer_Phone"] : "-- --"; ?>
                    
                </div>
                <?php } ?>
                <div class="col-xs-4 inv-info">
                    <strong><?php print CommonLanguage::getMessage('invoice_info');?></strong>
                    <br/><span> <?php echo $IsVendor ? 'Purchase Voucher ': 'Invoice Number';?> 	</span><span>&nbsp;<?php echo 	$total[0]["Entry_ID"]; ?></span>
                    <div><span>  <?php print CommonLanguage::getMessage('Date');?>   </span><span>&nbsp;<?php echo 	$total[0]["Date"]; ?></span></div>
                    <span>  <?php print CommonLanguage::getMessage('due_date');?>     </span><span>&nbsp;<?php echo 	$total[0]["Due_Date"]; ?></span>
                </div>
            </div>
            <br/>
            <br/>
            <br/>
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th>#</th>
                        <th><?php print CommonLanguage::getMessage('Code');?></th>
                        <th class=""><?php print CommonLanguage::getMessage('Item');?></th>
                        <th class=""><?php print CommonLanguage::getMessage('Quantity');?></th>
                        <th class=""><?php print CommonLanguage::getMessage('unit_cost');?></th>
                        <th class=""><?php print CommonLanguage::getMessage('discount');?></th>
                        <th><?php print CommonLanguage::getMessage('total');?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
for($i=0;$i<count($list);$i++){
                    ?>
                    <tr>
                        <td><?php echo $i; ?></td>
                        <td><?php echo $list[$i]["Code"] ; ?></td>
                        <td><?php echo $list[$i]["Name"] ; ?></td>
                        <td class=""><?php echo $list[$i]["Item_Quantity"] ; ?> </td>
                        <td class=""><span class='CurrencyIndicator'><?php echo $list[$i]["Currency_Symbol"]; ?></span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($list[$i]["Item_Price"]) ; ?></span></td>
                        <td class=""><span class='CurrencyIndicator'>%</span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($list[$i]["Item_Discount"]) ; ?></span></td>
                        <td><span class='CurrencyIndicator'><?php echo $list[$i]["Currency_Symbol"]; ?></span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($list[$i]["Item_Total_Price"]) ; ?> </td>
                    </tr>
                    <?php } ?>
                </tbody>
            </table>
            <br/>
            <br/>
            <div class="row">
                <div class="col-xs-8" id="InvoiceBottomPriceInWords">
                    <h4></h4>

                </div>
                <div class="col-xs-4">
                    <table class="table table-hover" id="TotalTable">
                        <tbody>
                            <tr>
                                <td><?php print CommonLanguage::getMessage('subtotal');?></td>
                                <td class='v-align-middle text-center'><span class='CurrencyIndicator'><?php echo $total[0]["Currency_Symbol"]; ?></span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($total[0]["Sub_Total"]);?></span></td>
                            </tr>
                            <tr>
                                <td><?php print CommonLanguage::getMessage('discount');?></td>
                                <td class='v-align-middle text-center'><span class='CurrencyIndicator'><?php echo $total[0]["Currency_Symbol"]; ?></span>&nbsp;<span class=""><?php echo Forms::DecimalNumber($total[0]["Discount"]) ;?></span></td>
                            </tr>
                             <tr>
                                <td>
                                    <strong><?php print CommonLanguage::getMessage('total_paid');?></strong>
                                </td>
                                <td class='v-align-middle text-center'><strong><span class='CurrencyIndicator'><?php echo $total[0]["Currency_Symbol"]; ?></span>&nbsp;<span class=" TotalVal"><?php echo Forms::DecimalNumber($total[0]["Paid_Amount"]);?></script></span></strong></td>
                            </tr>
                            <tr>
                                <td>
                                    <strong><?php print CommonLanguage::getMessage('grand_total');?></strong>
                                </td>
                                <td class='v-align-middle text-center'><strong><span class='CurrencyIndicator'><?php echo $total[0]["Currency_Symbol"]; ?></span>&nbsp;<span class=" TotalVal"><?php echo Forms::DecimalNumber($total[0]["Net_Total"]);?></script></span></strong></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <br/>
            <br/>
            <br/>
            <div class="row no-print">
                <div class="col-md-12">
                    <div class="pull-right">
                        <a class="btn btn-danger" onclick="javascript:window.print();"><i class="fa fa-print"></i> <?php print CommonLanguage::getMessage('print');?></a>
                        <a href="#" class="btn btn-primary"><?php print CommonLanguage::getMessage('generate_pdf');?></a>
                    </div>
                    <!--
<div class="pull-right">
<a href="#" class="btn btn-success">Submit Payment</a>
</div>
-->
                </div>
            </div>
        </div>
    </div>
</div>
<!--body wrapper end-->
<script>
//    var ZeroLang = <?php // echo json_encode(CommonLanguage::getMessage('zero'));?>,
//        SayLang = <?php // echo json_encode(CommonLanguage::getMessage('say'));?>;
//    $(function(){
//        var PrimaryCurrency = <?php // echo json_encode($CurrName); ?>;
//        var TotalVal = ($("#TotalTable").find("span.TotalVal").text());


//        var WordedPriceFirstCurrency = ucWords(toWords(TotalVal)) + " " + PrimaryCurrency;
        // Adding Zero if 0.##
//        if(TotalVal < 1)WordedPriceFirstCurrency = ZeroLang+" " + WordedPriceFirstCurrency;



//        $("#InvoiceBottomPriceInWords > h4").html(SayLang+" " + WordedPriceFirstCurrency);

//    })
</script>
