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