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