! -> Note
$ -> Affected files
+07-May-2010 Joe Hunt
++ Added Account tags selection in Annual Expense Breakdown, Balanse Sheet
+ and Profit and Loss Sheet
+$ /admin/db/tags_db.inc
+ /reporting/rep705.php
+ /reporting/rep706.php
+ /reporting/rep707.php
+ /reporting/reports_main.php
+ /reporting/includes/reports_classes.inc
+
07-May-2010 Janusz Dobrowolski
# Fixed bug in array_selector for multiply lists
$ /includes/ui/ui_lists.inc
return $row[0];
}
+//----------------------------------------------------------------------------------------------------
+function get_tag_names($tags)
+{
+ $str = "";
+ if ($tags == -1)
+ return $str;
+ foreach($tags as $id)
+ {
+ $tag = get_tag_name($id);
+ if ($str == "")
+ $str .= $tag;
+ else
+ $str .= ", ".$tag;
+ }
+ return $str;
+}
//--------------------------------------------------------------------------------------
function get_tag_description($id)
//--------------------------------------------------------------------------------------
+function is_record_in_tags($tags, $type, $recordid)
+{
+ foreach($tags as $id)
+ {
+ $sql = "SELECT ta.record_id FROM ".TB_PREF."tag_associations AS ta
+ INNER JOIN ".TB_PREF."tags AS tags ON tags.id = ta.tag_id
+ WHERE tags.type = $type AND tags.id = $id AND ta.record_id = ".db_escape($recordid);
+ $res = db_query($sql, "could not get tags associations for record");
+ if (db_num_rows($res) == 0)
+ return false;
+ }
+ return true;
+}
+
?>
\ No newline at end of file
$tag_type = TAG_ACCOUNT;
else
$tag_type = TAG_DIMENSION;
- return tag_list($name, 5, $tag_type, true, _("No tags"));
+ //return tag_list($name, 5, $tag_type, true, false, _("No tags"));
+ return tag_list($name, 5, $tag_type, true);
}
return '';
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
+include_once($path_to_root . "/admin/db/tags_db.inc");
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
-function display_type ($type, $typename, $yr, $mo, $convert, &$dec, &$rep, $dimension, $dimension2)
+function display_type ($type, $typename, $yr, $mo, $convert, &$dec, &$rep, $dimension, $dimension2, $tags)
{
$ctotal = array(1 => 0,0,0,0,0,0,0,0,0,0,0,0,0,0);
$total = array(1 => 0,0,0,0,0,0,0,0,0,0,0,0,0,0);
$result = get_gl_accounts(null, null, $type);
while ($account=db_fetch($result))
{
+ if ($tags != -1)
+ {
+ if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code']))
+ continue;
+ }
$bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2);
if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] && !$bal['per05'] &&
!$bal['per06'] && !$bal['per07'] && !$bal['per08'] && !$bal['per09'] && !$bal['per10'] &&
$year = $_POST['PARAM_0'];
$dimension = $_POST['PARAM_1'];
$dimension2 = $_POST['PARAM_2'];
- $comments = $_POST['PARAM_3'];
- $destination = $_POST['PARAM_4'];
+ $tags = (isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1);
+ $comments = $_POST['PARAM_4'];
+ $destination = $_POST['PARAM_5'];
}
else if ($dim == 1)
{
$year = $_POST['PARAM_0'];
$dimension = $_POST['PARAM_1'];
- $comments = $_POST['PARAM_2'];
- $destination = $_POST['PARAM_3'];
+ $tags = (isset($_POST['PARAM_2']) ? $_POST['PARAM_2'] : -1);
+ $comments = $_POST['PARAM_3'];
+ $destination = $_POST['PARAM_4'];
}
else
{
$year = $_POST['PARAM_0'];
- $comments = $_POST['PARAM_1'];
- $destination = $_POST['PARAM_2'];
+ $tags = (isset($_POST['PARAM_1']) ? $_POST['PARAM_1'] : -1);
+ $comments = $_POST['PARAM_2'];
+ $destination = $_POST['PARAM_3'];
}
if ($destination)
include_once($path_to_root . "/reporting/includes/excel_report.inc");
'from' => get_dimension_string($dimension), 'to' => ''),
3 => array('text' => _("Dimension")." 2",
'from' => get_dimension_string($dimension2), 'to' => ''),
- 4 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
+ 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''),
+ 5 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
'to' => ''));
}
else if ($dim == 1)
'from' => $year, 'to' => ''),
2 => array('text' => _('Dimension'),
'from' => get_dimension_string($dimension), 'to' => ''),
- 3 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
+ 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''),
+ 4 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
'to' => ''));
}
else
$params = array( 0 => $comments,
1 => array('text' => _("Year"),
'from' => $year, 'to' => ''),
- 2 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
+ 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''),
+ 3 => array('text' => _('Info'), 'from' => _('Amounts in thousands'),
'to' => ''));
}
$typeresult = get_account_types(false, $class['cid'], -1);
while ($accounttype=db_fetch($typeresult))
{
- $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2);
+ $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension,
+ $dimension2, $tags);
for ($i = 1; $i <= 12; $i++)
$ctotal[$i] += $classtotal[$i];
}
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
+include_once($path_to_root . "/admin/db/tags_db.inc");
//----------------------------------------------------------------------------------------------------
-function display_type ($type, $typename, $from, $to, $convert, &$dec, &$rep, $dimension, $dimension2, &$pg, $graphics)
+function display_type ($type, $typename, $from, $to, $convert, &$dec, &$rep, $dimension, $dimension2, $tags, &$pg, $graphics)
{
$code_open_balance = 0;
$code_period_balance = 0;
$open_balance_total = 0;
$period_balance_total = 0;
- unset($totals_arr);
$totals_arr = array();
$printtitle = 0; //Flag for printing type name
$result = get_gl_accounts(null, null, $type);
while ($account=db_fetch($result))
{
+ if ($tags != -1)
+ {
+ if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code']))
+ continue;
+ }
$prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2);
$curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
{
$dimension = $_POST['PARAM_2'];
$dimension2 = $_POST['PARAM_3'];
+ $tags = (isset($_POST['PARAM_4']) ? $_POST['PARAM_4'] : -1);
+ $decimals = $_POST['PARAM_5'];
+ $graphics = $_POST['PARAM_6'];
+ $comments = $_POST['PARAM_7'];
+ $destination = $_POST['PARAM_8'];
+ }
+ else if ($dim == 1)
+ {
+ $dimension = $_POST['PARAM_2'];
+ $tags = (isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1);
$decimals = $_POST['PARAM_4'];
$graphics = $_POST['PARAM_5'];
$comments = $_POST['PARAM_6'];
$destination = $_POST['PARAM_7'];
}
- else if ($dim == 1)
+ else
{
- $dimension = $_POST['PARAM_2'];
+ $tags = (isset($_POST['PARAM_2']) ? $_POST['PARAM_2'] : -1);
$decimals = $_POST['PARAM_3'];
$graphics = $_POST['PARAM_4'];
$comments = $_POST['PARAM_5'];
$destination = $_POST['PARAM_6'];
}
- else
- {
- $decimals = $_POST['PARAM_2'];
- $graphics = $_POST['PARAM_3'];
- $comments = $_POST['PARAM_4'];
- $destination = $_POST['PARAM_5'];
- }
if ($destination)
include_once($path_to_root . "/reporting/includes/excel_report.inc");
else
2 => array('text' => _('Dimension')." 1",
'from' => get_dimension_string($dimension), 'to' => ''),
3 => array('text' => _('Dimension')." 2",
- 'from' => get_dimension_string($dimension2), 'to' => ''));
+ 'from' => get_dimension_string($dimension2), 'to' => ''),
+ 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
else if ($dim == 1)
{
$params = array( 0 => $comments,
1 => array('text' => _('Period'),'from' => $from, 'to' => $to),
2 => array('text' => _('Dimension'),
- 'from' => get_dimension_string($dimension), 'to' => ''));
+ 'from' => get_dimension_string($dimension), 'to' => ''),
+ 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
else
{
$params = array( 0 => $comments,
- 1 => array('text' => _('Period'),'from' => $from, 'to' => $to));
+ 1 => array('text' => _('Period'),'from' => $from, 'to' => $to),
+ 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
$rep = new FrontReport(_('Balance Sheet'), "BalanceSheet", user_pagesize());
while ($accounttype=db_fetch($typeresult))
{
$classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dec,
- $rep, $dimension, $dimension2, $pg, $graphics);
+ $rep, $dimension, $dimension2, $tags, $pg, $graphics);
$class_open_total += $classtotal[0];
$class_period_total += $classtotal[1];
}
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/gl/includes/gl_db.inc");
+include_once($path_to_root . "/admin/db/tags_db.inc");
//----------------------------------------------------------------------------------------------------
-function display_type ($type, $typename, $from, $to, $begin, $end, $compare, $convert, &$dec, &$pdec, &$rep, $dimension, $dimension2, &$pg, $graphics)
+function display_type ($type, $typename, $from, $to, $begin, $end, $compare, $convert, &$dec, &$pdec, &$rep, $dimension, $dimension2,
+ $tags, &$pg, $graphics)
{
$code_per_balance = 0;
$code_acc_balance = 0;
$per_balance_total = 0;
$acc_balance_total = 0;
- unset($totals_arr);
$totals_arr = array();
$printtitle = 0; //Flag for printing type name
$result = get_gl_accounts(null, null, $type);
while ($account=db_fetch($result))
{
+ if ($tags != -1)
+ {
+ if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code']))
+ continue;
+ }
$per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
if ($compare == 2)
{
$dimension = $_POST['PARAM_3'];
$dimension2 = $_POST['PARAM_4'];
+ $tags = (isset($_POST['PARAM_5']) ? $_POST['PARAM_5'] : -1);
+ $decimals = $_POST['PARAM_6'];
+ $graphics = $_POST['PARAM_7'];
+ $comments = $_POST['PARAM_8'];
+ $destination = $_POST['PARAM_9'];
+ }
+ else if ($dim == 1)
+ {
+ $dimension = $_POST['PARAM_3'];
+ $tags = (isset($_POST['PARAM_4']) ? $_POST['PARAM_4'] : -1);
$decimals = $_POST['PARAM_5'];
$graphics = $_POST['PARAM_6'];
$comments = $_POST['PARAM_7'];
$destination = $_POST['PARAM_8'];
}
- else if ($dim == 1)
+ else
{
- $dimension = $_POST['PARAM_3'];
+ $tags = (isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1);
$decimals = $_POST['PARAM_4'];
$graphics = $_POST['PARAM_5'];
$comments = $_POST['PARAM_6'];
$destination = $_POST['PARAM_7'];
}
- else
- {
- $decimals = $_POST['PARAM_3'];
- $graphics = $_POST['PARAM_4'];
- $comments = $_POST['PARAM_5'];
- $destination = $_POST['PARAM_6'];
- }
if ($destination)
include_once($path_to_root . "/reporting/includes/excel_report.inc");
else
2 => array('text' => _('Dimension')." 1",
'from' => get_dimension_string($dimension), 'to' => ''),
3 => array('text' => _('Dimension')." 2",
- 'from' => get_dimension_string($dimension2), 'to' => ''));
+ 'from' => get_dimension_string($dimension2), 'to' => ''),
+ 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
else if ($dim == 1)
{
$params = array( 0 => $comments,
1 => array('text' => _('Period'),'from' => $from, 'to' => $to),
2 => array('text' => _('Dimension'),
- 'from' => get_dimension_string($dimension), 'to' => ''));
+ 'from' => get_dimension_string($dimension), 'to' => ''),
+ 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
else
{
$params = array( 0 => $comments,
- 1 => array('text' => _('Period'),'from' => $from, 'to' => $to));
+ 1 => array('text' => _('Period'),'from' => $from, 'to' => $to),
+ 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''));
}
$rep->Info($params, $cols, $headers, $aligns);
$rep->NewPage();
- $classper = 0.0;
- $classacc = 0.0;
$salesper = 0.0;
$salesacc = 0.0;
while ($accounttype=db_fetch($typeresult))
{
$classtotal = display_type($accounttype["id"], $accounttype["name"], $from, $to, $begin, $end, $compare, $convert, $dec,
- $pdec, $rep, $dimension, $dimension2, $pg, $graphics);
+ $pdec, $rep, $dimension, $dimension2, $tags, $pg, $graphics);
$class_per_total += $classtotal[0];
$class_acc_total += $classtotal[1];
}
array( _('Year') => 'TRANS_YEARS',
_('Dimension')." 1" => 'DIMENSIONS1',
_('Dimension')." 2" => 'DIMENSIONS2',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Comments') => 'TEXTBOX',
_('Destination') => 'DESTINATION'));
$reports->addReport(RC_GL, 706, _('&Balance Sheet'),
_('End Date') => 'DATEENDM',
_('Dimension')." 1" => 'DIMENSIONS1',
_('Dimension')." 2" => 'DIMENSIONS2',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',
_('Compare to') => 'COMPARE',
_('Dimension')." 1" => 'DIMENSIONS1',
_('Dimension')." 2" => 'DIMENSIONS2',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',
$reports->addReport(RC_GL, 705, _('Annual &Expense Breakdown'),
array( _('Year') => 'TRANS_YEARS',
_('Dimension') => 'DIMENSIONS1',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Comments') => 'TEXTBOX',
_('Destination') => 'DESTINATION'));
$reports->addReport(RC_GL, 706, _('&Balance Sheet'),
array( _('Start Date') => 'DATEBEGIN',
_('End Date') => 'DATEENDM',
_('Dimension') => 'DIMENSIONS1',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',
_('End Date') => 'DATEENDM',
_('Compare to') => 'COMPARE',
_('Dimension') => 'DIMENSIONS1',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',
_('Destination') => 'DESTINATION'));
$reports->addReport(RC_GL, 705, _('Annual &Expense Breakdown'),
array( _('Year') => 'TRANS_YEARS',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Comments') => 'TEXTBOX',
_('Destination') => 'DESTINATION'));
$reports->addReport(RC_GL, 706, _('&Balance Sheet'),
array( _('Start Date') => 'DATEBEGIN',
_('End Date') => 'DATEENDM',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',
array( _('Start Date') => 'DATEBEGINM',
_('End Date') => 'DATEENDM',
_('Compare to') => 'COMPARE',
+ _('Account Tags') => 'ACCOUNTTAGS',
_('Decimal values') => 'YES_NO',
_('Graphics') => 'GRAPHIC',
_('Comments') => 'TEXTBOX',