<style>
    .solidgraytop{
        border-top-style:solid;
        border-top-color:#ddd;
    }
    .solidgrayleft{
        border-left:solid;
        border-left-width:3px;
        border-color: #ddd;
    }
    .solidgrayright{
        border-right-style:solid;
        border-right-color:#ddd;
    }
    .solidgraybottom{
        border-top-style:solid;
        border-top-color:#ddd;
    }
    .hidetop{
        border-top:hidden !important;
    }
    .fromaccountstyle{
        font-weight:bold;
        font-size:17px;
        color:blue;
    }
    .toaccountstyle
    {
        font-weight:bold;
        font-size:17px;
        color:purple;
    }
    .mytotal{
        background-color:#ddd;
        font-weight:bold;
    }
    .nodata{
        background-color: #72B4EC;
        color: white;
        border-radius: 13px;
        margin: 14px;
        font-size: 24px;
        text-align: center;
        padding: 5px;
    }

</style>
<div class="row">
    <div class="container">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title"><strong>القيد الافتتاحى</strong></h3>
                <a href="{$youtubes[219]->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">
                <form class="nameToBeChecked form-horizontal" action="" method="post" id="dailyEntry_Form">
                    <input type="hidden" id="isOpeningEntry" name="isOpeningEntry" value="1"/>
                    <input type="hidden" id="selectedIds" name="selectedIds" value=""/>
                    <input type="hidden" id="searchvalue" name="searchvalue" value="1"/>
                    {if $user_data->branchId == 0}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">الفرع</label>
                        <div class="col-lg-4">
                            <select  class="select2 " name="branchid_entry" id="branchid_entry" >
                                <option value="-1">اختر الفرع</option>

                                {foreach $allbranchdata as $myallbranchdata}

                                <option value="{$myallbranchdata->branchId}">{$myallbranchdata->branchName}</option>

                                {/foreach}


                            </select>
                        </div>
                    </div>
                    {else}
                    <input type="hidden" name="branchid_entry" id="branchid_entry" value="{$user_data->branchId}"/>
                    {/if}
                    <div class="col-lg-12" style="padding: 0">
                        <div class="form-group">
                            <label class="col-lg-2 control-label">تاريخ القيد</label>
                            <div class="col-lg-4">
                                <div class="input-group date form_datetime col-md-5" data-date="" data-date-format="yyyy-mm-dd  h:i:s" data-link-field="dtp_input1">
                                    <input class="form-control" size="16" type="text" value="{$now}" readonly="" id="dDateTime" name="dDateTime">
                                    <span class="input-group-addon "><span class=" glyphicon glyphicon-remove col-lg-4"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th col-lg-4"></span></span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-lg-2 control-label">بيان القيد </label>
                            <div class="col-lg-4">
                                <textarea class="form-control" rows="3" id="entryComment" name="entryComment">قيد افتتاحى</textarea>
                            </div>
                        </div>
                    </div>
                    <div style="clear:both"></div>
                    <br/>
                    <div style="clear:both"></div>
                    <!--<button type="button" class="btn btn-primary" style="float: left;" id="DE_add">اضافة</button>-->
                    <table class="table table-black" >

                        <thead>
                            <tr>
                                <th>#</th>
                                <th>اسم الحساب</th>
                                <th colspan="2">قيمة الحساب</th>
                                <th>مدين</th>
                                <th>دائن</th>
                                <th>ملاحظة</th>
                                <!--<th>مركز التكلفة</th>-->
                                <th>حذف</th>
                            </tr>
                            <tr>
                                <th></th>
                                <th></th>
                                <th>مدين</th>
                                <th>دائن</th>
                                <th></th>
                                <th></th>
                                <th></th>
                                <!--<th>مركز التكلفة</th>-->
                                <th></th>
                            </tr>
                        </thead>
                        <tbody id="DE_Table">
                            {assign var=totalDebtor value=0}
                            {assign var=totalCreditor value=0}
                            {assign var=i value=1}
                            {foreach $allLastLeafs as $data}
                            <tr class="clearit">
                                <td class="rowNo" style="font-weight: bold">{$i}</td>
                                <td>{$data->layingOrder} {$data->customName}
                                    <input type="hidden" id="E_parent{$i}" name="E_parent{$i}" data-placeholder="اختر" class="dailyParent wdt100 select2-offscreen" value="{$data->id}"></td>
                                <td>
                                    {if ($data->accountNature == 0 && $data->theValue >0) ||  ($data->accountNature == 1 && $data->theValue <0)}

                                    {if $data->theValue < 0}{assign var=val value=$data->theValue*-1}{else}{assign var=val value=$data->theValue}{/if}

                                    {assign var=totalDebtor value=$totalDebtor + $val}
                                    {$val}

                                    {/if}
                                </td>
                                <td>
                                    {if ($data->accountNature == 1 && $data->theValue >0) ||  ($data->accountNature == 0 && $data->theValue <0)}

                                    {if $data->theValue < 0}{assign var=val value=$data->theValue*-1}{else}{assign var=val value=$data->theValue}{/if}

                                    {assign var=totalCreditor value=$totalCreditor + $val}
                                    {$val}

                                    {/if}
                                </td>
                                <td> <input name="valueFrom{$i}" type="text" id="valueFrom{$i}" data-itr="{$i}" class="form-control positivefloat valueFrom" value="" placeholder="0"></td>
                                <td> <input name="valueTo{$i}" type="text" id="valueTo{$i}" data-itr="{$i}" class="form-control positivefloat valueTo" value="" placeholder="0"></td>
                                <td> <textarea class="form-control" rows="2" id="comment{$i}" name="comment{$i}"></textarea></td>
                                <!--                                <td><select id="costcenterid{$i}" name="costcenterid{$i}" data-placeholder="اختر" style="width:200px" tabindex="-1" class="select2-offscreen">
                                                                        <option value="0" selected="selected"> لا يوجد</option>
                                                                    </select></td>-->
                                <td> <a class="btn btn-default btn-lg removeicon removethis" data-itr="{$i}" data-type="fromDiv" style="padding:11px" tabindex="0"></a></td>
                            </tr>
                            {assign var=i value=$i+1}
                            {/foreach}
                        </tbody>
                        <tr class="mytotal bg-dark">
                            <td>الاجمالى</td>
                            <td></td>
                            <td>{$totalDebtor}</td>
                            <td>{$totalCreditor}</td>
                            <th id="totalValueFrom">0</th>
                            <th id="totalValueTo">0</th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>
                    </table><input type="hidden" id="itr" name="itr" value="{$i}" />

                    <br/>
                    <!-- totals ------------------------------------------------->
                    <input type="hidden" id="totalValueFrom_hidden" name="totalValueFrom_hidden" value="0"/>
                    <input type="hidden" id="totalValueTo_hidden" name="totalValueTo_hidden" value="0"/>
                    <!-- totals ------------------------------------------------->


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button name="btnAdd" type="button" id="btnAdd_dailyEntry" class="btn btn-primary pull-left">حفظ</button>
                        </div>
                    </div>
                    <div style="clear: both"></div></br>
                    <div class="form-group col-lg-12">
                        <div class="alert alert-success" style="font-size: 22px;text-align: center;display: none">
                            <button class="close" data-dismiss="alert"></button>
                            تمت العملية بنجاح
                            <!--Your form validation is successful!-->
                        </div>
                    </div><div style="clear: both"></div>
                </form>
            </div>
        </div>



    </div>
</div>








<div id="accountsTree" style="display:none">
    <option value=""></option>
    {foreach $accountsTree as $element}
    <option value="{$element->id}">{$element->id}-{$element->name}</option>
    {/foreach}
</div>
<div id="costCenterDiv" style="display:none">
    <option value="0" selected="selected"> لا يوجد</option>
    {foreach $costCenter as $element}
    <option value="{$element->id}">{$element->name}</option>
    {/foreach}
</div>
