1 | <?php |
||||
2 | |||||
3 | /* Copyright (C) 2001-2005 Rodolphe Quiedeville <[email protected]> |
||||
4 | * Copyright (C) 2003 Eric Seigne <[email protected]> |
||||
5 | * Copyright (C) 2004-2016 Laurent Destailleur <[email protected]> |
||||
6 | * Copyright (C) 2005-2010 Regis Houssin <[email protected]> |
||||
7 | * Copyright (C) 2010-2015 Juanjo Menent <[email protected]> |
||||
8 | * Copyright (C) 2014 Jean Heimburger <[email protected]> |
||||
9 | * Copyright (C) 2015 Marcos García <[email protected]> |
||||
10 | * Copyright (C) 2015 Raphaël Doursenaud <[email protected]> |
||||
11 | * Copyright (C) 2021 Frédéric France <[email protected]> |
||||
12 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||||
13 | * |
||||
14 | * This program is free software; you can redistribute it and/or modify |
||||
15 | * it under the terms of the GNU General Public License as published by |
||||
16 | * the Free Software Foundation; either version 3 of the License, or |
||||
17 | * (at your option) any later version. |
||||
18 | * |
||||
19 | * This program is distributed in the hope that it will be useful, |
||||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
22 | * GNU General Public License for more details. |
||||
23 | * |
||||
24 | * You should have received a copy of the GNU General Public License |
||||
25 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
26 | */ |
||||
27 | |||||
28 | use Dolibarr\Code\Adherents\Classes\Adherent; |
||||
29 | use Dolibarr\Code\Categories\Classes\Categorie; |
||||
30 | use Dolibarr\Code\Contact\Classes\Contact; |
||||
31 | use Dolibarr\Code\Core\Classes\ExtraFields; |
||||
32 | use Dolibarr\Code\Core\Classes\Form; |
||||
33 | use Dolibarr\Code\Fourn\Classes\CommandeFournisseur; |
||||
34 | use Dolibarr\Code\Fourn\Classes\FactureFournisseur; |
||||
35 | use Dolibarr\Code\Fourn\Classes\Fournisseur; |
||||
36 | use Dolibarr\Code\Product\Classes\Product; |
||||
37 | use Dolibarr\Code\SupplierProposal\Classes\SupplierProposal; |
||||
38 | use Dolibarr\Lib\ViewMain; |
||||
39 | |||||
40 | /** |
||||
41 | * \file htdocs/fourn/card.php |
||||
42 | * \ingroup fournisseur, facture |
||||
43 | * \brief Page for supplier third party card (view, edit) |
||||
44 | */ |
||||
45 | |||||
46 | // Load Dolibarr environment |
||||
47 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||||
48 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/company.lib.php'; |
||||
49 | if (!empty($conf->accounting->enabled)) { |
||||
50 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/accounting.lib.php'; |
||||
51 | } |
||||
52 | |||||
53 | // Load translation files required by page |
||||
54 | $langs->loadLangs(array( |
||||
55 | 'companies', |
||||
56 | 'suppliers', |
||||
57 | 'products', |
||||
58 | 'bills', |
||||
59 | 'orders', |
||||
60 | 'commercial', |
||||
61 | )); |
||||
62 | |||||
63 | $action = GETPOST('action', 'aZ09'); |
||||
64 | $cancel = GETPOST('cancel', 'alpha'); |
||||
65 | |||||
66 | // Security check |
||||
67 | $id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id')); |
||||
68 | if ($user->socid) { |
||||
69 | $id = $user->socid; |
||||
70 | } |
||||
71 | $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid'); |
||||
72 | |||||
73 | $object = new Fournisseur($db); |
||||
74 | $extrafields = new ExtraFields($db); |
||||
75 | |||||
76 | // fetch optionals attributes and labels |
||||
77 | $extrafields->fetch_name_optionals_label($object->table_element); |
||||
78 | |||||
79 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||||
80 | $hookmanager->initHooks(array('thirdpartysupplier', 'globalcard')); |
||||
81 | |||||
82 | // Security check |
||||
83 | $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); |
||||
84 | |||||
85 | if ($object->id > 0) { |
||||
86 | if (!($object->fournisseur > 0) || !$user->hasRight("fournisseur", "lire")) { |
||||
87 | accessforbidden(); |
||||
88 | } |
||||
89 | } |
||||
90 | |||||
91 | /* |
||||
92 | * Action |
||||
93 | */ |
||||
94 | |||||
95 | $parameters = array('id' => $id); |
||||
96 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||||
97 | if ($reshook < 0) { |
||||
98 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||||
99 | } |
||||
100 | |||||
101 | if (empty($reshook)) { |
||||
102 | if ($cancel) { |
||||
103 | $action = ""; |
||||
104 | } |
||||
105 | |||||
106 | // Set supplier accounting account |
||||
107 | if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) { |
||||
108 | $result = $object->fetch($id); |
||||
109 | $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); |
||||
0 ignored issues
–
show
|
|||||
110 | $result = $object->update($object->id, $user, 1, 0, 1); |
||||
111 | if ($result < 0) { |
||||
112 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
113 | $action = 'editsupplieraccountancycode'; |
||||
114 | } |
||||
115 | } |
||||
116 | // Set vat number accounting account |
||||
117 | if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) { |
||||
118 | $result = $object->fetch($id); |
||||
119 | $object->tva_intra = GETPOST("tva_intra"); |
||||
0 ignored issues
–
show
It seems like
GETPOST('tva_intra') can also be of type array or array or array . However, the property $tva_intra is declared as type string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||||
120 | $result = $object->update($object->id, $user, 1, 0, 0); |
||||
121 | if ($result < 0) { |
||||
122 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
123 | } |
||||
124 | } |
||||
125 | // Set payment terms of the settlement |
||||
126 | if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { |
||||
127 | $object->fetch($id); |
||||
128 | $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_supplier_id')); |
||||
129 | if ($result < 0) { |
||||
130 | dol_print_error($db, $object->error); |
||||
131 | } |
||||
132 | } |
||||
133 | // Payment mode |
||||
134 | if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { |
||||
135 | $object->fetch($id); |
||||
136 | $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_supplier_id')); |
||||
137 | if ($result < 0) { |
||||
138 | dol_print_error($db, $object->error); |
||||
139 | } |
||||
140 | } |
||||
141 | |||||
142 | // Bank account |
||||
143 | if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { |
||||
144 | $object->fetch($id); |
||||
145 | $result = $object->setBankAccount(GETPOSTINT('fk_account')); |
||||
146 | if ($result < 0) { |
||||
147 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
148 | } |
||||
149 | } |
||||
150 | |||||
151 | // update supplier order min amount |
||||
152 | if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) { |
||||
153 | $object->fetch($id); |
||||
154 | $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha')); |
||||
155 | $result = $object->update($object->id, $user); |
||||
156 | if ($result < 0) { |
||||
157 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
158 | } |
||||
159 | } |
||||
160 | |||||
161 | if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) { |
||||
162 | $object->fetch($id); |
||||
163 | |||||
164 | $object->oldcopy = dol_clone($object, 2); |
||||
165 | |||||
166 | // Fill array 'array_options' with data from update form |
||||
167 | $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); |
||||
168 | |||||
169 | if ($ret < 0) { |
||||
170 | $error++; |
||||
171 | } |
||||
172 | |||||
173 | if (!$error) { |
||||
174 | $result = $object->insertExtraFields('COMPANY_MODIFY'); |
||||
175 | if ($result < 0) { |
||||
176 | setEventMessages($object->error, $object->errors, 'errors'); |
||||
177 | $error++; |
||||
178 | } |
||||
179 | } |
||||
180 | |||||
181 | if ($error) { |
||||
182 | $action = 'edit_extras'; |
||||
183 | } |
||||
184 | } |
||||
185 | } |
||||
186 | |||||
187 | |||||
188 | /* |
||||
189 | * View |
||||
190 | */ |
||||
191 | |||||
192 | $contactstatic = new Contact($db); |
||||
193 | $form = new Form($db); |
||||
194 | |||||
195 | if ($id > 0 && empty($object->id)) { |
||||
196 | // Load data of third party |
||||
197 | $res = $object->fetch($id); |
||||
198 | if ($object->id <= 0) { |
||||
199 | dol_print_error($db, $object->error); |
||||
200 | exit(-1); |
||||
201 | } |
||||
202 | } |
||||
203 | |||||
204 | if ($object->id > 0) { |
||||
205 | $title = $langs->trans("ThirdParty") . " - " . $langs->trans('Supplier'); |
||||
206 | if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) { |
||||
207 | $title = $object->name . " - " . $langs->trans('Supplier'); |
||||
208 | } |
||||
209 | $help_url = ''; |
||||
210 | ViewMain::llxHeader('', $title, $help_url); |
||||
211 | |||||
212 | /* |
||||
213 | * Show tabs |
||||
214 | */ |
||||
215 | $head = societe_prepare_head($object); |
||||
216 | |||||
217 | print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); |
||||
218 | |||||
219 | $linkback = '<a href="' . constant('BASE_URL') . '/societe/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||||
220 | |||||
221 | dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); |
||||
222 | |||||
223 | print '<div class="fichecenter"><div class="fichehalfleft">'; |
||||
224 | |||||
225 | print '<div class="underbanner clearboth"></div>'; |
||||
226 | print '<table class="border centpercent tableforfield">'; |
||||
227 | |||||
228 | // Type Prospect/Customer/Supplier |
||||
229 | print '<tr><td class="titlefield">' . $langs->trans('NatureOfThirdParty') . '</td><td>'; |
||||
230 | print $object->getTypeUrl(1); |
||||
231 | print '</td></tr>'; |
||||
232 | |||||
233 | if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field |
||||
234 | print '<tr><td>' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
||||
235 | } |
||||
236 | |||||
237 | if ($object->fournisseur) { |
||||
238 | print '<tr>'; |
||||
239 | print '<td class="titlefield">' . $langs->trans("SupplierCode") . '</td><td>'; |
||||
240 | print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); |
||||
241 | $tmpcheck = $object->check_codefournisseur(); |
||||
242 | if ($tmpcheck != 0 && $tmpcheck != -5) { |
||||
243 | print ' <span class="error">(' . $langs->trans("WrongSupplierCode") . ')</span>'; |
||||
244 | } |
||||
245 | print '</td>'; |
||||
246 | print '</tr>'; |
||||
247 | |||||
248 | $langs->load('compta'); |
||||
249 | print '<tr>'; |
||||
250 | print '<td>'; |
||||
251 | print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer')); |
||||
252 | print '</td><td>'; |
||||
253 | print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer')); |
||||
254 | print '</td>'; |
||||
255 | print '</tr>'; |
||||
256 | } |
||||
257 | |||||
258 | // Assujetti a TVA ou pas |
||||
259 | print '<tr>'; |
||||
260 | print '<td class="titlefield">'; |
||||
261 | print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling')); |
||||
262 | print '</td><td>'; |
||||
263 | print yn($object->tva_assuj); |
||||
264 | print '</td>'; |
||||
265 | print '</tr>'; |
||||
266 | |||||
267 | // Local Taxes |
||||
268 | if ($mysoc->useLocalTax(1)) { |
||||
269 | print '<tr><td>' . $langs->transcountry("LocalTax1IsUsed", $mysoc->country_code) . '</td><td>'; |
||||
270 | print yn($object->localtax1_assuj); |
||||
271 | print '</td></tr>'; |
||||
272 | } |
||||
273 | if ($mysoc->useLocalTax(2)) { |
||||
274 | print '<tr><td>' . $langs->transcountry("LocalTax2IsUsed", $mysoc->country_code) . '</td><td>'; |
||||
275 | print yn($object->localtax2_assuj); |
||||
276 | print '</td></tr>'; |
||||
277 | } |
||||
278 | |||||
279 | // VAT reverse-charge by default on supplier invoice or not |
||||
280 | if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { |
||||
281 | print '<tr>'; |
||||
282 | print '<td class="titlefield">'; |
||||
283 | print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc')); |
||||
284 | print '</td><td>'; |
||||
285 | print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>'; |
||||
286 | print '</td>'; |
||||
287 | print '</tr>'; |
||||
288 | } |
||||
289 | |||||
290 | // TVA Intra |
||||
291 | print '<tr><td class="nowrap">'; |
||||
292 | //print $langs->trans('VATIntra').'</td><td>'; |
||||
293 | $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : ''); |
||||
294 | print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer')); |
||||
295 | print '</td><td>'; |
||||
296 | print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped' => 1)); |
||||
297 | print '</td></tr>'; |
||||
298 | |||||
299 | // Default terms of the settlement |
||||
300 | $langs->load('bills'); |
||||
301 | $form = new Form($db); |
||||
302 | print '<tr><td>'; |
||||
303 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
||||
304 | print $langs->trans('PaymentConditions'); |
||||
305 | print '<td>'; |
||||
306 | if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) { |
||||
307 | print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&token=' . newToken() . '&socid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; |
||||
308 | } |
||||
309 | print '</tr></table>'; |
||||
310 | print '</td><td>'; |
||||
311 | if ($action == 'editconditions') { |
||||
312 | $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', 1); |
||||
313 | } else { |
||||
314 | $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->cond_reglement_supplier_id, 'none'); |
||||
315 | } |
||||
316 | print "</td>"; |
||||
317 | print '</tr>'; |
||||
318 | |||||
319 | // Default payment mode |
||||
320 | print '<tr><td class="nowrap">'; |
||||
321 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
||||
322 | print $langs->trans('PaymentMode'); |
||||
323 | print '<td>'; |
||||
324 | if (($action != 'editmode') && $user->hasRight('societe', 'creer')) { |
||||
325 | print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editmode&token=' . newToken() . '&socid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; |
||||
326 | } |
||||
327 | print '</tr></table>'; |
||||
328 | print '</td><td>'; |
||||
329 | if ($action == 'editmode') { |
||||
330 | $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1); |
||||
331 | } else { |
||||
332 | $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->mode_reglement_supplier_id, 'none'); |
||||
333 | } |
||||
334 | print "</td>"; |
||||
335 | print '</tr>'; |
||||
336 | |||||
337 | if (isModEnabled("bank")) { |
||||
338 | // Default bank account for payments |
||||
339 | print '<tr><td class="nowrap">'; |
||||
340 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
||||
341 | print $langs->trans('PaymentBankAccount'); |
||||
342 | print '<td>'; |
||||
343 | if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) { |
||||
344 | print '<td class="right"><a class="editfielda" href="' . $_SERVER["PHP_SELF"] . '?action=editbankaccount&token=' . newToken() . '&socid=' . $object->id . '">' . img_edit($langs->trans('SetBankAccount'), 1) . '</a></td>'; |
||||
345 | } |
||||
346 | print '</tr></table>'; |
||||
347 | print '</td><td>'; |
||||
348 | if ($action == 'editbankaccount') { |
||||
349 | $form->formSelectAccount($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->fk_account, 'fk_account', 1); |
||||
350 | } else { |
||||
351 | $form->formSelectAccount($_SERVER['PHP_SELF'] . '?socid=' . $object->id, $object->fk_account, 'none'); |
||||
352 | } |
||||
353 | print "</td>"; |
||||
354 | print '</tr>'; |
||||
355 | } |
||||
356 | |||||
357 | // Relative discounts (Discounts-Drawbacks-Rebates) |
||||
358 | print '<tr><td class="nowrap">'; |
||||
359 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
||||
360 | print $langs->trans("CustomerRelativeDiscountShort"); |
||||
361 | print '<td><td class="right">'; |
||||
362 | if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { |
||||
363 | print '<a class="editfielda" href="' . constant('BASE_URL') . '/comm/remise.php?id=' . $object->id . '&backtopage=' . $_SERVER["PHP_SELF"] . ('?socid=' . $object->id) . '&action=create&token=' . newToken() . '">' . img_edit($langs->trans("Modify")) . '</a>'; |
||||
364 | } |
||||
365 | print '</td></tr></table>'; |
||||
366 | print '</td><td>' . ($object->remise_supplier_percent ? '<a href="' . constant('BASE_URL') . '/comm/remise.php?id=' . $object->id . '">' . $object->remise_supplier_percent . '%</a>' : '') . '</td>'; |
||||
367 | print '</tr>'; |
||||
368 | |||||
369 | // Absolute discounts (Discounts-Drawbacks-Rebates) |
||||
370 | print '<tr><td class="nowrap">'; |
||||
371 | print '<table width="100%" class="nobordernopadding">'; |
||||
372 | print '<tr><td class="nowrap">'; |
||||
373 | print $langs->trans("CustomerAbsoluteDiscountShort"); |
||||
374 | print '<td><td class="right">'; |
||||
375 | if ($user->hasRight('societe', 'creer') && !$user->socid > 0) { |
||||
376 | print '<a class="editfielda" href="' . constant('BASE_URL') . '/comm/remx.php?id=' . $object->id . '&backtopage=' . $_SERVER["PHP_SELF"] . ('?socid=' . $object->id) . '&action=create&token=' . newToken() . '">' . img_edit($langs->trans("Modify")) . '</a>'; |
||||
377 | } |
||||
378 | print '</td></tr></table>'; |
||||
379 | print '</td>'; |
||||
380 | print '<td>'; |
||||
381 | $amount_discount = $object->getAvailableDiscounts('', '', 0, 1); |
||||
382 | if ($amount_discount < 0) { |
||||
383 | dol_print_error($db, $object->error); |
||||
384 | } |
||||
385 | if ($amount_discount > 0) { |
||||
386 | print '<a href="' . constant('BASE_URL') . '/comm/remx.php?id=' . $object->id . '&backtopage=' . $_SERVER["PHP_SELF"] . ('?socid=' . $object->id) . '&action=create&token=' . newToken() . '">' . price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency) . '</a>'; |
||||
387 | } |
||||
388 | //else print $langs->trans("DiscountNone"); |
||||
389 | print '</td>'; |
||||
390 | print '</tr>'; |
||||
391 | |||||
392 | if (isModEnabled("supplier_order") && getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT')) { |
||||
393 | print '<tr class="nowrap">'; |
||||
394 | print '<td>'; |
||||
395 | print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer")); |
||||
396 | print '</td><td>'; |
||||
397 | $limit_field_type = (getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) ? 'numeric' : 'amount'; |
||||
398 | print $form->editfieldval("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer"), $limit_field_type, ($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); |
||||
399 | print '</td>'; |
||||
400 | print '</tr>'; |
||||
401 | } |
||||
402 | |||||
403 | // Categories |
||||
404 | if (isModEnabled('category')) { |
||||
405 | $langs->load("categories"); |
||||
406 | print '<tr><td>' . $langs->trans("SuppliersCategoriesShort") . '</td>'; |
||||
407 | print '<td>'; |
||||
408 | print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); |
||||
409 | print "</td></tr>"; |
||||
410 | } |
||||
411 | |||||
412 | // Other attributes |
||||
413 | $parameters = array('socid' => $object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); |
||||
414 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
||||
415 | |||||
416 | // Module Adherent |
||||
417 | if (isModEnabled('member')) { |
||||
418 | $langs->load("members"); |
||||
419 | $langs->load("users"); |
||||
420 | print '<tr><td>' . $langs->trans("LinkedToDolibarrMember") . '</td>'; |
||||
421 | print '<td>'; |
||||
422 | $adh = new Adherent($db); |
||||
423 | $result = $adh->fetch('', '', $object->id); |
||||
424 | if ($result > 0) { |
||||
425 | $adh->ref = $adh->getFullName($langs); |
||||
426 | print $adh->getNomUrl(1); |
||||
427 | } else { |
||||
428 | print $langs->trans("ThirdpartyNotLinkedToMember"); |
||||
429 | } |
||||
430 | print '</td>'; |
||||
431 | print "</tr>\n"; |
||||
432 | } |
||||
433 | |||||
434 | print '</table>'; |
||||
435 | |||||
436 | |||||
437 | print '</div><div class="fichehalfright">'; |
||||
438 | |||||
439 | $boxstat = ''; |
||||
440 | |||||
441 | // Nbre max d'elements des petites listes |
||||
442 | $MAXLIST = getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT'); |
||||
443 | |||||
444 | print '<div class="underbanner underbanner-before-box clearboth"></div>'; |
||||
445 | print '<br>'; |
||||
446 | |||||
447 | // Lien recap |
||||
448 | $boxstat .= '<div class="box box-halfright">'; |
||||
449 | $boxstat .= '<table summary="' . dol_escape_htmltag($langs->trans("DolibarrStateBoard")) . '" class="border boxtable boxtablenobottom boxtablenotop" width="100%">'; |
||||
450 | $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">'; |
||||
451 | |||||
452 | if (isModEnabled('supplier_proposal')) { |
||||
453 | // Box proposals |
||||
454 | $tmp = $object->getOutstandingProposals('supplier'); |
||||
455 | $outstandingOpened = $tmp['opened']; |
||||
456 | $outstandingTotal = $tmp['total_ht']; |
||||
457 | $outstandingTotalIncTax = $tmp['total_ttc']; |
||||
458 | $text = $langs->trans("OverAllSupplierProposals"); |
||||
459 | $link = constant('BASE_URL') . '/supplier_proposal/list.php?socid=' . $object->id; |
||||
460 | $icon = 'bill'; |
||||
461 | if ($link) { |
||||
462 | $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">'; |
||||
463 | } |
||||
464 | $boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">'; |
||||
465 | $boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>'; |
||||
466 | $boxstat .= '<span class="boxstatsindicator">' . price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency) . '</span>'; |
||||
467 | $boxstat .= '</div>'; |
||||
468 | if ($link) { |
||||
469 | $boxstat .= '</a>'; |
||||
470 | } |
||||
471 | } |
||||
472 | |||||
473 | if (isModEnabled("supplier_order")) { |
||||
474 | // Box proposals |
||||
475 | $tmp = $object->getOutstandingOrders('supplier'); |
||||
476 | $outstandingOpened = $tmp['opened']; |
||||
477 | $outstandingTotal = $tmp['total_ht']; |
||||
478 | $outstandingTotalIncTax = $tmp['total_ttc']; |
||||
479 | $text = $langs->trans("OverAllOrders"); |
||||
480 | $link = constant('BASE_URL') . '/fourn/commande/list.php?socid=' . $object->id; |
||||
481 | $icon = 'bill'; |
||||
482 | if ($link) { |
||||
483 | $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">'; |
||||
484 | } |
||||
485 | $boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">'; |
||||
486 | $boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>'; |
||||
487 | $boxstat .= '<span class="boxstatsindicator">' . price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency) . '</span>'; |
||||
488 | $boxstat .= '</div>'; |
||||
489 | if ($link) { |
||||
490 | $boxstat .= '</a>'; |
||||
491 | } |
||||
492 | } |
||||
493 | |||||
494 | if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) { |
||||
495 | $warn = ''; |
||||
496 | $tmp = $object->getOutstandingBills('supplier'); |
||||
497 | $outstandingOpened = $tmp['opened']; |
||||
498 | $outstandingTotal = $tmp['total_ht']; |
||||
499 | $outstandingTotalIncTax = $tmp['total_ttc']; |
||||
500 | |||||
501 | $text = $langs->trans("OverAllInvoices"); |
||||
502 | $link = constant('BASE_URL') . '/fourn/facture/list.php?socid=' . $object->id; |
||||
503 | $icon = 'bill'; |
||||
504 | if ($link) { |
||||
505 | $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">'; |
||||
506 | } |
||||
507 | $boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">'; |
||||
508 | $boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>'; |
||||
509 | $boxstat .= '<span class="boxstatsindicator">' . price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency) . '</span>'; |
||||
510 | $boxstat .= '</div>'; |
||||
511 | if ($link) { |
||||
512 | $boxstat .= '</a>'; |
||||
513 | } |
||||
514 | |||||
515 | // Box outstanding bill |
||||
516 | $text = $langs->trans("CurrentOutstandingBill"); |
||||
517 | $link = constant('BASE_URL') . '/fourn/recap-fourn.php?socid=' . $object->id; |
||||
518 | $icon = 'bill'; |
||||
519 | if ($link) { |
||||
520 | $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">'; |
||||
521 | } |
||||
522 | $boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">'; |
||||
523 | $boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>'; |
||||
524 | $boxstat .= '<span class="boxstatsindicator' . ($outstandingOpened > 0 ? ' amountremaintopay' : '') . '">' . price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency) . $warn . '</span>'; |
||||
525 | $boxstat .= '</div>'; |
||||
526 | if ($link) { |
||||
527 | $boxstat .= '</a>'; |
||||
528 | } |
||||
529 | |||||
530 | $tmp = $object->getOutstandingBills('supplier', 1); |
||||
531 | $outstandingOpenedLate = $tmp['opened']; |
||||
532 | if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) { |
||||
533 | $text = $langs->trans("CurrentOutstandingBillLate"); |
||||
534 | $link = constant('BASE_URL') . '/fourn/recap-fourn.php?socid=' . $object->id; |
||||
535 | $icon = 'bill'; |
||||
536 | if ($link) { |
||||
537 | $boxstat .= '<a href="' . $link . '" class="boxstatsindicator thumbstat nobold nounderline">'; |
||||
538 | } |
||||
539 | $boxstat .= '<div class="boxstats" title="' . dol_escape_htmltag($text) . '">'; |
||||
540 | $boxstat .= '<span class="boxstatstext">' . img_object("", $icon) . ' <span>' . $text . '</span></span><br>'; |
||||
541 | $boxstat .= '<span class="boxstatsindicator' . ($outstandingOpenedLate > 0 ? ' amountremaintopay' : '') . '">' . price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency) . $warn . '</span>'; |
||||
542 | $boxstat .= '</div>'; |
||||
543 | if ($link) { |
||||
544 | $boxstat .= '</a>'; |
||||
545 | } |
||||
546 | } |
||||
547 | } |
||||
548 | |||||
549 | |||||
550 | $parameters = array(); |
||||
551 | $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action); |
||||
552 | if (empty($reshook)) { |
||||
553 | $boxstat .= $hookmanager->resPrint; |
||||
554 | } |
||||
555 | |||||
556 | $boxstat .= '</td></tr>'; |
||||
557 | $boxstat .= '</table>'; |
||||
558 | $boxstat .= '</div>'; |
||||
559 | |||||
560 | print $boxstat; |
||||
561 | |||||
562 | |||||
563 | $MAXLIST = getDolGlobalString('MAIN_SIZE_SHORTLIST_LIMIT'); |
||||
564 | |||||
565 | |||||
566 | /* |
||||
567 | * List of products |
||||
568 | */ |
||||
569 | if (isModEnabled("product") || isModEnabled("service")) { |
||||
570 | $langs->load("products"); |
||||
571 | //Query from product/liste.php |
||||
572 | $sql = 'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity, p.tosell as status, p.tobuy as status_buy, p.tobatch as status_batch,'; |
||||
573 | $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice'; |
||||
574 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pfp'; |
||||
575 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = pfp.fk_product"; |
||||
576 | $sql .= ' WHERE p.entity IN (' . getEntity('product') . ')'; |
||||
577 | $sql .= ' AND pfp.fk_soc = ' . ((int)$object->id); |
||||
578 | $sql .= $db->order('pfp.tms', 'desc'); |
||||
579 | $sql .= $db->plimit($MAXLIST); |
||||
580 | |||||
581 | $query = $db->query($sql); |
||||
582 | if (!$query) { |
||||
583 | dol_print_error($db); |
||||
584 | } |
||||
585 | |||||
586 | $num = $db->num_rows($query); |
||||
587 | |||||
588 | print '<div class="div-table-responsive-no-min">'; |
||||
589 | print '<table class="noborder centpercent lastrecordtable">'; |
||||
590 | print '<tr class="liste_titre' . (($num == 0) ? ' nobottom' : '') . '">'; |
||||
591 | print '<td colspan="2">' . $langs->trans("ProductsAndServices") . '</td><td class="right" colspan="2">'; |
||||
592 | print '<a class="notasortlink" href="' . constant('BASE_URL') . '/fourn/product/list.php?fourn_id=' . $object->id . '"><span class="hideonsmartphone">' . $langs->trans("AllProductReferencesOfSupplier") . '</span><span class="badge marginleftonlyshort">' . $object->nbOfProductRefs() . '</span>'; |
||||
593 | print '</a></td></tr>'; |
||||
594 | |||||
595 | $return = array(); |
||||
596 | if ($num > 0) { |
||||
597 | $productstatic = new Product($db); |
||||
598 | |||||
599 | while ($objp = $db->fetch_object($query)) { |
||||
600 | $productstatic->id = $objp->rowid; |
||||
601 | $productstatic->ref = $objp->ref; |
||||
602 | $productstatic->label = $objp->label; |
||||
603 | $productstatic->type = $objp->fk_product_type; |
||||
604 | $productstatic->entity = $objp->entity; |
||||
605 | $productstatic->status = $objp->status; |
||||
606 | $productstatic->status_buy = $objp->status_buy; |
||||
607 | $productstatic->status_batch = $objp->status_batch; |
||||
608 | |||||
609 | print '<tr class="oddeven">'; |
||||
610 | print '<td class="nowrap">'; |
||||
611 | print $productstatic->getNomUrl(1); |
||||
612 | print '</td>'; |
||||
613 | print '<td>'; |
||||
614 | print dol_escape_htmltag($objp->supplier_ref); |
||||
615 | print '</td>'; |
||||
616 | print '<td class="tdoverflowmax200">'; |
||||
617 | print dol_trunc(dol_htmlentities($objp->label), 30); |
||||
618 | print '</td>'; |
||||
619 | //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>'; |
||||
620 | print '<td class="right">'; |
||||
621 | //print (isset($objp->unitprice) ? price($objp->unitprice) : ''); |
||||
622 | if (isset($objp->price)) { |
||||
623 | print '<span class="amount">' . price($objp->price) . '</span>'; |
||||
624 | if ($objp->quantity > 1) { |
||||
625 | print ' / '; |
||||
626 | print $objp->quantity; |
||||
627 | } |
||||
628 | } |
||||
629 | print '</td>'; |
||||
630 | print '</tr>'; |
||||
631 | } |
||||
632 | } |
||||
633 | |||||
634 | print '</table>'; |
||||
635 | print '</div>'; |
||||
636 | } |
||||
637 | |||||
638 | /* |
||||
639 | * Latest supplier proposal |
||||
640 | */ |
||||
641 | $proposalstatic = new SupplierProposal($db); |
||||
642 | |||||
643 | if ($user->hasRight("supplier_proposal", "lire")) { |
||||
644 | $langs->loadLangs(array("supplier_proposal")); |
||||
645 | |||||
646 | $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; |
||||
647 | $sql .= " FROM " . MAIN_DB_PREFIX . "supplier_proposal as p "; |
||||
648 | $sql .= " WHERE p.fk_soc = " . ((int)$object->id); |
||||
649 | $sql .= " AND p.entity IN (" . getEntity('supplier_proposal') . ")"; |
||||
650 | $sql .= " ORDER BY p.date_valid DESC"; |
||||
651 | $sql .= $db->plimit($MAXLIST); |
||||
652 | |||||
653 | $resql = $db->query($sql); |
||||
654 | if ($resql) { |
||||
655 | $i = 0; |
||||
656 | $num = $db->num_rows($resql); |
||||
657 | |||||
658 | if ($num > 0) { |
||||
659 | print '<div class="div-table-responsive-no-min">'; |
||||
660 | print '<table class="noborder centpercent lastrecordtable">'; |
||||
661 | |||||
662 | print '<tr class="liste_titre">'; |
||||
663 | print '<td colspan="3">'; |
||||
664 | print '<table class="nobordernopadding centpercent"><tr><td>' . $langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)) . '</td>'; |
||||
665 | print '<td class="right"><a class="notasortlink" href="' . constant('BASE_URL') . '/supplier_proposal/list.php?socid=' . $object->id . '"><span class="hideonsmartphone">' . $langs->trans("AllPriceRequests") . '</span><span class="badge marginleftonlyshort">' . $num . '</span></td>'; |
||||
666 | // print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>'; |
||||
667 | print '</tr></table>'; |
||||
668 | print '</td></tr>'; |
||||
669 | } |
||||
670 | |||||
671 | while ($i < $num && $i <= $MAXLIST) { |
||||
672 | $obj = $db->fetch_object($resql); |
||||
673 | |||||
674 | print '<tr class="oddeven">'; |
||||
675 | print '<td class="nowrap">'; |
||||
676 | $proposalstatic->id = $obj->rowid; |
||||
677 | $proposalstatic->ref = $obj->ref; |
||||
678 | $proposalstatic->total_ht = $obj->total_ht; |
||||
679 | $proposalstatic->total_tva = $obj->total_tva; |
||||
680 | $proposalstatic->total_ttc = $obj->total_ttc; |
||||
681 | print $proposalstatic->getNomUrl(1); |
||||
682 | print '</td>'; |
||||
683 | print '<td class="center" width="80">'; |
||||
684 | if ($obj->dc) { |
||||
685 | print dol_print_date($db->jdate($obj->dc), 'day'); |
||||
686 | } else { |
||||
687 | print "-"; |
||||
688 | } |
||||
689 | print '</td>'; |
||||
690 | print '<td class="right" class="nowrap">' . $proposalstatic->LibStatut($obj->fk_statut, 5) . '</td>'; |
||||
691 | print '</tr>'; |
||||
692 | $i++; |
||||
693 | } |
||||
694 | $db->free($resql); |
||||
695 | |||||
696 | if ($num > 0) { |
||||
697 | print "</table></div>"; |
||||
698 | } |
||||
699 | } else { |
||||
700 | dol_print_error($db); |
||||
701 | } |
||||
702 | } |
||||
703 | |||||
704 | /* |
||||
705 | * Latest supplier orders |
||||
706 | */ |
||||
707 | $orderstatic = new CommandeFournisseur($db); |
||||
708 | |||||
709 | if ($user->hasRight("fournisseur", "commande", "lire")) { |
||||
710 | // TODO move to DAO class |
||||
711 | // Check if there are supplier orders billable |
||||
712 | $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,'; |
||||
713 | $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut'; |
||||
714 | $sql2 .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
||||
715 | $sql2 .= ', ' . MAIN_DB_PREFIX . 'commande_fournisseur as c'; |
||||
716 | $sql2 .= ' WHERE c.fk_soc = s.rowid'; |
||||
717 | $sql2 .= " AND c.entity IN (" . getEntity('commande_fournisseur') . ")"; |
||||
718 | $sql2 .= ' AND s.rowid = ' . ((int)$object->id); |
||||
719 | // Show orders we can bill |
||||
720 | if (!getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')) { |
||||
721 | $sql2 .= " AND c.fk_statut IN (" . $db->sanitize(CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) . ")"; // Must match filter in htdocs/fourn/commande/list.php |
||||
722 | } else { |
||||
723 | // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY |
||||
724 | $sql2 .= " AND c.fk_statut IN (" . $db->sanitize(getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')) . ")"; |
||||
725 | } |
||||
726 | $sql2 .= " AND c.billed = 0"; |
||||
727 | // Find order that are not already invoiced |
||||
728 | // just need to check received status because we have the billed status now |
||||
729 | //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')"; |
||||
730 | $resql2 = $db->query($sql2); |
||||
731 | if ($resql2) { |
||||
732 | $orders2invoice = $db->num_rows($resql2); |
||||
733 | $db->free($resql2); |
||||
734 | } else { |
||||
735 | setEventMessages($db->lasterror(), null, 'errors'); |
||||
736 | } |
||||
737 | |||||
738 | // TODO move to DAO class |
||||
739 | $sql = "SELECT count(p.rowid) as total"; |
||||
740 | $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as p"; |
||||
741 | $sql .= " WHERE p.fk_soc = " . ((int)$object->id); |
||||
742 | $sql .= " AND p.entity IN (" . getEntity('commande_fournisseur') . ")"; |
||||
743 | $resql = $db->query($sql); |
||||
744 | if ($resql) { |
||||
745 | $object_count = $db->fetch_object($resql); |
||||
746 | $num = $object_count->total; |
||||
747 | } |
||||
748 | |||||
749 | $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; |
||||
750 | $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur as p"; |
||||
751 | $sql .= " WHERE p.fk_soc = " . ((int)$object->id); |
||||
752 | $sql .= " AND p.entity IN (" . getEntity('commande_fournisseur') . ")"; |
||||
753 | $sql .= " ORDER BY p.date_commande DESC"; |
||||
754 | $sql .= $db->plimit($MAXLIST); |
||||
755 | |||||
756 | $resql = $db->query($sql); |
||||
757 | if ($resql) { |
||||
758 | $i = 0; |
||||
759 | |||||
760 | if ($num > 0) { |
||||
761 | print '<div class="div-table-responsive-no-min">'; |
||||
762 | print '<table class="noborder centpercent lastrecordtable">'; |
||||
763 | |||||
764 | print '<tr class="liste_titre">'; |
||||
765 | print '<td colspan="4">'; |
||||
766 | print '<table class="nobordernopadding" width="100%"><tr><td>' . $langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)) . '</td>'; |
||||
767 | print '<td class="right"><a class="notasortlink" href="' . constant('BASE_URL') . '/fourn/commande/list.php?socid=' . $object->id . '"><span class="hideonsmartphone">' . $langs->trans("AllOrders") . '</span><span class="badge marginleftonlyshort">' . $num . '</span></td>'; |
||||
768 | print '<td width="20px" class="right"><a href="' . constant('BASE_URL') . '/commande/stats/index.php?mode=supplier&socid=' . $object->id . '">' . img_picto($langs->trans("Statistics"), 'stats') . '</a></td>'; |
||||
769 | print '</tr></table>'; |
||||
770 | print '</td></tr>'; |
||||
771 | } |
||||
772 | |||||
773 | while ($i < $num && $i < $MAXLIST) { |
||||
774 | $obj = $db->fetch_object($resql); |
||||
775 | |||||
776 | $orderstatic->id = $obj->rowid; |
||||
777 | $orderstatic->ref = $obj->ref; |
||||
778 | $orderstatic->total_ht = $obj->total_ht; |
||||
779 | $orderstatic->total_tva = $obj->total_tva; |
||||
780 | $orderstatic->total_ttc = $obj->total_ttc; |
||||
781 | $orderstatic->date = $db->jdate($obj->date); |
||||
782 | |||||
783 | print '<tr class="oddeven">'; |
||||
784 | print '<td class="nowraponall">'; |
||||
785 | print $orderstatic->getNomUrl(1); |
||||
786 | print '</td>'; |
||||
787 | print '<td class="center" width="80">'; |
||||
788 | if ($obj->date) { |
||||
789 | print dol_print_date($orderstatic->date, 'day'); |
||||
790 | } |
||||
791 | print '</td>'; |
||||
792 | print '<td class="right nowrap"><span class="amount">' . price($orderstatic->total_ttc) . '</span></td>'; |
||||
793 | print '<td class="right" class="nowrap">' . $orderstatic->LibStatut($obj->fk_statut, 5) . '</td>'; |
||||
794 | print '</tr>'; |
||||
795 | $i++; |
||||
796 | } |
||||
797 | $db->free($resql); |
||||
798 | |||||
799 | if ($num > 0) { |
||||
800 | print "</table></div>"; |
||||
801 | } |
||||
802 | } else { |
||||
803 | dol_print_error($db); |
||||
804 | } |
||||
805 | } |
||||
806 | |||||
807 | /* |
||||
808 | * Latest supplier invoices |
||||
809 | */ |
||||
810 | |||||
811 | $langs->load('bills'); |
||||
812 | $facturestatic = new FactureFournisseur($db); |
||||
813 | |||||
814 | if ($user->hasRight('fournisseur', 'facture', 'lire')) { |
||||
815 | // TODO move to DAO class |
||||
816 | $sql = 'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,'; |
||||
817 | $sql .= ' SUM(pf.amount) as am'; |
||||
818 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_fourn as f'; |
||||
819 | $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; |
||||
820 | $sql .= ' WHERE f.fk_soc = ' . ((int)$object->id); |
||||
821 | $sql .= " AND f.entity IN (" . getEntity('facture_fourn') . ")"; |
||||
822 | $sql .= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye'; |
||||
823 | $sql .= ' ORDER BY f.datef DESC'; |
||||
824 | $resql = $db->query($sql); |
||||
825 | if ($resql) { |
||||
826 | $i = 0; |
||||
827 | $num = $db->num_rows($resql); |
||||
828 | if ($num > 0) { |
||||
829 | print '<div class="div-table-responsive-no-min">'; |
||||
830 | print '<table class="noborder centpercent lastrecordtable">'; |
||||
831 | |||||
832 | print '<tr class="liste_titre">'; |
||||
833 | print '<td colspan="4">'; |
||||
834 | print '<table class="nobordernopadding" width="100%"><tr><td>' . $langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)) . '</td>'; |
||||
835 | print '<td class="right"><a class="notasortlink" href="' . constant('BASE_URL') . '/fourn/facture/list.php?socid=' . $object->id . '"><span class="hideonsmartphone">' . $langs->trans('AllBills') . '</span><span class="badge marginleftonlyshort">' . $num . '</span></td>'; |
||||
836 | print '<td width="20px" class="right"><a href="' . constant('BASE_URL') . '/compta/facture/stats/index.php?mode=supplier&socid=' . $object->id . '">' . img_picto($langs->trans("Statistics"), 'stats') . '</a></td>'; |
||||
837 | print '</tr></table>'; |
||||
838 | print '</td></tr>'; |
||||
839 | } |
||||
840 | |||||
841 | while ($i < min($num, $MAXLIST)) { |
||||
842 | $obj = $db->fetch_object($resql); |
||||
843 | |||||
844 | $facturestatic->id = $obj->rowid; |
||||
845 | $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); |
||||
846 | $facturestatic->ref_supplier = $obj->ref_supplier; |
||||
847 | $facturestatic->libelle = $obj->label; // deprecated |
||||
0 ignored issues
–
show
The property
Dolibarr\Code\Fourn\Clas...reFournisseur::$libelle has been deprecated: Use $label
(
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. ![]() |
|||||
848 | $facturestatic->label = $obj->label; |
||||
849 | $facturestatic->total_ht = $obj->total_ht; |
||||
850 | $facturestatic->total_tva = $obj->total_tva; |
||||
851 | $facturestatic->total_ttc = $obj->total_ttc; |
||||
852 | $facturestatic->date = $db->jdate($obj->df); |
||||
853 | |||||
854 | print '<tr class="oddeven">'; |
||||
855 | print '<td class="tdoverflowmax200">'; |
||||
856 | print '<span class="nowraponall">' . $facturestatic->getNomUrl(1) . '</span>'; |
||||
857 | print $obj->ref_supplier ? ' - ' . $obj->ref_supplier : ''; |
||||
858 | print($obj->label ? ' - ' : '') . dol_trunc($obj->label, 14); |
||||
859 | print '</td>'; |
||||
860 | print '<td class="center nowrap">' . dol_print_date($facturestatic->date, 'day') . '</td>'; |
||||
861 | print '<td class="right nowrap"><span class="amount">' . price($facturestatic->total_ttc) . '</span></td>'; |
||||
862 | print '<td class="right nowrap">'; |
||||
863 | print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am); |
||||
864 | print '</td>'; |
||||
865 | print '</tr>'; |
||||
866 | $i++; |
||||
867 | } |
||||
868 | $db->free($resql); |
||||
869 | if ($num > 0) { |
||||
870 | print '</table></div>'; |
||||
871 | } |
||||
872 | } else { |
||||
873 | dol_print_error($db); |
||||
874 | } |
||||
875 | } |
||||
876 | |||||
877 | // Allow external modules to add their own shortlist of recent objects |
||||
878 | $parameters = array(); |
||||
879 | $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action); |
||||
880 | if ($reshook < 0) { |
||||
881 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||||
882 | } else { |
||||
883 | print $hookmanager->resPrint; |
||||
884 | } |
||||
885 | |||||
886 | print '</div></div>'; |
||||
887 | print '<div class="clearboth"></div>'; |
||||
888 | |||||
889 | print dol_get_fiche_end(); |
||||
890 | |||||
891 | |||||
892 | /* |
||||
893 | * Action bar |
||||
894 | */ |
||||
895 | print '<div class="tabsAction">'; |
||||
896 | |||||
897 | $parameters = array(); |
||||
898 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been |
||||
899 | // modified by hook |
||||
900 | if (empty($reshook)) { |
||||
901 | if ($object->status != 1) { |
||||
902 | print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('ThirdPartyIsClosed'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
903 | } |
||||
904 | |||||
905 | if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "creer")) { |
||||
906 | $langs->load("supplier_proposal"); |
||||
907 | if ($object->status == 1) { |
||||
908 | print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', constant('BASE_URL') . '/supplier_proposal/card.php?action=create&socid=' . $object->id, ''); |
||||
909 | } else { |
||||
910 | print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
911 | } |
||||
912 | } |
||||
913 | |||||
914 | if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) { |
||||
915 | $langs->load("orders"); |
||||
916 | if ($object->status == 1) { |
||||
917 | print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', constant('BASE_URL') . '/fourn/commande/card.php?action=create&token=' . newToken() . '&socid=' . $object->id, ''); |
||||
918 | } else { |
||||
919 | print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
920 | } |
||||
921 | } |
||||
922 | |||||
923 | if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) { |
||||
924 | if (!empty($orders2invoice) && $orders2invoice > 0) { |
||||
925 | if ($object->status == 1) { |
||||
926 | // Company is open |
||||
927 | print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', constant('BASE_URL') . '/fourn/commande/list.php?socid=' . $object->id . '&search_billed=0&autoselectall=1', ''); |
||||
928 | } else { |
||||
929 | print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
930 | } |
||||
931 | } else { |
||||
932 | print dolGetButtonAction($langs->trans("NoOrdersToInvoice") . ' (' . $langs->trans("WithReceptionFinished") . ')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
933 | } |
||||
934 | } |
||||
935 | |||||
936 | if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) { |
||||
937 | $langs->load("bills"); |
||||
938 | if ($object->status == 1) { |
||||
939 | print dolGetButtonAction('', $langs->trans('AddBill'), 'default', constant('BASE_URL') . '/fourn/facture/card.php?action=create&socid=' . $object->id, ''); |
||||
940 | } else { |
||||
941 | print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddBill'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
942 | } |
||||
943 | } |
||||
944 | |||||
945 | // Add action |
||||
946 | if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) { |
||||
947 | if ($user->hasRight("agenda", "myactions", "create")) { |
||||
948 | print dolGetButtonAction('', $langs->trans('AddAction'), 'default', constant('BASE_URL') . '/comm/action/card.php?action=create&socid=' . $object->id, ''); |
||||
949 | } else { |
||||
950 | print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddAction'), 'default', $_SERVER['PHP_SELF'] . '#', '', false); |
||||
951 | } |
||||
952 | } |
||||
953 | } |
||||
954 | |||||
955 | print '</div>'; |
||||
956 | |||||
957 | |||||
958 | if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) { |
||||
959 | print '<br>'; |
||||
960 | // List of contacts |
||||
961 | show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"] . '?socid=' . $object->id); |
||||
962 | } |
||||
963 | |||||
964 | if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) { |
||||
965 | print load_fiche_titre($langs->trans("ActionsOnCompany"), '', ''); |
||||
966 | |||||
967 | // List of todo actions |
||||
968 | show_actions_todo($conf, $langs, $db, $object); |
||||
969 | |||||
970 | // List of done actions |
||||
971 | show_actions_done($conf, $langs, $db, $object); |
||||
972 | } |
||||
973 | } else { |
||||
974 | dol_print_error($db); |
||||
975 | } |
||||
976 | |||||
977 | // End of page |
||||
978 | ViewMain::llxFooter(); |
||||
979 | $db->close(); |
||||
980 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.