32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
39 if (!empty($conf->adherent->enabled)) {
40 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
42 if (!empty($conf->categorie->enabled)) {
43 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
47 $langs->loadLangs(array(
56 $action =
GETPOST(
'action',
'aZ09');
57 $cancel =
GETPOST(
'cancel',
'alpha');
64 $result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
70 $extrafields->fetch_name_optionals_label($object->table_element);
73 $hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
76 $result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
78 if ($object->id > 0) {
79 if (!($object->fournisseur > 0) || empty($user->rights->fournisseur->lire)) {
90 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
95 if (empty($reshook)) {
100 if ($action ==
'setsupplieraccountancycode') {
101 $result = $object->fetch($id);
102 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
103 $result = $object->update($object->id, $user, 1, 0, 1);
109 if ($action ==
'setconditions' && $user->rights->societe->creer) {
111 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
117 if ($action ==
'setmode' && $user->rights->societe->creer) {
119 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
126 if ($action ==
'setsupplier_order_min_amount') {
128 $object->supplier_order_min_amount =
price2num(
GETPOST(
'supplier_order_min_amount',
'alpha'));
129 $result = $object->update($object->id, $user);
135 if ($action ==
'update_extras') {
141 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
148 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
156 $action =
'edit_extras';
166 $contactstatic =
new Contact($db);
169 if ($id > 0 && empty($object->id)) {
171 $res = $object->fetch($id);
172 if ($object->id <= 0) {
178 if ($object->id > 0) {
179 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
180 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
181 $title = $object->name.
" - ".$langs->trans(
'Supplier');
191 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
193 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
195 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
197 print
'<div class="fichecenter"><div class="fichehalfleft">';
199 print
'<div class="underbanner clearboth"></div>';
200 print
'<table class="border centpercent tableforfield">';
203 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
204 print $object->getTypeUrl(1);
207 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
208 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
211 if ($object->fournisseur) {
213 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
215 $tmpcheck = $object->check_codefournisseur();
216 if ($tmpcheck != 0 && $tmpcheck != -5) {
217 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
222 $langs->load(
'compta');
225 print
$form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);
227 print
$form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);
234 print
'<td class="titlefield">';
235 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
237 print
yn($object->tva_assuj);
242 if ($mysoc->useLocalTax(1)) {
243 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
244 print
yn($object->localtax1_assuj);
247 if ($mysoc->useLocalTax(2)) {
248 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
249 print
yn($object->localtax2_assuj);
254 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
259 $langs->load(
'bills');
262 print
'<table width="100%" class="nobordernopadding"><tr><td>';
263 print $langs->trans(
'PaymentConditions');
265 if (($action !=
'editconditions') && $user->rights->societe->creer) {
266 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>';
268 print
'</tr></table>';
270 if ($action ==
'editconditions') {
271 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
273 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'none');
279 print
'<tr><td class="nowrap">';
280 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
281 print $langs->trans(
'PaymentMode');
283 if (($action !=
'editmode') && $user->rights->societe->creer) {
284 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>';
286 print
'</tr></table>';
288 if ($action ==
'editmode') {
289 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
291 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'none');
297 print
'<tr><td class="nowrap">';
298 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
299 print $langs->trans(
"CustomerRelativeDiscountShort");
300 print
'<td><td class="right">';
301 if ($user->rights->societe->creer && !$user->socid > 0) {
302 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>';
304 print
'</td></tr></table>';
305 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
309 print
'<tr><td class="nowrap">';
310 print
'<table width="100%" class="nobordernopadding">';
311 print
'<tr><td class="nowrap">';
312 print $langs->trans(
"CustomerAbsoluteDiscountShort");
313 print
'<td><td class="right">';
314 if ($user->rights->societe->creer && !$user->socid > 0) {
315 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>';
317 print
'</td></tr></table>';
320 $amount_discount = $object->getAvailableDiscounts(
'',
'', 0, 1);
321 if ($amount_discount < 0) {
324 if ($amount_discount > 0) {
325 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>';
331 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
332 print
'<tr class="nowrap">';
334 print
$form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer);
336 $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ?
'numeric' :
'amount';
337 print
$form->editfieldval(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->supplier_order_min_amount !=
'' ?
price($object->supplier_order_min_amount) :
''));
343 if (!empty($conf->categorie->enabled)) {
344 $langs->load(
"categories");
345 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
347 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
352 $parameters = array(
'socid'=>$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
353 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
356 if (!empty($conf->adherent->enabled)) {
357 $langs->load(
"members");
358 $langs->load(
"users");
359 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
362 $result = $adh->fetch(
'',
'', $object->id);
364 $adh->ref = $adh->getFullName($langs);
365 print $adh->getNomUrl(1);
367 print $langs->trans(
"ThirdpartyNotLinkedToMember");
376 print
'</div><div class="fichehalfright">';
381 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
383 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
386 $boxstat .=
'<div class="box box-halfright">';
387 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
388 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
390 if (!empty($conf->supplier_proposal->enabled)) {
392 $tmp = $object->getOutstandingProposals(
'supplier');
393 $outstandingOpened = $tmp[
'opened'];
394 $outstandingTotal = $tmp[
'total_ht'];
395 $outstandingTotalIncTax = $tmp[
'total_ttc'];
396 $text = $langs->trans(
"OverAllSupplierProposals");
397 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
400 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
402 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
403 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
404 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
405 $boxstat .=
'</div>';
411 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
413 $tmp = $object->getOutstandingOrders(
'supplier');
414 $outstandingOpened = $tmp[
'opened'];
415 $outstandingTotal = $tmp[
'total_ht'];
416 $outstandingTotalIncTax = $tmp[
'total_ttc'];
417 $text = $langs->trans(
"OverAllOrders");
418 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
421 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
423 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
424 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
425 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
426 $boxstat .=
'</div>';
432 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
434 $tmp = $object->getOutstandingBills(
'supplier');
435 $outstandingOpened = $tmp[
'opened'];
436 $outstandingTotal = $tmp[
'total_ht'];
437 $outstandingTotalIncTax = $tmp[
'total_ttc'];
439 $text = $langs->trans(
"OverAllInvoices");
440 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
443 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
445 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
446 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
447 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
448 $boxstat .=
'</div>';
454 $text = $langs->trans(
"CurrentOutstandingBill");
455 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
458 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
460 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
461 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
462 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
463 $boxstat .=
'</div>';
468 $tmp = $object->getOutstandingBills(
'supplier', 1);
469 $outstandingOpenedLate = $tmp[
'opened'];
470 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
471 $text = $langs->trans(
"CurrentOutstandingBillLate");
472 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
475 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
477 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
478 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
479 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
480 $boxstat .=
'</div>';
489 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier',
$parameters, $object, $action);
490 if (empty($reshook)) {
491 $boxstat .= $hookmanager->resPrint;
494 $boxstat .=
'</td></tr>';
495 $boxstat .=
'</table>';
496 $boxstat .=
'</div>';
501 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
517 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
518 $langs->load(
"products");
520 $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,';
521 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
522 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
523 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
524 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
525 $sql .=
' AND pfp.fk_soc = '.((int) $object->id);
526 $sql .= $db->order(
'pfp.tms',
'desc');
527 $sql .= $db->plimit($MAXLIST);
529 $query = $db->query($sql);
534 $num = $db->num_rows($query);
536 print
'<div class="div-table-responsive-no-min">';
537 print
'<table class="noborder centpercent lastrecordtable">';
538 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
539 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
540 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>';
541 print
'</a></td></tr>';
545 $productstatic =
new Product($db);
547 while ($objp = $db->fetch_object($query)) {
548 $productstatic->id = $objp->rowid;
549 $productstatic->ref = $objp->ref;
550 $productstatic->label = $objp->label;
551 $productstatic->type = $objp->fk_product_type;
552 $productstatic->entity = $objp->entity;
553 $productstatic->status = $objp->status;
554 $productstatic->status_buy = $objp->status_buy;
555 $productstatic->status_batch = $objp->status_batch;
557 print
'<tr class="oddeven">';
558 print
'<td class="nowrap">';
559 print $productstatic->getNomUrl(1);
564 print
'<td class="maxwidthonsmartphone">';
568 print
'<td class="right">';
570 if (isset($objp->price)) {
571 print
'<span class="amount">'.price($objp->price).
'</span>';
572 if ($objp->quantity > 1) {
574 print $objp->quantity;
592 if (!empty($user->rights->supplier_proposal->lire)) {
593 $langs->loadLangs(array(
"supplier_proposal"));
595 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
596 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
597 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
598 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
599 $sql .=
" ORDER BY p.date_valid DESC";
600 $sql .= $db->plimit($MAXLIST);
602 $resql = $db->query($sql);
605 $num = $db->num_rows(
$resql);
608 print
'<div class="div-table-responsive-no-min">';
609 print
'<table class="noborder centpercent lastrecordtable">';
611 print
'<tr class="liste_titre">';
612 print
'<td colspan="3">';
613 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
614 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>';
615 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
616 print
'</tr></table>';
620 while ($i < $num && $i <= $MAXLIST) {
621 $obj = $db->fetch_object(
$resql);
623 print
'<tr class="oddeven">';
624 print
'<td class="nowrap">';
625 $proposalstatic->id = $obj->rowid;
626 $proposalstatic->ref = $obj->ref;
627 $proposalstatic->total_ht = $obj->total_ht;
628 $proposalstatic->total_tva = $obj->total_tva;
629 $proposalstatic->total_ttc = $obj->total_ttc;
630 print $proposalstatic->getNomUrl(1);
632 print
'<td class="center" width="80">';
639 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
646 print
"</table></div>";
658 if ($user->rights->fournisseur->commande->lire) {
661 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
662 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
663 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
664 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
665 $sql2 .=
' WHERE c.fk_soc = s.rowid';
666 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
667 $sql2 .=
' AND s.rowid = '.((int) $object->id);
669 if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
673 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).
")";
675 $sql2 .=
" AND c.billed = 0";
679 $resql2 = $db->query($sql2);
681 $orders2invoice = $db->num_rows($resql2);
688 $sql =
"SELECT count(p.rowid) as total";
689 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
690 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
691 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
692 $resql = $db->query($sql);
694 $object_count = $db->fetch_object(
$resql);
695 $num = $object_count->total;
698 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
699 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
700 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
701 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
702 $sql .=
" ORDER BY p.date_commande DESC";
703 $sql .= $db->plimit($MAXLIST);
705 $resql = $db->query($sql);
710 print
'<div class="div-table-responsive-no-min">';
711 print
'<table class="noborder centpercent lastrecordtable">';
713 print
'<tr class="liste_titre">';
714 print
'<td colspan="4">';
715 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
716 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>';
717 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>';
718 print
'</tr></table>';
722 while ($i < $num && $i < $MAXLIST) {
723 $obj = $db->fetch_object(
$resql);
725 $orderstatic->id = $obj->rowid;
726 $orderstatic->ref = $obj->ref;
727 $orderstatic->total_ht = $obj->total_ht;
728 $orderstatic->total_tva = $obj->total_tva;
729 $orderstatic->total_ttc = $obj->total_ttc;
730 $orderstatic->date = $db->jdate($obj->date);
732 print
'<tr class="oddeven">';
733 print
'<td class="nowraponall">';
734 print $orderstatic->getNomUrl(1);
736 print
'<td class="center" width="80">';
741 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
742 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
749 print
"</table></div>";
760 $langs->load(
'bills');
763 if ($user->rights->fournisseur->facture->lire) {
765 $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,';
766 $sql .=
' SUM(pf.amount) as am';
767 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
768 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
769 $sql .=
' WHERE f.fk_soc = '.((int) $object->id);
770 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
771 $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';
772 $sql .=
' ORDER BY f.datef DESC';
773 $resql = $db->query($sql);
776 $num = $db->num_rows(
$resql);
778 print
'<div class="div-table-responsive-no-min">';
779 print
'<table class="noborder centpercent lastrecordtable">';
781 print
'<tr class="liste_titre">';
782 print
'<td colspan="4">';
783 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
784 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>';
785 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>';
786 print
'</tr></table>';
790 while ($i < min($num, $MAXLIST)) {
791 $obj = $db->fetch_object(
$resql);
793 $facturestatic->id = $obj->rowid;
794 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
795 $facturestatic->ref_supplier = $obj->ref_supplier;
796 $facturestatic->libelle = $obj->label;
797 $facturestatic->label = $obj->label;
798 $facturestatic->total_ht = $obj->total_ht;
799 $facturestatic->total_tva = $obj->total_tva;
800 $facturestatic->total_ttc = $obj->total_ttc;
801 $facturestatic->date = $db->jdate($obj->df);
803 print
'<tr class="oddeven">';
804 print
'<td class="tdoverflowmax200">';
805 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
806 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
807 print ($obj->label ?
' - ' :
'').dol_trunc($obj->label, 14);
809 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
810 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
811 print
'<td class="right nowrap">';
812 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
819 print
'</table></div>';
826 print
'</div></div>';
827 print
'<div style="clear:both"></div>';
835 print
'<div class="tabsAction">';
838 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
840 if (empty($reshook)) {
841 if ($object->status != 1) {
842 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
845 if (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->creer)) {
846 $langs->load(
"supplier_proposal");
847 if ($object->status == 1) {
848 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id,
'');
850 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposalGR'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
854 if ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer) {
855 $langs->load(
"orders");
856 if ($object->status == 1) {
857 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.$object->id,
'');
859 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
863 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
864 if (!empty($orders2invoice) && $orders2invoice > 0) {
865 if ($object->status == 1) {
867 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplierGR'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1',
'');
869 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
872 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
876 if ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer) {
877 $langs->load(
"bills");
878 if ($object->status == 1) {
879 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id,
'');
881 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
886 if (
isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
887 if ($user->rights->agenda->myactions->create) {
888 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id,
'');
890 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
898 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
901 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
904 if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {