
<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">{$smarty.const.EXPENSES_REVENUE}</a></li>
            <li><a href="#">{$smarty.const.EXPENSES}</a></li>
            <li class="active">{$smarty.const.EXPENSES_TYPE_EDIT}</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">{$smarty.const.EXPENSES_TYPE_EDIT}</h3>
            </div>
            <div class="panel-body">
                <form id="typeform" class="nameToBeChecked form-horizontal" action="expensesTypeController.php?do=update&id={$data->expensestypeid}" method="post">
                    <!--validate the form before checking name-->




                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_MAIN_CLASSIFICATION}</label>
                        <div class="col-lg-5">
                            <select name="parent" id="parent" class="select2 wdt100">
                                <option></option>
                                <option {if $data->parent eq 0} selected {/if} value="0">{$smarty.const.EXPENSES_TYPE_NO_MAIN_CLASSIFICATION}</option>
                                {foreach $allParents as $parent}
                                <option value="{$parent->expensestypeid}" {if $data->parent eq $parent->expensestypeid} selected {/if}>{$parent->expensestypename}</option>
                                {/foreach}
                            </select>
                            <div id="parentError" style="display:none;"></div>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_NAME}</label>
                        <div class="col-lg-5">
                            <input type="text" name="name" id="name" value="{$data->expensestypename}" class="form-control"/>
                            <input type="hidden" name="oldname" id="oldname" value="{$data->expensestypename}"/>

                            <input type="hidden" name="expensestypeid" id="expensestypeid" value="{$data->expensestypeid}"/>
                            <div id="nameError"  style="display:none;"></div>
                        </div>
                    </div>

                    {if $Programsettingdata->realestatedev eq 0} 

                     <div class="form-group">
                        <label  class="col-lg-2 control-label"> داخل نسبة الاشراف   </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="withinsupervision_ratio" value="1" {if {$data->withinsupervision_ratio} eq 1} checked="checked"  {/if}"">
                          <label >نعم </label>
                          <input type="radio"  name="withinsupervision_ratio" value="2" {if {$data->withinsupervision_ratio} eq 2} checked="checked"  {/if}>
                          <label >لا</label>
                        </div>
                    </div>
<!-- 
                    <div class="form-group withinsupervisionratio" {if {$data->withinsupervision_ratio} eq 2} style="display: none;" {/if}>
                        <label  class="col-lg-2 control-label">  نسبة الاشراف   </label>
                        <div class="col-lg-4">
                          <input type="radio"  name="supervision_ratiotype" value="1" {if {$data->supervision_ratiotype} eq 1} checked="checked"  {/if}>
                          <label >قيمه </label>
                          <input type="radio"  name="supervision_ratiotype" value="2" {if {$data->supervision_ratiotype} eq 2} checked="checked"  {/if}>
                          <label >نسبه</label>
                        </div>
                    </div>

                     <div class="form-group withinsupervisionratio" {if {$data->withinsupervision_ratio} eq 2} style="display: none;" {/if}>
                        <label for="supervision_amount" class="col-lg-2 control-label"> مبلغ الاشراف   </label>
                        <div class="col-lg-4">
                            <input type="text" name="supervision_amount" id="supervision_amount" data-id='' class="form-control" placeholder="  مبلغ الاشراف  " required="" value="{$data->supervision_amount}" />

                        </div>
                    </div>
                   
                    -->
                    {/if}

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

                     {if $searchinonesave == 1}
                    <input type="hidden" name="saveid" id="saveid" value="{$saveid}" />
                    {else}
                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_SAFE}</label>
                        <div class="col-lg-5">
                            <select name="saveid" id="saveid" class="select2 wdt100">
                                <option value="0" {if $saveid == 0}selected{/if}>{$smarty.const.EXPENSES_TYPE_ALL_SAFE}</option>
                                {foreach $saves as $save}
                                <option value="{$save->saveid}" {if $data->saveid ==  $save->saveid}selected{/if}>{$save->savename}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    {/if}
                    
                   
                    <!--==============================-->
                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_USER_GROUPS}</label>
                        <div class="col-lg-5">
                            <select multiple name="addOnlyGroupIds[]" id="addOnlyGroupIds" class="select2 wdt100">
                                {foreach $userGroups as $group}
                                <option value="{$group->usergroupid}" {if $group->usergroupid|in_array:$data->addOnlyGroupIds}selected{/if}>{$group->usergroupname}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>

                    <!--==============================-->
                    <div class="form-group" id="treeTypeDiv">
                        <label class="col-lg-2 control-label"> النوع فى شجرة الحسابات</label>
                        <div class="col-lg-5">
                            <div class="radio-inline">
                                <label><input value="2"  class="radioR" name="treeType" type="radio" {if {$data->treeType} eq 2} checked="checked"  {/if}/>مصروفات التشغيل</label>
                            </div>
                            <div class="radio-inline">
                                <label><input value="1"  class="radioR" name="treeType" type="radio" {if {$data->treeType} eq 1} checked="checked"  {/if}/>مصروفات عمومية و إدارية</label>
                            </div>
                            <div class="radio-inline">
                                <label><input value="0"  class="noradioR" name="treeType" type="radio" {if {$data->treeType} eq 0} checked="checked"  {/if}/>مصروفات بيع و تسويق</label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_MANUFACTURING}</label>
                        <div class="col-lg-5">
                            <div class="radio-inline">
                                <label>
                                    <input value="1"  class="radioR" name="type"   type="radio"   {if {$data->type} eq 1} checked="checked"  {/if}/>

                                    {$smarty.const.EXPENSES_TYPE_YES} </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input value="0"  class="noradioR" name="type"   type="radio"   {if {$data->type} eq 0} checked="checked"  {/if}/>
                                    {$smarty.const.EXPENSES_TYPE_NO} </label>
                            </div>

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

                    <div class="form-group">
                        <label class="col-lg-2 control-label">{$smarty.const.EXPENSES_TYPE_OTHER_DETAILS}</label>
                        <div class="col-lg-5">
                            <textarea cols="20" rows="5" name="descripe" id="descripe" class="form-control">{$data->expensestypedetails}</textarea>
                        </div>
                    </div>

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

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" id="savebtn"  class="btn btn-primary pull-left">{$smarty.const.EDIT}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
    $('#parent').on('change', function () {
        var val = Number($(this).val());
        if (val > 0) {
            $('#treeTypeDiv').hide();
        } else {
            $('#treeTypeDiv').show();
        }
    })
    $('#parent').change();
</script> {/literal}