31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
38 if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
39 if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42 $langs->loadLangs(array(
51 $action =
GETPOST(
'action',
'aZ09');
52 $cancelbutton =
GETPOST(
'cancel',
'alpha');
56 if ($user->socid) $id = $user->socid;
57 $result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
63 $extrafields->fetch_name_optionals_label($object->table_element);
66 $hookmanager->initHooks(array(
'suppliercard',
'globalcard'));
69 $result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
71 if ($object->id > 0) {
72 if (!($object->fournisseur > 0) || empty($user->rights->fournisseur->lire)) {
82 $parameters = array(
'id'=>$id);
83 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
84 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
93 if ($action ==
'setsupplieraccountancycode')
95 $result = $object->fetch($id);
96 $object->code_compta_fournisseur = $_POST[
"supplieraccountancycode"];
97 $result = $object->update($object->id, $user, 1, 0, 1);
98 if ($result < 0)
setEventMessages($object->error, $object->errors,
'errors');
101 if ($action ==
'setconditions' && $user->rights->societe->creer)
104 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
108 if ($action ==
'setmode' && $user->rights->societe->creer)
111 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
116 if ($action ==
'setsupplier_order_min_amount')
119 $object->supplier_order_min_amount =
price2num(
GETPOST(
'supplier_order_min_amount',
'alpha'));
120 $result = $object->update($object->id, $user);
121 if ($result < 0)
setEventMessages($object->error, $object->errors,
'errors');
124 if ($action ==
'update_extras') {
130 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
132 if ($ret < 0) $error++;
136 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
137 if ($result < 0) $error++;
140 if ($error) $action =
'edit_extras';
149 $contactstatic =
new Contact($db);
150 $form =
new Form($db);
152 if ($id > 0 && empty($object->id))
155 $res = $object->fetch($id);
161 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
162 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.
" - ".$langs->trans(
'Supplier');
173 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
175 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
177 print '<div class="fichecenter"><div class="fichehalfleft">';
179 print '<div class="underbanner clearboth"></div>';
180 print '<table width="100%" class="border">';
182 if (!empty($conf->global->SOCIETE_USEPREFIX))
184 print '<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
187 if ($object->fournisseur)
190 print '<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
191 print $object->code_fournisseur;
192 $tmpcheck = $object->check_codefournisseur();
193 if ($tmpcheck != 0 && $tmpcheck != -5) {
194 print ' <font class="error">('.$langs->trans(
"WrongSupplierCode").
')</font>';
199 $langs->load(
'compta');
202 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);
204 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->rights->societe->creer);
211 print '<td class="titlefield">';
212 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
219 if ($mysoc->useLocalTax(1))
221 print '<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
222 print yn($object->localtax1_assuj);
225 if ($mysoc->useLocalTax(2))
227 print '<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
228 print yn($object->localtax2_assuj);
233 print '<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
234 print $object->tva_intra;
238 $langs->load(
'bills');
239 $form =
new Form($db);
241 print '<table width="100%" class="nobordernopadding"><tr><td>';
242 print $langs->trans(
'PaymentConditions');
244 if (($action !=
'editconditions') && $user->rights->societe->creer)
print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&socid='.$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
245 print '</tr></table>';
247 if ($action ==
'editconditions')
249 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', -1, 1);
251 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'none');
257 print
'<tr><td class="nowrap">';
258 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
259 print $langs->trans(
'PaymentMode');
261 if (($action !=
'editmode') && $user->rights->societe->creer) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&socid='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
262 print
'</tr></table>';
264 if ($action ==
'editmode')
266 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
268 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'none');
274 print
'<tr><td class="nowrap">';
275 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
276 print $langs->trans(
"CustomerRelativeDiscountShort");
277 print
'<td><td class="right">';
278 if ($user->rights->societe->creer && !$user->socid > 0)
280 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
282 print
'</td></tr></table>';
283 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
287 print
'<tr><td class="nowrap">';
288 print
'<table width="100%" class="nobordernopadding">';
289 print
'<tr><td class="nowrap">';
290 print $langs->trans(
"CustomerAbsoluteDiscountShort");
291 print
'<td><td class="right">';
292 if ($user->rights->societe->creer && !$user->socid > 0)
294 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$object->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id).
'">'.
img_edit($langs->trans(
"Modify")).
'</a>';
296 print
'</td></tr></table>';
299 $amount_discount = $object->getAvailableDiscounts(
'',
'', 0, 1);
301 if ($amount_discount > 0) print
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.$object->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id).
'">'.
price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).
'</a>';
306 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
308 print
'<tr class="nowrap">';
310 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer);
312 $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ?
'numeric' :
'amount';
313 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) :
''));
319 if (!empty($conf->categorie->enabled))
321 $langs->load(
"categories");
322 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
324 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
329 $parameters = array(
'socid'=>$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
330 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
333 if (!empty($conf->adherent->enabled))
335 $langs->load(
"members");
336 $langs->load(
"users");
337 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
340 $result = $adh->fetch(
'',
'', $object->id);
343 $adh->ref = $adh->getFullName($langs);
344 print $adh->getNomUrl(1);
346 print $langs->trans(
"ThirdpartyNotLinkedToMember");
355 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
360 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
362 print
'<div class="underbanner clearboth"></div>';
365 $boxstat .=
'<div class="box">';
366 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
367 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
369 if ($conf->supplier_proposal->enabled)
372 $tmp = $object->getOutstandingProposals(
'supplier');
373 $outstandingOpened = $tmp[
'opened'];
374 $outstandingTotal = $tmp[
'total_ht'];
375 $outstandingTotalIncTax = $tmp[
'total_ttc'];
376 $text = $langs->trans(
"OverAllSupplierProposals");
377 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
379 if ($link) $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
380 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
381 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
382 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
383 $boxstat .=
'</div>';
384 if ($link) $boxstat .=
'</a>';
387 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
390 $tmp = $object->getOutstandingOrders(
'supplier');
391 $outstandingOpened = $tmp[
'opened'];
392 $outstandingTotal = $tmp[
'total_ht'];
393 $outstandingTotalIncTax = $tmp[
'total_ttc'];
394 $text = $langs->trans(
"OverAllOrders");
395 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
397 if ($link) $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
398 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
399 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
400 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
401 $boxstat .=
'</div>';
402 if ($link) $boxstat .=
'</a>';
405 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
407 $tmp = $object->getOutstandingBills(
'supplier');
408 $outstandingOpened = $tmp[
'opened'];
409 $outstandingTotal = $tmp[
'total_ht'];
410 $outstandingTotalIncTax = $tmp[
'total_ttc'];
412 $text = $langs->trans(
"OverAllInvoices");
413 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
415 if ($link) $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
416 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
417 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
418 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
419 $boxstat .=
'</div>';
420 if ($link) $boxstat .=
'</a>';
423 $text = $langs->trans(
"CurrentOutstandingBill");
424 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
426 if ($link) $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
427 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
428 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
429 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
430 $boxstat .=
'</div>';
431 if ($link) $boxstat .=
'</a>';
433 $tmp = $object->getOutstandingBills(
'supplier', 1);
434 $outstandingOpenedLate = $tmp[
'opened'];
435 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
436 $text = $langs->trans(
"CurrentOutstandingBillLate");
437 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
439 if ($link) $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
440 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
441 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
442 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
443 $boxstat .=
'</div>';
444 if ($link) $boxstat .=
'</a>';
448 $boxstat .=
'</td></tr>';
449 $boxstat .=
'</table>';
450 $boxstat .=
'</div>';
455 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
471 if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
473 $langs->load(
"products");
475 $sql =
'SELECT p.rowid, p.ref, p.label, p.fk_product_type, p.entity,';
476 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
477 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
478 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
479 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
480 $sql .=
' AND pfp.fk_soc = '.$object->id;
481 $sql .= $db->order(
'pfp.tms',
'desc');
482 $sql .= $db->plimit($MAXLIST);
484 $query = $db->query($sql);
487 $num = $db->num_rows($query);
489 print
'<table class="noborder centpercent lastrecordtable">';
490 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
491 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
492 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/product/list.php?fourn_id='.$object->id.
'">'.$langs->trans(
"AllProductReferencesOfSupplier").
'<span class="badge marginleftonlyshort">'.$object->nbOfProductRefs().
'</span>';
493 print
'</a></td></tr>';
498 $productstatic =
new Product($db);
500 while ($objp = $db->fetch_object($query))
502 $productstatic->id = $objp->rowid;
503 $productstatic->ref = $objp->ref;
504 $productstatic->label = $objp->label;
505 $productstatic->type = $objp->fk_product_type;
506 $productstatic->entity = $objp->entity;
508 print
'<tr class="oddeven">';
509 print
'<td class="nowrap">';
510 print $productstatic->getNomUrl(1);
513 print $objp->supplier_ref;
515 print
'<td class="maxwidthonsmartphone">';
519 print
'<td class="right">';
521 if (isset($objp->price))
523 print
price($objp->price);
524 if ($objp->quantity > 1)
527 print $objp->quantity;
544 if ($user->rights->supplier_proposal->lire)
546 $langs->loadLangs(array(
"supplier_proposal"));
548 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc";
549 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
550 $sql .=
" WHERE p.fk_soc =".$object->id;
551 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
552 $sql .=
" ORDER BY p.date_valid DESC";
553 $sql .=
" ".$db->plimit($MAXLIST);
555 $resql = $db->query($sql);
559 $num = $db->num_rows(
$resql);
563 print
'<table class="noborder centpercent lastrecordtable">';
565 print
'<tr class="liste_titre">';
566 print
'<td colspan="3">';
567 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
568 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id.
'">'.$langs->trans(
"AllPriceRequests").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td>';
569 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>';
570 print
'</tr></table>';
574 while ($i < $num && $i <= $MAXLIST)
576 $obj = $db->fetch_object(
$resql);
578 print
'<tr class="oddeven">';
579 print
'<td class="nowrap">';
580 $proposalstatic->id = $obj->rowid;
581 $proposalstatic->ref = $obj->ref;
582 $proposalstatic->total_ht = $obj->total_ht;
583 $proposalstatic->total_tva = $obj->total_tva;
584 $proposalstatic->total_ttc = $obj->total_ttc;
585 print $proposalstatic->getNomUrl(1);
587 print
'<td class="center" width="80">';
595 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
601 if ($num > 0) print
"</table>";
612 if ($user->rights->fournisseur->commande->lire)
616 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
617 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
618 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
619 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
620 $sql2 .=
' WHERE c.fk_soc = s.rowid';
621 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
622 $sql2 .=
' AND s.rowid = '.$object->id;
624 if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS))
629 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($db->escape($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)).
")";
631 $sql2 .=
" AND c.billed = 0";
635 $resql2 = $db->query($sql2);
637 $orders2invoice = $db->num_rows($resql2);
644 $sql =
"SELECT count(p.rowid) as total";
645 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
646 $sql .=
" WHERE p.fk_soc =".$object->id;
647 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
648 $resql = $db->query($sql);
651 $object_count = $db->fetch_object(
$resql);
652 $num = $object_count->total;
655 $sql =
"SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc";
656 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
657 $sql .=
" WHERE p.fk_soc =".$object->id;
658 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
659 $sql .=
" ORDER BY p.date_commande DESC";
660 $sql .=
" ".$db->plimit($MAXLIST);
661 $resql = $db->query($sql);
668 print
'<table class="noborder centpercent lastrecordtable">';
670 print
'<tr class="liste_titre">';
671 print
'<td colspan="3">';
672 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
673 print
'<td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'">'.$langs->trans(
"AllOrders").
'<span class="badge marginleftonlyshort">'.$num.
'</span></td>';
674 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>';
675 print
'</tr></table>';
679 while ($i < $num && $i < $MAXLIST)
681 $obj = $db->fetch_object(
$resql);
683 print
'<tr class="oddeven">';
684 print
'<td class="nowrap">';
685 $orderstatic->id = $obj->rowid;
686 $orderstatic->ref = $obj->ref;
687 $orderstatic->total_ht = $obj->total_ht;
688 $orderstatic->total_tva = $obj->total_tva;
689 $orderstatic->total_ttc = $obj->total_ttc;
690 print $orderstatic->getNomUrl(1);
692 print
'<td class="center" width="80">';
700 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
706 if ($num > 0) print
"</table>";
716 $langs->load(
'bills');
719 if ($user->rights->fournisseur->facture->lire)
722 $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 as amount,f.paye,';
723 $sql .=
' SUM(pf.amount) as am';
724 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
725 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
726 $sql .=
' WHERE f.fk_soc = '.$object->id;
727 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
728 $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';
729 $sql .=
' ORDER BY f.datef DESC';
730 $resql = $db->query($sql);
734 $num = $db->num_rows(
$resql);
737 print
'<table class="noborder centpercent lastrecordtable">';
739 print
'<tr class="liste_titre">';
740 print
'<td colspan="4">';
741 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id.
'">'.$langs->trans(
'AllBills').
'<span class="badge marginleftonlyshort">'.$num.
'</span></td>';
742 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>';
743 print
'</tr></table>';
747 while ($i < min($num, $MAXLIST))
749 $obj = $db->fetch_object(
$resql);
751 print
'<tr class="oddeven">';
753 print
'<a href="facture/card.php?facid='.$obj->rowid.
'">';
754 $facturestatic->id = $obj->rowid;
755 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
756 $facturestatic->ref_supplier = $obj->ref_supplier;
757 $facturestatic->libelle = $obj->label;
758 $facturestatic->label = $obj->label;
759 $facturestatic->total_ht = $obj->total_ht;
760 $facturestatic->total_tva = $obj->total_tva;
761 $facturestatic->total_ttc = $obj->total_ttc;
762 print $facturestatic->getNomUrl(1);
763 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
764 print ($obj->label ?
' - ' :
'').dol_trunc($obj->label, 14);
766 print
'<td class="center nowrap">'.dol_print_date($db->jdate($obj->df),
'day').
'</td>';
767 print
'<td class="right nowrap">'.price($obj->amount).
'</td>';
768 print
'<td class="right nowrap">';
769 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
775 if ($num > 0) print
'</table>';
781 print
'</div></div></div>';
782 print
'<div style="clear:both"></div>';
790 print
'<div class="tabsAction">';
792 $parameters = array();
793 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
797 if ($object->status != 1)
799 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"ThirdPartyIsClosed").
'</a></div>';
802 if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer)
804 $langs->load(
"supplier_proposal");
805 if ($object->status == 1) {
806 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id.
'">'.$langs->trans(
"AddSupplierProposal").
'</a>';
808 print
'<a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddSupplierProposal").
'</a>';
812 if ($user->rights->fournisseur->commande->creer)
814 $langs->load(
"orders");
815 if ($object->status == 1) {
816 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&socid='.$object->id.
'">'.$langs->trans(
"AddOrder").
'</a>';
818 print
'<a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddOrder").
'</a>';
822 if ($user->rights->fournisseur->facture->creer)
824 if (!empty($orders2invoice) && $orders2invoice > 0)
826 if ($object->status == 1) {
828 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1">'.$langs->trans(
"CreateInvoiceForThisSupplier").
'</a></div>';
830 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
832 }
else print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')').
'" href="#">'.$langs->trans(
"CreateInvoiceForThisCustomer").
'</a></div>';
835 if ($user->rights->fournisseur->facture->creer)
837 $langs->load(
"bills");
838 if ($object->status == 1) {
839 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id.
'">'.$langs->trans(
"AddBill").
'</a>';
841 print
'<a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans(
"ThirdPartyIsClosed")).
'" href="#">'.$langs->trans(
"AddBill").
'</a>';
846 if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1)
848 if ($user->rights->agenda->myactions->create)
850 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id.
'">'.$langs->trans(
"AddAction").
'</a>';
852 print
'<a class="butAction" title="'.dol_escape_js($langs->trans(
"NotAllowed")).
'" href="#">'.$langs->trans(
"AddAction").
'</a>';
860 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD))
867 if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB))
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
const STATUS_RECEIVED_COMPLETELY
Received completely.
Class to manage products or services.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
show_actions_done($conf, $langs, $db, $filterobj, $objcon= '', $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).
show_contacts($conf, $langs, $db, $object, $backtopage= '')
Show html area for list of contacts.
Class to manage suppliers invoices.
Class to manage suppliers.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage members of a foundation.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Class to manage predefined suppliers products.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage price ask supplier.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
show_actions_todo($conf, $langs, $db, $filterobj, $objcon= '', $noprint=0, $actioncode= '')
Show html area with actions to do.