This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
tiki-accounting_books.php
109 lines (104 loc) · 3.28 KB
/
tiki-accounting_books.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// 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.
// $Id$
$section = 'accounting';
require_once('tiki-setup.php');
$access->checkAuthenticity();
// 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['action'])) {
$_REQUEST['action'] = '';
}
$globalperms = Perms::get();
$accountinglib = TikiLib::lib('accounting');
if ($_REQUEST['book_start_Year']) {
$bookStartDate = new DateTime();
$bookStartDate->setDate(
$_REQUEST['book_start_Year'],
$_REQUEST['book_start_Month'],
$_REQUEST['book_start_Day']
);
}
if ($_REQUEST['book_end_Year']) {
$bookEndDate = new DateTime();
$bookEndDate->setDate(
$_REQUEST['book_end_Year'],
$_REQUEST['book_end_Month'],
$_REQUEST['book_end_Day']
);
}
if ($access->ticketMatch()) {
switch ($_REQUEST['action']) {
case 'create':
if (! $globalperms->acct_create_book) {
$smarty->assign('msg', tra("You do not have permissions to create a book") . ": feature_accounting");
$smarty->display("error.tpl");
die;
}
$bookId = $accountinglib->createBook(
$_REQUEST['bookName'],
'n',
date_format($bookStartDate, 'Y-m-d H:i:s'),
date_format($bookEndDate, 'Y-m-d H:i:s'),
$_REQUEST['bookCurrency'],
$_REQUEST['bookCurrencyPos'],
$_REQUEST['bookDecimals'],
$_REQUEST['bookDecPoint'],
$_REQUEST['bookThousand'],
$_REQUEST['exportSeparator'],
$_REQUEST['exportEOL'],
$_REQUEST['exportQuote'],
$_REQUEST['bookAutoTax']
);
if (! is_numeric($bookId)) {
$errors[] = tra($bookId);
Feedback::error(implode("\n", $errors));
$smarty->assign('bookName', $_REQUEST['bookName']);
$smarty->assign('bookStartDate', $bookStartDate);
$smarty->assign('bookEndDate', $bookEndDate);
$smarty->assign('bookCurrency', $_REQUEST['bookCurrency']);
$smarty->assign('bookCurrencyPos', $_REQUEST['bookCurrencyPos']);
$smarty->assign('bookDecimals', $_REQUEST['bookDecimals']);
$smarty->assign('bookDecPoint', $_REQUEST['bookDecPoint']);
$smarty->assign('bookThousand', $_REQUEST['bookThousand']);
$smarty->assign('exportSeparator', $_REQUEST['exportSeparator']);
$smarty->assign('exportEOL', $_REQUEST['exportEOL']);
$smarty->assign('exportQuote', $_REQUEST['exportQuote']);
$smarty->assign('bookAutoTax', $_REQUEST['bookAutoTax']);
}
break;
case 'close':
if (! $globalperms->acct_create_book) {
$smarty->assign('msg', tra("You do not have permissions to close this book") . ": feature_accounting");
$smarty->display("error.tpl");
die;
}
$accountinglib->closeBook($_REQUEST['bookId']);
break;
case 'view':
break;
default://list
}
}
$books = $accountinglib->listBooks();
$filtered = Perms::filter(
[ 'type' => 'accounting book'],
'object',
$books,
[ 'object' => 'bookName' ],
'acct_view'
);
$smarty->assign('books', $books);
$smarty->assign('canCreate', $globalperms->acct_create_book);
$smarty->assign('mid', 'tiki-accounting_books.tpl');
$smarty->display("tiki.tpl");