35require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
57 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
61$langs->loadLangs(array(
'accountancy',
'companies',
'suppliers',
'products',
'bills',
'orders',
'commercial'));
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'alpha');
67if ($user->isExternalUser()) {
68 $id = $user->isExternalUser();
72$hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
74$result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
79$extrafields->fetch_name_optionals_label(
$object->table_element);
81$permissiontoadd = $user->hasRight(
'societe',
'creer');
82$permissiontoeditextra = $permissiontoadd;
83if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
85 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
89$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
92 if (!(
$object->fournisseur > 0) || !$user->hasRight(
"fournisseur",
"lire")) {
102$parameters = array(
'id' => $id);
103$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
108if (empty($reshook)) {
114 if ($action ==
'setsupplieraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
116 $object->accountancy_code_supplier_general =
GETPOST(
"supplieraccountancycodegeneral");
120 $_GET[
'action'] =
'editsupplieraccountancycode';
125 if ($action ==
'setsupplieraccountancycode' && $user->hasRight(
'societe',
'creer')) {
127 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
131 $action =
'editsupplieraccountancycode';
135 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
144 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
146 $result =
$object->setPaymentTerms(
GETPOSTINT(
'cond_reglement_supplier_id'),
GETPOSTINT(
'cond_reglement_supplier_id_deposit_percent'));
152 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
161 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
170 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
179 if ($action ==
'update_extras' && $permissiontoeditextra) {
184 $attribute_name =
GETPOST(
'attribute',
'aZ09');
187 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
193 $result =
$object->updateExtraField($attribute_name,
'COMPANY_MODIFY');
201 $action =
'edit_extras';
214if ($id > 0 && empty(
$object->id)) {
225 $langs->load(
"errors");
226 llxHeader(
'', $langs->trans(
"ThirdParty").
' - '.$langs->trans(
'Supplier'));
227 print
'<div class="warning">'.$langs->trans(
"ErrorRecordNotFound").
' ('.$langs->trans(
"Supplier").
')';
228 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?socid='.((int) $id).
'">'.$langs->trans(
"ThirdParty").
'</a>';
237 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
239 $title =
$object->name.
" - ".$langs->trans(
'Supplier');
242 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn page-card');
249 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
251 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
253 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
255 print
'<div class="fichecenter"><div class="fichehalfleft">';
257 print
'<div class="underbanner clearboth"></div>';
258 print
'<table class="border centpercent tableforfield">';
261 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
266 $langs->load(
'compta');
269 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
271 $tmpcheck =
$object->check_codefournisseur();
272 if ($tmpcheck != 0 && $tmpcheck != -5) {
273 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
283 print $form->editfieldkey(
"SupplierAccountancyCodeGeneral",
'supplieraccountancycodegeneral',
length_accountg(
$object->accountancy_code_supplier_general), $object, $user->hasRight(
'societe',
'creer'));
285 if ($action ==
'editsupplieraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
286 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_supplier_general,
'supplieraccountancycodegeneral', 0, 1,
'', 1);
288 if (
$object->accountancy_code_supplier_general > 0) {
290 $accountingaccount->fetch(0,
$object->accountancy_code_supplier_general, 1);
292 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
295 if (
$object->accountancy_code_supplier_general > 0) {
298 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')) .
'</span>';
299 print $accountingAccountByDefault;
308 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
310 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
317 print
'<td class="titlefield">';
318 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
325 if (
$mysoc->useLocalTax(1)) {
326 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
330 if (
$mysoc->useLocalTax(2)) {
331 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
339 print
'<td class="titlefield">';
340 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc').
'<br>'.$langs->trans(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE_DESC'));
342 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
348 print
'<tr><td class="nowrap">';
351 print $form->editfieldkey(
"VATIntra",
'tva_intra',
$object->tva_intra, $object, $user->hasRight(
'societe',
'creer'));
353 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow, $object, $user->hasRight(
'societe',
'creer'),
'string',
$object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped' => 1));
357 $langs->load(
'bills');
360 print
'<table width="100%" class="nobordernopadding"><tr><td>';
361 print $langs->trans(
'PaymentConditions');
363 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
364 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>';
366 print
'</tr></table>';
368 if ($action ==
'editconditions') {
369 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?socid=' .
$object->id, (
string)
$object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1,
'', 1,
$object->deposit_percent);
371 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?socid=' .
$object->id, (
string)
$object->cond_reglement_supplier_id,
'none', 0,
'', 1,
$object->deposit_percent);
377 print
'<tr><td class="nowrap">';
378 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
379 print $langs->trans(
'PaymentMode');
381 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
382 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>';
384 print
'</tr></table>';
386 if ($action ==
'editmode') {
387 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
389 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_supplier_id,
'none');
396 print
'<tr><td class="nowrap">';
397 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
398 print $langs->trans(
'PaymentBankAccount');
400 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
401 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>';
403 print
'</tr></table>';
405 if ($action ==
'editbankaccount') {
406 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
408 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
415 print
'<tr><td class="nowrap">';
416 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
417 print $langs->trans(
"CustomerRelativeDiscountShort");
418 print
'<td><td class="right">';
419 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
420 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>';
422 print
'</td></tr></table>';
423 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
427 print
'<tr><td class="nowrap">';
428 print
'<table width="100%" class="nobordernopadding">';
429 print
'<tr><td class="nowrap">';
430 print $langs->trans(
"CustomerAbsoluteDiscountShort");
431 print
'<td><td class="right">';
432 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
433 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>';
435 print
'</td></tr></table>';
438 $amount_discount =
$object->getAvailableDiscounts(
null,
'', 0, 1);
439 if ($amount_discount < 0) {
442 if ($amount_discount > 0) {
443 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>';
450 print
'<tr class="nowrap">';
452 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount, $object, $user->hasRight(
"societe",
"creer"));
455 $limit_field_type =
'amount';
456 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) :
''));
463 $langs->load(
"categories");
464 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
466 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
471 $parameters = array(
'socid' =>
$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
476 $langs->load(
"members");
477 $langs->load(
"users");
478 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
481 $result = $adh->fetch(0,
'',
$object->id);
483 $adh->ref = $adh->getFullName($langs);
484 print $adh->getNomUrl(1);
486 print $langs->trans(
"ThirdpartyNotLinkedToMember");
495 print
'</div><div class="fichehalfright">';
502 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
506 $boxstat .=
'<div class="box divboxtable box-halfright">';
507 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
508 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
512 $tmp =
$object->getOutstandingProposals(
'supplier');
513 $outstandingOpened = $tmp[
'opened'];
514 $outstandingTotal = $tmp[
'total_ht'];
515 $outstandingTotalIncTax = $tmp[
'total_ttc'];
516 $text = $langs->trans(
"OverAllSupplierProposals");
517 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id;
520 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
522 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
523 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
524 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
525 $boxstat .=
'</div>';
533 $tmp =
$object->getOutstandingOrders(
'supplier');
534 $outstandingOpened = $tmp[
'opened'];
535 $outstandingTotal = $tmp[
'total_ht'];
536 $outstandingTotalIncTax = $tmp[
'total_ttc'];
537 $text = $langs->trans(
"OverAllOrders");
538 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id;
541 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
543 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
544 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
545 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
546 $boxstat .=
'</div>';
552 if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
554 $tmp =
$object->getOutstandingBills(
'supplier');
555 $outstandingOpened = $tmp[
'opened'];
556 $outstandingTotal = $tmp[
'total_ht'];
557 $outstandingTotalIncTax = $tmp[
'total_ttc'];
559 $text = $langs->trans(
"OverAllInvoices");
560 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->id;
563 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
565 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
566 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
567 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
568 $boxstat .=
'</div>';
574 $text = $langs->trans(
"CurrentOutstandingBill");
575 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
578 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
580 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
581 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
582 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
583 $boxstat .=
'</div>';
588 $tmp =
$object->getOutstandingBills(
'supplier', 1);
589 $outstandingOpenedLate = $tmp[
'opened'];
590 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
591 $text = $langs->trans(
"CurrentOutstandingBillLate");
592 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
595 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
597 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
598 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
599 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
600 $boxstat .=
'</div>';
608 $parameters = array();
609 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters, $object, $action);
610 if (empty($reshook)) {
611 $boxstat .= $hookmanager->resPrint;
614 $boxstat .=
'</td></tr>';
615 $boxstat .=
'</table>';
616 $boxstat .=
'</div>';
628 $langs->load(
"products");
630 $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,';
631 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
632 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
633 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
634 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
635 $sql .=
' AND pfp.fk_soc = '.((int)
$object->id);
636 $sql .=
$db->order(
'pfp.tms',
'desc');
637 $sql .=
$db->plimit($MAXLIST);
639 $query =
$db->query($sql);
644 $num =
$db->num_rows($query);
646 print
'<div class="div-table-responsive-no-min">';
647 print
'<table class="noborder centpercent lastrecordtable">';
648 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
649 print
'<td colspan="2">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right" colspan="2">';
650 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>';
651 print
'</a></td></tr>';
657 while ($objp =
$db->fetch_object($query)) {
658 $productstatic->id = $objp->rowid;
659 $productstatic->ref = $objp->ref;
660 $productstatic->label = $objp->label;
661 $productstatic->type = $objp->fk_product_type;
662 $productstatic->entity = $objp->entity;
663 $productstatic->status = $objp->status;
664 $productstatic->status_buy = $objp->status_buy;
665 $productstatic->status_batch = $objp->status_batch;
667 print
'<tr class="oddeven">';
668 print
'<td class="nowrap">';
669 print $productstatic->getNomUrl(1);
674 print
'<td class="tdoverflowmax200">';
678 print
'<td class="right">';
680 if (isset($objp->price)) {
681 print
'<span class="amount">'.price($objp->price).
'</span>';
682 if ($objp->quantity > 1) {
684 print $objp->quantity;
691 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"NoProductPriceDefinedForThisSupplier").
'</span></td></tr>';
704 if ($user->hasRight(
"supplier_proposal",
"lire")) {
705 $langs->loadLangs(array(
"supplier_proposal"));
707 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
708 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
709 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
710 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
711 $sql .=
" ORDER BY p.date_valid DESC";
712 $sql .=
$db->plimit($MAXLIST);
714 $resql =
$db->query($sql);
717 $num =
$db->num_rows($resql);
720 print
'<div class="div-table-responsive-no-min">';
721 print
'<table class="noborder centpercent lastrecordtable">';
723 print
'<tr class="liste_titre">';
724 print
'<td colspan="3">';
725 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
726 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>';
728 print
'</tr></table>';
732 while ($i < $num && $i <= $MAXLIST) {
733 $obj =
$db->fetch_object($resql);
735 print
'<tr class="oddeven">';
736 print
'<td class="nowrap">';
737 $proposalstatic->id = $obj->rowid;
738 $proposalstatic->ref = $obj->ref;
739 $proposalstatic->total_ht = $obj->total_ht;
740 $proposalstatic->total_tva = $obj->total_tva;
741 $proposalstatic->total_ttc = $obj->total_ttc;
742 print $proposalstatic->getNomUrl(1);
744 print
'<td class="center" width="80">';
751 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
758 print
"</table></div>";
771 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
774 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
775 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
776 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
777 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
778 $sql2 .=
' WHERE c.fk_soc = s.rowid';
779 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
780 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
786 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize(
getDolGlobalString(
'SUPPLIER_ORDER_TO_INVOICE_STATUS')).
")";
788 $sql2 .=
" AND c.billed = 0";
792 $resql2 =
$db->query($sql2);
794 $orders2invoice =
$db->num_rows($resql2);
801 $sql =
"SELECT count(p.rowid) as total";
802 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
803 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
804 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
806 $resql =
$db->query($sql);
808 $object_count =
$db->fetch_object($resql);
809 $num = $object_count->total;
812 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
813 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
814 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
815 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
816 $sql .=
" ORDER BY p.date_commande DESC";
817 $sql .=
$db->plimit($MAXLIST);
819 $resql =
$db->query($sql);
824 print
'<div class="div-table-responsive-no-min">';
825 print
'<table class="noborder centpercent lastrecordtable">';
827 print
'<tr class="liste_titre">';
828 print
'<td colspan="4">';
829 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
830 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>';
831 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>';
832 print
'</tr></table>';
836 while ($i < $num && $i < $MAXLIST) {
837 $obj =
$db->fetch_object($resql);
839 $orderstatic->id = $obj->rowid;
840 $orderstatic->ref = $obj->ref;
841 $orderstatic->total_ht = $obj->total_ht;
842 $orderstatic->total_tva = $obj->total_tva;
843 $orderstatic->total_ttc = $obj->total_ttc;
844 $orderstatic->date =
$db->jdate($obj->date);
846 print
'<tr class="oddeven">';
847 print
'<td class="nowraponall">';
848 print $orderstatic->getNomUrl(1);
850 print
'<td class="center" width="80">';
855 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
856 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
863 print
"</table></div>";
874 if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
875 $sql =
'SELECT f.rowid as id, f.titre as ref';
876 $sql .=
', f.total_ht';
877 $sql .=
', f.total_tva';
878 $sql .=
', f.total_ttc';
879 $sql .=
', f.datec as dc';
880 $sql .=
', f.date_last_gen, f.date_when';
881 $sql .=
', f.frequency';
882 $sql .=
', f.unit_frequency';
883 $sql .=
', f.suspended as suspended';
884 $sql .=
', s.nom, s.rowid as socid';
885 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_fourn_rec as f";
886 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
887 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
888 $sql .=
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
889 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
890 $sql .=
' f.suspended, f.date_when,';
891 $sql .=
' s.nom, s.rowid';
892 $sql .=
$db->order(
"f.date_last_gen, f.datec",
"DESC");
894 $resql =
$db->query($sql);
898 $num =
$db->num_rows($resql);
900 print
'<div class="div-table-responsive-no-min">';
901 print
'<table class="noborder centpercent lastrecordtable">';
902 print
'<tr class="liste_titre">';
907 print
'<td colspan="'.$colspan.
'">';
908 print
'<table class="centpercent nobordernopadding"><tr>';
909 print
'<td>'.$langs->trans(
"LatestSupplierTemplateInvoices", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
910 print
'<td class="right">';
911 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list-rec.php?socid='.
$object->id.
'">';
912 print
'<span class="hideonsmartphone">'.$langs->trans(
"AllSupplierTemplateInvoices").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
913 print
'</tr></table>';
919 while ($i < $num && $i < $MAXLIST) {
920 $objp =
$db->fetch_object($resql);
922 $invoicetemplate->id = $objp->id;
923 $invoicetemplate->ref = $objp->ref;
924 $invoicetemplate->suspended = $objp->suspended;
925 $invoicetemplate->frequency = $objp->frequency;
926 $invoicetemplate->unit_frequency = $objp->unit_frequency;
927 $invoicetemplate->total_ht = $objp->total_ht;
928 $invoicetemplate->total_tva = $objp->total_tva;
929 $invoicetemplate->total_ttc = $objp->total_ttc;
930 $invoicetemplate->date_last_gen = $objp->date_last_gen;
931 $invoicetemplate->date_when = $objp->date_when;
933 print
'<tr class="oddeven">';
934 print
'<td class="tdoverflowmax250">';
935 print $invoicetemplate->getNomUrl(1);
938 if ($objp->frequency && $objp->date_last_gen > 0) {
939 print
'<td class="right" width="80px">'.dol_print_date(
$db->jdate($objp->date_last_gen),
'day').
'</td>';
942 print
'<td class="right" width="80px">'.dol_print_date(
$db->jdate($objp->dc),
'day').
'</td>';
944 print
'<td class="right"><b>!!!</b></td>';
947 print
'<td class="right nowraponall">';
948 print
price($objp->total_ht);
952 print
'<td class="right nowraponall">';
953 print
price($objp->total_ttc);
957 print
'<td class="nowrap right" style="min-width: 60px">';
958 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
959 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
980 $langs->load(
'bills');
983 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
985 $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,';
986 $sql .=
' SUM(pf.amount) as am';
987 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
988 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
989 $sql .=
' WHERE f.fk_soc = '.((int)
$object->id);
990 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
991 $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';
992 $sql .=
' ORDER BY f.datef DESC';
993 $resql =
$db->query($sql);
996 $num =
$db->num_rows($resql);
998 print
'<div class="div-table-responsive-no-min">';
999 print
'<table class="noborder centpercent lastrecordtable">';
1001 print
'<tr class="liste_titre">';
1002 print
'<td colspan="4">';
1003 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
1004 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>';
1005 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>';
1006 print
'</tr></table>';
1010 while ($i < min($num, $MAXLIST)) {
1011 $obj =
$db->fetch_object($resql);
1013 $facturestatic->id = $obj->rowid;
1014 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
1015 $facturestatic->ref_supplier = $obj->ref_supplier;
1016 $facturestatic->libelle = $obj->label;
1017 $facturestatic->label = $obj->label;
1018 $facturestatic->total_ht = $obj->total_ht;
1019 $facturestatic->total_tva = $obj->total_tva;
1020 $facturestatic->total_ttc = $obj->total_ttc;
1021 $facturestatic->date =
$db->jdate($obj->df);
1023 print
'<tr class="oddeven">';
1024 print
'<td class="tdoverflowmax200">';
1025 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
1026 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
1027 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
1029 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
1030 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
1031 print
'<td class="right nowrap">';
1032 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
1039 print
'</table></div>';
1047 $parameters = array();
1048 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1052 print $hookmanager->resPrint;
1055 print
'</div></div>';
1056 print
'<div class="clearboth"></div>';
1064 print
'<div class="tabsAction">';
1066 $parameters = array();
1067 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1069 if (empty($reshook)) {
1070 if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
1071 $langs->load(
"supplier_proposal");
1073 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.
$object->id,
'');
1075 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1079 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
1080 $langs->load(
"orders");
1082 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&socid='.
$object->id,
'');
1084 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1088 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1089 if (!empty($orders2invoice) && $orders2invoice > 0) {
1092 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1',
'');
1094 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1098 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1100 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1105 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1106 $langs->load(
"bills");
1108 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.
$object->id,
'');
1110 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1116 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
1117 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id,
'');
1119 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
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 suppliers invoices.
Class to manage invoice templates.
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, $subtabs='')
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.