dolibarr 19.0.3
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 = "accounting";
37 public $boxlabel = "BoxSuspenseAccount";
38 public $depends = array("accounting");
39
43 public $db;
44
45 public $param;
46
47 public $info_box_head = array();
48 public $info_box_contents = array();
49
50
57 public function __construct($db, $param)
58 {
59 global $user;
60
61 $this->db = $db;
62
63 $this->hidden = !$user->hasRight('accounting', 'mouvements', 'lire');
64 }
65
71 public function loadBox()
72 {
73 global $user, $langs, $conf;
74
75 include_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
76
77 //$bookkeepingstatic = new BookKeeping($this->db);
78
79 $this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount"));
80
81 if ($user->hasRight('accounting', 'mouvements', 'lire')) {
82 $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
83 if (!empty($suspenseAccount) && $suspenseAccount > 0) {
84 $sql = "SELECT COUNT(*) as nb_suspense_account";
85 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
86 $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'";
87 $sql .= " AND b.entity = ".$conf->entity;
88
89 $result = $this->db->query($sql);
90 $nbSuspenseAccount = 0;
91 if ($result) {
92 $obj = $this->db->fetch_object($result);
93 $nbSuspenseAccount = $obj->nb_suspense_account;
94 }
95
96 $this->info_box_contents[0][0] = array(
97 'td' => '',
98 'text' => $langs->trans("NumberOfLinesInSuspenseAccount").':'
99 );
100
101 $this->info_box_contents[0][1] = array(
102 'td' => 'class="right"',
103 'text' => '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($suspenseAccount).'&search_accountancy_code_end='.urlencode($suspenseAccount).'">'.$nbSuspenseAccount.'</a>',
104 'asis' => 1
105 );
106 } else {
107 $this->info_box_contents[0][0] = array(
108 'td' => 'class="nohover"',
109 'text' => '<span class="opacitymedium">'.$langs->trans("SuspenseAccountNotDefined").'</span>'
110 );
111 }
112 } else {
113 $this->info_box_contents[0][0] = array(
114 'td' => 'class="nohover"',
115 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
116 );
117 }
118 }
119
128 public function showBox($head = null, $contents = null, $nooutput = 0)
129 {
130 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
131 }
132}
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.