Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model HelpDesk.Models.UsersViewParentModel
- @{
- ViewBag.Title = "Users";
- }
- <script src="//code.jquery.com/jquery-1.10.2.js"></script>
- <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
- <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
- @*<div class="panel panel1 panel-default">
- <div class="panel-heading" style="background-color: #2583C3; color: white;">
- <h3 class="panel-title">Create</h3>
- </div>
- <div class="panel-body">
- <form class="form-horizontal">
- <fieldset>
- <!-- Multiple Radios -->
- <div class="form-group">
- <label class="col-md-4 control-label" for="radios">User type:</label>
- <div class="col-md-8">
- <div class="radio">
- <label for="radios-0">
- <input name="radios" id="radios-0" value="1" checked="checked" type="radio">
- Client
- </label>
- </div>
- <div class="radio">
- <label for="radios-1">
- <input name="radios" id="radios-1" value="2" type="radio">
- Admin
- </label>
- </div>
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-username">Username*:</label>
- <div class="col-md-8">
- <input id="create-username" name="create-username" placeholder="Username" class="form-control input-md" required="" type="text">
- </div>
- </div>
- <!-- Password input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-password">Password*:</label>
- <div class="col-md-8">
- <input id="create-password" name="create-password" placeholder="Password" class="form-control input-md" required="" type="password">
- </div>
- </div>
- <!-- Password input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-confirm-password">Confirm*:</label>
- <div class="col-md-8">
- <input id="create-confirm-password" name="create-confirm-password" placeholder="Password again" class="form-control input-md" required="" type="password">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-firstname">First name</label>
- <div class="col-md-8">
- <input id="create-firstname" name="create-firstname" placeholder="First name" class="form-control input-md" type="text">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-lastname">Last name</label>
- <div class="col-md-8">
- <input id="create-lastname" name="create-lastname" placeholder="Last name" class="form-control input-md" type="text">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-email">Email</label>
- <div class="col-md-8">
- <input id="create-email" name="create-email" placeholder="Email" class="form-control input-md" type="text">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-phone">Phone</label>
- <div class="col-md-8">
- <input id="create-phone" name="create-phone" placeholder="Phone" class="form-control input-md" type="text">
- </div>
- </div>
- <!-- Text input-->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-skype">SkypeID</label>
- <div class="col-md-8">
- <input id="create-skype" name="create-skype" placeholder="SkypeID" class="form-control input-md" type="text">
- </div>
- </div>
- <!-- Select Basic -->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-companyID">Company</label>
- <div class="col-md-8">
- <select id="create-companyID" name="create-companyID" class="form-control">
- @foreach (var company in Model.Companies)
- {
- <option value="@company.CompanyID">@company.CompanyName</option>
- }
- </select>
- </div>
- </div>
- <!-- Button -->
- <div class="form-group">
- <label class="col-md-4 control-label" for="create-confirm-button"></label>
- <div class="col-md-8">
- <a id="create-confirm-button" name="create-confirm-button" class="submit-button-blue" style="padding-left: 35px; padding-right: 35px;">Confirm</a>
- </div>
- </div>
- </fieldset>
- </form>
- </div>
- </div>*@
- <div class="body-header clearfix" style="padding-right: 0px;">
- <div class="row" style="display: inline-block">
- <form class="form-horizontal" style="display: inline-block">
- <fieldset style="width: auto">
- <!-- Select Basic -->
- <label class="col-md-1 control-label" for="first-select">Filters: </label>
- <div class="col-md-3">
- <select id="user-company" name="first-select" class="col-sm-12 form-control">
- <option value="0">All Companies</option>
- @foreach (var companies in Model.Companies)
- {
- <option value="@companies.CompanyID">@companies.CompanyName</option>
- }
- </select>
- </div>
- <div class="col-md-3">
- <select id="selectbasic" name="selectbasic" class="form-control">
- <option value="0">Active/Not</option>
- <option value="1">Active</option>
- <option value="2">Not Active</option>
- </select>
- </div>
- <div class="col-md-3">
- <select id="selectbasic" name="selectbasic" class="form-control">
- <option value="0">All Roles</option>
- <option value="1">Client</option>
- <option value="2">Admin</option>
- </select>
- </div>
- <div class="col-md-2">
- <input class="btn btn-vertinity-blue right" type="submit" value="Apply" />
- </div>
- </fieldset>
- </form>
- </div>
- <input type="button" value="New User" class="btn btn-vertinity-blue" onclick="window.location.href='@Url.Action("Products", "Admin")'" style="float: right" />
- @*<a class="submit-button-blue" style="float: right; margin-left: 10px;">Create new</a>*@
- </div>
- <div class="clearfix"></div>
- @*<div class="panel-heading" style="background-color: #2583C3; color: white; border-bottom: none;">
- Users
- </div>*@
- <div class="table-responsive">
- <table class="table table-striped">
- <thead>
- <tr id="head-tr" style="background: black; color: white; border: none; font-weight: 500;">
- <td>Active</td>
- <td>Type</td>
- <td>User name</td>
- <td>Password</td>
- <td>First name</td>
- <td>Last name</td>
- <td>Email</td>
- <td>Phone number</td>
- <td>Company name</td>
- <td>Skype</td>
- </tr>
- </thead>
- <tbody class="searchable">
- @{
- foreach (var user in Model.Users)
- {
- string type = "Client";
- if (user.IsAdmin != null && user.IsAdmin == true)
- {
- type = "Admin";
- }
- string active = "is-active glyphicon glyphicon-remove";
- if (user.Active == true)
- {
- active = "is-active glyphicon glyphicon-ok";
- }
- <tr data-id="@user.ID" style="border: none;">
- <td><a title="Click to activate/deactivate user"><span class="@active"></span></a></td>
- <td>@type</td>
- <td>@user.Username</td>
- <td>@user.Password</td>
- <td>@user.FirstName</td>
- <td>@user.LastName</td>
- <td>@user.Email</td>
- <td>@user.PhoneNumber</td>
- <td>@user.CompanyName</td>
- <td>@user.SkypeID</td>
- </tr>
- }
- }
- </tbody>
- </table>
- </div>
- <script>
- $(document).on("click", ".is-active", function () {
- var that = (this);
- var id = $(this).closest('tr').attr('data-id');
- var active = $(this).hasClass('glyphicon glyphicon-ok');
- $.ajax({
- cache: false,
- type: 'POST',
- url: '@Url.Action("IsActive", "Admin")',
- data: { id: id, active: active },
- success: function (data, textStatus, jqXHR) {
- if (active) {
- $(that).switchClass('glyphicon-ok', 'glyphicon-remove', 1000);
- }else{
- $(that).switchClass('glyphicon-remove', 'glyphicon-ok', 1000);
- }
- },
- error: function (data, textStatus, jqXHR) {
- alert("error");
- }
- });
- });
- //$("tr td:contains('Admin')").each(function () {
- // var text = $(this).text();
- // var parent = $(this).parent();
- // if (text == "Admin") {
- // $(this).parent().css("background", "#f9c87f");
- // }
- //});
- $(document).on("click", "#create-confirm-button", function () {
- var pss = $('#create-password').val();
- var pssConfirm = $('#create-confirm-password').val();
- if (pss != pssConfirm) {
- return false;
- }
- var userDetails = {
- UserName: $('#create-username').val(),
- Password: pss,
- FirstName: $('#create-firstname').val(),
- LastName: $('#create-lastname').val(),
- Email: $('#create-email').val(),
- PhoneNumber: $('#create-phone').val(),
- CompanyID: $('#create-companyID').val(),
- SkypeID: $('#create-skype').val(),
- }
- $.ajax({
- cache: false,
- type: 'POST',
- url: '@Url.Action("CreateUser", "Admin")',
- data: { user: userDetails },
- success: function (data, textStatus, jqXHR) {
- $('tbody').prepend(data);
- },
- error: function (data, textStatus, jqXHR) {
- alert("error");
- }
- });
- });
- </script>
- <style>
- .glyphicon-ok {
- color: green;
- }
- .glyphicon-remove {
- color: red;
- }
- .is-active:hover {
- cursor: pointer;
- }
- .panel {
- border: 1px solid #2583C3;
- color: black;
- }
- tr {
- }
- td {
- border: none;
- }
- .form-group {
- display: inline-block;
- }
- label {
- font-size: 16px;
- font-weight: 500;
- padding-left: 0px;
- margin-left: 0px;
- }
- select {
- color: black;
- }
- table {
- width: 100%;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement