dolibarr 23.0.3
block-info.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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
28// This script is called with a POST method.
29// Directory to scan (full path) is inside POST['dir'].
30
31if (!defined('NOTOKENRENEWAL')) {
32 define('NOTOKENRENEWAL', 1); // Disables token renewal
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40
41
42// Load Dolibarr environment
43require '../../main.inc.php';
51require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
52
53
54$id = GETPOSTINT('id');
55$block = new BlockedLog($db);
56
57if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || empty($conf->blockedlog->enabled)) {
59}
60
61$langs->loadLangs(array("admin", "bills", "blockedlog", "cashdesk", "companies", "members", "products"));
62
63
64/*
65 * View
66 */
67
69
70print '<div id="pop-info"><table height="80%" class="border centpercent"><thead>';
71print '<th width="30%" class="left">'.$langs->trans('Field').'</th><th class="left">'.$langs->trans('Label').'</th><th class="left">'.$langs->trans('Value').'</th></thead>';
72print '<tbody>';
73
74if ($block->fetch($id) > 0) {
75 $objtoshow = $block->object_data;
76 print formatObject($objtoshow, '');
77} else {
78 print 'Error, failed to get unalterable log with id '.$id;
79}
80
81print '</tbody>';
82print '</table></div>';
83
84
85$db->close();
86
87
95function formatObject($objtoshow, $prefix)
96{
97 global $db, $langs;
98
99 $s = '';
100
101 $newobjtoshow = $objtoshow;
102
103 $tmpobject = null;
104 $arrayoffields = array();
105 if ($prefix == 'mycompany' || $prefix == 'thirdparty') {
106 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
107 $tmpobject = new Societe($db);
108 $arrayoffields = $tmpobject->fields;
109 } elseif ($prefix == 'invoice') {
110 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
111 $tmpobject = new Facture($db);
112 $arrayoffields = $tmpobject->fields;
113 } elseif ($prefix == 'invoiceline') {
114 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/factureligne.class.php';
115 $tmpobject = new FactureLigne($db);
116 $arrayoffields = $tmpobject->fields;
117 }
118
119 // Convert the key stored into blocked log into the key used into ->fields
120 $convertkey = array(
121 'name' => 'nom',
122 'country_code' => 'fk_pays',
123 'typent_code' => 'fk_typent',
124 'forme_juridique_code' => 'fk_forme_juridique',
125 );
126
127 $otherlabels = array(
128 'module_source' => 'POSModule',
129 'pos_source' => "POSTerminal",
130 'posmodule' => 'POSModule',
131 'posnumber' => 'POSTerminal',
132 'pos_print_counter' => "NumberOfPrints",
133 'email_sent_counter' => "NumberOfEmailsSent",
134 'managers' => 'Managers',
135 'type_code' => 'PaymentMode',
136 'date_creation' => 'DateCreation',
137 'datec' => 'DateCreation',
138 'dateh' => 'DateSubscription',
139 'datef' => 'DateEndSubscription',
140 'fk_adherent' => 'MemberId',
141 'amount' => 'Amount',
142 'id' => 'ID',
143 'ref' => 'Ref',
144 'element' => 'TypeOfEvent',
145 'entity' => 'Entity',
146 'label' => 'Label',
147 'date' => 'Date',
148 'total_ht' => 'TotalHT',
149 'total_ttc' => 'TotalTTC',
150 'total_tva' => 'TotalVAT',
151 'total_localtax1' => 'TotalTax2',
152 'total_localtax2' => 'TotalTax3',
153 'multicurrency_total_ht' => 'TotalHTShortCurrency',
154 'multicurrency_total_ttc' => 'TotalTTCShortCurrency',
155 'multicurrency_total_tva' => 'TotalVATShortCurrency',
156 'tva_tx' => 'VatRate',
157 'localtax1_tx' => 'Localtax1Rate',
158 'localtax2_tx' => 'Localtax2Rate',
159 'vat_src_code' => 'VATCode',
160 'multicurrency_code' => 'Currency',
161 'qty' => 'Quantity',
162 'nom' => 'Name',
163 'name' => 'Name',
164 'email' => 'Email',
165 'address' => 'Address',
166 'town' => 'Town',
167 'state_code' => 'State',
168 'fk_pays' => 'Country',
169 'fk_typent' => 'CompanyType',
170 'revenuestamp' => 'RevenueStamp',
171 'code_client' => 'CustomerCode',
172 'code_fournisseur' => 'SupplierCode',
173 'capital' => 'Capital',
174 'localtax1_assuj' => 'UseLocalTax1',
175 'localtax2_assuj' => 'UseLocalTax2',
176 'localtax1_value' => 'LocalTax1DefaultValue',
177 'localtax2_value' => 'LocalTax2DefaultValue',
178 'subprice' => 'UnitPrice',
179 'product_type' => 'ProductType',
180 'product_label' => 'ProductLabel',
181 'type' => 'InvoiceType',
182 'info_bits' => 'TVA NPR or NOT',
183 'special_code' => 'Special line (WEEE line, option, id of module...)',
184 'status' => 'Status',
185 'cash' => 'PaymentTypeLIQ',
186 'cash_lifetime' => $langs->transnoentities('LifetimeAmount', $langs->transnoentities('PaymentTypeLIQ')),
187 'card' => 'PaymentTypeCB',
188 'card_lifetime' => $langs->transnoentities('LifetimeAmount', $langs->transnoentities('PaymentTypeCB')),
189 'cheque' => 'PaymentTypeCHQ',
190 'cheque_lifetime' => $langs->transnoentities('LifetimeAmount', $langs->transnoentities('PaymentTypeCHQ')),
191 'lifetime_start' => 'LifetimeStartDate'
192 );
193
194 if (is_object($newobjtoshow) || is_array($newobjtoshow)) {
195 //var_dump($newobjtoshow);
196 foreach ($newobjtoshow as $key => $val) {
197 if (!is_object($val) && !is_array($val)) {
198 // TODO $val can be '__PHP_Incomplete_Class', the is_object return false
199 $s .= '<tr>';
200
201 // Field code
202 $s .= '<td>';
203 $s .= '<!-- '.$key.' '.$arrayoffields[$key]['type'].''.$arrayoffields[$convertkey[$key]]['label'].' -->';
204 $s .= ($prefix ? $prefix.' > ' : '');
205 $s .= $key;
206 $s .= '</td>';
207
208 // Label
209 $s .= '<td>';
210 $label = '';
211 if (isset($arrayoffields[$key]['label'])) {
212 $label = $langs->trans($tmpobject->fields[$key]['label']);
213 } elseif (!empty($convertkey[$key]) && isset($arrayoffields[$convertkey[$key]]['label'])) {
214 $label = $langs->trans($tmpobject->fields[$convertkey[$key]]['label']);
215 } elseif ($prefix == 'mycompany' || $prefix == 'thirdparty') {
216 $reg = array();
217 if (preg_match('/^idprof(\d+)$/', $key, $reg)) {
218 $countrycode = property_exists($newobjtoshow, 'country_code') ? ($newobjtoshow->country_code ?? '') : '';
219 $label = $langs->trans("ProfId".$reg[1].$countrycode);
220 }
221 }
222 if (empty($label) && !empty($otherlabels[$key])) {
223 $label = $langs->trans($otherlabels[$key]);
224 }
225 if (empty($label) && array_key_exists($key, $convertkey) && array_key_exists((string) $convertkey[$key], $otherlabels)) {
226 $label = $langs->trans((string) $otherlabels[(string) $convertkey[$key]]);
227 }
228 if (empty($label)) {
229 $label = array_key_exists($key, $convertkey) ? $convertkey[$key] : '';
230 }
231 if (!empty($label)) {
232 $s .= '<span class="opacitymedium">'.$label.'</span>';
233 }
234
235 // Value
236 $s .= '<td>';
237 if (in_array($key, array('date', 'datef'))) {
238 $s .= dol_print_date($val, 'day');
239 } elseif (in_array($key, array('dateh', 'datec', 'date_creation', 'datem', 'tms', 'date_valid', 'datep'))) {
240 $s .= dol_print_date($val, 'dayhour');
241 } elseif (in_array($key, array('tva_assuj', 'localtax1_assuj', 'localtax2_assuj'))) {
242 $s .= yn($val);
243 } elseif (in_array($key, array('product_type'))) {
244 $s .= $val ? 'Product' : 'Service';
245 } elseif (in_array($key, array(
246 'qty', 'subprice',
247 'tva_tx', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_ttc', 'total_tva', 'total_localtax1', 'total_localtax2', 'localtax2', 'localtax2', 'revenuestamp',
248 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'multicurrency_subprice',
249 'opening', 'cash', 'cheque', 'card',
250 'amount'
251 )) || (isset($arrayoffields[$key]['type']) && in_array($arrayoffields[$key]['type'], array('price')))) {
252 $s .= '<span class="amount">'.price($val, 0, $langs, 1, 0, -2).'</span>';
253 } else {
254 $s .= $val;
255 }
256 $s .= '</td></tr>';
257 } elseif (is_array($val)) {
258 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
259 } elseif (is_object($val)) {
260 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
261 }
262 }
263 }
264
265 return $s;
266}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
Class to manage Blocked Log.
Class to manage invoices.
Class to manage invoice lines.
Class to manage third parties objects (customers, suppliers, prospects...)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.