dolibarr 25.0.0-alpha
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-2026 Frédéric France <frederic.france@free.fr>
11 * Copyright (C) 2024-2026 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';
45require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
46require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
47require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture-rec.class.php';
48require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
49require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
52if (isModEnabled('member')) {
53 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
54}
55if (isModEnabled('accounting')) {
56 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
57 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
58}
59
60// Load translation files required by page
61$langs->loadLangs(array('accountancy', 'companies', 'suppliers', 'products', 'bills', 'orders', 'commercial'));
62
63$action = GETPOST('action', 'aZ09');
64$cancel = GETPOST('cancel', 'alpha');
65
66$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'));
67if ($user->isExternalUser()) {
68 $id = $user->isExternalUser();
69}
70
71// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
72$hookmanager->initHooks(array('thirdpartysupplier', 'globalcard'));
73
74$result = restrictedArea($user, 'societe&fournisseur', $id, '&societe', '', 'rowid');
75
77
78// fetch optionals attributes and labels
79$extrafields->fetch_name_optionals_label($object->table_element);
80
81$permissiontoadd = $user->hasRight('societe', 'creer');
82$permissiontoeditextra = $permissiontoadd;
83if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
84 // For action 'update_extras', is there a specific permission set for the attribute to update
85 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
86}
87
88// Security check
89$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
90
91if ($object->id > 0) {
92 if (!($object->fournisseur > 0) || !$user->hasRight("fournisseur", "lire")) {
94 }
95}
96
97
98/*
99 * Actions
100 */
101$error = 0;
102$parameters = array('id' => $id);
103$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
104if ($reshook < 0) {
105 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
106}
107
108if (empty($reshook)) {
109 if ($cancel) {
110 $action = "";
111 }
112
113 // set general supplier accounting account
114 if ($action == 'setsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
115 $result = $object->fetch($id);
116 $object->accountancy_code_supplier_general = GETPOST("supplieraccountancycodegeneral");
117 $result = $object->update($object->id, $user, 1, 0, 1);
118 if ($result < 0) {
119 setEventMessages($object->error, $object->errors, 'errors');
120 $_GET['action'] = 'editsupplieraccountancycode';
121 }
122 }
123
124 // Set auxiliary supplier accounting account
125 if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) {
126 $result = $object->fetch($id);
127 $object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
128 $result = $object->update($object->id, $user, 1, 0, 1);
129 if ($result < 0) {
130 setEventMessages($object->error, $object->errors, 'errors');
131 $action = 'editsupplieraccountancycode';
132 }
133 }
134 // Set vat number accounting account
135 if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) {
136 $result = $object->fetch($id);
137 $object->tva_intra = GETPOST("tva_intra");
138 $result = $object->update($object->id, $user, 1, 0, 0);
139 if ($result < 0) {
140 setEventMessages($object->error, $object->errors, 'errors');
141 }
142 }
143 // Set payment terms of the settlement
144 if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) {
145 $object->fetch($id);
146 $result = $object->setPaymentTerms(GETPOSTINT('cond_reglement_supplier_id'), GETPOSTINT('cond_reglement_supplier_id_deposit_percent'));
147 if ($result < 0) {
148 dol_print_error($db, $object->error);
149 }
150 }
151 // Payment mode
152 if ($action == 'setmode' && $user->hasRight('societe', 'creer')) {
153 $object->fetch($id);
154 $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_supplier_id'));
155 if ($result < 0) {
156 dol_print_error($db, $object->error);
157 }
158 }
159
160 // Bank account
161 if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) {
162 $object->fetch($id);
163 $result = $object->setBankAccount(GETPOSTINT('fk_account'));
164 if ($result < 0) {
165 setEventMessages($object->error, $object->errors, 'errors');
166 }
167 }
168
169 // update supplier order min amount
170 if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) {
171 $object->fetch($id);
172 $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha'));
173 $result = $object->update($object->id, $user);
174 if ($result < 0) {
175 setEventMessages($object->error, $object->errors, 'errors');
176 }
177 }
178
179 if ($action == 'update_extras' && $permissiontoeditextra) {
180 $object->fetch($id);
181
182 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
183
184 $attribute_name = GETPOST('attribute', 'aZ09');
185
186 // Fill array 'array_options' with data from update form
187 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
188 if ($ret < 0) {
189 $error++;
190 }
191
192 if (!$error) {
193 $result = $object->updateExtraField($attribute_name, 'COMPANY_MODIFY');
194 if ($result < 0) {
195 setEventMessages($object->error, $object->errors, 'errors');
196 $error++;
197 }
198 }
199
200 if ($error) {
201 $action = 'edit_extras';
202 }
203 }
204}
205
206
207/*
208 * View
209 */
210
211$contactstatic = new Contact($db);
212$form = new Form($db);
213
214if ($id > 0 && empty($object->id)) {
215 // Load data of third party
216 $res = $object->fetch($id);
217 if ($object->id <= 0) {
218 if ($object->error) {
219 dol_print_error($db, $object->error);
220 exit(1);
221 }
222 // Fournisseur::fetch() filters on s.fournisseur > 0, so a third party that exists but is no
223 // longer a vendor returns no row and no database error. Show a readable message with a link to
224 // the generic card instead of the technical error page (#39618).
225 $langs->load("errors");
226 llxHeader('', $langs->trans("ThirdParty").' - '.$langs->trans('Supplier'));
227 print '<div class="warning">'.$langs->trans("ErrorRecordNotFound").' ('.$langs->trans("Supplier").')';
228 print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.((int) $id).'">'.$langs->trans("ThirdParty").'</a>';
229 print '</div>';
230 llxFooter();
231 $db->close();
232 exit(0);
233 }
234}
235
236if ($object->id > 0) {
237 $title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier');
238 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
239 $title = $object->name." - ".$langs->trans('Supplier');
240 }
241 $help_url = '';
242 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-fourn page-card');
243
244 /*
245 * Show tabs
246 */
247 $head = societe_prepare_head($object);
248
249 print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company');
250
251 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
252
253 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
254
255 print '<div class="fichecenter"><div class="fichehalfleft">';
256
257 print '<div class="underbanner clearboth"></div>';
258 print '<table class="border centpercent tableforfield">';
259
260 // Nature Prospect/Customer/Supplier
261 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
262 print $object->getTypeUrl(1);
263 print '</td></tr>';
264
265 if ($object->fournisseur) {
266 $langs->load('compta');
267
268 print '<tr>';
269 print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>';
271 $tmpcheck = $object->check_codefournisseur();
272 if ($tmpcheck != 0 && $tmpcheck != -5) {
273 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
274 }
275 print '</td>';
276 print '</tr>';
277
278 if (isModEnabled('accounting')) {
279 $formaccounting = new FormAccounting($db);
280
281 print '<tr>';
282 print '<td>';
283 print $form->editfieldkey("SupplierAccountancyCodeGeneral", 'supplieraccountancycodegeneral', length_accountg($object->accountancy_code_supplier_general), $object, $user->hasRight('societe', 'creer'));
284 print '</td><td>';
285 if ($action == 'editsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
286 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_supplier_general, 'supplieraccountancycodegeneral', 0, 1, '', 1);
287 } else {
288 if ($object->accountancy_code_supplier_general > 0) {
289 $accountingaccount = new AccountingAccount($db);
290 $accountingaccount->fetch(0, $object->accountancy_code_supplier_general, 1);
291
292 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
293 }
294 if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) {
295 if ($object->accountancy_code_supplier_general > 0) {
296 print ' - ';
297 }
298 $accountingAccountByDefault = '<span class="opacitymedium">' . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) . '</span>';
299 print $accountingAccountByDefault;
300 }
301 }
302 print '</td>';
303 print '</tr>';
304 }
305
306 print '<tr>';
307 print '<td>';
308 print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
309 print '</td><td>';
310 print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
311 print '</td>';
312 print '</tr>';
313 }
314
315 // VAT is used
316 print '<tr>';
317 print '<td class="titlefield">';
318 print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
319 print '</td><td>';
320 print yn($object->tva_assuj);
321 print '</td>';
322 print '</tr>';
323
324 // Local Taxes
325 if ($mysoc->useLocalTax(1)) {
326 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
327 print yn($object->localtax1_assuj);
328 print '</td></tr>';
329 }
330 if ($mysoc->useLocalTax(2)) {
331 print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
332 print yn($object->localtax2_assuj);
333 print '</td></tr>';
334 }
335
336 // VAT reverse-charge by default on supplier invoice or not
337 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
338 print '<tr>';
339 print '<td class="titlefield">';
340 print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc').'<br>'.$langs->trans('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC'));
341 print '</td><td>';
342 print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>';
343 print '</td>';
344 print '</tr>';
345 }
346
347 // TVA Intra
348 print '<tr><td class="nowrap">';
349 //print $langs->trans('VATIntra').'</td><td>';
350 $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : '');
351 print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer'));
352 print '</td><td>';
353 print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped' => 1));
354 print '</td></tr>';
355
356 // Default terms of the settlement
357 $langs->load('bills');
358 $form = new Form($db);
359 print '<tr><td>';
360 print '<table width="100%" class="nobordernopadding"><tr><td>';
361 print $langs->trans('PaymentConditions');
362 print '<td>';
363 if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) {
364 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>';
365 }
366 print '</tr></table>';
367 print '</td><td>';
368 if ($action == 'editconditions') {
369 $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);
370 } else {
371 $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, (string) $object->cond_reglement_supplier_id, 'none', 0, '', 1, $object->deposit_percent);
372 }
373 print "</td>";
374 print '</tr>';
375
376 // Default payment mode
377 print '<tr><td class="nowrap">';
378 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
379 print $langs->trans('PaymentMode');
380 print '<td>';
381 if (($action != 'editmode') && $user->hasRight('societe', 'creer')) {
382 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>';
383 }
384 print '</tr></table>';
385 print '</td><td>';
386 if ($action == 'editmode') {
387 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1);
388 } else {
389 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'none');
390 }
391 print "</td>";
392 print '</tr>';
393
394 if (isModEnabled("bank")) {
395 // Default bank account for payments
396 print '<tr><td class="nowrap">';
397 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
398 print $langs->trans('PaymentBankAccount');
399 print '<td>';
400 if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) {
401 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>';
402 }
403 print '</tr></table>';
404 print '</td><td>';
405 if ($action == 'editbankaccount') {
406 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'fk_account', 1);
407 } else {
408 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'none');
409 }
410 print "</td>";
411 print '</tr>';
412 }
413
414 // Relative discounts (Discounts-Drawbacks-Rebates)
415 print '<tr><td class="nowrap">';
416 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
417 print $langs->trans("CustomerRelativeDiscountShort");
418 print '<td><td class="right">';
419 if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
420 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>';
421 }
422 print '</td></tr></table>';
423 print '</td><td>'.($object->remise_supplier_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>' : '').'</td>';
424 print '</tr>';
425
426 // Absolute discounts (Discounts-Drawbacks-Rebates)
427 print '<tr><td class="nowrap">';
428 print '<table width="100%" class="nobordernopadding">';
429 print '<tr><td class="nowrap">';
430 print $langs->trans("CustomerAbsoluteDiscountShort");
431 print '<td><td class="right">';
432 if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
433 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>';
434 }
435 print '</td></tr></table>';
436 print '</td>';
437 print '<td>';
438 $amount_discount = $object->getAvailableDiscounts(null, '', 0, 1);
439 if ($amount_discount < 0) {
440 dol_print_error($db, $object->error);
441 }
442 if ($amount_discount > 0) {
443 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>';
444 }
445 //else print $langs->trans("DiscountNone");
446 print '</td>';
447 print '</tr>';
448
449 if (isModEnabled("supplier_order") && getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT')) {
450 print '<tr class="nowrap">';
451 print '<td>';
452 print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer"));
453 print '</td><td>';
454 //$limit_field_type = (getDolGlobalString('MAIN_USE_EDIT_IN_PLACE')) ? 'numeric' : 'amount'; // TODO deprecated ?
455 $limit_field_type = 'amount';
456 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) : ''));
457 print '</td>';
458 print '</tr>';
459 }
460
461 // Categories
462 if (isModEnabled('category')) {
463 $langs->load("categories");
464 print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>';
465 print '<td>';
466 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
467 print "</td></tr>";
468 }
469
470 // Other attributes
471 $parameters = array('socid' => $object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
472 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
473
474 // Module Adherent
475 if (isModEnabled('member')) {
476 $langs->load("members");
477 $langs->load("users");
478 print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
479 print '<td>';
480 $adh = new Adherent($db);
481 $result = $adh->fetch(0, '', $object->id);
482 if ($result > 0) {
483 $adh->ref = $adh->getFullName($langs);
484 print $adh->getNomUrl(1);
485 } else {
486 print $langs->trans("ThirdpartyNotLinkedToMember");
487 }
488 print '</td>';
489 print "</tr>\n";
490 }
491
492 print '</table>';
493
494
495 print '</div><div class="fichehalfright">';
496
497 $boxstat = '';
498
499 // Nbre max d'elements des petites listes
500 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
501
502 print '<div class="underbanner underbanner-before-box clearboth"></div>';
503 print '<br>';
504
505 // Summary link
506 $boxstat .= '<div class="box divboxtable box-halfright">';
507 $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
508 $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
509
510 if (isModEnabled('supplier_proposal')) {
511 // Box proposals
512 $tmp = $object->getOutstandingProposals('supplier');
513 $outstandingOpened = $tmp['opened'];
514 $outstandingTotal = $tmp['total_ht'];
515 $outstandingTotalIncTax = $tmp['total_ttc'];
516 $text = $langs->trans("OverAllSupplierProposals");
517 $link = DOL_URL_ROOT.'/supplier_proposal/list.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">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
525 $boxstat .= '</div>';
526 if ($link) {
527 $boxstat .= '</a>';
528 }
529 }
530
531 if (isModEnabled("supplier_order")) {
532 // Box proposals
533 $tmp = $object->getOutstandingOrders('supplier');
534 $outstandingOpened = $tmp['opened'];
535 $outstandingTotal = $tmp['total_ht'];
536 $outstandingTotalIncTax = $tmp['total_ttc'];
537 $text = $langs->trans("OverAllOrders");
538 $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id;
539 $icon = 'bill';
540 if ($link) {
541 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
542 }
543 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
544 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
545 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
546 $boxstat .= '</div>';
547 if ($link) {
548 $boxstat .= '</a>';
549 }
550 }
551
552 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
553 $warn = '';
554 $tmp = $object->getOutstandingBills('supplier');
555 $outstandingOpened = $tmp['opened'];
556 $outstandingTotal = $tmp['total_ht'];
557 $outstandingTotalIncTax = $tmp['total_ttc'];
558
559 $text = $langs->trans("OverAllInvoices");
560 $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id;
561 $icon = 'bill';
562 if ($link) {
563 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
564 }
565 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
566 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
567 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
568 $boxstat .= '</div>';
569 if ($link) {
570 $boxstat .= '</a>';
571 }
572
573 // Box outstanding bill
574 $text = $langs->trans("CurrentOutstandingBill");
575 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
576 $icon = 'bill';
577 if ($link) {
578 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
579 }
580 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
581 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
582 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
583 $boxstat .= '</div>';
584 if ($link) {
585 $boxstat .= '</a>';
586 }
587
588 $tmp = $object->getOutstandingBills('supplier', 1);
589 $outstandingOpenedLate = $tmp['opened'];
590 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
591 $text = $langs->trans("CurrentOutstandingBillLate");
592 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
593 $icon = 'bill';
594 if ($link) {
595 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
596 }
597 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
598 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
599 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
600 $boxstat .= '</div>';
601 if ($link) {
602 $boxstat .= '</a>';
603 }
604 }
605 }
606
607
608 $parameters = array();
609 $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action);
610 if (empty($reshook)) {
611 $boxstat .= $hookmanager->resPrint;
612 }
613
614 $boxstat .= '</td></tr>';
615 $boxstat .= '</table>';
616 $boxstat .= '</div>';
617
618 print $boxstat;
619
620
621 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
622
623
624 /*
625 * List of products prices
626 */
627 if (isModEnabled("product") || isModEnabled("service")) {
628 $langs->load("products");
629 //Query from product/liste.php
630 $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,';
631 $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
632 $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
633 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
634 $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
635 $sql .= ' AND pfp.fk_soc = '.((int) $object->id);
636 $sql .= $db->order('pfp.tms', 'desc');
637 $sql .= $db->plimit($MAXLIST);
638
639 $query = $db->query($sql);
640 if (!$query) {
642 }
643
644 $num = $db->num_rows($query);
645
646 print '<div class="div-table-responsive-no-min">';
647 print '<table class="noborder centpercent lastrecordtable">';
648 print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
649 print '<td colspan="2">'.$langs->trans("ProductsAndServices").'</td><td class="right" colspan="2">';
650 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>';
651 print '</a></td></tr>';
652
653 $return = array();
654 if ($num > 0) {
655 $productstatic = new Product($db);
656
657 while ($objp = $db->fetch_object($query)) {
658 $productstatic->id = $objp->rowid;
659 $productstatic->ref = $objp->ref;
660 $productstatic->label = $objp->label;
661 $productstatic->type = $objp->fk_product_type;
662 $productstatic->entity = $objp->entity;
663 $productstatic->status = $objp->status;
664 $productstatic->status_buy = $objp->status_buy;
665 $productstatic->status_batch = $objp->status_batch;
666
667 print '<tr class="oddeven">';
668 print '<td class="nowrap">';
669 print $productstatic->getNomUrl(1);
670 print '</td>';
671 print '<td>';
672 print dol_escape_htmltag($objp->supplier_ref);
673 print '</td>';
674 print '<td class="tdoverflowmax200">';
675 print dol_trunc(dol_htmlentities($objp->label), 30);
676 print '</td>';
677 //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>';
678 print '<td class="right">';
679 //print (isset($objp->unitprice) ? price($objp->unitprice) : '');
680 if (isset($objp->price)) {
681 print '<span class="amount">'.price($objp->price).'</span>';
682 if ($objp->quantity > 1) {
683 print ' / ';
684 print $objp->quantity;
685 }
686 }
687 print '</td>';
688 print '</tr>';
689 }
690 } else {
691 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoProductPriceDefinedForThisSupplier").'</span></td></tr>';
692 }
693
694 print '</table>';
695 print '</div>';
696 }
697
698
699 /*
700 * Latest supplier proposal
701 */
702 $proposalstatic = new SupplierProposal($db);
703
704 if ($user->hasRight("supplier_proposal", "lire")) {
705 $langs->loadLangs(array("supplier_proposal"));
706
707 $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
708 $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
709 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
710 $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
711 $sql .= " ORDER BY p.date_valid DESC";
712 $sql .= $db->plimit($MAXLIST);
713
714 $resql = $db->query($sql);
715 if ($resql) {
716 $i = 0;
717 $num = $db->num_rows($resql);
718
719 if ($num > 0) {
720 print '<div class="div-table-responsive-no-min">';
721 print '<table class="noborder centpercent lastrecordtable">';
722
723 print '<tr class="liste_titre">';
724 print '<td colspan="3">';
725 print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
726 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>';
727 // 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>';
728 print '</tr></table>';
729 print '</td></tr>';
730 }
731
732 while ($i < $num && $i <= $MAXLIST) {
733 $obj = $db->fetch_object($resql);
734
735 print '<tr class="oddeven">';
736 print '<td class="nowrap">';
737 $proposalstatic->id = $obj->rowid;
738 $proposalstatic->ref = $obj->ref;
739 $proposalstatic->total_ht = $obj->total_ht;
740 $proposalstatic->total_tva = $obj->total_tva;
741 $proposalstatic->total_ttc = $obj->total_ttc;
742 print $proposalstatic->getNomUrl(1);
743 print '</td>';
744 print '<td class="center" width="80">';
745 if ($obj->dc) {
746 print dol_print_date($db->jdate($obj->dc), 'day');
747 } else {
748 print "-";
749 }
750 print '</td>';
751 print '<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).'</td>';
752 print '</tr>';
753 $i++;
754 }
755 $db->free($resql);
756
757 if ($num > 0) {
758 print "</table></div>";
759 }
760 } else {
762 }
763 }
764
765 /*
766 * Latest supplier orders
767 */
768 $orderstatic = new CommandeFournisseur($db);
769 $orders2invoice = 0;
770
771 if ($user->hasRight("fournisseur", "commande", "lire")) {
772 // TODO move to DAO class
773 // Check if there are supplier orders billable
774 $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
775 $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
776 $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
777 $sql2 .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c';
778 $sql2 .= ' WHERE c.fk_soc = s.rowid';
779 $sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")";
780 $sql2 .= ' AND s.rowid = '.((int) $object->id);
781 // Show orders we can bill
782 if (!getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')) {
783 $sql2 .= " AND c.fk_statut IN (".$db->sanitize((string) CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php
784 } else {
785 // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY
786 $sql2 .= " AND c.fk_statut IN (".$db->sanitize(getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')).")";
787 }
788 $sql2 .= " AND c.billed = 0";
789 // Find order that are not already invoiced
790 // just need to check received status because we have the billed status now
791 //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
792 $resql2 = $db->query($sql2);
793 if ($resql2) {
794 $orders2invoice = $db->num_rows($resql2);
795 $db->free($resql2);
796 } else {
797 setEventMessages($db->lasterror(), null, 'errors');
798 }
799
800 // TODO move to DAO class
801 $sql = "SELECT count(p.rowid) as total";
802 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
803 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
804 $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
805 $num = 0;
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 {
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 {
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 {
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 (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "creer")) {
1071 $langs->load("supplier_proposal");
1072 if ($object->status == 1) {
1073 print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&socid='.$object->id, '');
1074 } else {
1075 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1076 }
1077 }
1078
1079 if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) {
1080 $langs->load("orders");
1081 if ($object->status == 1) {
1082 print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id, '');
1083 } else {
1084 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1085 }
1086 }
1087
1088 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
1089 if (!empty($orders2invoice) && $orders2invoice > 0) {
1090 if ($object->status == 1) {
1091 // Company is open
1092 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1', '');
1093 } else {
1094 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1095 }
1096 } else {
1097 if ($object->status == 1) {
1098 print dolGetButtonAction($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1099 } else {
1100 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1101 }
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&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&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 {
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 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, $subtabs='')
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
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)
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.
Definition html.lib.php:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
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...
Definition html.lib.php:172
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.