Changes in / [61a8e52:5f22008]
- Files:
-
- 7 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
web/core.php
r61a8e52 r5f22008 192 192 if(isset($_REQUEST[$varname])) return $_REQUEST[$varname]; 193 193 return $def; 194 } 195 196 /// Проверяет был ли получен запрос через ajax 197 /// @return boolean 198 function isAjaxRequest() 199 { 200 return isset($_SERVER['HTTP_X_REQUESTED_WITH']) 201 && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) 202 && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; 194 203 } 195 204 -
web/css/comm.js
r61a8e52 r5f22008 379 379 httpRequest.onreadystatechange = function() { popupReqWin(httpRequest,popup); }; 380 380 httpRequest.open('GET', url, true); 381 httpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 381 382 httpRequest.send(null); 382 383 return false; … … 405 406 //popup.innerHTML="Обработка..."; 406 407 } 407 else popup.innerHTML="state "+httpRequest.readyState;408 408 } 409 409 -
web/include/models/ldo/doclist.php
r61a8e52 r5f22008 88 88 } 89 89 return $filter; 90 } 91 92 93 /** 94 * Сформировать order из запроса 95 * @return string 96 */ 97 protected function getOrder() 98 { 99 $orderFields = [ 100 'sum' => '`doc_list`.`sum`', 101 'date' => '`doc_list`.`date`', 102 'asc' => 'ASC', 103 'desc' => 'DESC' 104 ]; 105 if(!empty($this->options['order'])) { 106 foreach (json_decode($this->options['order'], true) as $item) { 107 if(!empty($orderFields[$item['field']]) && !empty($orderFields[$item['order']])) { 108 $orders[] = $orderFields[$item['field']] . ' ' . $orderFields[$item['order']]; 109 } 110 } 111 } 112 if(!empty($orders)) { 113 return 'ORDER BY '.implode(', ', $orders); 114 } 115 return 'ORDER by `doc_list`.`date` DESC'; 90 116 } 91 117 … … 203 229 $sql_join 204 230 WHERE 1 $sql_filter 205 ORDER by `doc_list`.`date` DESC231 {$this->getOrder()} 206 232 LIMIT $start,{$this->limit}"; 207 233 $result = array(); -
web/js/doc_journal.js
r61a8e52 r5f22008 132 132 var httpRequest = new XMLHttpRequest(); 133 133 134 let sortableFields = []; 135 let fieldsWithCnt = [ 136 { 137 attributes: { 138 width: 55 139 }, 140 html: 'a.№' 141 }, 142 { 143 attributes: { 144 width: 20 145 }, 146 html: '' 147 }, 148 { 149 attributes: { 150 width: 20 151 }, 152 html: '' 153 }, 154 { 155 html: 'Тип' 156 }, 157 { 158 html: 'Участник 1' 159 }, 160 { 161 html: 'Участник 2' 162 }, 163 { 164 html: 'Кол-во' 165 }, 166 { 167 html: 'Цена' 168 }, 169 { 170 attributes: { 171 class: 'js-order-filter' 172 }, 173 field: 'sum', 174 order: 'asc', 175 html: 'Сумма' 176 }, 177 { 178 attributes: { 179 class: 'js-order-filter' 180 }, 181 field: 'date', 182 order: 'asc', 183 html: 'Дата' 184 }, 185 { 186 html: 'Автор' 187 }, 188 { 189 html: 'id' 190 }, 191 ]; 192 193 let fields = [ 194 { 195 attributes: { 196 width: 55 197 }, 198 html: 'a.№' 199 }, 200 { 201 attributes: { 202 width: 20 203 }, 204 html: '' 205 }, 206 { 207 attributes: { 208 width: 20 209 }, 210 html: '' 211 }, 212 { 213 html: 'Тип' 214 }, 215 { 216 html: 'Участник 1' 217 }, 218 { 219 html: 'Участник 2' 220 }, 221 { 222 attributes: { 223 class: 'js-order-filter' 224 }, 225 field: 'sum', 226 order: 'asc', 227 html: 'Сумма' 228 }, 229 { 230 attributes: { 231 class: 'js-order-filter' 232 }, 233 field: 'date', 234 order: 'asc', 235 html: 'Дата' 236 }, 237 { 238 html: 'Автор' 239 }, 240 { 241 html: 'id' 242 }, 243 ]; 244 245 134 246 var deffer_timer; 135 247 var docj_list_body = document.getElementById('docj_list_body'); … … 218 330 if (okfilter_id.value != '0') 219 331 filter_request += '&doclist[ok]=' + encodeURIComponent(okfilter_id.value); 332 333 if(sortableFields) { 334 let orderQuery = []; 335 sortableFields.forEach(function(item){ 336 if(item.hasOwnProperty('order') && item.hasOwnProperty('field')) { 337 orderQuery.push({ 338 'field': item.field, 339 'order': item.order 340 }); 341 } 342 }); 343 filter_request += '&doclist[order]=' + encodeURIComponent(JSON.stringify(orderQuery)); 344 } 220 345 } 221 346 … … 558 683 } 559 684 685 function buldHeaderFields(data) { 686 let tr = document.createElement("tr"); 687 data.forEach(function (item, i) { 688 let th = document.createElement("th"); 689 th.innerText = item.html; 690 if(item.hasOwnProperty('attributes')) { 691 if(item.attributes.hasOwnProperty('class')){ 692 th.classList = item.attributes.class ? item.attributes.class : ''; 693 } 694 } 695 if(item.hasOwnProperty('order')) { 696 th.style = 'background: url(/img/i_orderarrows.png) 100% ' 697 +(item.order === 'asc' ? '' : '10') 698 +'0% no-repeat transparent; background-color: #6488DC; cursor: pointer'; 699 } 700 if(item.hasOwnProperty('field')) { 701 th.dataset.field = item.field; 702 } 703 th.dataset.fieldId = i; 704 tr.appendChild(th); 705 }); 706 return tr.innerHTML; 707 } 708 709 560 710 function initTableHead() { 561 711 var head = document.getElementById('doc_list_head'); 562 712 if (show_count_column) { 563 head.innerHTML = "<tr><th width='55'>a.№</th><th width='20'> </th><th width='20'> </th><th>Тип</th><th>Участник 1</th><th>Участник 2</th><th>Кол-во</th><th>Цена</th><th>Сумма</th><th>Дата</th><th>Автор</th><th width='45'>id</th></tr>";713 head.innerHTML = buldHeaderFields(fieldsWithCnt); 564 714 } 565 715 else { 566 head.innerHTML = "<tr><th width='55'>a.№</th><th width='20'> </th><th width='20'> </th><th>Тип</th><th>Участник 1</th><th>Участник 2</th><th>Сумма</th><th>Дата</th><th>Автор</th><th width='45'>id</th></tr>"; 567 } 716 head.innerHTML = buldHeaderFields(fields); 717 } 718 let orderFilter = function(e) { 719 let data = show_count_column ? fieldsWithCnt : fields; 720 let self = this; 721 sortableFields = sortableFields.filter(function(val){ 722 return val.field !== data[self.dataset.fieldId].field; 723 }); 724 sortableFields.unshift({ 725 field: data[this.dataset.fieldId].field, 726 order: data[this.dataset.fieldId].order === 'asc' ? 'desc' : 'asc', 727 }); 728 data[this.dataset.fieldId].order = data[this.dataset.fieldId].order === 'asc' ? 'desc' : 'asc'; 729 beginDefferedRequest(); 730 }; 731 document.querySelectorAll("th.js-order-filter").forEach(box => { box.addEventListener('click', orderFilter, false); }); 568 732 } 569 733 -
web/skins/default/basic.css
r61a8e52 r5f22008 193 193 div.notify 194 194 { 195 width: 97%;196 195 BORDER: #999900 1px solid; 197 196 FONT-SIZE: 14px; -
web/vitrina.php
r61a8e52 r5f22008 194 194 } 195 195 } else { 196 if (getenv("HTTP_REFERER")) { 197 redirect(getenv("HTTP_REFERER")); 198 } 199 $tmpl->msg("Товар добавлен в корзину!", "info", "<a class='urllink' href='/vitrina.php?mode=basket'>Ваша корзина</a>"); 196 if(isAjaxRequest()) { 197 $tmpl->msg("Товар добавлен в корзину!", "info", "<a class='urllink' href='/vitrina.php?mode=basket'>Ваша корзина</a>"); 198 } else { 199 if (getenv("HTTP_REFERER")) { 200 redirect(getenv("HTTP_REFERER")); 201 } 202 } 200 203 } 201 204 } else {
Note: See TracChangeset
for help on using the changeset viewer.