<style>
    th,td{
        border: 1px solid #ddd !important;
    }
</style>
<div class="row">
    <div class="container">
        <!--show-------------------------------------------------------------------------------------------->
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title"><strong> قائمة الدخل </strong></h3>
                <a href="{$youtubes[224]->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">
                <div>
                    <table class="table table-black">
                        <thead>
                            <tr class="">
                                <th style="text-align: center;" class="color-black">الكود </th>
                                <th style="text-align: center;" class="color-black">البند </th>
                                <th style="text-align: center;" class="color-black">القيمة </th>
                            </tr>
                        </thead>
                        <tbody>


                            <!---$revenues and cost of activity inside it ---------------------------------------------->
                            {assign var=totalSell value=0}
                            {assign var=i value=0}
                            {foreach $revenues as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>{$item->layingOrder}</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {if $item->theValue != 0}
                                    {$item->theValue}
                                    {assign var=totalSell value=$totalSell+$item->theValue}

                                    {/if}
                                </td>
                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                            <tr style="background-color: #c1e4ff;">
                                <td></td>
                                <td>
                                    <b>اجمالى المبيعات </b>
                                </td>
                                <td>
                                    <b>{$totalSell}</b>
                                </td>
                            </tr>






                            {assign var=allowedDiscountVal value=0}
                            {assign var=i value=0}
                            {foreach $allowedDiscount as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>({$item->layingOrder})</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {$item->theValue}
                                    {assign var=allowedDiscountVal value=$item->theValue}

                                </td>
                            </tr>

                            {assign var=i value=$i+1}
                            {/foreach}
                            <tr style="background-color: #c1e4ff;">
                                <td></td>
                                <td>
                                    <b>صافى المبيعات</b>
                                </td>
                                <td>
                                    {assign var=netSell value=$totalSell-$allowedDiscountVal}
                                    <b>{$netSell}</b>
                                </td>
                            </tr>








                            {assign var=totalCost value=0}
                            {assign var=i value=0}
                            {foreach $WorkingCost as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>{$item->layingOrder}</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {$item->theValue}
                                    {assign var=totalCost value=$totalCost + $item->theValue}

                                </td>
                            </tr>

                            {assign var=i value=$i+1}
                            {/foreach}
                            {assign var=i value=0}
                            {foreach $workingExpenses as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>{$item->layingOrder}</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {$item->theValue}
                                    {assign var=totalCost value=$totalCost + $item->theValue}

                                </td>
                            </tr>

                            {assign var=i value=$i+1}
                            {/foreach}
                            <tr style="background-color: #c1e4ff;">
                                <td></td>
                                <td>
                                    <b>اجمالى التكلفة</b>
                                </td>
                                <td>
                                    <b>{$totalCost}</b>
                                </td>
                            </tr>
                            <tr style="background-color: #c1e4ff;">
                                <td></td>
                                <td>
                                    <b>مجمل الربح</b>
                                </td>
                                <td>
                                    {assign var=totalProfit value=$netSell - $totalCost}
                                    <b>{$totalProfit}</b>
                                </td>
                            </tr>






                            {assign var=totalgeneralAndManegeralExpenses value=0}
                            {assign var=i value=0}
                            {foreach $generalAndManegeralExpenses as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>({$item->layingOrder})</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {$item->theValue}
                                    {assign var=totalgeneralAndManegeralExpenses value=$totalgeneralAndManegeralExpenses + $item->theValue}

                                </td>
                            </tr>

                            {assign var=i value=$i+1}
                            {/foreach}


                            {assign var=totalOtherRevenu value=0}
                            {assign var=i value=0}
                            {foreach $otherRevenues as $item}
                            <tr {if $i==0}class="bg-black"{/if}>
                                <td>{$item->layingOrder}</td>
                                <td>
                                    {for $foo = 0 to $item->notes step=1}
                                    &emsp;
                                    {/for}
                                    {$item->name}
                                </td>
                                <td>
                                    {$item->theValue}
                                    {assign var=totalOtherRevenu value=$totalOtherRevenu + $item->theValue}

                                </td>
                            </tr>

                            {assign var=i value=$i+1}
                            {/foreach}


                            <!----------------------------------------------------->

                            {assign var=netProfitLoss value=($totalProfit + $totalOtherRevenu - $totalgeneralAndManegeralExpenses)}
                            <tr {if $netProfitLoss >= 0}style="background-color: #76c7c0;"{else}style="background-color: #ef9a9a;"{/if}>
                                <td></td>
                                <td>

                                    <b>صافى
                                        {if $netProfitLoss >= 0}
                                        الربح
                                        {else}
                                        الخسارة
                                        {/if}
                                    </b>
                                </td>
                                <td>
                                    <b>{abs($netProfitLoss)}</b>
                                </td>
                            </tr>


                        </tbody>
                    </table>
                    <br/>
                    <div class="col-lg-offset-16 col-lg-4">
                        <div class="well well-sm">
                            <h4 class="text-center">{$gainLossMsg}</h4>
                        </div>
                    </div>
                </div>
                </br>
            </div>
        </div>
    </div>
</div>