Issues (2811)

public/htdocs/contrat/ticket.php (1 issue)

Labels
Severity
1
<?php
2
3
/* Copyright (C) 2004       Rodolphe Quiedeville        <[email protected]>
4
 * Copyright (C) 2004-2016	Laurent Destailleur		    <[email protected]>
5
 * Copyright (C) 2012-2023	Charlene BENKE		        <[email protected]>
6
 * Copyright (C) 2024		MDW							<[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 <http://www.gnu.org/licenses/>.
21
 */
22
23
use Dolibarr\Code\Contrat\Classes\Contrat;
24
use Dolibarr\Code\Core\Classes\Form;
25
use Dolibarr\Code\Projet\Classes\Project;
26
use Dolibarr\Code\User\Classes\User;
27
use Dolibarr\Lib\ViewMain;
28
29
/**
30
 *      \file       htdocs/contrat/ticket.php
31
 *      \ingroup    contrat
32
 *      \brief      Page of associated ticket
33
 */
34
35
require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php';
36
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/contract.lib.php';
37
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/date.lib.php';
38
39
$langs->loadLangs(array('companies', 'contracts', 'tickets'));
40
41
$socid = GETPOSTINT('socid');
42
$id = GETPOSTINT('id');
43
$ref = GETPOST('ref', 'alpha');
44
$action = GETPOST('action', 'alpha');
45
46
if ($id == '' && $ref == '') {
47
    dol_print_error(null, 'Bad parameter');
48
    exit;
49
}
50
51
// Security check
52
$socid = 0;
53
if ($user->socid > 0) {
54
    $socid = $user->socid;
55
}
56
57
$result = restrictedArea($user, 'contrat', $id);
58
59
60
/*
61
 *	View
62
 */
63
64
ViewMain::llxHeader("", $langs->trans("Tickets"), "Contrat");
65
66
$form = new Form($db);
67
$userstatic = new User($db);
68
69
$object = new Contrat($db);
70
$result = $object->fetch($id, $ref);
71
$ret = $object->fetch_thirdparty();
72
$head = contract_prepare_head($object);
73
74
dol_get_fiche_head($head, 'ticket', $langs->trans("Contract"), -1, 'contract');
75
76
$linkback = '<a href="' . constant('BASE_URL') . '/contrat/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">';
77
$linkback .= $langs->trans("BackToList") . '</a>';
78
79
$morehtmlref = '';
80
$morehtmlref .= $object->ref;
81
82
$morehtmlref .= '<div class="refidno">';
83
// Ref customer
84
$morehtmlref .= $form->editfieldkey(
85
    "RefCustomer",
86
    'ref_customer',
87
    $object->ref_customer,
88
    $object,
89
    0,
90
    'string',
91
    '',
92
    0,
93
    1
94
);
95
$morehtmlref .= $form->editfieldval(
96
    "RefCustomer",
97
    'ref_customer',
98
    $object->ref_customer,
99
    $object,
100
    0,
101
    'string',
102
    '',
103
    null,
104
    null,
105
    '',
106
    1
107
);
108
// Ref supplier
109
$morehtmlref .= '<br>';
110
$morehtmlref .= $form->editfieldkey(
111
    "RefSupplier",
112
    'ref_supplier',
113
    $object->ref_supplier,
114
    $object,
115
    0,
116
    'string',
117
    '',
118
    0,
119
    1
120
);
121
$morehtmlref .= $form->editfieldval(
122
    "RefSupplier",
123
    'ref_supplier',
124
    $object->ref_supplier,
125
    $object,
126
    0,
127
    'string',
128
    '',
129
    null,
130
    null,
131
    '',
132
    1
133
);
134
// Thirdparty
135
$morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
0 ignored issues
show
The method getNomUrl() does not exist on null. ( Ignorable by Annotation )

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

135
$morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->/** @scrutinizer ignore-call */ getNomUrl(1);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
136
// Project
137
if (!empty($conf->projet->enabled)) {
138
    $langs->load("projects");
139
    $morehtmlref .= '<br>' . $langs->trans('Project') . ' : ';
140
    if (!empty($object->fk_project)) {
141
        $proj = new Project($db);
142
        $proj->fetch($object->fk_project);
143
        $morehtmlref .= '<a href="' . constant('BASE_URL') . '/projet/card.php?id=';
144
        $morehtmlref .= $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
145
        $morehtmlref .= $proj->ref;
146
        $morehtmlref .= '</a>';
147
    } else {
148
        $morehtmlref .= '';
149
    }
150
}
151
$morehtmlref .= '</div>';
152
153
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
154
155
print '<div class="underbanner clearboth"></div>';
156
157
158
/*
159
 * Referrers types
160
 */
161
162
$title = $langs->trans("ListTicketsLinkToContract");
163
164
print '<table class="noborder" width="100%">';
165
print '<tr class="liste_titre">';
166
print '<td >' . $langs->trans("Ref") . '</td>';
167
print '<td width="300">' . $langs->trans("Subject") . '</td>';
168
print '<td align="left">' . $langs->trans("Type") . '</td>';
169
print '<td align="left" nowrap >' . $langs->trans("TicketCategory") . '</td>';
170
print '<td align="left">' . $langs->trans("Severity") . '</td>';
171
print '<td  align="center">' . $langs->trans("Date") . '</td>';
172
print '<td  align="center" nowrap >' . $langs->trans("DateEnd") . '</td>';
173
print '<td  align="right">' . $langs->trans("Progress") . '</td>';
174
print '<td align="right" width="100">' . $langs->trans("Status") . '</td>';
175
print '</tr>';
176
// on récupère la totalité des tickets liés au contrat
177
$allticketarray = $object->getTicketsArray();
178
if (is_array($allticketarray) && count($allticketarray) > 0) {
179
    foreach ($allticketarray as $key => $value) {
180
        $total_ht = 0;
181
        $total_ttc = 0;
182
183
        $element = $value;
184
185
        print "<tr>";
186
187
        // Ref
188
        print '<td align="left">';
189
        print $element->getNomUrl(1);
190
        print "</td>\n";
191
192
        // Information
193
        print '<td align="left">' . $value->subject . '</td>';
194
        print '<td align="left">' . $value->type_label . '</td>';
195
        print '<td align="left">' . $value->category_label . '</td>';
196
        print '<td align="left">' . $value->severity_label . '</td>';
197
198
        // Date
199
        print '<td align="center">' . dol_print_date($element->datec, 'day') . '</td>';
200
        print '<td align="center">' . dol_print_date($element->date_close, 'day') . '</td>';
201
202
        // Duration
203
        print '<td align="right">';
204
        print(isset($element->progress) ? $element->progress . '%' : '');
205
        print '</td>';
206
207
        // Status
208
        print '<td align="right">' . $element->getLibStatut(5) . '</td>';
209
        print '</tr>';
210
    }
211
}
212
print "</table>";
213
214
215
ViewMain::llxFooter();
216
$db->close();
217