@extends('backend.header')
@section('index-content')
<?php
function convertToUnicodeNumber($input) {
    
    $standard_numsets = array("0","1","2","3","4","5","6","7","8","9");
    $devanagari_numsets = array("०","१","२","३","४","५","६","७","८","९");
    
    return str_replace($standard_numsets, $devanagari_numsets, $input);
  }
?>
				<section role="main" class="content-body">
					<header class="page-header">
						<h2> वापरकर्ता फॉर्म</h2>
					
						<div class="right-wrapper pull-right">
							<ol class="breadcrumbs">
								<li>
									<a href="/">
										<i class="fa fa-home"></i>
									</a>
								</li>
								<li><span>फॉर्म</span></li>
								<li><span> वापरकर्ता</span></li>
							</ol>
					
							<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
						</div>
					</header>

					<!-- start: page -->
					<div class="row" id="useraddform">
						<div class="col-md-10">
							<form id="form" action="{{route('user.store')}}" class="form-horizontal" method="post">
							@csrf
								<section class="panel">
									<header class="panel-heading">
										<div class="panel-actions">
											<a href="#" class="fa fa-caret-down"></a>
											<a href="#" class="fa fa-times"></a>
										</div>

										<h2 class="panel-title"> वापरकर्ता फॉर्म</h2>
										<!--<p class="panel-subtitle">
											Basic validation will display a label with the error after the form control.
										</p>-->
									</header>
									<div class="panel-body">
										<div class="form-group">
											<label class="col-sm-3 control-label"> वापरकर्ता नाव <span class="required">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="user_name" class="form-control" required pattern="[A-Za-z ]{0,100}" title="Enter Valid Name">
												@error('user_name')
												<font size="3" color="red">{{$message}}</font>
												@enderror	
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">मोबाईल नंबर <span class="required">*</span></label>
											<div class="col-sm-9">
												<input type="text" name="mobile_number" class="form-control" required pattern="[0-9]{10}" title="Enter 10 Digits Number">
												@error('mobile_number')
												<font size="3" color="red">{{$message}}</font>
												@enderror	
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-3 control-label">पासवर्ड <span class="required">*</span></label>
											<div class="col-sm-9">
												<input type="password" name="password" class="form-control" required>
												@error('password')
												<font size="3" color="red">{{$message}}</font>
												@enderror	
											</div>
										</div>
										
									</div>
									<footer class="panel-footer">
										<div class="row">
											<div class="col-sm-9 col-sm-offset-3">
												<button class="btn btn-primary" type="submit">Submit</button>
												<!--<button type="reset" class="btn btn-default">Reset</button>-->
											</div>
										</div>
									</footer>
								</section>
							</form>
						</div>
						
					</div>
					
					<!-- allot user code here -->
					<div class="row" id="userallotform" style="display:none;">
						<div class="col-md-12">
						    <center>Username:-<h4 id="usernameid"></h4></center>
							<form action="{{route('allotuser.store')}}" method="post" class="form-horizontal">
							   @csrf
							<div class="panel-body">
							    <div class="row">
							        <input type="hidden" class="userid" name="userid">
                                    <div class="col-sm-3" style="height:100px;border:1px solid black;border:none;">
                                        <h4>जिल्हा</h4>
                                        <select style="height:40px;width:100%;margin-top:0px;" id="jilla_id">
                                            <option value="">जिल्हा नाव</option>
                                            @foreach($jilla as $j)
                                            <option value="{{$j->id}}">{{$j->area_name}}</option>
                                            @endforeach
                                          </select>
                                          
                                    </div>
                                    <div class="col-sm-3" style="height:100px;border:1px solid black;border:none;">
                                        <h4>तालुका</h4>
                                        <select style="height:40px;width:100%;margin-top:0px;" id="taluka">
                                         <option value="">तालुका</option>   
                                        </select>
                                    </div>
                                    <div class="col-sm-3" style="height:100px;border:1px solid black;border:none;">
                                        <h4>ग्राम</h4>
                                        <select style="height:40px;width:100%;margin-top:0px;" id="gram_id">
                                         	<option value="">ग्रामपंचायत</option>
                                         	</select>
                                          
                                    </div>
                                    <div class="col-sm-3" style="height:100px;border:1px solid black;border:none;">
                                        <h4>Add</h4>
                                        <button type="button" id="addallot"><i class="fa fa-plus" aria-hidden="true"></i></button>
  
                                    </div>
                                    
                                </div>
                                <table border=1 id="rowallot">
                                    <tr><th>Jilla Name</th><th>Taluka Name</th><th>Gram Name</th><th>Delete</th></tr>
                                    
                                </table>
                                <input type="hidden" id="rowcount" name="rowcount">
                                <div class="row">
                                <input type="submit" style="padding:10px;margin-top:20px;width:40%;margin-left:300px;" class="btn btn-success" value="Submit">
                                </div>
                                <br>
                                
							</div>
							</form>
						</div>
						
					</div>
					<!-- allot code end here-->
					<!-- end: page -->
					<!-- start: page -->
					<section class="panel">
							<header class="panel-heading">
								<div class="panel-actions">
									<a href="#" class="fa fa-caret-down"></a>
									<a href="#" class="fa fa-times"></a>
								</div>
						
								<h2 class="panel-title">वापरकर्ता तपशील</h2>
							</header>
							<div class="panel-body">
								<table class="table table-bordered table-striped mb-none" id="datatable-default">
									<thead>
										<tr>
											<th>वापरकर्ता क्र.</th>
											<th>वापरकर्ता नाव</th>
											<th>मोबाईल नंबर</th>
											<th>पासवर्ड</th>
											<th>Status</th>
											
											<th>Edit</th>
											<th>Delete</th>
											<th>Allot</th>
											
										</tr>
									</thead>
									<tbody>
									@foreach($regi as $a)
									<tr class="gradeX">
											<td><?php echo convertToUnicodeNumber($a->id);?></td>
											<td>{{$a->name}}</td>
											<td><?php echo convertToUnicodeNumber($a->mobile);?></td>
											<td>{{$a->password}}</td>
												<?php 
											$s=$a->status;
											if($s=='active')
											{
											?>
											<td><a href="/userstatusupdate/{{$a->id}}" class="btn btn-success" id="statuschk" value="{{$a->id}}">{{$a->status}}</a></td>
											<?php
											}else{
											?>
											<td><a href="/userstatusupdate/{{$a->id}}" class="btn btn-warning" id="statuschk" value="{{$a->id}}">{{$a->status}}</a></td>
											<?php
											}
											?>
											<td class="actions">
												
												<a href="{{route('user.edit',$a->id)}}" class="on-default edit-row"><button class="btn btn-primary">Edit</button></a></td>
												<td><form action="{{route('user.destroy',$a->id)}}" method="post">
												@csrf
												@method('DELETE')
												<input type="submit" class="btn btn-danger" value="Delete">
												</form>
											</td>
											
											<td><form action="/userallotform" method="post">
											    @csrf
											    <input type="hidden" value="{{$a->id}}" name="userid">
											    <input type="submit" class="allotuser" class="btn btn-secondary" value="Allot"></form></td>
											
									</tr>
									@endforeach
									</tbody>
								</table>
							</div>
						</section>
				</section>
			@stop