<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">

<style type="text/css">
    .ValSpan{
        opacity:0;
    }
</style>
<script src="<?php echo VIEWS; ?>files/towords.js"></script>
<script src="<?php echo JS_PATH; ?>scripts.js"></script>
<script>
    // to check if this invoice is for customer or vendor by using URL

    // to remove many digits after the period
    $(function () {
        $(".ValSpan").each(function () {
            $(this).html(AddCommas(parseFloat($.trim($(this).text())).toFixed(3))).animate({opacity: 1})
        })
    })
</script>
<!--body wrapper start-->
<div class="wrapper">
    <div class="panel invoice">
        <div class="panel-body">
            <div class="row">
                <div class="col-xs-3">
                    <div class="invoice-logo">
                        <img src="<?= upload_url;?>org_logo/invoice_logo.jpg" alt=""style="max-width:250px"/>
                    </div>
                </div>
                <div class="col-xs-5">
                    <h1> <?php print CommonLanguage::getMessage('service_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 $ListDetails[0]['Currency_Symbol']; ?></span>&nbsp;<?php echo Forms::DecimalNumber($ListDetails[0]["Invoice_Net_Total"]); ?></strong>
                    </div>
                </div>-->
            </div>
            <br/>
            <br/>
            <br/>
            <div class="row">
                <div class="col-xs-4">

                    <strong><?php print CommonLanguage::getMessage('From'); ?></strong>
                    <br/><?php print CommonLanguage::getMessage('Name'); ?>: <?php echo $From_Details[0]["Organization_Name"]; ?>
                    <br/><?php print CommonLanguage::getMessage('address'); ?>: <?php echo $From_Details[0]["Country_Name"] . '-' . $From_Details[0]["Name"] . '-' . $From_Details[0]["Organization_Street"] ?>
                    <br/><?php print CommonLanguage::getMessage('Email'); ?>: <?php echo $From_Details[0]["Organization_Email"] ?>
                    <br/><?php print CommonLanguage::getMessage('Phone'); ?>: <?php echo $From_Details[0]["Organization_Phone"] ?>
                </div>
                <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"] : "-- --"; ?>
                    <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>
                <div class="col-xs-4 inv-info">
                    <strong><?php print CommonLanguage::getMessage('invoice_info'); ?></strong>
                    <br/><span>  <?php print CommonLanguage::getMessage('invoice_number'); ?> 	</span><span>&nbsp;<?php echo $ListDetails[0]["Invoice_ID"]; ?></span>

                    <div><span> <?php print CommonLanguage::getMessage('Date'); ?>    </span><span>&nbsp;<?php echo $ListDetails[0]["Invoice_Date"]; ?></span></div>
                    <span> <?php print CommonLanguage::getMessage('due_date'); ?>        </span><span>&nbsp;<?php echo $ListDetails[0]["Invoice_Due_Date"]; ?></span>
                </div>
            </div>
            <br/>
            <br/>
            <br/>
            <table class="table table-striped table-hover">
                <thead>
                    <tr>

                        <th>#</th>
                        <th><?php print CommonLanguage::getMessage('account'); ?></th>
                        <th class=""><?php print CommonLanguage::getMessage('service_decription'); ?></th>
                        <th class=""><?php print CommonLanguage::getMessage('amount'); ?></th>

                    </tr>
                </thead>
                <tbody>
<?php
for ($i = 0; $i < count($ListDetails); $i++) {
    ?>
                        <tr>
                            <td><?php echo $i + 1; ?></td>
                            <td><?php echo $ListDetails[$i]["Account_Name"]; ?></td>
                            <td><?php echo $ListDetails[$i]["Service_Description"]; ?></td>

                            <td class=""><span class='CurrencyIndicator'><?php echo $ListDetails[$i]["Currency_Symbol"]; ?></span>&nbsp;<?php echo Forms::DecimalNumber($ListDetails[$i]["Service_Amount"]); ?></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>
                                    <strong><?php print CommonLanguage::getMessage('grand_total'); ?></strong>
                                </td>
                                <td class='v-align-middle text-center'><strong><span class='CurrencyIndicator'><?php echo $ListDetails[0]["Currency_Symbol"]; ?></span>&nbsp;<?php echo Forms::DecimalNumber($ListDetails[0]["Invoice_Net_Total"]); ?></script></strong></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <br/>
            <br/>
            <br/>
            <div class="row no-print hidden">
                <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="#" data-download-pdf='' data-title='<?php print CommonLanguage::getMessage('service_invoice'); ?>' class="btn btn-primary"><?php print CommonLanguage::getMessage('generate_pdf'); ?></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(CommonLanguage::getMessage($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>
