@@ -6,6 +6,9 @@ discard block |
||
6 | 6 | |
7 | 7 | interface Observer |
8 | 8 | { |
9 | + /** |
|
10 | + * @return boolean |
|
11 | + */ |
|
9 | 12 | function update($code, $msg); |
10 | 13 | } |
11 | 14 | |
@@ -47,6 +50,9 @@ discard block |
||
47 | 50 | } |
48 | 51 | } |
49 | 52 | |
53 | + /** |
|
54 | + * @param string $table |
|
55 | + */ |
|
50 | 56 | function tableExists($table) |
51 | 57 | { |
52 | 58 | $this->db->loadModule('Manager', null, true); |
@@ -64,12 +64,12 @@ |
||
64 | 64 | $result = $this->db->createTable($this->table_name, $this->table_definition); |
65 | 65 | |
66 | 66 | if (PEAR::isError($result)) { |
67 | - throw new Exception('create ' . $result->getMessage()); |
|
67 | + throw new Exception('create '.$result->getMessage()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $result = $this->db->createConstraint($this->table_name, 'PRIMARY', $this->definition); |
71 | 71 | if (PEAR::isError($result)) { |
72 | - throw new Exception('primary ' . $result->getMessage()); |
|
72 | + throw new Exception('primary '.$result->getMessage()); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 |
@@ -169,8 +169,6 @@ discard block |
||
169 | 169 | /** |
170 | 170 | * getModule() |
171 | 171 | * |
172 | - * @param string $module_name |
|
173 | - * |
|
174 | 172 | * @return object |
175 | 173 | */ |
176 | 174 | function getModule($name) |
@@ -250,6 +248,9 @@ discard block |
||
250 | 248 | return false; |
251 | 249 | } |
252 | 250 | |
251 | + /** |
|
252 | + * @param string $name |
|
253 | + */ |
|
253 | 254 | private static function isValidModuleName($name) |
254 | 255 | { |
255 | 256 | return preg_match("/^[a-z0-9]+$/", $name); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function useModule($module_name, $ignore_user_access = false) |
79 | 79 | { |
80 | 80 | if (!self::isValidModuleName($module_name)) { |
81 | - throw new Exception($module_name . ' is not a valid module name'); |
|
81 | + throw new Exception($module_name.' is not a valid module name'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | if (!empty($this->modules[$module_name]) AND is_object($this->modules[$module_name])) { |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | if ($access !== true) { |
119 | - throw new Exception('You need access to a required module to see this page, maybe it is ' . $module_name); |
|
119 | + throw new Exception('You need access to a required module to see this page, maybe it is '.$module_name); |
|
120 | 120 | } |
121 | 121 | |
122 | - $main_class_name = "Main" . ucfirst($module_name); |
|
123 | - $main_class_path = PATH_INCLUDE_MODULE . $module_name . "/" . $main_class_name . ".php"; |
|
122 | + $main_class_name = "Main".ucfirst($module_name); |
|
123 | + $main_class_path = PATH_INCLUDE_MODULE.$module_name."/".$main_class_name.".php"; |
|
124 | 124 | |
125 | 125 | if (file_exists($main_class_path)) { |
126 | 126 | require_once($main_class_path); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | return $object; |
131 | 131 | } else { |
132 | 132 | // @TODO this should not fail as hard - but what should happen then? |
133 | - throw new Exception('ModuleHandler: ' . $main_class_path . ' does not exist'); |
|
133 | + throw new Exception('ModuleHandler: '.$main_class_path.' does not exist'); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function useShared($shared_name) |
145 | 145 | { |
146 | 146 | if (!self::isValidModuleName($shared_name)) { |
147 | - throw new Exception($shared_name. ' is not a valid shared module name'); |
|
147 | + throw new Exception($shared_name.' is not a valid shared module name'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Tjekker om shared allerede er loaded |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | return $this->shared[$shared_name]; |
153 | 153 | } |
154 | 154 | |
155 | - $main_shared_name = 'Shared' . ucfirst($shared_name); |
|
156 | - $main_shared_path = PATH_INCLUDE_SHARED . $shared_name . '/' . $main_shared_name . '.php'; |
|
155 | + $main_shared_name = 'Shared'.ucfirst($shared_name); |
|
156 | + $main_shared_path = PATH_INCLUDE_SHARED.$shared_name.'/'.$main_shared_name.'.php'; |
|
157 | 157 | |
158 | 158 | if (file_exists($main_shared_path)) { |
159 | 159 | require_once $main_shared_path; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->shared[$shared_name] = $object; |
163 | 163 | return $object; |
164 | 164 | } else { |
165 | - throw new Exception($shared_name . ' cannot be found on ' . $main_shared_path . ' with PATH_INCLUDE_SHARED: ' . PATH_INCLUDE_SHARED); |
|
165 | + throw new Exception($shared_name.' cannot be found on '.$main_shared_path.' with PATH_INCLUDE_SHARED: '.PATH_INCLUDE_SHARED); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (is_object($this->modules[$name])) { |
179 | 179 | return($this->modules[$name]); |
180 | 180 | } else { |
181 | - throw new Exception('getModule() module ' . $name . ' not loaded'); |
|
181 | + throw new Exception('getModule() module '.$name.' not loaded'); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @deprecated |
115 | 115 | * @param integer $account_number |
116 | 116 | * |
117 | - * @return object |
|
117 | + * @return double |
|
118 | 118 | */ |
119 | 119 | public static function factory($year, $account_number) |
120 | 120 | { |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * @param $date_from (date) yyyy-mm-dd Der s�ges jo kun i indev�rende �r |
452 | 452 | * @param $date_to (date) yyyy-mm-dd Der s�ges kun i indev�rende �r |
453 | 453 | * |
454 | - * @return (array) med debet, credit og total saldo |
|
454 | + * @return boolean med debet, credit og total saldo |
|
455 | 455 | * |
456 | 456 | * |
457 | 457 | * |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $this->value['vat_account_id'] = 0; |
198 | 198 | } |
199 | 199 | $this->value['vat_shorthand'] = $this->value['vat']; |
200 | - } |
|
200 | + } |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $this->get('id'); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $this->error->set('Ikke en tilladt type'); |
237 | 237 | } |
238 | 238 | |
239 | - $validator->isNumeric($var['use_key'], 'Det kan en konto ikke bruges til'); |
|
239 | + $validator->isNumeric($var['use_key'], 'Det kan en konto ikke bruges til'); |
|
240 | 240 | |
241 | 241 | if (!array_key_exists($var['use_key'], $this->use)) { |
242 | 242 | $this->error->set('Ikke en tilladt brug af kontoen'); |
@@ -642,6 +642,6 @@ discard block |
||
642 | 642 | |
643 | 643 | public function getNumber() |
644 | 644 | { |
645 | - return $this->get('number'); |
|
645 | + return $this->get('number'); |
|
646 | 646 | } |
647 | 647 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->db = new DB_Sql; |
95 | 95 | $this->mdb2 = MDB2::singleton(DB_DSN); |
96 | 96 | if (PEAR::isError($this->mdb2)) { |
97 | - throw new Exception($this->mdb2->getMessage() . $this->mdb2->getUserInfo()); |
|
97 | + throw new Exception($this->mdb2->getMessage().$this->mdb2->getUserInfo()); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->error = new Intraface_Error; |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | account.active |
151 | 151 | FROM |
152 | 152 | accounting_account account |
153 | - WHERE account.id = " . $this->id . " |
|
154 | - AND account.intranet_id = ".$this->year->kernel->intranet->get('id'). " |
|
153 | + WHERE account.id = " . $this->id." |
|
154 | + AND account.intranet_id = ".$this->year->kernel->intranet->get('id')." |
|
155 | 155 | AND year_id = ".$this->year->get('id')." |
156 | 156 | LIMIT 1"; |
157 | 157 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | |
245 | 245 | $validator->isString($var['name'], 'Kontonavnet kan kune v�re en tekststreng.'); |
246 | 246 | $validator->isNumeric($var['vat_key'], 'Ugyldig moms', 'allow_empty'); |
247 | - $validator->isNumeric($var['sum_to'], 'sum_to' , 'allow_empty'); |
|
248 | - $validator->isNumeric($var['sum_from'], 'sum_from' , 'allow_empty'); |
|
247 | + $validator->isNumeric($var['sum_to'], 'sum_to', 'allow_empty'); |
|
248 | + $validator->isNumeric($var['sum_from'], 'sum_from', 'allow_empty'); |
|
249 | 249 | |
250 | 250 | settype($var['comment'], 'integer'); |
251 | 251 | $validator->isString($var['comment'], 'Error in comment', '', 'allow_empty'); |
@@ -257,26 +257,26 @@ discard block |
||
257 | 257 | |
258 | 258 | if ($this->id > 0) { |
259 | 259 | $sql_type = "UPDATE accounting_account "; |
260 | - $sql_end = " WHERE id = " . $this->id; |
|
260 | + $sql_end = " WHERE id = ".$this->id; |
|
261 | 261 | } else { |
262 | 262 | $sql_type = "INSERT INTO accounting_account "; |
263 | 263 | $sql_end = ", date_created=NOW()"; |
264 | 264 | } |
265 | 265 | |
266 | - $sql = $sql_type . "SET |
|
266 | + $sql = $sql_type."SET |
|
267 | 267 | number = '".(int)$var['number']."', |
268 | - intranet_id = " . $this->year->kernel->intranet->get('id') . ", |
|
269 | - user_id = " . $this->year->kernel->user->get("id") . ", |
|
268 | + intranet_id = " . $this->year->kernel->intranet->get('id').", |
|
269 | + user_id = " . $this->year->kernel->user->get("id").", |
|
270 | 270 | type_key='" . $var['type_key']."', |
271 | 271 | year_id = " . $this->year->get('id').", |
272 | 272 | use_key = '" . $var['use_key']."', |
273 | 273 | name = '" . $var['name']."', |
274 | 274 | comment = '" . $var['comment']."', |
275 | - vat_percent = '" . $var['vat_percent'] . "', |
|
276 | - sum_to_account_number = " . (int)$var['sum_to'] . ", |
|
277 | - sum_from_account_number = " . (int)$var['sum_from'] . ", |
|
275 | + vat_percent = '" . $var['vat_percent']."', |
|
276 | + sum_to_account_number = " . (int)$var['sum_to'].", |
|
277 | + sum_from_account_number = " . (int)$var['sum_from'].", |
|
278 | 278 | date_changed = NOW(), |
279 | - vat_key=" . (int)$var['vat_key'] . " " . $sql_end; |
|
279 | + vat_key=" . (int)$var['vat_key']." ".$sql_end; |
|
280 | 280 | |
281 | 281 | $this->db->query($sql); |
282 | 282 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | if (!empty($var['created_from_id']) AND is_numeric($var['created_from_id'])) { |
288 | - $this->db->query("UPDATE accounting_account SET created_from_id = ".$var['created_from_id']." WHERE id = " . $this->id); |
|
288 | + $this->db->query("UPDATE accounting_account SET created_from_id = ".$var['created_from_id']." WHERE id = ".$this->id); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $this->load(); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | - $this->db->query("UPDATE accounting_account SET active = 0, date_changed=NOW() WHERE intranet_id = " . $this->year->kernel->intranet->get('id') . " AND year_id = ".$this->year->get('id')." AND id = " . $this->id); |
|
353 | + $this->db->query("UPDATE accounting_account SET active = 0, date_changed=NOW() WHERE intranet_id = ".$this->year->kernel->intranet->get('id')." AND year_id = ".$this->year->get('id')." AND id = ".$this->id); |
|
354 | 354 | $this->value['active'] = 0; |
355 | 355 | return true; |
356 | 356 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | $sql = "SELECT |
392 | 392 | id |
393 | 393 | FROM accounting_account |
394 | - WHERE number = " . $account_number . " |
|
395 | - AND intranet_id = " . $this->year->kernel->intranet->get('id') . " |
|
396 | - AND year_id = " .$this->year->get('id'). " |
|
397 | - AND id <> " . $this->id . " AND active = 1"; |
|
394 | + WHERE number = " . $account_number." |
|
395 | + AND intranet_id = " . $this->year->kernel->intranet->get('id')." |
|
396 | + AND year_id = " .$this->year->get('id')." |
|
397 | + AND id <> " . $this->id." AND active = 1"; |
|
398 | 398 | $result = $this->mdb2->query($sql); |
399 | 399 | if (PEAR::isError($result)) { |
400 | 400 | throw new Exception('Error in query: '.$result->getUserInfo()); |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | { |
420 | 420 | $sql = "SELECT primosaldo_debet, primosaldo_credit |
421 | 421 | FROM accounting_account |
422 | - WHERE year_id = " . $this->year->get('id') . " |
|
423 | - AND id = ".$this->id . " |
|
422 | + WHERE year_id = " . $this->year->get('id')." |
|
423 | + AND id = ".$this->id." |
|
424 | 424 | AND active = 1 |
425 | 425 | AND intranet_id = ".$this->year->kernel->intranet->get('id'); |
426 | 426 | |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | if ($this->get('type_key') == array_search('sum', $this->types)) { |
501 | 501 | $db2 = new DB_Sql; |
502 | 502 | $sql = "SELECT id FROM accounting_account |
503 | - WHERE number >= " . $this->get('sum_from') . " |
|
503 | + WHERE number >= " . $this->get('sum_from')." |
|
504 | 504 | AND type_key != ".array_search('sum', $this->types)." |
505 | - AND number <= " . $this->get('sum_to') . " |
|
505 | + AND number <= " . $this->get('sum_to')." |
|
506 | 506 | AND year_id = ".$this->year->get('id')." |
507 | 507 | AND intranet_id = " . $this->year->kernel->intranet->get('id'); |
508 | 508 | $db2->query($sql); |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | $this->db->query("SELECT |
571 | 571 | id |
572 | 572 | FROM accounting_post post |
573 | - WHERE (post.account_id = ". $this->id . ") |
|
573 | + WHERE (post.account_id = ". $this->id.") |
|
574 | 574 | AND intranet_id = ".$this->year->kernel->intranet->get('id')." |
575 | - AND year_id = " . $this->year->get('id') . " |
|
575 | + AND year_id = " . $this->year->get('id')." |
|
576 | 576 | LIMIT 1"); |
577 | 577 | return $this->db->numRows(); |
578 | 578 | } |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | debet, |
594 | 594 | credit |
595 | 595 | FROM accounting_post post |
596 | - WHERE (post.account_id = ". $this->get('id') . ") |
|
596 | + WHERE (post.account_id = ". $this->get('id').") |
|
597 | 597 | AND intranet_id = ".$this->year->kernel->intranet->get('id')." |
598 | - AND year_id = " . $this->year->get('id') . " |
|
598 | + AND year_id = " . $this->year->get('id')." |
|
599 | 599 | AND stated = 1 |
600 | 600 | ORDER BY date ASC, id ASC"); |
601 | 601 | $i = 1; |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | public function calculateVat($amount, $vat_percent) |
631 | 631 | { |
632 | 632 | $amount = (float)$amount; |
633 | - $vat_percent = (float)$vat_percent / 100; |
|
633 | + $vat_percent = (float)$vat_percent/100; |
|
634 | 634 | |
635 | - return $amount * ($vat_percent / (1 + $vat_percent)); |
|
635 | + return $amount*($vat_percent/(1 + $vat_percent)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | public function getId() |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @deprecated |
67 | 67 | * @param $id |
68 | - * @return unknown_type |
|
68 | + * @return Account |
|
69 | 69 | */ |
70 | 70 | function findFromId($id) |
71 | 71 | { |
@@ -78,6 +78,9 @@ discard block |
||
78 | 78 | return new Account($this->year, $id); |
79 | 79 | } |
80 | 80 | |
81 | + /** |
|
82 | + * @param string $type |
|
83 | + */ |
|
81 | 84 | function findByType($type, $saldo = false) |
82 | 85 | { |
83 | 86 | return $this->getList($type, $saldo); |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | |
27 | 27 | function __construct($year) |
28 | 28 | { |
29 | - $this->year = $year; |
|
29 | + $this->year = $year; |
|
30 | 30 | } |
31 | 31 | |
32 | - /** |
|
32 | + /** |
|
33 | 33 | * Denne funktion bruges bl.a. under bogf�ringen, s� man bare taster kontonummer |
34 | 34 | * og s� s�ttes den rigtige konto. |
35 | 35 | * |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function findById($id) |
76 | 76 | { |
77 | 77 | require_once dirname (__FILE__) . '/Account.php'; |
78 | - return new Account($this->year, $id); |
|
78 | + return new Account($this->year, $id); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | function findByType($type, $saldo = false) |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | function findById($id) |
76 | 76 | { |
77 | - require_once dirname (__FILE__) . '/Account.php'; |
|
77 | + require_once dirname(__FILE__).'/Account.php'; |
|
78 | 78 | return new Account($this->year, $id); |
79 | 79 | } |
80 | 80 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $db = new DB_Sql; |
112 | 112 | if (!empty($type)) { |
113 | - switch($type) { |
|
113 | + switch ($type) { |
|
114 | 114 | case 'expenses': |
115 | 115 | $type_sql = " AND use_key = '".array_search('expenses', $this->use)."'"; |
116 | 116 | break; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $db = new DB_Sql; |
189 | 189 | $sql = "SELECT id |
190 | 190 | FROM accounting_account |
191 | - WHERE intranet_id = " . $this->year->kernel->intranet->get("id") . " AND year_id = ".$this->year->get('id')." AND active = 1"; |
|
191 | + WHERE intranet_id = " . $this->year->kernel->intranet->get("id")." AND year_id = ".$this->year->get('id')." AND active = 1"; |
|
192 | 192 | $db->query($sql); |
193 | 193 | |
194 | 194 | return $db->numRows(); |
@@ -36,6 +36,9 @@ discard block |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | + /** |
|
40 | + * @param integer $post_id |
|
41 | + */ |
|
39 | 42 | public function factory($year, $post_id) |
40 | 43 | { |
41 | 44 | return Intraface_modules_accounting_PostGateway::getFromYearAndPostId($year, $post_id); |
@@ -76,6 +79,13 @@ discard block |
||
76 | 79 | return 1; |
77 | 80 | } |
78 | 81 | |
82 | + /** |
|
83 | + * @param string $date |
|
84 | + * @param integer $account_id |
|
85 | + * @param string $text |
|
86 | + * @param double $debet |
|
87 | + * @param double $credit |
|
88 | + */ |
|
79 | 89 | private function validate($date, $account_id, $text, $debet, $credit) |
80 | 90 | { |
81 | 91 | $validator = new Intraface_Validator($this->error); |
@@ -99,9 +109,7 @@ discard block |
||
99 | 109 | /** |
100 | 110 | * States the posts |
101 | 111 | * |
102 | - * @param integer $year_id |
|
103 | 112 | * @param string $date |
104 | - * @param string $voucher_number |
|
105 | 113 | * @param string $text |
106 | 114 | * @param integer $account_id |
107 | 115 | * @param float $debet |
@@ -194,6 +194,6 @@ |
||
194 | 194 | |
195 | 195 | function getId() |
196 | 196 | { |
197 | - return $this->id; |
|
197 | + return $this->id; |
|
198 | 198 | } |
199 | 199 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | private function load() |
45 | 45 | { |
46 | 46 | $db = new DB_Sql; |
47 | - $db->query("SELECT *, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE id = " . $this->id . " AND intranet_id=" .$this->voucher->year->kernel->intranet->get('id')); |
|
47 | + $db->query("SELECT *, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE id = ".$this->id." AND intranet_id=".$this->voucher->year->kernel->intranet->get('id')); |
|
48 | 48 | if (!$db->nextRecord()) { |
49 | 49 | return 0; |
50 | 50 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($this->id > 0) { |
127 | 127 | $sql_type = "UPDATE"; |
128 | - $sql_end = " WHERE id = " . $this->id; |
|
128 | + $sql_end = " WHERE id = ".$this->id; |
|
129 | 129 | |
130 | 130 | } else { |
131 | 131 | $sql_type = "INSERT INTO"; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | $db = new DB_Sql; |
136 | - $sql = $sql_type . " accounting_post |
|
136 | + $sql = $sql_type." accounting_post |
|
137 | 137 | SET |
138 | 138 | voucher_id = '".$this->voucher->get('id')."', |
139 | 139 | intranet_id = ".$this-> |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | account_id = '".(int)$account_id."', |
149 | 149 | text = '".(string)$text."', |
150 | 150 | debet = '".$debet."', |
151 | - credit = '".$credit."'" . $sql_end; |
|
151 | + credit = '".$credit."'".$sql_end; |
|
152 | 152 | $db->query($sql); |
153 | 153 | |
154 | 154 | $this->id = $db->insertedId(); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | $db = new DB_Sql; |
178 | - $db->query("UPDATE accounting_post SET stated = 1 WHERE id = " . $this->id . " AND intranet_id =" .$this->voucher->year->kernel->intranet->get('id')); |
|
178 | + $db->query("UPDATE accounting_post SET stated = 1 WHERE id = ".$this->id." AND intranet_id =".$this->voucher->year->kernel->intranet->get('id')); |
|
179 | 179 | |
180 | 180 | return true; |
181 | 181 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | $db = new DB_Sql; |
190 | - $db->query("DELETE FROM accounting_post WHERE id = " . $this->id); |
|
190 | + $db->query("DELETE FROM accounting_post WHERE id = ".$this->id); |
|
191 | 191 | return true; |
192 | 192 | |
193 | 193 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @param object $voucher |
25 | 25 | * |
26 | - * @return void |
|
26 | + * @return string |
|
27 | 27 | */ |
28 | 28 | function __construct($voucher) |
29 | 29 | { |
@@ -22,8 +22,6 @@ discard block |
||
22 | 22 | * Constructor |
23 | 23 | * |
24 | 24 | * @param object $year_object |
25 | - * @param integer $post_id (optional) |
|
26 | - * |
|
27 | 25 | * @return void |
28 | 26 | */ |
29 | 27 | function __construct($year_object, $id = 0) |
@@ -45,7 +43,7 @@ discard block |
||
45 | 43 | * @param object $year |
46 | 44 | * @param string $voucher_number |
47 | 45 | * |
48 | - * @return void |
|
46 | + * @return Voucher |
|
49 | 47 | */ |
50 | 48 | function factory($year, $voucher_number) |
51 | 49 | { |
@@ -339,9 +337,7 @@ discard block |
||
339 | 337 | /** |
340 | 338 | * Prepares amounts for stating, e.g. whether the accounts needs vat calculations |
341 | 339 | * |
342 | - * @param integer $year_id |
|
343 | 340 | * @param string $date |
344 | - * @param string $voucher_number |
|
345 | 341 | * @param string $text |
346 | 342 | * @param integer $account_id |
347 | 343 | * @param float $debet |
@@ -271,11 +271,11 @@ |
||
271 | 271 | * @return array |
272 | 272 | */ |
273 | 273 | |
274 | - function getList($filter = '') |
|
275 | - { |
|
274 | + function getList($filter = '') |
|
275 | + { |
|
276 | 276 | $gateway = new Intraface_modules_accounting_VoucherGateway($this->year); |
277 | 277 | return $gateway->getList($filter); |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * States voucher |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | voucher.date, |
69 | 69 | voucher.reference |
70 | 70 | FROM accounting_voucher voucher |
71 | - WHERE voucher.id = " . $this->id. " AND intranet_id = ". $this->year->kernel->intranet->getId(); |
|
71 | + WHERE voucher.id = " . $this->id." AND intranet_id = ".$this->year->kernel->intranet->getId(); |
|
72 | 72 | |
73 | 73 | $db = new DB_Sql; |
74 | 74 | $db->query($sql); |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | $sql_end = ", date_created = NOW()"; |
144 | 144 | } else { |
145 | 145 | $sql_type = "UPDATE"; |
146 | - $sql_end = " WHERE id = " . (int)$this->id; |
|
146 | + $sql_end = " WHERE id = ".(int)$this->id; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $db = new DB_Sql; |
150 | - $sql = $sql_type . " accounting_voucher |
|
150 | + $sql = $sql_type." accounting_voucher |
|
151 | 151 | SET intranet_id = ".$this->year->kernel->intranet->get('id').", |
152 | 152 | year_id = ".$this->year->get('id').", |
153 | 153 | user_id = ".$this->year->kernel->user->get('id').", |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | number = '".$var['voucher_number']."', |
156 | 156 | date = '".$post_date->get()."', |
157 | 157 | reference = '".$var['reference']."', |
158 | - text = '".$var['text']."'" . $sql_end; |
|
158 | + text = '".$var['text']."'".$sql_end; |
|
159 | 159 | |
160 | 160 | $db->query($sql); |
161 | 161 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | $buy_all_abroad = $buy_abroad; |
310 | 310 | } |
311 | 311 | |
312 | - $amount = $this->get('amount') * ($this->vatpercent / 100); |
|
312 | + $amount = $this->get('amount')*($this->vatpercent/100); |
|
313 | 313 | |
314 | 314 | // I det omfang du har fradragsret for momsen, kan du medregne det beregnede |
315 | 315 | // momsbeløb til konto for indgående moms. Det beregnede momsbeløb af EU-varekøb |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | $debet = $debet - $vat_amount; |
374 | 374 | // bogfør momsen |
375 | 375 | $post = new Post($this); |
376 | - $post->save($date, $vat_account_id, $text . " - købsmoms", $vat_amount, 0, $skip_draft); |
|
376 | + $post->save($date, $vat_account_id, $text." - købsmoms", $vat_amount, 0, $skip_draft); |
|
377 | 377 | } else { |
378 | 378 | $vat_amount = $this->calculateVat($credit, $vat_percent); |
379 | 379 | $credit = $credit - $vat_amount; |
380 | 380 | // bogføre udgående moms |
381 | 381 | $post = new Post($this); |
382 | - $post->save($date, $vat_account_id, $text . " - tilbageført moms", 0, $vat_amount, $skip_draft); |
|
382 | + $post->save($date, $vat_account_id, $text." - tilbageført moms", 0, $vat_amount, $skip_draft); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | // bogføre selve posten |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $credit = $credit - $vat_amount; |
396 | 396 | // bogføre udgående moms |
397 | 397 | $post = new Post($this); |
398 | - $post->save($date, $vat_account_id, $text . " - salgsmoms", 0, $vat_amount, $skip_draft); |
|
398 | + $post->save($date, $vat_account_id, $text." - salgsmoms", 0, $vat_amount, $skip_draft); |
|
399 | 399 | } else { |
400 | 400 | // tilbagefører momsen hvis det er et debet beløb |
401 | 401 | $vat_amount = $this->calculateVat($debet, $vat_percent); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $post = new Post($this, $p['id']); |
455 | 455 | |
456 | 456 | if (!$post->setStated()) { |
457 | - $this->error->set('id#' .$p['id'] . ': Det lykkedes ikke at bogføre denne post.'); |
|
457 | + $this->error->set('id#'.$p['id'].': Det lykkedes ikke at bogføre denne post.'); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | if ($this->get('saldo') <> 0) { |
483 | - $this->error->set('Du kan kun bogføre et bilag, hvis det stemmer. Saldoen på dette bilag er ' . $this->get('saldo') . '.'); |
|
483 | + $this->error->set('Du kan kun bogføre et bilag, hvis det stemmer. Saldoen på dette bilag er '.$this->get('saldo').'.'); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | if ($this->error->isError()) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | if ($post->get('stated') == 1) continue; |
495 | 495 | |
496 | 496 | if (!$post->setStated()) { |
497 | - $this->error->set('id#' .$p['id'] . ': Det lykkedes ikke at bogføre denne post.'); |
|
497 | + $this->error->set('id#'.$p['id'].': Det lykkedes ikke at bogføre denne post.'); |
|
498 | 498 | |
499 | 499 | } |
500 | 500 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | function getPosts() |
510 | 510 | { |
511 | 511 | $db = new DB_Sql; |
512 | - $db->query("SELECT id, text, debet, credit, account_id, stated, date, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE voucher_id = " . $this->id . " AND intranet_id=".$this->year->kernel->intranet->get('id')); |
|
512 | + $db->query("SELECT id, text, debet, credit, account_id, stated, date, DATE_FORMAT(date, '%d-%m-%Y') AS date_dk FROM accounting_post WHERE voucher_id = ".$this->id." AND intranet_id=".$this->year->kernel->intranet->get('id')); |
|
513 | 513 | $list = array(); |
514 | 514 | $i = 0; |
515 | 515 | $this->value['saldo'] = 0; |
@@ -491,7 +491,9 @@ |
||
491 | 491 | |
492 | 492 | foreach ($posts as $p) { |
493 | 493 | $post = new Post($this, $p['id']); |
494 | - if ($post->get('stated') == 1) continue; |
|
494 | + if ($post->get('stated') == 1) { |
|
495 | + continue; |
|
496 | + } |
|
495 | 497 | |
496 | 498 | if (!$post->setStated()) { |
497 | 499 | $this->error->set('id#' .$p['id'] . ': Det lykkedes ikke at bogføre denne post.'); |
@@ -90,6 +90,9 @@ |
||
90 | 90 | return $files; |
91 | 91 | } |
92 | 92 | |
93 | + /** |
|
94 | + * @param string $url |
|
95 | + */ |
|
93 | 96 | function url($url) |
94 | 97 | { |
95 | 98 | return PATH_WWW . 'restricted' . $url; |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | |
23 | 23 | function findFromId($id) |
24 | 24 | { |
25 | - require_once dirname(__FILE__) . '/VoucherFile.php'; |
|
25 | + require_once dirname(__FILE__).'/VoucherFile.php'; |
|
26 | 26 | return new VoucherFile($this->voucher, $id); |
27 | 27 | } |
28 | 28 | |
29 | 29 | function getList() |
30 | 30 | { |
31 | 31 | $db = new DB_Sql; |
32 | - $db->query("SELECT * FROM accounting_voucher_file WHERE active = 1 AND voucher_id = " . $this->voucher->get('id') . " AND intranet_id=" . $this->voucher->year->kernel->intranet->get('id')); |
|
32 | + $db->query("SELECT * FROM accounting_voucher_file WHERE active = 1 AND voucher_id = ".$this->voucher->get('id')." AND intranet_id=".$this->voucher->year->kernel->intranet->get('id')); |
|
33 | 33 | $i = 0; |
34 | 34 | $files = array(); |
35 | 35 | while ($db->nextRecord()) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $files[$i]['description'] = 'Momsperiode'; |
50 | 50 | } |
51 | 51 | $files[$i]['name'] = 'Momsperiode'; |
52 | - $files[$i]['file_uri'] = $this->url('/module/accounting/year/'.$this->voucher->year->getId().'/vat/' . $db->f('belong_to_id')); |
|
52 | + $files[$i]['file_uri'] = $this->url('/module/accounting/year/'.$this->voucher->year->getId().'/vat/'.$db->f('belong_to_id')); |
|
53 | 53 | break; |
54 | 54 | case 'file': |
55 | 55 | $this->voucher->year->kernel->useModule('filemanager'); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $files[$i]['description'] = 'Kreditnota'; |
64 | 64 | } |
65 | 65 | $files[$i]['name'] = 'Kreditnota'; |
66 | - $files[$i]['file_uri'] = $this->url('/module/debtor/credit_note/' . $db->f('belong_to_id') . '.pdf'); |
|
66 | + $files[$i]['file_uri'] = $this->url('/module/debtor/credit_note/'.$db->f('belong_to_id').'.pdf'); |
|
67 | 67 | break; |
68 | 68 | case 'reminder': |
69 | 69 | if (empty($files[$i]['description'])) { |
@@ -92,6 +92,6 @@ discard block |
||
92 | 92 | |
93 | 93 | function url($url) |
94 | 94 | { |
95 | - return PATH_WWW . 'restricted' . $url; |
|
95 | + return PATH_WWW.'restricted'.$url; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param object $year_object |
18 | 18 | * |
19 | - * @return void |
|
19 | + * @return string |
|
20 | 20 | */ |
21 | 21 | public function __construct($year_object) |
22 | 22 | { |
@@ -32,10 +32,9 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Creates a voucher |
34 | 34 | * |
35 | - * @param object $year |
|
36 | 35 | * @param string $voucher_number |
37 | 36 | * |
38 | - * @return void |
|
37 | + * @return Voucher |
|
39 | 38 | */ |
40 | 39 | public function findFromVoucherNumber($voucher_number) |
41 | 40 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function findFromId($id) |
27 | 27 | { |
28 | 28 | require_once dirname (__FILE__) . '/Voucher.php'; |
29 | - return new Voucher($this->year, $id); |
|
29 | + return new Voucher($this->year, $id); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @return (array) |
53 | 53 | */ |
54 | - function getList($filter = '') |
|
55 | - { |
|
54 | + function getList($filter = '') |
|
55 | + { |
|
56 | 56 | $sql = "SELECT *, DATE_FORMAT(voucher.date, '%d-%m-%Y') AS date_dk |
57 | 57 | FROM accounting_voucher voucher |
58 | 58 | WHERE voucher.active = 1 AND voucher.year_id = ".$this->year->get('id')." |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | switch ($filter) { |
62 | 62 | case 'lastfive': |
63 | 63 | $sql .= " ORDER BY voucher.number DESC, voucher.id DESC LIMIT 5"; |
64 | - break; |
|
64 | + break; |
|
65 | 65 | default: |
66 | 66 | $sql .= " ORDER BY voucher.number DESC, voucher.id DESC"; |
67 | 67 | break; |
68 | 68 | } |
69 | 69 | |
70 | - $db = new Db_Sql; |
|
70 | + $db = new Db_Sql; |
|
71 | 71 | |
72 | 72 | $db->query($sql); |
73 | 73 | |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | $i++; |
84 | 84 | } |
85 | 85 | return $list; |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - function getMaxNumber() |
|
89 | - { |
|
90 | - $db = new DB_Sql; |
|
88 | + function getMaxNumber() |
|
89 | + { |
|
90 | + $db = new DB_Sql; |
|
91 | 91 | |
92 | - $db->query("SELECT MAX(number) AS max_voucher_number |
|
92 | + $db->query("SELECT MAX(number) AS max_voucher_number |
|
93 | 93 | FROM accounting_voucher |
94 | 94 | WHERE intranet_id = " . $this->year->kernel->intranet->get('id') . " |
95 | 95 | AND year_id = " . $this->year->get('id')); |
96 | - if (!$db->nextRecord()) { |
|
97 | - return 0; |
|
98 | - } |
|
99 | - return $db->f('max_voucher_number'); |
|
100 | - } |
|
96 | + if (!$db->nextRecord()) { |
|
97 | + return 0; |
|
98 | + } |
|
99 | + return $db->f('max_voucher_number'); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function findFromId($id) |
27 | 27 | { |
28 | - require_once dirname (__FILE__) . '/Voucher.php'; |
|
28 | + require_once dirname(__FILE__).'/Voucher.php'; |
|
29 | 29 | return new Voucher($this->year, $id); |
30 | 30 | } |
31 | 31 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function findFromVoucherNumber($voucher_number) |
41 | 41 | { |
42 | 42 | $db = new DB_Sql; |
43 | - $db->query("SELECT id FROM accounting_voucher WHERE number = '".safeToDb($voucher_number)."' AND year_id = '".$this->year->get('id')."' AND intranet_id = " . $this->year->kernel->intranet->get('id')); |
|
43 | + $db->query("SELECT id FROM accounting_voucher WHERE number = '".safeToDb($voucher_number)."' AND year_id = '".$this->year->get('id')."' AND intranet_id = ".$this->year->kernel->intranet->get('id')); |
|
44 | 44 | if (!$db->nextRecord()) { |
45 | 45 | return new Voucher($this->year); |
46 | 46 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $db->query("SELECT MAX(number) AS max_voucher_number |
93 | 93 | FROM accounting_voucher |
94 | - WHERE intranet_id = " . $this->year->kernel->intranet->get('id') . " |
|
94 | + WHERE intranet_id = " . $this->year->kernel->intranet->get('id')." |
|
95 | 95 | AND year_id = " . $this->year->get('id')); |
96 | 96 | if (!$db->nextRecord()) { |
97 | 97 | return 0; |