Advertisement
krot

xfilter

Aug 4th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.77 KB | None | 0 0
  1. <th><select id="fclient" onchange="return xchange('client');" style="width:100%">
  2. <option value="">Покупатель</option>
  3. </select></th>
  4.  
  5. <td style="font-size: 80%;"  class="client">{$item.Client}</td>
  6.  
  7.  
  8. <tr>
  9. <td colspan="6" >Всего {$sumcount} на сумму:</td>
  10. <td colspan="1" id="sumall" data-sum='{$sum|round:"2"}'><b>{$sum|round:"2"}</b></td>
  11. <td>
  12.  
  13.  
  14. <script>
  15. /*фильтр*/
  16. function xfilter(cl){
  17.         var supervise = {};
  18.         $("."+cl).each(function() {
  19.         var txt = $(this).text();
  20.         if(txt=='')return;
  21.         if (supervise[txt]){
  22.         }else{
  23.         ($('#f'+cl).append('<option value="'+txt+'">'+txt+'</option>'))
  24.         supervise[txt] = true;
  25.         };
  26.         });
  27. }
  28. var xfilterLs = {};/*хранить классы предыдущих*/
  29.  function xchange(cl){
  30.         $("."+cl).parent().show();
  31.        
  32.         xfilterLs[cl]=true;
  33.          for(var p in xfilterLs) {
  34.             op=$( "#f"+p+" option:selected" ).val();
  35.             $("."+p).each(function() {
  36.             if($(this).text()==op){
  37.                 }else if(op!=='')$(this).parent().hide();
  38.             });
  39.          }
  40.          var sump=0;
  41.          var sumz=0;
  42.          var sumo=0;
  43.          $("."+cl).parent().each(function() {
  44.              if($(this).css('display')=='none')return;
  45.              
  46.             sump+=Number($(this).find('.sump').text());
  47.             sumz+=Number($(this).find('.sumz').text());
  48.             sumo+=Number($(this).find('.sumo').text());
  49.         });
  50.         $('#sumall b').text(Math.round(sump));//.toFixed(2));/*сумма продажи*/
  51.         $('#sumallz b').text(Math.round(sumz))//.toFixed(2));/*сумма закупки*/
  52.         $('#sumallr b').text(Math.round(sump-sumz));/*разница*/
  53.         $('#sumallrp b').text(Math.round(((sump-sumz)/sumz)*100));/*разница %*/
  54.         $('#sumallo b').text(Math.round(sumo));/*отказы %*/
  55.      }
  56. </script>
  57.  
  58. <script>
  59. xfilter('seller');
  60. xfilter('client');
  61. xfilter('city');
  62. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement