#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.34014
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Disco.Web.Areas.Config.Views.DocumentTemplate
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Web;
    using System.Web.Helpers;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using System.Web.Mvc.Html;
    using System.Web.Routing;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.WebPages;
    using Disco;
    using Disco.BI.Extensions;
    using Disco.Models.Repository;
    using Disco.Services;
    using Disco.Services.Authorization;
    using Disco.Services.Web;
    using Disco.Web;
    using Disco.Web.Extensions;
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
    [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DocumentTemplate/Show.cshtml")]
    public partial class Show : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DocumentTemplate.ShowModel>
    {
        public Show()
        {
        }
        public override void Execute()
        {
            
            #line 2 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
  
    Authorization.Require(Claims.Config.DocumentTemplate.Show);

    var canConfig = Authorization.Has(Claims.Config.DocumentTemplate.Configure);

    #region Can Bulk Generate
    var canBulkGenerate = Authorization.Has(Claims.Config.DocumentTemplate.BulkGenerate);
    if (canBulkGenerate)
    {
        switch (Model.DocumentTemplate.Scope)
        {
            case DocumentTemplate.DocumentTemplateScopes.Device:
                canBulkGenerate = Authorization.Has(Claims.Device.Actions.GenerateDocuments);
                break;
            case DocumentTemplate.DocumentTemplateScopes.Job:
                canBulkGenerate = Authorization.Has(Claims.Job.Actions.GenerateDocuments);
                break;
            case DocumentTemplate.DocumentTemplateScopes.User:
                canBulkGenerate = Authorization.Has(Claims.User.Actions.GenerateDocuments);
                break;
            default:
                throw new InvalidOperationException("Invalid DocumentType Scope");
        }
    }
    #endregion

    ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(null), Model.DocumentTemplate.Description);

            
            #line default
            #line hidden
WriteLiteral("\r\n<div");

WriteLiteral(" class=\"form\"");

WriteLiteral(" style=\"width: 650px\"");

WriteLiteral(">\r\n    <table>\r\n        <tr>\r\n            <th>Id:\r\n            </th>\r\n           " +
" <td>");

            
            #line 35 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.DisplayFor(model => model.DocumentTemplate.Id));

            
            #line default
            #line hidden
WriteLiteral("\r\n            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Stored Instance" +
"s:\r\n            </th>\r\n            <td>");

            
            #line 41 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.DisplayFor(model => model.StoredInstanceCount));

            
            #line default
            #line hidden
WriteLiteral("\r\n            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Description:\r\n " +
"           </th>\r\n            <td>");

            
            #line 47 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig)
                {
                
            
            #line default
            #line hidden
            
            #line 49 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.TextBoxFor(model => model.DocumentTemplate.Description));

            
            #line default
            #line hidden
            
            #line 49 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                             
                
            
            #line default
            #line hidden
            
            #line 50 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxSave());

            
            #line default
            #line hidden
            
            #line 50 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                       
                
            
            #line default
            #line hidden
            
            #line 51 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxLoader());

            
            #line default
            #line hidden
            
            #line 51 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         

            
            #line default
            #line hidden
WriteLiteral("                <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
                    $(function () {
                        var $Description = $('#DocumentTemplate_Description');
                        var $DescriptionAjaxSave = $Description.next('.ajaxSave');
                        $Description
                                .watermark('Description')
                                .focus(function () { $Description.select() })
                                .keydown(function (e) {
                                    $DescriptionAjaxSave.show();
                                    if (e.which == 13) {
                                        $(this).blur();
                                    }
                                }).blur(function () {
                                    $DescriptionAjaxSave.hide();
                                })
                                .change(function () {
                                    $DescriptionAjaxSave.hide();
                                    var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
                                    var data = { Description: $Description.val() };
                                    $.ajax({
                                        url: '");

            
            #line 72 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         Write(Url.Action(MVC.API.DocumentTemplate.UpdateDescription(Model.DocumentTemplate.Id)));

            
            #line default
            #line hidden
WriteLiteral(@"',
                                        dataType: 'json',
                                        data: data,
                                        success: function (d) {
                                            if (d == 'OK') {
                                                $ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
                                            } else {
                                                $ajaxLoading.hide();
                                                alert('Unable to update description: ' + d);
                                            }
                                        },
                                        error: function (jqXHR, textStatus, errorThrown) {
                                            alert('Unable to update description: ' + textStatus);
                                            $ajaxLoading.hide();
                                        }
                                    });
                                });
                    });
                </script>
");

            
            #line 91 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }
                else
                {
                    if (string.IsNullOrEmpty(Model.DocumentTemplate.Description))
                    {

            
            #line default
            #line hidden
WriteLiteral("                <span");

WriteLiteral(" class=\"smallMessage\"");

WriteLiteral(">&lt;None Specified&gt;</span>\r\n");

            
            #line 97 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                    }
                    else
                    {
                
            
            #line default
            #line hidden
            
            #line 100 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Model.DocumentTemplate.Description);

            
            #line default
            #line hidden
            
            #line 100 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                   
                    }
                }

            
            #line default
            #line hidden
WriteLiteral("            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Always Flatten Fo" +
"rm:\r\n            </th>\r\n            <td>");

            
            #line 108 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig)
                {

            
            #line default
            #line hidden
WriteLiteral("                <input");

WriteLiteral(" id=\"DocumentTemplate_FlattenForm\"");

WriteLiteral(" type=\"checkbox\"");

WriteLiteral(" ");

            
            #line 110 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                     Write(Model.DocumentTemplate.FlattenForm ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty));

            
            #line default
            #line hidden
WriteLiteral("/>\r\n");

            
            #line 111 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                
            
            #line default
            #line hidden
            
            #line 111 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxLoader());

            
            #line default
            #line hidden
            
            #line 111 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         

            
            #line default
            #line hidden
WriteLiteral("                <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
                    $(function () {
                        $('#DocumentTemplate_FlattenForm').click(function () {
                            var $this = $(this);
                            var $ajaxLoading = $this.next('.ajaxLoading').show();
                            var data = { FlattenForm: $this.is(':checked') };
                            $.getJSON('");

            
            #line 118 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                   Write(Url.Action(MVC.API.DocumentTemplate.UpdateFlattenForm(Model.DocumentTemplate.Id)));

            
            #line default
            #line hidden
WriteLiteral(@"', data, function (response, result) {
                                if (result != 'success' || response != 'OK') {
                                    alert('Unable to change Flatten Form:\n' + response);
                                    $ajaxLoading.hide();
                                } else {
                                    $ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
                                }
                            });
                        });
                    });
                </script>
");

            
            #line 129 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }
                else
                {

            
            #line default
            #line hidden
WriteLiteral("                <input");

WriteLiteral(" id=\"DocumentTemplate_FlattenForm\"");

WriteLiteral(" type=\"checkbox\"");

WriteLiteral(" ");

            
            #line 132 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                     Write(Model.DocumentTemplate.FlattenForm ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty));

            
            #line default
            #line hidden
WriteLiteral(" disabled=\"disabled\" />\r\n");

            
            #line 133 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }

            
            #line default
            #line hidden
WriteLiteral("            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Scope:\r\n         " +
"   </th>\r\n            <td>");

            
            #line 139 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig)
                {
                
            
            #line default
            #line hidden
            
            #line 141 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.DropDownListFor(model => model.DocumentTemplate.Scope, Model.Scopes.ToSelectListItems(null)));

            
            #line default
            #line hidden
            
            #line 141 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                                  
                
            
            #line default
            #line hidden
            
            #line 142 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxLoader());

            
            #line default
            #line hidden
            
            #line 142 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         

            
            #line default
            #line hidden
WriteLiteral("                <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
                    $(function () {
                        var $scope = $('#DocumentTemplate_Scope');
                        $scope.change(function () {
                            var $ajaxLoading = $scope.next('.ajaxLoading').show();
                            var data = { Scope: $scope.val() };
                            $.ajax({
                                url: '");

            
            #line 150 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                 Write(Url.Action(MVC.API.DocumentTemplate.UpdateScope(Model.DocumentTemplate.Id)));

            
            #line default
            #line hidden
WriteLiteral(@"',
                                dataType: 'json',
                                data: data,
                                success: function (d) {
                                    if (d == 'OK') {
                                        $ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
                                        scopeChange();
                                    } else {
                                        $ajaxLoading.hide();
                                        alert('Unable to update scope: ' + d);
                                    }
                                },
                                error: function (jqXHR, textStatus, errorThrown) {
                                    alert('Unable to update scope: ' + textStatus);
                                    $ajaxLoading.hide();
                                }
                            });
                        });

                        var $JobSubTypes = $('#Config_DocumentTemplates_JobSubTypes');

                        function scopeChange() {
                            if ($scope.val() == 'Job') {
                                $JobSubTypes.slideDown('fast');
                            } else {
                                $JobSubTypes.slideUp('fast');
                            }
                        }
                    });
                </script>
");

            
            #line 180 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }
                else
                {

            
            #line default
            #line hidden
WriteLiteral("                <div>");

            
            #line 183 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                Write(Model.DocumentTemplate.Scope);

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

            
            #line 184 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }

            
            #line default
            #line hidden
WriteLiteral("                ");

            
            #line 185 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig || (Model.DocumentTemplate.Scope == DocumentTemplate.DocumentTemplateScopes.Job))
                {

            
            #line default
            #line hidden
WriteLiteral("                    <div");

WriteLiteral(" id=\"Config_DocumentTemplates_JobSubTypes\"");

WriteLiteral(" ");

            
            #line 187 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                               Write(Model.DocumentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.Job ? "style=\"display: none;\" " : null);

            
            #line default
            #line hidden
WriteLiteral(">\r\n                        <h4>Filter:</h4>\r\n                        <div>\r\n");

            
            #line 190 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                            
            
            #line default
            #line hidden
            
            #line 190 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                             if (Model.DocumentTemplate.JobSubTypes.Count > 0)
                            {

            
            #line default
            #line hidden
WriteLiteral("                                <ul>\r\n");

            
            #line 193 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                    
            
            #line default
            #line hidden
            
            #line 193 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                     foreach (var jobType in Model.DocumentTemplate.JobSubTypes.GroupBy(jst => jst.JobType).OrderBy(jtg => jtg.Key.Description))
                                    {

            
            #line default
            #line hidden
WriteLiteral("                                        <li>\r\n");

WriteLiteral("                                            ");

            
            #line 196 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                       Write(jobType.Key.Description);

            
            #line default
            #line hidden
WriteLiteral("\r\n                                            <ul>\r\n");

            
            #line 198 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                
            
            #line default
            #line hidden
            
            #line 198 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                 if (jobType.Count() == Model.JobTypes.FirstOrDefault(jt => jt.Id == jobType.Key.Id).JobSubTypes.Count)
                                                {

            
            #line default
            #line hidden
WriteLiteral("                                                    <li><span");

WriteLiteral(" class=\"smallMessage\"");

WriteLiteral(">[All Sub Types]</span></li>\r\n");

            
            #line 201 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                }
                                                else
                                                {
                                                    foreach (var jobSubType in jobType)
                                                    {

            
            #line default
            #line hidden
WriteLiteral("                                                    <li>");

            
            #line 206 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                   Write(jobSubType.Description);

            
            #line default
            #line hidden
WriteLiteral("</li>\r\n");

            
            #line 207 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                    }
                                                }

            
            #line default
            #line hidden
WriteLiteral("                                            </ul>\r\n                              " +
"          </li>\r\n");

            
            #line 211 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                    }

            
            #line default
            #line hidden
WriteLiteral("                                </ul>\r\n");

            
            #line 213 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                            }
                            else
                            {

            
            #line default
            #line hidden
WriteLiteral("                                <span");

WriteLiteral(" class=\"smallMessage\"");

WriteLiteral(">&lt;No Filter&gt;</span>\r\n");

            
            #line 217 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                            }

            
            #line default
            #line hidden
WriteLiteral("                        </div>\r\n");

            
            #line 219 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                        
            
            #line default
            #line hidden
            
            #line 219 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                         if (canConfig)
                        {

            
            #line default
            #line hidden
WriteLiteral("                            <a");

WriteLiteral(" id=\"Config_DocumentTemplates_JobSubTypes_Update\"");

WriteLiteral(" href=\"#\"");

WriteLiteral(" class=\"button small\"");

WriteLiteral(">Update</a>\r\n");

WriteLiteral("                            <div");

WriteLiteral(" id=\"Config_DocumentTemplates_JobSubTypes_Update_Dialog\"");

WriteLiteral(" class=\"dialog\"");

WriteLiteral(" title=\"Job Type Filter\"");

WriteLiteral(">\r\n");

            
            #line 223 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                
            
            #line default
            #line hidden
            
            #line 223 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                 using (Html.BeginForm(MVC.API.DocumentTemplate.UpdateJobSubTypes(Model.DocumentTemplate.Id, null, true)))
                                {
                                    var selectedTypes = Model.DocumentTemplate.JobSubTypes.Select(jst => jst.JobType).Distinct().ToList();
                                    foreach (var jt in Model.JobTypes)
                                    {

            
            #line default
            #line hidden
WriteLiteral("                                    <div");

WriteLiteral(" class=\"jobTypes\"");

WriteLiteral(">\r\n                                        <h4>\r\n                                " +
"            <input");

WriteAttribute("id", Tuple.Create(" id=\"", 12011), Tuple.Create("\"", 12030)
, Tuple.Create(Tuple.Create("", 12016), Tuple.Create("Types_", 12016), true)
            
            #line 230 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
, Tuple.Create(Tuple.Create("", 12022), Tuple.Create<System.Object, System.Int32>(jt.Id
            
            #line default
            #line hidden
, 12022), false)
);

WriteLiteral(" class=\"jobType\"");

WriteLiteral(" type=\"checkbox\"");

WriteAttribute("value", Tuple.Create(" value=\"", 12063), Tuple.Create("\"", 12079)
            
            #line 230 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                              , Tuple.Create(Tuple.Create("", 12071), Tuple.Create<System.Object, System.Int32>(jt.Id
            
            #line default
            #line hidden
, 12071), false)
);

WriteLiteral(" ");

            
            #line 230 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                                    Write(selectedTypes.Contains(jt) ? "checked=\"checked\"" : null);

            
            #line default
            #line hidden
WriteLiteral(" /><label");

WriteAttribute("for", Tuple.Create(" for=\"", 12150), Tuple.Create("\"", 12170)
, Tuple.Create(Tuple.Create("", 12156), Tuple.Create("Types_", 12156), true)
            
            #line 230 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                                         , Tuple.Create(Tuple.Create("", 12162), Tuple.Create<System.Object, System.Int32>(jt.Id
            
            #line default
            #line hidden
, 12162), false)
);

WriteLiteral(">");

            
            #line 230 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                                                                                                                              Write(jt.Description);

            
            #line default
            #line hidden
WriteLiteral("</label></h4>\r\n                                        <div");

WriteAttribute("id", Tuple.Create(" id=\"", 12246), Tuple.Create("\"", 12268)
, Tuple.Create(Tuple.Create("", 12251), Tuple.Create("SubTypes_", 12251), true)
            
            #line 231 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
, Tuple.Create(Tuple.Create("", 12260), Tuple.Create<System.Object, System.Int32>(jt.Id
            
            #line default
            #line hidden
, 12260), false)
);

WriteLiteral(" class=\"jobSubTypes\"");

WriteLiteral(">\r\n");

WriteLiteral("                                            ");

            
            #line 232 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                       Write(CommonHelpers.CheckboxBulkSelect(string.Format("CheckboxBulkSelect_{0}", jt.Id), "div"));

            
            #line default
            #line hidden
WriteLiteral("\r\n");

WriteLiteral("                                            ");

            
            #line 233 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                       Write(CommonHelpers.CheckBoxList("JobSubTypes", jt.JobSubTypes.OrderBy(jst => jst.Description).ToSelectListItems(Model.DocumentTemplate.JobSubTypes), 2));

            
            #line default
            #line hidden
WriteLiteral("\r\n                                        </div>\r\n                               " +
"     </div>   \r\n");

            
            #line 236 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                    }
                                }

            
            #line default
            #line hidden
WriteLiteral("                            </div>\r\n");

WriteLiteral("                            <script>\r\n                                (function (" +
") {\r\n                                    var dialog;\r\n\r\n                        " +
"            function showDialog() {\r\n                                        if " +
"(!dialog) {\r\n                                            dialog = $(\'#Config_Doc" +
"umentTemplates_JobSubTypes_Update_Dialog\').dialog({\r\n                           " +
"                     resizable: false,\r\n                                        " +
"        modal: true,\r\n                                                autoOpen: " +
"false,\r\n                                                width: 750,\r\n           " +
"                                     height: 620,\r\n                             " +
"                   buttons: {\r\n                                                 " +
"   \"Save Changes\": saveChanges,\r\n                                               " +
"     Cancel: cancel\r\n                                                }\r\n        " +
"                                    });\r\n\r\n                                     " +
"       dialog.find(\'.jobSubTypes\').hide();\r\n                                    " +
"        dialog.on(\'change\', \'input.jobType\', function () {\r\n                    " +
"                            var $this = $(this);\r\n                              " +
"                  if ($this.is(\':checked\'))\r\n                                   " +
"                 $(\'#SubTypes_\' + $this.val()).slideDown(\'fast\');\r\n             " +
"                                   else\r\n                                       " +
"             $(\'#SubTypes_\' + $this.val()).slideUp(\'fast\');\r\n                   " +
"                         }).find(\'input.jobType:checked\').each(function () {\r\n  " +
"                                              $(\'#SubTypes_\' + $(this).val()).sh" +
"ow();\r\n                                            });\r\n                        " +
"                }\r\n\r\n                                        dialog.dialog(\'open" +
"\');\r\n\r\n                                        return false;\r\n                  " +
"                  }\r\n\r\n                                    function cancel() {\r\n" +
"                                        dialog.dialog(\"disable\");\r\n             " +
"                           dialog.dialog(\"option\", \"buttons\", null);\r\n\r\n        " +
"                                // Refresh Page\r\n                               " +
"         window.location.href = window.location.href;\r\n                         " +
"           }\r\n\r\n                                    function saveChanges() {\r\n  " +
"                                      var form = dialog.find(\'form\');\r\n\r\n       " +
"                                 $(\'input.jobType:unchecked\').each(function () {" +
"\r\n                                            $(\'#SubTypes_\' + $(this).val()).fi" +
"nd(\'input\').prop(\'checked\', false);\r\n                                        });" +
"\r\n\r\n                                        form.submit();\r\n\r\n                  " +
"                      dialog.dialog(\"disable\");\r\n                               " +
"         dialog.dialog(\"option\", \"buttons\", null);\r\n                            " +
"        }\r\n\r\n                                    $(function () {\r\n              " +
"                          $(\'#Config_DocumentTemplates_JobSubTypes_Update\').clic" +
"k(showDialog);\r\n                                    });\r\n\r\n                     " +
"           })();\r\n                            </script>\r\n");

            
            #line 301 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                        }

            
            #line default
            #line hidden
WriteLiteral("                    </div>\r\n");

            
            #line 303 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }

            
            #line default
            #line hidden
WriteLiteral("            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Template PDF\r\n   " +
"         </th>\r\n            <td>\r\n");

WriteLiteral("                ");

            
            #line 310 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.ActionLink("Download Template", MVC.API.DocumentTemplate.Template(Model.DocumentTemplate.Id)));

            
            #line default
            #line hidden
WriteLiteral("\r\n");

            
            #line 311 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                
            
            #line default
            #line hidden
            
            #line 311 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.Upload))
                {

            
            #line default
            #line hidden
WriteLiteral("                    <br />\r\n");

            
            #line 314 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                    using (Html.BeginForm(MVC.API.DocumentTemplate.Template(Model.DocumentTemplate.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
                    {

            
            #line default
            #line hidden
WriteLiteral("                    <input");

WriteLiteral(" type=\"file\"");

WriteLiteral(" name=\"Template\"");

WriteLiteral(" id=\"Template\"");

WriteLiteral(" style=\"width: 250px;\"");

WriteLiteral(" />\r\n");

WriteLiteral("                    <input");

WriteLiteral(" class=\"button\"");

WriteLiteral(" type=\"submit\"");

WriteLiteral(" value=\"Upload\"");

WriteLiteral(" />\r\n");

            
            #line 318 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                    }

            
            #line default
            #line hidden
WriteLiteral("                    <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
                        $(function () {
                            var $template = $('#Template');
                            $template.closest('form').submit(function () {
                                if ($template.val() == '') {
                                    alert('A template file is required to upload.');
                                    return false;
                                }
                            });
                        });
                    </script>
");

            
            #line 330 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }

            
            #line default
            #line hidden
WriteLiteral("            </td>\r\n        </tr>\r\n        <tr>\r\n            <th>Filter Expression" +
":\r\n            </th>\r\n            <td>");

            
            #line 336 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                 if (canConfig && Authorization.Has(Claims.Config.DocumentTemplate.ConfigureFilterExpression))
                {
                
            
            #line default
            #line hidden
            
            #line 338 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(Html.TextBoxFor(model => model.DocumentTemplate.FilterExpression));

            
            #line default
            #line hidden
            
            #line 338 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                  
                
            
            #line default
            #line hidden
            
            #line 339 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxRemove());

            
            #line default
            #line hidden
            
            #line 339 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         
                
            
            #line default
            #line hidden
            
            #line 340 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
           Write(AjaxHelpers.AjaxLoader());

            
            #line default
            #line hidden
            
            #line 340 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                         

            
            #line default
            #line hidden
WriteLiteral("                <script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(">\r\n                    $(function () {\r\n                        var $FilterExpres" +
"sion = $(\'#DocumentTemplate_FilterExpression\');\r\n                        var $aj" +
"axLoading = $FilterExpression.nextAll(\'.ajaxLoading\').first();\r\n                " +
"        var $ajaxRemove = $FilterExpression.nextAll(\'.ajaxRemove\').first();\r\n   " +
"                     $FilterExpression\r\n                                .waterma" +
"rk(\'Filter Expression\')\r\n                                .focus(function () { $F" +
"ilterExpression.select() })\r\n                                .keydown(function (" +
"e) {\r\n                                    if (e.which == 13) {\r\n                " +
"                        $(this).blur();\r\n                                    }\r\n" +
"                                }).change(function () {\r\n                       " +
"             updateFilterExpression($FilterExpression.val());\r\n                 " +
"               });\r\n                        if ($FilterExpression.val() != \'\')\r\n" +
"                            $ajaxRemove.show();\r\n                        $ajaxRe" +
"move.click(function () {\r\n                            updateFilterExpression(\'\')" +
";\r\n                            $FilterExpression.val(\'\');\r\n                     " +
"   });\r\n                        var updateFilterExpression = function (filterExp" +
"ression) {\r\n                            $ajaxLoading.show();\r\n                  " +
"          $ajaxRemove.hide();\r\n                            var data = { FilterEx" +
"pression: filterExpression };\r\n                            $.ajax({\r\n           " +
"                     url: \'");

            
            #line 367 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                 Write(Url.Action(MVC.API.DocumentTemplate.UpdateFilterExpression(Model.DocumentTemplate.Id)));

            
            #line default
            #line hidden
WriteLiteral(@"',
                                dataType: 'json',
                                data: data,
                                success: function (d) {
                                    if (d == 'OK') {
                                        $ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
                                        if (data.FilterExpression != '')
                                            $ajaxRemove.fadeIn('fast');
                                    } else {
                                        $ajaxLoading.hide();
                                        alert('Unable to update filter expression: ' + d);
                                    }
                                },
                                error: function (jqXHR, textStatus, errorThrown) {
                                    alert('Unable to update filter expression: ' + textStatus);
                                    $ajaxLoading.hide();
                                }
                            });
                        };
                    });
                </script>
");

            
            #line 388 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(Model.DocumentTemplate.FilterExpression))
                    {

            
            #line default
            #line hidden
WriteLiteral("                <span");

WriteLiteral(" class=\"smallMessage\"");

WriteLiteral(">&lt;None Specified&gt;</span>\r\n");

            
            #line 394 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                    }
                    else
                    {

            
            #line default
            #line hidden
WriteLiteral("                <div");

WriteLiteral(" class=\"code\"");

WriteLiteral(">\r\n");

WriteLiteral("                    ");

            
            #line 398 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
               Write(Model.DocumentTemplate.FilterExpression);

            
            #line default
            #line hidden
WriteLiteral("\r\n                </div>\r\n");

            
            #line 400 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                    }
                }

            
            #line default
            #line hidden
WriteLiteral("            </td>\r\n        </tr>\r\n    </table>\r\n</div>\r\n<h2>Template Expressions<" +
"/h2>\r\n");

            
            #line 407 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
Write(Html.Partial(MVC.Config.DocumentTemplate.Views._ExpressionsTable, Model.TemplateExpressions));

            
            #line default
            #line hidden
WriteLiteral("\r\n<div");

WriteLiteral(" id=\"dialogConfirmDelete\"");

WriteLiteral(" title=\"Delete this Document Template?\"");

WriteLiteral(">\r\n    <p>\r\n        <i");

WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg warning\"");

WriteLiteral(@"></i>This item will be permanently deleted and cannot be recovered.<br />
        <em>This <strong>will not delete attachments</strong> which have already been imported,
            but any generated documents will no longer be automatically imported.</em><br />
        Are you sure?
    </p>
</div>
<script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
    $(function () {
        var button = $('#buttonDelete');
        var buttonDialog = $(""#dialogConfirmDelete"");
        var buttonLink = button.attr('href');
        button.attr('href', '#');
        button.click(function () {
            buttonDialog.dialog('open');
            return false;
        });
        buttonDialog.dialog({
            resizable: false,
            modal: true,
            autoOpen: false,
            buttons: {
                ""Delete"": function () {
                    $this = $(this);
                    $this.dialog('disable');
                    $this.dialog(""option"", ""buttons"", null);
                    window.location.href = buttonLink;
                },
                Cancel: function () {
                    $(this).dialog(""close"");
                }
            }
        });

    });
</script>
<div");

WriteLiteral(" class=\"actionBar\"");

WriteLiteral(">\r\n");

            
            #line 446 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
    
            
            #line default
            #line hidden
            
            #line 446 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
     if (Authorization.Has(Claims.Config.Show))
    {
        
            
            #line default
            #line hidden
            
            #line 448 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
   Write(Html.ActionLinkButton("Expression Browser", MVC.Config.DocumentTemplate.ExpressionBrowser()));

            
            #line default
            #line hidden
            
            #line 448 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                     
    }

            
            #line default
            #line hidden
WriteLiteral("    ");

            
            #line 450 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
     if (canBulkGenerate)
    {

            
            #line default
            #line hidden
WriteLiteral("        <a");

WriteLiteral(" id=\"buttonBulkGenerate\"");

WriteLiteral(" href=\"#\"");

WriteLiteral(" class=\"button\"");

WriteLiteral(">Bulk Generate</a>\r\n");

WriteLiteral("        <div");

WriteLiteral(" id=\"dialogBulkGenerate\"");

WriteLiteral(" class=\"hiddenDialog\"");

WriteAttribute("title", Tuple.Create(" title=\"", 23181), Tuple.Create("\"", 23232)
, Tuple.Create(Tuple.Create("", 23189), Tuple.Create("Bulk", 23189), true)
, Tuple.Create(Tuple.Create(" ", 23193), Tuple.Create("Generate:", 23194), true)
            
            #line 453 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
, Tuple.Create(Tuple.Create(" ", 23203), Tuple.Create<System.Object, System.Int32>(Model.DocumentTemplate.Id
            
            #line default
            #line hidden
, 23204), false)
);

WriteLiteral(">\r\n            <div");

WriteLiteral(" class=\"brief\"");

WriteLiteral(">\r\n                <div>\r\n                    Enter multiple <span");

WriteLiteral(" class=\"scopeDescBulkGenerate\"");

WriteLiteral("></span>&nbsp;separated by <code>&lt;new line&gt;</code>, commas (<code>,</code>)" +
" or semicolons (<code>;</code>).\r\n                </div>\r\n                <div");

WriteLiteral(" class=\"examples clearfix\"");

WriteLiteral(">\r\n                    <h4>Examples:</h4>\r\n                    <div");

WriteLiteral(" class=\"example1 code\"");

WriteLiteral("></div>\r\n                    <div");

WriteLiteral(" class=\"example2 code\"");

WriteLiteral("></div>\r\n                    <div");

WriteLiteral(" class=\"example3 code\"");

WriteLiteral("></div>\r\n                </div>\r\n            </div>\r\n");

            
            #line 465 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
            
            
            #line default
            #line hidden
            
            #line 465 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
             using (Html.BeginForm(MVC.API.DocumentTemplate.BulkGenerate(Model.DocumentTemplate.Id), FormMethod.Post))
            {

            
            #line default
            #line hidden
WriteLiteral("                <div");

WriteLiteral(" class=\"field-validation-valid\"");

WriteLiteral(" data-valmsg-replace=\"true\"");

WriteLiteral(" data-valmsg-for=\"DataIds\"");

WriteLiteral("></div>\r\n");

WriteLiteral("                <textarea");

WriteLiteral(" id=\"inputBulkGenerateDataIds\"");

WriteLiteral(" name=\"DataIds\"");

WriteLiteral(" data-val=\"true\"");

WriteLiteral(" data-val-required=\"Identifiers are required\"");

WriteLiteral("></textarea>\r\n");

            
            #line 469 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
            }

            
            #line default
            #line hidden
WriteLiteral("        </div>\r\n");

            
            #line 471 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"


            
            #line default
            #line hidden
WriteLiteral("        <script>\r\n            $(function () {\r\n                var dialog;\r\n\r\n   " +
"             $(\'#buttonBulkGenerate\').click(function () {\r\n                    i" +
"f (!dialog) {\r\n                        dialog = $(\'#dialogBulkGenerate\').dialog(" +
"{\r\n                            resizable: false,\r\n                            mo" +
"dal: true,\r\n                            autoOpen: false,\r\n                      " +
"      width: 460,\r\n                            buttons: {\r\n                     " +
"           \"Bulk Generate\": function () {\r\n                                    d" +
"ialog.find(\'form\').submit();\r\n                                    dialog.dialog(" +
"\"disable\");\r\n                                },\r\n                               " +
" Close: function () {\r\n                                    $(this).dialog(\"close" +
"\");\r\n                                }\r\n                            }\r\n         " +
"               });\r\n\r\n                        $.validator.unobtrusive.reparse(\'#" +
"inputBulkGenerateDataIds\');\r\n                    }\r\n\r\n                    switch" +
" ($(\'#DocumentTemplate_Scope\').val()) {\r\n                        case \'Device\':\r" +
"\n                            dialog.find(\'.scopeDescBulkGenerate\').text(\'Device " +
"Serial Numbers\');\r\n                            dialog.find(\'.example1\').html(\'01" +
"234567<br />ABCD9876<br />8VQ6G2R\');\r\n                            dialog.find(\'." +
"example2\').text(\'01234567,ABCD9876,8VQ6G2R\');\r\n                            dialo" +
"g.find(\'.example3\').text(\'01234567;ABCD9876;8VQ6G2R\');\r\n                        " +
"    break;\r\n                        case \'Job\':\r\n                            dia" +
"log.find(\'.scopeDescBulkGenerate\').text(\'Job Ids\');\r\n                           " +
" dialog.find(\'.example1\').html(\'86<br />99<br />44\');\r\n                         " +
"   dialog.find(\'.example2\').text(\'86,99,44\');\r\n                            dialo" +
"g.find(\'.example3\').text(\'86;99;44\');\r\n                            break;\r\n     " +
"                   case \'User\':\r\n                            dialog.find(\'.scope" +
"DescBulkGenerate\').text(\'User Ids\');\r\n                            dialog.find(\'." +
"example1\').html(\'user6<br />smi0099<br />rsmith\');\r\n                            " +
"dialog.find(\'.example2\').text(\'user6,smi0099,rsmith\');\r\n                        " +
"    dialog.find(\'.example3\').text(\'user6;smi0099;rsmith\');\r\n                    " +
"        break;\r\n                    }\r\n\r\n                    dialog.dialog(\'open" +
"\');\r\n                    return false;\r\n                });\r\n            });\r\n  " +
"      </script>\r\n");

            
            #line 523 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
    }

            
            #line default
            #line hidden
WriteLiteral("    ");

            
            #line 524 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
     if (Authorization.Has(Claims.Config.DocumentTemplate.Delete))
    {
        
            
            #line default
            #line hidden
            
            #line 526 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
   Write(Html.ActionLinkButton("Delete", MVC.API.DocumentTemplate.Delete(Model.DocumentTemplate.Id, true), "buttonDelete"));

            
            #line default
            #line hidden
            
            #line 526 "..\..\Areas\Config\Views\DocumentTemplate\Show.cshtml"
                                                                                                                          
    }

            
            #line default
            #line hidden
WriteLiteral("</div>\r\n");

        }
    }
}
#pragma warning restore 1591
