tiki-accounting.php 1.78 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
3 4 5
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id$
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

$section = 'accounting';
require_once ('tiki-setup.php');
require_once ('lib/accounting/accountinglib.php');


// Feature available?
if ($prefs['feature_accounting'] !='y') {
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_accounting");
	$smarty->display("error.tpl");
	die;
}

if (!isset($_REQUEST['bookId'])) {
	$smarty->assign('msg', tra("Missing book id"));
	$smarty->display("error.tpl");
	die;
}
$bookId=$_REQUEST['bookId'];
$smarty->assign('bookId',$bookId);
27 28 29 30 31 32 33 34 35

$globalperms = Perms::get();
$objectperms = Perms::get( array( 'type' => 'accounting book', 'object' => $bookId ) );
if (!($globalperms->acct_view or $objectperms->acct_view)) {
	$smarty->assign('msg', tra("You do not have the right view this page"));
	$smarty->display("error.tpl");
	die;		
}

36 37 38 39 40 41 42 43 44 45 46 47
$book=$accountinglib->getBook($bookId);
$smarty->assign('book',$book);

$accounts=$accountinglib->getExtendedAccounts($bookId,true);
$smarty->assign('accounts',$accounts);

if (!isset($_REQUEST['journalLimit'])) {
	$_REQUEST['journalLimit']=-25;
}
$journal=$accountinglib->getJournal($bookId,'%','`journalId` DESC',$_REQUEST['journalLimit']);
$smarty->assign('journal',$journal);

48 49 50 51 52 53 54 55 56 57
if ($globalperms->acct_book or $objectperms->acct_book) {
	$smarty->assign('canBook',true);
} else {
	$smarty->assign('canBook',false);
}
if ($globalperms->acct_book_stack or $objectperms->acct_book_stack) {
	$smarty->assign('canStack',true);
} else {
	$smarty->assign('canStack',false);
}
58 59 60
ask_ticket('accounting');


61
$smarty->assign('mid','tiki-accounting.tpl');
62
$smarty->display("tiki.tpl");