dolibarr 24.0.0-beta
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 dol_print_error($db, $object->error);
219 exit(1);
220 }
221}
222
223if ($object->id > 0) {
224 $title = $langs->trans("ThirdParty")." - ".$langs->trans('Supplier');
225 if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
226 $title = $object->name." - ".$langs->trans('Supplier');
227 }
228 $help_url = '';
229 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-fourn page-card');
230
231 /*
232 * Show tabs
233 */
234 $head = societe_prepare_head($object);
235
236 print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company');
237
238 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
239
240 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
241
242 print '<div class="fichecenter"><div class="fichehalfleft">';
243
244 print '<div class="underbanner clearboth"></div>';
245 print '<table class="border centpercent tableforfield">';
246
247 // Nature Prospect/Customer/Supplier
248 print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
249 print $object->getTypeUrl(1);
250 print '</td></tr>';
251
252 if ($object->fournisseur) {
253 $langs->load('compta');
254
255 print '<tr>';
256 print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>';
257 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
258 $tmpcheck = $object->check_codefournisseur();
259 if ($tmpcheck != 0 && $tmpcheck != -5) {
260 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
261 }
262 print '</td>';
263 print '</tr>';
264
265 if (isModEnabled('accounting')) {
266 $formaccounting = new FormAccounting($db);
267
268 print '<tr>';
269 print '<td>';
270 print $form->editfieldkey("SupplierAccountancyCodeGeneral", 'supplieraccountancycodegeneral', length_accountg($object->accountancy_code_supplier_general), $object, $user->hasRight('societe', 'creer'));
271 print '</td><td>';
272 if ($action == 'editsupplieraccountancycodegeneral' && $user->hasRight('societe', 'creer')) {
273 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code_supplier_general, 'supplieraccountancycodegeneral', 0, 1, '', 1);
274 } else {
275 if ($object->accountancy_code_supplier_general > 0) {
276 $accountingaccount = new AccountingAccount($db);
277 $accountingaccount->fetch(0, $object->accountancy_code_supplier_general, 1);
278
279 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
280 }
281 if (getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) {
282 if ($object->accountancy_code_supplier_general > 0) {
283 print ' - ';
284 }
285 $accountingAccountByDefault = '<span class="opacitymedium">' . $langs->trans("AccountingAccountByDefaultShort") . ": " . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER')) . '</span>';
286 print $accountingAccountByDefault;
287 }
288 }
289 print '</td>';
290 print '</tr>';
291 }
292
293 print '<tr>';
294 print '<td>';
295 print $form->editfieldkey("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
296 print '</td><td>';
297 print $form->editfieldval("SupplierAccountancyCode", 'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight('societe', 'creer'));
298 print '</td>';
299 print '</tr>';
300 }
301
302 // VAT is used
303 print '<tr>';
304 print '<td class="titlefield">';
305 print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
306 print '</td><td>';
307 print yn($object->tva_assuj);
308 print '</td>';
309 print '</tr>';
310
311 // Local Taxes
312 if ($mysoc->useLocalTax(1)) {
313 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
314 print yn($object->localtax1_assuj);
315 print '</td></tr>';
316 }
317 if ($mysoc->useLocalTax(2)) {
318 print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
319 print yn($object->localtax2_assuj);
320 print '</td></tr>';
321 }
322
323 // VAT reverse-charge by default on supplier invoice or not
324 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
325 print '<tr>';
326 print '<td class="titlefield">';
327 print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc'));
328 print '</td><td>';
329 print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>';
330 print '</td>';
331 print '</tr>';
332 }
333
334 // TVA Intra
335 print '<tr><td class="nowrap">';
336 //print $langs->trans('VATIntra').'</td><td>';
337 $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : '');
338 print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer'));
339 print '</td><td>';
340 print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped' => 1));
341 print '</td></tr>';
342
343 // Default terms of the settlement
344 $langs->load('bills');
345 $form = new Form($db);
346 print '<tr><td>';
347 print '<table width="100%" class="nobordernopadding"><tr><td>';
348 print $langs->trans('PaymentConditions');
349 print '<td>';
350 if (($action != 'editconditions') && $user->hasRight('societe', 'creer')) {
351 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>';
352 }
353 print '</tr></table>';
354 print '</td><td>';
355 if ($action == 'editconditions') {
356 $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);
357 } else {
358 $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?socid=' . $object->id, (string) $object->cond_reglement_supplier_id, 'none', 0, '', 1, $object->deposit_percent);
359 }
360 print "</td>";
361 print '</tr>';
362
363 // Default payment mode
364 print '<tr><td class="nowrap">';
365 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
366 print $langs->trans('PaymentMode');
367 print '<td>';
368 if (($action != 'editmode') && $user->hasRight('societe', 'creer')) {
369 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>';
370 }
371 print '</tr></table>';
372 print '</td><td>';
373 if ($action == 'editmode') {
374 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'mode_reglement_supplier_id', 'DBIT', 1, 1);
375 } else {
376 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->mode_reglement_supplier_id, 'none');
377 }
378 print "</td>";
379 print '</tr>';
380
381 if (isModEnabled("bank")) {
382 // Default bank account for payments
383 print '<tr><td class="nowrap">';
384 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
385 print $langs->trans('PaymentBankAccount');
386 print '<td>';
387 if (($action != 'editbankaccount') && $user->hasRight('societe', 'creer')) {
388 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>';
389 }
390 print '</tr></table>';
391 print '</td><td>';
392 if ($action == 'editbankaccount') {
393 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'fk_account', 1);
394 } else {
395 $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, (string) $object->fk_account, 'none');
396 }
397 print "</td>";
398 print '</tr>';
399 }
400
401 // Relative discounts (Discounts-Drawbacks-Rebates)
402 print '<tr><td class="nowrap">';
403 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
404 print $langs->trans("CustomerRelativeDiscountShort");
405 print '<td><td class="right">';
406 if ($user->hasRight('societe', 'creer') && !$user->socid > 0) {
407 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>';
408 }
409 print '</td></tr></table>';
410 print '</td><td>'.($object->remise_supplier_percent ? '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>' : '').'</td>';
411 print '</tr>';
412
413 // Absolute discounts (Discounts-Drawbacks-Rebates)
414 print '<tr><td class="nowrap">';
415 print '<table width="100%" class="nobordernopadding">';
416 print '<tr><td class="nowrap">';
417 print $langs->trans("CustomerAbsoluteDiscountShort");
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/remx.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>';
424 print '<td>';
425 $amount_discount = $object->getAvailableDiscounts(null, '', 0, 1);
426 if ($amount_discount < 0) {
427 dol_print_error($db, $object->error);
428 }
429 if ($amount_discount > 0) {
430 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>';
431 }
432 //else print $langs->trans("DiscountNone");
433 print '</td>';
434 print '</tr>';
435
436 if (isModEnabled("supplier_order") && getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT')) {
437 print '<tr class="nowrap">';
438 print '<td>';
439 print $form->editfieldkey("OrderMinAmount", 'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight("societe", "creer"));
440 print '</td><td>';
441 //$limit_field_type = (getDolGlobalString('MAIN_USE_EDIT_IN_PLACE')) ? 'numeric' : 'amount'; // TODO deprecated ?
442 $limit_field_type = 'amount';
443 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) : ''));
444 print '</td>';
445 print '</tr>';
446 }
447
448 // Categories
449 if (isModEnabled('category')) {
450 $langs->load("categories");
451 print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>';
452 print '<td>';
453 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
454 print "</td></tr>";
455 }
456
457 // Other attributes
458 $parameters = array('socid' => $object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
459 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
460
461 // Module Adherent
462 if (isModEnabled('member')) {
463 $langs->load("members");
464 $langs->load("users");
465 print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
466 print '<td>';
467 $adh = new Adherent($db);
468 $result = $adh->fetch(0, '', $object->id);
469 if ($result > 0) {
470 $adh->ref = $adh->getFullName($langs);
471 print $adh->getNomUrl(1);
472 } else {
473 print $langs->trans("ThirdpartyNotLinkedToMember");
474 }
475 print '</td>';
476 print "</tr>\n";
477 }
478
479 print '</table>';
480
481
482 print '</div><div class="fichehalfright">';
483
484 $boxstat = '';
485
486 // Nbre max d'elements des petites listes
487 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
488
489 print '<div class="underbanner underbanner-before-box clearboth"></div>';
490 print '<br>';
491
492 // Summary link
493 $boxstat .= '<div class="box divboxtable box-halfright">';
494 $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
495 $boxstat .= '<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
496
497 if (isModEnabled('supplier_proposal')) {
498 // Box proposals
499 $tmp = $object->getOutstandingProposals('supplier');
500 $outstandingOpened = $tmp['opened'];
501 $outstandingTotal = $tmp['total_ht'];
502 $outstandingTotalIncTax = $tmp['total_ttc'];
503 $text = $langs->trans("OverAllSupplierProposals");
504 $link = DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->id;
505 $icon = 'bill';
506 if ($link) {
507 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
508 }
509 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
510 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
511 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
512 $boxstat .= '</div>';
513 if ($link) {
514 $boxstat .= '</a>';
515 }
516 }
517
518 if (isModEnabled("supplier_order")) {
519 // Box proposals
520 $tmp = $object->getOutstandingOrders('supplier');
521 $outstandingOpened = $tmp['opened'];
522 $outstandingTotal = $tmp['total_ht'];
523 $outstandingTotalIncTax = $tmp['total_ttc'];
524 $text = $langs->trans("OverAllOrders");
525 $link = DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id;
526 $icon = 'bill';
527 if ($link) {
528 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
529 }
530 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
531 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
532 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
533 $boxstat .= '</div>';
534 if ($link) {
535 $boxstat .= '</a>';
536 }
537 }
538
539 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
540 $warn = '';
541 $tmp = $object->getOutstandingBills('supplier');
542 $outstandingOpened = $tmp['opened'];
543 $outstandingTotal = $tmp['total_ht'];
544 $outstandingTotalIncTax = $tmp['total_ttc'];
545
546 $text = $langs->trans("OverAllInvoices");
547 $link = DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->id;
548 $icon = 'bill';
549 if ($link) {
550 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
551 }
552 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
553 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
554 $boxstat .= '<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
555 $boxstat .= '</div>';
556 if ($link) {
557 $boxstat .= '</a>';
558 }
559
560 // Box outstanding bill
561 $text = $langs->trans("CurrentOutstandingBill");
562 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
563 $icon = 'bill';
564 if ($link) {
565 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
566 }
567 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
568 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
569 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpened > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
570 $boxstat .= '</div>';
571 if ($link) {
572 $boxstat .= '</a>';
573 }
574
575 $tmp = $object->getOutstandingBills('supplier', 1);
576 $outstandingOpenedLate = $tmp['opened'];
577 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
578 $text = $langs->trans("CurrentOutstandingBillLate");
579 $link = DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
580 $icon = 'bill';
581 if ($link) {
582 $boxstat .= '<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
583 }
584 $boxstat .= '<div class="boxstats" title="'.dol_escape_htmltag($text).'">';
585 $boxstat .= '<span class="boxstatstext">'.img_object("", $icon).' <span>'.$text.'</span></span><br>';
586 $boxstat .= '<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ? ' amountremaintopay' : '').'">'.price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
587 $boxstat .= '</div>';
588 if ($link) {
589 $boxstat .= '</a>';
590 }
591 }
592 }
593
594
595 $parameters = array();
596 $reshook = $hookmanager->executeHooks('addMoreBoxStatsSupplier', $parameters, $object, $action);
597 if (empty($reshook)) {
598 $boxstat .= $hookmanager->resPrint;
599 }
600
601 $boxstat .= '</td></tr>';
602 $boxstat .= '</table>';
603 $boxstat .= '</div>';
604
605 print $boxstat;
606
607
608 $MAXLIST = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
609
610
611 /*
612 * List of products prices
613 */
614 if (isModEnabled("product") || isModEnabled("service")) {
615 $langs->load("products");
616 //Query from product/liste.php
617 $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,';
618 $sql .= ' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
619 $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp';
620 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product";
621 $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
622 $sql .= ' AND pfp.fk_soc = '.((int) $object->id);
623 $sql .= $db->order('pfp.tms', 'desc');
624 $sql .= $db->plimit($MAXLIST);
625
626 $query = $db->query($sql);
627 if (!$query) {
629 }
630
631 $num = $db->num_rows($query);
632
633 print '<div class="div-table-responsive-no-min">';
634 print '<table class="noborder centpercent lastrecordtable">';
635 print '<tr class="liste_titre'.(($num == 0) ? ' nobottom' : '').'">';
636 print '<td colspan="2">'.$langs->trans("ProductsAndServices").'</td><td class="right" colspan="2">';
637 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>';
638 print '</a></td></tr>';
639
640 $return = array();
641 if ($num > 0) {
642 $productstatic = new Product($db);
643
644 while ($objp = $db->fetch_object($query)) {
645 $productstatic->id = $objp->rowid;
646 $productstatic->ref = $objp->ref;
647 $productstatic->label = $objp->label;
648 $productstatic->type = $objp->fk_product_type;
649 $productstatic->entity = $objp->entity;
650 $productstatic->status = $objp->status;
651 $productstatic->status_buy = $objp->status_buy;
652 $productstatic->status_batch = $objp->status_batch;
653
654 print '<tr class="oddeven">';
655 print '<td class="nowrap">';
656 print $productstatic->getNomUrl(1);
657 print '</td>';
658 print '<td>';
659 print dol_escape_htmltag($objp->supplier_ref);
660 print '</td>';
661 print '<td class="tdoverflowmax200">';
662 print dol_trunc(dol_htmlentities($objp->label), 30);
663 print '</td>';
664 //print '<td class="right" class="nowrap">'.dol_print_date($objp->tms, 'day').'</td>';
665 print '<td class="right">';
666 //print (isset($objp->unitprice) ? price($objp->unitprice) : '');
667 if (isset($objp->price)) {
668 print '<span class="amount">'.price($objp->price).'</span>';
669 if ($objp->quantity > 1) {
670 print ' / ';
671 print $objp->quantity;
672 }
673 }
674 print '</td>';
675 print '</tr>';
676 }
677 } else {
678 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoProductPriceDefinedForThisSupplier").'</span></td></tr>';
679 }
680
681 print '</table>';
682 print '</div>';
683 }
684
685
686 /*
687 * Latest supplier proposal
688 */
689 $proposalstatic = new SupplierProposal($db);
690
691 if ($user->hasRight("supplier_proposal", "lire")) {
692 $langs->loadLangs(array("supplier_proposal"));
693
694 $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
695 $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p ";
696 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
697 $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
698 $sql .= " ORDER BY p.date_valid DESC";
699 $sql .= $db->plimit($MAXLIST);
700
701 $resql = $db->query($sql);
702 if ($resql) {
703 $i = 0;
704 $num = $db->num_rows($resql);
705
706 if ($num > 0) {
707 print '<div class="div-table-responsive-no-min">';
708 print '<table class="noborder centpercent lastrecordtable">';
709
710 print '<tr class="liste_titre">';
711 print '<td colspan="3">';
712 print '<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
713 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>';
714 // 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>';
715 print '</tr></table>';
716 print '</td></tr>';
717 }
718
719 while ($i < $num && $i <= $MAXLIST) {
720 $obj = $db->fetch_object($resql);
721
722 print '<tr class="oddeven">';
723 print '<td class="nowrap">';
724 $proposalstatic->id = $obj->rowid;
725 $proposalstatic->ref = $obj->ref;
726 $proposalstatic->total_ht = $obj->total_ht;
727 $proposalstatic->total_tva = $obj->total_tva;
728 $proposalstatic->total_ttc = $obj->total_ttc;
729 print $proposalstatic->getNomUrl(1);
730 print '</td>';
731 print '<td class="center" width="80">';
732 if ($obj->dc) {
733 print dol_print_date($db->jdate($obj->dc), 'day');
734 } else {
735 print "-";
736 }
737 print '</td>';
738 print '<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).'</td>';
739 print '</tr>';
740 $i++;
741 }
742 $db->free($resql);
743
744 if ($num > 0) {
745 print "</table></div>";
746 }
747 } else {
749 }
750 }
751
752 /*
753 * Latest supplier orders
754 */
755 $orderstatic = new CommandeFournisseur($db);
756 $orders2invoice = 0;
757
758 if ($user->hasRight("fournisseur", "commande", "lire")) {
759 // TODO move to DAO class
760 // Check if there are supplier orders billable
761 $sql2 = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
762 $sql2 .= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
763 $sql2 .= ' FROM '.MAIN_DB_PREFIX.'societe as s';
764 $sql2 .= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c';
765 $sql2 .= ' WHERE c.fk_soc = s.rowid';
766 $sql2 .= " AND c.entity IN (".getEntity('commande_fournisseur').")";
767 $sql2 .= ' AND s.rowid = '.((int) $object->id);
768 // Show orders we can bill
769 if (!getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')) {
770 $sql2 .= " AND c.fk_statut IN (".$db->sanitize((string) CommandeFournisseur::STATUS_RECEIVED_COMPLETELY).")"; // Must match filter in htdocs/fourn/commande/list.php
771 } else {
772 // CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.", ".CommandeFournisseur::STATUS_RECEIVED_COMPLETELY
773 $sql2 .= " AND c.fk_statut IN (".$db->sanitize(getDolGlobalString('SUPPLIER_ORDER_TO_INVOICE_STATUS')).")";
774 }
775 $sql2 .= " AND c.billed = 0";
776 // Find order that are not already invoiced
777 // just need to check received status because we have the billed status now
778 //$sql2 .= " AND c.rowid NOT IN (SELECT fk_source FROM " . MAIN_DB_PREFIX . "element_element WHERE targettype='invoice_supplier')";
779 $resql2 = $db->query($sql2);
780 if ($resql2) {
781 $orders2invoice = $db->num_rows($resql2);
782 $db->free($resql2);
783 } else {
784 setEventMessages($db->lasterror(), null, 'errors');
785 }
786
787 // TODO move to DAO class
788 $sql = "SELECT count(p.rowid) as total";
789 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
790 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
791 $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
792 $num = 0;
793 $resql = $db->query($sql);
794 if ($resql) {
795 $object_count = $db->fetch_object($resql);
796 $num = $object_count->total;
797 }
798
799 $sql = "SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
800 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p";
801 $sql .= " WHERE p.fk_soc = ".((int) $object->id);
802 $sql .= " AND p.entity IN (".getEntity('commande_fournisseur').")";
803 $sql .= " ORDER BY p.date_commande DESC";
804 $sql .= $db->plimit($MAXLIST);
805
806 $resql = $db->query($sql);
807 if ($resql) {
808 $i = 0;
809
810 if ($num > 0) {
811 print '<div class="div-table-responsive-no-min">';
812 print '<table class="noborder centpercent lastrecordtable">';
813
814 print '<tr class="liste_titre">';
815 print '<td colspan="4">';
816 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).'</td>';
817 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>';
818 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>';
819 print '</tr></table>';
820 print '</td></tr>';
821 }
822
823 while ($i < $num && $i < $MAXLIST) {
824 $obj = $db->fetch_object($resql);
825
826 $orderstatic->id = $obj->rowid;
827 $orderstatic->ref = $obj->ref;
828 $orderstatic->total_ht = $obj->total_ht;
829 $orderstatic->total_tva = $obj->total_tva;
830 $orderstatic->total_ttc = $obj->total_ttc;
831 $orderstatic->date = $db->jdate($obj->date);
832
833 print '<tr class="oddeven">';
834 print '<td class="nowraponall">';
835 print $orderstatic->getNomUrl(1);
836 print '</td>';
837 print '<td class="center" width="80">';
838 if ($obj->date) {
839 print dol_print_date($orderstatic->date, 'day');
840 }
841 print '</td>';
842 print '<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).'</span></td>';
843 print '<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).'</td>';
844 print '</tr>';
845 $i++;
846 }
847 $db->free($resql);
848
849 if ($num > 0) {
850 print "</table></div>";
851 }
852 } else {
854 }
855 }
856
857
858 /*
859 * Latest invoices templates
860 */
861 if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
862 $sql = 'SELECT f.rowid as id, f.titre as ref';
863 $sql .= ', f.total_ht';
864 $sql .= ', f.total_tva';
865 $sql .= ', f.total_ttc';
866 $sql .= ', f.datec as dc';
867 $sql .= ', f.date_last_gen, f.date_when';
868 $sql .= ', f.frequency';
869 $sql .= ', f.unit_frequency';
870 $sql .= ', f.suspended as suspended';
871 $sql .= ', s.nom, s.rowid as socid';
872 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn_rec as f";
873 $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
874 $sql .= " AND f.entity IN (".getEntity('invoice').")";
875 $sql .= ' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
876 $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
877 $sql .= ' f.suspended, f.date_when,';
878 $sql .= ' s.nom, s.rowid';
879 $sql .= $db->order("f.date_last_gen, f.datec", "DESC");
880
881 $resql = $db->query($sql);
882 if ($resql) {
883 $invoicetemplate = new FactureFournisseurRec($db);
884
885 $num = $db->num_rows($resql);
886 if ($num > 0) {
887 print '<div class="div-table-responsive-no-min">';
888 print '<table class="noborder centpercent lastrecordtable">';
889 print '<tr class="liste_titre">';
890 $colspan = 4;
891 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
892 $colspan++;
893 }
894 print '<td colspan="'.$colspan.'">';
895 print '<table class="centpercent nobordernopadding"><tr>';
896 print '<td>'.$langs->trans("LatestSupplierTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
897 print '<td class="right">';
898 print '<a class="notasortlink" href="'.DOL_URL_ROOT.'/fourn/facture/list-rec.php?socid='.$object->id.'">';
899 print '<span class="hideonsmartphone">'.$langs->trans("AllSupplierTemplateInvoices").'</span><span class="badge marginleftonlyshort">'.$num.'</span></a></td>';
900 print '</tr></table>';
901 print '</td>';
902 print '</tr>';
903 }
904
905 $i = 0;
906 while ($i < $num && $i < $MAXLIST) {
907 $objp = $db->fetch_object($resql);
908
909 $invoicetemplate->id = $objp->id;
910 $invoicetemplate->ref = $objp->ref;
911 $invoicetemplate->suspended = $objp->suspended;
912 $invoicetemplate->frequency = $objp->frequency;
913 $invoicetemplate->unit_frequency = $objp->unit_frequency;
914 $invoicetemplate->total_ht = $objp->total_ht;
915 $invoicetemplate->total_tva = $objp->total_tva;
916 $invoicetemplate->total_ttc = $objp->total_ttc;
917 $invoicetemplate->date_last_gen = $objp->date_last_gen;
918 $invoicetemplate->date_when = $objp->date_when;
919
920 print '<tr class="oddeven">';
921 print '<td class="tdoverflowmax250">';
922 print $invoicetemplate->getNomUrl(1);
923 print '</td>';
924
925 if ($objp->frequency && $objp->date_last_gen > 0) {
926 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
927 } else {
928 if ($objp->dc > 0) {
929 print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day').'</td>';
930 } else {
931 print '<td class="right"><b>!!!</b></td>';
932 }
933 }
934 print '<td class="right nowraponall">';
935 print price($objp->total_ht);
936 print '</td>';
937
938 if (getDolGlobalString('MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES')) {
939 print '<td class="right nowraponall">';
940 print price($objp->total_ttc);
941 print '</td>';
942 }
943
944 print '<td class="nowrap right" style="min-width: 60px">';
945 print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
946 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
947 print '</td>';
948 print "</tr>\n";
949 $i++;
950 }
951 $db->free($resql);
952
953 if ($num > 0) {
954 print "</table>";
955 print '</div>';
956 }
957 } else {
959 }
960 }
961
962
963 /*
964 * Latest supplier invoices
965 */
966
967 $langs->load('bills');
968 $facturestatic = new FactureFournisseur($db);
969
970 if ($user->hasRight('fournisseur', 'facture', 'lire')) {
971 // TODO move to DAO class
972 $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,';
973 $sql .= ' SUM(pf.amount) as am';
974 $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
975 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
976 $sql .= ' WHERE f.fk_soc = '.((int) $object->id);
977 $sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
978 $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';
979 $sql .= ' ORDER BY f.datef DESC';
980 $resql = $db->query($sql);
981 if ($resql) {
982 $i = 0;
983 $num = $db->num_rows($resql);
984 if ($num > 0) {
985 print '<div class="div-table-responsive-no-min">';
986 print '<table class="noborder centpercent lastrecordtable">';
987
988 print '<tr class="liste_titre">';
989 print '<td colspan="4">';
990 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).'</td>';
991 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>';
992 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>';
993 print '</tr></table>';
994 print '</td></tr>';
995 }
996
997 while ($i < min($num, $MAXLIST)) {
998 $obj = $db->fetch_object($resql);
999
1000 $facturestatic->id = $obj->rowid;
1001 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
1002 $facturestatic->ref_supplier = $obj->ref_supplier;
1003 $facturestatic->libelle = $obj->label; // deprecated
1004 $facturestatic->label = $obj->label;
1005 $facturestatic->total_ht = $obj->total_ht;
1006 $facturestatic->total_tva = $obj->total_tva;
1007 $facturestatic->total_ttc = $obj->total_ttc;
1008 $facturestatic->date = $db->jdate($obj->df);
1009
1010 print '<tr class="oddeven">';
1011 print '<td class="tdoverflowmax200">';
1012 print '<span class="nowraponall">'.$facturestatic->getNomUrl(1).'</span>';
1013 print $obj->ref_supplier ? ' - '.$obj->ref_supplier : '';
1014 print($obj->label ? ' - ' : '').dol_trunc($obj->label, 14);
1015 print '</td>';
1016 print '<td class="center nowrap">'.dol_print_date($facturestatic->date, 'day').'</td>';
1017 print '<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).'</span></td>';
1018 print '<td class="right nowrap">';
1019 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
1020 print '</td>';
1021 print '</tr>';
1022 $i++;
1023 }
1024 $db->free($resql);
1025 if ($num > 0) {
1026 print '</table></div>';
1027 }
1028 } else {
1030 }
1031 }
1032
1033 // Allow external modules to add their own shortlist of recent objects
1034 $parameters = array();
1035 $reshook = $hookmanager->executeHooks('addMoreRecentObjects', $parameters, $object, $action);
1036 if ($reshook < 0) {
1037 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1038 } else {
1039 print $hookmanager->resPrint;
1040 }
1041
1042 print '</div></div>';
1043 print '<div class="clearboth"></div>';
1044
1045 print dol_get_fiche_end();
1046
1047
1048 /*
1049 * Action bar
1050 */
1051 print '<div class="tabsAction">';
1052
1053 $parameters = array();
1054 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1055 // modified by hook
1056 if (empty($reshook)) {
1057 if ($object->status != 1) {
1058 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('ThirdPartyIsClosed'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1059 }
1060
1061 if (isModEnabled('supplier_proposal') && $user->hasRight("supplier_proposal", "creer")) {
1062 $langs->load("supplier_proposal");
1063 if ($object->status == 1) {
1064 print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;socid='.$object->id, '');
1065 } else {
1066 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierProposal'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1067 }
1068 }
1069
1070 if ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')) {
1071 $langs->load("orders");
1072 if ($object->status == 1) {
1073 print dolGetButtonAction('', $langs->trans('AddSupplierOrderShort'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;token='.newToken().'&amp;socid='.$object->id, '');
1074 } else {
1075 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddSupplierOrderShort'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1076 }
1077 }
1078
1079 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
1080 if (!empty($orders2invoice) && $orders2invoice > 0) {
1081 if ($object->status == 1) {
1082 // Company is open
1083 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisSupplier'), 'default', DOL_URL_ROOT.'/fourn/commande/list.php?socid='.$object->id.'&amp;search_billed=0&amp;autoselectall=1', '');
1084 } else {
1085 print dolGetButtonAction('', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1086 }
1087 } else {
1088 print dolGetButtonAction($langs->trans("NoOrdersToInvoice").' ('.$langs->trans("WithReceptionFinished").')', $langs->trans('CreateInvoiceForThisCustomer'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1089 }
1090 }
1091
1092 if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer')) {
1093 $langs->load("bills");
1094 if ($object->status == 1) {
1095 print dolGetButtonAction('', $langs->trans('AddBill'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;socid='.$object->id, '');
1096 } else {
1097 print dolGetButtonAction($langs->trans('ThirdPartyIsClosed'), $langs->trans('AddBill'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1098 }
1099 }
1100
1101 // Add action
1102 if (isModEnabled('agenda') && getDolGlobalString('MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
1103 if ($user->hasRight("agenda", "myactions", "create")) {
1104 print dolGetButtonAction('', $langs->trans('AddAction'), 'default', DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;socid='.$object->id, '');
1105 } else {
1106 print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddAction'), 'default', $_SERVER['PHP_SELF'].'#', '', false);
1107 }
1108 }
1109 }
1110
1111 print '</div>';
1112
1113
1114 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) {
1115 print '<br>';
1116 // List of contacts
1117 show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
1118 }
1119
1120 if (getDolGlobalString('MAIN_REPEATTASKONEACHTAB')) {
1121 print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
1122
1123 // List of todo actions
1124 show_actions_todo($conf, $langs, $db, $object);
1125
1126 // List of done actions
1127 show_actions_done($conf, $langs, $db, $object);
1128 }
1129} else {
1131}
1132
1133// End of page
1134llxFooter();
1135$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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.