dolibarr 25.0.0-alpha
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, $mysoc;
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 'zip' => 'Zip',
173 'state_code' => 'State',
174 'fk_pays' => 'Country',
175 'fk_typent' => 'CompanyType',
176 'revenuestamp' => 'RevenueStamp',
177 'code_client' => 'CustomerCode',
178 'code_fournisseur' => 'SupplierCode',
179 'capital' => 'Capital',
180 'fullname' => 'Fullname',
181 'period' => 'Period',
182 'tva_assuj' => 'VATIsUsed',
183 'localtax1_assuj' => $langs->transcountry('LocalTax1IsUsed', $mysoc->country_code),
184 'localtax2_assuj' => $langs->transcountry('LocalTax2IsUsed', $mysoc->country_code),
185 'localtax1_value' => 'Localtax1Rate',
186 'localtax2_value' => 'Localtax2Rate',
187 'subprice' => 'UnitPrice',
188 'product_type' => 'ProductType',
189 'product_label' => 'ProductLabel',
190 'type' => 'InvoiceType',
191 'info_bits' => 'TVA NPR or NOT',
192 'special_code' => 'Special line (WEEE line, option, id of module...)',
193 'status' => 'Status',
194 'cash' => 'PaymentTypeLIQ',
195 'cash_declared' => $langs->transnoentitiesnoconv('PaymentTypeLIQ').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
196 'cash_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeLIQ')),
197 'card' => 'PaymentTypeCB',
198 'card_declared' => $langs->transnoentitiesnoconv('PaymentTypeCB').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
199 'card_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeCB')),
200 'cheque' => 'PaymentTypeCHQ',
201 'cheque_declared' => $langs->transnoentitiesnoconv('PaymentTypeCHQ').' - '.$langs->transnoentitiesnoconv("AmuntCountedByUserShort"),
202 'cheque_lifetime' => $langs->transnoentitiesnoconv('LifetimeAmount', $langs->transnoentitiesnoconv('PaymentTypeCHQ')),
203 'lifetime_start' => 'LifetimeStatDate',
204 'total_billed' => 'Turnover',
205 'total_collected' => 'TurnoverCollected',
206 'totallifetime_billed' => $langs->transnoentitiesnoconv('Turnover').' - '.$langs->transnoentitiesnoconv('LifetimeAmountShort'),
207 'totallifetime_collected' => $langs->transnoentitiesnoconv('TurnoverCollected').' - '.$langs->transnoentitiesnoconv('LifetimeAmountShort'),
208 'email_from' => 'MailFrom',
209 'email_to' => 'MailTo',
210 'email_msgid' => 'EmailMsgID',
211 'year_close' => 'Year',
212 'month_close' => 'Month',
213 'day_close' => 'Day',
214 'hour_close' => 'Hour',
215 'min_close' => 'Minutes',
216 'sec_close' => 'Second',
217 );
218
219 if (is_object($newobjtoshow) || is_array($newobjtoshow)) {
220 //var_dump($newobjtoshow);
221 foreach ($newobjtoshow as $key => $val) {
222 if (!is_object($val) && !is_array($val)) {
223 // $val can be '__PHP_Incomplete_Class', the is_object return false
224 $s .= '<tr>';
225
226 // Field code
227 $s .= '<td>';
228 $types = $arrayoffields[$key]['type'] ?? '';
229 $labels = (array_key_exists($key, $convertkey) ? ($arrayoffields[$convertkey[$key]]['label'] ?? '') : '');
230 $s .= '<!-- '.$key.' '.$types.' '.$labels.' -->';
231 $s .= ($prefix ? $prefix.' > ' : '');
232 $s .= $key;
233 $s .= '</td>';
234
235 // Label
236 $s .= '<td>';
237 $label = '';
238 if (isset($arrayoffields[$key]['label'])) {
239 $label = $langs->trans($tmpobject->fields[$key]['label']);
240 } elseif (!empty($convertkey[$key]) && isset($arrayoffields[$convertkey[$key]]['label'])) {
241 $label = $langs->trans($tmpobject->fields[$convertkey[$key]]['label']);
242 } elseif ($prefix == 'mycompany' || $prefix == 'thirdparty') {
243 $reg = array();
244 if (preg_match('/^idprof(\d+)$/', $key, $reg)) {
245 $countrycode = property_exists($newobjtoshow, 'country_code') ? ($newobjtoshow->country_code ?? '') : '';
246 $label = $langs->trans("ProfId".$reg[1].$countrycode);
247 }
248 }
249 if (empty($label) && !empty($otherlabels[$key])) {
250 if (preg_match('/^invoiceline/', $prefix) && $key === 'ref') {
251 $label = $langs->trans("ProductRef");
252 } else {
253 $label = $langs->trans($otherlabels[$key]);
254 }
255 }
256 if (empty($label) && array_key_exists($key, $convertkey) && array_key_exists((string) $convertkey[$key], $otherlabels)) {
257 $label = $langs->trans((string) $otherlabels[(string) $convertkey[$key]]);
258 }
259 if (empty($label)) {
260 $label = array_key_exists($key, $convertkey) ? $convertkey[$key] : '';
261 }
262 if (!empty($label)) {
263 $s .= '<span class="opacitymedium">'.$label.'</span>';
264 }
265
266 // Value
267 $s .= '<td>';
268 if (in_array($key, array('type')) && $parentelement == 'facture') {
269 //var_dump($tmpobject);
270 include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
271 $tmpinvoice = new Facture($db);
272 $tmpinvoice->type = $val;
273 $s .= $tmpinvoice->getLibType(0);
274 } elseif (in_array($key, array('date', 'datef'))) {
275 $s .= dol_print_date($val, 'day');
276 } elseif (in_array($key, array('dateh', 'datec', 'date_creation', 'datem', 'tms', 'date_valid', 'datep', 'lifetime_start'))) {
277 $s .= dol_print_date($val, 'dayhour');
278 } elseif (in_array($key, array('tva_assuj', 'localtax1_assuj', 'localtax2_assuj'))) {
279 $s .= yn($val);
280 } elseif (in_array($key, array('product_type'))) {
281 $s .= $val ? 'Product' : 'Service';
282 } elseif (in_array($key, array(
283 'qty', 'subprice',
284 'tva_tx', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_ttc', 'total_tva', 'total_localtax1', 'total_localtax2', 'localtax2', 'localtax2', 'revenuestamp',
285 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'multicurrency_subprice',
286 'opening',
287 'cash', 'cheque', 'card',
288 'amount',
289 'cash_declared', 'cheque_declared', 'card_declared', 'cash_lifetime', 'cheque_lifetime', 'card_lifetime'
290 )) || (isset($arrayoffields[$key]['type']) && in_array($arrayoffields[$key]['type'], array('price')))) {
291 $s .= '<span class="amount">'.price($val, 0, $langs, 1, 0, -2).'</span>';
292 } elseif (in_array($key, array('total_billed', 'total_collected', 'totallifetime_billed', 'totallifetime_collected'))) {
293 $s .= '<span class="amount">'.$val.'</span>';
294 } else {
295 $s .= $val;
296 }
297 $s .= '</td></tr>';
298 } elseif (is_array($val)) {
299 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key, $parentelement);
300 } elseif (is_object($val)) {
301 $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key, $parentelement);
302 }
303 }
304 }
305
306 return $s;
307}
$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...)
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.