<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;
    }

</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=show" method="post">

                    {if $searchinonesave eq 0}
                    <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>
                    {/if}
                    <div class="form-group">

                        <label class="sr-only">اسم العمليه</label>
                        <select class="select2 wdt300"  name="processid" id="processid" >
                            <option value="-1">  اختر عمليه </option>


                            {foreach $allprocess as $process}


                            <option value="{$process->processname}">{$process->processname}</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" name="bure" checked="checked" id="bure" value="1" />
                        <label for="bure"></label>
                    </div>
                    <div class="form-group">
                        <label class="sr-only"> قاعدة البيانات</label>
                        <input type="checkbox" name="db"  id="db" value="1" onclick='localStorage.setItem("db", Number($(this).is(":checked")))'/>
                        <label for="bure"></label>
                    </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">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>





                <!-- Tab panes -->
                <div class="tab-content">


                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs hidden-print">
                        <li class="active"><a href="#savetab" data-toggle="tab">يومية الخزنة</a></li>
                        {if $Programsetting->visaPay == 1}<li><a href="#accountTab" data-toggle="tab">الدفع الالكترونى</a></li>{/if}
                    </ul>
                    <div class="tab-pane active" id="savetab"><!-- start the 1st tab -->


                        <div class="panel-body">
                            {if count($savedailyData)>0}
                            <div class="col-lg-offset-8 col-lg-4">
                                {if $savedailydate eq 1}
                                <div class="well well-sm hidden-print">
                                    <h4 class="text-center">الاجمالى {$sumValue} {$currency}</h4>
                                </div>

                                {/if}
                            </div>

                            <div class="col-lg-offset-8 col-lg-4">
                                <div class="well well-sm hidden-print">
                                    <h4 class="text-center">قيمة التغير {$changeAmountSum} {$currency}</h4>
                                </div>
                            </div>

                            <div class="col-lg-offset-1 col-lg-4">
                                <div class="well well-sm">
                                    <h4 class="text-center">الرصيد الافتتاحي {$savecur} {$currency}</h4>
                                </div>
                            </div>


                            <div class="clearfix"></div>
                            <table class="table table-black" >
                                <thead >
                                    <tr style="text-align:center">
                                        <th>اسم الخزينة</th>
                                        <th>اسم العملية</th>
                                        <th>اسم المستخدم</th>
                                        <th>التاريخ</th>
                                        <!--{*if $burex <> 1*}-->       <th>المبلغ قبل </th><!--{*/if*}-->
                                        <th>
                                            <table   class="table  table-black " border="1" width="100%"  style="text-align:center" >
                                                <tr ><td colspan="2" class="" >القيمة المتغيرة</td></tr>
                                                <tr class="">
                                                    <td>وارد</td>
                                                    <td>صادر</td></tr>

                                            </table>

                                        </th>
                                        <!--{*if $burex <> 1*}-->         <th>المبلغ بعد</th><!--{*/if*}-->
                                        <th class="hidden-print ">تفاصيل </th>
                                        <th class="hidden-print ">تفاصيل العملية بالخزنة</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {assign var=j value=0}
                                    {assign var=k value=0}
                                    {foreach $savedailyData as $savedaily}


                                    {if {$savedaily->savedailyid} > 0}
                                    {if ($savedaily->savedailychangetype eq 0 && $savedaily->savedailychangeamount >= 0) || ($savedaily->savedailychangetype eq 1 && $savedaily->savedailychangeamount < 0)}
                                    {capture assign=j}{$j+{abs($savedaily->savedailychangeamount)}}{/capture}
                                    {else if ($savedaily->savedailychangetype eq 1 && $savedaily->savedailychangeamount >= 0) || ($savedaily->savedailychangetype eq 0 && $savedaily->savedailychangeamount < 0)}
                                    {capture assign=k}{$k+{abs($savedaily->savedailychangeamount)}}{/capture}

                                    {/if}
                                    {if {$savedaily->savedailychangetype} eq 1}
                                    <tr class="danger"> {elseif {$savedaily->savedailychangetype} eq 0}
                                        {else}
                                    <tr>
                                        {/if}
                                        <td>{$savedaily->savename} </td>
                                        <td>
                                            {$savedaily->processname}
                                            {if ($savedaily->personName <> '0' && $savedaily->personName <> '') ||$savedaily->savecurrentvalue !=""}
                                            ( {$savedaily->savecurrentvalue} )
                                            {/if}
                                            {if {$savedaily->tablename} eq "buyBillController.php" || {$savedaily->tablename} eq "returnBuyBillController.php"  || {$savedaily->tablename} eq "buyAndReturnBillController.php"
                                            || {$savedaily->tablename} eq "sellbillController.php" || {$savedaily->tablename} eq "sellbillandruternController.php" ||{$savedaily->tablename} eq "returnsellbillController.php"
                                            || {$savedaily->tablename} eq "clientPayedDeptSellBillsController.php" || {$savedaily->tablename} eq "clientPayedDeptReturnSellBillsController.php"}
                                            رقم الفاتورة {$savedaily->savedailymodelid}
                                            {/if}
                                        </td>
                                        <td>{$savedaily->username}</td>
                                        <td nowrap="nowrap">{$savedaily->savedailydate}</td>
                                        <!--{*if $burex <> 1*}-->
                                        <td>

                                            {$savedaily->savedailysavebefore}
                                        </td>
                                        <!--{*/if*}-->
                                        <td>
                                            <table border="0" width="100%"  style="text-align:center" class="ddrt">

                                                <tr><td width="50%">
                                                        {if ($savedaily->savedailychangetype eq 0 && $savedaily->savedailychangeamount >= 0) || ($savedaily->savedailychangetype eq 1 && $savedaily->savedailychangeamount < 0)}{abs($savedaily->savedailychangeamount)}{/if}
                                                    </td>
                                                    <td width="50%">
                                                        {if ($savedaily->savedailychangetype eq 1 && $savedaily->savedailychangeamount >= 0) || ($savedaily->savedailychangetype eq 0 && $savedaily->savedailychangeamount < 0)}{abs($savedaily->savedailychangeamount)}{/if}
                                                    </td>
                                                </tr>

                                            </table>

                                        </td>
                                        <!--{*if $burex <> 1*}-->
                                        <td>

                                            {$savedaily->savedailysaveafter}
                                        </td>
                                        <!--{*/if*}-->
                                        <td class="hidden-print ">

                                            {if {$savedaily->tablename} eq "buyBillController.php" || {$savedaily->tablename} eq "returnBuyBillController.php"  || {$savedaily->tablename} eq "buyAndReturnBillController.php"}
                                            <a href="{$savedaily->tablename}?do=details&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>


                                            {elseif {$savedaily->tablename} eq "sellbillController.php" || {$savedaily->tablename} eq "sellbillandruternController.php"}

                                            <a href="{$savedaily->tablename}?do=showDetail&sellbillid={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>


                                            {elseif {$savedaily->tablename} eq "returnsellbillController.php"}

                                            <a href="{$savedaily->tablename}?do=showDetail&returnsellbillid={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {elseif {$savedaily->tablename} eq "bills.php" || {$savedaily->tablename} eq "billsreturn.php"}

                                            <a href="{$savedaily->tablename}?do=details&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {elseif {$savedaily->tablename} eq "dailyentry.php"}

                                            <a href="{$savedaily->tablename}?id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {elseif $savedaily->tablename eq "datedCheckedController.php"}
                                            <a href="{$savedaily->tablename}?do=details&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {else}
                                            <a href="{$savedaily->tablename}?do=editprint&id={$savedaily->savedailymodelid}" type="button" class="btn btn-default btn-lg editicon"></a>
                                            {/if}
                                        </td>
                                        <td class="hidden-print "> <a href="#" type="button" class="btn btn-default btn-lg editicon conformdel1" data-position="savedailyController.php?do=showDetail&savedailyid={$savedaily->savedailyid}"></a> </td>
                                    </tr>

                                    {/if}
                                    {/foreach}
                                    <tr>
                                        <!--{*if $burex <> 1*}-->
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <!--{*else*}-->
                                        <!--                                        <td></td>
                                                                                <td></td>
                                                                                <td></td>
                                                                                <td></td>-->
                                        <!--{*/if*}-->
                                        <td> <table border="1" width="100%"  style="text-align:center" class="table-black">
                                                <tr><td width="50%">  {$j}</td><td width="50%">{$k}</td></tr>

                                            </table>
                                        </td>
                                        <!--{*if $burex <> 1*}-->
                                        <td></td>
                                        <!--{*/if*}-->
                                        <!-- <td></td>
                                        <td></td> -->
                                    </tr>

                                </tbody>

                            </table>

                            <div class="col-lg-offset-8 col-lg-4">
                                {if $savedailydate eq 1}
                                <div class="well well-sm">

                                    <h4 class="text-center">الاجمالى {$sumValue} {$currency}</h4>

                                </div>
                                {/if}
                            </div>
                            <div class="col-lg-offset-8 col-lg-4">
                                <div class="well well-sm">
                                    <h4 class="text-center">قيمة التغير {$changeAmountSum} {$currency}</h4>
                                </div>
                            </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" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right">طباعة</button>
                                        </div>
                                    </div>
                                </div>
                                <div class="clearfix"></div>
                            </div>
                            {else}
                            <div class="nodata">عفوا لا توجد نتائج</div>
                            {/if}




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



                        </div>
                    </div>

                    {if $Programsetting->visaPay == 1}
                    <!-- Tab panes -->
                    <div class="tab-pane" id="accountTab"><!-- start the 1st tab -->

                        <div class="col-lg-offset-8 col-lg-4">
                            {if $savedailydate eq 1}
                            <div class="well well-sm">
                                <h4 class="text-center">الاجمالى {$sumValOfVisaAccount} {$currency}</h4>
                            </div>

                            {/if}
                        </div>

                        <div class="col-lg-offset-8 col-lg-4">
                            <div class="well well-sm">
                                <h4 class="text-center">قيمة التغير {$changeAmountSum_account} {$currency}</h4>
                            </div>
                        </div>

                        <table class="table table-black dataTableClass">
                            <thead>
                                <tr>
                                    <th rowspan="2">#</th>
                                    <th rowspan="2">العملية</th>
                                    <th rowspan="2">تاريخ العملية</th>
                                    <th rowspan="2">الرصيد قبل</th>
                                    <th colspan="2">قيمة العملية</th>
                                    <th rowspan="2">الرصيد بعد</th>
                                    <th rowspan="2">العميل</th>
                                    <th rowspan="2">المستخدم</th>
                                    <th rowspan="2">التفاصيل</th>
                                </tr>
                                <tr>
                                    <td>وارد</td>
                                    <td>صادر</td>
                                </tr>
                            </thead>
                            <tbody>



                                {foreach $allMovements as $data}
                                <tr class="{if {$data->accountmovementtype} eq 1} danger {/if}">
                                    <td>
                                        {$data@iteration}
                                    </td>

                                    <td>{if $data->tablename eq "cashTransferController.php"}{$data->processname}{else}{$data->processname} ({$data->bankname}- {$data->accountname} {if $data->clientname}/{$data->clientname}{/if}){/if}</td>
                                    <td>{$data->accountmovementdate}</td>
                                    <td>{$data->accountmovementbefore}</td>
                                    <td>
                                        {if $data->accountmovementtype eq 0}
                                        {$data->accountmovementamount}
                                        {/if}
                                    </td>
                                    <td>
                                        {if $data->accountmovementtype eq 1}
                                        {$data->accountmovementamount}
                                        {/if}
                                    </td>


                                    <td>{$data->accountmovementafter}</td>
                                    <td>{$data->clientName}</td>
                                    <td>{$data->employeename}</td>
                                    <td>
                                        <a href="
                                           {if $data->tablename == 'sellbillController.php'}
                                           {$data->tablename}?do=showDetail&sellbillid={$data->accountmovementmodelid}
                                           {else if $data->tablename == 'sellbillandruternController.php'}
                                           {$data->tablename}?do=showDetail&sellbillid={$data->accountmovementmodelid}
                                           {else if $data->tablename == 'returnsellbillController.php'}
                                           {$data->tablename}?do=showDetail&returnsellbillid={$data->accountmovementmodelid}
                                           {else}
                                           {$data->tablename}?do=details&{if $data->tablename eq 'bankaccountController.php'}accountid={else}id={/if}{$data->accountmovementmodelid}
                                           {/if}
                                           "
                                           target="_blank">التفاصيل</a></td>
                                </tr>
                                {/foreach}


                            </tbody>
                        </table>

                        <div class="col-lg-offset-8 col-lg-4">
                            {if $savedailydate eq 1}
                            <div class="well well-sm">
                                <h4 class="text-center">الاجمالى {$sumValOfVisaAccount} {$currency}</h4>
                            </div>

                            {/if}
                        </div>

                        <div class="col-lg-offset-8 col-lg-4">
                            <div class="well well-sm">
                                <h4 class="text-center">قيمة التغير {$changeAmountSum_account} {$currency}</h4>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    {/if}
                </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');
            }
            /*
             //write number at input id=ddrt, mark it with sucess class @ value columns
             $('#ddrt').on('blur', function () {
             var val = $(this).val();
             $('.ddrt td').each(function () {
             if ($(this).text().trim() == val) {
             $(this).parent().parent().addClass('success');
             }
             })
             })
             $('.ddrt').on('click', function () {
             $(this).addClass('success');
             })
             */
        </script>
        {/literal}