<style>
    .borderleft{
        border-left: 2px solid #ddd;
    }
</style>
<div class="row">
    <div class="container">
        <!--show-------------------------------------------------------------------------------------------->
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title"><strong> ميزان المراجعة الشهرى</strong></h3>
                <a href="{$youtubes[222]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
            </div>
            <div class="panel-body">
                ,
                <form class="form-inline hidden-print" action="monthlytrialbalance.php" method="post">
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off" data-date-format="yyyy-mm-dd" name="from">
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off" data-date-format="yyyy-mm-dd" name="to">
                    </div>

                    <button type="submit" class="btn btn-primary">بحث</button>

                </form>
                <p>{$msg}</p>
                <hr/>

                <div class="form-group">
                    <label class="sr-only"> اخفاء الاجمالى صفر</label>
                    <input type="checkbox" name="bure" id="bure" checked="checked" value="1">
                    <label for="bure"></label>
                </div>
                <div id="dailyEntryTable" style="overflow-x: scroll">

                    <table class="table table-black">
                        <thead>
                            <tr class="mytotal">
                                <th rowspan="2" class="solidgrayright">#</th>
                                <th rowspan="2">الكود</th>
                                <th rowspan="2" style="min-width: 250px">الحساب</th>

                                <th colspan="2" style="min-width:150px;text-align: center" class="borderleft">رصيد اول المدة</th>
                                {foreach $months as $month}
                                <th colspan="2" style="min-width:150px;text-align: center" class="borderleft">{$month}</th>
                                {/foreach}
                                <th colspan="2" style="min-width:150px;text-align: center" class="borderleft">الاجمالى</th>
                                <th colspan="2" style="min-width:150px;text-align: center" class="borderleft">رصيد</th>
                            </tr>
                            <tr class="mytotal">
                                <th>مدين</th>
                                <th class="borderleft">دائن</th>
                                {foreach $months as $month}
                                <th>مدين</th>
                                <th class="borderleft">دائن</th>
                                {/foreach}
                                <th>مدين</th>
                                <th class="borderleft">دائن</th>
                                <th>مدين</th>
                                <th class="borderleft">دائن</th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=netDebt value=0}
                            {assign var=netCredit value=0}
                            {assign var=i value=1}
                            {foreach $balanceArray as $data}
                            <tr>
                                <td>{$i}</td>
                                <td>{$data->layingOrder}</td>
                                <td>{$data->customName}</td>

                                <th>{$data->firstPeriodDebtor}</th>
                                <th class="borderleft">{$data->firstPeriodCreditor}</th>

                                {assign var=totMonthsDebt value=$data->firstPeriodDebtor}
                                {assign var=totMonthsCredit value=$data->firstPeriodCreditor}
                                {assign var=m value=1}
                                {foreach $months as $month}
                                <th>{$data->theValue2[$month]['debt']}</th>
                                <th class="borderleft">{$data->theValue2[$month]['credit']}</th>
                                {assign var=m value=$m+1}
                                {assign var=totMonthsDebt value=$totMonthsDebt+$data->theValue2[$month]['debt']}
                                {assign var=totMonthsCredit value=$totMonthsCredit+$data->theValue2[$month]['credit']}
                                {/foreach}

                                <th>{$totMonthsDebt}</th>
                                <th class="borderleft">
                                    {$totMonthsCredit}
                                    <input type="hidden" id="iszero{$i}" class="iszeroClass" data-itr="{$i}" value="{if $totMonthsDebt == 0 && $totMonthsCredit == 0}1{else}0{/if}">
                                </th>

                                <th>
                                    {if $totMonthsDebt > $totMonthsCredit}
                                    {$totMonthsDebt-$totMonthsCredit}

                                    {if  $data->islastLeaf == 1}{assign var=netDebt value=$netDebt + ($totMonthsDebt-$totMonthsCredit)}{/if}
                                    {if (($showClientsAtTree == 0 && ($data->id == 58 || $data->id == 60)) || ($showSuppliersAtTree == 0 && ($data->id == 81 || $data->id == 87))) }
                                    {assign var=netDebt value=$netDebt + ($totMonthsDebt-$totMonthsCredit)}
                                    {/if}


                                    {/if}


                                </th>
                                <th class="borderleft">
                                    {if $totMonthsCredit > $totMonthsDebt}
                                    {$totMonthsCredit-$totMonthsDebt}

                                    {if  $data->islastLeaf == 1}{assign var=netCredit value=$netCredit + ($totMonthsCredit-$totMonthsDebt)}{/if}
                                    {if (($showClientsAtTree == 0 && ($data->id == 58 || $data->id == 60)) || ($showSuppliersAtTree == 0 && ($data->id == 81 || $data->id == 87))) }
                                    {assign var=netCredit value=$netCredit + ($totMonthsCredit-$totMonthsDebt)}
                                    {/if}


                                    {/if}
                                </th>

                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                            <tr style="background-color: gray">
                                <td colspan="3" style="text-align: center">الاجــمــالــى</td>

                                <td>{$totalsArr['firstPeriodDebtor']}</td>
                                <td>{$totalsArr['firstPeriodCreditor']}</td>

                                {assign var=allDebtTot value=$totalsArr['firstPeriodDebtor']}
                                {assign var=allCreditTot value=$totalsArr['firstPeriodCreditor']}
                                {assign var=m value=1}
                                {foreach $months as $month}
                                <td>{$totalsArr[{$month}]['debt']}</td>
                                <td>{$totalsArr[{$month}]['credit']}</td>

                                {assign var=allDebtTot value=$allDebtTot + {$totalsArr[{$month}]['debt']}}
                                {assign var=allCreditTot value=$allCreditTot + {$totalsArr[{$month}]['credit']}}

                                {assign var=m value=$m+1}
                                {/foreach}

                                <td>{$allDebtTot}</td>
                                <td>{$allCreditTot}</td>
                                <td>{$netDebt}</td>
                                <td>{$netCredit}</td>

                            </tr>
                        </tbody>
                    </table>

                </div>
                </br>
            </div>
        </div>
    </div>
</div>






{literal}
<script>
    $(function () {

        $('#bure').live('change', function () {
            $('.iszeroClass').each(function () {
                var itr = $(this).data('itr');
                if ($('#bure').is(':checked') && $(this).val() == 1) {
                    $('#iszero' + itr).parent().parent().hide();
                } else {
                    $('#iszero' + itr).parent().parent().show();
                }
            })
        });
        $('#bure').change();


    });

</script>
{/literal}