Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- ViewBag.Title = "Quản lý của hàng";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- <div class="page-content">
- <div class="page-header">
- @*<h1>@Resources.Resources.Admin_Bill_Title Phòng</h1>
- *@
- <h1>
- Quản lý cửa hàng
- </h1>
- </div>
- <div class="form-inline">
- <div class="col-xs-3" style="width: 17%;">
- <div class="input-group input-group-sm">
- <input type="text" id="dpFrom" class="form-control" data-date-format="dd/mm/yyyy" placeholder="Từ" />
- <span class="input-group-addon" onclick="focusOnDpFrom()">
- <i class="icon-calendar"></i>
- </span>
- </div>
- </div>
- <div class="col-xs-3" style="width: 17%;">
- <div class="input-group input-group-sm">
- <input type="text" id="dpTo" class="form-control" data-date-format="dd/mm/yyyy" placeholder="Đến" />
- <span class="input-group-addon" onclick="focusOnDpTo()">
- <i class="icon-calendar"></i>
- </span>
- </div>
- </div>
- <div class="col-xs-1">
- <input type="button" class="btn btn-sm active" value="Lọc" onclick="RefreshTable()" />
- </div>
- <div class="col-sm-5">
- <a id="btnCreate" href="#" role="button" class="btn btn-success btn-sm pull-right">
- <strong>Tạo mới</strong>
- </a>
- </div>
- <div class="">
- <table id="storeDatatable" class="table table-striped table-bordered table-hover" style="width: 100% !important">
- <thead>
- <tr>
- <th>
- <label class="">STT</label>
- </th>
- <th>
- <label class="">ID</label>
- </th>
- <th>
- <label class="">Tên cửa hàng</label>
- </th>
- <th>
- <label class="">Địa chỉ</label>
- </th>
- <th>
- <label class="">ID quản lí</label>
- </th>
- <th></th>
- </tr>
- </thead>
- <tbody></tbody>
- </table>
- </div>
- </div>
- </div>
- <div id="create-store-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
- aria-hidden="true">
- <div class="modal-form col-lg-offset-1 col-lg-10 col-md-12 col-sm-12 col-xs-12">
- <div class="widget-box">
- <div class="widget-header">
- Khởi tạo cửa hàng
- </div>
- <div class="widget-body" id="create-store-modal-body">
- </div>
- </div>
- </div>
- </div>
- <!--Modal-->
- <div id="createModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-form">
- <div class="widget-box col-lg-6 col-lg-offset-3" style="opacity: 1; z-index: 0;">
- <div class="widget-header">
- <h5 class="bigger-120" id="modalHeader">Thêm Đối Tác</h5>
- <div class="widget-toolbar">
- <a id="btnModalClose" href="#">
- <i class="icon-remove"></i>
- </a>
- </div>
- </div>
- <div class="widget-body margin-20">
- <div class="widget-main">
- @*<div class="col-sm-12">*@
- <div class="widget-box transparent">
- <div id="content">
- <div class="row">
- <div class="col-xs-12">
- <form id="CreateEditForm">
- <input type="hidden" name="FormMode" value="Create" />
- <input type="hidden" name="Id" value="" />
- <div class="form-horizontal">
- <div id="FormError" class="alert alert-danger" style="display: none; padding: 10px; margin-left: 10px"></div>
- <div id="FormSuccess" class="alert alert-success" style="display: none; padding: 10px; margin-left: 10px"></div>
- <div class="form-group">
- @Html.Label("Tên cửa hàng", htmlAttributes: new { @class = "control-label col-md-4" })
- <div class="col-md-5">
- @Html.TextBox("Name", "", new { @class = "col-sm-12" })
- @Html.ValidationMessage("Name", htmlAttributes: new { @class = "error-message", style = "color: red;" })
- </div>
- </div>
- <div class="form-group">
- @Html.Label("Địa chỉ", htmlAttributes: new { @class = "control-label col-md-4" })
- <div class="col-md-5">
- @Html.TextArea("Address", "", new { @class = "col-sm-12" })
- @Html.ValidationMessage("Address", htmlAttributes: new { @class = "error-message", style = "color: red;" })
- </div>
- </div>
- <div class="form-group">
- @Html.Label("Mã quản lí", htmlAttributes: new { @class = "control-label col-md-4" })
- <div class="col-md-5">
- @Html.TextBox("ManagerID", "", new { @class = "col-sm-12" })
- @Html.ValidationMessage("ManagerID", htmlAttributes: new { @class = "error-message", style = "color: red;" })
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-offset-4 col-md-8">
- <input type="button" id="btnSubmit" value="Create" class="btn btn-default" />
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- @* </div>*@
- </div>
- <div class="clearfix"></div>
- </div>
- @*<div class="modal-footer"></div>*@
- </div>
- </div>
- </div>
- <script>
- $("#btnModalClose").click(function () {
- $("#createModal").modal("hide");
- if (modalModified) location.reload();
- });
- // Button submit on modal form
- $("#btnSubmit").click(function () {
- // clear error
- $(".error-message").html("");
- $("#FormError").hide();
- $("#FormError").html("");
- $("#FormSuccess").hide();
- $("#FormSuccess").html("");
- var hasError = false;
- // validating
- if ($("input[name='Name']").val() == "") {
- $("span[data-valmsg-for='Name']").html("Tên đối tác không được bỏ trống");
- hasError = true;
- }
- if ($("textarea[name='Address']").val() == "") {
- $("span[data-valmsg-for='Address']").html("Địa chỉ đối tác không được bỏ trống");
- hasError = true;
- }
- // submit
- if (!hasError) {
- $("form#CreateEditForm").submit();
- }
- });
- // Edit a partner
- function EditStore(id) {
- $.ajax({
- url: '@Url.Action("GetStoreJSon")',
- type: 'POST',
- data: 'id=' + id,
- success: function (data) {
- if (data.success) {
- // clear error
- $(".error-message").html("");
- $("#FormError").hide();
- $("#FormError").html("");
- $("#FormSuccess").hide();
- $("#FormSuccess").html("");
- $("form#CreateEditForm")[0].reset();
- $("#modalHeader").html("Sửa thông tin đối tác");
- $("#createModal").modal("show");
- $("input[name='FormMode']").val("Edit");
- $("input[name='ID']").val(data.info.CustomerID);
- $("input[name='Name']").val(data.info.Name);
- $("textarea[name='Address']").html(data.info.Address);
- $("input[name='ManagerID']").val(data.info.ManagerID);
- $("#btnSubmit").val("Save");
- modalModified = false;
- } else {
- ShowMessage("Không thể lấy dữ liệu của đối tác này. Xin vui lòng thử lại sau!", 1);
- }
- },
- error: function (e) {
- ShowMessage("Không thể lấy dữ liệu của đối tác này. Xin vui lòng thử lại sau!", 1);
- }
- });
- modalModified = false;
- }
- // Delete a partner
- function DeleteStore(id, name) {
- bootbox.dialog({
- title: 'Xác nhận',
- message: "<h5>Bạn có muốn xóa cửa hàng '" + name + "'?</h5>",
- buttons:
- {
- "ok":
- {
- "label": "<i class='icon-ok'></i> Đồng ý",
- "className": "btn-sm btn-success",
- "callback": function () {
- $.ajax({
- url: '@Url.Action("DeleteStore")',
- type: 'POST',
- data: 'id=' + id,
- error: function () {
- ShowMessage("Không thể xóa đối tác này. Xin vui lòng thử lại sau!", 1);
- },
- success: function (data) {
- if (data.success) {
- location.reload();
- } else {
- ShowMessage("Không thể xóa đối tác này. Xin vui lòng thử lại sau!", 1);
- }
- }
- });
- }
- },
- "close":
- {
- "label": "<i class='icon-remove'></i> Đóng",
- "className": "btn-sm btn-danger",
- "callback": function () {
- bootbox.hideAll();
- }
- }
- }
- });
- }
- // Initial submit form
- $("form#CreateEditForm").submit(function () {
- var formData = new FormData($(this)[0]);
- $.ajax({
- url: '@Url.Action("CreateNew")',
- type: 'POST',
- data: formData,
- async: false,
- success: function (data) {
- if (data.success) {
- if (data.type == "create") {
- $("#FormSuccess").html(data.msg);
- $("#FormSuccess").show();
- $("form#CreateEditForm")[0].reset();
- } else if (data.type == "edit") {
- $("#FormSuccess").html(data.msg);
- $("#FormSuccess").show();
- }
- modalModified = true;
- } else {
- $("#FormError").html(data.msg);
- $("#FormError").show();
- }
- },
- cache: false,
- contentType: false,
- processData: false
- });
- return false;
- });
- $("#btnCreate").click(function () {
- // clear error
- $(".error-message").html("");
- $("#FormError").hide();
- $("#FormError").html("");
- $("#FormSuccess").hide();
- $("#FormSuccess").html("");
- $("form#CreateEditForm")[0].reset();
- $("#modalHeader").html("Tạo mới");
- $("#createModal").modal("show");
- $("input[name='FormMode']").val("Create");
- $("#btnSubmit").val("Create");
- modalModified = false;
- });
- function GetCreateForm() {
- $.ajax({
- url: "/StoreManager/Store/Create",
- context: document.body
- }).done(function (result) {
- $('#create-store-modal-body').html(result);
- });
- }
- function focusOnDpFrom() {
- $("#dpFrom").focus();
- }
- function focusOnDpTo() {
- $("#dpTo").focus();
- }
- $(document).ready(function () {
- $("#dpFrom").datetimepicker({
- showOtherMonths: true,
- selectOtherMonths: false,
- changeMonth: true,
- changeYear: true,
- dateFormat: 'dd-mm-yy',
- showButtonPanel: true,
- beforeShow: function () {
- //change button colors
- var datepicker = $(this).datepicker("widget");
- setTimeout(function () {
- var buttons = datepicker.find('.ui-datepicker-buttonpane')
- .find('button');
- buttons.eq(0).addClass('btn btn-xs');
- buttons.eq(1).addClass('btn btn-xs btn-success');
- buttons.wrapInner('<span class="bigger-110" />');
- }, 0);
- },
- onClose: function (selectedDate) {
- if (selectedDate != "") {
- var newDate = selectedDate.match(/\d\d\d\d/).toString()
- + "/"
- + selectedDate.match(/-\d\d/).toString().substr(1, 3)
- + "/"
- + selectedDate.match(/\d\d/).toString()
- + selectedDate.match(/ \d\d:\d\d/).toString();
- $("#dpTo").datetimepicker("option", "minDate", selectedDate);
- $("#dpTo").datetimepicker("option", "minDateTime", new Date(newDate));
- }
- }
- });
- $("#dpTo").datetimepicker({
- showOtherMonths: true,
- selectOtherMonths: false,
- changeMonth: true,
- changeYear: true,
- dateFormat: 'dd-mm-yy',
- showButtonPanel: true,
- beforeShow: function () {
- //change button colors
- var datepicker = $(this).datepicker("widget");
- setTimeout(function () {
- var buttons = datepicker.find('.ui-datepicker-buttonpane')
- .find('button');
- buttons.eq(0).addClass('btn btn-xs');
- buttons.eq(1).addClass('btn btn-xs btn-success');
- buttons.wrapInner('<span class="bigger-110" />');
- }, 0);
- }
- });
- });
- InitDatatable();
- function RefreshTable() {
- var oTable = $("#storeDatatable").dataTable();
- oTable._fnPageChange(0);
- oTable._fnAjaxUpdate();
- }
- function InitDatatable() {
- $("#storeDatatable").dataTable({
- "bFilter": false,
- "bRetrieve": true,
- "bServerSide": true,
- "bScrollCollapse": true,
- "sAjaxSource": "/StoreManager/Store/LoadStoreByStatusDatatables",
- "bProcessing": true,
- "oLanguage": {
- "sSearch": "Tên cửa hàng:",
- "sZeroRecords": "Không có dữ liệu phù hợp",
- "sInfo": "Hiển thị từ _START_ đến _END_ trên tổng số _TOTAL_ dòng",
- "sEmptyTable": "Không có dữ liệu",
- "sInfoFiltered": " - lọc ra từ _MAX_ dòng",
- "sLengthMenu": "Hiển thị _MENU_ dòng",
- "sProcessing": "Đang xử lý..."
- },
- "aoColumnDefs": [
- { "aTargets": [0, 1, 3] },
- {
- "aTargets": [2, 4,5],
- "bSortable": false,
- }
- ],
- "bAutoWidth": false,
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement