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