<style>
    .clientAreaOption{
       background-color:#828282;
       color: whitesmoke;
    }
</style>


<div class="row">
  <div class="container">
    <ol class="breadcrumb">
      <li><a href="#">خصائص عامة</a></li>
      <li><a href="governmentController.php?do=show"> المحافظات التابع لها  الشركات</a></li>
      <li class="active">اضافة محافظة </li>
    </ol>
    
      <h3>اضافة  شركة</h3>
      <hr/>
    
      {literal}
    <form class="edit_governmentform form-horizontal" action="governmentController.php?do=update" method="post">
    
    <!--- onsubmit="if (Spry.Widget.Form.validate(this)) {checkName(event, 'clientarea', 'companyName'); return true;} else {return false;}"-->
          <!--validate the form before checking name--> 
          {/literal}
          
    
    <div class="row">
    	<div class="col-lg-8">
        
            <input type="hidden" name="oldGovernmentId" id="oldGovernmentId" value="{$governmentData->governmetid}"/>
        <div class="form-group">
             <label for="governmentName" class="col-lg-2 control-label">اسم المحافظة </label>

            <div class="col-lg-4">
                <input type="text" name="governmentname" id="governmentname" class="form-control" placeholder="اسم المحافظة" value="{$governmentData->governmentname}" />
                <div id="governmentnameError" class="alert alert-block alert-danger fade in" style="display:none"></div>
            </div>
        </div>

        <div class="form-group">
             <label for="governmentname_en" class="col-lg-2 control-label">اسم المحافظة </label>

            <div class="col-lg-4">
                <input type="text" name="governmentname_en" id="governmentname_en" class="form-control" placeholder="اسم المحافظة" value="{$governmentData->governmentname_en}" />
                <div id="governmentname_enError" class="alert alert-block alert-danger fade in" style="display:none"></div>
            </div>
        </div>


         <div class="form-group">
                <label for="storereporttype" class="col-lg-2 control-label">الحاله 1 </label>
                <div class=" col-lg-4">
                    <div class="radio-inline">
                        <label>
                            <input type="radio" name="is_active" id="is_active" value="1"  {if $governmentData->is_active  eq 1} checked {/if}>
                            مفعل </label>
                    </div>
                    <div class="radio-inline">
                        <label>
                            <input type="radio" name="is_active" id="is_active" value="0"  {if $governmentData->is_active  eq 0} checked {/if}>
                            معطل </label>
                    </div>
                </div>
            </div>


            <input type="hidden" name="area_itration" id="area_itration" value="{$loadAreaIds }"/>
            {assign var=x value = 0}
            {foreach $governmentClientareaData as $govern}
            <div class="form-group area_content area_content_{$x}">
             <label style="font-size: 11px;" for="companyName" class="col-lg-2 control-label">اسم شركة - منطقة </label>
            <div class="col-lg-4">
               
                <select data-placeholder="اختر الشركة" class="newArea" name="areaid_{$x}" id="newArea">
                    <option value="-1"> اختر الشركة</option>
                    {assign var=i value = 1}
                    {foreach $allClientarea as $area}
                            {if $govern->clientareaid eq $area->id}
                                 <option value="{$area->id}" selected="selected">{$area->name}</option>
                            {else}
                               
                                    <option value="{$area->id}" >{$area->name}</option>
                               
                            {/if}

                            {if  $i eq 1 }
                            <option class="clientAreaOption"  value="-2" >اضافة شركة جديدة</option>
                            {/if}
                    {assign var=i value=$i+1}
                    {/foreach}
                </select>
                {if $x neq 0 }
                    <input type="button" name="del_area" data-id="{$x}" class="del_area btn btn-danger" value ="مسح الشركة" id="del_area" style="margin-right: 380px;margin-top: -30px;"/> 
                {/if}

              <div id="newAreaError" class="alert alert-block alert-danger fade in" style="display:none"> </div>
            </div>
          </div>
                    {assign var=x value=$x+1}
                    {/foreach} 

            <div class="newAreaDiv"></div>
            <button type="button" class="addArea btn btn-warning" style="margin-right: 134px;margin-bottom: 8px;" >اضافة اسم شركة - منطقة</button>
        	
        <div class="form-group">
            <label for="otherInfo" class="col-lg-2 control-label">بيانات أخرى</label>
            <div class="col-lg-4">
              <textarea  class="form-control" rows="3" name="comment"></textarea>
            </div>
          </div>
          
          <!--==============================-->
        

    	</div><!-- end of client info-->
    
    </div><!-- end of frist row-->
  
    <div class="row">
    <button type="button"  style="margin-right: 147px;margin-top: 11px;" class="btn btn-primary savebtn">حفظ</button>
    
    </div><!-- end of fifth row-->
     
      
    <!------------------------Client Model----------------------------->
<!-- Modal -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">اضافة شركة جديدة</h4>
            </div>
            <div class="modal-body">
                <form id="clientareaInfo" action="#" method="post" class="form-horizontal">
                    <div class="form-group">
                        <label for="newclientName" class="col-lg-2 control-label">اسم الشركة </label>
                        <div class="col-lg-4"> 
                                <input class="form-control" placeholder="اسم الشركة" id="newclientArea"   name="newclientArea" type="text"  required="required"/>
                            <div id="newclientAreaError" class="alert alert-block alert-danger fade in" style="display:none"></div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="newclientArea_en" class="col-lg-2 control-label">اسم الشركة </label>
                        <div class="col-lg-4"> 
                                <input class="form-control" placeholder="اسم الشركة" id="newclientArea_en"   name="newclientArea_en" type="text"  required="required"/>
                            <div id="newclientArea_enError" class="alert alert-block alert-danger fade in" style="display:none"></div>
                        </div>
                    </div>

     
                    <div class="form-group">
                        <label for="clientAreaDiscription" class="col-lg-2 control-label">الوصف</label>
                        <div class="col-lg-4">
                            <textarea  class="form-control" rows="3" name="clientAreaDiscription" id="clientAreaDiscription"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="webApiId" class="col-lg-2 control-label">id - الخارجي  </label>
                        <div class="col-lg-4"> 
                                <input class="form-control" placeholder="id - الخارجي " id="webApiId"   name="webApiId" type="text"  />
                            <!--<div id="newclientAreaError" class="alert alert-block alert-danger fade in" style="display:none"></div>-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="shipping_cost" class="col-lg-2 control-label"> قيمة الشحن   </label>
                        <div class="col-lg-4"> 
                                <input class="form-control" placeholder="قيمة - الشحن " id="shipping_cost"   name="shipping_cost" type="text"  />
                            <!--<div id="newclientAreaError" class="alert alert-block alert-danger fade in" style="display:none"></div>-->
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <input type="hidden" name="selectionId" value="" id="selectionId" />
                <button type="button" class="btn btn-primary savemodel1" onClick="insertClientArea();">نعم</button>
                <button type="button" class="btn btn-default savemodel2" data-dismiss="modal">لا</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
    

<!------------------------------------------- area select  ------------------------------------------->
<div id="area_select" style="display:none">
                    <option value="-1"> اختر الشركة</option>
                        {assign var=i value = 1}
                        {foreach $allClientarea as $area}
                              <option value="{$area->id}">{$area->name}</option>
                            {if  $i eq 1 }
                            <option class="clientAreaOption"  value="-2" >اضافة شركة جديدة</option>
                            {/if}
                        {assign var=i value=$i+1}
                        {/foreach}
                 
</div>
<!------------------------------------------- area select ------------------------------------------->

    
   	</form>
    </div><!-- end of container-->
</div><!-- end of main row-->



{literal} 
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");

</script>
{/literal} 

