dolibarr 20.0.2
box_accountancy_suspense_account.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
28
29
34{
35 public $boxcode = "accountancy_suspense_account";
36 public $boximg = "accountancy";
37 public $boxlabel = "BoxSuspenseAccount";
38 public $depends = array("accounting");
39
46 public function __construct($db, $param)
47 {
48 global $user;
49
50 $this->db = $db;
51
52 $this->hidden = !$user->hasRight('accounting', 'mouvements', 'lire');
53 }
54
60 public function loadBox()
61 {
62 global $user, $langs, $conf;
63
64 include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
65
66 //$bookkeepingstatic = new BookKeeping($this->db);
67
68 $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount"));
69
70 if ($user->hasRight('accounting', 'mouvements', 'lire')) {
71 $suspenseAccount = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE');
72 if (!empty($suspenseAccount) && $suspenseAccount > 0) {
73 $sql = "SELECT COUNT(*) as nb_suspense_account";
74 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
75 $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'";
76 $sql .= " AND b.entity = ".$conf->entity;
77
78 $result = $this->db->query($sql);
79 $nbSuspenseAccount = 0;
80 if ($result) {
81 $obj = $this->db->fetch_object($result);
82 $nbSuspenseAccount = $obj->nb_suspense_account;
83 }
84
85 $this->info_box_contents[0][0] = array(
86 'td' => '',
87 'text' => $langs->trans("NumberOfLinesInSuspenseAccount")
88 );
89
90 $this->info_box_contents[0][1] = array(
91 'td' => 'class="right"',
92 'text' => '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($suspenseAccount).'&search_accountancy_code_end='.urlencode($suspenseAccount).'">'.$nbSuspenseAccount.'</a>',
93 'asis' => 1
94 );
95 } else {
96 $this->info_box_contents[0][0] = array(
97 'td' => 'class="nohover"',
98 'text' => '<span class="opacitymedium">'.$langs->trans("SuspenseAccountNotDefined").'</span>'
99 );
100 }
101 } else {
102 $this->info_box_contents[0][0] = array(
103 'td' => 'class="nohover"',
104 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
105 );
106 }
107 }
108
117 public function showBox($head = null, $contents = null, $nooutput = 0)
118 {
119 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
120 }
121}
Class ModeleBoxes.
Class to manage the box to show suspense account.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox()
Load data for box to show them later.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.