
@{section header}
<title>ویرایش کاربر</title>
@{end}
@{if repository.user.role=="administrator"}
<div class="Hrow">
	<div class="Hcontainer Hcontainer-1200 Hpadd-2per">
        
                @{view('../modules/https_modules/users/views/partial/userINSup',model)}
	</div>
</div>
@{else}
<div class="HpaddR-5 HpaddL-5 HpaddT-2per" data-color="#333" style="max-width:500px;display:block;margin:auto;overflow:auto;">
    <span class="Hfloat-R"><b  class="fas fa-user-edit HpaddL-7"></b> @{model.username} </span>
    <span class="Hfloat-L"> @{!resource(model.role)} </span>
</div>
@{fi}

<div class="Hrow">
	<div class="Hcontainer Hcontainer-1200 HpaddR-2per HpaddL-2per HpaddB-2per">
                @{view('../modules/https_modules/users/views/partial/userinfoINSup',model.joinlist[0])}
	</div>
</div>

@{section footer}





  <script type="text/javascript">
function show_resUPDuserinfo(result){
    switch(result.status){
      case 200:
            Hnotification({status:"success",Cstyle:[{color:"#ffffff"}],Ctext:result.data});
      break;
        default:
            Hnotification({status:"warning",Cstyle:[{color:"#000000"}],Ctext:result.data});
      break;
    }
   }
   
   
function show_resINSuserinfo(result){
    switch(result.status){
      case 200:
            Hnotification({status:"success",Cstyle:[{color:"#ffffff"}],Ctext:result.data});
            document.location.reload(true);
      break;
        default:
            Hnotification({status:"warning",Cstyle:[{color:"#000000"}],Ctext:result.data});
      break;
    }
}

   
function show_resUPDuser(result){
    switch(result.status){
      case 200:
            Hnotification({status:"success",Cstyle:[{color:"#ffffff"}],Ctext:result.data});
      break;
        default:
            Hnotification({status:"warning",Cstyle:[{color:"#000000"}],Ctext:result.data});
      break;
    }
}


var opensubmit=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
//var opensubmit=[0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1];


$(document).ready(function(){

    $("#userinfoINSup").click(async function(){

        var formdata=new FormData(frm_userinfo);
        var id=window.location.href.split("/");
        id=id[id.length-1];

        var url=($(this).attr("upd")*1)?"/userinfo/update":("/userinfo/insert/"+id);
        
        if(opensubmit.toString().replace(/,/g,"")=="1111111111111111"){
            $("#frm_userinfo input").each(function(index,element){
                $("#"+$(element).attr("id")).trigger("blur");
            });
            if($("#Hnotification").children().length==0){
                
                var result=await jqajax(url,formdata,"post","loader");
                ($(this).attr("upd")*1)?show_resUPDuserinfo(result):show_resINSuserinfo(result);
            }
        }else{
            Hnotification({status:"info",Cstyle:[{color:"#ffffff"}],Ctext:"لطفا کادرها را بصورت صحیح پر کنید"});
        }
    });
    
    $("#userINSup").click(async function(){
        
        var formdata=new FormData(frm_user);

        if(opensubmit.toString().replace(/,/g,"")=="1111111111111111"){
            $("#frm_user input").each(function(index,element){
                $("#"+$(element).attr("id")).trigger("blur");
            });
            if($("#Hnotification").children().length==0){
                var result=await jqajax("/user/update",formdata,"post","loader");
                show_resUPDuser(result);
            }
        }else{
            Hnotification({status:"info",Cstyle:[{color:"#ffffff"}],Ctext:"لطفا کادرها را بصورت صحیح پر کنید"});
        }
    });
    
});





</script>


@{end}
