
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="clientReportsController.php?do=clientShowforsellonly">العملاء</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=clientShowforsellonly" 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 type="checkbox" name="bure" checked="checked" 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 dataTableClass">
                <thead>
                    <tr>
                        <th>وصف العمليه</th>
                        <th>المبيعات</th>
                        <th>المدفوعات</th>
                        <th>الرصيد</th>
                        <th>البيان</th>
                        <th>التاريخ</th>
                        <th>اسم المستخدم</th>
                        <th>اسم العميل</th>
                        <th>الخزنة</th>
                    </tr>
                </thead>
                <tbody>
                    {assign var=i value=1}

                    {foreach $shownData as $data}


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


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

                    <tr>
                        {/if}


                        <td>{$data->clientdebtchangeid}--{$data->processname}</td>

                        <td>
                            {if $data->mysellData }

                            {if ($data->tablename eq "sellbillandruternController.php" ||  $data->tablename eq "sellbillController.php" )}
                            {foreach  $data->mysellData  as  $mydata}

                            {if $mydata->selltype <> 1}
                            {$mydata->sellbilldetailtotalprice}
                            {else}
                            ( {$mydata->sellbilldetailtotalprice} -)
                            {/if}


                            <br />

                            {/foreach}



                            {else  $data->tablename eq "ruternsellbillController.php" }
                            {foreach  $data->mysellData  as  $mydata}


                            ( {$mydata->returnsellbilldetailtotalprice} -)



                            <br />

                            {/foreach}
                            {/if}

                            {else}
                            {if ($data->tablename eq "sellbillandruternController.php" ||  $data->tablename eq "sellbillController.php" )}
                            {foreach  $myselldata{$i}  as  $mymyselldata{$i}}

                            {if $mymyselldata{$i}->selltype <> 1}
                            {$mymyselldata{$i}->sellbilldetailtotalprice}
                            {else}
                            ( {$mymyselldata{$i}->sellbilldetailtotalprice} -)
                            {/if}


                            <br />

                            {/foreach}



                            {else  $data->tablename eq "ruternsellbillController.php" }
                            {foreach  $myselldata{$i}  as  $mymyselldata{$i}}


                            ( {$mymyselldata{$i}->returnsellbilldetailtotalprice} -)



                            <br />

                            {/foreach}
                            {/if}


                            {/if}

                        </td>


                        <td>{$data->sellbilltotalpayed}</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->sellbillfinalbill}
                            </div></td>
                        <td>
                            {if $data->mysellData }
                            {foreach  $data->mysellData  as  $mydaata}
                            {$mydaata->sellbilldetailquantity} {$mydaata->returnsellbilldetailquantity}   {$mydaata->unitName}/ {$mydaata->productName}/ {$mydaata->productCatName}/ {$mydaata->sellbilldetailprice}
                            <br />

                            {/foreach}
                            {else}

                            {foreach  $myselldata{$i}  as  $mymyselldata{$i}}
                            {$mymyselldata{$i}->sellbilldetailquantity} {$mymyselldata{$i}->returnsellbilldetailquantity}   {$mymyselldata{$i}->unitName}/ {$mymyselldata{$i}->productName}/ {$mymyselldata{$i}->productCatName}/ {$mymyselldata{$i}->sellbilldetailprice}
                            <br />

                            {/foreach}
                            {/if}

                        </td>

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

                        <td>{$data->username}</td>
                        <td>{$data->clientname}</td>
                        <td>{$data->savename}</td>
                    </tr>


                    {/if}

                    {capture assign=i}{$i+1}{/capture}
                    {/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="row">
                <div class="col-lg-3">
                    <button type="button" class="btn btn-dark ft-nor">
                        اجمالى عدد قطع المبيعات<span class="badge wht-clo">
                            <div >{$allPcsPlus}</div>
                        </span>
                    </button>
                </div>
                <div class="col-lg-3">
                    <button type="button" class="btn btn-dark ft-nor">
                        اجمالى عدد قطع مردودات المبيعات<span class="badge wht-clo">
                            <div >{$allPcsMinus}</div>
                        </span>
                    </button>
                </div>
                <div class="col-lg-3">
                    <button type="button" class="btn btn-dark ft-nor">
                        اجمالى المدفوعات <span class="badge wht-clo">
                            <div >{$allPayed|round:"2"}</div>
                        </span>
                    </button>
                </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>
