[simpleinvoices commit] r1645 - branches/nextrelease/lang/en-gb branches/nextrelease/modules/reports branches/nextrelease...

32 views
Skip to first unread message

codesite...@google.com

unread,
May 13, 2008, 8:28:13 AM5/13/08
to simpleinv...@googlegroups.com
Author: linuxppc
Date: Tue May 13 05:26:54 2008
New Revision: 1645

Added:
branches/nextrelease/modules/reports/report_sales_by_periods.php
branches/nextrelease/templates/default/reports/report_sales_by_periods.tpl
trunk/modules/reports/report_sales_by_periods.php
trunk/templates/default/reports/report_sales_by_periods.tpl
Modified:
branches/nextrelease/lang/en-gb/lang.php
branches/nextrelease/templates/default/menu.tpl
trunk/lang/da/info.xml
trunk/lang/en-gb/lang.php
trunk/lang/lang_check.php
trunk/lang/lang_check.txt
trunk/templates/default/menu.tpl

Log:
add new sales report in - month by month per year

Modified: branches/nextrelease/lang/en-gb/lang.php
==============================================================================
--- branches/nextrelease/lang/en-gb/lang.php (original)
+++ branches/nextrelease/lang/en-gb/lang.php Tue May 13 05:26:54 2008
@@ -189,6 +189,7 @@
$LANG['mandatory_fields'] = "All fields are mandatory";//1
$LANG['mobile_phone'] = "Mobile Phone";//1
$LANG['mobile_short'] = "Mob.";//1
+$LANG['monthly_sales_per_year'] = "Monthly Sales and Payments per year";//1
$LANG['new_invoice_consulting'] = "New Invoices - Consulting";//1
$LANG['new_invoice_itemised'] = "New Invoices - Itemised";//1
$LANG['new_invoice_total'] = "New Invoices - Total";//1

Added: branches/nextrelease/modules/reports/report_sales_by_periods.php
==============================================================================
--- (empty file)
+++ branches/nextrelease/modules/reports/report_sales_by_periods.php Tue May 13 05:26:54 2008
@@ -0,0 +1,121 @@
+<?php
+
+/*
+* Script: report_sales_by_period.php
+* Sales reports by period add page
+*
+* Authors:
+* Justin Kelly
+*
+* Last edited:
+* 2008-05-13
+*
+* License:
+* GPL v3
+*
+* Website:
+* http://www.simpleinvoices.org
+*/
+
+checkLogin();
+
+
+/*
+* Get earliest invoice date
+*/
+$sql="select min(date) as date from ".TB_PREFIX."invoices";
+$invoice_start = mysqlQuery($sql);
+$invoice_start_array= mysql_fetch_array($invoice_start);
+$first_invoice_year = date('Y', strtotime( $invoice_start_array['date'] ) );
+/*
+* Get total for each month of each year from first invoice
+*/
+$this_year= date('Y');
+$year = $first_invoice_year ;
+$years[]=$first_invoice_year ;
+/*
+* loop for each year
+*/
+while ( $year <= $this_year )
+{
+ /*
+ * loop for each month
+ */
+ $month = 01;
+ while ($month <= 12)
+ {
+ //make month nice for mysql - accounts table doesnt like it if not 08 etc..
+ if ( $month < 10 )
+ {
+ $month="0".$month;
+ };
+ /*
+ * Sales
+ */
+ $total_month_sales_sql = "select sum(ii.total) as month_total from ".TB_PREFIX."invoice_items ii, si_invoices i where i.id = ii.invoice_id AND i.date like '$year-$month%'";
+ $total_month_sales = mysqlQuery($total_month_sales_sql);
+ $total_month_sales_array= mysql_fetch_array($total_month_sales);
+ $total_sales[$year][$month] = $total_month_sales_array['month_total'];
+ if ($total_sales[$year][$month] == "" )
+ {
+ $total_sales[$year][$month] = "-";
+ }
+
+ /*
+ * Payment
+ */
+ $total_month_payments_sql = " select sum(ac_amount) as month_total_payments from ".TB_PREFIX."account_payments where ac_date like '$year-$month%'";
+ $total_month_payments = mysqlQuery($total_month_payments_sql);
+ $total_month_payments_array= mysql_fetch_array($total_month_payments);
+ $total_payments[$year][$month] = $total_month_payments_array['month_total_payments'];
+ if ($total_payments[$year][$month] == "" )
+ {
+ $total_payments[$year][$month] = "-";
+ }
+ $month++;
+ }
+ /*
+ * Sales
+ */
+ $total_year_sales_sql = "select sum(ii.total) as year_total from ".TB_PREFIX."invoice_items ii, si_invoices i where i.id = ii.invoice_id AND i.date like '$year%'";
+ $total_year_sales = mysqlQuery($total_year_sales_sql);
+ $total_year_sales_array= mysql_fetch_array($total_year_sales);
+ $total_sales[$year]['Total'] = $total_year_sales_array['year_total'];
+ if ($total_sales[$year]['Total'] == "" )
+ {
+ $total_sales[$year]['Total'] = "-";
+ }
+
+ /*
+ * Payment
+ */
+ $total_year_payments_sql = " select sum(ac_amount) as year_total_payments from ".TB_PREFIX."account_payments where ac_date like '$year%'";
+ $total_year_payments = mysqlQuery($total_year_payments_sql);
+ $total_year_payments_array= mysql_fetch_array($total_year_payments);
+ $total_payments[$year]['Total'] = $total_year_payments_array['year_total_payments'];
+ if ($total_payments[$year]['Total'] == "" )
+ {
+ $total_payments[$year]['Total'] = "-";
+ }
+
+ $years[]=$year ;
+ $year++;
+}
+/*
+echo "Total Sales<pre>";
+print_r($total_sales);
+echo "</pre><br>Total Payments<pre>";
+print_r($total_payments);
+echo "</pre>";
+*/
+$pageActive = "reports";
+
+$smarty->assign('pageActive', $pageActive);
+$smarty->assign('total_sales', $total_sales);
+$smarty->assign('total_payments', $total_payments);
+//$years = array(2006,2007,2008);
+$years = array_reverse($years);
+$smarty->assign('years', $years);
+
+
+?>

Modified: branches/nextrelease/templates/default/menu.tpl
==============================================================================
--- branches/nextrelease/templates/default/menu.tpl (original)
+++ branches/nextrelease/templates/default/menu.tpl Tue May 13 05:26:54 2008
@@ -40,6 +40,7 @@
<li><a href="index.php?module=reports&view=report_sales_total">{$LANG.sales} +</a>
<ul>
<li><a href="index.php?module=reports&view=report_sales_total">{$LANG.total_sales}</a></li>
+ <li><a href="index.php?module=reports&view=report_sales_by_period">{$LANG.monthly_sales_per_year}</a></li>
</ul>
</li>
<li><a href="index.php?module=reports&view=report_sales_customers_total">{$LANG.sales_by_customers} +</a>

Added: branches/nextrelease/templates/default/reports/report_sales_by_periods.tpl
==============================================================================
--- (empty file)
+++ branches/nextrelease/templates/default/reports/report_sales_by_periods.tpl Tue May 13 05:26:54 2008
@@ -0,0 +1,22 @@
+
+
+<div id="top"><h3>{$LANG.monthly_sales_per_year}</h3></div>
+ <hr />
+
+<table width="100%">
+ {foreach item=year from=$years}
+ <tr>
+ <td><b>{$year}</b></td>
+ <tr>
+ <td></td><td>Month:<br>Sales:<br>Payments:</td>
+ {foreach key=key item=item_sales from=$total_sales.$year}
+ <td>{$key}<br>{$item_sales}<br>{$total_payments.$year.$key} </td>
+ {/foreach}
+
+ </tr>
+ {/foreach}
+ </table>
+
+
+
+

Modified: trunk/lang/da/info.xml
==============================================================================
--- trunk/lang/da/info.xml (original)
+++ trunk/lang/da/info.xml Tue May 13 05:26:54 2008
@@ -5,8 +5,6 @@
<englishname>Danish</englishname>
<version>1.0.0</version>
<creationDate>2004-11-10</creationDate>
- <author>Claus M�lgaard Nielsen</author>
- <authorEmail>cl...@cmn-service.dk</authorEmail>
- <author> Michael Larsen</author>
- <authorEmail></authorEmail>
+ <author>Claus M�lgaard Nielsen, Michael Larsen</author>
+ <authorEmail>cl...@cmn-service.dk,-</authorEmail>
</langfile>

Modified: trunk/lang/en-gb/lang.php
==============================================================================
--- trunk/lang/en-gb/lang.php (original)
+++ trunk/lang/en-gb/lang.php Tue May 13 05:26:54 2008
@@ -189,6 +189,7 @@
$LANG['mandatory_fields'] = "All fields are mandatory";//1
$LANG['mobile_phone'] = "Mobile Phone";//1
$LANG['mobile_short'] = "Mob.";//1
+$LANG['monthly_sales_per_year'] = "Monthly Sales and Payments per year";//1
$LANG['new_invoice_consulting'] = "New Invoices - Consulting";//1
$LANG['new_invoice_itemised'] = "New Invoices - Itemised";//1
$LANG['new_invoice_total'] = "New Invoices - Total";//1

Modified: trunk/lang/lang_check.php
==============================================================================
--- trunk/lang/lang_check.php (original)
+++ trunk/lang/lang_check.php Tue May 13 05:26:54 2008
@@ -92,17 +92,18 @@


// Header
-print str_repeat("=", 90);
+print str_repeat("=", 108);
print "\n";
print sprintf("%-10s", 'Lang. Code') . " | ";
print sprintf("%-15s", 'Lang. name') . " | ";
+print sprintf("%-15s", 'English name') . " | ";
print sprintf("%-11s", 'New strings') . " | ";
print sprintf("%13s", 'Total strings') . " | ";
print sprintf("%16s", 'Total translated') . " | ";
print sprintf("%8s", '% Done') . " | ";
//print sprintf("%10s", 'Authors');
print "\n";
-print str_repeat("=", 90);
+print str_repeat("=", 108);
print "\n";


@@ -145,6 +146,7 @@

print sprintf("%-10s", $lang_code) . " | ";
print sprintf("%-15s", utf8_decode($xml->name)) . " | ";
+ print sprintf("%-15s", utf8_decode($xml->englishname)) . " | ";
print sprintf("%-11s", $new_strings) . " | ";
print sprintf("%13s", $count[0]) . " | ";
print sprintf("%16s", $count[1]) . " | ";
@@ -154,6 +156,6 @@
}

// Footer
-print str_repeat("-", 90);
+print str_repeat("-", 108);
print "\n";
?>

Modified: trunk/lang/lang_check.txt
==============================================================================
--- trunk/lang/lang_check.txt (original)
+++ trunk/lang/lang_check.txt Tue May 13 05:26:54 2008
@@ -1,23 +1,23 @@
-==========================================================================================
-Lang. Code | Lang. name | New strings | Total strings | Total translated | % Done |
-==========================================================================================
-ca | Catala | All Done | 313 | 298 | 95.21% |
-cs | Cestina | All Done | 313 | 261 | 83.39% |
-da | Dansk | All Done | 313 | 310 | 99.04% |
-de | Deutsch | All Done | 313 | 313 | 100.00% |
-de-ch | Schwizerd�tsch | All Done | 313 | 259 | 82.75% |
-en-gb | English | All Done | 313 | 313 | 100.00% |
-es | Castellano | All Done | 313 | 310 | 99.04% |
-fi | Suomi | All Done | 313 | 296 | 94.57% |
-fr | Fran�ais | All Done | 313 | 291 | 92.97% |
-gl | Galego | All Done | 313 | 205 | 65.50% |
-gr | Greek | All Done | 313 | 313 | 100.00% |
-ls | Sloven??ina | All Done | 313 | 297 | 94.89% |
-lv | Latviesu | All Done | 313 | 165 | 52.72% |
-nl | Nederland | All Done | 313 | 313 | 100.00% |
-no-nb | Norsk NB | All Done | 313 | 300 | 95.85% |
-pt | Portugues | All Done | 313 | 313 | 100.00% |
-ro | Romana | All Done | 313 | 300 | 95.85% |
-sk | Slovensky | All Done | 313 | 261 | 83.39% |
-sq | Shqip | All Done | 313 | 313 | 100.00% |
-------------------------------------------------------------------------------------------
+============================================================================================================
+Lang. Code | Lang. name | English name | New strings | Total strings | Total translated | % Done |
+============================================================================================================
+ca | Catala | Catalan | 1 | 313 | 298 | 95.21% |
+cs | Cestina | Czech | 1 | 313 | 261 | 83.39% |
+da | Dansk | Danish | 1 | 313 | 310 | 99.04% |
+de | Deutsch | German | 1 | 313 | 313 | 100.00% |
+de-ch | Schwizerd�tsch | Swiss German | 1 | 313 | 259 | 82.75% |
+en-gb | English | UK | All Done | 314 | 314 | 100.00% |
+es | Castellano | Spanish | 1 | 313 | 310 | 99.04% |
+fi | Suomi | Finnish | 1 | 313 | 296 | 94.57% |
+fr | Fran�ais | French | 1 | 313 | 291 | 92.97% |
+gl | Galego | Galician | 1 | 313 | 205 | 65.50% |
+gr | Greek | GR | 1 | 313 | 313 | 100.00% |
+ls | Sloven??ina | Slovenian | 1 | 313 | 297 | 94.89% |
+lv | Latviesu | Latvian | 1 | 313 | 165 | 52.72% |
+nl | Nederland | Dutch | 1 | 313 | 313 | 100.00% |
+no-nb | Norsk NB | Norwegian NB | 1 | 313 | 300 | 95.85% |
+pt | Portugues | Portuguese | 1 | 313 | 313 | 100.00% |
+ro | Romana | Romanian | 1 | 313 | 300 | 95.85% |
+sk | Slovensky | Slovak | 1 | 313 | 261 | 83.39% |
+sq | Shqip | SQ | 1 | 313 | 313 | 100.00% |
+------------------------------------------------------------------------------------------------------------

Added: trunk/modules/reports/report_sales_by_periods.php
==============================================================================
--- (empty file)
+++ trunk/modules/reports/report_sales_by_periods.php Tue May 13 05:26:54 2008
@@ -0,0 +1,121 @@
+<?php
+
+/*
+* Script: report_sales_by_period.php
+* Sales reports by period add page
+*
+* Authors:
+* Justin Kelly
+*
+* Last edited:
+* 2008-05-13
+*
+* License:
+* GPL v3
+*
+* Website:
+* http://www.simpleinvoices.org
+*/
+
+checkLogin();
+
+
+/*
+* Get earliest invoice date
+*/
+$sql="select min(date) as date from ".TB_PREFIX."invoices";
+$invoice_start = mysqlQuery($sql);
+$invoice_start_array= mysql_fetch_array($invoice_start);
+$first_invoice_year = date('Y', strtotime( $invoice_start_array['date'] ) );
+/*
+* Get total for each month of each year from first invoice
+*/
+$this_year= date('Y');
+$year = $first_invoice_year ;
+$years[]=$first_invoice_year ;
+/*
+* loop for each year
+*/
+while ( $year <= $this_year )
+{
+ /*
+ * loop for each month
+ */
+ $month = 01;
+ while ($month <= 12)
+ {
+ //make month nice for mysql - accounts table doesnt like it if not 08 etc..
+ if ( $month < 10 )
+ {
+ $month="0".$month;
+ };
+ /*
+ * Sales
+ */
+ $total_month_sales_sql = "select sum(ii.total) as month_total from ".TB_PREFIX."invoice_items ii, si_invoices i where i.id = ii.invoice_id AND i.date like '$year-$month%'";
+ $total_month_sales = mysqlQuery($total_month_sales_sql);
+ $total_month_sales_array= mysql_fetch_array($total_month_sales);
+ $total_sales[$year][$month] = $total_month_sales_array['month_total'];
+ if ($total_sales[$year][$month] == "" )
+ {
+ $total_sales[$year][$month] = "-";
+ }
+
+ /*
+ * Payment
+ */
+ $total_month_payments_sql = " select sum(ac_amount) as month_total_payments from ".TB_PREFIX."account_payments where ac_date like '$year-$month%'";
+ $total_month_payments = mysqlQuery($total_month_payments_sql);
+ $total_month_payments_array= mysql_fetch_array($total_month_payments);
+ $total_payments[$year][$month] = $total_month_payments_array['month_total_payments'];
+ if ($total_payments[$year][$month] == "" )
+ {
+ $total_payments[$year][$month] = "-";
+ }
+ $month++;
+ }
+ /*
+ * Sales
+ */
+ $total_year_sales_sql = "select sum(ii.total) as year_total from ".TB_PREFIX."invoice_items ii, si_invoices i where i.id = ii.invoice_id AND i.date like '$year%'";
+ $total_year_sales = mysqlQuery($total_year_sales_sql);
+ $total_year_sales_array= mysql_fetch_array($total_year_sales);
+ $total_sales[$year]['Total'] = $total_year_sales_array['year_total'];
+ if ($total_sales[$year]['Total'] == "" )
+ {
+ $total_sales[$year]['Total'] = "-";
+ }
+
+ /*
+ * Payment
+ */
+ $total_year_payments_sql = " select sum(ac_amount) as year_total_payments from ".TB_PREFIX."account_payments where ac_date like '$year%'";
+ $total_year_payments = mysqlQuery($total_year_payments_sql);
+ $total_year_payments_array= mysql_fetch_array($total_year_payments);
+ $total_payments[$year]['Total'] = $total_year_payments_array['year_total_payments'];
+ if ($total_payments[$year]['Total'] == "" )
+ {
+ $total_payments[$year]['Total'] = "-";
+ }
+
+ $years[]=$year ;
+ $year++;
+}
+/*
+echo "Total Sales<pre>";
+print_r($total_sales);
+echo "</pre><br>Total Payments<pre>";
+print_r($total_payments);
+echo "</pre>";
+*/
+$pageActive = "reports";
+
+$smarty->assign('pageActive', $pageActive);
+$smarty->assign('total_sales', $total_sales);
+$smarty->assign('total_payments', $total_payments);
+//$years = array(2006,2007,2008);
+$years = array_reverse($years);
+$smarty->assign('years', $years);
+
+
+?>

Modified: trunk/templates/default/menu.tpl
==============================================================================
--- trunk/templates/default/menu.tpl (original)
+++ trunk/templates/default/menu.tpl Tue May 13 05:26:54 2008
@@ -43,6 +43,7 @@
<li><a href="index.php?module=reports&view=report_sales_total">{$LANG.sales} +</a>
<ul>
<li><a href="index.php?module=reports&view=report_sales_total">{$LANG.total_sales}</a></li>
+ <li><a href="index.php?module=reports&view=report_sales_by_period">{$LANG.monthly_sales_per_year}</a></li>
</ul>
</li>
<li><a href="index.php?module=reports&view=report_sales_customers_total">{$LANG.sales_by_customers} +</a>

Added: trunk/templates/default/reports/report_sales_by_periods.tpl
==============================================================================
--- (empty file)
+++ trunk/templates/default/reports/report_sales_by_periods.tpl Tue May 13 05:26:54 2008
@@ -0,0 +1,22 @@
+
+
+<div id="top"><h3>{$LANG.monthly_sales_per_year}</h3></div>
+ <hr />
+
+<table width="100%">
+ {foreach item=year from=$years}
+ <tr>
+ <td><b>{$year}</b></td>
+ <tr>
+ <td></td><td>Month:<br>Sales:<br>Payments:</td>
+ {foreach key=key item=item_sales from=$total_sales.$year}
+ <td>{$key}<br>{$item_sales}<br>{$total_payments.$year.$key} </td>
+ {/foreach}
+
+ </tr>
+ {/foreach}
+ </table>
+
+
+
+

Reply all
Reply to author
Forward
0 new messages