<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 panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title"><strong> اضافة فى قيد يومية</strong></h3>
                <a href="{$youtubes[227]->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="searchvalue" name="searchvalue" value="1"/>
                    <div class="col-lg-12" style="padding: 0">
                        {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}" {if $myallbranchdata->branchId==0}selected{/if}>{$myallbranchdata->branchName}</option>

                                    {/foreach}


                                </select>
                            </div>
                        </div>
                        {else}
                        <input type="hidden" name="branchid_entry" id="branchid_entry" value="{$user_data->branchId}"/>
                        {/if}
                        <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 id="DEMany">

                    </div>
                    <button type="button" class="btn btn-warning" style="float: left;" id="newHoleEntry">اضافة قيد</button>
                    <input type="hidden" id="noOfEntries" name="noOfEntries" value="0"/>

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


        <!--show-------------------------------------------------------------------------------------------->
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title"><strong> قيد يومية</strong></h3>

            </div>
            <div class="panel-body">
                <form class="form-inline hidden-print" action="" method="post" id="DEForm">
                    <div class="form-group">
                        <label class="sr-only">رقم القيد المجمع</label>
                        <input type="text" class="form-control" placeholder="رقم القيد المجمع" name="dailyentryid" id="dailyentryid">
                    </div>
                    <div class="form-group">
                        <label for="usergroupid" class="col-lg-4 control-label">الفرع</label>
                        <div >



                            <select  class="select2 " name="branchid" id="branchid" >
                                <option value="-1">اختر الفرع</option>

                                {foreach $allbranchdata as $myallbranchdata}
                                <option value="0">كل الفروع</option>

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

                                {/foreach}


                            </select>

                        </div>
                    </div>
                    <!--div class="form-group" style="width:270px  ;">
                        <label class="sr-only">ترتيب القيد</label>
                        <input type="hidden"  class="getlayingOrder wdt600" name="layingOrder" id="layingOrder" data-placeholder="اختر"  />
                    </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="datefrom" >
                    </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="dateto" >
                    </div>
                    <button type="button" class="btn btn-primary DEsubmit" id="DESerach">بحث</button>
                    <button type="button" class="btn btn-success DEsubmit" id="DESerachPrint">بحث و طياعة</button>
                </form>
                <div id="dailyEntryTable">
                    {if $allDailyEnteryCount>0}
                    <br />
                    <hr/>
                    <br/>
                    {foreach $relatedArr as $related}
                    <div class="row">
                        <div class="form-group col-lg-2">
                            <label class="sr-only">  رقم القيد المجمع</label>
                            <input type="text" class="form-control" placeholder="رقم القيد المجمع" value="{$allDailyEntery{$related}[0]->related}">
                        </div>
                        <div class="form-group col-lg-2">
                            <label class="sr-only">تاريخ القيد المجمع</label>
                            <input type="text" class="form-control" placeholder="تاريخ القيد المجمع" value="{$allDailyEntery{$related}[0]->thedate}">
                        </div>
                        <div class="form-group col-lg-6">
                            <label class="sr-only">بيان القيد المجمع</label>
                            <input type="text" class="form-control" placeholder="بيان القيد المجمع" value="{$allDailyEntery{$related}[0]->entryComment}">
                        </div>
                        <div class="form-group col-lg-2">
                            <label class="sr-only">طباعة</label><br/>
                            <a class="btn btn-default btn-lg printicon" href="dailyentrymany.php?do=print&id={$related}" target="_blank"></a>
                        </div>
                    </div>
                    <table class="table table-black">
                        <thead>
                            <tr class="mytotal">
                                <th class="solidgrayright">#</th>
                                <th class="solidgrayright">رقم القيد</th>
                                <th class="solidgrayright">الفرع</th>
                                <th>مدين</th>
                                <th>دائن</th>
                                <th>الحساب</th>
                                <th>البيان</th>
                                <th class="solidgrayleft">عكس القيد</th>
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=i value=1}
                            {assign var=debtorTotal value=0}
                            {assign var=creditorTotal value=0}
                            {foreach $allDailyEntery{$related} as $dailyEntery}
                            {if $dailyEntery->id !=""}

                            <!--عكس القيد-->
                            {if $dailyEntery->reverseofid != 0 && $dailyEntery->reverseofid != -10}
                            <tr class="solidgraytop bg-open-report">
                                {else}
                            <tr class="solidgraytop">
                                {/if}

                                <td class="solidgrayleft solidgrayright">{$i}</td>
                                {assign var=i value=$i+1}
                                <td class="solidgrayleft solidgrayright">{$dailyEntery->id}</td>
                                {else}

                                <!--عكس القيد-->
                                {if $dailyEntery->reverseofid > 0}
                            <tr style="background-color: #FCE4EC">
                                {else}
                            <tr>
                                {/if}

                                <td class="hidetop solidgrayleft solidgrayright"></td>
                                <td class="hidetop solidgrayleft solidgrayright"></td>
                                {/if}


                                <td  >{$dailyEntery->branchName}</td>
                                {if $dailyEntery->type eq 0}
                                <td>{$dailyEntery->value}</td>
                                <td></td>
                                <td> <span class="fromaccountstyle">من حــ/ </span> {$dailyEntery->accountstreeName}</td>
                                <td class="solidgrayleft solidgrayright">{$dailyEntery->dComment}</td>
                                {assign var=debtorTotal value=$debtorTotal+ $dailyEntery->value}
                                {else}
                                <td></td>
                                <td>{$dailyEntery->value}</td>
                                <td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="toaccountstyle">الى حــ/ </span>{$dailyEntery->accountstreeName}</td>
                                <td class="solidgrayleft solidgrayright">{$dailyEntery->dComment}</td>
                                {assign var=creditorTotal value=$creditorTotal+ $dailyEntery->value}
                                {/if}




                                {if $dailyEntery->id !=""}
                                {if $dailyEntery->reverseofid != 0 || $dailyEntery->reverseofid == -10}
                                <td class="solidgrayleft solidgrayright"></td>
                                {else}
                                <td class="solidgrayleft solidgrayright">
                                    <a class="btn btn-default btn-lg undoicon" href="dailyentrymany.php?do=reverse&id={$dailyEntery->id}"></a>
                                </td>
                                {/if}
                                {else}

                                <td class="hidetop solidgrayleft solidgrayright"></td>
                                {/if}
                            </tr>
                            {/foreach}
                            <tr class="mytotal bg-dark">
                                <td class="solidgrayright"></td>
                                <td class="solidgrayright"></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td colspan="4" class="solidgrayleft" style="text-align:center;"></td>

                            </tr>
                            <!--tr class="mytotal">
                                <td class="solidgrayright"></td>
                                <td class="solidgrayright"></td>
                                <td>{$debtorTotal}</td>
                                <td>{$creditorTotal}</td>
                                <td colspan="3" class="solidgrayleft" style="text-align:center;">الاجــــــــــمــــــــــالــــــى</td>

                            </tr-->

                        </tbody>
                    </table>
                    {/foreach}
                    {else}
                    <div class="nodata">عفوا لا توجد نتائج</div>
                    {/if}
                </div>
                </br>
            </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>
