<style>
    .ValSpan {
        opacity: 0
    }

    .text-center {
        padding-right: 50% !important;
    }

    .panel .panel-heading {
        padding: 10px 15px !important;
    }

    .WidgetTitle {
        font-size: 17px !important;
        color: white;
        margin: 0;
        opacity: 1;
        /*text-align:center;*/
    }



    .ShowMoreDiv {
        padding: 0 12px;
        position: relative;
        /*        top:15px;*/
    }

    .ShowMoreDiv i.fa {
        top: 1px;
        position: relative;
        margin: 0 4px 0 0;
    }

    .WidgetList>div {
        border-color: rgba(0, 0, 0, 0.2);
        margin-bottom: 10px;
    }

    .WrapText {
        white-space: nowrap;
        width: 100%;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .InvoiceAmount>h4 {
        display: inline-block;
        margin: 0;
    }

    .InvoiceAmountShowDate {
        display: inline-block;
    }

    .InvoiceAmountShowDate>h4 {
        display: table-cell;
    }

    .InvoiceAmountShowDate>h4>span {
        vertical-align: middle;
        font-size: 14px !important;
    }

    .WidgetMenu {
        width: 140px;
        text-align: center;
        border: 1px solid #4c0870;
        padding-bottom: 10px !important;
    }

    .WidgetMenu>.Mini {
        display: inline-block !important;
        color: #555;
        padding: 0 !important;
    }

    .WidgetMenu>li:not(.Mini) {
        display: block !important;
        padding: 5px 0;
    }

    .WidgetMenu>li:not(.Caption)>a {
        padding: 3px 8px;
        line-height: normal;
        opacity: 0.7;
    }

    .WidgetMenu>.Caption:not(:first-child) {
        margin-top: 10px;
    }

    .WidgetMenu>.Caption {
        text-align: left;
        font-size: 14px;
        display: block !important;
        padding: 4px;
        text-indent: 5px;
        line-height: normal !important;
        color: #ccc !important;
    }

    .WidgetMenu>.Selected {
        background: #4c0870;
        color: #fff !important;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
    }

    .WidgetMenu>.Selected>a {
        color: #fff !important;
        opacity: 0.7;
    }

    .ForceShow {
        display: block
    }

    .ForceHide {
        display: none !important;
    }

    .wrap {
        display: inline-block;
        /*
        width:100px;
        white-space: nowrap;
        overflow:hidden !important;
        text-overflow: ellipsis;
        */
        cursor: pointer;
    }

    .ar-2-1 {
        height: 153px;
    }

    .table thead tr>th {
        background: #ed9421;
        color: #fff
    }

    /*.scroll-wrapper .scrollable {
        height: 310px;
    }*/

    .aRows {
        width: 100%;
    }

    .rowDiv {
        bottom: 20px !important;
    }
</style>
<script>
    function AddCommas(val) {
        val = parseFloat(val.toString()).toString();
        while (/(\d+)(\d{3})/.test(val.toString())) {
            val = val.toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2');
        }
        return val.replace(/\.0$|\.00$/, "") || "0";
    }

    function FixNumber(val) {
        return AddCommas(public_round_number(parseFloat(val + "")));
    }
</script>
<script src="<?php echo JS_PATH; ?>Chart.min.js"></script>
<script src="<?php echo JS_PATH; ?>morris.js"></script>
<script src="<?php echo JS_PATH; ?>raphael-2.1.0.min.js"></script>
<script src="<?php echo JS_PATH; ?>jquery.flot.js"></script>
<!--<script src="<?php echo JS_PATH; ?>jquery.flot.tooltip.min.js"></script>-->
<script src="<?php echo JS_PATH; ?>jquery.flot.resize.js"></script>
<script src="<?php echo JS_PATH; ?>jquery.flot.spline.js"></script>
<script src="<?php echo JS_PATH; ?>jquery.flot.pie.js"></script>
<script src="<?php echo JS_PATH; ?>jquery.flot.time.js"></script>
<div class="page-content-wrapper">
    <div class="row">
        <div class="col-md-3 form-group <?php echo $permissions->hasPermission('Branches') ? '':'hidden'; ?>">
            <label><?php echo CommonLanguage::getMessage('choose_branch') ?></label>
            <input id="current_branch_id" value="<?php echo !empty($branch_data) ? $branch_data[0]['branch_id'] : smc_session()['user_accounts']['branch_id']; ?>" data-select-name="<?php echo !empty($branch_data) ? $branch_data[0]['branch_name'] : smc_session()['user_accounts']['branch_name']; ?>" type="hidden" class="full-width" name="current_branch_id">
        </div>
        <div class="col-md-3 form-group">
            <label><?php echo CommonLanguage::getMessage('Date') ?></label>
            <input id="dashboard_date" value="<?php echo (empty($_GET['current_date']) ? $today : $_GET['current_date']); ?>" class="form-control" name="dashboard_date">
        </div>
    </div>
    <div class="row">

        <div class="col-md-6">
            <?php if ($permissions->hasPermission('users_cash') && $permissions->hasPermission('totals_all_invoice_type')) { ?>

                <div class="widget-1-wrapper" style="height:100%;">
                    <!-- START WIDGET -->
                    <div class="widget-1 panel no-border bg-success-darker  widget-loader-circle-lg">

                        <div class="panel-body">
                            <?php if ($permissions->hasPermission('users_cash')) { ?>

                                <div class="col-md-6 col-xlg-6">
                                    <div class="row">
                                        <div class="padding-10">
                                            <div class="pull-top">
                                                <div class="WidgetTitle">
                                                    <?php print CommonLanguage::getMessage('users_cash'); ?>
                                                    <br />
                                                </div>
                                            </div>
                                            <div class="p-b-10 WidgetList">
                                                <?php foreach ($user_cash as $user) { ?>
                                                    <div class="col-xs-12 col-md-12 b-b b-dashed">
                                                        <p style="color:white" class="pull-left wrap " data-toggle="tooltip" data-original-title="<?php echo $user['user']; ?>"><?php echo $user['user']; ?></p>
                                                        <p style="color:white" class="pull-right bold"><?php echo smc_session()['local_currency_symbol'] ?> <?php echo CommonFunctions::formatNumber($user['cash_amount']); ?>
                                                        </p>
                                                    </div>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            <?php }
                            if ($permissions->hasPermission('totals_all_invoice_type')) { ?>
                                <div class="col-md-6 col-xlg-6">
                                    <div class="row">
                                        <div class="padding-10">
                                            <div class="pull-top">
                                                <div class="WidgetTitle">
                                                    <?php print CommonLanguage::getMessage('total_invoice_type'); ?><br />
                                                </div>
                                                <br />
                                            </div>
                                            <div class="p-b-10 WidgetList">
                                                <?php foreach ($total_inv_type as $title => $row) { ?>
                                                    <div class=" col-md-12 b-b b-dashed">
                                                        <p class="pull-left wrap " data-toggle="tooltip" data-original-title="<?php echo CommonLanguage::getMessage($title); ?>"><?php echo CommonLanguage::getMessage($title); ?>
                                                            <span class="badge  " style="min-width:20px;width:auto;padding:0 2px;color:#ed9421;"><?php echo $row['number'] ?></span>
                                                        </p>
                                                        <p class="pull-right bold"><?php echo smc_session()['local_currency_symbol'] ?> <?php echo CommonFunctions::formatNumber($row['amount']); ?>
                                                        </p>
                                                    </div>
                                                <?php } ?>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>
            <?php } ?>
            <div class=" widget-1-wrapper" style="height:100%;">
                <!-- START WIDGET -->
                <div class="widget-1 panel no-border bg-complete widget-loader-circle-lg">
                    <div class="panel-heading top-right ">
                        <div class="panel-controls">
                            <ul>
                                <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:white !important;" class="portlet-icon portlet-icon-refresh"></i></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="col-md-6 col-xlg-6">
                            <div class="row">
                                <div class="padding-10">
                                    <div class="pull-top">
                                        <div class="WidgetTitle">
                                            <?php print CommonLanguage::getMessage('customers_debit'); ?>
                                            <br />
                                        </div>
                                        <div style="text-align:center">
                                            <h3 class="no-margin text-white p-b-10" style="color: #ed9421 !important;"><?php echo smc_session()['local_currency_symbol'] ?>   <?php echo CommonFunctions::formatNumber(abs($receivables['Total_Balance'])); ?>
                                            </h3>
                                        </div>
                                        <br />
                                    </div>
                                    <div class="p-b-10 WidgetList">
                                        <?php for ($i = 0; $i < count($receivables) - 1; $i++) { ?>
                                            <a href="<?php echo $permissions->hasPermission('DebitListPerCustomer') ? SITE_LINK . "ACC/DebitListPerCustomer/" . $receivables[$i]['ID'] : "javascript:void(0)" ?>" class="portlet-refresh text-black aRows" style="float:left">
                                                <!--                                                    <i class="portlet-icon portlet-icon-refresh"></i>-->
                                                <div class="col-md-12 b-b b-dashed">
                                                    <p style="color: #ffff !important;"  class="pull-left wrap " data-toggle="tooltip" data-original-title="<?php echo $receivables[$i]['Name']; ?>"><?php echo $receivables[$i]['Name']; ?></p>
                                                    <p style="color: #ffff !important;" class="pull-right bold"><?php echo smc_session()['local_currency_symbol'] ?> <?php echo CommonFunctions::formatNumber(abs($receivables[$i]['Balance'])); ?>
                                                    </p>
                                                </div>
                                            </a>
                                        <?php
                                            if ($i == 10)
                                                break;
                                        }
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="ShowMoreDiv">
                                <p class="small no-margin ">
                                    <?php if ($i > 10) : ?>
                                        <a href="<?php echo SITE_LINK; ?>ACC/CustomersDebit" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('more_customers'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    <?php endif ?>
                                </p>
                            </div>
                        </div>
                        <div class="col-md-6 col-xlg-6">
                            <div class="row">
                                <div class="padding-10">
                                    <div class="pull-top">
                                        <div class="WidgetTitle">
                                            <?php print CommonLanguage::getMessage('vendors_credit'); ?><br />
                                        </div>
                                        <div style="text-align:center">
                                            <h3 class="no-margin text-white p-b-10" style="color: #ed9421 !important;"><?php echo smc_session()['local_currency_symbol'] ?><?php echo CommonFunctions::formatNumber(abs($payables['Total_Balance'])); ?>
                                            </h3>
                                        </div>
                                        <br />
                                    </div>
                                    <div class="p-b-10 WidgetList">
                                        <?php for ($i = 0; $i < count($payables) - 1; $i++) { ?>
                                            <div class="col-xs-12 col-md-12 b-b b-dashed">
                                                <a href="<?php echo $permissions->hasPermission('CreditListPerVendor') ? SITE_LINK . "ACC/DebitListPerCustomer/vendor/" . $payables[$i]['ID'] : "javascript:void(0)" ?>" class="portlet-refresh text-black aRows" style="float:left">
                                                    <!--                                                <i class="portlet-icon portlet-icon-refresh"></i>-->
                                                    <p style="color:white !important;"  class="pull-left wrap " data-toggle="tooltip" data-original-title="<?php echo $payables[$i]['Name']; ?>"><?php echo $payables[$i]['Name']; ?></p>
                                                    <p style="color:white !important;" class="pull-right bold"><?php echo smc_session()['local_currency_symbol'] ?> <?php echo CommonFunctions::formatNumber(abs($payables[$i]['Balance'])); ?>
                                                    </p>
                                            </div>
                                            </a>
                                        <?php
                                            if ($i == 10)
                                                break;
                                        }
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="ShowMoreDiv">
                                <p class="small no-margin ">
                                    <?php if ($i > 10) : ?>
                                        <a href="<?php echo SITE_LINK; ?>ACC/VendorsCredit" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('more_vendors'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  " style="color: #ed9421 !important;"><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    <?php endif ?>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="ibox float-e-margins " id="accountBarChart" style="background-color: rgba(255, 255, 255, 0.8);">
                <div class="ibox-title" style="padding-left:10px;">
                    <h5> <?php print CommonLanguage::getMessage('acc_report_bar_chart'); ?> </h5>
                </div>
                <div class="ibox-content">
                    <div>
                        <canvas id="barChart" height="226" width="485" style="width: 485px; height: 226px;padding-left:10px;"></canvas>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="widget-11-2 panel no-border panel-condensed widget-loader-circle TopProductsWidget">
                <div class="portlet-progress" style="display: none; background-color: rgba(255, 255, 255, 0.8);">
                    <div class="progress-circle-indeterminate progress-circle-master"></div>
                </div>
                <div class="panel-heading top-left top-right">
                    <div class="panel-controls">
                        <ul>
                            <li class="hidden-xlg">
                                <div class="dropdown">
                                    <a data-target="#" href="#" data-toggle="dropdown" aria-haspopup="true" role="button" aria-expanded="false">
                                        <i class="portlet-icon portlet-icon-settings"></i>
                                    </a>
                                    <ul class="dropdown-menu pull-right WidgetMenu" role="menu">
                                        <li style="color:black !important;" class="Caption"><?php print CommonLanguage::getMessage('items'); ?></li>
                                        <li  data-val="1" class="Mini MItems Selected"><a href="#">5</a></li>
                                        <li data-val="2" class="Mini MItems"><a href="#">10</a></li>
                                        <li data-val="3" class="Mini MItems"><a href="#">15</a></li>
                                        <li style="color:black !important;" class="Caption"><?php print CommonLanguage::getMessage('show'); ?></li>
                                        <li data-val="1" class="Mini MShow Selected"><a href="#"><?php print CommonLanguage::getMessage('sales'); ?></a></li>
                                        <li data-val="2" class="Mini MShow"><a href="#"><?php print CommonLanguage::getMessage('purchase'); ?></a></li>
                                        <li style="color:black !important;" class="Caption"><?php print CommonLanguage::getMessage('sort'); ?></li>
                                        <li data-val="1" class="Mini MSort Selected"><a href="#"><?php print CommonLanguage::getMessage('Quantity'); ?></a></li>
                                        <li data-val="2" class="Mini MSort"><a href="#"><?php print CommonLanguage::getMessage('Price'); ?></a></li>
                                    </ul>
                                </div>
                            </li>
                            <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i  class="portlet-icon portlet-icon-refresh"></i></a></li>
                        </ul>
                    </div>
                </div>
                <div class="padding-25">
                    <div class="pull-left">
                        <h2 class="text-success no-margin TopXCaption"><?php print CommonLanguage::getMessage('top_five_sales'); ?></h2>
                    </div>
                    <h3 class="pull-right semi-bold"><small class="semi-bold"><?php echo smc_session()['local_currency_symbol']; ?></small><span class="WidgetTopSalesTotal"></span></h3>
                    <div class="clearfix"></div>
                </div>
                <div>
                    <div class="scrollable">
                        <div class="demo-portlet-scrollable">
                            <div class="widget-11-2-table padding-25">
                                <table class="table table-condensed table-hover TableOfContents">
                                    <tbody>
                                        <?php foreach ($top_products as $top) : ?>
                                            <tr>
                                                <td class="font-montserrat fs-14 col-lg-4"><?php echo $top['Product_Name']; ?></td>

                                                <td class="text-right b-r b-dashed b-grey col-lg-5">
                                                    <span class="hint-text small"><?php print CommonLanguage::getMessage('price'); ?> <?php echo CommonFunctions::public_round_number(($top['SUM'] / $top['QTY']), 2); ?></span>&nbsp;|&nbsp;
                                                    <span class="hint-text small"><?php print CommonLanguage::getMessage('qty'); ?> <?php echo $top['QTY']; ?></span>
                                                </td>
                                                <td class="col-lg-3">
                                                    <span class="font-montserrat fs-18"><span><?php echo smc_session()['local_currency_symbol']; ?></span><span class=" ItemSumForTopSaled" myval="<?php echo $top['SUM'] ?>"><?php echo CommonFunctions::public_round_number($top['SUM'], 2); ?></span></span>
                                                </td>
                                            </tr>
                                        <?php endforeach; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="padding-25">
                    <canvas id="doughnutChart" height="140"></canvas>
                </div>
                <div class="padding-25">
                    <p class="small no-margin">
                        <a href="#" data-url="<?php echo SITE_LINK; ?>Inventory/InvoiceList" class="ShowMoreButton"><i class="fa fs-16 fa-arrow-circle-o-down text-success m-r-10"></i></a>
                        <span class="hint-text"><?php print CommonLanguage::getMessage('show_more'); ?> </span>
                    </p>
                </div>
            </div>
        </div>
    </div> <!-- START WIDGET -->
    <!-- START WIDGET -->
    <div class="row">
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-master  no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Day">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle" style="color:#eb9220"><?php print CommonLanguage::getMessage('daily_sales'); ?></h2>

                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-white" data-toggle="refresh"><i style="color:black !important;" class="portlet-icon portlet-icon-refresh" style="color:#fff !important"></i></a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                    <div class="col-xs-height ">
                                        <span class="white p-l-15"><?php echo (!empty($last_close_time) ? '(' . CommonLanguage::getMessage('from') . ': ' . $last_close_time . ')' : '') ?></span>
                                    </div>
                                </div>
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20 ">
                                            <h3 class="no-margin p-b-5 " style="color:#eb9220"><?php echo $CurrencySymbol; ?>
                                            <?php echo CommonFunctions::formatNumber($daily_sales) ; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>

                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#eb9220" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/daily" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('daily_sales'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-success no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Week">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-black">
                                                <h2 class="WidgetTitle" style="color:#66cfbe"><?php print CommonLanguage::getMessage('daily_purchase'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i class="portlet-icon portlet-icon-refresh"></i></a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                    <div class="col-xs-height ">
                                        <span class="white p-l-15"><?php echo (!empty($last_close_time) ? '(' . CommonLanguage::getMessage('from') . ': ' . $last_close_time . ')' : '') ?></span>
                                    </div>
                                </div>
                                <div class="row-xs-height">
                                    <div class=" col-top">
                                        <div class="p-l-20 ">
                                            <h3 style="color:#66cfbe" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?> <?php echo !empty($daily_purchases) ? CommonFunctions::formatNumber($daily_purchases) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#66cfbe" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/daily/vendor" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('daily_purchase'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-danger no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Day">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle " style="color:#e85651"><?php print CommonLanguage::getMessage('weekly_sales'); ?></h2> </span>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:black !important;" class="portlet-icon portlet-icon-refresh" style="color:#fff !important"></i></a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                <div class="col-xs-height ">
                                    <span class="white p-l-15"></span>
                                </div>
                                </div>

                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20 ">
                                            <h3 style="color:#e85651" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?>
                                      <?php echo !empty($weekly_sales) ? CommonFunctions::formatNumber($weekly_sales) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#e85651" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/weekly" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('weekly_sales'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-complete-dark no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Week">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-black">
                                                <h2 class="WidgetTitle" style="color:#478fc9"><?php print CommonLanguage::getMessage('weekly_purchase'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i class="portlet-icon portlet-icon-refresh"></i></a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                <div class="col-xs-height ">
                                    <span class="white p-l-15"></span>
                                </div>
                                </div>

                                <div class="row-xs-height">
                                    <div class=" col-top">
                                        <div class="p-l-15 ">
                                            <h3 style="color:#478fc9" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?> <?php echo !empty($weekly_purchases) ? CommonFunctions::formatNumber($weekly_purchases) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#478fc9" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/weekly/vendor" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('weekly_purchase'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-menu-dark no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Month1">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle" style="color:#4c0870"><?php print CommonLanguage::getMessage('monthly_sales'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:#000 !important" class="portlet-icon portlet-icon-refresh"></i></a></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                <div class="col-xs-height ">
                                    <span class="white p-l-15"></span>
                                </div>
                                </div>

                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20 ">
                                            <h3 style="color:#4c0870" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?><?php echo !empty($monthly_sales) ? CommonFunctions::formatNumber($monthly_sales) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#4c0870" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/monthly" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('monthly_sales'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-primary no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Month1">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle" style="color:#4c0870"><?php print CommonLanguage::getMessage('monthly_purchase'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:#4c0870 !important" class="portlet-icon portlet-icon-refresh"></i></a></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="row-xs-height">
                                <div class="col-xs-height ">
                                    <span class="white p-l-15"></span>
                                </div>
                                </div>
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20 ">
                                            <h3 style="color:#4c0870" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?> <?php echo !empty($monthly_purchases) ? CommonFunctions::formatNumber($monthly_purchases) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#4c0870" href="<?php echo SITE_LINK ?>Inventory/InvoiceList/monthly/vendor" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('monthly_purchase'); ?>!">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-success-darker no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Month1">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle" style="color:#3a7c71"><?php print CommonLanguage::getMessage('daily_expenses'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:#000 !important" class="portlet-icon portlet-icon-refresh"></i></a></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>
                               

                                <div class="row-xs-height">
                                    <div class="col-xs-height ">
                                        <span class="white p-l-15"><?php echo (!empty($last_close_time) ? '(' . CommonLanguage::getMessage('from') . ': ' . $last_close_time . ')' : '') ?></span>
                                    </div>
                                </div>
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20 ">
                                            <h3 style="color:#3a7c71" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?><?php echo !empty($daily_expense) ? CommonFunctions::formatNumber($daily_expense) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#3a7c71" href="<?php echo SITE_LINK ?>ACC/ExpensesList/daily" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('daily_expenses'); ?>!">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3 m-b-10">
            <div class="row">
                <div class="col-sm-12 m-b-10">
                    <div class="ar-2-1">
                        <div class="widget-3 panel no-border bg-danger-darker no-margin widget-loader-bar rowDiv" data-cmd="fetchsalespurchase" data-type="Month1">
                            <div class="container-sm-height full-height" style="background-color: #ffffff;">
                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="panel-heading  top-left top-right">
                                            <div class="panel-title text-white">
                                                <h2 class="WidgetTitle" style="color:#933432"><?php print CommonLanguage::getMessage('monthly_expenses'); ?></h2>
                                            </div>
                                            <div class="panel-controls">
                                                <ul>
                                                    <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:#000 !important" class="portlet-icon portlet-icon-refresh"></i></a></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <br>
                                <br>

                                <div class="row-xs-height">
                                <div class="col-xs-height ">
                                    <span class="white p-l-15"></span>
                                </div>
                                </div>

                                <div class="row-xs-height">
                                    <div class="col-xs-height col-top">
                                        <div class="p-l-20  ">
                                            <h3 style="color:#933432" class="no-margin p-b-5 "><?php echo $CurrencySymbol ?> <?php echo !empty($monthly_expense) ? CommonFunctions::formatNumber($monthly_expense) : '0'; ?>
                                            </h3>
                                        </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a style="color:#933432" href="<?php echo SITE_LINK ?>ACC/ExpensesList/monthly" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('monthly_expenses'); ?>!">
                                            <i class="fa fs-16 fa-arrow-circle-o-down "></i>
                                            <span class="hint-text  "><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="row">
        <div class="col-md-6 m-b-10">
            <div class="widget-1-wrapper m-b-20" style="height:100%;">
                <div class=" panel  no-border no-margin widget-loader-circle">
                    <div class="panel-heading">
                        <div class="panel-title">
                            <i class="pg-unordered_list"></i><?php print CommonLanguage::getMessage('latest_unpaid_inv'); ?>
                        </div>
                        <div class="panel-controls">
                            <ul>
                                <li>
                                    <a data-toggle="refresh" class="portlet-refresh text-black" href="#"><i class="portlet-icon portlet-icon-refresh"></i></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="p-l-5">
                            <div class="row">
                                <div class="col-md-12 col-xlg-12">
                                    <?php foreach ($unpaid as $late_invoice) : ?>
                                        <div class="row m-t-20">
                                            <div class="col-md-3">
                                                <h4 class="no-margin wrap" data-toggle="tooltip" data-original-title="<?php echo $late_invoice['Customer_Name']; ?>"><?php echo $late_invoice['Customer_Name']; ?></h4>
                                                <p class="small hint-text"><?php print CommonLanguage::getMessage('due_date'); ?>: <?php echo $late_invoice['Invoice_Due_Date']; ?></p>
                                            </div>
                                            <div class="col-md-4">
                                                <div style="text-align:center">
                                                    <div class="InvoiceAmountShowDate">
                                                        <h4>
                                                            <span class="small"><?php echo $late_invoice['Invoice_Date']; ?></span>
                                                        </h4>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-5">
                                                <div class="pull-right">
                                                    <div class="InvoiceAmount">
                                                        <h4 class="text-danger bold no-margin" data-toggle="tooltip" data-original-title="Unpaid Amount!"><?php echo $late_invoice['Currency_Symbol']; ?>
                                                        <?php echo CommonFunctions::formatNumber($late_invoice['Upaid_Ammount']); ?>
                                                        </h4>
                                                        <h4><span class="small" data-toggle="tooltip" data-original-title="Total Invoice Amount!">/ <?php echo $late_invoice['Currency_Symbol']; ?> <?php echo CommonFunctions::formatNumber($late_invoice['Invoice_Net_Total']); ?>
                                                            </span></h4>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-6 ">
            <div class="widget-1-wrapper m-b-20" style="height:100%;">
                <!-- START WIDGET -->
                <div class="widget-1 panel no-border bg-primary-light no-margin widget-loader-circle-lg">
                    <div class="panel-heading top-right ">
                        <div class="panel-controls">
                            <ul>
                                <li><a href="#" class="portlet-refresh text-black" data-toggle="refresh"><i style="color:white !important;" class="portlet-icon portlet-icon-refresh"></i></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="col-md-6 col-xlg-6">
                            <div class="row">
                                <div class="padding-10">
                                    <div class="pull-top">
                                        <div class="WidgetTitle">
                                            <?php print CommonLanguage::getMessage('cash_dashboard'); ?><br />
                                        </div>
                                        <div style="text-align:center">
                                        <h3 class="no-margin text-white p-b-10" style="color: #ed9421 !important;"><?php echo $CurrencySymbol ?><?php echo CommonFunctions::formatNumber($viewCash['Total_Balance']); ?>
                                            </h3>
                                        </div>
                                        <br />
                                    </div>
                                    <div class="p-b-10 WidgetList">
                                        <?php for ($i = 0; $i < count($viewCash) - 1; $i++) { ?>
                                            <a href="<?php echo $permissions->hasPermission('CashList') ? SITE_LINK . 'ACC/CashList/' . $viewCash[$i]['ID'] : 'javascript:void(0)' ?>" class="portlet-refresh text-black aRows">
                                                <!--                                                    <i class="portlet-icon portlet-icon-refresh"></i>-->
                                                <div class="col-md-12 col-xs-12 b-b b-dashed">
                                                    <p style="color:white !important;" class="pull-left  " data-toggle="tooltip" data-original-title="<?php echo $viewCash[$i]['Name']; ?>"><?php echo $viewCash[$i]['Name']; ?></p>
                                                    <p style="color:white !important;" class="pull-right bold"><?php echo $CurrencySymbol ?>
                                                           <?php echo CommonFunctions::formatNumber($viewCash[$i]['Balance']) ?>
                                                        
                                                    </p>
                                                </div>
                                            </a>
                                        <?php
                                            if ($i == 5)
                                                break;
                                        }
                                        ?>
                                    </div>
                                </div>
                            </div>
                            <div class="ShowMoreDiv">
                                <p class="small no-margin ">
                                    <a href="<?php echo $permissions->hasPermission('CashBalanceDetails') ? SITE_LINK . 'ACC/CashBankBalanceDetails' : 'javascript:void(0)' ?>" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('show_more'); ?>">
                                        <i class="fa fs-16 fa-arrow-circle-o-down " style="color: #ed9421 !important;"></i>
                                        <span class="hint-text  " style="color: #ed9421 !important;"><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                    </a>
                                </p>
                            </div>
                        </div>
                        <div class=" col-md-6 col-xlg-6">
                            <div class="row">
                                <div class="padding-10">
                                    <div class="pull-top">
                                        <div class="WidgetTitle">
                                            <?php print CommonLanguage::getMessage('bank_dashboard'); ?><br />
                                        </div>
                                        <div style="text-align:center">
                                            <h3 class="no-margin text-white p-b-10" style="color: #ed9421 !important;"><?php echo $CurrencySymbol ?> <?php echo CommonFunctions::formatNumber($viewBank['Total_Balance']); ?>
                                            </h3>
                                        </div>
                                        <br />
                                    </div>
                                    <div class="p-b-10 WidgetList">
                                        <?php for ($i = 0; $i < count($viewBank) - 1; $i++) { ?>
                                            <div class="col-md-12 b-b b-dashed" style="padding-top: 10px;">
                                                <a href="<?php echo $permissions->hasPermission('BankList') ? SITE_LINK . 'ACC/BankList/' . $viewBank[$i]['ID'] : 'javascript:void(0)' ?>" class="portlet-refresh text-black aRows">
                                                    <!--                                                <i class="portlet-icon portlet-icon-refresh"></i>-->
                                                    <p  style="color:white"  class="pull-left wrap " data-toggle="tooltip" data-original-title="<?php echo $viewBank[$i]['Name']; ?>"><?php echo $viewBank[$i]['Name']; ?></p>
                                                    <p  style="color:white" class="pull-right bold"><?php echo $CurrencySymbol; ?> <?php echo $viewBank[$i]['Balance']; ?>
                                                    </p>
                                                </a>
                                            <?php
                                            if ($i == 5)
                                                break;
                                        }
                                            ?>
                                            </div>
                                    </div>
                                </div>
                                <div class="ShowMoreDiv">
                                    <p class="small no-margin ">
                                        <a href="<?php echo $permissions->hasPermission('BankBalanceDetails') ? SITE_LINK . 'ACC/CashBankBalanceDetails/Bank' : 'javascript:void(0)' ?>" data-placement="top" title="" data-toggle="tooltip" data-original-title="<?php print CommonLanguage::getMessage('show_more'); ?>">
                                            <i class="fa fs-16 fa-arrow-circle-o-down " style="color: #ed9421 !important;"></i>
                                            <span class="hint-text  " style="color: #ed9421 !important;"><?php print CommonLanguage::getMessage('show_more'); ?></span>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var TopLang = <?php echo json_encode(CommonLanguage::getMessage('top')); ?>,
            pricelang = <?php echo json_encode(CommonLanguage::getMessage('price')); ?>,
            qtyLang = <?php echo json_encode(CommonLanguage::getMessage('qty')); ?>;
        //$(document).ready(function () {
        //    /* ----------  equal height columns   -------- */
        //    $('.inner').matchHeight();
        //});
        $(".WidgetMenu > li:not(.Caption)").on("click", function(e) {
            e.preventDefault();
            var me = $(this),
                Loader = $(">.portlet-progress", me.parents(".TopProductsWidget"));
            //if(Loader.is(":visible"))return
            me.parent().addClass("ForceHide")
            Loader.show()
            setTimeout(function() {
                var MyClass = me.hasClass("MItems") ? "MItems" : (me.hasClass("MShow") ? "MShow" : "MSort");
                me.parent().find("li." + MyClass).removeClass("Selected").end().find("li").eq(me.index()).addClass("Selected") //.parents(".dropdown").addClass("open")
                $.ajax({
                    url: "Dashboard/DashboardAjax",
                    data: {
                        cmd: "fetchtopsalesdata",
                        items: $(">.MItems.Selected", me.parent()).attr("data-val"),
                        type: $(">.MShow.Selected", me.parent()).attr("data-val"),
                        sort: $(">.MSort.Selected", me.parent()).attr("data-val")
                    },
                    dataType: "json",
                    complete: function(v, vv) {
                        if (vv == "success" && typeof(v.responseJSON) === "object") {
                            var TargetTableBody = me.parents(".TopProductsWidget").find(".TableOfContents > tbody").empty();
                            for (var x = 0; x < v.responseJSON.length; x++) {
                                var TR = '<tr>' +
                                    '<td class="font-montserrat fs-14 col-lg-4">' + v.responseJSON[x]["Product_Name"] + '</td>' +
                                    '<td class="text-right b-r b-dashed b-grey col-lg-5"><span class="hint-text small">' + pricelang + ': ' + AddCommas(public_round_number(parseFloat(v.responseJSON[x]['SUM']) / parseFloat(v.responseJSON[x]['QTY']))) + '</span>&nbsp;|&nbsp;' +
                                    '<span class="hint-text small">' + qtyLang + ' ' + AddCommas(public_round_number(parseFloat(v.responseJSON[x]["QTY"]))) + '</span></td>' +
                                    '<td class="col-lg-3"><span class="font-montserrat fs-18"><span><?php echo $CurrencySymbol; ?></span><span class=" ItemSumForTopSaled" style="opacity:1" myval="' + v.responseJSON[x]["SUM"] + '">' + AddCommas(public_round_number(parseFloat(v.responseJSON[x]["SUM"]))) + '</span></span></td>' +
                                    '</tr>';
                                TargetTableBody.append($(TR))
                            }
                            me.parents(".TopProductsWidget").find(".TopXCaption").html(TopLang + " " + $(">.MItems.Selected", me.parent()).text() + " " + $(">.MShow.Selected", me.parent()).text())
                            me.parents(".TopProductsWidget").attr("IsSales", $(">.MShow.Selected", me.parent()).attr("data-val") == 1 ? "yes" : "no")
                            UpdateWidgetsTopProducts()
                        }
                        me.parent().removeClass("ForceHide").parents(".dropdown").removeClass("open")
                        Loader.hide();
                    }
                })
            }, 0)
        });

        // to remove many digits after the period
        $(function() {
            //        var labels =<?php echo json_encode($arrName1); ?>;
            $(".ValSpan").each(function() {
                $(this).attr({
                    myval: $(this).text()
                }).html(AddCommas(public_round_number(parseFloat($.trim($(this).text()))))).animate({
                    opacity: 1
                })
            })
            UpdateWidgetsTopProducts();
            PIE(<?php echo (json_encode($arrName)) ?>, <?php echo (json_encode($arrValue)) ?>);
            BarChartTotal(<?php echo (json_encode($arrVal)); ?>, <?php echo json_encode($arrName1); ?>);
            $('#dashboard_date').datepicker({
                autoclose: true
            });
            build_select2($("#current_branch_id"), "xhr/CommonSearch?col_name=branch_name&col_id=branch_id&table=tbl_organization_branches");
            $("#dashboard_date,#current_branch_id").on("change", function() {
                window.location = 'Dashboard?branch_id=' + $('#current_branch_id').val() + '&current_date=' + $('#dashboard_date').val();
            });
        })

        function UpdateWidgetsTopProducts() {
            $(".TopProductsWidget").each(function() {

                var MySum = 0;
                $(".ItemSumForTopSaled[myval]", this).each(function() {
                    MySum += parseFloat($(this).attr("myval"));
                    //                     console.log('here')
                })
                $(".WidgetTopSalesTotal", this).text(AddCommas(public_round_number(MySum)))
                $(".ShowMoreButton", this).attr("href", $(".ShowMoreButton", this).attr("data-url") + ($(this).attr("IsSales") == "no" ? "/vendor" : ""))
            })
        }

        function PIE(GetLabel, GetValue) {
            var label_length = GetLabel.length;
            if (label_length < 5) {
                for (i = label_length; i < 5; i++) {
                    GetLabel.push("");
                    GetValue.push(0);
                }
            }


            var doughnutData = {
                labels: GetLabel,
                datasets: [{
                    label: "Pie Report",
                    data: GetValue,
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.2)',
                        'rgba(54, 162, 235, 0.2)',
                        'rgba(255, 206, 86, 0.2)',
                        'rgba(75, 192, 192, 0.2)',
                        'rgba(153, 102, 255, 0.2)'
                    ],
                    borderColor: [
                        'rgba(255, 99, 132, 1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)',
                        'rgba(153, 102, 255, 1)'
                    ],
                }]
            };
            var doughnutOptions = {
                segmentShowStroke: true,
                segmentStrokeColor: "#fff",
                segmentStrokeWidth: 2,
                percentageInnerCutout: 45, // This is 0 for Pie charts
                animationSteps: 100,
                animationEasing: "easeOutBounce",
                animateRotate: true,
                animateScale: true,
                responsive: true,
            };
            var ctx = document.getElementById("doughnutChart").getContext("2d");
            // var myNewChart = new Chart(ctx).doughnut(doughnutData, doughnutOptions);

            var myNewChart = new Chart(ctx, {
                type: 'doughnut',
                data: doughnutData,
                options: doughnutOptions
            });
        }

        function BarChartTotal(Total, labels) {
            var barData = {
                labels: labels,
                datasets: [{
                    label: "Accounting Report",
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.2)',
                        'rgba(54, 162, 235, 0.2)',
                        'rgba(255, 206, 86, 0.2)',
                        'rgba(75, 192, 192, 0.2)',
                        'rgba(153, 102, 255, 0.2)',
                        'rgba(255, 159, 64, 0.2)',
                        'rgba(255, 159, 64, 0.2)',
                        'rgba(255, 159, 64, 0.2)',
                        'rgba(255, 159, 64, 0.2)',
                    ],
                    borderColor: [
                        'rgba(255, 99, 132, 1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)',
                        'rgba(153, 102, 255, 1)',
                        'rgba(255, 159, 64, 1)',
                        'rgba(255, 159, 64, 1)',
                        'rgba(255, 159, 64, 1)',
                        'rgba(255, 159, 64, 1)',
                    ],
                    borderWidth: 1,
                    data: Total
                }]
            };
            var barOptions = {
                scaleBeginAtZero: false,
                scaleShowGridLines: false,
                scaleGridLineColor: "#8a7dbe",
                scaleGridLineWidth: 1,
                scaleShowHorizontalLines: true,
                scaleShowVerticalLines: true,
                barShowStroke: true,
                barStrokeWidth: 2,
                barValueSpacing: 5,
                barDatasetSpacing: 1,
                responsive: true,
            }
            var ctx = document.getElementById("barChart").getContext("2d");
            // MonthmyLineChart = new Chart(ctx).Bar(barData, barOptions);
            var MonthmyLineChart = new Chart(ctx, {
                type: 'bar',
                data: barData,
                options: barOptions
            });
        }
    </script>