dolibarr 23.0.4
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
4 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
8 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
9 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
10 * Copyright (C) 2021-2025 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
12 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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
34// Load Dolibarr environment
35require '../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
37require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
38require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture-rec.class.php';
39require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
40require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
44if (isModEnabled('member')) {
45 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
46}
47if (isModEnabled('accounting')) {
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
49 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
50}
51
61// Load translation files required by page
62$langs->loadLangs(array('accountancy', 'companies', 'suppliers', 'products', 'bills', 'orders', 'commercial'));
63
64$action = GETPOST('action', 'aZ09');
65$cancel = GETPOST('cancel', 'alpha');
66
67$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'));
68if ($user->socid) {
69 $id = $user->socid;
70}
71
72// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
73$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard'));
74
75$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid');
76
77$object = new Fournisseur($db);
78$extrafields = new ExtraFields($db);
79
80// fetch optionals attributes and labels
81$extrafields->fetch_name_optionals_label($object->table_element);
82
83$permissiontoadd = $user->hasRight('societe', 'creer');
84$permissiontoeditextra = $permissiontoadd;
85if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
86 // For action 'update_extras', is there a specific permission set for the attribute to update
87 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
88}
89
90// Security check
91$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
92
93if ($object->id > 0) {
94 if (!($object->fournisseur > 0) || !$user->hasRight("fournisseur", "lire")) {
96 }
97}
98
99
100/*
101 * Actions
102 */
103$error = 0;
104$parameters = array('id' => $id);
105$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
106if ($reshook < 0) {
107 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
108}
109
110if (empty($reshook)) {
111 if ($cancel) {
112 $action = "";
113 }
114
115 // set general supplier accounting account
116 if ($action == 'setsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
117 $result = $object->fetch($id);
118 $object->accountancy_code_supplier_general = GETPOST("supplieraccountancycodegeneral");
119 $result = $object->update($object->id, $user, 1, 0, 1);
120 if ($result < 0) {
121 setEventMessages($object->error, $object->errors, 'errors');
122 $_GET['action'] = 'editsupplieraccountancycode';
123 }
124 }
125
126 // Set auxiliary supplier accounting account
127 if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) {
128 $result = $object->fetch($id);
129 $object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
130 $result = $object->update($object->id, $user, 1, 0, 1);
131 if ($result < 0) {
132 setEventMessages($object->error, $object->errors, 'errors');
133 $action = 'editsupplieraccountancycode';
134 }
135 }
136 // Set vat number accounting account
137 if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) {
138 $result = $object->fetch($id);
139 $object->tva_intra = GETPOST("tva_intra");
140 $result = $object->update($object->id, $user, 1, 0, 0);
141 if ($result < 0) {
142 setEventMessages($object->error, $object->errors, 'errors');
143 }
144 }
145 // Set payment terms of the settlement
146 if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) {
147 $object->fetch($id);
148 $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_supplier_id'), GETPOSTINT('cond_reglement_supplier_id_deposit_percent'));
149 if ($result < 0) {
150 dol_print_error($db, $object->error);
151 }
152 }
153 // Payment mode
154 if ($action == 'setmode' && $user->hasRight('societe', 'creer')) {
155 $object->fetch($id);
156 $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_supplier_id'));
157 if ($result < 0) {
158 dol_print_error($db, $object->error);
159 }
160 }
161
162 // Bank account
163 if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) {
164 $object->fetch($id);
165 $result = $object->setBankAccount(GETPOSTINT('fk_account'));
166 if ($result < 0) {
167 setEventMessages($object->error, $object->errors, 'errors');
168 }
169 }
170
171 // update supplier order min amount
172 if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) {
173 $object->fetch($id);
174 $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha'));
175 $result = $object->update($object->id, $user);
176 if ($result < 0) {
177 setEventMessages($object->error, $object->errors, 'errors');
178 }
179 }
180
181 if ($action == 'update_extras' && $permissiontoeditextra) {
182 $object->fetch($id);
183
184 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
185
186 $attribute_name = GETPOST('attribute', 'aZ09');
187
188 // Fill array 'array_options' with data from update form
189 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
190 if ($ret < 0) {
191 $error++;
192 }
193
194 if (!$error) {
195 $result = $object->updateExtraField($attribute_name, 'COMPANY_MODIFY');
196 if ($result < 0) {
197 setEventMessages($object->error, $object->errors, 'errors');
198 $error++;
199 }
200 }
201
202 if ($error) {
203 $action = 'edit_extras';
204 }
205 }
206}
207
208
209/*
210 * View
211 */
212
213$contactstatic = new Contact($db);
214$form = new Form($db);
215
216if ($id > 0 && empty($object->id)) {
217 // Load data of third party
218 $res = $object->fetch($id);
219 if ($object->id <= 0) {
220 if ($object->error) {
221 dol_print_error($db, $object->error);
222 exit(1);
223 }
224 // Fournisseur::fetch() filters on s.fournisseur > 0, so a third party that exists but is no
225 // longer a vendor returns no row and no database error. Show a readable message with a link to
226 // the generic card instead of the technical error page (#39618).
227 $langs->load("errors");
228 llxHeader('', $langs->trans("ThirdParty").' - '.$langs->trans('Supplier'));
229 print '<div class="warning">'.$langs->trans("ErrorRecordNotFound").' ('.$langs->trans("Supplier").')';
230 print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.((int) $id).'">'.$langs->trans("ThirdParty").'</a>';
231 print '</div>';
232 llxFooter();
233 $db->close();
234 exit(0);
235 }
236}
237
238if ($object->id > 0) {
239 $title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier');
240 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
241 $title = $object->name." - ".$langs->trans('Supplier');
242 }
243 $help_url = '';
244 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-fourn page-card');
245
246 /*
247 * Show tabs
248 */
249 $head = societe_prepare_head($object);
250
251 print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company');
252
253 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
254
255 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
256
257 print '<div class="fichecenter"><div class="fichehalfleft">';
258
259 print '<div class="underbanner clearboth"></div>';
260 print '<table class="border centpercent tableforfield">';
261
262 // Nature Prospect/Customer/Supplier
263 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
264 print $object->getTypeUrl(1);
265 print '</td></tr>';
266
267 if ($object->fournisseur) {
268 $langs->load('compta');
269
270 print '<tr>';
271 print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>';
273 $tmpcheck = $object->check_codefournisseur();
274 if ($tmpcheck != 0 && $tmpcheck != -5) {
275 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
276 }
277 print '</td>';
278 print '</tr>';
279
280 if (isModEnabled('accounting')) {
281 $formaccounting = new FormAccounting($db);
282
283 print '<tr>';
284 print '<td>';
285 print $form->editfieldkey("SupplierAccountancyCodeGeneral", 'supplieraccountancycodegeneral', length_accountg($object->accountancy_code_supplier_general), $object, $user->hasRight('societe', 'creer'));
286 print '</td><td>';
287 if ($action == 'editsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
288 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_supplier_general, 'supplieraccountancycodegeneral', 0, 1, '', 1);
289 } else {
290 if ($object->accountancy_code_supplier_general > 0) {
291 $accountingaccount = new AccountingAccount($db);
292 $accountingaccount->fetch(0, $object->accountancy_code_supplier_general, 1);
293
294 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
295 }
296 if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) {
297 if ($object->accountancy_code_supplier_general > 0) {
298 print ' - ';
299 }
300 $accountingAccountByDefault = '<span class="opacitymedium">' . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) . '</span>';
301 print $accountingAccountByDefault;
302 }
303 }
304 print '</td>';
305 print '</tr>';
306 }
307
308 print '<tr>';
309 print '<td>';
310 print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
311 print '</td><td>';
312 print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
313 print '</td>';
314 print '</tr>';
315 }
316
317 // VAT is used
318 print '<tr>';
319 print '<td class="titlefield">';
320 print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
321 print '</td><td>';
322 print yn($object->tva_assuj);
323 print '</td>';
324 print '</tr>';
325
326 // Local Taxes
327 if ($mysoc->useLocalTax(1)) {
328 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
329 print yn($object->localtax1_assuj);
330 print '</td></tr>';
331 }
332 if ($mysoc->useLocalTax(2)) {
333 print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
334 print yn($object->localtax2_assuj);
335 print '</td></tr>';
336 }
337
338 // VAT reverse-charge by default on supplier invoice or not
339 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
340 print '<tr>';
341 print '<td class="titlefield">';
342 print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc'));
343 print '</td><td>';
344 print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>';
345 print '</td>';
346 print '</tr>';
347 }
348
349 // TVA Intra
350 print '<tr><td class="nowrap">';
351 //print $langs->trans('VATIntra').'</td><td>';
352 $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : '');
353 print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer'));
354 print '</td><td>';
355 print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped' => 1));
356 print '</td></tr>';
357
358 // Default terms of the settlement
359 $langs->load('bills');
360 $form = new Form($db);
361 print '<tr><td>';
362 print '<table width="100%" class="nobordernopadding"><tr><td>';
363 print $langs->trans('PaymentConditions');
364 print '<td>';
365 if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) {
366 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>';
367 }
368 print '</tr></table>';
369 print '</td><td>';
370 if ($action == 'editconditions') {
371 $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, (string) $object->cond_reglement_supplier_id, 'cond_reglement_supplier_id', 1, '', 1, $object->deposit_percent);
372 } else {
373 $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, (string) $object->cond_reglement_supplier_id, 'none', 0, '', 1, $object->deposit_percent);
374 }
375 print "</td>";
376 print '</tr>';
377
378 // Default payment mode
379 print '<tr><td class="nowrap">';
380 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
381 print $langs->trans('PaymentMode');
382 print '<td>';
383 if (($action != 'editmode') && $user->hasRight('societe', 'creer')) {
384 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>';
385 }
386 print '</tr></table>';
387 print '</td><td>';
388 if ($action == 'editmode') {
389 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1);
390 } else {
391 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'none');
392 }
393 print "</td>";
394 print '</tr>';
395
396 if (isModEnabled("bank")) {
397 // Default bank account for payments
398 print '<tr><td class="nowrap">';
399 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
400 print $langs->trans('PaymentBankAccount');
401 print '<td>';
402 if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) {
403 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>';
404 }
405 print '</tr></table>';
406 print '</td><td>';
407 if ($action == 'editbankaccount') {
408 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'fk_account', 1);
409 } else {
410 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'none');
411 }
412 print "</td>";
413 print '</tr>';
414 }
415
416 // Relative discounts (Discounts-Drawbacks-Rebates)
417 print '<tr><td class="nowrap">';
418 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
419 print $langs->trans("CustomerRelativeDiscountShort");
420 print '<td><td class="right">';
421 if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
422 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create&token='.newToken().'">'.img_edit($langs->trans("Modify")).'</a>';
423 }
424 print '</td></tr></table>';
425 print '</td><td>'.($object->remise_supplier_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>' : '').'</td>';
426 print '</tr>';
427
428 // Absolute discounts (Discounts-Drawbacks-Rebates)
429 print '<tr><td class="nowrap">';
430 print '<table width="100%" class="nobordernopadding">';
431 print '<tr><td class="nowrap">';
432 print $langs->trans("CustomerAbsoluteDiscountShort");
433 print '<td><td class="right">';
434 if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
435 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create&token='.newToken().'">'.img_edit($langs->trans("Modify")).'</a>';
436 }
437 print '</td></tr></table>';
438 print '</td>';
439 print '<td>';
440 $amount_discount = $object->getAvailableDiscounts(null, '', 0, 1);
441 if ($amount_discount < 0) {
442 dol_print_error($db, $object->error);
443 }
444 if ($amount_discount > 0) {
445 print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'&action=create&token='.newToken().'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>';
446 }
447 //else print $langs->trans("DiscountNone");
448 print '</td>';
449 print '</tr>';
450
451 if (isModEnabled("supplier_order") && getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT')) {
452 print '<tr class="nowrap">';
453 print '<td>';
454 print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer"));
455 print '</td><td>';
456 $limit_field_type = (getDolGlobalString('MAIN_USE_JQUERY_JEDITABLE')) ? 'numeric' : 'amount';
457 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) : ''));
458 print '</td>';
459 print '</tr>';
460 }
461
462 // Categories
463 if (isModEnabled('category')) {
464 $langs->load("categories");
465 print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>';
466 print '<td>';
467 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
468 print "</td></tr>";
469 }
470
471 // Other attributes
472 $parameters = array('socid' => $object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
473 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
474
475 // Module Adherent
476 if (isModEnabled('member')) {
477 $langs->load("members");
478 $langs->load("users");
479 print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
480 print '<td>';
481 $adh = new Adherent($db);
482 $result = $adh->fetch(0, '', $object->id);
483 if ($result > 0) {
484 $adh->ref = $adh->getFullName($langs);
485 print $adh->getNomUrl(1);
486 } else {
487 print $langs->trans("ThirdpartyNotLinkedToMember");
488 }
489 print '</td>';
490 print "</tr>\n";
491 }
492
493 print '</table>';
494
495
496 print '</div><div class="fichehalfright">';
497
498 $boxstat = '';
499
500 // Nbre max d'elements des petites listes
501 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
502
503 print '<div class="underbanner underbanner-before-box clearboth"></div>';
504 print '<br>';
505
506 // Summary link
507 $boxstat .= '<div class="box divboxtable box-halfright">';
508 $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
509 $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
510
511 if (isModEnabled('supplier_proposal')) {
512 // Box proposals
513 $tmp = $object->getOutstandingProposals('supplier');
514 $outstandingOpened = $tmp['opened'];
515 $outstandingTotal = $tmp['total_ht'];
516 $outstandingTotalIncTax = $tmp['total_ttc'];
517 $text = $langs->trans("OverAllSupplierProposals");
518 $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id;
519 $icon = 'bill';
520 if ($link) {
521 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
522 }
523 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
524 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
525 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
526 $boxstat .= '</div>';
527 if ($link) {
528 $boxstat .= '</a>';
529 }
530 }
531
532 if (isModEnabled("supplier_order")) {
533 // Box proposals
534 $tmp = $object->getOutstandingOrders('supplier');
535 $outstandingOpened = $tmp['opened'];
536 $outstandingTotal = $tmp['total_ht'];
537 $outstandingTotalIncTax = $tmp['total_ttc'];
538 $text = $langs->trans("OverAllOrders");
539 $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id;
540 $icon = 'bill';
541 if ($link) {
542 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
543 }
544 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
545 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
546 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
547 $boxstat .= '</div>';
548 if ($link) {
549 $boxstat .= '</a>';
550 }
551 }
552
553 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
554 $warn = '';
555 $tmp = $object->getOutstandingBills('supplier');
556 $outstandingOpened = $tmp['opened'];
557 $outstandingTotal = $tmp['total_ht'];
558 $outstandingTotalIncTax = $tmp['total_ttc'];
559
560 $text = $langs->trans("OverAllInvoices");
561 $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id;
562 $icon = 'bill';
563 if ($link) {
564 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
565 }
566 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
567 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
568 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
569 $boxstat .= '</div>';
570 if ($link) {
571 $boxstat .= '</a>';
572 }
573
574 // Box outstanding bill
575 $text = $langs->trans("CurrentOutstandingBill");
576 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
577 $icon = 'bill';
578 if ($link) {
579 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
580 }
581 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
582 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
583 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
584 $boxstat .= '</div>';
585 if ($link) {
586 $boxstat .= '</a>';
587 }
588
589 $tmp = $object->getOutstandingBills('supplier', 1);
590 $outstandingOpenedLate = $tmp['opened'];
591 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
592 $text = $langs->trans("CurrentOutstandingBillLate");
593 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
594 $icon = 'bill';
595 if ($link) {
596 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
597 }
598 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
599 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
600 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
601 $boxstat .= '</div>';
602 if ($link) {
603 $boxstat .= '</a>';
604 }
605 }
606 }
607
608
609 $parameters = array();
610 $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action);
611 if (empty($reshook)) {
612 $boxstat .= $hookmanager->resPrint;
613 }
614
615 $boxstat .= '</td></tr>';
616 $boxstat .= '</table>';
617 $boxstat .= '</div>';
618
619 print $boxstat;
620
621
622 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
623
624
625 /*
626 * List of products prices
627 */
628 if (isModEnabled("product") || isModEnabled("service")) {
629 $langs->load("products");
630 //Query from product/liste.php
631 $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,';
632 $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
633 $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
634 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
635 $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
636 $sql .= ' AND pfp.fk_soc = '.((int) $object->id);
637 $sql .= $db->order('pfp.tms', 'desc');
638 $sql .= $db->plimit($MAXLIST);
639
640 $query = $db->query($sql);
641 if (!$query) {
642 dol_print_error($db);
643 }
644
645 $num = $db->num_rows($query);
646
647 print '<div class="div-table-responsive-no-min">';
648 print '<table class="noborder centpercent lastrecordtable">';
649 print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
650 print '<td colspan="2">'.$langs->trans("ProductsAndServices").'</td><td class="right" colspan="2">';
651 print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/product/list.php?fourn_id='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllProductReferencesOfSupplier").'</span><span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().'</span>';
652 print '</a></td></tr>';
653
654 $return = array();
655 if ($num > 0) {
656 $productstatic = new Product($db);
657
658 while ($objp = $db->fetch_object($query)) {
659 $productstatic->id = $objp->rowid;
660 $productstatic->ref = $objp->ref;
661 $productstatic->label = $objp->label;
662 $productstatic->type = $objp->fk_product_type;
663 $productstatic->entity = $objp->entity;
664 $productstatic->status = $objp->status;
665 $productstatic->status_buy = $objp->status_buy;
666 $productstatic->status_batch = $objp->status_batch;
667
668 print '<tr class="oddeven">';
669 print '<td class="nowrap">';
670 print $productstatic->getNomUrl(1);
671 print '</td>';
672 print '<td>';
673 print dol_escape_htmltag($objp->supplier_ref);
674 print '</td>';
675 print '<td class="tdoverflowmax200">';
676 print dol_trunc(dol_htmlentities($objp->label), 30);
677 print '</td>';
678 //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>';
679 print '<td class="right">';
680 //print (isset($objp->unitprice) ? price($objp->unitprice) : '');
681 if (isset($objp->price)) {
682 print '<span class="amount">'.price($objp->price).'</span>';
683 if ($objp->quantity > 1) {
684 print ' / ';
685 print $objp->quantity;
686 }
687 }
688 print '</td>';
689 print '</tr>';
690 }
691 } else {
692 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoProductPriceDefinedForThisSupplier").'</span></td></tr>';
693 }
694
695 print '</table>';
696 print '</div>';
697 }
698
699
700 /*
701 * Latest supplier proposal
702 */
703 $proposalstatic = new SupplierProposal($db);
704
705 if ($user->hasRight("supplier_proposal", "lire")) {
706 $langs->loadLangs(array("supplier_proposal"));
707
708 $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
709 $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
710 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
711 $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
712 $sql .= " ORDER BY p.date_valid DESC";
713 $sql .= $db->plimit($MAXLIST);
714
715 $resql = $db->query($sql);
716 if ($resql) {
717 $i = 0;
718 $num = $db->num_rows($resql);
719
720 if ($num > 0) {
721 print '<div class="div-table-responsive-no-min">';
722 print '<table class="noborder centpercent lastrecordtable">';
723
724 print '<tr class="liste_titre">';
725 print '<td colspan="3">';
726 print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
727 print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllPriceRequests").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
728 // 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>';
729 print '</tr></table>';
730 print '</td></tr>';
731 }
732
733 while ($i < $num && $i <= $MAXLIST) {
734 $obj = $db->fetch_object($resql);
735
736 print '<tr class="oddeven">';
737 print '<td class="nowrap">';
738 $proposalstatic->id = $obj->rowid;
739 $proposalstatic->ref = $obj->ref;
740 $proposalstatic->total_ht = $obj->total_ht;
741 $proposalstatic->total_tva = $obj->total_tva;
742 $proposalstatic->total_ttc = $obj->total_ttc;
743 print $proposalstatic->getNomUrl(1);
744 print '</td>';
745 print '<td class="center" width="80">';
746 if ($obj->dc) {
747 print dol_print_date($db->jdate($obj->dc), 'day');
748 } else {
749 print "-";
750 }
751 print '</td>';
752 print '<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).'</td>';
753 print '</tr>';
754 $i++;
755 }
756 $db->free($resql);
757
758 if ($num > 0) {
759 print "</table></div>";
760 }
761 } else {
762 dol_print_error($db);
763 }
764 }
765
766 /*
767 * Latest supplier orders
768 */
769 $orderstatic = new CommandeFournisseur($db);
770 $orders2invoice = 0;
771
772 if ($user->hasRight("fournisseur", "commande", "lire")) {
773 // TODO move to DAO class
774 // Check if there are supplier orders billable
775 $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
776 $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
777 $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
778 $sql2 .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c';
779 $sql2 .= ' WHERE c.fk_soc = s.rowid';
780 $sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")";
781 $sql2 .= ' AND s.rowid = '.((int) $object->id);
782 // Show orders we can bill
783 if (!getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')) {
784 $sql2 .= " AND c.fk_statut IN (".$db->sanitize((string) CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php
785 } else {
786 // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY
787 $sql2 .= " AND c.fk_statut IN (".$db->sanitize(getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')).")";
788 }
789 $sql2 .= " AND c.billed = 0";
790 // Find order that are not already invoiced
791 // just need to check received status because we have the billed status now
792 //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
793 $resql2 = $db->query($sql2);
794 if ($resql2) {
795 $orders2invoice = $db->num_rows($resql2);
796 $db->free($resql2);
797 } else {
798 setEventMessages($db->lasterror(), null, 'errors');
799 }
800
801 // TODO move to DAO class
802 $sql = "SELECT count(p.rowid) as total";
803 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
804 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
805 $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
806 $resql = $db->query($sql);
807 if ($resql) {
808 $object_count = $db->fetch_object($resql);
809 $num = $object_count->total;
810 }
811
812 $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
813 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
814 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
815 $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
816 $sql .= " ORDER BY p.date_commande DESC";
817 $sql .= $db->plimit($MAXLIST);
818
819 $resql = $db->query($sql);
820 if ($resql) {
821 $i = 0;
822
823 if ($num > 0) {
824 print '<div class="div-table-responsive-no-min">';
825 print '<table class="noborder centpercent lastrecordtable">';
826
827 print '<tr class="liste_titre">';
828 print '<td colspan="4">';
829 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
830 print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans("AllOrders").'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
831 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
832 print '</tr></table>';
833 print '</td></tr>';
834 }
835
836 while ($i < $num && $i < $MAXLIST) {
837 $obj = $db->fetch_object($resql);
838
839 $orderstatic->id = $obj->rowid;
840 $orderstatic->ref = $obj->ref;
841 $orderstatic->total_ht = $obj->total_ht;
842 $orderstatic->total_tva = $obj->total_tva;
843 $orderstatic->total_ttc = $obj->total_ttc;
844 $orderstatic->date = $db->jdate($obj->date);
845
846 print '<tr class="oddeven">';
847 print '<td class="nowraponall">';
848 print $orderstatic->getNomUrl(1);
849 print '</td>';
850 print '<td class="center" width="80">';
851 if ($obj->date) {
852 print dol_print_date($orderstatic->date, 'day');
853 }
854 print '</td>';
855 print '<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).'</span></td>';
856 print '<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).'</td>';
857 print '</tr>';
858 $i++;
859 }
860 $db->free($resql);
861
862 if ($num > 0) {
863 print "</table></div>";
864 }
865 } else {
866 dol_print_error($db);
867 }
868 }
869
870
871 /*
872 * Latest invoices templates
873 */
874 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
875 $sql = 'SELECT f.rowid as id, f.titre as ref';
876 $sql .= ', f.total_ht';
877 $sql .= ', f.total_tva';
878 $sql .= ', f.total_ttc';
879 $sql .= ', f.datec as dc';
880 $sql .= ', f.date_last_gen, f.date_when';
881 $sql .= ', f.frequency';
882 $sql .= ', f.unit_frequency';
883 $sql .= ', f.suspended as suspended';
884 $sql .= ', s.nom, s.rowid as socid';
885 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn_rec as f";
886 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
887 $sql .= " AND f.entity IN (".getEntity('invoice').")";
888 $sql .= ' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
889 $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
890 $sql .= ' f.suspended, f.date_when,';
891 $sql .= ' s.nom, s.rowid';
892 $sql .= $db->order("f.date_last_gen, f.datec", "DESC");
893
894 $resql = $db->query($sql);
895 if ($resql) {
896 $invoicetemplate = new FactureFournisseurRec($db);
897
898 $num = $db->num_rows($resql);
899 if ($num > 0) {
900 print '<div class="div-table-responsive-no-min">';
901 print '<table class="noborder centpercent lastrecordtable">';
902 print '<tr class="liste_titre">';
903 $colspan = 4;
904 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
905 $colspan++;
906 }
907 print '<td colspan="'.$colspan.'">';
908 print '<table class="centpercent nobordernopadding"><tr>';
909 print '<td>'.$langs->trans("LatestSupplierTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
910 print '<td class="right">';
911 print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list-rec.php?socid='.$object->id.'">';
912 print '<span class="hideonsmartphone">'.$langs->trans("AllSupplierTemplateInvoices").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
913 print '</tr></table>';
914 print '</td>';
915 print '</tr>';
916 }
917
918 $i = 0;
919 while ($i < $num && $i < $MAXLIST) {
920 $objp = $db->fetch_object($resql);
921
922 $invoicetemplate->id = $objp->id;
923 $invoicetemplate->ref = $objp->ref;
924 $invoicetemplate->suspended = $objp->suspended;
925 $invoicetemplate->frequency = $objp->frequency;
926 $invoicetemplate->unit_frequency = $objp->unit_frequency;
927 $invoicetemplate->total_ht = $objp->total_ht;
928 $invoicetemplate->total_tva = $objp->total_tva;
929 $invoicetemplate->total_ttc = $objp->total_ttc;
930 $invoicetemplate->date_last_gen = $objp->date_last_gen;
931 $invoicetemplate->date_when = $objp->date_when;
932
933 print '<tr class="oddeven">';
934 print '<td class="tdoverflowmax250">';
935 print $invoicetemplate->getNomUrl(1);
936 print '</td>';
937
938 if ($objp->frequency && $objp->date_last_gen > 0) {
939 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
940 } else {
941 if ($objp->dc > 0) {
942 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
943 } else {
944 print '<td class="right"><b>!!!</b></td>';
945 }
946 }
947 print '<td class="right nowraponall">';
948 print price($objp->total_ht);
949 print '</td>';
950
951 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
952 print '<td class="right nowraponall">';
953 print price($objp->total_ttc);
954 print '</td>';
955 }
956
957 print '<td class="nowrap right" style="min-width: 60px">';
958 print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
959 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
960 print '</td>';
961 print "</tr>\n";
962 $i++;
963 }
964 $db->free($resql);
965
966 if ($num > 0) {
967 print "</table>";
968 print '</div>';
969 }
970 } else {
971 dol_print_error($db);
972 }
973 }
974
975
976 /*
977 * Latest supplier invoices
978 */
979
980 $langs->load('bills');
981 $facturestatic = new FactureFournisseur($db);
982
983 if ($user->hasRight('fournisseur', 'facture', 'lire')) {
984 // TODO move to DAO class
985 $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,';
986 $sql .= ' SUM(pf.amount) as am';
987 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
988 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
989 $sql .= ' WHERE f.fk_soc = '.((int) $object->id);
990 $sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
991 $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';
992 $sql .= ' ORDER BY f.datef DESC';
993 $resql = $db->query($sql);
994 if ($resql) {
995 $i = 0;
996 $num = $db->num_rows($resql);
997 if ($num > 0) {
998 print '<div class="div-table-responsive-no-min">';
999 print '<table class="noborder centpercent lastrecordtable">';
1000
1001 print '<tr class="liste_titre">';
1002 print '<td colspan="4">';
1003 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
1004 print '<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id.'"><span class="hideonsmartphone">'.$langs->trans('AllBills').'</span><span class="badge marginleftonlyshort">'.$num.'</span></td>';
1005 print '<td width="20px" class="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"), 'stats').'</a></td>';
1006 print '</tr></table>';
1007 print '</td></tr>';
1008 }
1009
1010 while ($i < min($num, $MAXLIST)) {
1011 $obj = $db->fetch_object($resql);
1012
1013 $facturestatic->id = $obj->rowid;
1014 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
1015 $facturestatic->ref_supplier = $obj->ref_supplier;
1016 $facturestatic->libelle = $obj->label; // deprecated
1017 $facturestatic->label = $obj->label;
1018 $facturestatic->total_ht = $obj->total_ht;
1019 $facturestatic->total_tva = $obj->total_tva;
1020 $facturestatic->total_ttc = $obj->total_ttc;
1021 $facturestatic->date = $db->jdate($obj->df);
1022
1023 print '<tr class="oddeven">';
1024 print '<td class="tdoverflowmax200">';
1025 print '<span class="nowraponall">'.$facturestatic->getNomUrl(1).'</span>';
1026 print $obj->ref_supplier ? ' - '.$obj->ref_supplier : '';
1027 print($obj->label ? ' - ' : '').dol_trunc($obj->label, 14);
1028 print '</td>';
1029 print '<td class="center nowrap">'.dol_print_date($facturestatic->date, 'day').'</td>';
1030 print '<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).'</span></td>';
1031 print '<td class="right nowrap">';
1032 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
1033 print '</td>';
1034 print '</tr>';
1035 $i++;
1036 }
1037 $db->free($resql);
1038 if ($num > 0) {
1039 print '</table></div>';
1040 }
1041 } else {
1042 dol_print_error($db);
1043 }
1044 }
1045
1046 // Allow external modules to add their own shortlist of recent objects
1047 $parameters = array();
1048 $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
1049 if ($reshook < 0) {
1050 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1051 } else {
1052 print $hookmanager->resPrint;
1053 }
1054
1055 print '</div></div>';
1056 print '<div class="clearboth"></div>';
1057
1058 print dol_get_fiche_end();
1059
1060
1061 /*
1062 * Action bar
1063 */
1064 print '<div class="tabsAction">';
1065
1066 $parameters = array();
1067 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1068 // modified by hook
1069 if (empty($reshook)) {
1070 if ($object->status != 1) {
1071 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('ThirdPartyIsClosed'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1072 }
1073
1074 if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "creer")) {
1075 $langs->load("supplier_proposal");
1076 if ($object->status == 1) {
1077 print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;socid='.$object->id, '');
1078 } else {
1079 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1080 }
1081 }
1082
1083 if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) {
1084 $langs->load("orders");
1085 if ($object->status == 1) {
1086 print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;token='.newToken().'&amp;socid='.$object->id, '');
1087 } else {
1088 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1089 }
1090 }
1091
1092 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
1093 if (!empty($orders2invoice) && $orders2invoice > 0) {
1094 if ($object->status == 1) {
1095 // Company is open
1096 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&amp;search_billed=0&amp;autoselectall=1', '');
1097 } else {
1098 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1099 }
1100 } else {
1101 print dolGetButtonAction($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1102 }
1103 }
1104
1105 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
1106 $langs->load("bills");
1107 if ($object->status == 1) {
1108 print dolGetButtonAction('', $langs->trans('AddBill'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;socid='.$object->id, '');
1109 } else {
1110 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddBill'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1111 }
1112 }
1113
1114 // Add action
1115 if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
1116 if ($user->hasRight("agenda", "myactions", "create")) {
1117 print dolGetButtonAction('', $langs->trans('AddAction'), 'default', DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;socid='.$object->id, '');
1118 } else {
1119 print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddAction'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1120 }
1121 }
1122 }
1123
1124 print '</div>';
1125
1126
1127 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) {
1128 print '<br>';
1129 // List of contacts
1130 show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
1131 }
1132
1133 if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) {
1134 print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
1135
1136 // List of todo actions
1137 show_actions_todo($conf, $langs, $db, $object);
1138
1139 // List of done actions
1140 show_actions_done($conf, $langs, $db, $object);
1141 }
1142} else {
1143 dol_print_error($db);
1144}
1145
1146// End of page
1147llxFooter();
1148$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage predefined suppliers products.
const STATUS_RECEIVED_COMPLETELY
Received completely.
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage suppliers invoices.
Class to manage invoice templates.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class to manage suppliers.
Class to manage products or services.
Class to manage price ask supplier.
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.