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




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


        <ol class="breadcrumb">
            <li><a href="#">التقارير</a></li>
            <li class="active"> تقرير ارباح مدة</li>

        </ol>




        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">تفاصيل تقرير ارباح مدة</div>
            <div class="panel-body">





                <form class="form-inline  hidden-print" action="profitdetailController.php?do=show" method="post">




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




            <div class="panel panel-default panel-m">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body">
                    <hr/>


                    <!------------------- المبيعات-------------------------->
                    <table class="table table-black">
                        <thead>
                            <tr>
                                <th class="active" colspan="4" style="background:#f5f5f5"><center>المبيعات</center></th>
                        </tr>

                        <tr>
                            <th>الرقم المتسلسل</th>
                            <th>رقم الفاتورة</th>
                            <th>اجمالى الفاتورة قبل الخصم</th>
                            <th>اجمالى الفاتورة بعد الخصم</th>
                        </tr>

                        </thead>
                        <tbody>



                            {foreach $sellbillData as $sellbill}

                            <tr class="danger">

                                <td>{$sellbill->sellbillid}</td>
                                <td>{$sellbill->sellbillserial}</td>
                                <td>{$sellbill->sellbilltotalbill}</td>
                                <td>{$sellbill->sellbillaftertotalbill}</td>

                            </tr>
                            {/foreach}


                            {foreach $aditionalsellbillData as $aditionalsellbill}
                            {if {$aditionalsellbill->sellbillaftertotalbill} >= 0}
                            <tr class="danger">

                                <td>{$aditionalsellbill->sellbillid}</td>
                                <td>{$aditionalsellbill->sellbillserial}</td>
                                <td>{$aditionalsellbill->sellbilltotalbill}</td>
                                <td>{$aditionalsellbill->sellbillaftertotalbill}</td>

                            </tr>

                            {/if}
                            {/foreach}


                            <tr class="active" style="background:#f5f5f5">
                                <td colspan="2" ><center> اجمالى المبيعات</center></td>
                        <td colspan="2"><center>
                            {$totalSellPrice}
                        </center></td>
                        </tr>

                        </tbody>
                    </table>



                    <!-------------------مردودات المبيعات-------------------------->
                    <table class="table table-black">
                        <thead>
                            <tr>
                                <th class="active" colspan="4" style="background:#f5f5f5"><center>مردودات المبيعات</center></th>
                        </tr>

                        <tr>
                            <th>الرقم المتسلسل</th>
                            <th>رقم الفاتورة</th>
                            <th>اجمالى الفاتورة قبل الخصم</th>
                            <th>اجمالى الفاتورة بعد الخصم</th>
                        </tr>

                        </thead>
                        <tbody>



                            {foreach $returnsellbillData as $returnsellbill}

                            <tr class="danger">

                                <td>{$returnsellbill->returnsellbillid}</td>
                                <td>{$returnsellbill->returnsellbillserial}</td>
                                <td>{$returnsellbill->returnsellbilltotalbill}</td>
                                <td>{$returnsellbill->returnsellbillaftertotalbill}</td>

                            </tr>
                            {/foreach}


                            {foreach $aditionalReturnSellbillData as $aditionalReturnSellbill}

                            {if {$aditionalReturnSellbill->sellbillaftertotalbill} < 0}
                            <tr class="danger">

                                <td>{$aditionalReturnSellbill->sellbillid}</td>
                                <td>{$aditionalReturnSellbill->sellbillserial}</td>
                                <td>{$aditionalReturnSellbill->sellbilltotalbill}</td>
                                <td>{$aditionalReturnSellbill->sellbillaftertotalbill}</td>

                            </tr>
                            {/if}
                            {/foreach}

                            <tr class="active" style="background:#f5f5f5">
                                <td colspan="2" ><center> اجمالى مردودات المبيعات</center></td>
                        <td colspan="2"><center>
                            {$totalReturnSellPrice}
                        </center></td>
                        </tr>


                        <tr class="success" style="background:#f5f5f5">
                            <td colspan="2" ><center>صافى ايرادات المبيعات</center></td>
                        <td colspan="2"><center>{$totalSellCost}</center></td>
                        </tr>


                        </tbody>
                    </table>



                    <!-------------------المباع بسعر التكلفة-------------------------->

                    <table class="table table-black">
                        <thead>
                            <tr>
                                <th class="active" colspan="4" style="background:#f5f5f5"><center>المباع بسعر التكلفة</center></th>
                        </tr>

                        <tr>
                            <th>الرقم المتسلسل</th>
                            <th>رقم الفاتورة</th>
                            <th>الكمية</th>
                            <th>سعر الشراء</th>

                        </tr>

                        </thead>
                        <tbody>


                            {assign var=h value=1}
                            {foreach $sellbilldetailData as $sellbilldetail}

                            <tr class="danger">

                                <td>{$sellbilldetail->sellbillid}</td>
                                <td>{$sellbilldetail->sellbillserial}</td>
                                <td>{$sellbilldetail->sellbilldetailquantity}</td>
                                <td>{$productBuyPrice{$h}}</td>
                            </tr>

                            {capture assign=h}{$h+1}{/capture}
                            {/foreach}


                            {assign var=j value=1}
                            {foreach $aditionalsellbilldetailData as $aditionalsellbilldetail}

                            <tr class="danger">

                                <td>{$aditionalsellbilldetail->sellbillid}</td>
                                <td>{$aditionalsellbilldetail->sellbillserial}</td>
                                <td>{$aditionalsellbilldetail->sellbilldetailquantity}</td>
                                <td>{$aditionalproductBuyPrice{$j}}</td>


                            </tr>
                            {capture assign=j}{$j+1}{/capture}
                            {/foreach}

                            <tr class="active" style="background:#f5f5f5">
                                <td colspan="2" ><center> اجمالى المباع بسعر التكلفة</center></td>
                        <td colspan="2"><center>
                            {$totalQuantityBuyPrice}
                        </center></td>
                        </tr>




                        </tbody>
                    </table>


                    <!--------------- مردود البيع بسعر التكلفة-------------------------->

                    <table class="table table-black">
                        <thead>
                            <tr>
                                <th class="active" colspan="4" style="background:#f5f5f5"><center> مردود البيع بسعر التكلفة</center></th>
                        </tr>

                        <tr>
                            <th>الرقم المتسلسل</th>
                            <th>رقم الفاتورة</th>
                            <th>الكمية</th>
                            <th>سعر الشراء</th>

                        </tr>

                        </thead>
                        <tbody>


                            {assign var=k value=1}
                            {foreach $returnsellbilldetailData as $returnsellbilldetail}

                            <tr class="danger">

                                <td>{$returnsellbilldetail->returnsellbillid}</td>
                                <td>{$returnsellbilldetail->returnsellbillserial}</td>
                                <td>{$returnsellbilldetail->returnsellbilldetailquantity}</td>
                                <td>{$returnproductBuyPrice{$k}}</td>
                            </tr>

                            {capture assign=k}{$k+1}{/capture}
                            {/foreach}


                            {assign var=l value=1}
                            {foreach $aditionalreturnsellbilldetailData as $aditionalreturnsellbilldetail}

                            <tr class="danger">

                                <td>{$aditionalreturnsellbilldetail->sellbillid}</td>
                                <td>{$aditionalreturnsellbilldetail->sellbillserial}</td>
                                <td>{$aditionalreturnsellbilldetail->sellbilldetailquantity}</td>
                                <td>{$aditionalreturnproductBuyPrice{$l}}</td>


                            </tr>
                            {capture assign=l}{$l+1}{/capture}
                            {/foreach}

                            <tr class="active" style="background:#f5f5f5">
                                <td colspan="2" ><center> اجمالى مردود البيع بسعر التكلفة</center></td>
                        <td colspan="2"><center>
                            {$totalQuantityReturnBuyPrice}
                        </center></td>
                        </tr>


                        <tr class="success" style="background:#f5f5f5">
                            <td colspan="2" ><center> تكلفة المبيعات</center></td>
                        <td colspan="2"><center>
                            {$totalBuyCost}
                        </center></td>
                        </tr>


                        <tr class="active" style="background:#f5f5f5">
                            <td colspan="2" ><center> مجمل الربح</center></td>
                        <td colspan="2"><center>
                            {math equation="x - y" x=$totalSellCost y=$totalBuyCost}
                        </center></td>
                        </tr>



                        <tr>
                            <td colspan="2"><center>اجمالى المصروفات</center></td>
                        <td colspan="2"><center>{$totalExpenses}</center></td>
                        </tr>


                        <tr class="active"  style="background:#f5f5f5">

                            <td colspan="2"><center>صافى الربح</center></td>
                        <td colspan="2"><center>{$profitFinal}</center></td>
                        </tr>

                        </tbody>
                    </table>











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


                    <hr />




                    <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  hidden-print">طباعة</button>
                                </div>
                            </div>


                        </div>

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





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






            </div>

        </div>



