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