NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

@model Web.Models.HomeViewModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="card">
<div class="card-body">

<div class="p-3" id="setcartouserModal">

<h4 class="modal-header d-flex justify-content-center ">Kullanıcılar</h4>
<h6 style="margin-left: 19px" class="mt-">Kullanıcıya Araç Atama</h6>
<div class="row" style="margin-left: 7px">
<div class="col-md-4 col-12">
<div class="mb-2 mt-2">
<label for="aracatamauserid" class="form-label">Kullanıcı Adı</label>
<select onchange="GetUserDevicesByUserId(this.value)" id="aracatamauserid" class="form-select">
</select>
</div>
</div>
<div class="col-md-4 d-flex justify-content-center align-items-center" style="padding-top:16px;">
<input style="display:none" id="_userId" value="@Model.User.Id">
<input style="display:none" id="NameKAA" value="@Model.User.UserCode">
<input type="checkbox" class="check mr-2" id="checkusersetcar" onclick="Disabled()">
<label for="checkusersetcar" class="ml-2">Tüm şirket araçlarında çalış</label>
</div>
<div class="col-md-4 col-12">
<div class="mb-2 mt-2">
<label for="aracAtamaCompanyId" class="form-label">Şirket</label>
<select id="aracAtamaCompanyId" class="form-select" disabled onchange="GetAllCompanyUsers()">
<option value="@Model.User.CompanyId" selected>@Model.User.CompanyName</option>
</select>
</div>
</div>
<div class="row mt-4 mb-5">
<div class="col-md-5 ml-2">
<label>Tüm Araçlar</label>
<select style="width: 100%;height: 150px;" class="form-control" id="carLeft" multiple="">
</select>
</div>
<div class="col-md-2">
<div class="row">
<div class="col-md-12 d-flex justify-content-center">
<button class="btn btn-dark btn-lg btn-xs ml-5" onclick="carToRight()">
&gt;&gt;
</button>
</div>
<div class="col-md-12 d-flex justify-content-center mt-2">
<button class="btn btn-dark btn-lg btn-xs ml-5 mt-1" onclick="carToLeft()">
&lt;&lt;
</button>
</div>
</div>
</div>
<div class="col-md-5 ml-2">
<label>Atanmış Araçlar</label>
<select style="width: 100%;height: 150px;" class="form-control" id="carRight" multiple="">
</select>
</div>
</div>
<div class="col-md-12 col-12">
<div class="d-flex justify-content-end ml-5 mb-5">
<button type="button" class="btn btn-dark mr-2 mt-3" onclick="AssignVehicleToUser()" id="saveusersetcar">
Kaydet
</button>


</div>
</div>
</div>
</div>
</div>
</div>

<script>
$(document).ready(function () {
GetDevicesByCompany(@Model.Company.Id);
});

function GetDevicesByCompany(id) {
$('#carRight').html("");
$.ajax({
url: '@Url.Action("GetUserListToAppend", "Yonetim")',
dataType: 'json',
type: 'post',
data: {
"_companyId": id
},
success: function (data) {
var Id = $('#IdKAA').val();
var Name = $('#NameKAA').val();
var toAppend = "";
if (data == false) {
$('#aracatamauserid').html("");
toAppend += "<option value='0' selected>Seçiniz..</option>";
// toAppend += "<option value="+Id+">"+Name+"</option>";
$('#aracatamauserid').append(toAppend);
}
else {
$('#aracatamauserid').html("");
toAppend += "<option value='0' selected>Seçiniz..</option>";
//toAppend += "<option value="+Id+">"+Name+"</option>";
for (var i = 0; i < data.length; i++) {
var item = data[i];
toAppend += "<option value=" + item.Id + ">" + item.UserCode + "</option>";
}

$('#aracatamauserid').append(toAppend);
}
}
});
$.ajax({
url: '@Url.Action("GetDevicesByCompany2", "Yonetim")',
dataType: 'json',
data: {
"_aracAtamaCompanyId": id
},
success: function (data) {

if (data) {
$('#carLeft').empty();
for (var i = 0; i < data.length; i++) {
item = data[i];
$('#carLeft').append('<option class="leftCarAracAtama" style="font-size:13px;font-weight:600;"value="' + item.Id + '">' + item.CarPlateNumber + '</option>');
}
}
else {
$('#carLeft').append('<option>' + " Cihaz bulunamadı... " + '</option>');

}

}
});
GetAllCompaniesByUserId();
}

function GetAllCompaniesByUserId() {

$.ajax({
url: '@Url.Action("GetAllCompaniesByUserId", "Yonetim")',
type: 'POST',
dataType: 'json',
data: {
},
success: function (data) {
for (var i = 0; i < data.length; i++) {
var item = data[i];
if (data.length > 1) {
$('#aracAtamaCompanyId').append("<option value='" + item.Id + "'>" + item.CompanyDescription + "</option>");
}
}

}
});



}

function GetUserDevicesByUserId() {
console.log("girdi")
var aracatamauserid = $('#aracatamauserid').val();
var aracAtamaCompanyId = $('#aracAtamaCompanyId').val();
$("#carLeft option").show();
$("#carRight").html("");
$.ajax({
url: '@Url.Action("GetAppendUserDeviceList", "Yonetim")',
type: 'POST',
dataType: 'json',
data: {
"_aracatamauserid": aracatamauserid
},
success: function (data) {
console.log("girdi")
if (data) {
if ($('#aracatamauserid').val() == 0) {
$("#carLeft option").show();
$("#carRight").html('');
return;
}
var deviceIds = [];
for (var i = 0; i < data.length; i++) {
deviceIds.push(data[i]["Id"]);
}

$("#carLeft option").show();
$("#carRight").html("");

var items = $("#carLeft option");

for (var i = 0; i < items.length; i++) {
var value = parseInt($(items[i]).attr("value"));
var name = $(items[i]).text().trim();

if (deviceIds.includes(value)) {
$(items[i]).hide();
$("#carRight").append('<option value="' + value + '">' + name + '</option>');
}
}
}
else {
$("#carLeft option").show();
$("#carRight").html("");
}

}
});

}

function GetAllCompanyUsers() {
$("#carLeft").empty;
$("#carRight").empty;
var aracAtamaCompanyId = $('#aracAtamaCompanyId').val();
$.ajax({
url: '@Url.Action("GetCompanyUser", "Yonetim")',
type: 'POST',
dataType: 'json',
data: {
"_aracAtamaCompanyId": aracAtamaCompanyId
},
success: function (data) {
$('#aracatamauserid').empty();
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
var item = data[i];
$('#aracatamauserid').append("<option value='" + item.Id + "'>" + item.UserCode + "</option>");
}
}
if (data.length == 0) {
$('#aracatamauserid').append("<option>Kullanıcı Bulunamadı</option>");
}
GetUserDevicesByUserId();
}
});
GetDevicesByCompany(aracAtamaCompanyId);
}


function carToRight() {
var val = $("#carLeft").val();

for (var i = 0; i < val.length; i++) {
if (val.includes(val[i])) {
$("#carRight").find("*[value='" + val[i] + "']").remove();
}
var html = $("#carLeft").find("*[value='" + val[i] + "']");
html = html[0].outerHTML;
$("#carRight").append(html);
$('#carRight option').show();
$("#carLeft").find("*[value='" + val[i] + "']").hide();
}
}

function carToLeft() {
var val = $("#carRight").val();

for (var i = 0; i < val.length; i++) {
if (val.includes(val[i])) {
$("#carLeft").find("*[value='" + val[i] + "']").remove();
}
var html = $("#carRight").find("*[value='" + val[i] + "']");
html = html[0].outerHTML;

$("#carLeft").append(html);
$("#carRight").find("*[value='" + val[i] + "']").remove();
}
}

function AssignVehicleToUser() {
var aracatamauserid = $('#aracatamauserid').val();
if ($('#aracatamauserid').val() == 0) {
swal("Hata!", "Lütfen bir kullanıcı seçiniz...", "error");
return;
}

var selectedDeviceIds = [];
var options = $('#carRight option');
//if (options.length == 0) {
// swal("Hata!", "Lütfen bir araç seçiniz...", "error");
// return;
//}
for (var i = 0; i < options.length; i++) {
selectedDeviceIds.push($(options[i]).attr("value"));
}
$.ajax({
url: '@Url.Action("AssignVehicleToUser", "Yonetim")',
type: 'POST',
dataType: 'json',
data: {
"_aracatamauserid": aracatamauserid,
"_selectedDeviceIds": selectedDeviceIds
},
success: function (data) {
if (data) {
swal("Başarılı", "Eklendi", "success");
}
else {
swal("HATA!", "Kaydedilemedi", "error");
}
}
});
}
</script>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.