Advertisement
donstany

Untitled

Feb 26th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 17.96 KB | None | 0 0
  1. @using IOWebApplication.Core.Models.Attachments
  2. @using IOWebApplication.Core.Helper.GlobalConstants
  3. @model IOWebApplication.Core.Models.Applications.ApplicationDetailsViewModel
  4. @{
  5.     Layout = "~/Areas/Internal/Views/Shared/_MasterLayout.cshtml";
  6.     ViewData["Title"] = "Заявление";
  7.     var pleaseUploadApplication = "Прикачете 'Сканирано заявление'";
  8.     var scannedApplicationFileClickButtonText = pleaseUploadApplication;
  9.  
  10.     var returnUrl = "";
  11.     if (!string.IsNullOrEmpty(ViewBag.ReturnUrl))
  12.     {
  13.         returnUrl = (string)ViewBag.ReturnUrl;
  14.     }
  15.  
  16. }
  17.     <div class="row">
  18.         @if (Model.HasAttorneyDocument && !string.IsNullOrEmpty(Model.AttorneyDocumentFileContentId))
  19.         {
  20.             <div class="col-lg-4  margin-bottom">
  21.                 <label style="display:block">&nbsp;</label>
  22.                 <span class="form-control" readonly="readonly">№ @Model.Number / @Model.DateSent?.ToString("dd.MM.yyyy г.")</span>
  23.             </div>
  24.             <div class="col-lg-2  margin-bottom">
  25.             </div>
  26.             <div class="col-lg-3">
  27.                 <label style="display:block">&nbsp;</label>
  28.                 <a href="@Url.Action("Download","File", new { area = "Internal" })/@Model.AttorneyDocumentFileContentId" style="width: 100%;" class="btn btn-info btn-flat" title="Изтегли пълномощно"><i class="fa fa-download"></i><span class="hidden-sm hidden-xs"> Изтегли пълномощно</span></a>
  29.             </div>
  30.             <div class="col-lg-3">
  31.                 @Html.EditorFor(x => x.AttorneyDocumentValidityDate, "DateTimeReadonly")
  32.             </div>
  33.         }
  34.         else
  35.         {
  36.             <div class="col-lg-4  margin-bottom">
  37.                 <span class="form-control" readonly="readonly">№ @Model.Number / @Model.DateSent?.ToString("dd.MM.yyyy г.")</span>
  38.             </div>
  39.         }
  40.         @if (Model.IsRejected)
  41.         {
  42.             <div class="col-lg-12  margin-bottom">
  43.                 <span class="form-control" readonly="readonly" style="background-color: #dd4b39; color: #fff;border-color: #d73925;"><span class="text-bold">ОТКАЗАНО</span> (@(Html.Raw(Model.ReasonForReject)))</span>
  44.             </div>
  45.         }
  46.     </div>
  47.  
  48. <div class="box box-primary">
  49.     <div class="box-body">
  50.         <div class="row">
  51.             <div class="col-lg-12">
  52.                 <object data="@Model.PdfPreviewUrl" type="application/pdf" width="100%" style="height:50vh;">
  53.                     <embed src="@Model.PdfPreviewUrl" type="application/pdf" width="100%" style="height:50vh;" />
  54.                 </object>
  55.             </div>
  56.         </div>
  57.         <hr />
  58.         @if (Model.IsDocumentSigned)
  59.         {
  60.             <div class="row">
  61.                 <div class="col-lg-5">
  62.                     @if (string.IsNullOrEmpty(returnUrl))
  63.                     {
  64.                         <a asp-area="Internal" asp-controller="Application" asp-action="Index" class="btn btn-danger btn-flat">Назад</a>
  65.                     }
  66.                     else
  67.                     {
  68.                         <a href="@returnUrl" class="btn btn-danger btn-flat">Назад</a>
  69.                     }
  70.  
  71.                     <a href="@Url.Action("DownloadFileBySourceIdAndSourceType", "File", new { area = "Internal"})?sourceId=@Model.Id&sourceType=@IOWebApplication.Core.Helper.GlobalConstants.FileSourceTypeConstant.PrintedApplication" class="btn btn-primary btn-flat" title="Отпечатай"><i class="fa fa-print"></i><span class="hidden-sm hidden-xs"> Отпечатай</span></a>
  72.                     @if (!Model.IsFromPatient)
  73.                     {
  74.                         <a href="@Url.Action("DownloadFileBySourceIdAndSourceType", "File", new { area = "Internal"})?sourceId=@Model.Id&sourceType=@IOWebApplication.Core.Helper.GlobalConstants.FileSourceTypeConstant.ScannedApplication" class="btn btn-info btn-flat" title="Ръчно подписано копие"><i class="fa fa-download"></i><span class="hidden-sm hidden-xs"> Ръчно подписано копие</span></a>
  75.                     }
  76.                 </div>
  77.                 <div class="col-lg-7 text-right">
  78.                     @if (Model.MedicalDocumentType == DocumentTypesConstant.Direction)
  79.                     {
  80.                         <a target="_blank"
  81.                            asp-area="Internal"
  82.                            asp-controller="Direction"
  83.                            asp-action="DetailsDirection"
  84.                            asp-route-id="@Model.MedicalDocumentId"
  85.                            asp-route-returnUrl="@(Url.Action("DetailsApplication", "Application", new { applicationId = Model.Id}))"
  86.                            class="btn btn-default btn-flat">
  87.                             Медицинско направление
  88.                         </a>
  89.  
  90.                     }
  91.                     else if (Model.MedicalDocumentType == DocumentTypesConstant.MedicalProtocol)
  92.                     {
  93.                         <a target="_blank"
  94.                            asp-area="Internal"
  95.                            asp-controller="MedicalProtocol"
  96.                            asp-action="DetailsMedicalProtocol"
  97.                            asp-route-id="@Model.MedicalDocumentId"
  98.                            asp-route-returnUrl="@(Url.Action("DetailsApplication", "Application", new { applicationId = Model.Id}))"
  99.                            class="btn btn-default btn-flat">
  100.                             Медицински протокол
  101.                         </a>
  102.                     }
  103.                     @if (User.IsInRole(RolesConstant.RhiOfficial) && !Model.IsRejected && Model.CommissionId == null)
  104.                     {
  105.                         <button type="button" id="RejectApplicationButton" onclick="RejectApplicationWarning(); return false;" class="btn btn-danger btn-flat">Откажи заявление</button>
  106.                     }
  107.                     @if (User.IsInRole(RolesConstant.RhiOfficial) && !Model.IsRejected && Model.IsFromPatient && !Model.IsConfirmed)
  108.                     {
  109.                         <button type="button" id="ConfirmApplicationButton" onclick="ConfirmApplicationWarning(); return false;" class="btn btn-success btn-flat">Потвърди заявление</button>
  110.                     }
  111.                 </div>
  112.             </div>
  113.         }
  114.         else
  115.         {
  116.             @if (User.IsInRole(RolesConstant.RhiOfficial))
  117.             {
  118.                 <form id="detailsApplicationForm" asp-area="Internal" asp-controller="Application" asp-action="DetailsApplication" method="post" enctype="multipart/form-data">
  119.                     @Html.HiddenFor(x => x.Id)
  120.                     @Html.HiddenFor(x => x.IsDocumentSigned)
  121.                     @Html.HiddenFor(x => x.MedicalDocumentId)
  122.                     @Html.HiddenFor(x => x.MedicalDocumentType)
  123.                     @Html.HiddenFor(x => x.PdfPreviewUrl)
  124.                     @Html.HiddenFor(x => x.IsFromPatient)
  125.                     @Html.HiddenFor(x => x.IsRejected)
  126.                     @Html.HiddenFor(x => x.IsConfirmed)
  127.                     @Html.HiddenFor(x => x.ReasonForReject)
  128.                     @Html.HiddenFor(x => x.AttorneyDocumentFileContentId)
  129.                     @Html.HiddenFor(x => x.AttorneyDocumentValidityDate)
  130.                     @Html.HiddenFor(x => x.HasAttorneyDocument)
  131.  
  132.                     <div class="row">
  133.                         <div class="col-lg-6">
  134.                             <div class="form-group">
  135.                                 <label asp-for="@Model.ScannedApplicationFile" class="control-label"></label>
  136.                                 <input asp-for="@Model.ScannedApplicationFile" style="display:none" />
  137.                                 <div>
  138.                                     <div class="btn-group" role="group">
  139.                                         <button type="button" id="ScannedApplicationFileClickButton" class="btn btn-info btn-flat" onclick="ScannedApplicationFileClick();"><i class="fa fa-upload"></i></button>
  140.                                         <button type="button" id="ScannedApplicationFileClickButtonText" class="btn btn-flat" onclick="ScannedApplicationFileClick();">@Html.Raw(scannedApplicationFileClickButtonText)</button>
  141.                                     </div>
  142.                                 </div>
  143.                                 <span asp-validation-for="@Model.ScannedApplicationFile" class="text-danger"></span>
  144.                             </div>
  145.  
  146.                         </div>
  147.                     </div>
  148.                 </form>
  149.             }
  150.             <div class="row">
  151.                 <div class="col-md-12">
  152.                     @if (string.IsNullOrEmpty(returnUrl))
  153.                     {
  154.                         <a asp-area="Internal" asp-controller="Application" asp-action="Index" class="btn btn-danger btn-flat">Назад</a>
  155.                     }
  156.                     else
  157.                     {
  158.                         <a href="@returnUrl" class="btn btn-danger btn-flat">Назад</a>
  159.                     }
  160.                     @if (User.IsInRole(RolesConstant.RhiOfficial))
  161.                     {
  162.                         <button id="detailsApplicationFormSubmitButton" type="button" class="btn btn-flat btn-success">Маркирай като подписан</button>
  163.                     }
  164.                     <a href="@Url.Action("DownloadFileBySourceIdAndSourceType", "File", new { area = "Internal"})?sourceId=@Model.Id&sourceType=@IOWebApplication.Core.Helper.GlobalConstants.FileSourceTypeConstant.PrintedApplication" class="btn btn-primary btn-flat" title="Отпечатай"><i class="fa fa-print"></i><span class="hidden-sm hidden-xs"> Отпечатай</span></a>
  165.                 </div>
  166.             </div>
  167.         }
  168.     </div>
  169. </div>
  170.  
  171. @if (Model.Id > 0)
  172. {
  173.     @await Html.PartialAsync("_AttachedDocumentsTablePartial", new AttachedDocumentsTableViewModel
  174.     {
  175.         MedicalDocumentId = Model.MedicalDocumentId,
  176.         MedicalDocumentType = Model.MedicalDocumentType,
  177.         HideDeleteButton = true,
  178.         HideAddNewDocumentButton = true
  179.     })
  180. }
  181.  
  182. @section scripts{
  183.     <script id="rejectApplicationTemplate" type="text/x-handlebars-template">
  184.         <div class="form-group">
  185.             <div class="row">
  186.                 <div class="col-md-12">
  187.                     <label for="reasonForRejection" class="control-label">Мотиви за отказ:</label>
  188.                     <div>
  189.                         <textarea id="reasonForRejection" rows="3" class="form-control"></textarea>
  190.                     </div>
  191.                 </div>
  192.             </div>
  193.             <div class="row">
  194.                 <div class="col-md-12">
  195.                     <span id="reasonForRejectionValidation" class="text-danger" data-valmsg-replace="true"></span>
  196.                 </div>
  197.             </div>
  198.             <div class="row">
  199.                 <div class="col-md-12">
  200.                     <br />
  201.                     <button type="button" onclick="RejectApplication(); return false;" class="btn btn-primary">@Html.Raw("Откажи заявление")</button>
  202.                     <button type="button" class="btn btn-danger dt-reload" data-dismiss="modal">@Html.Raw("Назад")</button>
  203.                 </div>
  204.             </div>
  205.         </div>
  206.     </script>
  207.     <script>
  208.         function ValidateRejectApplication(reasonForRejection) {
  209.             $('#reasonForRejectionValidation').text('');
  210.  
  211.             if (reasonForRejection === '') {
  212.                 $('#reasonForRejectionValidation').text('Полето е задължително.');
  213.                 return false;
  214.             }
  215.  
  216.             return true;
  217.         }
  218.  
  219.         function RejectApplication() {
  220.             var reasonForRejection = $('#reasonForRejection').val().trim();
  221.             var isValid = ValidateRejectApplication(reasonForRejection);
  222.  
  223.             if (isValid) {
  224.                 $.post("@Url.Action("RejectApplication", "Application", new { area = "Internal"})", { applicationId: '@Model.Id', reasonForReject: reasonForRejection })
  225.                     .done(function (result) {
  226.                         HideModalDialog();
  227.                         if (result === 'ok') {
  228.                             swal({
  229.                                 title: '@(Html.Raw(MessageConstant.Values.SaveOK))',
  230.                                 text: 'Настоящото заявление беше отказано успешно!',
  231.                                 icon: "success"
  232.                             });
  233.  
  234.                             setTimeout(function () {
  235.                                 window.location.href = '@Url.Action("DetailsApplication", "Application", new { area = "Internal", applicationId = Model.Id})';
  236.                             }, 2000);
  237.                         }
  238.                         else {
  239.                             HideModalDialog();
  240.                             swal({
  241.                                 title: '@(Html.Raw(MessageConstant.Values.SaveFailed))',
  242.                                 text: 'Настъпи грешка при отказването на настоящото заявление!',
  243.                                 icon: "error",
  244.                                 dangerMode: true
  245.                             });
  246.                         }
  247.                     })
  248.                     .fail(function (error) {
  249.                         HideModalDialog();
  250.                         swal({
  251.                             title: '@(Html.Raw(MessageConstant.Values.SaveFailed))',
  252.                             text: 'Настъпи грешка при отказването на настоящото заявление!',
  253.                             icon: "error",
  254.                             dangerMode: true
  255.                         });
  256.                     })
  257.                     .always();
  258.             }
  259.         }
  260.  
  261.         function RejectApplicationWarning() {
  262.             swal({
  263.                 title: "Сигурни ли сте?",
  264.                 text: "Настоящото Заявление ще бъде ОТКАЗАНО!",
  265.                 icon: "warning",
  266.                 dangerMode: true,
  267.                 buttons: ["Назад", "Да"],
  268.             })
  269.             .then((result) => {
  270.                 if (result) {
  271.                     ShowModalDialog("Отказ на Заявление!", TemplateToHtml('#rejectApplicationTemplate'));
  272.                 }
  273.             });
  274.         }
  275.     </script>
  276.  
  277.     <script>
  278.         function ConfirmApplication() {
  279.             $.post("@Url.Action("ConfirmApplication", "Application", new { area = "Internal"})", { applicationId: '@Model.Id' })
  280.              .done(function (result) {
  281.                  if (result === 'ok') {
  282.                      swal({
  283.                          title: '@(Html.Raw(MessageConstant.Values.SaveOK))',
  284.                          text: 'Настоящото заявление беше потвърдено успешно!',
  285.                          icon: "success"
  286.                      });
  287.                      setTimeout(function () {
  288.                          window.location.href = '@Url.Action("DetailsApplication", "Application", new { area = "Internal", applicationId = Model.Id})';
  289.                      }, 2000);
  290.                  }
  291.                  else {
  292.                      swal({
  293.                          title: '@(Html.Raw(MessageConstant.Values.SaveFailed))',
  294.                          text: 'Настъпи грешка при потвърждаването на настоящото заявление!',
  295.                          icon: "error",
  296.                          dangerMode: true
  297.                      });
  298.                  }
  299.              })
  300.              .fail(function (error) {
  301.                  swal({
  302.                      title: '@(Html.Raw(MessageConstant.Values.SaveFailed))',
  303.                      text: 'Настъпи грешка при потвърждаването на настоящото заявление!',
  304.                      icon: "error",
  305.                      dangerMode: true
  306.                  });
  307.              })
  308.              .always();
  309.         }
  310.  
  311.         function ConfirmApplicationWarning() {
  312.             swal({
  313.                 title: "Сигурни ли сте?",
  314.                 text: "Настоящото Заявление ще бъде ПОТВЪРДЕНО!",
  315.                 icon: "warning",
  316.                 dangerMode: true,
  317.                 buttons: ["Назад", "Да"],
  318.             })
  319.             .then((result) => {
  320.                 if (result) {
  321.                     ConfirmApplication();
  322.                 }
  323.             });
  324.         }
  325.  
  326.         function ScannedApplicationFileClick() {
  327.             $('#ScannedApplicationFile').trigger('click');
  328.         }
  329.  
  330.         function ValidateAndSubmitDetailsApplicationForm() {
  331.             if ($('#ScannedApplicationFileClickButtonText').text() === "@Html.Raw(pleaseUploadApplication)") {
  332.                 swal({
  333.                     title: "Моля прикачете файл!",
  334.                     text: "Към настоящото заявление няма приложено 'Сканирано заявление (Ръчно подписано)'!",
  335.                     icon: "error",
  336.                     dangerMode: true
  337.                 });
  338.             }
  339.             else {
  340.                 $('#detailsApplicationForm').submit();
  341.             }
  342.         }
  343.  
  344.         $(document).on('click', '#detailsApplicationFormSubmitButton', function () {
  345.             ValidateAndSubmitDetailsApplicationForm();
  346.         });
  347.  
  348.         $(document).on('change', '#ScannedApplicationFile', function () {
  349.             if ($('#ScannedApplicationFile').val() !== "") {
  350.                 var fileNameArray = $('#ScannedApplicationFile').val().split(/[\\\/]+/);
  351.                 $('#ScannedApplicationFileClickButtonText').text(fileNameArray[fileNameArray.length - 1]);
  352.             } else {
  353.                 $('#ScannedApplicationFileClickButtonText').text('@pleaseUploadApplication');
  354.             }
  355.         });
  356.     </script>
  357. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement