<style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }

    .nodata {
        background-color: #72B4EC;
        color: white;
        border-radius: 13px;
        margin: 14px;
        font-size: 24px;
        text-align: center;
        padding: 5px;
    }

    @media print {

        #ResultTable th,
        #ResultTable td {
            padding: 20px !important;
        }
    }
</style>

<div class="row">
    <div class="container {if $lang_code == 'en'} gt4-ltr{/if}">
        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li><a href="savedailyController.php?do=show">تقرير حركة للخزنه مجمع</a></li>
            <li class="active">عرض التقرير</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير حركة للخزنه مجمع
                <a href="{$youtubes[118]->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="savedailyController.php?do=joined" method="post">

                    <div class="form-group">
                        <label class="sr-only">الخزنة</label>
                        <select class="select2 wdt300" name="saveId" id="saveid">
                            <option value="-1">اختر خزنة</option>
                            {foreach $saveData as $save}
                            <a href="show_ltr.html"></a>
                            <option value="{$save['saveid']}">{$save['savename']}</option>
                            {/foreach}
                        </select>

                    </div>
                    <div class="form-group">
                        <label class="sr-only">المستخدم</label>
                        <select class="select2 wdt300" name="userId" id="userId">
                            <option value="-1"> اختر مستخدم </option>
                            {foreach $usersData as $data}
                            <option value="{$data->userid}">{$data->employeename}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">خزن مجمعة </label>
                        <input type="checkbox" class="" name="mergeSaves" checked="checked" value="1">
                    </div>
                    <br />

                    {if $savedailydate eq 1}
                    <div id="dateTimeDiv">
                        <div class="form-group">
                            <label class="sr-only">من التاريخ</label>
                            <div class="input-group date form_datetime col-md-5" data-date=""
                                data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                <input class="form-control" size="16" type="text" value="" name="from" id="from"
                                    readonly="">
                                <span class="input-group-addon " style="width: 0%;"><span
                                        class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                <span class="input-group-addon" style="width: 0%;"><span
                                        class="glyphicon glyphicon-th col-lg-4"></span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="sr-only">إلى التاريخ</label>
                            <div class="input-group date form_datetime col-md-5" data-date=""
                                data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                <input class="form-control" size="16" type="text" value="" name="to" id="to"
                                    readonly="">
                                <span class="input-group-addon " style="width: 0%;"><span
                                        class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                <span class="input-group-addon" style="width: 0%;"><span
                                        class="glyphicon glyphicon-th col-lg-4"></span></span>
                            </div>
                        </div>
                    </div>

                    <div id="dateOnlyDiv">
                        <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>
                    </div>

                    <div class="form-group">
                        <label class="sr-only">بحث بـ</label>
                        <div class="input-group">
                            <label> <input value="dateOnly" name="search" id="searchdateOnly" type="radio" checked
                                    onclick='localStorage.setItem("search", "dateOnly");
                                    window.location.reload();'>
                                تاريخ</label>
                            <label>
                                <input value="dateTime" name="search" id="searchdateTime" type="radio" onclick='localStorage.setItem("search", "dateTime");
                                        window.location.reload();'>
                                تاريخ ووقت</label>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>
                {/if}
            </div>

            <div class="clearfix"></div>
            <hr />
            <div class="panel panel-default panel-m">
                <div class="panel-heading">{$message}<br/>
                <span class="prntdat panel-heading" style="display: none;">تاريخ الطباعة:  <span class="panel-heading" id="printDate"></span></span>
                </div>

                {if count($dataArr) > 0}
                <table class="table table-black" id="ResultTable">
                    <thead>
                        <tr style="text-align:center">
                            <th>البيان</th>
                            <th colspan="2">وارد نقدا</th>
                            <th colspan="2">منصرف نقدا</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td rowspan="{count($dataArr)}">فواتير مبيعات نقديه </td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.payedSellBillVal}</td>
                            {/if}
                            {/foreach}
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.payedSellBillVal}</td>
                        </tr>
                        {/if}
                        {/foreach}

                        <tr>
                            <td rowspan="{count($dataArr)}">مصروفات </td>
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.expensesVal}</td>
                            {/if}
                            {/foreach}
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.expensesVal}</td>
                        </tr>
                        {/if}
                        {/foreach}

                        <tr>
                            <td rowspan="{count($dataArr)}">مرتجع بيع </td>
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.payedRetSellBillVal}</td>
                            {/if}
                            {/foreach}
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.payedRetSellBillVal}</td>
                        </tr>
                        {/if}
                        {/foreach}

                        <tr>
                            <td rowspan="{count($dataArr)}">دفعات سداد نقدا </td>
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.cashPayed}</td>
                            {/if}
                            {/foreach}
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.cashPayed}</td>
                        </tr>
                        {/if}
                        {/foreach}
                        <tr>
                            <td rowspan="{count($dataArr)}">دفعات تحصيل اجل </td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.laterPayed}</td>
                            {/if}
                            {/foreach}
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.laterPayed}</td>
                        </tr>
                        {/if}
                        {/foreach}

                        <tr>
                            <td rowspan="{count($dataArr)}">رصيد سابق بالخزينة </td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.valueFirstOfPeriod}</td>
                            {/if}
                            {/foreach}
                            <td colspan="2" rowspan="{count($dataArr)}"></td>
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.valueFirstOfPeriod}</td>
                        </tr>
                        {/if}
                        {/foreach}

                    </tbody>
                    <tfoot style="background-color:rgb(225, 226, 227)!important;">
                        <tr class="foot">
                            <td rowspan="{count($dataArr)}">اجمالى الحركات</td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                            <td>{$data.savename}</td>
                            <td>{$data.totalIncome}</td>
                            <td>{$data.savename}</td>
                            <td>{$data.totalEx}</td>
                            {/if}
                            {/foreach}
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            <td>{$data.savename}</td>
                            <td>{$data.totalIncome}</td>
                            <td>{$data.savename}</td>
                            <td>{$data.totalEx}</td>
                        </tr>
                        {/if}
                        {/foreach}

                        <tr class="foot">
                            <td rowspan="{count($dataArr)}">باقى بالخزينة</td>
                            {foreach $dataArr as $data}
                            {if $data@iteration eq 1}
                                {if $data.net >= 0}
                                    <td>{$data.savename}</td>
                                    <td>{$data.net}</td>
                                    <td></td>
                                    <td></td>
                                {else}
                                    <td></td>
                                    <td></td>
                                    <td>{$data.savename}</td>
                                    <td>{$data.net}</td>
                                {/if}
                            {/if}
                            {/foreach}
                        </tr>
                        {foreach $dataArr as $data}
                        {if $data@iteration > 1}
                        <tr>
                            {if $data.net >= 0}
                                    <td>{$data.savename}</td>
                                    <td>{$data.net}</td>
                                    <td></td>
                                    <td></td>
                                {else}
                                    <td></td>
                                    <td></td>
                                    <td>{$data.savename}</td>
                                    <td>{$data.net}</td>
                                {/if}
                        </tr>
                        {/if}
                        {/foreach}
                    </tfoot>
                </table>
                 {else}
                لا يوجد بيانات
                {/if}
                <br />
                <!--class="panel-heading"-->
                <div style="font-size: 14px;">{$netWritten}</div>

                <div class="clearfix"></div>
                <hr />
                <div class="hidden-print ">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <div class="col-lg-4">
                                <button type="button"  id="printData" class="btn btn-success pull-right">طباعة</button>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>




                <div class="clearfix"></div>

            </div>
        </div>
        <!--<input id="ddrt" name="ddrt" value="">-->
        {literal}
        <script>
            var search = localStorage.getItem("search");
            if (search == "dateTime") {
                $('#searchdateTime').attr('checked', 'checked');
                $('#searchdateOnly').removeAttr('checked');
                //
                $('#dateTimeDiv').show();
                $('#dateOnlyDiv').remove();
            } else {
                $('#searchdateOnly').attr('checked', 'checked');
                $('#searchdateTime').removeAttr('checked');
                //
                $('#dateOnlyDiv').show();
                $('#dateTimeDiv').remove();
            }
            var db = Number(localStorage.getItem("db"));
            if (db == 1) {
                $('#db').attr('checked', 'checked');
            } else {
                $('#db').removeAttr('checked');
            }
            
            $('#printData').on('click',function(){
                var dt = new Date();
                var month =1;
                month += Number(dt.getMonth()) ;
                var time = dt.getDate() +"-"+ month +"-"+ dt.getFullYear() +" "+ dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
                $('#printDate').html(time);
                $('.prntdat').css('display','inline');
                print_Custom('mycustomheader');
                $('.prntdat').css('display','none');

            });
        </script>
        {/literal}