Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Umsatzanzeige im Admin erweitern mit Jahresumsatz?

    voodoopupp

    • Fördermitglied
    • Beiträge: 1.854
    • Geschlecht:
    Servus,

    wie der Titel schon sagt, würde ich gerne den Jahresumsatz im Shop Backend darstellen lassen, denn meines Erachtens macht es auch sehr viel Sinn zu sehen, wie ich im aktuellen Geschäftsjahr dastehe. Das wäre meines Erachtens wesentlich wichtiger als ein "Umsatz gesamt".

    [ Für Gäste sind keine Dateianhänge sichtbar ]

    Ich bin auch der Meinung, dass ich da in der admin/start.php fündig werden müsste in etwa hier:

    Code: PHP  [Auswählen]
    // turnover
    $turnover_query = xtc_db_query('select
      round(coalesce(sum(if(date(o.date_purchased) = current_date, ot.value, null)), 0), 2) today,
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 1 day, ot.value, null)), 0), 2) yesterday,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date), ot.value, null)), 0), 2) this_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month), ot.value, null)), 0), 2) last_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1, ot.value, null)), 0), 2) last_month_paid,
      round(coalesce(sum(ot.value), 0), 2) total
      from '
    . TABLE_ORDERS . ' o
      join '
    . TABLE_ORDERS_TOTAL . ' ot on ot.orders_id = o.orders_id
      where ot.class = \'ot_total\''
    );
    $turnover = xtc_db_fetch_array($turnover_query);       
    und hier

    Code: PHP  [Auswählen]
                      <td width="25%" valign="top"><table width="100%" border="0">
                                            <tr>
                                                     <td style="background:#eee"><strong><?php echo TURNOVER_TODAY; ?>:</strong></td>
                                                     <td  style="background:#eee" align="right"><?php echo $currencies->format($turnover['today']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#fff"><strong><?php echo TURNOVER_YESTERDAY; ?>:</strong></td>
                                                     <td style="background:#fff" align="right"><?php echo $currencies->format($turnover['yesterday']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#eee"><strong><?php echo TURNOVER_THIS_MONTH; ?>:</strong></td>
                                                     <td  style="background:#eee" align="right"><?php echo $currencies->format($turnover['this_month']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#ccc"><strong><?php echo TURNOVER_LAST_MONTH; ?>:</strong></td>
                                                     <td style="background:#ccc" align="right"><?php echo $currencies->format($turnover['last_month']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#ccc"><strong><?php echo TURNOVER_LAST_MONTH_PAID; ?>:</strong></td>
                                                     <td style="background:#ccc" align="right"><?php echo $currencies->format($turnover['last_month_paid']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#666; color:#FFF"><strong><?php echo TOTAL_TURNOVER; ?>:</strong></td>
                                                     <td style="background:#666; color:#FFF" align="right"><?php echo $currencies->format($turnover['total']); ?></td>
                                            </tr>
                               </table></td>
    Nur fehlt mir irgendwie der Durchblick, wie genau ich das jetzt mit dem Jahr erweitern kann!?

    Des weiteren müssten dann natürlich auch noch die language-Dateien angepasst werden:

    Code: PHP  [Auswählen]
    define('TURNOVER_THIS_YEAR', 'aktuelles Jahr');
    Könnte man das nicht noch erweitern? Denn die Statistik ist schonmal sehr praktisch, aber mit dem Jahr einfach noch besser. Dann kann ich mir den ständigen Weg in die Umsatzstatistik sparen ;)

    Danke & Grüße
    Voodoo



    Linkback: https://www.modified-shop.org/forum/index.php?topic=10676.0

    voodoopupp

    • Fördermitglied
    • Beiträge: 1.854
    • Geschlecht:
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #1 am: 15. Januar 2011, 08:33:05
    Okay, hab dann mal ein wenig gebastelt
    [ Für Gäste sind keine Dateianhänge sichtbar ]

    in der admin/start.php:
    suche

    Code: PHP  [Auswählen]
    round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1, ot.value, null)), 0), 2) last_month_paid,
    füge danach ein

    Code: PHP  [Auswählen]
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date), ot.value, null)), 0), 2) this_year,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year), ot.value, null)), 0), 2) last_year,
    suche

    Code: PHP  [Auswählen]
                                            <tr>
                                                     <td style="background:#ccc"><strong><?php echo TURNOVER_LAST_MONTH_PAID; ?>:</strong></td>
                                                     <td style="background:#ccc" align="right"><?php echo $currencies->format($turnover['last_month_paid']); ?></td>
                                            </tr>
    füge danach ein

    Code: PHP  [Auswählen]
                                            <tr>
                                                     <td style="background:#888; color:#FFF"><strong><?php echo TURNOVER_THIS_YEAR; ?>:</strong></td>
                                                     <td style="background:#888; color:#FFF" align="right"><?php echo $currencies->format($turnover['this_year']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#888; color:#FFF"><strong><?php echo TURNOVER_LAST_YEAR; ?>:</strong></td>
                                                     <td style="background:#888; color:#FFF" align="right"><?php echo $currencies->format($turnover['last_year']); ?></td>
                                            </tr>
    lang/german/admin/start.php & lang/english/admin/start.php (und natürlich jede weitere Spracheinstellung):
    suche

    Code: PHP  [Auswählen]
    define('TURNOVER_LAST_MONTH_PAID', 'last month (paid)');
    füge danach ein

    Code: PHP  [Auswählen]
    define('TURNOVER_THIS_YEAR', 'aktuelles Jahr');
    define('TURNOVER_LAST_YEAR', 'letztes Jahr');
    Somit ist erstmal eine Umsatzstatistik für das Jahr enthalten. Das einzige was mich wirklich stutzig macht ist, dass die Statistik was anderes ausspuckt als die Umsatzstatistik. Wenn ich dort 01.01.10 - 31.12.10 einstelle bekomme ich leicht andere Zahlen - woran kann das liegen? :?

    Grüße
    Voodoo

    Clever

    • Schreiberling
    • Beiträge: 257
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #2 am: 02. März 2011, 13:47:23
    am Versand
    bei der Umsatzstatistik ist es exkl. Versand auf der Startseite inkl.

    Mich persönlich störte es immer, dass "Stornos" weiter in dieser Statistik wuselten.
    Darum hab ich das mal ergänzt:

    Code: PHP  [Auswählen]
    $turnover_query = xtc_db_query('select
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 0 day and o.orders_status <> 9, ot.value, null)), 0), 2) today,
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 1 day and o.orders_status <> 9, ot.value, null)), 0), 2) yesterday,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 0 month) and o.orders_status <> 9, ot.value, null)), 0), 2) this_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month), ot.value, null)), 0), 2) last_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1 and o.orders_status <> 9, ot.value, null)), 0), 2) last_month_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 0 year) and o.orders_status <> 9, ot.value, null)), 0), 2) this_year,
    round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year) and o.orders_status <> 9, ot.value, null)), 0), 2) last_year,
      round(coalesce(sum(ot.value), 0), 2) total
      from '
    . TABLE_ORDERS . ' o
      join '
    . TABLE_ORDERS_TOTAL . ' ot on ot.orders_id = o.orders_id
      where ot.class = \'ot_total\''
    );
    $turnover = xtc_db_fetch_array($turnover_query);
    ?>
     
    dabei ist die Ziffer 9 UNSRE ID für Storno - da muß natürlich jeder in seiner DB unter orders_status die entsprechende orders_status_id auslesen und entsprechend abändern.

    speedy

    • Viel Schreiber
    • Beiträge: 3.214
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #3 am: 02. März 2011, 14:07:08
    Würde vorschlagen das zu übernehmen, vielen Dank an voodoopupp.

    Tomcraft

    • modified Team
    • Gravatar
    • Beiträge: 46.204
    • Geschlecht:
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #4 am: 02. März 2011, 17:37:27
    Naja, es ist eben ein wenig schwer, da die Bestellstati von euch ja immer unterschiedliche IDs haben. Man müsste das, wenn überhaupt, mit einer Einstellung im Adminbereich versehen, oder zumindest den Status "storniert" per default mit einfügen.

    Aber auch dann ist es problematisch, denn viele haben mehrere "storniert-Stati", beispielsweise "PayPal storniert", "Sofortüberweisung storniert", etc.

    Grüße

    Torsten

    Schreibwarendiele

    • Frisch an Board
    • Beiträge: 67
    • Geschlecht:
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #5 am: 02. März 2011, 18:43:12
    [...]
    Aber auch dann ist es problematisch, denn viele haben mehrere "storniert-Stati", beispielsweise "PayPal storniert", "Sofortüberweisung storniert", etc.
    [...]

    Sonderfälle gibt es immer, aber einen Status>>Storniert<<kann wohl so ziemlich jeder gebrauchen, wenn der als Standard integriert würde, könnte man das schon in der Statistik heraus filtern. Wer mehr Storno-Varianten hat, muss es dann halt anpassen.

    Viel interessanter fände ich aber den Vergleich aktueller Monat/Jahr mit dem entsprechenden Zeitraum des Vorjahresmonats / Vorjahres.

    speedy

    • Viel Schreiber
    • Beiträge: 3.214
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #6 am: 02. März 2011, 18:53:39
    Hat mich auch schon immer gewundert und gestört, warum es werkseitig keinen Status "storniert" gibt.

    Tomcraft

    • modified Team
    • Gravatar
    • Beiträge: 46.204
    • Geschlecht:
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #7 am: 02. März 2011, 20:03:32
    So, das hat mir r1816 nun ein Ende. :)

    Grüße

    Torsten

    Clever

    • Schreiberling
    • Beiträge: 257
    Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #8 am: 03. März 2011, 12:52:06
    Naja, es ist eben ein wenig schwer, da die Bestellstati von euch ja immer unterschiedliche IDs haben. Man müsste das, wenn überhaupt, mit einer Einstellung im Adminbereich versehen, oder zumindest den Status "storniert" per default mit einfügen.

    Aber auch dann ist es problematisch, denn viele haben mehrere "storniert-Stati", beispielsweise "PayPal storniert", "Sofortüberweisung storniert", etc.

    Grüße

    Torsten

    naja... man kann ja unendliche "and" aneinander ketten...

    Code: PHP  [Auswählen]
     round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1 and o.orders_status <> 9 and o.orders_status <> 10 and o.orders_status <> 19 and o.orders_status <> 20, ot.value, null)), 0), 2) last_month_paid,
    natürlich wäre es schöner, wenn man dies im Backend festlegen kann.
    bei mir sieht es derzeit so aus:

    Code: PHP  [Auswählen]
    // turnover
    $turnover_query = xtc_db_query('select
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 0 day and o.orders_status <> 9, ot.value, null)), 0), 2) today,
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 1 day and o.orders_status <> 9, ot.value, null)), 0), 2) yesterday,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 0 month) and o.orders_status <> 9, ot.value, null)), 0), 2) this_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month), ot.value, null)), 0), 2) last_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 4 and o.orders_status <> 5 and o.orders_status <> 6 and o.orders_status <> 7 and o.orders_status <> 8 and o.orders_status <> 10 and o.orders_status <> 11 and o.orders_status <> 12 and o.orders_status <> 16 and o.orders_status <> 19 and o.orders_status <> 20 and o.orders_status <> 22 and o.orders_status <> 23 and o.orders_status <> 9 and o.orders_status <> 17 and o.orders_status <> 18, ot.value, null)), 0), 2) last_month_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 0 year) and o.orders_status <> 9 and o.orders_status <> 23, ot.value, null)), 0), 2) this_year,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 0 year) and o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 4 and o.orders_status <> 5 and o.orders_status <> 6 and o.orders_status <> 7 and o.orders_status <> 8 and o.orders_status <> 11 and o.orders_status <> 12 and o.orders_status <> 16 and o.orders_status <> 19 and o.orders_status <> 20 and o.orders_status <> 22 and o.orders_status <> 23 and o.orders_status <> 9 and o.orders_status <> 17 and o.orders_status <> 18, ot.value, null)), 0), 2) this_year_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year) and o.orders_status <> 9 and o.orders_status <> 23 and o.orders_status <> 11 and o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 7 and o.orders_status <> 8, ot.value, null)), 0), 2) last_year,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year) and o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 4 and o.orders_status <> 5 and o.orders_status <> 6 and o.orders_status <> 7 and o.orders_status <> 8 and o.orders_status <> 10 and o.orders_status <> 11 and o.orders_status <> 12 and o.orders_status <> 16 and o.orders_status <> 19 and o.orders_status <> 20 and o.orders_status <> 22 and o.orders_status <> 23 and o.orders_status <> 9 and o.orders_status <> 17 and o.orders_status <> 18, ot.value, null)), 0), 2) last_year_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date) - o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 4 and o.orders_status <> 5 and o.orders_status <> 6 and o.orders_status <> 7 and o.orders_status <> 8 and o.orders_status <> 10 and o.orders_status <> 11 and o.orders_status <> 12 and o.orders_status <> 16 and o.orders_status <> 19 and o.orders_status <> 20 and o.orders_status <> 22 and o.orders_status <> 23 and o.orders_status <> 9 and o.orders_status <> 17 and o.orders_status <> 18, ot.value, null)), 0), 2) total_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date) - o.orders_status <> 1 and o.orders_status <> 2 and o.orders_status <> 3 and o.orders_status <> 4 and o.orders_status <> 5 and o.orders_status <> 6 and o.orders_status <> 7 and o.orders_status <> 10 and o.orders_status <> 12 and o.orders_status <> 16 and o.orders_status <> 17 and o.orders_status <> 18 and o.orders_status <> 19 and o.orders_status <> 20 and o.orders_status <> 22, ot.value, null)), 0), 2) total_storno,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 0 year) and o.orders_status <> 3 and o.orders_status <> 8 and o.orders_status <> 9 and o.orders_status <> 11 and o.orders_status <> 23, ot.value, null)), 0), 2) total_offen,
      round(coalesce(sum(ot.value), 0), 2) total
      from '
    . TABLE_ORDERS . ' o
      join '
    . TABLE_ORDERS_TOTAL . ' ot on ot.orders_id = o.orders_id
      where ot.class = \'ot_total\''
    );
    $turnover = xtc_db_fetch_array($turnover_query);
     
    und entsprechend

    Code: PHP  [Auswählen]
                               <!--  BOF START INFOS STATISTIK -->
                               <table width="100%" border="0" cellspacing="0">
             <tr>
                      <td width="25%" valign="top"><table width="100%" border="0">
                                            <tr>
                                                     <td style="background:#eee"><strong><?php echo TURNOVER_TODAY; ?>:</strong></td>
                                                     <td  style="background:#eee" align="right"><?php echo $currencies->format($turnover['today']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#fff"><strong><?php echo TURNOVER_YESTERDAY; ?>:</strong></td>
                                                     <td style="background:#fff" align="right"><?php echo $currencies->format($turnover['yesterday']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#eee"><strong><?php echo TURNOVER_THIS_MONTH; ?>:</strong></td>
                                                     <td  style="background:#eee" align="right"><?php echo $currencies->format($turnover['this_month']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#ccc"><strong><?php echo TURNOVER_LAST_MONTH; ?>:</strong></td>
                                                     <td style="background:#ccc" align="right"><?php echo $currencies->format($turnover['last_month']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#ccc"><strong><?php echo TURNOVER_LAST_MONTH_PAID; ?>:</strong></td>
                                                     <td style="background:#ccc" align="right"><?php echo $currencies->format($turnover['last_month_paid']); ?></td>
                                            </tr>
                                            <tr>
         <td style="background:#888; color:#FFF"><strong><?php echo TURNOVER_THIS_YEAR; ?>:</strong></td>
         <td style="background:#888; color:#FFF" align="right"><?php echo $currencies->format($turnover['this_year']); ?></td>
    </tr>
                                            <tr>
         <td style="background:#CCC; color:#000"><strong><?php echo TURNOVER_THIS_YEAR_PAID; ?>:</strong></td>
         <td style="background:#CCC; color:#000" align="right"><?php echo $currencies->format($turnover['this_year_paid']); ?></td>
    </tr>
    <tr>
         <td style="background:#888; color:#FFF"><strong><?php echo TURNOVER_LAST_YEAR; ?>:</strong></td>
         <td style="background:#888; color:#FFF" align="right"><?php echo $currencies->format($turnover['last_year']); ?></td>
    </tr>
    <tr>
         <td style="background:#CCC; color:#008000"><strong><?php echo TURNOVER_LAST_YEAR_PAID; ?>:</strong></td>
         <td style="background:#CCC; color:#008000" align="right"><?php echo $currencies->format($turnover['last_year_paid']); ?></td>
    </tr>
    <tr>
                                                     <td style="background:#FFF; color:#008000"><strong><?php echo TOTAL_TURNOVER_PAID; ?>:</strong></td>
                                                     <td style="background:#FFF; color:#008000" align="right"><?php echo $currencies->format($turnover['total_paid']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#FF8080; color:#000"><strong><?php echo TURNOVER_STORNO; ?>:</strong></td>
                                                     <td style="background:#FF8080; color:#000" align="right"><?php echo $currencies->format($turnover['total_storno']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#90EE90; color:#000"><strong><?php echo TURNOVER_OFFEN; ?>:</strong></td>
                                                     <td style="background:#90EE90; color:#000" align="right"><?php echo $currencies->format($turnover['total_offen']); ?></td>
                                            </tr>
                                            <tr>
                                                     <td style="background:#666; color:#FFF"><strong><?php echo TOTAL_TURNOVER; ?>:</strong></td>
                                                     <td style="background:#666; color:#FFF" align="right"><?php echo $currencies->format($turnover['total']); ?></td>
                                            </tr>
                               </table></td>
                      <td width="25%" valign="top"><table width="100%">
     
    Dabei kommen die Summen nicht ganz hin :-( und mit Rundungsfehlern sind so hohe Differenzen nicht erklärbar.
    Aber im Prinzip schon Hilfreich für uns.
    Vielleicht hat ja mal jemand lust da was tolles zu zaubern. ;-)

    Simon

    • Viel Schreiber
    • Beiträge: 1.358
    Re: Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #9 am: 07. November 2012, 00:02:29
    Somit ist erstmal eine Umsatzstatistik für das Jahr enthalten. Das einzige was mich wirklich stutzig macht ist, dass die Statistik was anderes ausspuckt als die Umsatzstatistik. Wenn ich dort 01.01.10 - 31.12.10 einstelle bekomme ich leicht andere Zahlen - woran kann das liegen?

    Habe gerade die Erweiterung integriert und finde es prima.  :thx: dafür.
    Die Abweichung bei den Statistiken habe ich auch festgestellt, woran liegt das ?

    teekilla

    • Mitglied
    • Beiträge: 121
    • Geschlecht:
    Re: Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #10 am: 10. Februar 2014, 11:09:25
    Ist es eigentlich normal, dass nur die letzten 2 Jahre angezeigt werden können?

    Und wenn, ist es möglich, dass zu ändern?

    online-beobachter

    • Schreiberling
    • Beiträge: 387
    Re: Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #11 am: 21. Januar 2016, 20:00:27
    Weiß jemand was man ändern muß wenn man z.B. den Umsatz nach einem Land filtern will? Damit man die Lieferschwelle für ein Land überwachen kann.

    In der Tabelle orders müsste man ja einschränken können auf delivery_country = 'Österreich'

    Code: PHP  [Auswählen]
    // turnover
    $turnover_query = xtc_db_query('select
      round(coalesce(sum(if(date(o.date_purchased) = current_date, ot.value, null)), 0), 2) today,
      round(coalesce(sum(if(date(o.date_purchased) = current_date - interval 1 day, ot.value, null)), 0), 2) yesterday,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date), ot.value, null)), 0), 2) this_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month), ot.value, null)), 0), 2) last_month,
      round(coalesce(sum(if(extract(year_month from o.date_purchased) = extract(year_month from current_date - interval 1 year_month) and o.orders_status <> 1, ot.value, null)), 0), 2) last_month_paid,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date), ot.value, null)), 0), 2) this_year,
      round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year), ot.value, null)), 0), 2) last_year,
      round(coalesce(sum(ot.value), 0), 2) total  
      from '
    . TABLE_ORDERS . ' o
      join '
    . TABLE_ORDERS_TOTAL . ' ot on ot.orders_id = o.orders_id
      where ot.class = \'ot_total\''
    );
    $turnover = xtc_db_fetch_array($turnover_query);       

    Danke

    filib

    • Neu im Forum
    • Beiträge: 11
    Re: Umsatzanzeige im Admin erweitern mit Jahresumsatz?
    Antwort #12 am: 31. August 2021, 10:39:10
    Umsatzstatistik mit Länderabhängigkeit
    Zwar ein paar Jahre später, aber vermutlich bis heute nicht ganz uninteressant für jene, die nicht ganz so code-affin sind (da zähle ich mich auch dazu  :-D ).
    Ich habe eine neue turnoverAT Abfrage in die admin/start.php gebaut und als weitere Abhängigkeit das customer_country Austria eingefügt (in gekürzter Fassung mit Gesamtumsatz aus diesem und vergangenem Jahr):

    Code: PHP  [Auswählen]
    // turnoverAT
    $where = '';
    if (ORDER_STATUSES_FOR_SALES_STATISTICS != '') {
      $status_array = explode(',', ORDER_STATUSES_FOR_SALES_STATISTICS);
      $where = " AND o.orders_status IN ('".implode("','", $status_array)."') AND customers_country = 'Austria' ";
    }
    $turnoverAT_query = xtc_db_query("SELECT round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date - interval 1 year), ot.value/o.currency_value, null)), 0), 2) last_year,
                                            round(coalesce(sum(if(extract(year from o.date_purchased) = extract(year from current_date), ot.value/o.currency_value, null)), 0), 2) this_year
                                      FROM "
    . TABLE_ORDERS . " o
                                      JOIN "
    . TABLE_ORDERS_TOTAL . " ot
                                           ON ot.orders_id = o.orders_id
                                     WHERE ot.class = 'ot_total'
                                           "
    .$where);
    $turnoverAT = xtc_db_fetch_array($turnoverAT_query);
     

    Das lässt sich dann an entsprechender Stelle wie auch die bestehenden turnover Werte ausgeben:

    Code: PHP  [Auswählen]
    echo $currencies->format($turnoverAT['this_year']);
     
    1 Antworten
    2031 Aufrufe
    10. Oktober 2010, 19:53:19 von Tomcraft
    4 Antworten
    3475 Aufrufe
    25. September 2011, 00:49:03 von h-h-h
    10 Antworten
    8661 Aufrufe
    30. Juli 2017, 13:19:35 von Astwert
    2 Antworten
    1197 Aufrufe
    24. Januar 2019, 22:01:41 von dannyjung