Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 13.03 KB | None | 0 0
  1. @model HelpDesk.Models.UsersViewParentModel
  2.     @{
  3.         ViewBag.Title = "Users";
  4.     }
  5.     <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  6.     <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  7.     <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  8.  
  9.  
  10.  
  11. @*<div class="panel panel1 panel-default">
  12.         <div class="panel-heading" style="background-color: #2583C3; color: white;">
  13.             <h3 class="panel-title">Create</h3>
  14.         </div>
  15.         <div class="panel-body">
  16.             <form class="form-horizontal">
  17.                 <fieldset>
  18.  
  19.                     <!-- Multiple Radios -->
  20.                     <div class="form-group">
  21.                         <label class="col-md-4 control-label" for="radios">User type:</label>
  22.                         <div class="col-md-8">
  23.                             <div class="radio">
  24.                                 <label for="radios-0">
  25.                                     <input name="radios" id="radios-0" value="1" checked="checked" type="radio">
  26.                                     Client
  27.                                 </label>
  28.                             </div>
  29.                             <div class="radio">
  30.                                 <label for="radios-1">
  31.                                     <input name="radios" id="radios-1" value="2" type="radio">
  32.                                     Admin
  33.                                 </label>
  34.                             </div>
  35.                         </div>
  36.                     </div>
  37.  
  38.                     <!-- Text input-->
  39.                     <div class="form-group">
  40.                         <label class="col-md-4 control-label" for="create-username">Username*:</label>
  41.                         <div class="col-md-8">
  42.                             <input id="create-username" name="create-username" placeholder="Username" class="form-control input-md" required="" type="text">
  43.  
  44.                         </div>
  45.                     </div>
  46.  
  47.                     <!-- Password input-->
  48.                     <div class="form-group">
  49.                         <label class="col-md-4 control-label" for="create-password">Password*:</label>
  50.                         <div class="col-md-8">
  51.                             <input id="create-password" name="create-password" placeholder="Password" class="form-control input-md" required="" type="password">
  52.  
  53.                         </div>
  54.                     </div>
  55.  
  56.                     <!-- Password input-->
  57.                     <div class="form-group">
  58.                         <label class="col-md-4 control-label" for="create-confirm-password">Confirm*:</label>
  59.                         <div class="col-md-8">
  60.                             <input id="create-confirm-password" name="create-confirm-password" placeholder="Password again" class="form-control input-md" required="" type="password">
  61.  
  62.                         </div>
  63.                     </div>
  64.  
  65.                     <!-- Text input-->
  66.                     <div class="form-group">
  67.                         <label class="col-md-4 control-label" for="create-firstname">First name</label>
  68.                         <div class="col-md-8">
  69.                             <input id="create-firstname" name="create-firstname" placeholder="First name" class="form-control input-md" type="text">
  70.  
  71.                         </div>
  72.                     </div>
  73.  
  74.                     <!-- Text input-->
  75.                     <div class="form-group">
  76.                         <label class="col-md-4 control-label" for="create-lastname">Last name</label>
  77.                         <div class="col-md-8">
  78.                             <input id="create-lastname" name="create-lastname" placeholder="Last name" class="form-control input-md" type="text">
  79.  
  80.                         </div>
  81.                     </div>
  82.  
  83.                     <!-- Text input-->
  84.                     <div class="form-group">
  85.                         <label class="col-md-4 control-label" for="create-email">Email</label>
  86.                         <div class="col-md-8">
  87.                             <input id="create-email" name="create-email" placeholder="Email" class="form-control input-md" type="text">
  88.  
  89.                         </div>
  90.                     </div>
  91.  
  92.                     <!-- Text input-->
  93.                     <div class="form-group">
  94.                         <label class="col-md-4 control-label" for="create-phone">Phone</label>
  95.                         <div class="col-md-8">
  96.                             <input id="create-phone" name="create-phone" placeholder="Phone" class="form-control input-md" type="text">
  97.  
  98.                         </div>
  99.                     </div>
  100.  
  101.                     <!-- Text input-->
  102.                     <div class="form-group">
  103.                         <label class="col-md-4 control-label" for="create-skype">SkypeID</label>
  104.                         <div class="col-md-8">
  105.                             <input id="create-skype" name="create-skype" placeholder="SkypeID" class="form-control input-md" type="text">
  106.  
  107.                         </div>
  108.                     </div>
  109.  
  110.                     <!-- Select Basic -->
  111.                     <div class="form-group">
  112.                         <label class="col-md-4 control-label" for="create-companyID">Company</label>
  113.                         <div class="col-md-8">
  114.                             <select id="create-companyID" name="create-companyID" class="form-control">
  115.                                 @foreach (var company in Model.Companies)
  116.                                 {
  117.                                     <option value="@company.CompanyID">@company.CompanyName</option>
  118.                                 }
  119.                             </select>
  120.                         </div>
  121.                     </div>
  122.  
  123.                     <!-- Button -->
  124.                     <div class="form-group">
  125.                         <label class="col-md-4 control-label" for="create-confirm-button"></label>
  126.                         <div class="col-md-8">
  127.                             <a id="create-confirm-button" name="create-confirm-button" class="submit-button-blue" style="padding-left: 35px; padding-right: 35px;">Confirm</a>
  128.                         </div>
  129.                     </div>
  130.  
  131.  
  132.                 </fieldset>
  133.             </form>
  134.         </div>
  135.     </div>*@
  136. <div class="body-header clearfix" style="padding-right: 0px;">
  137.     <div class="row" style="display: inline-block">
  138.         <form class="form-horizontal" style="display: inline-block">
  139.             <fieldset style="width: auto">
  140.                 <!-- Select Basic -->
  141.                 <label class="col-md-1 control-label" for="first-select">Filters: </label>
  142.                 <div class="col-md-3">
  143.                     <select id="user-company" name="first-select" class="col-sm-12 form-control">
  144.                         <option value="0">All Companies</option>
  145.                         @foreach (var companies in Model.Companies)
  146.                         {
  147.                             <option value="@companies.CompanyID">@companies.CompanyName</option>
  148.                         }
  149.                     </select>
  150.                 </div>
  151.  
  152.  
  153.  
  154.                 <div class="col-md-3">
  155.                     <select id="selectbasic" name="selectbasic" class="form-control">
  156.                         <option value="0">Active/Not</option>
  157.                         <option value="1">Active</option>
  158.                         <option value="2">Not Active</option>
  159.                     </select>
  160.                 </div>
  161.  
  162.                 <div class="col-md-3">
  163.                     <select id="selectbasic" name="selectbasic" class="form-control">
  164.                         <option value="0">All Roles</option>
  165.                         <option value="1">Client</option>
  166.                         <option value="2">Admin</option>
  167.                     </select>
  168.                 </div>
  169.                 <div class="col-md-2">
  170.                     <input class="btn btn-vertinity-blue right" type="submit" value="Apply" />
  171.                 </div>
  172.             </fieldset>
  173.         </form>
  174.     </div>
  175.     <input type="button" value="New User" class="btn btn-vertinity-blue" onclick="window.location.href='@Url.Action("Products", "Admin")'" style="float: right" />
  176.     @*<a class="submit-button-blue" style="float: right; margin-left: 10px;">Create new</a>*@
  177. </div>
  178. <div class="clearfix"></div>
  179. @*<div class="panel-heading" style="background-color: #2583C3; color: white; border-bottom: none;">
  180.             Users
  181.         </div>*@
  182. <div class="table-responsive">
  183.     <table class="table table-striped">
  184.         <thead>
  185.             <tr id="head-tr" style="background: black; color: white; border: none; font-weight: 500;">
  186.                 <td>Active</td>
  187.                 <td>Type</td>
  188.                 <td>User name</td>
  189.                 <td>Password</td>
  190.                 <td>First name</td>
  191.                 <td>Last name</td>
  192.                 <td>Email</td>
  193.                 <td>Phone number</td>
  194.                 <td>Company name</td>
  195.                 <td>Skype</td>
  196.             </tr>
  197.         </thead>
  198.         <tbody class="searchable">
  199.             @{
  200.                 foreach (var user in Model.Users)
  201.                 {
  202.                     string type = "Client";
  203.                     if (user.IsAdmin != null && user.IsAdmin == true)
  204.                     {
  205.                         type = "Admin";
  206.                     }
  207.                     string active = "is-active glyphicon glyphicon-remove";
  208.                     if (user.Active == true)
  209.                     {
  210.                         active = "is-active glyphicon glyphicon-ok";
  211.                     }
  212.                     <tr data-id="@user.ID" style="border: none;">
  213.                         <td><a title="Click to activate/deactivate user"><span class="@active"></span></a></td>
  214.                         <td>@type</td>
  215.                         <td>@user.Username</td>
  216.                         <td>@user.Password</td>
  217.                         <td>@user.FirstName</td>
  218.                         <td>@user.LastName</td>
  219.                         <td>@user.Email</td>
  220.                         <td>@user.PhoneNumber</td>
  221.                         <td>@user.CompanyName</td>
  222.                         <td>@user.SkypeID</td>
  223.                     </tr>
  224.                 }
  225.             }
  226.         </tbody>
  227.     </table>
  228. </div>
  229.  
  230. <script>
  231.     $(document).on("click", ".is-active", function () {
  232.         var that = (this);
  233.         var id = $(this).closest('tr').attr('data-id');
  234.         var active = $(this).hasClass('glyphicon glyphicon-ok');
  235.         $.ajax({
  236.             cache: false,
  237.             type: 'POST',
  238.             url: '@Url.Action("IsActive", "Admin")',
  239.             data: { id: id, active: active },
  240.             success: function (data, textStatus, jqXHR) {
  241.                 if (active) {
  242.                     $(that).switchClass('glyphicon-ok', 'glyphicon-remove', 1000);
  243.                 }else{
  244.                     $(that).switchClass('glyphicon-remove', 'glyphicon-ok', 1000);
  245.                 }
  246.             },
  247.             error: function (data, textStatus, jqXHR) {
  248.                 alert("error");
  249.             }
  250.         });
  251.     });
  252.  
  253.     //$("tr td:contains('Admin')").each(function () {
  254.     //    var text = $(this).text();
  255.     //    var parent = $(this).parent();
  256.     //    if (text == "Admin") {
  257.     //        $(this).parent().css("background", "#f9c87f");
  258.     //    }
  259.     //});
  260.  
  261.     $(document).on("click", "#create-confirm-button", function () {
  262.         var pss = $('#create-password').val();
  263.         var pssConfirm = $('#create-confirm-password').val();
  264.         if (pss != pssConfirm) {
  265.             return false;
  266.         }
  267.         var userDetails = {
  268.             UserName: $('#create-username').val(),
  269.             Password: pss,
  270.             FirstName: $('#create-firstname').val(),
  271.             LastName: $('#create-lastname').val(),
  272.             Email: $('#create-email').val(),
  273.             PhoneNumber: $('#create-phone').val(),
  274.             CompanyID: $('#create-companyID').val(),
  275.             SkypeID: $('#create-skype').val(),
  276.         }
  277.         $.ajax({
  278.             cache: false,
  279.             type: 'POST',
  280.             url: '@Url.Action("CreateUser", "Admin")',
  281.             data: { user: userDetails },
  282.             success: function (data, textStatus, jqXHR) {
  283.                 $('tbody').prepend(data);
  284.             },
  285.             error: function (data, textStatus, jqXHR) {
  286.                 alert("error");
  287.             }
  288.         });
  289.     });
  290. </script>
  291.  
  292. <style>
  293.     .glyphicon-ok {
  294.         color: green;
  295.     }
  296.     .glyphicon-remove {
  297.         color: red;  
  298.     }
  299.    .is-active:hover {
  300.         cursor: pointer;
  301.     }
  302.  
  303.     .panel {
  304.         border: 1px solid #2583C3;
  305.         color: black;
  306.     }
  307.     tr {
  308.     }
  309.     td {
  310.         border: none;
  311.     }
  312.     .form-group {
  313.         display: inline-block;
  314.     }
  315.     label {
  316.         font-size: 16px;
  317.         font-weight: 500;
  318.         padding-left: 0px;
  319.         margin-left: 0px;
  320.     }
  321.     select {
  322.         color: black;
  323.     }
  324.     table {
  325.         width: 100%;
  326.     }
  327. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement