1{* $Id$ *} 2{if empty($iListExecute)}{assign var=iListExecute value=$id|replace:'wplistexecute-':''}{/if} 3{if isset($tableparams.title)} 4 <div class="list-table-heading">{wiki}{$tableparams.title|escape}{/wiki}</div> 5{/if} 6{if $actions} 7<form method="post" action="#{$id}" class="form-inline" id="listexecute-{$iListExecute}"> 8{/if} 9{if not empty($column.field)} 10 {$column = [$column]}{* if there is only one column then it will not be in an array *} 11{/if} 12{if isset($tableparams.allowtableexpansion) && $tableparams.allowtableexpansion eq 'y'} 13 {button href='javascript:void(0)' _type="primary" _class="btn btn-primary btn-sm table-expand-toggle" _icon_name="caret-square-right" _title="{tr}Expand table{/tr}"} 14 {jq} 15 $(".table-expand-toggle").click(function(){ 16 var $this = $(this); 17 if ( $this.data('expandStatus') != 'expanded' ) { 18 $this.data('expandStatus','expanded'); 19 var $parentdiv = $(this).parent('div'); 20 $parentdiv.find('div.table-responsive').each(function () { 21 $(this).removeClass('table-responsive').addClass('table'); 22 }); // end each 23 $this.attr('title','{tr}Restore layout{/tr}'); 24 $this.find(".icon").setIcon("caret-square-left"); 25 }else{ 26 $this.data('expandStatus','responsive'); 27 var $parentdiv = $(this).parent('div'); 28 $parentdiv.find('div.table').each(function () { 29 $(this).addClass('table-responsive').removeClass('table'); 30 }); // end each 31 $this.attr('title','{tr}Expand table{/tr}'); 32 $this.find(".icon").setIcon("caret-square-right"); 33 } 34 }); 35 {/jq} 36{/if} 37{if isset($tableparams.shownbitems) && $tableparams.shownbitems eq 'y'} 38 <div class="nbitems"> 39 {tr}Items found:{/tr} <span class='badge badge-secondary'>{$count}</span> 40 </div> 41{/if} 42<div {if $id}id="{$id}-div" {/if}class="table-responsive ts-wrapperdiv" {if $tsOn}style="visibility:hidden;"{/if}> 43 <table {if $id}id="{$id}" {/if}class="table normal table-hover table-striped" data-count="{$count}"> 44 <thead> 45 {$header=false} 46 {foreach from=$column item=col} 47 {if !empty($col.label) or !empty($col.sort)} 48 {$header=true} 49 {break} 50 {/if} 51 {/foreach} 52 {if $header} 53 {$fieldcount = 0} 54 <tr> 55 {if $actions} 56 {$fieldcount = 1} 57 <th> 58 <input type="checkbox" class="form-check-input listexecute-select-all" name="selectall" value=""> 59 <input type="hidden" name="objects{$iListExecute}[]" value="" class="listexecute-all"> 60 </th> 61 {/if} 62 {foreach from=$column item=col} 63 {$fieldcount = $fieldcount + 1} 64 <th{if not empty($col.class)} class="{$col.class}"{/if}> 65 {if isset($col.sort) && $col.sort} 66 {if !empty($sort_jsvar) and !empty($_onclick)} 67 {$order = '_asc'} 68 {if !empty($smarty.request.sort_mode) and stristr($smarty.request.sort_mode, $col.sort) neq false} 69 {if stristr($smarty.request.sort_mode, '_asc')} 70 {$order = '_desc'} 71 {elseif stristr($smarty.request.sort_mode, '_nasc')} 72 {$order = '_ndesc'} 73 {elseif stristr($smarty.request.sort_mode, '_desc')} 74 {$order = '_asc'} 75 {elseif stristr($smarty.request.sort_mode, '_ndesc')} 76 {$order = '_nasc'} 77 {/if} 78 {/if} 79 {$click = $sort_jsvar|cat:'=\''|cat:$col.sort|cat:$order|cat:'\';'|cat:$_onclick} 80 {if isset($col.translatelabel) && $col.translatelabel == 'y'} 81 {self_link _onclick=$click _ajax='y' _sort_arg='sort_mode' _sort_field=$col.sort}{$col.label|tra|escape}{/self_link} 82 {else} 83 {self_link _onclick=$click _ajax='y' _sort_arg='sort_mode' _sort_field=$col.sort}{$col.label|escape}{/self_link} 84 {/if} 85 {else} 86 {if isset($col.translatelabel) && $col.translatelabel == 'y'} 87 {self_link _sort_arg=$sort_arg _sort_field=$col.sort}{$col.label|tra|escape}{/self_link} 88 {else} 89 {self_link _sort_arg=$sort_arg _sort_field=$col.sort}{$col.label|escape}{/self_link} 90 {/if} 91 {/if} 92 {else} 93 {if isset($col.translatelabel) && $col.translatelabel == 'y'} 94 {$col.label|tra|escape} 95 {else} 96 {$col.label|escape} 97 {/if} 98 {/if} 99 </th> 100 {/foreach} 101 </tr> 102 {/if} 103 </thead> 104 <tbody> 105 {foreach from=$results item=row} 106 <tr> 107 {if $actions} 108 <td> 109 <input type="checkbox" name="objects{$iListExecute}[]" class="checkbox_objects form-check-input" value="{$row.object_type|escape}:{$row.object_id|escape}"> 110 {if $row.report_status eq 'success'} 111 {icon name='ok'} 112 {elseif $row.report_status eq 'error'} 113 {icon name='error'} 114 {/if} 115 </td> 116 {/if} 117 {foreach from=$column item=col} 118 <td{if not empty($col.class)} class="{$col.class}"{/if}> 119 {if isset($col.mode) && $col.mode eq 'raw'} 120 {if !empty($row[$col.field])}{$row[$col.field]}{/if} 121 {else} 122 {if !empty($row[$col.field])}{$row[$col.field]|escape}{/if} 123 {/if} 124 </td> 125 {/foreach} 126 </tr> 127 {/foreach} 128 </tbody> 129 {if !empty($tstotals) && $tsOn} 130 {include file="../../tablesorter/totals.tpl" fieldcount="{$fieldcount}"} 131 {/if} 132 </table> 133</div> 134{if $actions} 135 <div class="row w-100"> 136 <div class="col-sm-1"> 137 <input type="submit" class="btn btn-primary btn-sm" title="{tr}Apply Changes{/tr}" id="submit_form_{$id}" disabled value="{tr}Apply{/tr}"> 138 </div> 139 <div class="col-sm-4"> 140 <select name="list_action" class="form-control" id="check_submit_select_{$id}"> 141 <option></option> 142 {foreach from=$actions item=action} 143 <option value="{$action->getName()|escape}" data-input='{$action->requiresInput()}'> 144 {$action->getName()|escape} 145 </option> 146 {/foreach} 147 </select> 148 </div> 149 <div class="col-sm-4" id="list_input_container_{$id}"> 150 </div> 151 <input type="text" name="list_input" value="" class="form-control" style="display:none"> 152 </div> 153 154</form> 155{jq} 156(function(){ 157 var countChecked = function() { 158 if ($('#{{$id}}-div .checkbox_objects').is(':checked')) { 159 if($('select#check_submit_select_{{$id}}').val()){ 160 $('input#submit_form_{{$id}}').prop('disabled', false); 161 } 162 } else { 163 $('input#submit_form_{{$id}}').prop('disabled', true); 164 } 165 var header_checked = $('#{{$id}}-div .checkbox_objects').not(':checked').length == 0; 166 $('#listexecute-{{$iListExecute}} .listexecute-all').val(header_checked ? 'ALL' : ''); 167 }; 168 $('#listexecute-{{$iListExecute}} .listexecute-select-all').removeClass('listexecute-select-all') 169 .on('click', function (e) { 170 $(this).closest('form').find('tbody :checkbox:not(:disabled)').each(function () { 171 $(this).prop("checked", ! $(this).prop("checked")); 172 }).promise().done(function(){ countChecked(); }); 173 }); 174 $('#listexecute-{{$iListExecute}}').find('select[name=list_action]') 175 .on('change', function() { 176 var valueSel = $('select#check_submit_select_{{$id}}').val(); 177 if(valueSel == ''){ 178 $('input#submit_form_{{$id}}').prop('disabled', true); 179 } else { 180 if($('#{{$id}}-div .checkbox_objects').is(':checked')){ 181 $('input#submit_form_{{$id}}').prop('disabled', false); 182 } 183 } 184 var params = $(this).find('option:selected').data('input'); 185 if( typeof params === "object" && typeof params[0] === "object") { 186 $("#list_input_container_{{$id}}").load( 187 $.service('tracker', 'fetch_item_field', params[0]), 188 function () { 189 $(this).tiki_popover().applyChosen(); 190 } 191 ).show(); 192 } else if( params ) { 193 $(this).siblings('input[name=list_input]').show(); 194 $("#list_input_container_{{$id}}").hide(); 195 } else { 196 $(this).siblings('input[name=list_input]').hide(); 197 $("#list_input_container_{{$id}}").hide(); 198 } 199 }); 200 $( "#{{$id}}-div .checkbox_objects" ).on( "click", countChecked ); 201 countChecked(); 202 $('#listexecute-{{$iListExecute}}').submit(function(){ 203 feedback(tr('Action is being executed, please wait.')); 204 $(this).tikiModal(" "); 205 var filters = $('#list_filter{{$iListExecute|replace:'wplistexecute-':''}} form').serializeArray(), 206 inp, i; 207 for(i = 0, l = filters.length; i < l; i++) { 208 inp = $('<input type="hidden">'); 209 inp.attr('name', filters[i].name); 210 inp.val(filters[i].value); 211 $('#listexecute-{{$iListExecute}}').append(inp); 212 } 213 var trackerInputs = $("input,select,textarea", "#list_input_container_{{$id}}").serializeArray(); 214 if (trackerInputs) { 215 for (i = 0; i < trackerInputs.length; i++) { 216 inp = $('<input type="hidden">'); 217 inp.attr("name", "list_input~" + trackerInputs[i].name); // add tracker inputs as an array "inside" list_input 218 inp.val(trackerInputs[i].value); 219 $('#listexecute-{{$iListExecute}}').append(inp); 220 } 221 $("#listexecute-{{$iListExecute}}").remove("input[list_input]"); 222 } 223 }); 224})(); 225{/jq} 226{/if} 227{if ! empty($downloadable)} 228 {if $actions} 229 <br> 230 {/if} 231 <form method="post" id="listexecute-download-{$iListExecute}"> 232 <input type="hidden" name="download" value="1"> 233 <input type="hidden" name="tsAjax" value="y"> 234 <input type="submit" name="submit" value="{tr}Download{/tr}" class="btn btn-primary"> 235 </form> 236{jq} 237(function(){ 238 $('#listexecute-download-{{$iListExecute}}').submit(function(){ 239 var $form = $(this); 240 $form.find('input[name^=filter]').remove(); 241 $('.tablesorter-filter').each(function(i,el){ 242 var column = $(el).data('column'), 243 value = $(el).val(); 244 if( value ) { 245 $('<input type="hidden" name="filter['+column+']">') 246 .val(value) 247 .appendTo($form); 248 } 249 }); 250 }); 251})(); 252{/jq} 253{/if} 254