dolibarr 21.0.0-beta
box_accountancy_last_manual_entries.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_last_manual_entries";
37 public $boximg = "accountancy";
38 public $boxlabel = "BoxLastManualEntries";
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 = 5)
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("BoxTitleLastManualEntries", $max));
71
72 if ($user->hasRight('accounting', 'mouvements', 'lire')) {
73 $sql = "SELECT DISTINCT b.piece_num";
74 $sql .= ", b.doc_date as date_movement";
75 $sql .= ", b.label_operation";
76 $sql .= ", b.montant as amount";
77 $sql .= ", b.code_journal";
78 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
79 $sql .= " WHERE b.fk_doc = 0";
80 $sql .= " AND b.entity = ".$conf->entity;
81 $sql .= " ORDER BY b.piece_num DESC ";
82 $sql .= $this->db->plimit($max, 0);
83
84 $result = $this->db->query($sql);
85 if ($result) {
86 $num = $this->db->num_rows($result);
87
88 $line = 0;
89
90 while ($line < $num) {
91 $objp = $this->db->fetch_object($result);
92 $date = $this->db->jdate($objp->date_movement);
93 $journal = $objp->code_journal;
94 $label = $objp->label_operation;
95 $amount = $objp->amount;
96
97 // adding id (rowid) will give two lines (debit and credit)
98 // so rowid isn't in sql request
99 // $bookkeepingstatic->id = $objp->id;
100 $bookkeepingstatic->piece_num = $objp->piece_num;
101
102 $this->info_box_contents[$line][] = array(
103 'td' => '',
104 'text' => $bookkeepingstatic->getNomUrl(1),
105 'asis' => 1,
106 );
107
108 $this->info_box_contents[$line][] = array(
109 'td' => 'class="center nowraponall"',
110 'text' => dol_print_date($date, 'day'),
111 'asis' => 1,
112 );
113
114 $this->info_box_contents[$line][] = array(
115 'td' => 'class="center"',
116 'text' => $journal,
117 'asis' => 1,
118 );
119
120 $this->info_box_contents[$line][] = array(
121 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
122 'text' => $label,
123 'asis' => 1,
124 );
125
126 $this->info_box_contents[$line][] = array(
127 'td' => 'class="nowraponall right amount"',
128 'text' => price($amount, 0, $langs, 0, -1, -1, $conf->currency),
129 );
130
131 $line++;
132 }
133
134 if ($num == 0) {
135 $this->info_box_contents[$line][0] = array(
136 'td' => 'class="center"',
137 'text' => '<span class="opacitymedium">'.$langs->trans("NoRecordedManualEntries").'</span>'
138 );
139 }
140
141 $this->db->free($result);
142 } else {
143 $this->info_box_contents[0][0] = array(
144 'td' => '',
145 'maxlength' => 500,
146 'text' => ($this->db->error().' sql='.$sql),
147 );
148 }
149 } else {
150 $this->info_box_contents[0][0] = array(
151 'td' => 'class="nohover left"',
152 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
153 );
154 }
155 }
156
157
158
159
168 public function showBox($head = null, $contents = null, $nooutput = 0)
169 {
170 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
171 }
172}
Class to manage Ledger (General Ledger and Subledger)
Class ModeleBoxes.
Class to manage the box to show last manual entries.
loadBox($max=5)
Load data for box to show them later.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79