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)) {
224 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
226 $title =
$object->name.
" - ".$langs->trans(
'Supplier');
229 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn page-card');
236 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
238 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
240 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
242 print
'<div class="fichecenter"><div class="fichehalfleft">';
244 print
'<div class="underbanner clearboth"></div>';
245 print
'<table class="border centpercent tableforfield">';
248 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
253 $langs->load(
'compta');
256 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
258 $tmpcheck =
$object->check_codefournisseur();
259 if ($tmpcheck != 0 && $tmpcheck != -5) {
260 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
270 print $form->editfieldkey(
"SupplierAccountancyCodeGeneral",
'supplieraccountancycodegeneral',
length_accountg(
$object->accountancy_code_supplier_general), $object, $user->hasRight(
'societe',
'creer'));
272 if ($action ==
'editsupplieraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
273 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_supplier_general,
'supplieraccountancycodegeneral', 0, 1,
'', 1);
275 if (
$object->accountancy_code_supplier_general > 0) {
277 $accountingaccount->fetch(0,
$object->accountancy_code_supplier_general, 1);
279 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
282 if (
$object->accountancy_code_supplier_general > 0) {
285 $accountingAccountByDefault =
'<span class="opacitymedium">' . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')) .
'</span>';
286 print $accountingAccountByDefault;
295 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
297 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
304 print
'<td class="titlefield">';
305 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
312 if (
$mysoc->useLocalTax(1)) {
313 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
317 if (
$mysoc->useLocalTax(2)) {
318 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
326 print
'<td class="titlefield">';
327 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
329 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
335 print
'<tr><td class="nowrap">';
338 print $form->editfieldkey(
"VATIntra",
'tva_intra',
$object->tva_intra, $object, $user->hasRight(
'societe',
'creer'));
340 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow, $object, $user->hasRight(
'societe',
'creer'),
'string',
$object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped' => 1));
344 $langs->load(
'bills');
347 print
'<table width="100%" class="nobordernopadding"><tr><td>';
348 print $langs->trans(
'PaymentConditions');
350 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
351 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>';
353 print
'</tr></table>';
355 if ($action ==
'editconditions') {
356 $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);
358 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?socid=' .
$object->id, (
string)
$object->cond_reglement_supplier_id,
'none', 0,
'', 1,
$object->deposit_percent);
364 print
'<tr><td class="nowrap">';
365 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
366 print $langs->trans(
'PaymentMode');
368 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
369 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>';
371 print
'</tr></table>';
373 if ($action ==
'editmode') {
374 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
376 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->mode_reglement_supplier_id,
'none');
383 print
'<tr><td class="nowrap">';
384 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
385 print $langs->trans(
'PaymentBankAccount');
387 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
388 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>';
390 print
'</tr></table>';
392 if ($action ==
'editbankaccount') {
393 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
395 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->fk_account,
'none');
402 print
'<tr><td class="nowrap">';
403 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
404 print $langs->trans(
"CustomerRelativeDiscountShort");
405 print
'<td><td class="right">';
406 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
407 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>';
409 print
'</td></tr></table>';
410 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
414 print
'<tr><td class="nowrap">';
415 print
'<table width="100%" class="nobordernopadding">';
416 print
'<tr><td class="nowrap">';
417 print $langs->trans(
"CustomerAbsoluteDiscountShort");
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/remx.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>';
425 $amount_discount =
$object->getAvailableDiscounts(
null,
'', 0, 1);
426 if ($amount_discount < 0) {
429 if ($amount_discount > 0) {
430 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>';
437 print
'<tr class="nowrap">';
439 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount, $object, $user->hasRight(
"societe",
"creer"));
442 $limit_field_type =
'amount';
443 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) :
''));
450 $langs->load(
"categories");
451 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
453 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
458 $parameters = array(
'socid' =>
$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
459 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
463 $langs->load(
"members");
464 $langs->load(
"users");
465 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
468 $result = $adh->fetch(0,
'',
$object->id);
470 $adh->ref = $adh->getFullName($langs);
471 print $adh->getNomUrl(1);
473 print $langs->trans(
"ThirdpartyNotLinkedToMember");
482 print
'</div><div class="fichehalfright">';
489 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
493 $boxstat .=
'<div class="box divboxtable box-halfright">';
494 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
495 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
499 $tmp =
$object->getOutstandingProposals(
'supplier');
500 $outstandingOpened = $tmp[
'opened'];
501 $outstandingTotal = $tmp[
'total_ht'];
502 $outstandingTotalIncTax = $tmp[
'total_ttc'];
503 $text = $langs->trans(
"OverAllSupplierProposals");
504 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id;
507 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
509 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
510 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
511 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
512 $boxstat .=
'</div>';
520 $tmp =
$object->getOutstandingOrders(
'supplier');
521 $outstandingOpened = $tmp[
'opened'];
522 $outstandingTotal = $tmp[
'total_ht'];
523 $outstandingTotalIncTax = $tmp[
'total_ttc'];
524 $text = $langs->trans(
"OverAllOrders");
525 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id;
528 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
530 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
531 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
532 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
533 $boxstat .=
'</div>';
539 if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
541 $tmp =
$object->getOutstandingBills(
'supplier');
542 $outstandingOpened = $tmp[
'opened'];
543 $outstandingTotal = $tmp[
'total_ht'];
544 $outstandingTotalIncTax = $tmp[
'total_ttc'];
546 $text = $langs->trans(
"OverAllInvoices");
547 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->id;
550 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
552 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
553 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
554 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
555 $boxstat .=
'</div>';
561 $text = $langs->trans(
"CurrentOutstandingBill");
562 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
565 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
567 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
568 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
569 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
570 $boxstat .=
'</div>';
575 $tmp =
$object->getOutstandingBills(
'supplier', 1);
576 $outstandingOpenedLate = $tmp[
'opened'];
577 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
578 $text = $langs->trans(
"CurrentOutstandingBillLate");
579 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
582 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
584 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
585 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
586 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
587 $boxstat .=
'</div>';
595 $parameters = array();
596 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters, $object, $action);
597 if (empty($reshook)) {
598 $boxstat .= $hookmanager->resPrint;
601 $boxstat .=
'</td></tr>';
602 $boxstat .=
'</table>';
603 $boxstat .=
'</div>';
615 $langs->load(
"products");
617 $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,';
618 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
619 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
620 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
621 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
622 $sql .=
' AND pfp.fk_soc = '.((int)
$object->id);
623 $sql .=
$db->order(
'pfp.tms',
'desc');
624 $sql .=
$db->plimit($MAXLIST);
626 $query =
$db->query($sql);
631 $num =
$db->num_rows($query);
633 print
'<div class="div-table-responsive-no-min">';
634 print
'<table class="noborder centpercent lastrecordtable">';
635 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
636 print
'<td colspan="2">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right" colspan="2">';
637 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>';
638 print
'</a></td></tr>';
644 while ($objp =
$db->fetch_object($query)) {
645 $productstatic->id = $objp->rowid;
646 $productstatic->ref = $objp->ref;
647 $productstatic->label = $objp->label;
648 $productstatic->type = $objp->fk_product_type;
649 $productstatic->entity = $objp->entity;
650 $productstatic->status = $objp->status;
651 $productstatic->status_buy = $objp->status_buy;
652 $productstatic->status_batch = $objp->status_batch;
654 print
'<tr class="oddeven">';
655 print
'<td class="nowrap">';
656 print $productstatic->getNomUrl(1);
661 print
'<td class="tdoverflowmax200">';
665 print
'<td class="right">';
667 if (isset($objp->price)) {
668 print
'<span class="amount">'.price($objp->price).
'</span>';
669 if ($objp->quantity > 1) {
671 print $objp->quantity;
678 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"NoProductPriceDefinedForThisSupplier").
'</span></td></tr>';
691 if ($user->hasRight(
"supplier_proposal",
"lire")) {
692 $langs->loadLangs(array(
"supplier_proposal"));
694 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
695 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
696 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
697 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
698 $sql .=
" ORDER BY p.date_valid DESC";
699 $sql .=
$db->plimit($MAXLIST);
701 $resql =
$db->query($sql);
704 $num =
$db->num_rows($resql);
707 print
'<div class="div-table-responsive-no-min">';
708 print
'<table class="noborder centpercent lastrecordtable">';
710 print
'<tr class="liste_titre">';
711 print
'<td colspan="3">';
712 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
713 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllPriceRequests").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></td>';
715 print
'</tr></table>';
719 while ($i < $num && $i <= $MAXLIST) {
720 $obj =
$db->fetch_object($resql);
722 print
'<tr class="oddeven">';
723 print
'<td class="nowrap">';
724 $proposalstatic->id = $obj->rowid;
725 $proposalstatic->ref = $obj->ref;
726 $proposalstatic->total_ht = $obj->total_ht;
727 $proposalstatic->total_tva = $obj->total_tva;
728 $proposalstatic->total_ttc = $obj->total_ttc;
729 print $proposalstatic->getNomUrl(1);
731 print
'<td class="center" width="80">';
738 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
745 print
"</table></div>";
758 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
761 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
762 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
763 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
764 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
765 $sql2 .=
' WHERE c.fk_soc = s.rowid';
766 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
767 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
773 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize(
getDolGlobalString(
'SUPPLIER_ORDER_TO_INVOICE_STATUS')).
")";
775 $sql2 .=
" AND c.billed = 0";
779 $resql2 =
$db->query($sql2);
781 $orders2invoice =
$db->num_rows($resql2);
788 $sql =
"SELECT count(p.rowid) as total";
789 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
790 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
791 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
793 $resql =
$db->query($sql);
795 $object_count =
$db->fetch_object($resql);
796 $num = $object_count->total;
799 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
800 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
801 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
802 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
803 $sql .=
" ORDER BY p.date_commande DESC";
804 $sql .=
$db->plimit($MAXLIST);
806 $resql =
$db->query($sql);
811 print
'<div class="div-table-responsive-no-min">';
812 print
'<table class="noborder centpercent lastrecordtable">';
814 print
'<tr class="liste_titre">';
815 print
'<td colspan="4">';
816 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
817 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>';
818 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>';
819 print
'</tr></table>';
823 while ($i < $num && $i < $MAXLIST) {
824 $obj =
$db->fetch_object($resql);
826 $orderstatic->id = $obj->rowid;
827 $orderstatic->ref = $obj->ref;
828 $orderstatic->total_ht = $obj->total_ht;
829 $orderstatic->total_tva = $obj->total_tva;
830 $orderstatic->total_ttc = $obj->total_ttc;
831 $orderstatic->date =
$db->jdate($obj->date);
833 print
'<tr class="oddeven">';
834 print
'<td class="nowraponall">';
835 print $orderstatic->getNomUrl(1);
837 print
'<td class="center" width="80">';
842 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
843 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
850 print
"</table></div>";
861 if (
isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
862 $sql =
'SELECT f.rowid as id, f.titre as ref';
863 $sql .=
', f.total_ht';
864 $sql .=
', f.total_tva';
865 $sql .=
', f.total_ttc';
866 $sql .=
', f.datec as dc';
867 $sql .=
', f.date_last_gen, f.date_when';
868 $sql .=
', f.frequency';
869 $sql .=
', f.unit_frequency';
870 $sql .=
', f.suspended as suspended';
871 $sql .=
', s.nom, s.rowid as socid';
872 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_fourn_rec as f";
873 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
874 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
875 $sql .=
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
876 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
877 $sql .=
' f.suspended, f.date_when,';
878 $sql .=
' s.nom, s.rowid';
879 $sql .=
$db->order(
"f.date_last_gen, f.datec",
"DESC");
881 $resql =
$db->query($sql);
885 $num =
$db->num_rows($resql);
887 print
'<div class="div-table-responsive-no-min">';
888 print
'<table class="noborder centpercent lastrecordtable">';
889 print
'<tr class="liste_titre">';
894 print
'<td colspan="'.$colspan.
'">';
895 print
'<table class="centpercent nobordernopadding"><tr>';
896 print
'<td>'.$langs->trans(
"LatestSupplierTemplateInvoices", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
897 print
'<td class="right">';
898 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list-rec.php?socid='.
$object->id.
'">';
899 print
'<span class="hideonsmartphone">'.$langs->trans(
"AllSupplierTemplateInvoices").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
900 print
'</tr></table>';
906 while ($i < $num && $i < $MAXLIST) {
907 $objp =
$db->fetch_object($resql);
909 $invoicetemplate->id = $objp->id;
910 $invoicetemplate->ref = $objp->ref;
911 $invoicetemplate->suspended = $objp->suspended;
912 $invoicetemplate->frequency = $objp->frequency;
913 $invoicetemplate->unit_frequency = $objp->unit_frequency;
914 $invoicetemplate->total_ht = $objp->total_ht;
915 $invoicetemplate->total_tva = $objp->total_tva;
916 $invoicetemplate->total_ttc = $objp->total_ttc;
917 $invoicetemplate->date_last_gen = $objp->date_last_gen;
918 $invoicetemplate->date_when = $objp->date_when;
920 print
'<tr class="oddeven">';
921 print
'<td class="tdoverflowmax250">';
922 print $invoicetemplate->getNomUrl(1);
925 if ($objp->frequency && $objp->date_last_gen > 0) {
926 print
'<td class="right" width="80px">'.dol_print_date(
$db->jdate($objp->date_last_gen),
'day').
'</td>';
929 print
'<td class="right" width="80px">'.dol_print_date(
$db->jdate($objp->dc),
'day').
'</td>';
931 print
'<td class="right"><b>!!!</b></td>';
934 print
'<td class="right nowraponall">';
935 print
price($objp->total_ht);
939 print
'<td class="right nowraponall">';
940 print
price($objp->total_ttc);
944 print
'<td class="nowrap right" style="min-width: 60px">';
945 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
946 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
967 $langs->load(
'bills');
970 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
972 $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,';
973 $sql .=
' SUM(pf.amount) as am';
974 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
975 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
976 $sql .=
' WHERE f.fk_soc = '.((int)
$object->id);
977 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
978 $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';
979 $sql .=
' ORDER BY f.datef DESC';
980 $resql =
$db->query($sql);
983 $num =
$db->num_rows($resql);
985 print
'<div class="div-table-responsive-no-min">';
986 print
'<table class="noborder centpercent lastrecordtable">';
988 print
'<tr class="liste_titre">';
989 print
'<td colspan="4">';
990 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
991 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>';
992 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>';
993 print
'</tr></table>';
997 while ($i < min($num, $MAXLIST)) {
998 $obj =
$db->fetch_object($resql);
1000 $facturestatic->id = $obj->rowid;
1001 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
1002 $facturestatic->ref_supplier = $obj->ref_supplier;
1003 $facturestatic->libelle = $obj->label;
1004 $facturestatic->label = $obj->label;
1005 $facturestatic->total_ht = $obj->total_ht;
1006 $facturestatic->total_tva = $obj->total_tva;
1007 $facturestatic->total_ttc = $obj->total_ttc;
1008 $facturestatic->date =
$db->jdate($obj->df);
1010 print
'<tr class="oddeven">';
1011 print
'<td class="tdoverflowmax200">';
1012 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
1013 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
1014 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
1016 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
1017 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
1018 print
'<td class="right nowrap">';
1019 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
1026 print
'</table></div>';
1034 $parameters = array();
1035 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
1039 print $hookmanager->resPrint;
1042 print
'</div></div>';
1043 print
'<div class="clearboth"></div>';
1051 print
'<div class="tabsAction">';
1053 $parameters = array();
1054 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1056 if (empty($reshook)) {
1058 print dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1061 if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
1062 $langs->load(
"supplier_proposal");
1064 print dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.
$object->id,
'');
1066 print dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1070 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
1071 $langs->load(
"orders");
1073 print dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.newToken().
'&socid='.
$object->id,
'');
1075 print dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1079 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1080 if (!empty($orders2invoice) && $orders2invoice > 0) {
1083 print dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1',
'');
1085 print dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1088 print dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1092 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1093 $langs->load(
"bills");
1095 print dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.
$object->id,
'');
1097 print dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1103 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
1104 print dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id,
'');
1106 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
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, $morecssdiv='')
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.
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.
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($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_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.
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.
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.