dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
29
30
35{
36 public $boxcode = "accountancy_suspense_account";
37 public $boximg = "accountancy";
38 public $boxlabel = "BoxSuspenseAccount";
39 public $depends = array("accounting");
40
47 public function __construct($db, $param)
48 {
49 global $user;
50
51 $this->db = $db;
52
53 $this->hidden = !$user->hasRight('accounting', 'mouvements', 'lire');
54 }
55
62 public function loadBox($max = 1)
63 {
64 global $user, $langs, $conf;
65
66 include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
67
68 //$bookkeepingstatic = new BookKeeping($this->db);
69
70 $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount"));
71
72 if ($user->hasRight('accounting', 'mouvements', 'lire')) {
73 $suspenseAccount = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE');
74 if (!empty($suspenseAccount) && $suspenseAccount > 0) {
75 $sql = "SELECT COUNT(*) as nb_suspense_account";
76 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
77 $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'";
78 $sql .= " AND b.entity = ".$conf->entity;
79
80 $result = $this->db->query($sql);
81 $nbSuspenseAccount = 0;
82 if ($result) {
83 $obj = $this->db->fetch_object($result);
84 $nbSuspenseAccount = $obj->nb_suspense_account;
85 }
86
87 $this->info_box_contents[0][0] = array(
88 'td' => '',
89 'text' => $langs->trans("NumberOfLinesInSuspenseAccount")
90 );
91
92 $this->info_box_contents[0][1] = array(
93 'td' => 'class="right"',
94 'text' => '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($suspenseAccount).'&search_accountancy_code_end='.urlencode($suspenseAccount).'">'.$nbSuspenseAccount.'</a>',
95 'asis' => 1
96 );
97 } else {
98 $this->info_box_contents[0][0] = array(
99 'td' => 'class="nohover"',
100 'text' => '<span class="opacitymedium">'.$langs->trans("SuspenseAccountNotDefined").'</span>'
101 );
102 }
103 } else {
104 $this->info_box_contents[0][0] = array(
105 'td' => 'class="nohover"',
106 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
107 );
108 }
109 }
110
111
112
121 public function showBox($head = null, $contents = null, $nooutput = 0)
122 {
123 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
124 }
125}
Class ModeleBoxes.
Class to manage the box to show suspense account.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=1)
Load data for box to show them later.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79