35require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
43if (isModEnabled(
'member')) {
44 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
46if (isModEnabled(
'category')) {
47 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
49if (isModEnabled(
'accounting')) {
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
64$langs->loadLangs(array(
73$action =
GETPOST(
'action',
'aZ09');
74$cancel =
GETPOST(
'cancel',
'alpha');
83$hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
85$result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
91$extrafields->fetch_name_optionals_label(
$object->table_element);
96$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
99 if (!(
$object->fournisseur > 0) || !$user->hasRight(
"fournisseur",
"lire")) {
109$parameters = array(
'id' => $id);
110$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
115if (empty($reshook)) {
121 if ($action ==
'setsupplieraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
123 $object->accountancy_code_supplier_general =
GETPOST(
"supplieraccountancycodegeneral");
127 $_GET[
'action'] =
'editsupplieraccountancycode';
132 if ($action ==
'setsupplieraccountancycode' && $user->hasRight(
'societe',
'creer')) {
134 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
138 $action =
'editsupplieraccountancycode';
142 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
151 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
159 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
168 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
177 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
186 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
192 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
199 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
207 $action =
'edit_extras';
217$contactstatic =
new Contact($db);
218$form =
new Form($db);
220if ($id > 0 && empty(
$object->id)) {
230 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
232 $title =
$object->name.
" - ".$langs->trans(
'Supplier');
235 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn page-card');
242 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
244 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
246 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
248 print
'<div class="fichecenter"><div class="fichehalfleft">';
250 print
'<div class="underbanner clearboth"></div>';
251 print
'<table class="border centpercent tableforfield">';
254 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
259 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
264 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
266 $tmpcheck =
$object->check_codefournisseur();
267 if ($tmpcheck != 0 && $tmpcheck != -5) {
268 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
273 if (isModEnabled(
'accounting')) {
278 print $form->editfieldkey(
"SupplierAccountancyCodeGeneral",
'supplieraccountancycodegeneral',
length_accountg(
$object->accountancy_code_supplier_general),
$object, $user->hasRight(
'societe',
'creer'));
280 if ($action ==
'editsupplieraccountancycodegeneral' && $user->hasRight(
'societe',
'creer')) {
281 print $formaccounting->formAccountingAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->accountancy_code_supplier_general,
'supplieraccountancycodegeneral', 0, 1,
'', 1);
284 $accountingaccount->fetch(0,
$object->accountancy_code_supplier_general, 1);
286 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
288 $accountingAccountByDefault =
" (" . $langs->trans(
"AccountingAccountByDefaultShort") .
": " .
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')) .
")";
289 print (
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER') ? $accountingAccountByDefault :
'');
294 $langs->load(
'compta');
297 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
299 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
306 print
'<td class="titlefield">';
307 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
314 if ($mysoc->useLocalTax(1)) {
315 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
319 if ($mysoc->useLocalTax(2)) {
320 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
328 print
'<td class="titlefield">';
329 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
331 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
337 print
'<tr><td class="nowrap">';
340 print $form->editfieldkey(
"VATIntra",
'tva_intra',
$object->tva_intra,
$object, $user->hasRight(
'societe',
'creer'));
342 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow,
$object, $user->hasRight(
'societe',
'creer'),
'string',
$object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped' => 1));
346 $langs->load(
'bills');
347 $form =
new Form($db);
349 print
'<table width="100%" class="nobordernopadding"><tr><td>';
350 print $langs->trans(
'PaymentConditions');
352 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
353 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
355 print
'</tr></table>';
357 if ($action ==
'editconditions') {
358 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
360 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'none');
366 print
'<tr><td class="nowrap">';
367 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
368 print $langs->trans(
'PaymentMode');
370 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
371 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
373 print
'</tr></table>';
375 if ($action ==
'editmode') {
376 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
378 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'none');
383 if (isModEnabled(
"bank")) {
385 print
'<tr><td class="nowrap">';
386 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
387 print $langs->trans(
'PaymentBankAccount');
389 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
390 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
392 print
'</tr></table>';
394 if ($action ==
'editbankaccount') {
395 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'fk_account', 1);
397 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'none');
404 print
'<tr><td class="nowrap">';
405 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
406 print $langs->trans(
"CustomerRelativeDiscountShort");
407 print
'<td><td class="right">';
408 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
409 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
411 print
'</td></tr></table>';
412 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
416 print
'<tr><td class="nowrap">';
417 print
'<table width="100%" class="nobordernopadding">';
418 print
'<tr><td class="nowrap">';
419 print $langs->trans(
"CustomerAbsoluteDiscountShort");
420 print
'<td><td class="right">';
421 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
422 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
424 print
'</td></tr></table>';
427 $amount_discount =
$object->getAvailableDiscounts(
'',
'', 0, 1);
428 if ($amount_discount < 0) {
431 if ($amount_discount > 0) {
432 print
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.
$object->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?socid='.
$object->id).
'&action=create&token='.
newToken().
'">'.
price($amount_discount, 1, $langs, 1, -1, -1,
$conf->currency).
'</a>';
438 if (isModEnabled(
"supplier_order") &&
getDolGlobalString(
'ORDER_MANAGE_MIN_AMOUNT')) {
439 print
'<tr class="nowrap">';
441 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount,
$object, $user->hasRight(
"societe",
"creer"));
443 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
444 print $form->editfieldval(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount,
$object, $user->hasRight(
"societe",
"creer"), $limit_field_type, (
$object->supplier_order_min_amount !=
'' ?
price(
$object->supplier_order_min_amount) :
''));
450 if (isModEnabled(
'category')) {
451 $langs->load(
"categories");
452 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
454 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
459 $parameters = array(
'socid' =>
$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
460 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
463 if (isModEnabled(
'member')) {
464 $langs->load(
"members");
465 $langs->load(
"users");
466 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
469 $result = $adh->fetch(
'',
'',
$object->id);
471 $adh->ref = $adh->getFullName($langs);
472 print $adh->getNomUrl(1);
474 print $langs->trans(
"ThirdpartyNotLinkedToMember");
483 print
'</div><div class="fichehalfright">';
490 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
494 $boxstat .=
'<div class="box divboxtable box-halfright">';
495 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
496 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
498 if (isModEnabled(
'supplier_proposal')) {
500 $tmp =
$object->getOutstandingProposals(
'supplier');
501 $outstandingOpened = $tmp[
'opened'];
502 $outstandingTotal = $tmp[
'total_ht'];
503 $outstandingTotalIncTax = $tmp[
'total_ttc'];
504 $text = $langs->trans(
"OverAllSupplierProposals");
505 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id;
508 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
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>';
519 if (isModEnabled(
"supplier_order")) {
521 $tmp =
$object->getOutstandingOrders(
'supplier');
522 $outstandingOpened = $tmp[
'opened'];
523 $outstandingTotal = $tmp[
'total_ht'];
524 $outstandingTotalIncTax = $tmp[
'total_ttc'];
525 $text = $langs->trans(
"OverAllOrders");
526 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id;
529 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
531 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
532 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
533 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
534 $boxstat .=
'</div>';
540 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
542 $tmp =
$object->getOutstandingBills(
'supplier');
543 $outstandingOpened = $tmp[
'opened'];
544 $outstandingTotal = $tmp[
'total_ht'];
545 $outstandingTotalIncTax = $tmp[
'total_ttc'];
547 $text = $langs->trans(
"OverAllInvoices");
548 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->id;
551 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
553 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
554 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
555 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
556 $boxstat .=
'</div>';
562 $text = $langs->trans(
"CurrentOutstandingBill");
563 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
566 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
568 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
569 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
570 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
571 $boxstat .=
'</div>';
576 $tmp =
$object->getOutstandingBills(
'supplier', 1);
577 $outstandingOpenedLate = $tmp[
'opened'];
578 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
579 $text = $langs->trans(
"CurrentOutstandingBillLate");
580 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
583 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
585 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
586 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
587 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1,
$conf->currency).$warn.
'</span>';
588 $boxstat .=
'</div>';
596 $parameters = array();
597 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters,
$object, $action);
598 if (empty($reshook)) {
599 $boxstat .= $hookmanager->resPrint;
602 $boxstat .=
'</td></tr>';
603 $boxstat .=
'</table>';
604 $boxstat .=
'</div>';
615 if (isModEnabled(
"product") || isModEnabled(
"service")) {
616 $langs->load(
"products");
618 $sql =
'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity, p.tosell as status, p.tobuy as status_buy, p.tobatch as status_batch,';
619 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
620 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
621 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
622 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
623 $sql .=
' AND pfp.fk_soc = '.((int)
$object->id);
624 $sql .= $db->order(
'pfp.tms',
'desc');
625 $sql .= $db->plimit($MAXLIST);
627 $query = $db->query($sql);
632 $num = $db->num_rows($query);
634 print
'<div class="div-table-responsive-no-min">';
635 print
'<table class="noborder centpercent lastrecordtable">';
636 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
637 print
'<td colspan="2">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right" colspan="2">';
638 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/product/list.php?fourn_id='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllProductReferencesOfSupplier").
'</span><span class="badge marginleftonlyshort">'.
$object->nbOfProductRefs().
'</span>';
639 print
'</a></td></tr>';
643 $productstatic =
new Product($db);
645 while ($objp = $db->fetch_object($query)) {
646 $productstatic->id = $objp->rowid;
647 $productstatic->ref = $objp->ref;
648 $productstatic->label = $objp->label;
649 $productstatic->type = $objp->fk_product_type;
650 $productstatic->entity = $objp->entity;
651 $productstatic->status = $objp->status;
652 $productstatic->status_buy = $objp->status_buy;
653 $productstatic->status_batch = $objp->status_batch;
655 print
'<tr class="oddeven">';
656 print
'<td class="nowrap">';
657 print $productstatic->getNomUrl(1);
662 print
'<td class="tdoverflowmax200">';
666 print
'<td class="right">';
668 if (isset($objp->price)) {
669 print
'<span class="amount">'.price($objp->price).
'</span>';
670 if ($objp->quantity > 1) {
672 print $objp->quantity;
679 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"NoProductPriceDefinedForThisSupplier").
'</span></td></tr>';
692 if ($user->hasRight(
"supplier_proposal",
"lire")) {
693 $langs->loadLangs(array(
"supplier_proposal"));
695 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
696 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
697 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
698 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
699 $sql .=
" ORDER BY p.date_valid DESC";
700 $sql .= $db->plimit($MAXLIST);
702 $resql = $db->query($sql);
705 $num = $db->num_rows($resql);
708 print
'<div class="div-table-responsive-no-min">';
709 print
'<table class="noborder centpercent lastrecordtable">';
711 print
'<tr class="liste_titre">';
712 print
'<td colspan="3">';
713 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
714 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllPriceRequests").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></td>';
716 print
'</tr></table>';
720 while ($i < $num && $i <= $MAXLIST) {
721 $obj = $db->fetch_object($resql);
723 print
'<tr class="oddeven">';
724 print
'<td class="nowrap">';
725 $proposalstatic->id = $obj->rowid;
726 $proposalstatic->ref = $obj->ref;
727 $proposalstatic->total_ht = $obj->total_ht;
728 $proposalstatic->total_tva = $obj->total_tva;
729 $proposalstatic->total_ttc = $obj->total_ttc;
730 print $proposalstatic->getNomUrl(1);
732 print
'<td class="center" width="80">';
739 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
746 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').
")";
792 $resql = $db->query($sql);
794 $object_count = $db->fetch_object($resql);
795 $num = $object_count->total;
798 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
799 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
800 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
801 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
802 $sql .=
" ORDER BY p.date_commande DESC";
803 $sql .= $db->plimit($MAXLIST);
805 $resql = $db->query($sql);
810 print
'<div class="div-table-responsive-no-min">';
811 print
'<table class="noborder centpercent lastrecordtable">';
813 print
'<tr class="liste_titre">';
814 print
'<td colspan="4">';
815 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
816 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
"AllOrders").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></td>';
817 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/commande/stats/index.php?mode=supplier&socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
818 print
'</tr></table>';
822 while ($i < $num && $i < $MAXLIST) {
823 $obj = $db->fetch_object($resql);
825 $orderstatic->id = $obj->rowid;
826 $orderstatic->ref = $obj->ref;
827 $orderstatic->total_ht = $obj->total_ht;
828 $orderstatic->total_tva = $obj->total_tva;
829 $orderstatic->total_ttc = $obj->total_ttc;
830 $orderstatic->date = $db->jdate($obj->date);
832 print
'<tr class="oddeven">';
833 print
'<td class="nowraponall">';
834 print $orderstatic->getNomUrl(1);
836 print
'<td class="center" width="80">';
841 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
842 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
849 print
"</table></div>";
860 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
861 $sql =
'SELECT f.rowid as id, f.titre as ref';
862 $sql .=
', f.total_ht';
863 $sql .=
', f.total_tva';
864 $sql .=
', f.total_ttc';
865 $sql .=
', f.datec as dc';
866 $sql .=
', f.date_last_gen, f.date_when';
867 $sql .=
', f.frequency';
868 $sql .=
', f.unit_frequency';
869 $sql .=
', f.suspended as suspended';
870 $sql .=
', s.nom, s.rowid as socid';
871 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_fourn_rec as f";
872 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
873 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
874 $sql .=
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
875 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
876 $sql .=
' f.suspended, f.date_when,';
877 $sql .=
' s.nom, s.rowid';
878 $sql .= $db->order(
"f.date_last_gen, f.datec",
"DESC");
880 $resql = $db->query($sql);
884 $num = $db->num_rows($resql);
886 print
'<div class="div-table-responsive-no-min">';
887 print
'<table class="noborder centpercent lastrecordtable">';
888 print
'<tr class="liste_titre">';
893 print
'<td colspan="'.$colspan.
'">';
894 print
'<table class="centpercent nobordernopadding"><tr>';
895 print
'<td>'.$langs->trans(
"LatestSupplierTemplateInvoices", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
896 print
'<td class="right">';
897 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list-rec.php?socid='.
$object->id.
'">';
898 print
'<span class="hideonsmartphone">'.$langs->trans(
"AllSupplierTemplateInvoices").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
899 print
'</tr></table>';
905 while ($i < $num && $i < $MAXLIST) {
906 $objp = $db->fetch_object($resql);
908 $invoicetemplate->id = $objp->id;
909 $invoicetemplate->ref = $objp->ref;
910 $invoicetemplate->suspended = $objp->suspended;
911 $invoicetemplate->frequency = $objp->frequency;
912 $invoicetemplate->unit_frequency = $objp->unit_frequency;
913 $invoicetemplate->total_ht = $objp->total_ht;
914 $invoicetemplate->total_tva = $objp->total_tva;
915 $invoicetemplate->total_ttc = $objp->total_ttc;
916 $invoicetemplate->date_last_gen = $objp->date_last_gen;
917 $invoicetemplate->date_when = $objp->date_when;
919 print
'<tr class="oddeven">';
920 print
'<td class="tdoverflowmax250">';
921 print $invoicetemplate->getNomUrl(1);
924 if ($objp->frequency && $objp->date_last_gen > 0) {
925 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
928 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
930 print
'<td class="right"><b>!!!</b></td>';
933 print
'<td class="right nowraponall">';
934 print
price($objp->total_ht);
938 print
'<td class="right nowraponall">';
939 print
price($objp->total_ttc);
943 print
'<td class="nowrap right" style="min-width: 60px">';
944 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
945 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
966 $langs->load(
'bills');
969 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
971 $sql =
'SELECT f.rowid, f.libelle as label, f.ref, f.ref_supplier, f.fk_statut, f.datef as df, f.total_ht, f.total_tva, f.total_ttc, f.paye,';
972 $sql .=
' SUM(pf.amount) as am';
973 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
974 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
975 $sql .=
' WHERE f.fk_soc = '.((int)
$object->id);
976 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
977 $sql .=
' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye';
978 $sql .=
' ORDER BY f.datef DESC';
979 $resql = $db->query($sql);
982 $num = $db->num_rows($resql);
984 print
'<div class="div-table-responsive-no-min">';
985 print
'<table class="noborder centpercent lastrecordtable">';
987 print
'<tr class="liste_titre">';
988 print
'<td colspan="4">';
989 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
990 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->id.
'"><span class="hideonsmartphone">'.$langs->trans(
'AllBills').
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></td>';
991 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/compta/facture/stats/index.php?mode=supplier&socid='.
$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
992 print
'</tr></table>';
996 while ($i < min($num, $MAXLIST)) {
997 $obj = $db->fetch_object($resql);
999 $facturestatic->id = $obj->rowid;
1000 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
1001 $facturestatic->ref_supplier = $obj->ref_supplier;
1002 $facturestatic->libelle = $obj->label;
1003 $facturestatic->label = $obj->label;
1004 $facturestatic->total_ht = $obj->total_ht;
1005 $facturestatic->total_tva = $obj->total_tva;
1006 $facturestatic->total_ttc = $obj->total_ttc;
1007 $facturestatic->date = $db->jdate($obj->df);
1009 print
'<tr class="oddeven">';
1010 print
'<td class="tdoverflowmax200">';
1011 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
1012 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
1013 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
1015 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
1016 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
1017 print
'<td class="right nowrap">';
1018 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
1025 print
'</table></div>';
1033 $parameters = array();
1034 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
1038 print $hookmanager->resPrint;
1041 print
'</div></div>';
1042 print
'<div class="clearboth"></div>';
1050 print
'<div class="tabsAction">';
1052 $parameters = array();
1053 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1055 if (empty($reshook)) {
1057 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1060 if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
1061 $langs->load(
"supplier_proposal");
1063 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.
$object->id,
'');
1065 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1069 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
1070 $langs->load(
"orders");
1072 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.
$object->id,
'');
1074 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1078 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1079 if (!empty($orders2invoice) && $orders2invoice > 0) {
1082 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1',
'');
1084 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1087 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1091 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1092 $langs->load(
"bills");
1094 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.
$object->id,
'');
1096 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1102 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
1103 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id,
'');
1105 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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)
Return array of tabs to used on pages for third parties cards.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.