Advertisement
DataCCIW

Registrations Tab on Person Profile

Nov 3rd, 2023 (edited)
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {% javascript %}
  2. $(function(){
  3.     $('#registrations-table tr[data-href]').each(function(){
  4.         $(this).css('cursor','pointer').hover(
  5.             function(){
  6.                 $(this).addClass('active');
  7.             },  
  8.             function(){
  9.                 $(this).removeClass('active');
  10.             }).click( function(){
  11.                 document.location = $(this).attr('data-href');
  12.             }
  13.         );
  14.     });
  15. });
  16.  
  17. {% endjavascript %}
  18.  
  19. {% assign allRegistrationsItems = '' %}
  20.  
  21.  
  22. {% for alias in Context.Person.Aliases %}
  23. {% registration where:'PersonAliasId  == "{{alias.Id}}"' %}
  24.         {% for registration in registrationItems %}
  25.         {% assign allRegistrationsItems = allRegistrationsItems | AddToArray:registration %}
  26.         {% endfor %}
  27. {% endregistration %}
  28.  
  29. {% registrationregistrant  where:'PersonAliasId  == "{{alias.Id}}"' %}
  30.     {% for registrationregistrant in registrationregistrantItems %}
  31.     {% assign allRegistrationsItems = allRegistrationsItems | AddToArray:registrationregistrant.Registration %}
  32.     {% endfor %}
  33. {% endregistrationregistrant %}
  34. {% endfor %}
  35.  
  36. {% assign allRegistrationsItems = allRegistrationsItems | OrderBy:'CreatedDateTime desc' %}
  37. {% assign rows = allRegistrationsItems | Distinct:'RegistrationInstance.Id' %}
  38.  
  39.     //- Get All RegistrationInstance the current person has access to. A user may have access to view a registration object or a registrationregistrant even when they do not have access to view the registration instance they are tied to
  40.     //- All registrationinstance will have an id greater than -1, this is a little hack to grab all registrations instances the current user has access to
  41. {% registrationinstance where:'Id > -1' %}
  42.  
  43.     {%- assign pageSize = 25 -%}
  44.     {%- assign pageNum = 'Global' | PageParameter:'p' | Default:'' -%}
  45.     {%- assign query = 'Global' | Page:'QueryString' -%}
  46.     {%- assign url = 'Global' | Page:'Url' -%}
  47.     {%- assign rootURL = url | Url:'localpath' -%}
  48.     {%- assign firstLoop = true -%}
  49.     {%- for queryParam in query -%}
  50.         {%- assign kvParam = queryParam | PropertyToKeyValue -%}
  51.         {%- if kvParam.Key != 'p' and  kvParam.Key != 'PageId' -%}
  52.             {%- if firstLoop == true -%}
  53.                 {%- capture rootURL %}{{ rootURL }}?{{ kvParam.Key }}={{ kvParam.Value }}{% endcapture -%}
  54.                 {%- assign firstLoop = false -%}
  55.             {%- else -%}
  56.                 {%- capture rootURL %}{{ rootURL }}&{{ kvParam.Key }}={{ kvParam.Value }}{% endcapture -%}
  57.             {%- endif -%}
  58.         {%- endif -%}
  59.     {%- endfor -%}
  60.     {%- if pageNum == '1' -%}
  61.         {%- comment %} redirect if the page query value is 1 {% endcomment -%}
  62.         {{ rootURL | PageRedirect }}
  63.     {%- endif -%}
  64.     {%- if pageNum == '' %}{% assign pageNum = '1' %}{% endif -%}
  65.     {%- assign pageNum = pageNum | AsInteger -%}
  66.     {%- assign itemCount = rows | Size -%}
  67.     {%- assign pageCount = itemCount | DividedBy:pageSize | Ceiling -%}
  68.     {%- assign skipCount = pageNum | Minus:1 | Times:pageSize -%}
  69.     {%- assign roleID = 'Global' | PageParameter:'GroupId' | Default:'0' -%}
  70.     <div class="panel panel-block">
  71.         <div class="panel-body">
  72.             <div class="grid grid-panel">
  73.                 <div class="table-responsive">
  74.                     <table id="registrations-table" class="grid-table table js-sticky-headers sticky-headers table-bordered table-striped table-hover">
  75.                         <thead>
  76.                             <tr align="left">
  77.     {%- assign columnCount = 6 -%}
  78.                                 <th data-priority="1" scope="col">Template</th>
  79.                                 <th data-priority="1" scope="col">Instance</th>
  80.                                 <th data-priority="1" scope="col">Date</th>
  81.                                 <th data-priority="1" scope="col">Registrants</th>
  82.                                 <th data-priority="1" scope="col">Registrar</th>
  83.                                 <th data-priority="1" scope="col">Registrant</th>
  84.                                 <th data-priority="1" scope="col">Registration Payment Link</th>
  85.                             </tr>
  86.                         </thead>
  87.                         <tbody>
  88.                            
  89.     {%- assign firstRow = rows | First -%}
  90.     //- Due to the way I constructed this array there is always at least one row but it might be empty
  91.     {%- if firstRow != '' -%}  
  92.     {%- for row in rows limit:pageSize offset:skipCount -%}
  93.    
  94.                             {% assign viewregistrationinstance = registrationinstanceItems | Where:'Id', row.RegistrationInstance.Id | Select:'Id' %}
  95.                             {% assign showRegistration = false %}
  96.                             {% if viewregistrationinstance > 0 %} {% assign showRegistration = true %}{% endif %}
  97.                            
  98.                             <tr align="left" title="" class="" data-key="" data-href="{% if showRegistration %}~/page/405?RegistrationId={{row.Id}}&RegistrationInstanceId={{row.RegistrationInstance.Id}}{% endif %}">
  99.                                 <td data-priority="1">{% if showRegistration %}{{ row.RegistrationInstance.RegistrationTemplate }}{% else %}Restricted View Access{% endif %}</td>
  100.                                 <td data-priority="1">{% if showRegistration %}{{ row.RegistrationInstance }}{% else %}{% endif %}</td>
  101.                                 <td data-priority="1">{{ row.CreatedDateTime | Date:'M/d/yyyy' }}</td>
  102.                                 <td data-priority="1">{{ row.Registrants | Size }}</td>
  103.                                 <td data-priority="1">{{ row.PersonAlias.Person }}</td>
  104.                                 <td data-priority="1">{{ row.Registrants | Join:', ' }}</td>
  105.                                 <td data-priority="1"><a href="{{ 'Global' | Attribute:'PublicApplicationRoot' }}Registration?RegistrationId={{row.Id}}">Payment Link</a></td>
  106.                                
  107.                             </tr>
  108.     {%- endfor -%}
  109.     {%- endif -%}  
  110.                         </tbody>
  111.                         <tfoot>
  112.     {%- if pageCount > 1 -%}
  113.                             <tr>
  114.                                 <td class="grid-paging" colspan="{{ columnCount }}">
  115.                                     <span class="grid-itemcount">{{ itemCount | Format:'#,##0' }} {{ 'Item' | PluralizeForQuantity:itemCount }}</span>
  116.                                     {[ pager current:'{{ pageNum }}' total:'{{ pageCount }}' rooturl:'{{ rootURL }}' buttoncount:'10' size:'small' class:'grid-pager' usequery:'true' ]}
  117.                                 </td>
  118.                             </tr>
  119.     {%- endif -%}
  120.                         </tfoot>
  121.                     </table>
  122.                 </div>
  123.             </div>
  124.         </div>
  125.     </div>
  126.  
  127. {% endregistrationinstance %}
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement