dolibarr  13.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 <http://www.gnu.org/licenses/>.
19  */
20 
27 include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
28 
29 
34 {
35  public $boxcode = "accountancy_suspense_account";
36  public $boximg = "object_invoice";
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->rights->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->rights->accounting->mouvements->lire)
82  {
83  $suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
84  if (!empty($suspenseAccount) && $suspenseAccount > 0)
85  {
86  $sql = "SELECT COUNT(*) as nb_suspense_account";
87  $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
88  $sql .= " WHERE b.numero_compte = ".$suspenseAccount;
89  $sql .= " AND b.entity = ".$conf->entity;
90 
91  $result = $this->db->query($sql);
92  $nbSuspenseAccount = 0;
93  if ($result)
94  {
95  $obj = $this->db->fetch_object($result);
96  $nbSuspenseAccount = $obj->nb_suspense_account;
97  }
98 
99  $this->info_box_contents[0][0] = array(
100  'td' => '',
101  'text' => $langs->trans("NumberOfLinesInSuspenseAccount").':'
102  );
103 
104  $this->info_box_contents[0][1] = array(
105  'td' => 'class="right"',
106  'text' => '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($suspenseAccount).'&search_accountancy_code_end='.urlencode($suspenseAccount).'">'.$nbSuspenseAccount.'</a>',
107  'asis' => 1
108  );
109  } else {
110  $this->info_box_contents[0][0] = array(
111  'td' => 'class="nohover"',
112  'text' => '<span class="opacitymedium">'.$langs->trans("SuspenseAccountNotDefined").'</span>'
113  );
114  }
115  } else {
116  $this->info_box_contents[0][0] = array(
117  'td' => 'class="nohover"',
118  'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
119  );
120  }
121  }
122 
131  public function showBox($head = null, $contents = null, $nooutput = 0)
132  {
133  return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
134  }
135 }
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox()
Load data for box to show them later.
Class ModeleBoxes.
$conf db
API class for accounts.
Definition: inc.php:54
Class to manage the box to show suspense account.