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