show_array_actions_to_do()   F
last analyzed

Complexity

Conditions 25
Paths 1040

Size

Total Lines 108
Code Lines 73

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 25
eloc 73
nc 1040
nop 1
dl 0
loc 108
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

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

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

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