<?php $__env->startSection('content'); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo e(base_path().'/resources/assets/invoicetemplate/invoicestyle.css'); ?>" />
    <?php if(isset($language->is_rtl) && $language->is_rtl=="Y"): ?>
        <link rel="stylesheet" type="text/css" href="<?php echo e(base_path().'/resources/assets/css/bootstrap-rtl.min.css'); ?>" />
        <style type="text/css">
            .leftsideview{
                direction: ltr;
            }
            #details{
                border-right: 3px solid #000000;
                padding-right: 6px;
                padding-left: 0px;
                border-left: 0px;
            }
			#client{
                border-left: 0;
            }
			#frontinvoice .desc {
                text-align: right;
            }
            #Service{
                float: right;
            }
            .leftalign {
                text-align: right;
            }
            .rightalign {
                text-align: left;
            }
        </style>
    <?php endif; ?>
<style type="text/css">
    .bg_graycolor{
        background-color: #f5f5f6;
        font-size: 12px;
    }
    .bg_graycolor th, .bg_graycolor td{
        border: 1px solid #dddddd;
    }
    .invoice,
    .invoice table,.invoice table td,.invoice table th,
    .invoice ul li
    { font-size: 12px; }

    #pdf_header, #pdf_footer{
        /*position: fixed;*/
    }

    @media  print {
        .page_break{page-break-after: always;}
        * {
            background-color: auto !important;
            background: auto !important;
            color: auto !important;
        }
    }
    .page_break{page-break-after: always;}
    tr {
        page-break-inside: avoid;
    }

    thead {
        display: table-header-group
    }

    tfoot {
        display: table-row-group
    }
    <?php if(isset($arrSignature["UseDigitalSignature"]) && $arrSignature["UseDigitalSignature"]==true): ?>
    img.signatureImage {
        position: absolute;
        z-index: 99999;
        top: <?php echo e(isset($arrSignature["DigitalSignature"]->positionTop)?$arrSignature["DigitalSignature"]->positionTop:0); ?>px;
        left: <?php echo e(isset($arrSignature["DigitalSignature"]->positionLeft)?$arrSignature["DigitalSignature"]->positionLeft:0); ?>px;
    }
    <?php endif; ?>
</style>
<div class="inovicebody">
    <!-- logo and invoice from section start-->
    <header class="clearfix">
        <div id="logo"  class="pull-left flip">
            <?php if(!empty($logo)): ?>
                <img src="<?php echo e(get_image_data($logo)); ?>" style="max-width: 250px">
            <?php endif; ?>
        </div>
        <div id="company"  class="pull-right flip">
            <h2 class="name text-right flip"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_INVOICE_FROM")); ?></b></h2>
            <div class="text-right flip"><?php echo e(nl2br($InvoiceTemplate->Header)); ?></div>
        </div>
    </header>
    <!-- logo and invoice from section end-->

    <!-- need to change with new logic -->

    <?php
    $InvoiceTo =$InvoiceFrom = '';
    $AllTaxSummary = array();
    $AllTaxCount=0;
    $AllPayment=0;
    $is_sub = $is_charge = false;
    $total_usage= $total_sub = $total_add = $total_sms = 0;
    foreach($InvoiceDetail as $ProductRow){
        if($ProductRow->ProductType == \App\Lib\Product::USAGE){
            $total_usage += $ProductRow->LineTotal;
        }
        if($ProductRow->ProductType == \App\Lib\Product::SMS){
            $total_sms += $ProductRow->LineTotal;
        }
        if($ProductRow->ProductType == \App\Lib\Product::INVOICE_PERIOD){
            $InvoiceFrom = date('F d,Y',strtotime($ProductRow->StartDate));
            $InvoiceTo = date('F d,Y',strtotime($ProductRow->EndDate));
        }
        if($ProductRow->ProductType == \App\Lib\Product::SUBSCRIPTION){
            $total_sub += $ProductRow->LineTotal;
            $is_sub = true;
        }
        if($ProductRow->ProductType == \App\Lib\Product::ONEOFFCHARGE){
            $total_add += $ProductRow->LineTotal;
            $is_charge = true;
        }
    }


    $message = $InvoiceTemplate->InvoiceTo;

    $replace_array = \App\Lib\Invoice::create_accountdetails($Account);
    $text = \App\Lib\Invoice::getInvoiceToByAccount($message,$replace_array);
    $return_message = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $text);

    $Terms = $Invoice->Terms;
    $textTerms = \App\Lib\Invoice::getInvoiceToByAccount($Terms,$replace_array);
    $return_terms = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $textTerms);

    $FooterTerm = $Invoice->FooterTerm;
    $replace_array = \App\Lib\Invoice::create_accountdetails($Account);
    $FooterTermtext = \App\Lib\Invoice::getInvoiceToByAccount($FooterTerm,$replace_array);
    $FooterTerm_message = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $FooterTermtext);
    // if cdrtype is detailcdr and calltype is active than we need to display inbound usage and outbound usage separate in detail section. otherwise it will as it is
    $DisplayCallType=0;
    $CallTypeData = array('NoCallType');
    if($InvoiceTemplate->CDRType == \App\Lib\Account::DETAIL_CDR){
        $DisplayCallType=\App\Lib\InvoiceTemplate::DisplayCallType($usage_data_table['header']);
        if($DisplayCallType==1){
            $CallTypeData= array('OutBound','InBound');
        }
    }
    $SMS_DISPLAY = 0;
    if(!empty(\App\Lib\CompanyConfiguration::get($Invoice->CompanyID,'SMS_DISPLAY')) && \App\Lib\CompanyConfiguration::get($Invoice->CompanyID,'SMS_DISPLAY') == 1){
        $SMS_DISPLAY = 1;
    }
    ?>

    <main>
        <?php if(isset($arrSignature["UseDigitalSignature"]) && $arrSignature["UseDigitalSignature"]==true): ?>
            <img src="<?php echo e(get_image_data($arrSignature['signaturePath'].$arrSignature['DigitalSignature']->image)); ?>" class="signatureImage" />
        <?php endif; ?>
        <div id="details" class="clearfix">
            <div id="client" class="pull-left flip">
                <div class="to"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_INVOICE_TO")); ?></b></div>
                <div><?php echo e(nl2br($return_message)); ?></div>
            </div>
            <div id="invoice" class="pull-right flip">
                <h1 class="text-right flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_INVOICE_NO")); ?> <?php echo e($Invoice->FullInvoiceNumber); ?></h1>
                <div class="date text-right flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_INVOICE_DATE")); ?> <?php echo e(date($InvoiceTemplate->DateFormat,strtotime($Invoice->IssueDate))); ?></div>
                <div class="date text-right flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_DUE_DATE")); ?> <?php echo e(date($InvoiceTemplate->DateFormat,strtotime($Invoice->IssueDate.' +'.$PaymentDueInDays.' days'))); ?></div>
                <?php if($InvoiceTemplate->ShowBillingPeriod == 1): ?>
                    <div class="date text-right flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_INVOICE_PERIOD")); ?> <?php echo e(date($InvoiceTemplate->DateFormat,strtotime($InvoiceFrom))); ?> - <?php echo e(date($InvoiceTemplate->DateFormat,strtotime($InvoiceTo))); ?></div>
                <?php endif; ?>
                <?php if(!empty($MultiCurrencies)): ?>
                    <?php foreach($MultiCurrencies as $multiCurrency): ?>
                        <div class="text-right flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_GRAND_TOTAL_IN")); ?> <?php echo e($multiCurrency['Title']); ?> : <?php echo e($multiCurrency['Amount']); ?></div>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>
        </div>

        <!-- content of front page section start -->

        <table border="0" cellspacing="0" cellpadding="0" id="frontinvoice">
            <thead>


            <?php $VisibleColumns = (array)json_decode($InvoiceTemplate->VisibleColumns); $colspan = 0; ?>
            <tr>
                <?php if(!empty($VisibleColumns)): ?>
                    <?php if(isset($VisibleColumns['Description']) && $VisibleColumns['Description'] == 1 && !empty($InvoiceTemplate->ItemDescription)): ?>
                        <?php $colspan++; ?>
                        <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DESCRIPTION")); ?></b></th>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Usage']) && $VisibleColumns['Usage'] == 1): ?>
                        <?php $colspan++; ?>
                        <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_USAGE")); ?></b></th>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['SMS']) && $VisibleColumns['SMS'] == 1 && $SMS_DISPLAY == 1): ?>
                        <?php $colspan++; ?>
                        <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_SMS")); ?></b></th>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Recurring']) && $VisibleColumns['Recurring'] == 1): ?>
                        <?php $colspan++; ?>
                        <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_RECURRING")); ?></b></th>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Additional']) && $VisibleColumns['Additional'] == 1): ?>
                        <?php $colspan++; ?>
                        <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_ADDITIONAL")); ?></b></th>
                    <?php endif; ?>
                    <?php if($colspan == 0): ?>
                        <th class="desc"></th>
                    <?php endif; ?>
                        <th class="total leftsideview"><b><?php echo e(cus_lang("TABLE_TOTAL")); ?></b></th>
                <?php else: ?>
                    <?php $colspan = 3; ?>
                    <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_USAGE")); ?></b></th>
                    <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_SMS")); ?></b></th>
                    <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_RECURRING")); ?></b></th>
                    <th class="desc"><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_ADDITIONAL")); ?></b></th>
                    <th class="total leftsideview"><b><?php echo e(cus_lang("TABLE_TOTAL")); ?></b></th>
                <?php endif; ?>
            </tr>
            </thead>
            <tbody>

            <tr>
                <?php if(!empty($VisibleColumns)): ?>
                    <?php if(isset($VisibleColumns['Description']) && $VisibleColumns['Description'] == 1 && !empty($InvoiceTemplate->ItemDescription)): ?>
                        <td class="desc"><?php echo e($InvoiceTemplate->ItemDescription); ?></td>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Usage']) && $VisibleColumns['Usage'] == 1): ?>
                        <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_usage,$RoundChargesAmount)); ?></td>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['SMS']) && $VisibleColumns['SMS'] == 1 && $SMS_DISPLAY == 1): ?>
                        <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sms,$RoundChargesAmount)); ?></td>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Recurring']) && $VisibleColumns['Recurring'] == 1): ?>
                        <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sub,$RoundChargesAmount)); ?></td>
                    <?php endif; ?>
                    <?php if(isset($VisibleColumns['Additional']) && $VisibleColumns['Additional'] == 1): ?>
                        <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_add,$RoundChargesAmount)); ?></td>
                    <?php endif; ?>
                    <?php if($colspan == 0): ?>
                        <td class="desc"></td>
                    <?php endif; ?>
                        <td class="total leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_usage+$total_sms+$total_sub+$total_add,$RoundChargesAmount)); ?></td>
                <?php else: ?>
                    <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_usage,$RoundChargesAmount)); ?></td>
                    <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sms,$RoundChargesAmount)); ?></td>
                    <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sub,$RoundChargesAmount)); ?></td>
                    <td class="desc leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_add,$RoundChargesAmount)); ?></td>
                    <td class="total leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_usage+$total_sms+$total_sub+$total_add,$RoundChargesAmount)); ?></td>
                <?php endif; ?>
            </tr>



            </tbody>
            <tfoot>
            <?php $colspan--; ?>
            <tr>
                <?php if(!empty($VisibleColumns)): ?>
                    <?php if($colspan > 0): ?>
                        <td colspan="<?php echo e($colspan); ?>"></td>
                    <?php endif; ?>
                <?php else: ?>
                    <td colspan="3"></td>
                <?php endif; ?>
                <td><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_SUB_TOTAL")); ?></td>
                <td class="subtotal leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($Invoice->SubTotal,$RoundChargesAmount)); ?></td>
            </tr>
            <?php if(count($InvoiceTaxRates)): ?>
                <?php foreach($InvoiceTaxRates as $InvoiceTaxRate): ?>
                    <?php
                    $tempsummary['Title']=$InvoiceTaxRate->Title;
                    $tempsummary['Amount']=$InvoiceTaxRate->TaxAmount;
                    $AllTaxSummary[]=$tempsummary;
                    $AllTaxCount+= str_replace(',','',$InvoiceTaxRate->TaxAmount);
                    ?>
                    <?php if($InvoiceTemplate->ShowTaxesOnSeparatePage==0): ?>
                        <tr>
                            <?php if(!empty($VisibleColumns)): ?>
                                <?php if($colspan > 0): ?>
                                    <td colspan="<?php echo e($colspan); ?>"></td>
                                <?php endif; ?>
                            <?php else: ?>
                                <td colspan="3"></td>
                            <?php endif; ?>
                            <td><?php echo e($InvoiceTaxRate->Title); ?></td>
                            <td class="subtotal leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($InvoiceTaxRate->TaxAmount,$RoundChargesAmount)); ?></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                <?php if($InvoiceTemplate->ShowTaxesOnSeparatePage==1): ?>
                    <tr>
                        <?php if(!empty($VisibleColumns)): ?>
                            <?php if($colspan > 0): ?>
                                <td colspan="<?php echo e($colspan); ?>"></td>
                            <?php endif; ?>
                        <?php else: ?>
                            <td colspan="3"></td>
                        <?php endif; ?>
                        <td><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TAXES_TOTAL")); ?></td>
                        <td class="subtotal leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($AllTaxCount,$RoundChargesAmount)); ?></td>
                    </tr>
                <?php endif; ?>
            <?php endif; ?>
            <?php if($Invoice->TotalDiscount > 0): ?>
                <tr>
                    <?php if(!empty($VisibleColumns)): ?>
                        <?php if($colspan > 0): ?>
                            <td colspan="<?php echo e($colspan); ?>"></td>
                        <?php endif; ?>
                    <?php else: ?>
                        <td colspan="3"></td>
                    <?php endif; ?>
                    <td><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DISCOUNT")); ?></td>
                    <td class="subtotal leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($Invoice->TotalDiscount,$RoundChargesAmount)); ?></td>
                </tr>
            <?php endif; ?>
            <?php if($InvoiceTemplate->ShowPrevBal): ?>
                <tr>
                    <?php if(!empty($VisibleColumns)): ?>
                        <?php if($colspan > 0): ?>
                            <td colspan="<?php echo e($colspan); ?>"></td>
                        <?php endif; ?>
                    <?php else: ?>
                        <td colspan="3"></td>
                    <?php endif; ?>
                    <td><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_BROUGHT_FORWARD")); ?></td>
                    <td class="subtotal leftsideview"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($Invoice->PreviousBalance,$RoundChargesAmount)); ?></td>
                </tr>
            <?php endif; ?>
            <tr>
                <?php if(!empty($VisibleColumns)): ?>
                    <?php if($colspan > 0): ?>
                        <td colspan="<?php echo e($colspan); ?>"></td>
                    <?php endif; ?>
                <?php else: ?>
                    <td colspan="3"></td>
                <?php endif; ?>
                <td>
					<?php if(!$InvoiceTemplate->ShowPrevBal): ?>
						<b>
					<?php endif; ?>
					
					<?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_GRAND_TOTAL")); ?>

					
					<?php if(!$InvoiceTemplate->ShowPrevBal): ?>
						</b>				
					<?php endif; ?>
				</td>
                <td class="subtotal leftsideview">
                    <?php if(!$InvoiceTemplate->ShowPrevBal): ?>
                        <b>
                    <?php endif; ?>

                    <?php echo e($CurrencySymbol); ?><?php echo e(number_format($Invoice->GrandTotal,$RoundChargesAmount)); ?>


                    <?php if(!$InvoiceTemplate->ShowPrevBal): ?>
                        </b>
                    <?php endif; ?>
                </td>
            </tr>
            <?php if($InvoiceTemplate->ShowPrevBal): ?>
                <tr>
                    <?php if(!empty($VisibleColumns)): ?>
                        <?php if($colspan > 0): ?>
                            <td colspan="<?php echo e($colspan); ?>"></td>
                        <?php endif; ?>
                    <?php else: ?>
                        <td colspan="3"></td>
                    <?php endif; ?>
                    <td><b><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TOTAL_DUE")); ?></b></td>
                    <td class="subtotal leftsideview"><b><?php echo e($CurrencySymbol); ?><?php echo e(number_format($Invoice->TotalDue,$RoundChargesAmount)); ?></b></td>
                </tr>
            <?php endif; ?>
            </tfoot>
        </table>
        <!-- content of front page section end -->
    </main>

    <!-- adevrtisement and terms section start-->
    <div id="thanksadevertise">
        <div class="invoice-left">
            <p><a class="form-control pull-left" style="height: auto"><?php echo e(nl2br($return_terms)); ?></a></p>
        </div>
    </div>
    <!-- adevrtisement and terms section end -->

    <!-- footer section start-->
    <?php if($InvoiceTemplate->FooterDisplayOnlyFirstPage==1): ?>
        <div id="thanksadevertise">
            <div class="invoice-left">
                <p><a class="form-control pull-left" style="height: auto"><?php echo e(nl2br($FooterTerm_message)); ?></a></p>
            </div>
        </div>
        <?php endif; ?>
    <!-- footer section end -->

    <?php if($total_usage != 0 || $total_sms != 0 || $is_sub || $is_charge): ?>
    <div class="page_break"> </div>
    <br/>
    <?php endif; ?>

    <main>
        <?php if($total_usage != 0): ?>
        <div class="ChargesTitle clearfix">
            <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_USAGE")); ?></div>
            <div class="text-right pull-right flip col-harf"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_usage,$RoundChargesAmount)); ?></div>
        </div>
        <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
            <thead>
            <tr>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TITLE")); ?></th>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DESCRIPTION")); ?></th>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_FROM")); ?></th>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_TO")); ?></th>
                <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_PRICE")); ?></th>
                <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_QUANTITY")); ?></th>
                <th class="rightalign leftsideview"><?php echo e(cus_lang("TABLE_TOTAL")); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($InvoiceDetail as $ProductRow): ?>
                <?php if($ProductRow->ProductType == \App\Lib\Product::USAGE): ?>
                    <tr>
                        <td class="leftalign"><?php echo e(\App\Lib\Product::getProductName($ProductRow->ProductID,$ProductRow->ProductType)); ?></td>
                        <td class="leftalign"><?php echo e($ProductRow->Description); ?></td>
                        <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->StartDate))); ?></td>
                        <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->EndDate))); ?></td>
                        <td class="rightalign leftsideview"><?php echo e(number_format($total_usage,$RoundChargesAmount)); ?></td>
                        <td class="rightalign leftsideview"><?php echo e($ProductRow->Qty); ?></td>
                        <td class="rightalign leftsideview"><?php echo e(number_format($total_usage,$RoundChargesAmount)); ?></td>
                    </tr>
                <?php endif; ?>
            <?php endforeach; ?>
            </tbody>
        </table>
        <?php endif; ?>

        <?php if($total_sms != 0  && $SMS_DISPLAY == 1): ?>
            <div class="ChargesTitle clearfix">
                <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_SMS")); ?></div>
                <div class="text-right pull-right flip col-harf"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sms,$RoundChargesAmount)); ?></div>
            </div>
            <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
                <thead>
                <tr>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TITLE")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DESCRIPTION")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_FROM")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_TO")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_PRICE")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_QUANTITY")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("TABLE_TOTAL")); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($InvoiceDetail as $ProductRow): ?>
                    <?php if($ProductRow->ProductType == \App\Lib\Product::SMS): ?>
                        <tr>
                            <td class="leftalign"><?php echo e(\App\Lib\Product::getProductName($ProductRow->ProductID,$ProductRow->ProductType)); ?></td>
                            <td class="leftalign"><?php echo e($ProductRow->Description); ?></td>
                            <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->StartDate))); ?></td>
                            <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->EndDate))); ?></td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($total_sms,$RoundChargesAmount)); ?></td>
                            <td class="rightalign leftsideview"><?php echo e($ProductRow->Qty); ?></td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($total_sms,$RoundChargesAmount)); ?></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tbody>
            </table>
        <?php endif; ?>

        <?php if($is_sub): ?>
            <div class="ChargesTitle clearfix">
                <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_RECURRING")); ?></div>
                <div class="text-right pull-right flip col-harf"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_sub,$RoundChargesAmount)); ?></div>
            </div>

            <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
                <thead>
                <tr>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TITLE")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DESCRIPTION")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_FROM")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE_TO")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_PRICE")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_QUANTITY")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DISCOUNT")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("TABLE_TOTAL")); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($InvoiceDetail as $ProductRow): ?>
                    <?php if($ProductRow->ProductType == \App\Lib\Product::SUBSCRIPTION): ?>
                        <tr>
                            <td class="leftalign"><?php echo e(\App\Lib\Product::getProductName($ProductRow->ProductID,$ProductRow->ProductType)); ?></td>
                            <td class="leftalign"><?php echo e($ProductRow->Description); ?></td>
                            <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->StartDate))); ?></td>
                            <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->EndDate))); ?></td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($ProductRow->Price,$RoundChargesAmount)); ?></td>
                            <td class="rightalign leftsideview"><?php echo e($ProductRow->Qty); ?></td>
                            <td class="rightalign leftsideview">
                                <?php if(!empty($ProductRow->DiscountAmount) && !empty($ProductRow->DiscountType)): ?>
                                    <?php echo e(number_format($ProductRow->DiscountAmount,$RoundChargesAmount)); ?><?php if($ProductRow->DiscountType=='Percentage'): ?> % <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($ProductRow->LineTotal,$RoundChargesAmount)); ?></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tbody>
            </table>
        <?php endif; ?>

        <?php if($is_charge): ?>
            <div class="ChargesTitle clearfix">
                <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_ADDITIONAL")); ?></div>
                <div class="text-right pull-right flip col-harf"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($total_add,$RoundChargesAmount)); ?></div>
            </div>

            <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
                <thead>
                <tr>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TITLE")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DESCRIPTION")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_PRICE")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_QUANTITY")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DISCOUNT")); ?></th>
                    <th class="rightalign leftsideview"><?php echo e(cus_lang("TABLE_TOTAL")); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($InvoiceDetail as $ProductRow): ?>
                    <?php if($ProductRow->ProductType == \App\Lib\Product::ONEOFFCHARGE): ?>
                        <tr>
                            <td class="leftalign"><?php echo e(\App\Lib\Product::getProductName($ProductRow->ProductID,$ProductRow->ProductType)); ?></td>
                            <td class="leftalign"><?php echo e($ProductRow->Description); ?></td>
                            <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($ProductRow->StartDate))); ?></td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($ProductRow->Price,$RoundChargesAmount)); ?></td>
                            <td class="rightalign leftsideview"><?php echo e($ProductRow->Qty); ?></td>
                            <td class="rightalign leftsideview">
                                <?php if(!empty($ProductRow->DiscountAmount) && !empty($ProductRow->DiscountType)): ?>
                                    <?php echo e(number_format($ProductRow->DiscountAmount,$RoundChargesAmount)); ?><?php if($ProductRow->DiscountType=='Percentage'): ?> % <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td class="rightalign leftsideview"><?php echo e(number_format($ProductRow->LineTotal,$RoundChargesAmount)); ?></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tbody>
            </table>
        <?php endif; ?>
    </main>


		<?php if($InvoiceTemplate->InvoicePages == 'single_with_detail'): ?>

        <?php if(isset($usage_data_table['data']) && count($usage_data_table['data']) > 0 && $InvoiceTemplate->CDRType != \App\Lib\Account::NO_CDR): ?>

            <div class="page_break"></div>
            <br />
            <br />

            <?php if($InvoiceTemplate->CDRType == \App\Lib\Account::SUMMARY_CDR): ?>
            <main>
                <div class="ChargesTitle clearfix">
                    <div class="pull-left flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_USAGE")); ?></div>
                </div>
                <table  border="0"  width="100%" cellpadding="0" cellspacing="0" id="backinvoice" class="bg_graycolor">
                    <tr>
                        <?php $total_columns_count = 0; ?>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php
                            $classname = 'centeralign';
                            if(in_array($row['Title'],array('AvgRatePerMin','ChargedAmount','NoOfCalls','BillDuration','Duration'))){
                                $classname = 'rightalign leftsideview';
                            }else if(in_array($row['Title'],array('Trunk','AreaPrefix','Country','Description'))){
                                $classname = 'leftalign';
                            }
                            //check how many columns will be displayed to show total in the last
                            if(in_array($row['Title'],array('NoOfCalls','Duration','BillDuration','ChargedAmount'))) {
                                $total_columns_count++;
                            }
                            ?>
                            <th class="<?php echo e($classname); ?>"><?php echo e($row['UsageName']); ?></th>
                        <?php endforeach; ?>
                    </tr>
                    <?php
                    $totalCalls=0;
                    $totalDuration=0;
                    $totalBillDuration=0;
                    $totalTotalCharges=0;
                    ?>


                            <?php foreach($usage_data_table['data'] as $ServiceID => $usage_data): ?>
							<?php foreach($usage_data as $row): ?>
                                <?php
                                $totalCalls  += $row['NoOfCalls'];
                                $totalDuration  += $row['DurationInSec'];
                                $totalBillDuration  += $row['BillDurationInSec'];
                                $totalTotalCharges  += str_replace(',','',$row['ChargedAmount']);
                                ?>
                                <tr>
                                    <?php foreach($usage_data_table['header'] as $table_h_row): ?>
                                        <?php
                                        $classname = 'centeralign';
                                        if(in_array($table_h_row['Title'],array('AvgRatePerMin','ChargedAmount','NoOfCalls','BillDuration','Duration'))){
                                            $classname = 'rightalign leftsideview';
                                        }else if(in_array($table_h_row['Title'],array('Trunk','AreaPrefix','Country','Description'))){
                                            $classname = 'leftalign';
                                        }
                                        ?>
                                        <?php if($table_h_row['Title'] == 'ChargedAmount'): ?>
                                                <td class="<?php echo e($classname); ?>"><?php echo e($CurrencySymbol); ?><?php echo e(\App\Lib\Invoice::NumberFormatNoZeroValue($row['ChargedAmount'],$RoundChargesCDR)); ?></td>
                                        <?php elseif($table_h_row['Title'] == 'AvgRatePerMin'): ?>
											<td class="<?php echo e($classname); ?>"><?php echo e($CurrencySymbol); ?><?php echo e($row['BillDurationInSec'] != 0? number_format($row['AvgRatePerMin'],$RoundChargesCDR) : 0); ?></td>
                                        <?php else: ?>
                                            <td class="<?php echo e($classname); ?>"><?php echo e($row[$table_h_row['Title']]); ?></td>
                                        <?php endif; ?>
                                    <?php endforeach; ?>

                                </tr>
                            <?php endforeach; ?>
							<?php endforeach; ?>


                    <?php
                    $totalDuration = intval($totalDuration / 60) .':' . ($totalDuration % 60);
                    $totalBillDuration = intval($totalBillDuration / 60) .':' . ($totalBillDuration % 60);
                    ?>
                    <?php if($total_columns_count > 0): ?>
                    <tr>
                        <th class="rightalign" colspan="<?php echo e(count($usage_data_table['header']) - $total_columns_count); ?>"></th>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php if(in_array($row['Title'],array('NoOfCalls','Duration','BillDuration','ChargedAmount'))): ?>
                                <th class="centeralign"><?php echo e($row['UsageName']); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <tr>
                        <th class="rightalign leftsideview" colspan="<?php echo e(count($usage_data_table['header']) - $total_columns_count); ?>"><strong><?php echo e(cus_lang("TABLE_TOTAL")); ?></strong></th>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php if($row['Title'] == 'NoOfCalls'): ?>
                                <th class="centeralign"><?php echo e($totalCalls); ?></th>
                            <?php elseif($row['Title'] == 'Duration'): ?>
                                <th class="centeralign"><?php echo e($totalDuration); ?></th>
                            <?php elseif($row['Title'] == 'BillDuration'): ?>
                                <th class="centeralign"><?php echo e($totalBillDuration); ?></th>
                            <?php elseif($row['Title'] == 'ChargedAmount'): ?>
                                <th class="centeralign"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($totalTotalCharges,$RoundChargesAmount)); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <?php endif; ?>
                </table>
            </main>
            <?php endif; ?>

            <?php if($InvoiceTemplate->CDRType == \App\Lib\Account::DETAIL_CDR): ?>
            <main>
                <?php foreach($CallTypeData as $key=>$Value): ?>
                <div class="ChargesTitle clearfix">
                    <?php if($Value=='NoCallType'): ?>
                        <div class="pull-left flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_USAGE")); ?></div>
                    <?php else: ?>
                        <?php if($Value=='OutBound'): ?>
                        <div class="pull-left flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_USAGE")); ?> - Outgoing</div>
                        <?php endif; ?>
                        <?php if($Value=='InBound'): ?>
                        <div class="pull-left flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_USAGE")); ?> - Incoming</div>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
                <table  border="0"  width="100%" cellpadding="0" cellspacing="0" id="backinvoice" class="bg_graycolor">
                    <tr>
                        <?php $total_columns_count = 0; ?>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php
                            $classname = 'centeralign';
                            if(in_array($row['Title'],array('ChargedAmount','BillDuration','BillDurationMinutes'))){
                                $classname = 'rightalign leftsideview';
                            }else if(in_array($row['Title'],array('CLI','Prefix','CLD','ConnectTime','DisconnectTime'))){
                                $classname = 'leftalign';
                            }
                            //check how many columns will be displayed to show total in the last
                            if(in_array($row['Title'],array('BillDuration','BillDurationMinutes','ChargedAmount'))) {
                                $total_columns_count++;
                            }
                            ?>
                            <th class="<?php echo e($classname); ?>"><?php echo e($row['UsageName']); ?></th>
                        <?php endforeach; ?>
                    </tr>
                    <?php
                    $totalBillDuration=0;
                    $totalTotalCharges=0;
                    $CallTypeColumn='';
                    if($Value=='InBound'){
                        $CallTypeColumn='Incoming';
                    }
                    if($Value=='OutBound'){
                        $CallTypeColumn='Outgoing';
                    }
                    ?>
                    <?php foreach($usage_data_table['data'] as $ServiceID => $usage_data): ?>
                    <?php foreach($usage_data as $row): ?>
                       <?php if($row['CallType']==$CallTypeColumn || $DisplayCallType==0): ?>
                            <?php
                                $totalBillDuration  +=  $row['BillDuration'];
                                $totalTotalCharges  += str_replace(',','',$row['ChargedAmount']);
                            ?>
                        <tr>
                            <?php foreach($usage_data_table['header'] as $table_h_row): ?>
                                <?php
                                $classname = 'centeralign';
                                if(in_array($table_h_row['Title'],array('ChargedAmount','BillDuration','BillDurationMinutes'))){
                                    $classname = 'rightalign leftsideview';
                                }else if(in_array($table_h_row['Title'],array('CLI','Prefix','CLD','ConnectTime','DisconnectTime'))){
                                    $classname = 'leftalign';
                                }
                                ?>
                                <?php if($table_h_row['Title'] == 'ChargedAmount'): ?>
                                    <td class="<?php echo e($classname); ?>"><?php echo e($CurrencySymbol); ?><?php echo e(\App\Lib\Invoice::NumberFormatNoZeroValue($row['ChargedAmount'],$RoundChargesCDR)); ?></td>
                                <?php elseif($table_h_row['Title'] == 'CLI' || $table_h_row['Title'] == 'CLD'): ?>
                                    <td class="<?php echo e($classname); ?>"><?php echo e(substr($row[$table_h_row['Title']],1)); ?></td>
                                <?php else: ?>
                                    <td class="<?php echo e($classname); ?>"><?php echo e($row[$table_h_row['Title']]); ?></td>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        </tr>
                       <?php endif; ?>
                    <?php endforeach; ?>
                    <?php endforeach; ?>

                    <?php
                    $totalBillDurationMinutes = intval($totalBillDuration / 60) .':' . ($totalBillDuration % 60);
                    ?>
                    <?php if($total_columns_count > 0): ?>
                    <tr>
                        <th class="rightalign" colspan="<?php echo e(count($usage_data_table['header']) - $total_columns_count); ?>"></th>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php if(in_array($row['Title'],array('BillDuration','BillDurationMinutes','ChargedAmount'))): ?>
                                <th class="centeralign"><?php echo e($row['UsageName']); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <tr>
                        <th class="rightalign leftsideview" colspan="<?php echo e(count($usage_data_table['header']) - $total_columns_count); ?>"><strong><?php echo e(cus_lang("TABLE_TOTAL")); ?></strong></th>
                        <?php foreach($usage_data_table['header'] as $row): ?>
                            <?php if($row['Title'] == 'BillDuration'): ?>
                                <th class="centeralign"><?php echo e($totalBillDuration); ?></th>
                            <?php elseif($row['Title'] == 'BillDurationMinutes'): ?>
                                <th class="centeralign"><?php echo e($totalBillDurationMinutes); ?></th>
                            <?php elseif($row['Title'] == 'ChargedAmount'): ?>
                                <th class="centeralign"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($totalTotalCharges,$RoundChargesAmount)); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <?php endif; ?>
                </table>
                <?php endforeach; ?>
            <?php endif; ?>
            </main>
            <?php endif; ?>

        <?php endif; ?>
    <!-- sms start -->

    <?php if(isset($sms_data_table['data']) && count($sms_data_table['data']) > 0): ?>

        <div class="page_break"></div>
        <br />
        <br />

        <main>
            <div class="ChargesTitle clearfix">
                <div class="pull-left flip"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_LBL_SMS")); ?></div>
            </div>

            <table  border="0"  width="100%" cellpadding="0" cellspacing="0" id="backinvoice" class="bg_graycolor">
                <tr>

                    <?php $total_columns_count = 0; ?>

                    <?php foreach($sms_data_table['header'] as $row): ?>
                        <?php
                        $classname = 'centeralign';
                        if(in_array($row['Title'],array('ChargedAmount','NoOfSMSs'))){
                            $classname = 'rightalign leftsideview';
                        }else if(in_array($row['Title'],array('Country','MCMNC'))){
                            $classname = 'leftalign';
                        }
                        //check how many columns will be displayed to show total in the last
                        if(in_array($row['Title'],array('ChargedAmount','NoOfSMSs'))) {
                            $total_columns_count++;
                        }
                        ?>
                        <th class="<?php echo e($classname); ?>"><?php echo e($row['UsageName']); ?></th>
                    <?php endforeach; ?>
                </tr>
                <?php
                $totalTotalCharges=0;
                $totalNoOfSMSss=0;
                ?>

                <?php foreach($sms_data_table['data'] as $ServiceID => $sms_data): ?>
                    <?php foreach($sms_data as $row): ?>
                        <?php
                            $totalTotalCharges  += str_replace(',','',$row['ChargedAmount']);
                            $totalNoOfSMSss  += str_replace(',','',$row['NoOfSMSs']);
                        ?>
                        <tr>
                            <?php foreach($sms_data_table['header'] as $table_h_row): ?>

                                <?php
                                $classname = 'centeralign';
                                if(in_array($table_h_row['Title'],array('ChargedAmount','NoOfSMSs'))){
                                    $classname = 'rightalign leftsideview';
                                }else if(in_array($table_h_row['Title'],array('Country','MCMNC'))){
                                    $classname = 'leftalign';
                                }
                                ?>
                                <?php if($table_h_row['Title'] == 'ChargedAmount'): ?>
                                    <td class="<?php echo e($classname); ?>"><?php echo e($CurrencySymbol); ?><?php echo e(\App\Lib\Invoice::NumberFormatNoZeroValue($row['ChargedAmount'],$RoundChargesCDR)); ?></td>
                                <?php else: ?>
                                    <td class="<?php echo e($classname); ?>"><?php echo e($row[$table_h_row['Title']]); ?></td>
                                <?php endif; ?>

                            <?php endforeach; ?>
                        </tr>
                    <?php endforeach; ?>
                <?php endforeach; ?>


                <?php if($total_columns_count > 0): ?>
                    <tr>
                        <th class="rightalign" colspan="<?php echo e(count($sms_data_table['header']) - $total_columns_count); ?>"></th>
                        <?php foreach($sms_data_table['header'] as $row): ?>
                            <?php if(in_array($row['Title'],array('NoOfSMSs'))): ?>
                                <th class="centeralign"><?php echo e($row['UsageName']); ?></th>
                            <?php elseif(in_array($row['Title'],array('ChargedAmount'))): ?>
                                <th class="centeralign"><?php echo e($row['UsageName']); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                    <tr>
                        <th class="rightalign leftsideview" colspan="<?php echo e(count($sms_data_table['header']) - $total_columns_count); ?>"><strong><?php echo e(cus_lang("TABLE_TOTAL")); ?></strong></th>
                        <?php foreach($sms_data_table['header'] as $row): ?>
                            <?php if(in_array($row['Title'],array('NoOfSMSs'))): ?>
                                <th class="centeralign"><?php echo e($totalNoOfSMSss); ?></th>
                            <?php elseif($row['Title'] == 'ChargedAmount'): ?>
                                <th class="centeralign"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($totalTotalCharges,$RoundChargesAmount)); ?></th>
                            <?php endif; ?>
                        <?php endforeach; ?>
                    </tr>
                <?php endif; ?>

            </table>


        </main>

        <?php endif; ?>

    <!-- sms end -->

    <?php if((!empty($InvoiceTemplate->ShowPaymentWidgetInvoice) && !empty($payment_data) && count($payment_data)>0) || (count($AllTaxSummary)>0 && $InvoiceTemplate->ShowTaxesOnSeparatePage==1)): ?>
        <div class="page_break"></div>
        <?php if(count($AllTaxSummary)>0 && $InvoiceTemplate->ShowTaxesOnSeparatePage==1): ?>
        <div class="ChargesTitle clearfix">
            <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TAXE_SUMMARY")); ?></div>
        </div>

        <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
            <thead>
            <tr>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_TITLE")); ?></th>
                <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_AMOUNT")); ?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($AllTaxSummary as $row): ?>
                <tr>
                    <td class="leftalign"><?php echo e($row['Title']); ?></td>
                    <td class="leftalign"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($row['Amount'],$RoundChargesAmount)); ?></td>
                </tr>
            <?php endforeach; ?>
            <tr>
                <td class="leftalign total"><?php echo e(cus_lang("TABLE_TOTAL")); ?></td>
                <td class="leftalign total"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($AllTaxCount,$RoundChargesAmount)); ?></td>
            </tr>
            </tbody>
        </table>
        <?php endif; ?>
        <?php if(!empty($InvoiceTemplate->ShowPaymentWidgetInvoice) && !empty($payment_data) && count($payment_data)>0): ?>
            <div class="ChargesTitle clearfix">
                <div class="pull-left flip col-harf"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_PAYMENT")); ?></div>
            </div>

            <table border="0" cellspacing="0" cellpadding="0" id="backinvoice">
                <thead>
                <tr>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_DATE")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_AMOUNT")); ?></th>
                    <th class="leftalign"><?php echo e(cus_lang("CUST_PANEL_PAGE_INVOICE_PDF_TBL_NOTES")); ?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($payment_data as $row): ?>
                    <?php
                    $AllPayment  += str_replace(',','',$row['Amount']);
                    ?>
                    <tr>
                        <td class="leftalign"><?php echo e(date($InvoiceTemplate->DateFormat,strtotime($row['PaymentDate']))); ?></td>
                        <td class="leftalign"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($row['Amount'],$RoundChargesAmount)); ?></td>
                        <td class="leftalign"><?php echo e($row['Notes']); ?></td>
                    </tr>
                <?php endforeach; ?>
                <tr>
                    <td class="leftalign total"><?php echo e(cus_lang("TABLE_TOTAL")); ?></td>
                    <td class="leftalign total" colspan="2"><?php echo e($CurrencySymbol); ?><?php echo e(number_format($AllPayment,$RoundChargesAmount)); ?></td>
                </tr>
                </tbody>
            </table>
        <?php endif; ?>

    <?php endif; ?>

        <?php if(!empty($ManagementReports) && $total_usage != 0): ?>
            <div class="page_break"></div>
            <?php echo $__env->make('emails.invoices.management_chart', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <?php endif; ?>

 <?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.print', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>