Passed
Push — EXTRACT_CLASSES ( c53232...d3ffdd )
by Rafael
39:58
created

show_array_last_actions_done()   B

Complexity

Conditions 7
Paths 32

Size

Total Lines 88
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 59
nc 32
nop 1
dl 0
loc 88
rs 7.9612
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/* Copyright (C) 2008-2014 Laurent Destailleur  <[email protected]>
4
 * Copyright (C) 2005-2009 Regis Houssin        <[email protected]>
5
 * Copyright (C) 2011	   Juanjo Menent        <[email protected]>
6
 * Copyright (C) 2022-2024	Frédéric France				<[email protected]>
7
 * Copyright (C) 2024       Rafael San José             <[email protected]>
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21
 * or see https://www.gnu.org/
22
 */
23
24
/**
25
 * \file        htdocs/core/lib/agenda.lib.php
26
 * \brief       Set of function for the agenda module
27
 */
28
29
use Dolibarr\Code\Comm\Classes\ActionComm;
30
use Dolibarr\Code\Core\Classes\ExtraFields;
31
use Dolibarr\Code\Core\Classes\Form;
32
use Dolibarr\Code\Core\Classes\FormActions;
33
use Dolibarr\Code\Core\Classes\FormOther;
34
use Dolibarr\Code\Core\Classes\FormProjets;
35
use Dolibarr\Code\Core\Classes\Link;
36
use Dolibarr\Code\Resource\Classes\Dolresource;
37
use Dolibarr\Code\Resource\Classes\FormResource;
38
use Dolibarr\Code\Societe\Classes\Client;
39
use Dolibarr\Code\Societe\Classes\Societe;
40
41
42
/**
43
 * Show filter form in agenda view
44
 *
45
 * @param   Form            $form               Form object
46
 * @param   int             $canedit            Can edit filter fields
47
 * @param   int             $status             Status
48
 * @param   int             $year               Year
49
 * @param   int             $month              Month
50
 * @param   int             $day                Day
51
 * @param   int             $showbirthday       Show birthday
52
 * @param   string          $filtera            Filter on create by user
53
 * @param   string          $filtert            Filter on assigned to user
54
 * @param   string          $filtered           Filter of done by user
55
 * @param   int             $pid                Product id
56
 * @param   int             $socid              Third party id
57
 * @param   string          $action             Action string
58
 * @param   array           $showextcals        Array with list of external calendars (used to show links to select calendar), or -1 to show no legend
59
 * @param   string|array    $actioncode         Preselected value(s) of actioncode for filter on event type
60
 * @param   int             $usergroupid        Id of group to filter on users
61
 * @param   string          $excludetype        A type to exclude ('systemauto', 'system', '')
62
 * @param   int             $resourceid         Preselected value of resource for filter on resource
63
 * @param   int             $search_categ_cus   Tag id
64
 * @return  void
65
 */
66
function print_actions_filter(
67
    $form,
68
    $canedit,
69
    $status,
70
    $year,
71
    $month,
72
    $day,
73
    $showbirthday,
74
    $filtera,
75
    $filtert,
76
    $filtered,
77
    $pid,
78
    $socid,
79
    $action,
80
    $showextcals = array(),
81
    $actioncode = '',
82
    $usergroupid = 0,
83
    $excludetype = '',
84
    $resourceid = 0,
85
    $search_categ_cus = 0
86
) {
87
    global $user, $langs, $db, $hookmanager;
88
    global $massaction;
89
90
    $langs->load("companies");
91
92
        $formactions = new FormActions($db);
93
94
    // Filters
95
    //print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
96
    print '<input type="hidden" name="token" value="' . newToken() . '">';
97
    print '<input type="hidden" name="year" value="' . ((int) $year) . '">';
98
    print '<input type="hidden" name="month" value="' . ((int) $month) . '">';
99
    print '<input type="hidden" name="day" value="' . ((int) $day) . '">';
100
    if ($massaction != 'predelete' && $massaction != 'preaffecttag') {      // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
101
        print '<input type="hidden" name="action" value="' . $action . '">';
102
    }
103
    print '<input type="hidden" name="search_showbirthday" value="' . ((int) $showbirthday) . '">';
104
105
    print '<div class="divsearchfield">';
106
    // Type
107
    $multiselect = 0;
108
    if (getDolGlobalString('MAIN_ENABLE_MULTISELECT_TYPE')) {     // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
109
        $multiselect = (getDolGlobalString('AGENDA_USE_EVENT_TYPE'));
110
    }
111
    print img_picto($langs->trans("ActionType"), 'square', 'class="pictofixedwidth inline-block" style="color: #ddd;"');
112
    print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1), 0, $multiselect, 0, 'minwidth200 maxwidth250 widthcentpercentminusx');
113
    print '</div>';
114
115
    if ($canedit) {
116
        // Assigned to user
117
        print '<div class="divsearchfield">';
118
        print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="pictofixedwidth inline-block"');
119
        print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth100 maxwidth250 widthcentpercentminusx');
120
        print '</div>';
121
122
        // Assigned to user group
123
        print '<div class="divsearchfield">';
124
        print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="pictofixedwidth inline-block"');
125
        print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', '', '0', false, 'minwidth100 maxwidth250 widthcentpercentminusx');
126
        print '</div>';
127
128
        if (isModEnabled('resource')) {
129
            $formresource = new FormResource($db);
130
131
            // Resource
132
            print '<div class="divsearchfield">';
133
            print img_picto($langs->trans("Resource"), 'object_resource', 'class="pictofixedwidth inline-block"');
134
            print $formresource->select_resource_list($resourceid, "search_resourceid", [], 1, 0, 0, [], [], 2, 0, 'minwidth100 maxwidth250 widthcentpercentminusx');
135
            print '</div>';
136
        }
137
    }
138
139
    if (isModEnabled('societe') && $user->hasRight('societe', 'lire')) {
140
        print '<div class="divsearchfield">';
141
        print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"');
142
        print $form->select_company($socid, 'search_socid', '', '&nbsp;', 0, 0, null, 0, 'minwidth100 maxwidth250 widthcentpercentminusx');
143
        print '</div>';
144
    }
145
146
    if (isModEnabled('project') && $user->hasRight('projet', 'lire')) {
147
        $formproject = new FormProjets($db);
148
149
        print '<div class="divsearchfield">';
150
        print img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth inline-block"');
151
        print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'minwidth100 maxwidth250 widthcentpercentminusx');
152
        print '</div>';
153
    }
154
155
    if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
156
        $formother = new FormOther($db);
157
        $langs->load('categories');
158
159
        print '<div class="divsearchfield">';
160
        print img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
161
        print $formother->select_categories('actioncomm', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('ActionCommCategoriesArea'), 'minwidth100 maxwidth250 widthcentpercentminusx');
162
        print '</div>';
163
    }
164
165
    if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) {
166
        // Status
167
        print '<div class="divsearchfield">';
168
        print img_picto($langs->trans("Status"), 'status', 'class="pictofixedwidth inline-block"');
169
        $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100');
170
        print '</div>';
171
    }
172
173
    // Hooks
174
    $parameters = array('canedit' => $canedit, 'pid' => $pid, 'socid' => $socid);
175
    $object = null;
176
    $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been
177
178
    print '<div class="clearboth"></div>';
179
}
180
181
182
/**
183
 *  Show actions to do array
184
 *
185
 *  @param  int     $max        Max nb of records
186
 *  @return void
187
 */
188
function show_array_actions_to_do($max = 5)
189
{
190
    global $langs, $conf, $user, $db, $socid;
191
192
    $now = dol_now();
193
194
    include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
195
196
    $sql = "SELECT a.id, a.label, a.datep as dp, a.datep2 as dp2, a.fk_user_author, a.percent";
197
    $sql .= ", c.code, c.libelle as type_label";
198
    $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
199
    $sql .= ", s.code_client, s.code_compta, s.client";
200
    $sql .= ", s.logo, s.email, s.entity";
201
    $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a LEFT JOIN ";
202
    $sql .= " " . MAIN_DB_PREFIX . "c_actioncomm as c ON c.id = a.fk_action";
203
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid";
204
    if (!$user->hasRight('societe', 'client', 'voir')) {
205
        $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
206
    }
207
    $sql .= " WHERE a.entity IN (" . getEntity('agenda') . ")";
208
    $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep2 > '" . $db->idate($now) . "'))";
209
    if (!$user->hasRight('societe', 'client', 'voir')) {
210
        $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
211
    }
212
    if ($socid) {
213
        $sql .= " AND s.rowid = " . ((int) $socid);
214
    }
215
    $sql .= " ORDER BY a.datep DESC, a.id DESC";
216
    $sql .= $db->plimit($max, 0);
217
218
    $resql = $db->query($sql);
219
    if ($resql) {
220
        $num = $db->num_rows($resql);
221
222
        print '<div class="div-table-responsive-no-min">';
223
        print '<table class="noborder centpercent">';
224
        print '<tr class="liste_titre"><th colspan="2">' . $langs->trans("LastActionsToDo", $max) . '</th>';
225
        print '<th colspan="2" class="right"><a class="commonlink" href="' . constant('BASE_URL') . '/comm/action/list.php?mode=show_list&status=todo">' . $langs->trans("FullList") . '</a></th>';
226
        print '</tr>';
227
228
        $i = 0;
229
230
        $staticaction = new ActionComm($db);
231
        $customerstatic = new Client($db);
232
233
        while ($i < $num) {
234
            $obj = $db->fetch_object($resql);
235
236
237
            print '<tr class="oddeven">';
238
239
            $staticaction->type_code = $obj->code;
240
            $staticaction->label = ($obj->label ? $obj->label : $obj->type_label);
241
            $staticaction->id = $obj->id;
242
            print '<td>' . $staticaction->getNomUrl(1, 34) . '</td>';
243
244
            // print '<td>'.dol_trunc($obj->label,22).'</td>';
245
246
            print '<td>';
247
            if ($obj->socid > 0) {
248
                $customerstatic->id = $obj->socid;
249
                $customerstatic->name = $obj->name;
250
                //$customerstatic->name_alias = $obj->name_alias;
251
                $customerstatic->code_client = $obj->code_client;
252
                $customerstatic->code_compta = $obj->code_compta;
0 ignored issues
show
Deprecated Code introduced by
The property Dolibarr\Code\Societe\Cl...s\Societe::$code_compta has been deprecated: Use $code_compta_client ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

252
                /** @scrutinizer ignore-deprecated */ $customerstatic->code_compta = $obj->code_compta;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
253
                $customerstatic->client = $obj->client;
254
                $customerstatic->logo = $obj->logo;
255
                $customerstatic->email = $obj->email;
256
                $customerstatic->entity = $obj->entity;
257
                print $customerstatic->getNomUrl(1, '', 40);
258
            }
259
            print '</td>';
260
261
            $datep = $db->jdate($obj->dp);
262
            $datep2 = $db->jdate($obj->dp2);
263
264
            // Date
265
            print '<td width="100" class="right tddate">' . dol_print_date($datep, 'day') . '&nbsp;';
266
            $late = 0;
267
            if ($obj->percent == 0 && $datep && $datep < time()) {
268
                $late = 1;
269
            }
270
            if ($obj->percent == 0 && !$datep && $datep2 && $datep2 < time()) {
271
                $late = 1;
272
            }
273
            if ($obj->percent > 0 && $obj->percent < 100 && $datep2 && $datep2 < time()) {
274
                $late = 1;
275
            }
276
            if ($obj->percent > 0 && $obj->percent < 100 && !$datep2 && $datep && $datep < time()) {
277
                $late = 1;
278
            }
279
            if ($late) {
280
                print img_warning($langs->trans("Late"));
281
            }
282
            print "</td>";
283
284
            // Statut
285
            print '<td class="right" width="14">' . $staticaction->LibStatut($obj->percent, 3) . "</td>\n";
286
287
            print "</tr>\n";
288
289
            $i++;
290
        }
291
        print "</table></div><br>";
292
293
        $db->free($resql);
294
    } else {
295
        dol_print_error($db);
296
    }
297
}
298
299
300
/**
301
 *  Show last actions array
302
 *
303
 *  @param  int     $max        Max nb of records
304
 *  @return void
305
 */
306
function show_array_last_actions_done($max = 5)
307
{
308
    global $langs, $conf, $user, $db, $socid;
309
310
    $now = dol_now();
311
312
    $sql = "SELECT a.id, a.percent, a.datep as da, a.datep2 as da2, a.fk_user_author, a.label";
313
    $sql .= ", c.code, c.libelle";
314
    $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
315
    $sql .= ", s.code_client, s.code_compta, s.client";
316
    $sql .= ", s.logo, s.email, s.entity";
317
    $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a LEFT JOIN ";
318
    $sql .= " " . MAIN_DB_PREFIX . "c_actioncomm as c ON c.id = a.fk_action ";
319
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid";
320
    if (!$user->hasRight('societe', 'client', 'voir')) {
321
        $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
322
    }
323
    $sql .= " WHERE a.entity IN (" . getEntity('agenda') . ")";
324
    $sql .= " AND (a.percent >= 100 OR (a.percent = -1 AND a.datep2 <= '" . $db->idate($now) . "'))";
325
    if (!$user->hasRight('societe', 'client', 'voir')) {
326
        $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
327
    }
328
    if ($socid) {
329
        $sql .= " AND s.rowid = " . ((int) $socid);
330
    }
331
    $sql .= " ORDER BY a.datep2 DESC";
332
    $sql .= $db->plimit($max, 0);
333
334
    $resql = $db->query($sql);
335
    if ($resql) {
336
        $num = $db->num_rows($resql);
337
338
        print '<div class="div-table-responsive-no-min">';
339
        print '<table class="noborder centpercent">';
340
        print '<tr class="liste_titre"><th colspan="2">' . $langs->trans("LastDoneTasks", $max) . '</th>';
341
        print '<th colspan="2" class="right"><a class="commonlink" href="' . constant('BASE_URL') . '/comm/action/list.php?mode=show_list&status=done">' . $langs->trans("FullList") . '</a></th>';
342
        print '</tr>';
343
344
        $i = 0;
345
346
        $staticaction = new ActionComm($db);
347
        $customerstatic = new Societe($db);
348
349
        while ($i < $num) {
350
            $obj = $db->fetch_object($resql);
351
352
353
            print '<tr class="oddeven">';
354
355
            $staticaction->type_code = $obj->code;
356
            $staticaction->label = $obj->label;
357
            $staticaction->id = $obj->id;
358
            print '<td>' . $staticaction->getNomUrl(1, 34) . '</td>';
359
360
            //print '<td>'.dol_trunc($obj->label,24).'</td>';
361
362
            print '<td>';
363
            if ($obj->socid > 0) {
364
                $customerstatic->id = $obj->socid;
365
                $customerstatic->name = $obj->name;
366
                //$customerstatic->name_alias = $obj->name_alias;
367
                $customerstatic->code_client = $obj->code_client;
368
                $customerstatic->code_compta = $obj->code_compta;
0 ignored issues
show
Deprecated Code introduced by
The property Dolibarr\Code\Societe\Cl...s\Societe::$code_compta has been deprecated: Use $code_compta_client ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

368
                /** @scrutinizer ignore-deprecated */ $customerstatic->code_compta = $obj->code_compta;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
369
                $customerstatic->client = $obj->client;
370
                $customerstatic->logo = $obj->logo;
371
                $customerstatic->email = $obj->email;
372
                $customerstatic->entity = $obj->entity;
373
                print $customerstatic->getNomUrl(1, '', 30);
374
            }
375
            print '</td>';
376
377
            // Date
378
            print '<td width="100" class="right tddate">' . dol_print_date($db->jdate($obj->da2), 'day');
379
            print "</td>";
380
381
            // Status
382
            print '<td class="right" width="14">' . $staticaction->LibStatut($obj->percent, 3) . "</td>\n";
383
384
            print "</tr>\n";
385
            $i++;
386
        }
387
        // TODO Ajouter rappel pour "il y a des contrats a mettre en service"
388
        // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration"
389
        print "</table></div><br>";
390
391
        $db->free($resql);
392
    } else {
393
        dol_print_error($db);
394
    }
395
}
396
397
398
/**
399
 * Prepare array with list of tabs
400
 *
401
 * @return  array               Array of tabs to show
402
 */
403
function agenda_prepare_head()
404
{
405
    global $langs, $conf, $user, $db;
406
407
    $extrafields = new ExtraFields($db);
408
    $extrafields->fetch_name_optionals_label('actioncomm');
409
410
    $h = 0;
411
    $head = array();
412
413
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda_other.php";
414
    $head[$h][1] = $langs->trans("Miscellaneous");
415
    $head[$h][2] = 'other';
416
    $h++;
417
418
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda.php";
419
    $head[$h][1] = $langs->trans("AutoActions");
420
    $head[$h][2] = 'autoactions';
421
    $h++;
422
423
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda_reminder.php";
424
    $head[$h][1] = $langs->trans("Reminders");
425
    $head[$h][2] = 'reminders';
426
    $h++;
427
428
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda_xcal.php";
429
    $head[$h][1] = $langs->trans("ExportCal");
430
    $head[$h][2] = 'xcal';
431
    $h++;
432
433
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda_extsites.php";
434
    $head[$h][1] = $langs->trans("ExtSites");
435
    $head[$h][2] = 'extsites';
436
    $h++;
437
438
    complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin');
439
440
    $head[$h][0] = constant('BASE_URL') . "/admin/agenda_extrafields.php";
441
    $head[$h][1] = $langs->trans("ExtraFields");
442
    $nbExtrafields = $extrafields->attributes['actioncomm']['count'];
443
    if ($nbExtrafields > 0) {
444
        $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
445
    }
446
    $head[$h][2] = 'attributes';
447
    $h++;
448
449
    complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin', 'remove');
450
451
452
    return $head;
453
}
454
455
/**
456
 * Prepare array with list of tabs
457
 *
458
 * @param   object  $object     Object related to tabs
459
 * @return  array               Array of tabs to show
460
 */
461
function actions_prepare_head($object)
462
{
463
    global $db, $langs, $conf, $user;
464
465
    $h = 0;
466
    $head = array();
467
468
    $head[$h][0] = constant('BASE_URL') . '/comm/action/card.php?id=' . $object->id;
469
    $head[$h][1] = $langs->trans("CardAction");
470
    $head[$h][2] = 'card';
471
    $h++;
472
473
    // Tab to link resources
474
    if (isModEnabled('resource')) {
475
        $resource = new Dolresource($db);
476
477
        $head[$h][0] = constant('BASE_URL') . '/resource/element_resource.php?element=action&element_id=' . $object->id;
478
        $listofresourcelinked = $resource->getElementResources($object->element, $object->id);
479
        $nbResources = (is_array($listofresourcelinked) ? count($listofresourcelinked) : 0);
480
        $head[$h][1] = $langs->trans("Resources");
481
        if ($nbResources > 0) {
482
            $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">' . ($nbResources) . '</span>' : '');
483
        }
484
        $head[$h][2] = 'resources';
485
        $h++;
486
    }
487
488
    // Attached files
489
    require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/files.lib.php';
490
    $upload_dir = $conf->agenda->dir_output . "/" . $object->id;
491
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
492
    $nbLinks = Link::count($db, $object->element, $object->id);
493
    $head[$h][0] = constant('BASE_URL') . '/comm/action/document.php?id=' . $object->id;
494
    $head[$h][1] = $langs->trans("Documents");
495
    if (($nbFiles + $nbLinks) > 0) {
496
        $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>' : '');
497
    }
498
    $head[$h][2] = 'documents';
499
    $h++;
500
501
    $head[$h][0] = constant('BASE_URL') . '/comm/action/info.php?id=' . $object->id;
502
    $head[$h][1] = $langs->trans('Info');
503
    $head[$h][2] = 'info';
504
    $h++;
505
506
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'action');
507
508
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'action', 'remove');
509
510
    return $head;
511
}
512
513
514
/**
515
 *  Define head array for tabs of agenda setup pages
516
 *
517
 *  @param  string  $param      Parameters to add to url
518
 *  @return array               Array of head
519
 */
520
function calendars_prepare_head($param)
521
{
522
    global $langs, $conf, $user;
523
524
    $h = 0;
525
    $head = array();
526
527
    $head[$h][0] = constant('BASE_URL') . '/comm/action/list.php?mode=show_list' . ($param ? '&' . $param : '');
528
    $head[$h][1] = $langs->trans("ViewList");
529
    $head[$h][2] = 'cardlist';
530
    $h++;
531
532
    $head[$h][0] = constant('BASE_URL') . '/comm/action/index.php?mode=show_month' . ($param ? '&' . $param : '');
533
    $head[$h][1] = $langs->trans("ViewCal");
534
    $head[$h][2] = 'cardmonth';
535
    $h++;
536
537
    $head[$h][0] = constant('BASE_URL') . '/comm/action/index.php?mode=show_week' . ($param ? '&' . $param : '');
538
    $head[$h][1] = $langs->trans("ViewWeek");
539
    $head[$h][2] = 'cardweek';
540
    $h++;
541
542
    $head[$h][0] = constant('BASE_URL') . '/comm/action/index.php?mode=show_day' . ($param ? '&' . $param : '');
543
    $head[$h][1] = $langs->trans("ViewDay");
544
    $head[$h][2] = 'cardday';
545
    $h++;
546
547
    //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
548
    if (getDolGlobalString('AGENDA_SHOW_PERTYPE')) {
549
        $head[$h][0] = constant('BASE_URL') . '/comm/action/pertype.php' . ($param ? '?' . $param : '');
550
        $head[$h][1] = $langs->trans("ViewPerType");
551
        $head[$h][2] = 'cardpertype';
552
        $h++;
553
    }
554
555
    $newparam = $param;
556
    $newparam = preg_replace('/&?search_filtert=\d+/', '', $newparam);
557
    $head[$h][0] = constant('BASE_URL') . '/comm/action/peruser.php' . ($newparam ? '?' . $newparam : '');
558
    $head[$h][1] = $langs->trans("ViewPerUser");
559
    $head[$h][2] = 'cardperuser';
560
    $h++;
561
562
563
    // Show more tabs from modules
564
    // Entries must be declared in modules descriptor with line
565
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
566
    // $this->tabs = array('entity:-tabname);                                                   to remove a tab
567
    complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda');
568
569
    complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda', 'remove');
570
571
    return $head;
572
}
573