1 | <?php |
||||
2 | |||||
3 | /* Copyright (C) 2003-2007 Rodolphe Quiedeville <[email protected]> |
||||
4 | * Copyright (C) 2004-2016 Laurent Destailleur <[email protected]> |
||||
5 | * Copyright (C) 2005 Marc Barilley / Ocebo <[email protected]> |
||||
6 | * Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
||||
7 | * Copyright (C) 2013 Cédric Salvador <[email protected]> |
||||
8 | * Copyright (C) 2017 Ferran Marcet <[email protected]> |
||||
9 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||||
10 | * |
||||
11 | * This program is free software; you can redistribute it and/or modify |
||||
12 | * it under the terms of the GNU General Public License as published by |
||||
13 | * the Free Software Foundation; either version 3 of the License, or |
||||
14 | * (at your option) any later version. |
||||
15 | * |
||||
16 | * This program is distributed in the hope that it will be useful, |
||||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
19 | * GNU General Public License for more details. |
||||
20 | * |
||||
21 | * You should have received a copy of the GNU General Public License |
||||
22 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
23 | */ |
||||
24 | |||||
25 | use Dolibarr\Code\Comm\Classes\Propal; |
||||
26 | use Dolibarr\Code\Commande\Classes\Commande; |
||||
27 | use Dolibarr\Code\Core\Classes\Form; |
||||
28 | use Dolibarr\Code\Expedition\Classes\Expedition; |
||||
29 | use Dolibarr\Code\Projet\Classes\Project; |
||||
30 | use Dolibarr\Lib\ViewMain; |
||||
31 | |||||
32 | /** |
||||
33 | * \file htdocs/expedition/document.php |
||||
34 | * \ingroup expedition |
||||
35 | * \brief Management page of documents attached to an expedition |
||||
36 | */ |
||||
37 | |||||
38 | // Load Dolibarr environment |
||||
39 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||||
40 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/order.lib.php'; |
||||
41 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/files.lib.php'; |
||||
42 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/images.lib.php'; |
||||
43 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/sendings.lib.php'; |
||||
44 | if (isModEnabled('project')) { |
||||
45 | } |
||||
46 | |||||
47 | // Load translation files required by the page |
||||
48 | $langs->loadLangs(array('companies', 'other')); |
||||
49 | |||||
50 | $action = GETPOST('action', 'aZ09'); |
||||
51 | $confirm = GETPOST('confirm'); |
||||
52 | $id = GETPOSTINT('id'); |
||||
53 | $ref = GETPOST('ref'); |
||||
54 | |||||
55 | // Get parameters |
||||
56 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||||
57 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||||
58 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||||
59 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||||
60 | if (empty($page) || $page == -1) { |
||||
61 | $page = 0; |
||||
62 | } // If $page is not defined, or '' or -1 |
||||
63 | $offset = $limit * $page; |
||||
64 | $pageprev = $page - 1; |
||||
65 | $pagenext = $page + 1; |
||||
66 | if (!$sortorder) { |
||||
67 | $sortorder = "ASC"; |
||||
68 | } |
||||
69 | if (!$sortfield) { |
||||
70 | $sortfield = "name"; |
||||
71 | } |
||||
72 | |||||
73 | $object = new Expedition($db); |
||||
74 | |||||
75 | if ($id > 0 || !empty($ref)) { |
||||
76 | $object->fetch($id, $ref); |
||||
77 | $object->fetch_thirdparty(); |
||||
78 | |||||
79 | if (!empty($object->origin)) { |
||||
0 ignored issues
–
show
|
|||||
80 | $typeobject = $object->origin; |
||||
0 ignored issues
–
show
The property
Dolibarr\Core\Base\CommonObject::$origin has been deprecated: Use $origin_type and $origin_id instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||
81 | $origin = $object->origin; |
||||
0 ignored issues
–
show
The property
Dolibarr\Core\Base\CommonObject::$origin has been deprecated: Use $origin_type and $origin_id instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||
82 | $object->fetch_origin(); |
||||
83 | } |
||||
84 | |||||
85 | // Linked documents |
||||
86 | if ($typeobject == 'commande' && $object->origin_object->id && isModEnabled('order')) { |
||||
87 | $objectsrc = new Commande($db); |
||||
88 | $objectsrc->fetch($object->origin_object->id); |
||||
89 | } |
||||
90 | if ($typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) { |
||||
91 | $objectsrc = new Propal($db); |
||||
92 | $objectsrc->fetch($object->origin_object->id); |
||||
93 | } |
||||
94 | |||||
95 | $upload_dir = $conf->expedition->dir_output . "/sending/" . dol_sanitizeFileName($object->ref); |
||||
96 | } |
||||
97 | |||||
98 | // Security check |
||||
99 | if ($user->socid) { |
||||
100 | $socid = $user->socid; |
||||
101 | } |
||||
102 | $result = restrictedArea($user, 'expedition', $object->id, ''); |
||||
103 | |||||
104 | $permissiontoadd = $user->hasRight('expedition', 'creer'); // Used by the include of actions_dellink.inc.php |
||||
105 | |||||
106 | |||||
107 | /* |
||||
108 | * Actions |
||||
109 | */ |
||||
110 | |||||
111 | include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; |
||||
112 | |||||
113 | |||||
114 | /* |
||||
115 | * View |
||||
116 | */ |
||||
117 | |||||
118 | ViewMain::llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:expeditions_Clients|ES:Pedidos de clientes'); |
||||
119 | |||||
120 | $form = new Form($db); |
||||
121 | |||||
122 | if ($id > 0 || !empty($ref)) { |
||||
123 | if ($object->fetch($id, $ref)) { |
||||
124 | $object->fetch_thirdparty(); |
||||
125 | |||||
126 | $upload_dir = $conf->expedition->dir_output . '/sending/' . dol_sanitizeFileName($object->ref); |
||||
127 | |||||
128 | $head = shipping_prepare_head($object); |
||||
129 | print dol_get_fiche_head($head, 'documents', $langs->trans("Shipment"), -1, $object->picto); |
||||
130 | |||||
131 | |||||
132 | // Build file list |
||||
133 | $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); |
||||
134 | $totalsize = 0; |
||||
135 | foreach ($filearray as $key => $file) { |
||||
136 | $totalsize += $file['size']; |
||||
137 | } |
||||
138 | |||||
139 | // Shipment card |
||||
140 | $linkback = '<a href="' . constant('BASE_URL') . '/expedition/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
||||
141 | |||||
142 | |||||
143 | $morehtmlref = '<div class="refidno">'; |
||||
144 | // Ref customer |
||||
145 | $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1); |
||||
146 | $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1); |
||||
147 | // Thirdparty |
||||
148 | $morehtmlref .= '<br>' . $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
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. ![]() |
|||||
149 | |||||
150 | // Project |
||||
151 | if (isModEnabled('project')) { |
||||
152 | $langs->load("projects"); |
||||
153 | $morehtmlref .= '<br>'; |
||||
154 | if (0) { // Do not change on shipment |
||||
155 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||||
156 | if ($action != 'classify') { |
||||
157 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||||
158 | } |
||||
159 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); |
||||
160 | } else { |
||||
161 | if (!empty($objectsrc->fk_project)) { |
||||
162 | $proj = new Project($db); |
||||
163 | $proj->fetch($objectsrc->fk_project); |
||||
164 | $morehtmlref .= $proj->getNomUrl(1); |
||||
165 | if ($proj->title) { |
||||
166 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||||
167 | } |
||||
168 | } |
||||
169 | } |
||||
170 | } |
||||
171 | $morehtmlref .= '</div>'; |
||||
172 | |||||
173 | // Order card |
||||
174 | |||||
175 | $linkback = '<a href="' . constant('BASE_URL') . '/expedition/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; |
||||
176 | |||||
177 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
||||
178 | |||||
179 | print '<div class="fichecenter">'; |
||||
180 | print '<div class="underbanner clearboth"></div>'; |
||||
181 | |||||
182 | print '<table class="border tableforfield centpercent">'; |
||||
183 | |||||
184 | print '<tr><td class="titlefield">' . $langs->trans("NbOfAttachedFiles") . '</td><td colspan="3">' . count($filearray) . '</td></tr>'; |
||||
185 | print '<tr><td>' . $langs->trans("TotalSizeOfAttachedFiles") . '</td><td colspan="3">' . dol_print_size($totalsize, 1, 1) . '</td></tr>'; |
||||
186 | |||||
187 | print "</table>\n"; |
||||
188 | |||||
189 | print "</div>\n"; |
||||
190 | |||||
191 | print dol_get_fiche_end(); |
||||
192 | |||||
193 | $modulepart = 'expedition'; |
||||
194 | $permissiontoadd = $user->hasRight('expedition', 'creer'); |
||||
195 | $permtoedit = $user->hasRight('expedition', 'creer'); |
||||
196 | $param = '&id=' . $object->id; |
||||
197 | include DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; |
||||
198 | } else { |
||||
199 | dol_print_error($db); |
||||
200 | } |
||||
201 | } else { |
||||
202 | header('Location: index.php'); |
||||
203 | exit; |
||||
204 | } |
||||
205 | |||||
206 | // End of page |
||||
207 | ViewMain::llxFooter(); |
||||
208 | $db->close(); |
||||
209 |
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.