<?php if (empty($List)) { ?>
<div class="alert alert-danger" role="alert">
    <button class="close" data-dismiss="alert"></button>
    <strong>Danger: </strong>you can not view this <?php echo $IsCredit ? 'Credit Note' : 'Debit Note';?>! 
    <br>
    This <?php echo $IsCredit ? 'Credit Note' : 'Debit Note';?> is not available.
</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>
<script src="<?php echo JS_PATH; ?>scripts.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 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 echo CommonLanguage::getMessage($IsCredit ? "credit_note" : "debit_note");?></h1>
                </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 $IsCredit ? $org_details[0]["Organization_Name"] : $List[0]['Supplier_Name']; ?>
                    <br/><?php print CommonLanguage::getMessage('address');?>: <?php echo $IsCredit ?  ($org_details[0]["Country_Name"] .'-'. $org_details[0]["Name"].'-'. $org_details[0]["Organization_Street"]) : $List[0]['Supplier_Address']?>
                    <br/><?php print CommonLanguage::getMessage('Email');?>: <?php echo $IsCredit ? $org_details[0]["Organization_Email"]  : $List[0]['Supplier_Email']?>
                    <br/><?php print CommonLanguage::getMessage('Phone');?>: <?php echo $IsCredit ? $org_details[0]["Organization_Phone"] : $List[0]['Supplier_Mobile'] ?>
                </div>
                <div class="col-xs-4">
                    <strong>
                        <?php print CommonLanguage::getMessage('To');?>
                    </strong>
                    <br/><?php print CommonLanguage::getMessage('Name');?>: <?php echo $IsCredit ? $List[0]['Customer_Name'] : $org_details[0]["Organization_Name"]; ?>
                    <br/><?php print CommonLanguage::getMessage('address');?>: <?php echo $IsCredit ? $List[0]['Customer_Address'] : ($org_details[0]["Country_Name"]  .'-'.  $org_details[0]["Name"] .'-'. $org_details[0]["Organization_Street"]);?>
                    <br/><?php print CommonLanguage::getMessage('Email');?>: <?php echo $IsCredit ? $List[0]['Customer_Email'] : $org_details[0]["Organization_Email"] ; ?>
                    <br/><?php print CommonLanguage::getMessage('Phone');?>: <?php echo $IsCredit ? $List[0]['Customer_Mobile'] : $org_details[0]["Organization_Phone"] ; ?>
                </div>
                <div class="col-xs-4 inv-info">

                    <div><span><?php print CommonLanguage::getMessage('Date');?>    </span><span>&nbsp;<?php echo 	$List[0]["Note_Date"]; ?></span></div>

                </div>
            </div>
            <br/>
            <br/>
            <br/>
            <table class="table table-striped table-hover">
                <thead>

                </thead>
                <tbody>

                    <tr>
                        <td><?php echo $List[0]['Note_Description']?></td>

                    </tr>

                </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 $List[0]["Currency_Symbol"]; ?></span>&nbsp;<span class=" TotalVal"><?php echo CommonFunctions::public_round_number($List[0]["Note_Amount"]);?></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="#" data-download-pdf='' data-title=' Invoice' 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 sayLang = <?php echo json_encode(CommonLanguage::getMessage('say'));?>,
        zeroLang = <?php echo json_encode(CommonLanguage::getMessage('zero'));?>;
        $(function(){
            var PrimaryCurrency = <?php echo json_encode(CommonLanguage::getMessage($List[0]['Currency_Name'])); ?>;
            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>
