Persönliche Werkzeuge

Vorlage:BV-BgPreisIndex

Aus BogenWiki

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
 
(Der Versionsvergleich bezieht 34 dazwischenliegende Versionen mit ein.)
Zeile 4: Zeile 4:
BVBgList    = [];
BVBgList    = [];
BVBgPreise  = [];
BVBgPreise  = [];
 +
BVBgPrStat  = {Total:{Count:0, DateFrom:'9999-99-99', DateTo:''},
 +
              ebay: {Count:0, DateFrom:'9999-99-99', DateTo:''},
 +
              AH:  {Count:0, DateFrom:'9999-99-99', DateTo:''}};
function OnBgListLoad(BgList,Param)
function OnBgListLoad(BgList,Param)
{
{
Zeile 16: Zeile 19:
{
{
   console.log('[OnBgLoad] Bogen.length='+Bogen.length);
   console.log('[OnBgLoad] Bogen.length='+Bogen.length);
-
   BVBgList   = Bogen;
+
   var BVBgList = Bogen;
-
   BVBgPreise = [];
+
   var aOptions = Param.Options.split(';');
 +
  var aGroupBy = [];
 +
  for (o = 0; o < aOptions.length; o++) {
 +
    if (aOptions[o].split(':')[0] == 'GroupBy')
 +
      aGroupBy = aOptions[o].split(':')[1].split('+');
 +
  }
   var sCellPadding = 'padding:0px; padding-left:4px; padding-right:4px;';
   var sCellPadding = 'padding:0px; padding-left:4px; padding-right:4px;';
   var eBgList = document.getElementById('BVBgList.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr);
   var eBgList = document.getElementById('BVBgList.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr);
Zeile 49: Zeile 57:
       sBN = '<a href="/bogenwiki/index.php?title=Bund MiNr. '+BVBgList[b].BogenNr+' groß">'+BVBgList[b].BogenNr+'</a>';
       sBN = '<a href="/bogenwiki/index.php?title=Bund MiNr. '+BVBgList[b].BogenNr+' groß">'+BVBgList[b].BogenNr+'</a>';
     var sPreis = BVBgList[b].Eingang.Preis;
     var sPreis = BVBgList[b].Eingang.Preis;
-
     var bPreis = ((BVBgList[b].Eingang.Art == 'AZ') || (BVBgList[b].Eingang.Art == 'K'));
+
     console.log('BVGetBgFieldValue(BVBgList['+b+'],"Zustand") = '+BVGetBgFieldValue(BVBgList[b],'Zustand'));
-
    if (BVGetBgFieldValue(BVBgList[b],'EM.Art.Key') == 'Satz') bPreis = false;
+
     if (!BVCheckPrice(sPreis,BVBgList[b].Eingang.Art,BVGetBgFieldValue(BVBgList[b],'EM.Art.Key'),BVGetBgFieldValue(BVBgList[b],'Erhaltung'),BVGetBgFieldValue(BVBgList[b],'Zustand')))
-
     if (BVBgList[b].Eingang.Preis == '0,00') bPreis = false;
+
       sPreis = '<span style="color:silver;"><i>'+sPreis+'€</i></span>';
-
    if (BVBgList[b].Eingang.Preis == '?,??') bPreis = false;
+
-
    if (bPreis) {
+
-
      var aOptions = Param.Options.split(';');
+
-
      var aGroupBy = '';
+
-
      for (o = 0; o < aOptions.length; o++) {
+
-
        if (aOptions[o].split(':')[0] == 'GroupBy')
+
-
          aGroupBy = aOptions[o].split(':')[1].split('+');
+
-
      }
+
-
      var sGroupByValue = '';
+
-
      for (g = 0; g < aGroupBy.length; g++) {
+
-
        sGroupByValue += BVGetBgFieldValue(BVBgList[b],aGroupBy[g])+'::';
+
-
      }
+
-
      var nPreis = parseFloat(sPreis.replace(/,/,'.'))
+
-
      var nGroupIdx = -1;
+
-
      for (var p = 0; p < BVBgPreise.length; p++)
+
-
        if (BVBgPreise[p].GroupValue == sGroupByValue) nGroupIdx = p;
+
-
      if (nGroupIdx < 0) {
+
-
        BVBgPreise.push({GroupValue:sGroupByValue, Min:nPreis, Sum:nPreis, Max:nPreis, Count:1, Preise:[nPreis]});
+
-
      } else {
+
-
        if (nPreis < BVBgPreise[nGroupIdx].Min) BVBgPreise[nGroupIdx].Min = nPreis;
+
-
        if (nPreis > BVBgPreise[nGroupIdx].Max) BVBgPreise[nGroupIdx].Max = nPreis;
+
-
        BVBgPreise[nGroupIdx].Sum += nPreis;
+
-
        BVBgPreise[nGroupIdx].Count++;
+
-
        BVBgPreise[nGroupIdx].Preise.push(nPreis);
+
-
      }
+
-
    } else {
+
-
       sPreis = '<span style="color:silver;"><i>'+BVBgList[b].Eingang.Preis+'€</i></span>';
+
-
    }
+
     sTabHTML += '  <tr style="background:#FCFCFC" valign=top>'+
     sTabHTML += '  <tr style="background:#FCFCFC" valign=top>'+
                 '    <td><div style="'+sCellPadding+'">'+sBN+'</div></td>'+
                 '    <td><div style="'+sCellPadding+'">'+sBN+'</div></td>'+
Zeile 92: Zeile 72:
   if (eBgList) eBgList.innerHTML = sTabHTML;
   if (eBgList) eBgList.innerHTML = sTabHTML;
   var eBgPreise = document.getElementById('BVBgPreise.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr);
   var eBgPreise = document.getElementById('BVBgPreise.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr);
-
   var aGroupBy = '';
+
   var BVBgPreise = BVCalcPriceIndex(Bogen,aGroupBy);
-
   for (o = 0; o < aOptions.length; o++) {
+
   console.log('BVBgPreise.length = '+BVBgPreise.length);
-
    if (aOptions[o].split(':')[0] == 'GroupBy') {
+
-
      aGroupBy = aOptions[o].split(':')[1].split('+');
+
-
    }
+
-
  }
+
   sTabHTML = '<table id="BVBgPreise.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr+'.Tab" style="background:silver" cellpadding=1 cellspacing=1>'+
   sTabHTML = '<table id="BVBgPreise.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr+'.Tab" style="background:silver" cellpadding=1 cellspacing=1>'+
             '  <tr style="background:#E0E0E0" valign=top>';
             '  <tr style="background:#E0E0E0" valign=top>';
Zeile 103: Zeile 79:
     var aGroupByParts = aGroupBy[g].split('.');
     var aGroupByParts = aGroupBy[g].split('.');
     var sGroupByText = aGroupByParts[0];
     var sGroupByText = aGroupByParts[0];
 +
    if (aGroupByParts[0] == 'Erhaltung') sGroupByText = 'Erh.';
     if (aGroupByParts[0] == 'Eingang') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'Eingang') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'Ausgang') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'Ausgang') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'BRS') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'BRS') sGroupByText = aGroupByParts[1];
-
     if (aGroupByParts[0] == 'PF') sGroupByText = aGroupByParts[1];
+
     if (aGroupByParts[0] == 'PF') sGroupByText = aGroupByParts[0];
     if (aGroupByParts[0] == 'EM') sGroupByText = aGroupByParts[1];
     if (aGroupByParts[0] == 'EM') sGroupByText = aGroupByParts[1];
-
     sTabHTML += '    <td><div style="'+sCellPadding+'"><b>'+sGroupByText+'</b></div></td>';
+
     sTabHTML += '    <td><div style="'+sCellPadding+'">'+sGroupByText+'</div></td>';
   }
   }
-
   sTabHTML += '    <td align=center><div style="'+sCellPadding+'"><b>Mittel</b></div></td>'+
+
   sTabHTML += '    <td align=center><div style="'+sCellPadding+'">Mittel</div></td>'+
-
               '    <td align=center><div style="'+sCellPadding+'"><b>Median</b></div></td>'+
+
               '    <td align=center><div style="'+sCellPadding+'">Median</div></td>'+
-
               '    <td align=center><div style="'+sCellPadding+'"><b>Min - Max</b></div></td>'+
+
               '    <td align=center><div style="'+sCellPadding+'">Min - Max</div></td>'+
-
               '    <td align=center><div style="'+sCellPadding+'"><b>Anz.</b></div></td>'+
+
               '    <td align=center><div style="'+sCellPadding+'">Anz.</div></td>'+
               '  </tr>';
               '  </tr>';
-
   BVBgPreise.sort((a, b) => a.GroupValue > b.GroupValue ? 1 : -1);
+
   if (BVBgPreise.length > 0) {
-
  for (var p = 0; p < BVBgPreise.length; p++) {
+
    TotalCount = 0;
-
    var aGroupValues = BVBgPreise[p].GroupValue.split('::');
+
    TotalDateFrom = '';
-
    sTabHTML += '  <tr style="background:#FCFCFC" valign=top>';
+
    TotalDateTo = '';
-
    for (v = 0; v < aGroupValues.length-1; v++)
+
    TotalEbayCount = 0;
-
      sTabHTML += '    <td><div style="'+sCellPadding+'">'+aGroupValues[v]+'</div></td>';
+
    TotalEbayDateFrom = '';
-
    sTabHTML += '    <td align=right><div style="'+sCellPadding+'">'+(BVBgPreise[p].Sum/BVBgPreise[p].Count).toFixed(2).replace(/\./,',')+'€</div></td>'+
+
    TotalEbayDateTo = '';
-
                '    <td align=right><div style="'+sCellPadding+'">'+median(BVBgPreise[p].Preise).toFixed(2).replace(/\./,',')+'€</div></td>'+
+
    TotalAHCount = 0;
-
                '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Min.toFixed(2).replace(/\./,',')+'€ - '+BVBgPreise[p].Max.toFixed(2).replace(/\./,',')+'€</div></td>'+
+
    TotalAHDateFrom = '';
-
                '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Count+'</div></td>'+
+
    TotalAHDateTo = '';
 +
    for (var p = 0; p < BVBgPreise.length; p++) {
 +
      console.log('BVBgPreise['+p+'].GroupValue = "'+BVBgPreise[p].GroupValue+'"');
 +
      if (BVBgPreise[p].GroupValue.indexOf('::') > 0) {
 +
        var aGroupValues = BVBgPreise[p].GroupValue.split('::');
 +
        sTabHTML += '  <tr style="background:#FCFCFC" valign=top>';
 +
        for (v = 0; v < aGroupValues.length-1; v++) {
 +
          var aGroupByParts = aGroupBy[v].split('.');
 +
          var sGroupByValueText = aGroupValues[v];
 +
          console.log('aGroupByParts['+v+']="'+aGroupByParts[v]+'"; aGroupValues['+v+']="'+aGroupValues[v]+'"');
 +
          if (aGroupByParts[v] == 'Erhaltung') {
 +
            switch (aGroupValues[v]) {
 +
              case 'Pf': sGroupByValueText = '<div style="padding-top:2px"><img src="/bogenwiki/images/Symbol_Pfr1T.png" width="27" height="14" alt="**" title="postfrisch"></div>'; break;
 +
              case 'Gs': sGroupByValueText = '<div style="padding-top:2px"><img src="/bogenwiki/images/Symbol_GesT1.png" width="13" height="14" alt="**" title="gestempelt"></div>'; break;
 +
              case 'Ug': sGroupByValueText = '<div style="padding-top:2px"><img src="/bogenwiki/images/Symbol_UgsT1.png" width="13" height="14" alt="**" title="ungebraucht"></div>'; break;
 +
              case 'Bt': sGroupByValueText = '<span title="Bogentasche">BT</span>'; break;
 +
            }
 +
          }
 +
          sTabHTML += '    <td><div style="'+sCellPadding+'">'+sGroupByValueText+'</div></td>';
 +
        }
 +
        sTabHTML += '    <td align=right><div style="'+sCellPadding+'">'+BVBgPreise[p].Avg.toFixed(2).replace(/\./,',')+'€</div></td>'+
 +
                    '    <td align=right><div style="'+sCellPadding+'">'+BVBgPreise[p].Median.toFixed(2).replace(/\./,',')+'€</div></td>'+
 +
                    '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Min.toFixed(2).replace(/\./,',')+'€ - '+BVBgPreise[p].Max.toFixed(2).replace(/\./,',')+'€</div></td>'+
 +
                    '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Count+'</div></td>'+
 +
                    '  </tr>';
 +
      } else {
 +
        switch (BVBgPreise[p].GroupValue) {
 +
          case '':
 +
            TotalCount = BVBgPreise[p].Count;
 +
            TotalDateFrom = BVBgPreise[p].DateFrom;
 +
            TotalDateTo = BVBgPreise[p].DateTo;
 +
            break;
 +
          case '[src:eb]':
 +
            TotalEbayCount = BVBgPreise[p].Count;
 +
            TotalEbayDateFrom = BVBgPreise[p].DateFrom;
 +
            TotalEbayDateTo = BVBgPreise[p].DateTo;
 +
            break;
 +
          case '[src:ah]':
 +
            TotalAHCount = BVBgPreise[p].Count;
 +
            TotalAHDateFrom = BVBgPreise[p].DateFrom;
 +
            TotalAHDateTo = BVBgPreise[p].DateTo;
 +
            break;
 +
        }
 +
      }
 +
    }
 +
    nColSpan = aGroupBy.length + 4;
 +
    sTabHTML += '  <tr style="background:#FCFCFC" valign=top>'+
 +
                '    <td align=left colspan='+nColSpan+'><div style="'+sCellPadding+'">'+
 +
                      '<table id="BVBgPrStat.'+Param.Gebiet+'.'+Param.Gebiet1+'.'+Param.KatNr+'.Tab" style="background:transparent" cellpadding=0 cellspacing=0>'+
 +
                        '<tr style="background:transparent" valign=top>'+
 +
                          '<td colspan=3><b>Datenbasis:</b></td>'+
 +
                        '</tr>'+
 +
                        '<tr style="background:transparent" valign=top>'+
 +
                          '<td>Gesamt:&nbsp;</td>'+
 +
                          '<td align=right>'+TotalCount+'&nbsp;</td>'+
 +
                          '<td>('+TotalDateFrom+' - '+TotalDateTo+')</td>'+
 +
                        '</tr>'+
 +
                        '<tr style="background:transparent" valign=top>'+
 +
                          '<td>&nbsp;&nbsp;davon ebay:&nbsp;</td>'+
 +
                          '<td align=right>'+TotalEbayCount+'&nbsp;</td>'+
 +
                          '<td>'+(TotalEbayCount>0 ? '('+TotalEbayDateFrom+' - '+TotalEbayDateTo+')' : ' ')+'</td>'+
 +
                        '</tr>'+
 +
                        '<tr style="background:transparent" valign=top>'+
 +
                          '<td>&nbsp;&nbsp;davon AH:&nbsp;</td>'+
 +
                          '<td align=right>'+TotalAHCount+'&nbsp;</td>'+
 +
                          '<td>'+(TotalAHCount>0 ? '('+TotalAHDateFrom+' - '+TotalAHDateTo+')' : ' ')+'</td>'+
 +
                        '</tr>'+
 +
                      '</table>'+
 +
                '    </div></td>'+
 +
                '  </tr>';
 +
 
 +
  } else {
 +
    nColSpan = aGroupBy.length + 4;
 +
    sTabHTML += '  <tr style="background:#FCFCFC" valign=top>'+
 +
                '    <td align=left colspan='+nColSpan+'><div style="'+sCellPadding+'">Keine Auktionsergebnisse vorhanden</div></td>'+
                 '  </tr>';
                 '  </tr>';
   }
   }
   sTabHTML += '</table>';
   sTabHTML += '</table>';
   eBgPreise.innerHTML = sTabHTML;
   eBgPreise.innerHTML = sTabHTML;
-
}
 
-
function median(arr) {
 
-
  const mid = Math.floor(arr.length / 2);
 
-
  const sortedArr = arr.sort((a, b) => a - b);
 
-
  if (arr.length % 2 === 0) {
 
-
    return (sortedArr[mid - 1] + sortedArr[mid]) / 2;
 
-
  } else {
 
-
    return sortedArr[mid];
 
-
  }
 
}
}
</script></html>
</script></html>

Aktuelle Version vom 18:16, 1. Dez. 2023

Template BV_BgPreisIndex: Invalid value for parameter Cmd ("empty")!!!