dolibarr 24.0.0-beta
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-2026 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", "compta", "mails", "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
77 print formatObject($objtoshow, '', $block->element);
78} else {
79 print 'Error, failed to get unalterable log with id '.$id;
80}
81
82print '</tbody>';
83print '</table></div>';
84
85
86$db->close();
87
88
97function formatObject($objtoshow, $prefix, $parentelement = '')
98{
99 global $db, $langs;
100
101 $s = '';
102
103 $newobjtoshow = $objtoshow;
104
105 $tmpobject = null;
106 $arrayoffields = array();
107 if ($prefix == 'mycompany' || $prefix == 'thirdparty') {
108 include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
109 $tmpobject = new Societe($db);
110 $arrayoffields = $tmpobject->fields;
111 } elseif ($prefix == 'invoice') {
112 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
113 $tmpobject = new Facture($db);
114 $arrayoffields = $tmpobject->fields;
115 } elseif ($prefix == 'invoiceline') {
116 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/factureligne.class.php';
117 $tmpobject = new FactureLigne($db);
118 $arrayoffields = $tmpobject->fields;
119 }
120
121 // Convert the key stored into blocked log into the key used into ->fields
122 $convertkey = array(
123 'name' => 'nom',
124 'country_code' => 'fk_pays',
125 'typent_code' => 'fk_typent',
126 'forme_juridique_code' => 'fk_forme_juridique',
127 );
128
129 $otherlabels = array(
130 'link' => 'Link',
131 'module_source' => 'POSModule',
132 'pos_source' => "POSTerminal",
133 'posmodule' => 'POSModule',
134 'posnumber' => 'POSTerminal',
135 'pos_print_counter' => "NumberOfPrintsIfDocValidated",
136 'email_sent_counter' => "NumberOfEmailsSent",
137 'managers' => 'Managers',
138 'type_code' => 'PaymentMode',
139 'date_creation' => 'DateCreation',
140 'datec' => 'DateCreation',
141 'dateh' => 'DateSubscription',
142 'datef' => 'DateEndSubscription',
143 'fk_adherent' => 'MemberId',
144 'amount' => 'Amount',
145 'id' => 'ID',
146 'ref' => 'Ref',
147 'payment_num' => '', // a label
148 'element' => 'TypeOfEvent',
149 'entity' => 'Entity',
150 'label' => 'Label',
151 'date' => 'Date',
152 'total_ht' => 'TotalHT',
153 'total_ttc' => 'TotalTTC',
154 'total_tva' => 'TotalVAT',
155 'total_localtax1' => 'TotalTax2',
156 'total_localtax2' => 'TotalTax3',
157 'multicurrency_total_ht' => 'TotalHTShortCurrency',
158 'multicurrency_total_ttc' => 'TotalTTCShortCurrency',
159 'multicurrency_total_tva' => 'TotalVATShortCurrency',
160 'tva_tx' => 'VATRate',
161 'localtax1_tx' => 'Localtax1Rate',
162 'localtax2_tx' => 'Localtax2Rate',
163 'vat_src_code' => 'VATCode',
164 'multicurrency_code' => 'Currency',
165 'qty' => 'Quantity',
166 'remise_percent' => $langs->transnoentitiesnoconv('Discount').' (%)',
167 'nom' => 'Name',
168 'name' => 'Name',
169 'email' => 'Email',
170 'address' => 'Address',
171 'town' => 'Town',
172 'state_code' => 'State',
173 'fk_pays' => 'Country',
174 'fk_typent' => 'CompanyType',
175 'revenuestamp' => 'RevenueStamp',
176 'code_client' => 'CustomerCode',
177 'code_fournisseur' => 'SupplierCode',
178 'capital' => 'Capital',
179 'fullname' => 'Fullname',
180 'period' => 'Period',
181 'localtax1_assuj' => 'UseLocalTax1',
182 'localtax2_assuj' => 'UseLocalTax2',
183 'localtax1_value' => 'LocalTax1DefaultValue',
184 'localtax2_value' => 'LocalTax2DefaultValue',
185 'subprice' => 'UnitPrice',
186 'product_type' => 'ProductType',
187 'product_label' => 'ProductLabel',
188 'type' => 'InvoiceType',
189 'info_bits' => 'TVA NPR or NOT',
190 'special_code' => 'Special line (WEEE line, option, id of module...)',
191 'status' => 'Status',
192 'cash' => 'PaymentTypeLIQ',
193 'cash_declared' => $langs->transnoentitiesnoconv('PaymentTypeLIQ').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
194 'cash_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeLIQ')),
195 'card' => 'PaymentTypeCB',
196 'card_declared' => $langs->transnoentitiesnoconv('PaymentTypeCB').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
197 'card_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeCB')),
198 'cheque' => 'PaymentTypeCHQ',
199 'cheque_declared' => $langs->transnoentitiesnoconv('PaymentTypeCHQ').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
200 'cheque_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeCHQ')),
201 'lifetime_start' => 'LifetimeStatDate',
202 'total_billed' => 'Turnover',
203 'total_collected' => 'TurnoverCollected',
204 'totallifetime_billed' => $langs->transnoentitiesnoconv('Turnover').' - '.$langs->transnoentitiesnoconv('LifetimeAmountShort'),
205 'totallifetime_collected' => $langs->transnoentitiesnoconv('TurnoverCollected').' - '.$langs->transnoentitiesnoconv('LifetimeAmountShort'),
206 'email_from' => 'MailFrom',
207 'email_to' => 'MailTo',
208 'email_msgid' => 'EmailMsgID',
209 'year_close' => 'Year',
210 'month_close' => 'Month',
211 'day_close' => 'Day',
212 'hour_close' => 'Hour',
213 'min_close' => 'Minutes',
214 'sec_close' => 'Second',
215 );
216
217 if (is_object($newobjtoshow) || is_array($newobjtoshow)) {
218 //var_dump($newobjtoshow);
219 foreach ($newobjtoshow as $key => $val) {
220 if (!is_object($val) && !is_array($val)) {
221 // TODO $val can be '__PHP_Incomplete_Class', the is_object return false
222 $s .= '<tr>';
223
224 // Field code
225 $s .= '<td>';
226 $types = $arrayoffields[$key]['type'] ?? '';
227 $labels = (array_key_exists($key, $convertkey) ? ($arrayoffields[$convertkey[$key]]['label'] ?? '') : '');
228 $s .= '<!-- '.$key.' '.$types.' '.$labels.' -->';
229 $s .= ($prefix ? $prefix.' > ' : '');
230 $s .= $key;
231 $s .= '</td>';
232
233 // Label
234 $s .= '<td>';
235 $label = '';
236 if (isset($arrayoffields[$key]['label'])) {
237 $label = $langs->trans($tmpobject->fields[$key]['label']);
238 } elseif (!empty($convertkey[$key]) && isset($arrayoffields[$convertkey[$key]]['label'])) {
239 $label = $langs->trans($tmpobject->fields[$convertkey[$key]]['label']);
240 } elseif ($prefix == 'mycompany' || $prefix == 'thirdparty') {
241 $reg = array();
242 if (preg_match('/^idprof(\d+)$/', $key, $reg)) {
243 $countrycode = property_exists($newobjtoshow, 'country_code') ? ($newobjtoshow->country_code ?? '') : '';
244 $label = $langs->trans("ProfId".$reg[1].$countrycode);
245 }
246 }
247 if (empty($label) && !empty($otherlabels[$key])) {
248 if (preg_match('/^invoiceline/', $prefix) && $key === 'ref') {
249 $label = $langs->trans("ProductRef");
250 } else {
251 $label = $langs->trans($otherlabels[$key]);
252 }
253 }
254 if (empty($label) && array_key_exists($key, $convertkey) && array_key_exists((string) $convertkey[$key], $otherlabels)) {
255 $label = $langs->trans((string) $otherlabels[(string) $convertkey[$key]]);
256 }
257 if (empty($label)) {
258 $label = array_key_exists($key, $convertkey) ? $convertkey[$key] : '';
259 }
260 if (!empty($label)) {
261 $s .= '<span class="opacitymedium">'.$label.'</span>';
262 }
263
264 // Value
265 $s .= '<td>';
266 if (in_array($key, array('type')) && $parentelement == 'facture') {
267 //var_dump($tmpobject);
268 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
269 $tmpinvoice = new Facture($db);
270 $tmpinvoice->type = $val;
271 $s .= $tmpinvoice->getLibType(0);
272 } elseif (in_array($key, array('date', 'datef'))) {
273 $s .= dol_print_date($val, 'day');
274 } elseif (in_array($key, array('dateh', 'datec', 'date_creation', 'datem', 'tms', 'date_valid', 'datep', 'lifetime_start'))) {
275 $s .= dol_print_date($val, 'dayhour');
276 } elseif (in_array($key, array('tva_assuj', 'localtax1_assuj', 'localtax2_assuj'))) {
277 $s .= yn($val);
278 } elseif (in_array($key, array('product_type'))) {
279 $s .= $val ? 'Product' : 'Service';
280 } elseif (in_array($key, array(
281 'qty', 'subprice',
282 'tva_tx', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_ttc', 'total_tva', 'total_localtax1', 'total_localtax2', 'localtax2', 'localtax2', 'revenuestamp',
283 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'multicurrency_subprice',
284 'opening',
285 'cash', 'cheque', 'card',
286 'amount',
287 'cash_declared', 'cheque_declared', 'card_declared', 'cash_lifetime', 'cheque_lifetime', 'card_lifetime'
288 )) || (isset($arrayoffields[$key]['type']) && in_array($arrayoffields[$key]['type'], array('price')))) {
289 $s .= '<span class="amount">'.price($val, 0, $langs, 1, 0, -2).'</span>';
290 } elseif (in_array($key, array('total_billed', 'total_collected', 'totallifetime_billed', 'totallifetime_collected'))) {
291 $s .= '<span class="amount">'.$val.'</span>';
292 } else {
293 $s .= $val;
294 }
295 $s .= '</td></tr>';
296 } elseif (is_array($val)) {
297 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key, $parentelement);
298 } elseif (is_object($val)) {
299 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key, $parentelement);
300 }
301 }
302 }
303
304 return $s;
305}
$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...)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.