<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>
            </div>
            <div class="panel-body">
                <form class="nameToBeChecked form-horizontal" action="" method="post" id="dailyEntry_Form">
                    <input type="hidden" id="selectedIds" name="selectedIds" value=""/>
                    <input type="hidden" id="searchvalue" name="searchvalue" value="1"/>
                    <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">
                                <select id="costcenterid" name="costcenterid" data-placeholder="اختر" class="select2 wdt300">
                                    <option value="0"> لا يوجد</option>
                                    {foreach $costCenter as $element}
                                    <option value="{$element->id}">{$element->name}</option>
                                    {/foreach}
                                </select>
                            </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>
                    <div class="panel col-lg-6" >
                        <div class="panel-heading">
                            <a href="javascript:;" id="DE_from_add" class="btn btn-primary pull-left" style="display:inline !important;margin-top: -3px;padding-top: 0px;padding-bottom: 0px;margin-left: -11px;">+</a>
                            <h3 class="panel-title"><strong>مـــن</strong></h3>

                        </div>
                        <input type="hidden" id="fromCount" name="fromCount" value="1" />

                        <!--==============================-->
                        <div id="DE_From_div">

                            <div class="form-group">
                                <label class="col-lg-1 control-label">القيمة</label>
                                <div class="col-lg-2">
                                    <input name="valueFrom1" type="text" id="valueFrom1"  class="form-control positiveNo valueFrom" value="0"/>
                                </div>
                                <label class="col-lg-1 control-label">العنصر</label>
                                <div class="col-lg-7">
                                    <input type="hidden"  id="parentFrom1" name="parentFrom1" data-placeholder="اختر" class="dailyParent wdt100"/>


                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-1 control-label">البيان</label>
                                <div class="col-lg-10">
                                    <textarea class="form-control" rows="2" id="commentFrom1" name="commentFrom1"></textarea>
                                </div>
                            </div>

                        </div>
                        <!--==============================-->

                    </div>



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



                    <div class="panel col-lg-6" >
                        <div class="panel-heading">
                            <a href="javascript:;" id="DE_to_add" class="btn btn-primary pull-left" style="display:inline !important;margin-top: -3px;padding-top: 0px;padding-bottom: 0px;margin-left: -11px;">+</a>
                            <h3 class="panel-title"><strong>الـــى</strong></h3>
                        </div>
                        <input type="hidden" id="toCount" name="toCount" value="1" />
                        <!--==============================-->
                        <div id="DE_To_div">

                            <div class="form-group">
                                <label class="col-lg-1 control-label">القيمة</label>
                                <div class="col-lg-2">
                                    <input name="valueTo1" type="text" id="valueTo1"  class="form-control positiveNo valueTo" value="0"/>
                                </div>

                                <label class="col-lg-1 control-label">العنصر</label>
                                <div class="col-lg-7">
                                    <input type="hidden"  id="parentTo1" name="parentTo1" data-placeholder="اختر" class="dailyParent wdt100"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-lg-1 control-label">البيان</label>
                                <div class="col-lg-10">
                                    <textarea class="form-control" rows="2" id="commentTo1" name="commentTo1"></textarea>
                                </div>
                            </div>

                        </div>
                        <!--==============================-->
                    </div>






                    <!-- totals ------------------------------------------------->
                    <div class="form-group col-lg-12">
                        <div class="col-lg-6">
                            <div class="well well-sm col-lg-offset-8 totalDiv">
                                <h4 class="text-center">الاجمالى <span id="totalValueFrom">0</span> {$currency}</h4>
                            </div>
                        </div>




                        <div class="col-lg-6">
                            <div class="well well-sm col-lg-offset-8 totalDiv">
                                <h4 class="text-center">الاجمالى <span id="totalValueTo">0</span> {$currency}</h4>
                            </div>
                        </div>
                    </div>
                    <!-- totals ------------------------------------------------->

                    <input type="hidden" id="totalValueFrom_hidden" name="totalValueFrom_hidden" value="0"/>
                    <input type="hidden" id="totalValueTo_hidden" name="totalValueTo_hidden" 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="dailyentry.php" method="post">
                    <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" 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="submit" class="btn btn-primary">بحث</button>
                </form>
                <div id="dailyEntryTable">
                    {if $allDailyEnteryCount>0}
                    <br />
                    <hr/>
                    <br/>
                    <table class="table table-black">
                        <thead>
                            <tr class="mytotal">
                                <th class="solidgrayright">#</th>
                                <th class="solidgrayright">رقم القيد</th>
                                <th>مدين</th>
                                <th>دائن</th>
                                <th>الحساب</th>
                                <th>التاريخ</th>
                                <th>البيان</th>
                                <th class="solidgrayleft">بيان القيد</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 as $dailyEntery}
                            {if $dailyEntery->id !=""}

                            <!--عكس القيد-->
                            {if $dailyEntery->reverseofid != 0 && $dailyEntery->reverseofid != -10}
                            <tr class="solidgraytop" style="background-color: #FCE4EC">
                                {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}



                                {if $dailyEntery->type eq 0}
                                <td>{$dailyEntery->value}</td>
                                <td></td>
                                <td> <span class="fromaccountstyle">من حــ/ </span> {$dailyEntery->accountstreeName}</td>
                                <td>{$dailyEntery->dDateTime}</td>
                                <td>{$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>{$dailyEntery->dDateTime}</td>
                                <td>{$dailyEntery->dComment}</td>
                                {assign var=creditorTotal value=$creditorTotal+ $dailyEntery->value}
                                {/if}




                                {if $dailyEntery->id !=""}
                                <td class="solidgrayleft solidgrayright">{$dailyEntery->entryComment}</td>
                                {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="dailyentry.php?do=reverse&id={$dailyEntery->id}"></a></td>
                                {/if}
                                {else}
                                <td class="hidetop solidgrayleft solidgrayright"></td>
                                <td class="hidetop solidgrayleft solidgrayright"></td>
                                {/if}
                            </tr>
                            {/foreach}
                            <tr class="mytotal">
                                <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>
                    {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>
