

<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">المصروفات والايرادات</a></li>
            <li><a href="saveController.php?do=show">الخزن</a></li>
            <li class="active">عرض الخزن</li>
        </ol>




        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading" style="padding:5px 15px 15px">
                <h3 class="panel-title" style="display: inline-block;"> عرض الخزن</h3>
                <a href="{$youtubes[82]->url}" target="_blank" class="hidden-print"><img src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube" style="width: 2%;"></a>
                <a href="saveController.php" class="hidden-print"><input type="button"  id="submit"  style="margin-left: 12px" class="btn btn-primary pull-left " value="إضافة جديد"/></a>
            </div>
            <div class="panel-body">


                <div id="outputString" class="alert alert-block alert-success fade in" style="display:none">
                    <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>

                    <p id="outputStringValue">{$outputString}</p>

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



            </div>

               <form class="form-inline hidden-print" method="post" action="saveController.php?do=show">
                    
                     <div class="form-group"  >
                        <label class="sr-only">انواع الخزن</label>
                            <select class="select2 wdt100" multiple name="savetypeids[]" id="savetypeids" data-placeholder="اختر ">
                                <option value="-1" >اختر </option>
                                 {foreach $allSaveType as $data}
                                <option value="{$data.id}" {if $data.id|in_array:$savetypeids} selected="selected" {/if}>{$data.name}</option>
                                {/foreach}
                            </select>
                    </div>


                    <button type="submit" class="btn btn-primary hidden-print">بحث</button>
                </form>
            <hr/>



            <table class="table table-black myTablesave" >
                <thead>
                    <tr>
                          <th width="10%">الرقم</th>
                        <th>اسم الخزنة</th>
                        <th>القيمة الحالية</th>
                        <th>القيمة بالعملة الاساسية</th>
                        <th>التعليق</th>
                        <th class="noprint">تعديل</th>
                        <th class="hidden-print ">ايقاف</th>
                    </tr>
                </thead>
                <tbody>



                    {assign var=totalMainCurrency value=0}
                    {foreach $saveData as $save}
                    {if {$save->conditions} eq 1}
                    <tr class="danger">
                        {elseif {$save->conditions} eq 0}
                    <tr>
                        {/if}
                        <td><input type="text" class="form-control" data-id="{$save->saveid}" id="sortby" value="{$save->sortby}"></td>
                        <td>{$save->savename}</td>
                        <td>{$save->savecurrentvalue} {$save->currencyName}</td>
                        <td>{$save->savecurrentvalueInMainCurrency}
                            {if {$save->conditions} eq 0}
                            {assign var=totalMainCurrency value=$totalMainCurrency+$save->savecurrentvalueInMainCurrency}
                            {/if}
                        </td>
                        <td>
                            {if {$save->savedetails} <> ""}
                            {$save->savedetails}
                            {else}
                            لا يوجد
                            {/if}
                        </td>



                        <td class="noprint">
                            <a href="saveController.php?do=edit&saveid={$save->saveid}" class="btn btn-default btn-lg editicon"></a>
                        </td>
                        <td class="hidden-print ">

                            {if {$save->conditions} eq 1}
                            <a href="saveController.php?do=delete&saveid={$save->saveid}&condition=1" type="button" class="btn btn-default btn-lg correcticon"></a>

                            {elseif {$save->conditions} eq 0 && {$save->saveid} gt 1}

                            <a href="#" type="button" class="btn btn-default btn-lg removeicon conformdel1" data-position="saveController.php?do=delete&saveid={$save->saveid}&condition=0"></a>

                            {/if}


                        </td>



                    </tr>
                    {/foreach}


                </tbody>
            </table>





            <div class="clearfix"></div>
            <hr />
            <div class="col-lg-offset-8 col-lg-4 ">
                <div class="well well-sm">
                    <h4 class="text-center">الاجمالى بالعملة الاساسية:  <span>{$totalMainCurrency}</span></h4>
                </div>
            </div>
            <div class="clearfix"></div>




            <div  class="noprint">
                <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>

            <!-- Modal -->
            <div class="hidden-print">
                <div class="modal fade " id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close pull-left" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <div class="modal-title">تأكيد حذف الخزنه</div>
                            </div>
                            <div class="modal-body"> هل تريد حذف هذه الخزنه؟ </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">لا</button>
                                <button type="button" class="btn btn-primary savemodel1">نعم</button>
                            </div>
                        </div>
                        <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                </div>
            </div>
            <!-- /.modal -->




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


        </div>



    </div>

</div>

{literal}
<script type="text/javascript">

$(document).ready( function () {
    $('.myTablesave').DataTable();
    $('body').on('change', '#sortby', function () {
        var id = $(this).attr('data-id');
        var sortby =  $.trim($(this).val());
        if (sortby) {
            $.post("saveController.php?do=sortby", {id: id , sortby: sortby});
        }
    });
} );


$('.conformdel1').click(function (e) {

e.preventDefault();

var elemposition = $(this).data('position');

$("#myModal1").find(".savemodel1").attr('data-position', elemposition);
$('#myModal1').modal('show');
});
$('.savemodel1').on('click', function () {

$('#myModal1').modal('hide');
var pos = $(this).attr('data-position');

window.location.href = pos;
});
</script>
{/literal}