
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="clientReportsController.php?do=show">العملاء</a></li>
            <li class="active">تقرير مديونية عميل</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير مديونية عميل<br />
                {if $message != ""}
                {$message}
                {/if}</div>
            <div class="panel-body">
                <form class="form-inline hidden-print" action="clientReportsController.php?do=show" method="post">
                    <div class="form-group">
                        <label class="sr-only">العميل</label>
                        <select class="select2 wdt300"  name="clientid" id="clientid" >
                            <option value="-1">اختر عميل</option>


                            {foreach $clientData as $client}


                            <option value="{$client->clientid}">{$client->clientname}</option>


                            {/foreach}



                        </select>

                    </div>



                    <div class="form-group">
                        <label class="sr-only">رصيد صافي</label>
                        <input name="bure" type="checkbox" id="bure"  value="1" />
                        <label for="bure"></label>
                    </div>
                    <br/>

                    <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>
            </div>
            <hr/>

            <table class="table billtable table-bordered table-black">
                <thead>
                    <tr>
                        <th>وصف العمليه</th>
                        <th>تاريخ العملية</th>

                        <th>إجمالي مبلغ العملية</th>
                        <th>المدفوع</th>
                        {if $burex <> 1}        <th>المديونيه قبل</th>{/if}
                        <!--<th><table   class="table" border="1" width="100%"  style="text-align:center" >
                        <tr ><td colspan="2" > القيمة المتغيرة</td></tr>
                           <tr><td>اضافه</td><td>خصم</td></tr>

                        </table>  </th>-->
                        <th>القيمة المتغيرة
                <table class="table billtable table-bordered">
                    <tr>
                        <td style="color:black;"> وارد</td>
                        <td style="color:black;"> صادر</td>
                    </tr>
                </table>
                </th>
                {if $burex <> 1}  <th>المديونيه بعد</th> {/if}
                </tr>
                </thead>
                <tbody>
                    {assign var=j value=0}
                    {assign var=k value=0}
                    {foreach $shownData as $data}


                    {if {$data->clientdebtchangeid} > 0}


                    {if $data->clientdebtchangetype eq 0}
                    {capture assign=j}{$j+{$data->clientdebtchangeamount}}{/capture}
                    {else}
                    {capture assign=k}{$k+{$data->clientdebtchangeamount}}{/capture}
                    {/if}


                    {if {$data->clientdebtchangetype} eq 1}
                    <tr class="danger"> {elseif {$data->clientdebtchangetype} eq 0}

                    <tr> {/if}

                        <td>{if $data->tablename eq "sellbillandruternController.php" ||  $data->tablename eq "sellbillController.php"  ||  $data->tablename eq "returnsellbillController.php" || $data->tablename eq "clientPayedDeptController.php"}
                            ( {$data->clientdebtchangemodelid})
                            {/if}<a class=" hidden-print" href="{$data->link}">{$data->processname}</a> <div class="visible-print">{$data->processname}

                            </div></td>
                        <td>{$data->clientdebtchangedate}</td>


                        {if $data->tablename eq "sellbillandruternController.php" ||  $data->tablename eq "sellbillController.php"  ||  $data->tablename eq "returnsellbillController.php" }
                        <td>{$data->totalOperationCost}</td>

                        <td>{if $data->totalOperationCost eq 0}
                            0
                            {else}
                            {{$data->totalOperationCost} - {$data->clientdebtchangeamount}}
                            {/if}</td>
                        {if $burex <> 1}        <td>{$data->clientdebtchangebefore}</td>{/if}
                        <td><div {if {$data->clientdebtchangetype} eq 1} style="float:left;  margin: 10px 10px 10px 10px;"  {else} style="float:right; margin: 10px 10px 10px 10px;"  {/if} >
                                {$data->clientdebtchangeamount}
                            </div></td>
                        <!--<td><table border="1" width="100%"  style="text-align:center" >

                         <tr><td width="50%">   {if $data->clientdebtchangetype eq 0}{$data->clientdebtchangeamount}{/if}</td><td width="50%">{if $data->clientdebtchangetype eq 1} {$data->clientdebtchangeamount}{/if}</td></tr>

                      </table> </td>-->
                        {else}
                        <td>{$data->clientdebtchangeamount}</td>
                        <td>{$data->clientdebtchangeamount}

                        </td>
                        {if $burex <> 1}            <td>{$data->clientdebtchangebefore}</td>{/if}
                        <!--<td> <table border="1" width="100%"  style="text-align:center" >

                         <tr><td width="50%">   {if $data->clientdebtchangetype eq 0}{$data->clientdebtchangeamount}{/if}</td><td width="50%">{if $data->clientdebtchangetype eq 1} {$data->clientdebtchangeamount}{/if}</td></tr>

                      </table> </td>-->
                        <td><div {if {$data->clientdebtchangetype} eq 1} style="float:left;  margin: 10px 10px 10px 10px;"  {else} style="float:right; margin: 10px 10px 10px 10px;"  {/if} >
                                {$data->clientdebtchangeamount}
                            </div></td>
                        {/if}
                        {if $burex <> 1}


                        <td>{$data->clientdebtchangeafter}</td>
                        {/if}
                    </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" >
                         <tr><td width="50%">  {$j}</td><td width="50%">{$k}</td></tr>

                      </table>
                    </td>


                  </tr>-->
                </tbody>

            </table>
            <div class="col-lg-offset-8 col-lg-4">
                <div class="well well-sm">
                    {if {$k} eq 0}
                    <h4 class="text-center"> اجمالى المبلغ  {$j}  {$currency}</h4>
                    {else}
                    <h4 class="text-center"> اجمالى المبلغ  {$k}  {$currency}</h4>
                    {/if}
                </div>
            </div>
            <div class="clearfix"></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>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
