Persönliche Werkzeuge

Vorlage:BV-BgPreisIndex

Aus BogenWiki

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
Zeile 19: Zeile 19:
{
{
   console.log('[OnBgLoad] Bogen.length='+Bogen.length);
   console.log('[OnBgLoad] Bogen.length='+Bogen.length);
-
   BVBgList   = Bogen;
+
   var BVBgList = Bogen;
-
  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:''}};
+
   var aOptions = Param.Options.split(';');
   var aOptions = Param.Options.split(';');
   var aGroupBy = [];
   var aGroupBy = [];
Zeile 61: 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'));
+
     if (!BVCheckPrice(sPreis,BVBgList[b].Eingang.Art,BVGetBgFieldValue(BVBgList[b],'EM.Art.Key')))
-
    if (BVGetBgFieldValue(BVBgList[b],'EM.Art.Key') == 'Satz') bPreis = false;
+
       sPreis = '<span style="color:silver;"><i>'+sPreis+'€</i></span>';
-
    if (BVGetBgFieldValue(BVBgList[b],'EM.Art.Key') == 'BT') bPreis = false;
+
-
    if (BVBgList[b].Eingang.Preis == '0,00') bPreis = false;
+
-
    if (BVBgList[b].Eingang.Preis == '?,??') bPreis = false;
+
-
    if (bPreis) {
+
-
      var sGroupByValue = '';
+
-
      for (g = 0; g < aGroupBy.length; g++) {
+
-
        sGroupByValue += BVGetBgFieldValue(BVBgList[b],aGroupBy[g])+'::';
+
-
      }
+
-
      var nPreis = parseFloat(sPreis.replace(/,/,'.'));
+
-
      // Eigene Käufe von Auktionshäusern enthalten die Aufschläge und Zusatzkosten.
+
-
      // Diese müssen für den Preis-Index abgezogen werden da alle ebay-Käufe und
+
-
      // Ergebnisse von Auktionshäusern nur den Zuschlagspreis enthalten. Da ich die
+
-
      // genauen Aufschläge nicht habe, setze ich die pauschal mit 25% an.
+
-
      if (BVBgList[b].Eingang.Art == 'K') {
+
-
        if (BVBgList[b].Eingang.Quelle == 'ah')
+
-
          nPreis = nPreis*0.8;
+
-
      }
+
-
      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);
+
-
      }
+
-
      BVBgPrStat.Total.Count++;
+
-
      if (BVBgList[b].Eingang.Datum != '') {
+
-
        if (BVBgPrStat.Total.DateFrom > BVBgList[b].Eingang.Datum) BVBgPrStat.Total.DateFrom = BVBgList[b].Eingang.Datum;
+
-
        if (BVBgPrStat.Total.DateTo < BVBgList[b].Eingang.Datum)  BVBgPrStat.Total.DateTo = BVBgList[b].Eingang.Datum;
+
-
      }
+
-
      if (BVBgList[b].Eingang.Quelle == 'eb') {
+
-
        BVBgPrStat.ebay.Count++;
+
-
        if (BVBgList[b].Eingang.Datum != '') {
+
-
          if (BVBgPrStat.ebay.DateFrom > BVBgList[b].Eingang.Datum) BVBgPrStat.ebay.DateFrom = BVBgList[b].Eingang.Datum;
+
-
          if (BVBgPrStat.ebay.DateTo < BVBgList[b].Eingang.Datum)  BVBgPrStat.ebay.DateTo = BVBgList[b].Eingang.Datum;
+
-
        }
+
-
      }
+
-
      if (BVBgList[b].Eingang.Quelle == 'ah') {
+
-
        BVBgPrStat.AH.Count++;
+
-
        if (BVBgList[b].Eingang.Datum != '') {
+
-
          if (BVBgPrStat.AH.DateFrom > BVBgList[b].Eingang.Datum) BVBgPrStat.AH.DateFrom = BVBgList[b].Eingang.Datum;
+
-
          if (BVBgPrStat.AH.DateTo < BVBgList[b].Eingang.Datum)  BVBgPrStat.AH.DateTo = BVBgList[b].Eingang.Datum;
+
-
        }
+
-
      }
+
-
    } 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 126: Zeile 71:
   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 BVBgPreise = BVCalcPriceIndex(Bogen,aGroupBy);
   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 144: Zeile 90:
               '  </tr>';
               '  </tr>';
   if (BVBgPreise.length > 0) {
   if (BVBgPreise.length > 0) {
-
     BVBgPreise.sort((a, b) => a.GroupValue > b.GroupValue ? 1 : -1);
+
     TotalCount = 0;
 +
    TotalDateFrom = '';
 +
    TotalDateTo = '';
 +
    TotalEbayCount = 0;
 +
    TotalEbayDateFrom = '';
 +
    TotalEbayDateTo = '';
 +
    TotalAHCount = 0;
 +
    TotalAHDateFrom = '';
 +
    TotalAHDateTo = '';
     for (var p = 0; p < BVBgPreise.length; p++) {
     for (var p = 0; p < BVBgPreise.length; p++) {
-
       var aGroupValues = BVBgPreise[p].GroupValue.split('::');
+
       if (BVBgPreise[p].GroupValue.indexOf('::') > 0) {
-
      sTabHTML += '  <tr style="background:#FCFCFC" valign=top>';
+
        var aGroupValues = BVBgPreise[p].GroupValue.split('::');
-
      for (v = 0; v < aGroupValues.length-1; v++)
+
        sTabHTML += '  <tr style="background:#FCFCFC" valign=top>';
-
        sTabHTML += '    <td><div style="'+sCellPadding+'">'+aGroupValues[v]+'</div></td>';
+
        for (v = 0; v < aGroupValues.length-1; v++)
-
      sTabHTML += '    <td align=right><div style="'+sCellPadding+'">'+(BVBgPreise[p].Sum/BVBgPreise[p].Count).toFixed(2).replace(/\./,',')+'€</div></td>'+
+
          sTabHTML += '    <td><div style="'+sCellPadding+'">'+aGroupValues[v]+'</div></td>';
-
                  '    <td align=right><div style="'+sCellPadding+'">'+median(BVBgPreise[p].Preise).toFixed(2).replace(/\./,',')+'€</div></td>'+
+
        sTabHTML += '    <td align=right><div style="'+sCellPadding+'">'+BVBgPreise[p].Avg.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=right><div style="'+sCellPadding+'">'+BVBgPreise[p].Median.toFixed(2).replace(/\./,',')+'€</div></td>'+
-
                  '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Count+'</div></td>'+
+
                    '    <td align=center><div style="'+sCellPadding+'">'+BVBgPreise[p].Min.toFixed(2).replace(/\./,',')+'€ - '+BVBgPreise[p].Max.toFixed(2).replace(/\./,',')+'€</div></td>'+
-
                  '  </tr>';
+
                    '    <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;
     nColSpan = aGroupBy.length + 4;
Zeile 165: Zeile 139:
                         '<tr style="background:transparent" valign=top>'+
                         '<tr style="background:transparent" valign=top>'+
                           '<td>Gesamt:&nbsp;</td>'+
                           '<td>Gesamt:&nbsp;</td>'+
-
                           '<td align=right>'+BVBgPrStat.Total.Count+'&nbsp;</td>'+
+
                           '<td align=right>'+TotalCount+'&nbsp;</td>'+
-
                           '<td>('+BVBgPrStat.Total.DateFrom+' - '+BVBgPrStat.Total.DateTo+')</td>'+
+
                           '<td>('+TotalDateFrom+' - '+TotalDateTo+')</td>'+
                         '</tr>'+
                         '</tr>'+
                         '<tr style="background:transparent" valign=top>'+
                         '<tr style="background:transparent" valign=top>'+
                           '<td>&nbsp;&nbsp;davon ebay:&nbsp;</td>'+
                           '<td>&nbsp;&nbsp;davon ebay:&nbsp;</td>'+
-
                           '<td align=right>'+BVBgPrStat.ebay.Count+'&nbsp;</td>'+
+
                           '<td align=right>'+TotalEbayCount+'&nbsp;</td>'+
-
                           '<td>'+(BVBgPrStat.ebay.Count>0 ? '('+BVBgPrStat.ebay.DateFrom+' - '+BVBgPrStat.ebay.DateTo+')' : ' ')+'</td>'+
+
                           '<td>'+(TotalEbayCount>0 ? '('+TotalEbayDateFrom+' - '+TotalEbayDateTo+')' : ' ')+'</td>'+
                         '</tr>'+
                         '</tr>'+
                         '<tr style="background:transparent" valign=top>'+
                         '<tr style="background:transparent" valign=top>'+
                           '<td>&nbsp;&nbsp;davon AH:&nbsp;</td>'+
                           '<td>&nbsp;&nbsp;davon AH:&nbsp;</td>'+
-
                           '<td align=right>'+BVBgPrStat.AH.Count+'&nbsp;</td>'+
+
                           '<td align=right>'+TotalAHCount+'&nbsp;</td>'+
-
                           '<td>'+(BVBgPrStat.AH.Count>0 ? '('+BVBgPrStat.AH.DateFrom+' - '+BVBgPrStat.AH.DateTo+')' : ' ')+'</td>'+
+
                           '<td>'+(TotalAHCount>0 ? '('+TotalAHDateFrom+' - '+TotalAHDateTo+')' : ' ')+'</td>'+
                         '</tr>'+
                         '</tr>'+
                       '</table>'+
                       '</table>'+
Zeile 190: Zeile 164:
   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>

Version vom 07:31, 28. Sep. 2023

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