33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
40if (isModEnabled(
'member')) {
41 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
43if (isModEnabled(
'category')) {
44 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46if (!empty($conf->accounting->enabled)) {
47 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
51$langs->loadLangs(array(
60$action =
GETPOST(
'action',
'aZ09');
61$cancel =
GETPOST(
'cancel',
'alpha');
68$result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
74$extrafields->fetch_name_optionals_label(
$object->table_element);
77$hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
80$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
83 if (!(
$object->fournisseur > 0) || !$user->hasRight(
"fournisseur",
"lire")) {
93$parameters = array(
'id'=>$id);
94$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
105 if ($action ==
'setsupplieraccountancycode' && $user->hasRight(
'societe',
'creer')) {
107 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
111 $action =
'editsupplieraccountancycode';
115 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
124 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
132 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
141 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
150 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
159 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
165 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
172 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
180 $action =
'edit_extras';
190$contactstatic =
new Contact($db);
191$form =
new Form($db);
193if ($id > 0 && empty(
$object->id)) {
203 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
205 $title =
$object->name.
" - ".$langs->trans(
'Supplier');
215 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
217 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
219 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
221 print
'<div class="fichecenter"><div class="fichehalfleft">';
223 print
'<div class="underbanner clearboth"></div>';
224 print
'<table class="border centpercent tableforfield">';
227 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
232 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
237 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
239 $tmpcheck =
$object->check_codefournisseur();
240 if ($tmpcheck != 0 && $tmpcheck != -5) {
241 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
246 $langs->load(
'compta');
249 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
251 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
258 print
'<td class="titlefield">';
259 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
266 if ($mysoc->useLocalTax(1)) {
267 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
271 if ($mysoc->useLocalTax(2)) {
272 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
280 print
'<td class="titlefield">';
281 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
283 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
289 print
'<tr><td class="nowrap">';
292 print $form->editfieldkey(
"VATIntra",
'tva_intra',
$object->tva_intra,
$object, $user->hasRight(
'societe',
'creer'));
294 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow,
$object, $user->hasRight(
'societe',
'creer'),
'string',
$object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped'=>1));
298 $langs->load(
'bills');
299 $form =
new Form($db);
301 print
'<table width="100%" class="nobordernopadding"><tr><td>';
302 print $langs->trans(
'PaymentConditions');
304 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
305 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>';
307 print
'</tr></table>';
309 if ($action ==
'editconditions') {
310 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
312 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'none');
318 print
'<tr><td class="nowrap">';
319 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
320 print $langs->trans(
'PaymentMode');
322 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
323 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>';
325 print
'</tr></table>';
327 if ($action ==
'editmode') {
328 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
330 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'none');
335 if (isModEnabled(
"bank")) {
337 print
'<tr><td class="nowrap">';
338 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
339 print $langs->trans(
'PaymentBankAccount');
341 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
342 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>';
344 print
'</tr></table>';
346 if ($action ==
'editbankaccount') {
347 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'fk_account', 1);
349 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'none');
356 print
'<tr><td class="nowrap">';
357 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
358 print $langs->trans(
"CustomerRelativeDiscountShort");
359 print
'<td><td class="right">';
360 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
361 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>';
363 print
'</td></tr></table>';
364 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
368 print
'<tr><td class="nowrap">';
369 print
'<table width="100%" class="nobordernopadding">';
370 print
'<tr><td class="nowrap">';
371 print $langs->trans(
"CustomerAbsoluteDiscountShort");
372 print
'<td><td class="right">';
373 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
374 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>';
376 print
'</td></tr></table>';
379 $amount_discount =
$object->getAvailableDiscounts(
'',
'', 0, 1);
380 if ($amount_discount < 0) {
383 if ($amount_discount > 0) {
384 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>';
390 if (isModEnabled(
"supplier_order") &&
getDolGlobalString(
'ORDER_MANAGE_MIN_AMOUNT')) {
391 print
'<tr class="nowrap">';
393 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount,
$object, $user->hasRight(
"societe",
"creer"));
395 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
396 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) :
''));
402 if (isModEnabled(
'category')) {
403 $langs->load(
"categories");
404 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
406 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
411 $parameters = array(
'socid'=>
$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
412 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
415 if (isModEnabled(
'member')) {
416 $langs->load(
"members");
417 $langs->load(
"users");
418 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
421 $result = $adh->fetch(
'',
'',
$object->id);
423 $adh->ref = $adh->getFullName($langs);
424 print $adh->getNomUrl(1);
426 print $langs->trans(
"ThirdpartyNotLinkedToMember");
435 print
'</div><div class="fichehalfright">';
442 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
446 $boxstat .=
'<div class="box divboxtable box-halfright">';
447 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
448 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
450 if (isModEnabled(
'supplier_proposal')) {
452 $tmp =
$object->getOutstandingProposals(
'supplier');
453 $outstandingOpened = $tmp[
'opened'];
454 $outstandingTotal = $tmp[
'total_ht'];
455 $outstandingTotalIncTax = $tmp[
'total_ttc'];
456 $text = $langs->trans(
"OverAllSupplierProposals");
457 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id;
460 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
462 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
463 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
464 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
465 $boxstat .=
'</div>';
471 if (isModEnabled(
"supplier_order")) {
473 $tmp =
$object->getOutstandingOrders(
'supplier');
474 $outstandingOpened = $tmp[
'opened'];
475 $outstandingTotal = $tmp[
'total_ht'];
476 $outstandingTotalIncTax = $tmp[
'total_ttc'];
477 $text = $langs->trans(
"OverAllOrders");
478 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id;
481 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
483 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
484 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
485 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
486 $boxstat .=
'</div>';
492 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
494 $tmp =
$object->getOutstandingBills(
'supplier');
495 $outstandingOpened = $tmp[
'opened'];
496 $outstandingTotal = $tmp[
'total_ht'];
497 $outstandingTotalIncTax = $tmp[
'total_ttc'];
499 $text = $langs->trans(
"OverAllInvoices");
500 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->id;
503 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
505 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
506 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
507 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
508 $boxstat .=
'</div>';
514 $text = $langs->trans(
"CurrentOutstandingBill");
515 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
518 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
520 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
521 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
522 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
523 $boxstat .=
'</div>';
528 $tmp =
$object->getOutstandingBills(
'supplier', 1);
529 $outstandingOpenedLate = $tmp[
'opened'];
530 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
531 $text = $langs->trans(
"CurrentOutstandingBillLate");
532 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
535 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
537 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
538 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
539 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
540 $boxstat .=
'</div>';
548 $parameters = array();
549 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters,
$object, $action);
550 if (empty($reshook)) {
551 $boxstat .= $hookmanager->resPrint;
554 $boxstat .=
'</td></tr>';
555 $boxstat .=
'</table>';
556 $boxstat .=
'</div>';
567 if (isModEnabled(
"product") || isModEnabled(
"service")) {
568 $langs->load(
"products");
570 $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,';
571 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
572 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
573 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
574 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
575 $sql .=
' AND pfp.fk_soc = '.((int)
$object->id);
576 $sql .= $db->order(
'pfp.tms',
'desc');
577 $sql .= $db->plimit($MAXLIST);
579 $query = $db->query($sql);
584 $num = $db->num_rows($query);
586 print
'<div class="div-table-responsive-no-min">';
587 print
'<table class="noborder centpercent lastrecordtable">';
588 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
589 print
'<td colspan="2">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right" colspan="2">';
590 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>';
591 print
'</a></td></tr>';
595 $productstatic =
new Product($db);
597 while ($objp = $db->fetch_object($query)) {
598 $productstatic->id = $objp->rowid;
599 $productstatic->ref = $objp->ref;
600 $productstatic->label = $objp->label;
601 $productstatic->type = $objp->fk_product_type;
602 $productstatic->entity = $objp->entity;
603 $productstatic->status = $objp->status;
604 $productstatic->status_buy = $objp->status_buy;
605 $productstatic->status_batch = $objp->status_batch;
607 print
'<tr class="oddeven">';
608 print
'<td class="nowrap">';
609 print $productstatic->getNomUrl(1);
614 print
'<td class="tdoverflowmax200">';
618 print
'<td class="right">';
620 if (isset($objp->price)) {
621 print
'<span class="amount">'.price($objp->price).
'</span>';
622 if ($objp->quantity > 1) {
624 print $objp->quantity;
631 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"NoProductPriceDefinedForThisSupplier").
'</span></td></tr>';
644 if ($user->hasRight(
"supplier_proposal",
"lire")) {
645 $langs->loadLangs(array(
"supplier_proposal"));
647 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
648 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
649 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
650 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
651 $sql .=
" ORDER BY p.date_valid DESC";
652 $sql .= $db->plimit($MAXLIST);
654 $resql = $db->query($sql);
657 $num = $db->num_rows($resql);
660 print
'<div class="div-table-responsive-no-min">';
661 print
'<table class="noborder centpercent lastrecordtable">';
663 print
'<tr class="liste_titre">';
664 print
'<td colspan="3">';
665 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
666 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>';
668 print
'</tr></table>';
672 while ($i < $num && $i <= $MAXLIST) {
673 $obj = $db->fetch_object($resql);
675 print
'<tr class="oddeven">';
676 print
'<td class="nowrap">';
677 $proposalstatic->id = $obj->rowid;
678 $proposalstatic->ref = $obj->ref;
679 $proposalstatic->total_ht = $obj->total_ht;
680 $proposalstatic->total_tva = $obj->total_tva;
681 $proposalstatic->total_ttc = $obj->total_ttc;
682 print $proposalstatic->getNomUrl(1);
684 print
'<td class="center" width="80">';
691 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
698 print
"</table></div>";
710 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
713 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
714 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
715 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
716 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
717 $sql2 .=
' WHERE c.fk_soc = s.rowid';
718 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
719 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
725 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize(
getDolGlobalString(
'SUPPLIER_ORDER_TO_INVOICE_STATUS')).
")";
727 $sql2 .=
" AND c.billed = 0";
731 $resql2 = $db->query($sql2);
733 $orders2invoice = $db->num_rows($resql2);
740 $sql =
"SELECT count(p.rowid) as total";
741 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
742 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
743 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
744 $resql = $db->query($sql);
746 $object_count = $db->fetch_object($resql);
747 $num = $object_count->total;
750 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
751 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
752 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
753 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
754 $sql .=
" ORDER BY p.date_commande DESC";
755 $sql .= $db->plimit($MAXLIST);
757 $resql = $db->query($sql);
762 print
'<div class="div-table-responsive-no-min">';
763 print
'<table class="noborder centpercent lastrecordtable">';
765 print
'<tr class="liste_titre">';
766 print
'<td colspan="4">';
767 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
768 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>';
769 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>';
770 print
'</tr></table>';
774 while ($i < $num && $i < $MAXLIST) {
775 $obj = $db->fetch_object($resql);
777 $orderstatic->id = $obj->rowid;
778 $orderstatic->ref = $obj->ref;
779 $orderstatic->total_ht = $obj->total_ht;
780 $orderstatic->total_tva = $obj->total_tva;
781 $orderstatic->total_ttc = $obj->total_ttc;
782 $orderstatic->date = $db->jdate($obj->date);
784 print
'<tr class="oddeven">';
785 print
'<td class="nowraponall">';
786 print $orderstatic->getNomUrl(1);
788 print
'<td class="center" width="80">';
793 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
794 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
801 print
"</table></div>";
812 $langs->load(
'bills');
815 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
817 $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,';
818 $sql .=
' SUM(pf.amount) as am';
819 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
820 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
821 $sql .=
' WHERE f.fk_soc = '.((int)
$object->id);
822 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
823 $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';
824 $sql .=
' ORDER BY f.datef DESC';
825 $resql = $db->query($sql);
828 $num = $db->num_rows($resql);
830 print
'<div class="div-table-responsive-no-min">';
831 print
'<table class="noborder centpercent lastrecordtable">';
833 print
'<tr class="liste_titre">';
834 print
'<td colspan="4">';
835 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
836 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>';
837 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>';
838 print
'</tr></table>';
842 while ($i < min($num, $MAXLIST)) {
843 $obj = $db->fetch_object($resql);
845 $facturestatic->id = $obj->rowid;
846 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
847 $facturestatic->ref_supplier = $obj->ref_supplier;
848 $facturestatic->libelle = $obj->label;
849 $facturestatic->label = $obj->label;
850 $facturestatic->total_ht = $obj->total_ht;
851 $facturestatic->total_tva = $obj->total_tva;
852 $facturestatic->total_ttc = $obj->total_ttc;
853 $facturestatic->date = $db->jdate($obj->df);
855 print
'<tr class="oddeven">';
856 print
'<td class="tdoverflowmax200">';
857 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
858 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
859 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
861 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
862 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
863 print
'<td class="right nowrap">';
864 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
871 print
'</table></div>';
879 $parameters = array();
880 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
884 print $hookmanager->resPrint;
887 print
'</div></div>';
888 print
'<div class="clearboth"></div>';
896 print
'<div class="tabsAction">';
898 $parameters = array();
899 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
901 if (empty($reshook)) {
903 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
906 if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
907 $langs->load(
"supplier_proposal");
909 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.
$object->id,
'');
911 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
915 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
916 $langs->load(
"orders");
918 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.
$object->id,
'');
920 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
924 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
925 if (!empty($orders2invoice) && $orders2invoice > 0) {
928 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1',
'');
930 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
933 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
937 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
938 $langs->load(
"bills");
940 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.
$object->id,
'');
942 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
948 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
949 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id,
'');
951 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
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 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.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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...
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.