-var timezoneid = ViewData["timezoneid"].ToString()
-var t_dt = ViewData["DataTable"] as DataTable
-var t_cols = ViewData["Columns"] as List<Column>
-var t_viscols = ViewData["VisibleColumns"] as Column[]
-var fixedcols = t_viscols.Where(c=>c.Id=="Changed" || c.Id=="EditorName" || c.Id=="Statusid")
-var othercols = t_viscols.Where(c=>c.Id!="Changed" && c.Id!="EditorName" && c.Id!="Statusid")
-var t_leftcols = t_viscols.Where(t=>t.SortAlias=="")
-string t_pk = ViewData.ContainsKey("PrimaryKey") ? ViewData["PrimaryKey"].ToString() : null
-bool trackchanges = ViewData.ContainsKey("trackchanges")
%style table.data td{font-size: 8pt;}
%link{rel="stylesheet",href="css/ui-jscrollpane/jquery.jscrollpane.css",type="text/css"}
-var task = ViewData["task"] as Task
=HtmlHelper.HiddenInput("id",task.Id)
.padded10{style="min-width: 550px;"}
  %div#floatingblock
    %div#block-header       
      %div.floatleft
        %h1
          =string.Format("{0}{1}.",HtmlHelper.Resource("Task.TaskNumber"),task.Id)
      %div#name.floatleft
        %h1
          =string.Format("{0} <strong>{1}</strong>, {2}",HtmlHelper.Resource("Task.TaskCreator"), task.Creator.Name, task.Created.ConvertToTimeZone(timezoneid))
      %div#excel 
        %h1
          %a.button{href=string.Format("taskhistory.ivp/excel/{0}",task.Id),target="_blank"}=HtmlHelper.Resource("Task.ExportExcel")
      _historypagination     
    %table{class="scrolltable" cellspacing="0" cellpadding="0"}
      %tbody
        %tr
          %td#fixedblock
            %table.data{style="margin-top:17px;"}
              %thead
                %tr#leftheader
                  -foreach(var t_c in fixedcols.Where(vc => vc.Id != t_pk))
                    %th{width=string.Format("{0}%",t_c.Width),title=t_c.Title,class=(t_c.Sortable && t_c.SortDirection != SortDirection.None) ? "sorted":"", colid=t_c.Id}
                      %nobr
                        -if(t_c.Sortable)
                          %a{href="#",onclick=String.Format("return orderBy('{0}')",t_c.SortExpression)}=(t_c.ShortTitle ?? t_c.Title)
                          -if(t_c.SortDirection != SortDirection.None)
                            =t_c.SortDirection==SortDirection.Ascending?"&darr;":"&uarr;"
                          -else
                            ="&nbsp;&nbsp;"
                        -else
                          =(t_c.ShortTitle ?? t_c.Title)
              %tbody#fixedcols
                -bool odd = true
                -bool hasRowClass = t_dt.Columns.Contains("RowClass")
                -DataRow prev_dr = null
                -int rownumber=0
                -foreach(DataRow t_dr in t_dt.Rows)  
                  -odd = !odd
                  %tr{class=(odd?"odd ":"") + (hasRowClass ? t_dr["RowClass"].ToString() : ""), rowid=rownumber}
                    -if(t_pk!=null && !t_viscols.Any(vc => vc.Id == t_pk))
                      %td.cb
                        -string strpk = Convert.ToString(t_dr[t_pk])
                        -if(!string.IsNullOrEmpty(strpk) && strpk != "0")
                          =HtmlHelper.Checkbox("id",t_dr[t_pk],"rowid cb",false,true)
                    -foreach(var t_c in fixedcols)
                      -string t_class = t_c.CssClass
                      -if(trackchanges && prev_dr != null && !object.Equals(prev_dr[t_c.Id],t_dr[t_c.Id])) t_class += " yellowbg"
                      -var tableDataRow = t_dr[t_c.Id].ToString()
                      -if(!string.IsNullOrEmpty(t_c.TdId))
                        -if(tableDataRow=="Да")
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.Yes")
                        -else if(tableDataRow=="Нет")
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.No")
                        -else
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=t_dr[t_c.Id]
                      -else
                        -if(tableDataRow=="Да")
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.Yes")
                        -else if(tableDataRow=="Нет")
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.No")
                        -else
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=t_dr[t_c.Id]
                  -rownumber++
                  -prev_dr = t_dr
          %td#variableblock        
            %div#scrollerclone{style="width: 100%; height: 100%; overflow-x: hidden; position: relative;", class="scroll-pane horizontal-only"}
              %table#historytable.data{style="border-left: medium none; margin-top:17px; z-index: 100;"}
                %thead
                  %tr#rightheader{class="alternateRow"}
                    -int i=0;
                    -foreach(var t_c in othercols.Where(vc => vc.Id != t_pk))
                      -string thstyle = (i==0)?"border-left:none;":""
                      %th{width=string.Format("{0}%",t_c.Width),title=t_c.Title,class=(t_c.Sortable && t_c.SortDirection != SortDirection.None) ? "sorted":"", colid=t_c.Id, style=thstyle}
                        %nobr
                          -if(t_c.Sortable)
                            %a{href="#",onclick=String.Format("return orderBy('{0}')",t_c.SortExpression)}=(t_c.ShortTitle ?? t_c.Title)
                            -if(t_c.SortDirection != SortDirection.None)
                              =t_c.SortDirection==SortDirection.Ascending?"&darr;":"&uarr;"
                            -else
                              ="&nbsp;&nbsp;"
                          -else
                            =(t_c.ShortTitle ?? t_c.Title)
                      -i++
                %tbody
                  -odd = true
                  -hasRowClass = t_dt.Columns.Contains("RowClass")
                  -prev_dr = null
                  -rownumber=0
                  -foreach(DataRow t_dr in t_dt.Rows)  
                    -odd = !odd
                    %tr{class=(odd?"odd ":"") + (hasRowClass ? t_dr["RowClass"].ToString() : ""), rowid=rownumber}
                      -if(t_pk!=null && !t_viscols.Any(vc => vc.Id == t_pk))
                        %td.cb
                          -string strpk = Convert.ToString(t_dr[t_pk])
                          -if(!string.IsNullOrEmpty(strpk) && strpk != "0")
                            =HtmlHelper.Checkbox("id",t_dr[t_pk],"rowid cb",false,true)
                      -i=0
                      -foreach(var t_c in othercols)
                        -string thstyle = (i==0)?"border-left:none;":""
                        -string t_class = t_c.CssClass
                        -if(trackchanges && prev_dr != null && !object.Equals(prev_dr[t_c.Id],t_dr[t_c.Id])) t_class += " yellowbg"
                        -var tableDataRow = t_dr[t_c.Id].ToString()
                        -if(!string.IsNullOrEmpty(t_c.TdId))
                          -if(tableDataRow=="Да")
                            %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.Yes")
                          -else if(tableDataRow=="Нет")
                            %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.No")
                          -else
                            %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=t_dr[t_c.Id]
                        -else
                          -if(tableDataRow=="Да")
                            %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.Yes")
                          -else if(tableDataRow=="Нет")
                            %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.No")
                          -else
                            %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=t_dr[t_c.Id]
                    -rownumber++
                    -prev_dr = t_dr
  #tableholder{style="overflow: hidden !important; width: 100%; margin-top:23px;"}
    =HtmlHelper.HiddenInput("tablecontroller",ViewData["Controller"])
    =HtmlHelper.HiddenInput("tableaction",ViewData["Action"])
    _error
    
    %table{class="scrolltable" cellspacing="0" cellpadding="0"}
      %tbody
        %tr
          %td#fixedblock
            %table.data{style="margin-top:17px;"}
              %thead
                %tr#leftheader
                  -foreach(var t_c in fixedcols.Where(vc => vc.Id != t_pk))
                    %th{width=string.Format("{0}%",t_c.Width),title=t_c.Title,class=(t_c.Sortable && t_c.SortDirection != SortDirection.None) ? "sorted":"", colid=t_c.Id}
                      %nobr
                        -if(t_c.Sortable)
                          %a{href="#",onclick=String.Format("return orderBy('{0}')",t_c.SortExpression)}=(t_c.ShortTitle ?? t_c.Title)
                          -if(t_c.SortDirection != SortDirection.None)
                            =t_c.SortDirection==SortDirection.Ascending?"&darr;":"&uarr;"
                          -else
                            ="&nbsp;&nbsp;"
                        -else
                          =(t_c.ShortTitle ?? t_c.Title)
              %tbody#fixedcols
                -odd = true
                -hasRowClass = t_dt.Columns.Contains("RowClass")
                -prev_dr = null
                -rownumber=0
                -foreach(DataRow t_dr in t_dt.Rows)  
                  -odd = !odd
                  %tr{class=(odd?"odd ":"") + (hasRowClass ? t_dr["RowClass"].ToString() : ""), rowid=rownumber}
                    -if(t_pk!=null && !t_viscols.Any(vc => vc.Id == t_pk))
                      %td.cb
                        -string strpk = Convert.ToString(t_dr[t_pk])
                        -if(!string.IsNullOrEmpty(strpk) && strpk != "0")
                          =HtmlHelper.Checkbox("id",t_dr[t_pk],"rowid cb",false,true)
                    -foreach(var t_c in fixedcols)
                      -string t_class = t_c.CssClass
                      -if(trackchanges && prev_dr != null && !object.Equals(prev_dr[t_c.Id],t_dr[t_c.Id])) t_class += " yellowbg"
                      -var tableDataRow = t_dr[t_c.Id].ToString()
                      -if(!string.IsNullOrEmpty(t_c.TdId))
                        -if(tableDataRow=="Да")
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.Yes")
                        -else if(tableDataRow=="Нет")
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.No")
                        -else
                          %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber}=t_dr[t_c.Id]
                      -else
                        -if(tableDataRow=="Да")
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.Yes")
                        -else if(tableDataRow=="Нет")
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=HtmlHelper.Resource("Common.No")
                        -else
                          %td{class=t_class, colid=t_c.Id, rowid=rownumber}=t_dr[t_c.Id]
                  -rownumber++
                  -prev_dr = t_dr
          %td#variableblock        
            %div#scroller{style="width: 100%; height: 100%; overflow-x: hidden; position: relative;", class="scroll-pane horizontal-only"}
              %div#tablescroller{style="left: 0px; padding: 0; position: relative;"}
                %table#historytable.data{style="border-left: medium none; margin-top:17px;"}
                  %thead
                    %tr#rightheader{class="alternateRow"}
                      -i=0;
                      -foreach(var t_c in othercols.Where(vc => vc.Id != t_pk))
                        -string thstyle = (i==0)?"border-left:none;":""
                        %th{width=string.Format("{0}%",t_c.Width),title=t_c.Title,class=(t_c.Sortable && t_c.SortDirection != SortDirection.None) ? "sorted":"", colid=t_c.Id, style=thstyle}
                          %nobr
                            -if(t_c.Sortable)
                              %a{href="#",onclick=String.Format("return orderBy('{0}')",t_c.SortExpression)}=(t_c.ShortTitle ?? t_c.Title)
                              -if(t_c.SortDirection != SortDirection.None)
                                =t_c.SortDirection==SortDirection.Ascending?"&darr;":"&uarr;"
                              -else
                                ="&nbsp;&nbsp;"
                            -else
                              =(t_c.ShortTitle ?? t_c.Title)
                        -i++
                  %tbody
                    -odd = true
                    -hasRowClass = t_dt.Columns.Contains("RowClass")
                    -prev_dr = null
                    -rownumber=0
                    -foreach(DataRow t_dr in t_dt.Rows)  
                      -odd = !odd
                      %tr{class=(odd?"odd ":"") + (hasRowClass ? t_dr["RowClass"].ToString() : ""), rowid=rownumber}
                        -if(t_pk!=null && !t_viscols.Any(vc => vc.Id == t_pk))
                          %td.cb
                            -string strpk = Convert.ToString(t_dr[t_pk])
                            -if(!string.IsNullOrEmpty(strpk) && strpk != "0")
                              =HtmlHelper.Checkbox("id",t_dr[t_pk],"rowid cb",false,true)
                        -i=0
                        -foreach(var t_c in othercols)
                          -string thstyle = (i==0)?"border-left:none;":""
                          -string t_class = t_c.CssClass
                          -if(trackchanges && prev_dr != null && !object.Equals(prev_dr[t_c.Id],t_dr[t_c.Id])) t_class += " yellowbg"
                          -var tableDataRow = t_dr[t_c.Id].ToString()
                          -if(!string.IsNullOrEmpty(t_c.TdId))
                            -if(tableDataRow=="Да")
                              %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.Yes")
                            -else if(tableDataRow=="Нет")
                              %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.No")
                            -else
                              %td{class=t_class,id=t_c.TdId+t_dr[t_pk], colid=t_c.Id, rowid=rownumber, style=thstyle}=t_dr[t_c.Id]
                          -else
                            -if(tableDataRow=="Да")
                              %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.Yes")
                            -else if(tableDataRow=="Нет")
                              %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.No")
                            -else if(tableDataRow=="Mobile")
                              %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=HtmlHelper.Resource("Common.Mobile")
                            -else
                              %td{class=t_class, colid=t_c.Id, rowid=rownumber, style=thstyle}=t_dr[t_c.Id]
                      -rownumber++
                      -prev_dr = t_dr