/
home
/
sjslayjy
/
public_html
/
cropnet
/
resources
/
views
/
admin
/
master
/
Upload File
HOME
@extends('admin.layouts.app') @section('title','Assign Sections to User') @section('style') <meta name="csrf-token" content="{{ csrf_token() }}"> {{-- {{Html::style("assets/css/bootstrap-datepicker3.min.css")}} --}} @endsection @section('content') <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Header Dynamic --> <div class="content-header"> <div class="d-flex align-items-center"> <div class="me-auto"> <h4 class="page-title">{{$page}}</h4> <div class="d-inline-block align-items-center"> <nav> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#"><i class="fa fa-home"></i></a></li> <li class="breadcrumb-item active" aria-current="page">{{$page}}</li> </ol> </nav> </div> </div> </div> </div> <!-- End Header Dynamic --> <!-- Main content --> <section class="content"> <div class="row"> <div class="col-12"> <div class="box"> <div class="box-header with-border"> <div class="clearfix"> </div> </div> <!-- /.box-header --> <div class="box-body"> <div class="row"> <form id="assingSectionForm"> <div class="row"> <div class="col-3"> <div class="form-group"> <label for="user_id" class="form-label">User :</label> <select class="form-control" name="user_id" id="user_id"> <option value="">Select User</option> @foreach($all_users as $key=>$value) <option value="{{ $value->id }}">{{ ucfirst($value->name) }}</option> @endforeach </select> <span class="label label-danger" id="add_user_id_error" style="display: none;"></span> </div> </div> <div class="col-3"> <div class="form-group"> <label for="module_id" class="form-label">Sections :</label> <select class="form-control select2" name="sections[]" id="section_id" multiple="multiple" data-placeholder="Select Sections" style="width: 100%;" > @foreach($sections as $key=>$value) <option value="{{ $value->id }}">{{ $value->id }}. {{ $value->section }}</option> @endforeach </select> <span class="label label-danger" id="add_module_id_error" style="display: none;"></span> </div> </div> <div class="col-3"> <label for="bmc" class="form-label">BMC/MCC</label> <select class="form-control select2" name="bmc[]" id="bmc_id" multiple="multiple" data-placeholder="Select BMC"> @foreach($all_bmc as $key=>$bmc) <option value="{{ $bmc->code }}">{{ $bmc->code }} {{ $bmc->name }}</option> @endforeach </select> <span class="label label-danger" id="add_bmc_error" style="display: none;"></span> </div> <div class="col-3"> <div class="pt-4"> <button type="button" class="btn btn-primary" onclick="assingSections()">Assign</button> </div> </div> </div> </form> </div> <div class="row"> <div class="table-responsive"> <table id="dynamic-table" class="table table-bordered table-hover display nowrap margin-top-10 w-p100 text-center"> <thead> <tr> <th style="text-align: center;">ID</th> <th style="text-align: center;">Name</th> <th style="text-align: center;">Email</th> <th style="text-align: center;">Assigned Sections</th> <th style="text-align: center;">Assigned MCC</th> </tr> </thead> <tbody> @foreach($all_users as $key=>$user) <tr id="tr_{{$user->id}}"> <td>{{$key+1}}</td> <td>{{ucfirst($user->name)}}</td> <td>{{$user->email}}</td> <td>{{ $user->assigned_sections }}</td> <td>{{ $user->assigned_mcc }}</td> </tr> @endforeach </tbody> </table> </div> </div> </div> <!-- /.box-body --> </div> <!-- /.box --> </div> </div> </section> <!-- /.content --> </div> </div> @endsection @section('script') <!--<script src="{{asset("assets/vendor_components/datatable/datatables.min.js")}}"></script>--> {{-- <script src="{{asset("src/js/pages/patients.js")}}"></script> --}} <!--<script src="../src/js/pages/data-table.js"></script>--> <script src="../src/js/pages/validation.js"></script> <script src="../src/js/pages/form-validation.js"></script> <script> function assingSections() { var userId = $('#user_id').val(); if (userId == "") { swal("User Missing !","User ID is missing. Please try again.","error"); return false; } $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') } }); $.ajax({ url: '/admin/assing-section-to-user', type: 'POST', data: $('#assingSectionForm').serialize(), success:function (data) { console.log(data); if (data.flag == true) { swal({ title:"Successfully", text:data.message, icon:"success" }).then(function(){ window.location.reload(); }); } else if(data.flag == 2){ $.each(data.error, function(key, value){ $('#add_'+key+'_error').text(value).show(); }); } else { swal("Something Went Wrong",data.error,"error"); } } }); } </script> @endsection