34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
37require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture-rec.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
42if (isModEnabled(
'member')) {
43 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
45if (isModEnabled(
'category')) {
46 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48if (!empty($conf->accounting->enabled)) {
49 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
53$langs->loadLangs(array(
62$action =
GETPOST(
'action',
'aZ09');
63$cancel =
GETPOST(
'cancel',
'alpha');
72$hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
74$result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
80$extrafields->fetch_name_optionals_label(
$object->table_element);
85$result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
88 if (!(
$object->fournisseur > 0) || !$user->hasRight(
"fournisseur",
"lire")) {
98$parameters = array(
'id' => $id);
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
104if (empty($reshook)) {
110 if ($action ==
'setsupplieraccountancycode' && $user->hasRight(
'societe',
'creer')) {
112 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
116 $action =
'editsupplieraccountancycode';
120 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
129 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
137 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
146 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
155 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
164 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
170 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
177 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
185 $action =
'edit_extras';
195$contactstatic =
new Contact($db);
196$form =
new Form($db);
198if ($id > 0 && empty(
$object->id)) {
208 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
210 $title =
$object->name.
" - ".$langs->trans(
'Supplier');
213 llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn page-card');
220 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
222 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
224 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
226 print
'<div class="fichecenter"><div class="fichehalfleft">';
228 print
'<div class="underbanner clearboth"></div>';
229 print
'<table class="border centpercent tableforfield">';
232 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
237 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
242 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
244 $tmpcheck =
$object->check_codefournisseur();
245 if ($tmpcheck != 0 && $tmpcheck != -5) {
246 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
251 $langs->load(
'compta');
254 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
256 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode',
$object->code_compta_fournisseur,
$object, $user->hasRight(
'societe',
'creer'));
263 print
'<td class="titlefield">';
264 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
271 if ($mysoc->useLocalTax(1)) {
272 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
276 if ($mysoc->useLocalTax(2)) {
277 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
285 print
'<td class="titlefield">';
286 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
288 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
294 print
'<tr><td class="nowrap">';
297 print $form->editfieldkey(
"VATIntra",
'tva_intra',
$object->tva_intra,
$object, $user->hasRight(
'societe',
'creer'));
299 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow,
$object, $user->hasRight(
'societe',
'creer'),
'string',
$object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped' => 1));
303 $langs->load(
'bills');
304 $form =
new Form($db);
306 print
'<table width="100%" class="nobordernopadding"><tr><td>';
307 print $langs->trans(
'PaymentConditions');
309 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
310 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>';
312 print
'</tr></table>';
314 if ($action ==
'editconditions') {
315 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
317 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->cond_reglement_supplier_id,
'none');
323 print
'<tr><td class="nowrap">';
324 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
325 print $langs->trans(
'PaymentMode');
327 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
328 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>';
330 print
'</tr></table>';
332 if ($action ==
'editmode') {
333 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
335 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->mode_reglement_supplier_id,
'none');
340 if (isModEnabled(
"bank")) {
342 print
'<tr><td class="nowrap">';
343 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
344 print $langs->trans(
'PaymentBankAccount');
346 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
347 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>';
349 print
'</tr></table>';
351 if ($action ==
'editbankaccount') {
352 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'fk_account', 1);
354 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->fk_account,
'none');
361 print
'<tr><td class="nowrap">';
362 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
363 print $langs->trans(
"CustomerRelativeDiscountShort");
364 print
'<td><td class="right">';
365 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
366 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>';
368 print
'</td></tr></table>';
369 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.
$object->id.
'">'.
$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
373 print
'<tr><td class="nowrap">';
374 print
'<table width="100%" class="nobordernopadding">';
375 print
'<tr><td class="nowrap">';
376 print $langs->trans(
"CustomerAbsoluteDiscountShort");
377 print
'<td><td class="right">';
378 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
379 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>';
381 print
'</td></tr></table>';
384 $amount_discount =
$object->getAvailableDiscounts(
'',
'', 0, 1);
385 if ($amount_discount < 0) {
388 if ($amount_discount > 0) {
389 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>';
395 if (isModEnabled(
"supplier_order") &&
getDolGlobalString(
'ORDER_MANAGE_MIN_AMOUNT')) {
396 print
'<tr class="nowrap">';
398 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount',
$object->supplier_order_min_amount,
$object, $user->hasRight(
"societe",
"creer"));
400 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
401 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) :
''));
407 if (isModEnabled(
'category')) {
408 $langs->load(
"categories");
409 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
411 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
416 $parameters = array(
'socid' =>
$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
417 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
420 if (isModEnabled(
'member')) {
421 $langs->load(
"members");
422 $langs->load(
"users");
423 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
426 $result = $adh->fetch(
'',
'',
$object->id);
428 $adh->ref = $adh->getFullName($langs);
429 print $adh->getNomUrl(1);
431 print $langs->trans(
"ThirdpartyNotLinkedToMember");
440 print
'</div><div class="fichehalfright">';
447 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
451 $boxstat .=
'<div class="box divboxtable box-halfright">';
452 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
453 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
455 if (isModEnabled(
'supplier_proposal')) {
457 $tmp =
$object->getOutstandingProposals(
'supplier');
458 $outstandingOpened = $tmp[
'opened'];
459 $outstandingTotal = $tmp[
'total_ht'];
460 $outstandingTotalIncTax = $tmp[
'total_ttc'];
461 $text = $langs->trans(
"OverAllSupplierProposals");
462 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->id;
465 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
467 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
468 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
469 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
470 $boxstat .=
'</div>';
476 if (isModEnabled(
"supplier_order")) {
478 $tmp =
$object->getOutstandingOrders(
'supplier');
479 $outstandingOpened = $tmp[
'opened'];
480 $outstandingTotal = $tmp[
'total_ht'];
481 $outstandingTotalIncTax = $tmp[
'total_ttc'];
482 $text = $langs->trans(
"OverAllOrders");
483 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id;
486 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
488 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
489 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
490 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
491 $boxstat .=
'</div>';
497 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
499 $tmp =
$object->getOutstandingBills(
'supplier');
500 $outstandingOpened = $tmp[
'opened'];
501 $outstandingTotal = $tmp[
'total_ht'];
502 $outstandingTotalIncTax = $tmp[
'total_ttc'];
504 $text = $langs->trans(
"OverAllInvoices");
505 $link = DOL_URL_ROOT.
'/fourn/facture/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 $text = $langs->trans(
"CurrentOutstandingBill");
520 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
523 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
525 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
526 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
527 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
528 $boxstat .=
'</div>';
533 $tmp =
$object->getOutstandingBills(
'supplier', 1);
534 $outstandingOpenedLate = $tmp[
'opened'];
535 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
536 $text = $langs->trans(
"CurrentOutstandingBillLate");
537 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.
$object->id;
540 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
542 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
543 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
544 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
545 $boxstat .=
'</div>';
553 $parameters = array();
554 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters,
$object, $action);
555 if (empty($reshook)) {
556 $boxstat .= $hookmanager->resPrint;
559 $boxstat .=
'</td></tr>';
560 $boxstat .=
'</table>';
561 $boxstat .=
'</div>';
572 if (isModEnabled(
"product") || isModEnabled(
"service")) {
573 $langs->load(
"products");
575 $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,';
576 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
577 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
578 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
579 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
580 $sql .=
' AND pfp.fk_soc = '.((int)
$object->id);
581 $sql .= $db->order(
'pfp.tms',
'desc');
582 $sql .= $db->plimit($MAXLIST);
584 $query = $db->query($sql);
589 $num = $db->num_rows($query);
591 print
'<div class="div-table-responsive-no-min">';
592 print
'<table class="noborder centpercent lastrecordtable">';
593 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
594 print
'<td colspan="2">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right" colspan="2">';
595 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>';
596 print
'</a></td></tr>';
600 $productstatic =
new Product($db);
602 while ($objp = $db->fetch_object($query)) {
603 $productstatic->id = $objp->rowid;
604 $productstatic->ref = $objp->ref;
605 $productstatic->label = $objp->label;
606 $productstatic->type = $objp->fk_product_type;
607 $productstatic->entity = $objp->entity;
608 $productstatic->status = $objp->status;
609 $productstatic->status_buy = $objp->status_buy;
610 $productstatic->status_batch = $objp->status_batch;
612 print
'<tr class="oddeven">';
613 print
'<td class="nowrap">';
614 print $productstatic->getNomUrl(1);
619 print
'<td class="tdoverflowmax200">';
623 print
'<td class="right">';
625 if (isset($objp->price)) {
626 print
'<span class="amount">'.price($objp->price).
'</span>';
627 if ($objp->quantity > 1) {
629 print $objp->quantity;
636 print
'<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans(
"NoProductPriceDefinedForThisSupplier").
'</span></td></tr>';
649 if ($user->hasRight(
"supplier_proposal",
"lire")) {
650 $langs->loadLangs(array(
"supplier_proposal"));
652 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
653 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
654 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
655 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
656 $sql .=
" ORDER BY p.date_valid DESC";
657 $sql .= $db->plimit($MAXLIST);
659 $resql = $db->query($sql);
662 $num = $db->num_rows($resql);
665 print
'<div class="div-table-responsive-no-min">';
666 print
'<table class="noborder centpercent lastrecordtable">';
668 print
'<tr class="liste_titre">';
669 print
'<td colspan="3">';
670 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
671 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>';
673 print
'</tr></table>';
677 while ($i < $num && $i <= $MAXLIST) {
678 $obj = $db->fetch_object($resql);
680 print
'<tr class="oddeven">';
681 print
'<td class="nowrap">';
682 $proposalstatic->id = $obj->rowid;
683 $proposalstatic->ref = $obj->ref;
684 $proposalstatic->total_ht = $obj->total_ht;
685 $proposalstatic->total_tva = $obj->total_tva;
686 $proposalstatic->total_ttc = $obj->total_ttc;
687 print $proposalstatic->getNomUrl(1);
689 print
'<td class="center" width="80">';
696 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
703 print
"</table></div>";
715 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
718 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
719 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
720 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
721 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
722 $sql2 .=
' WHERE c.fk_soc = s.rowid';
723 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
724 $sql2 .=
' AND s.rowid = '.((int)
$object->id);
730 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize(
getDolGlobalString(
'SUPPLIER_ORDER_TO_INVOICE_STATUS')).
")";
732 $sql2 .=
" AND c.billed = 0";
736 $resql2 = $db->query($sql2);
738 $orders2invoice = $db->num_rows($resql2);
745 $sql =
"SELECT count(p.rowid) as total";
746 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
747 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
748 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
749 $resql = $db->query($sql);
751 $object_count = $db->fetch_object($resql);
752 $num = $object_count->total;
755 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
756 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
757 $sql .=
" WHERE p.fk_soc = ".((int)
$object->id);
758 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
759 $sql .=
" ORDER BY p.date_commande DESC";
760 $sql .= $db->plimit($MAXLIST);
762 $resql = $db->query($sql);
767 print
'<div class="div-table-responsive-no-min">';
768 print
'<table class="noborder centpercent lastrecordtable">';
770 print
'<tr class="liste_titre">';
771 print
'<td colspan="4">';
772 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
773 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>';
774 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>';
775 print
'</tr></table>';
779 while ($i < $num && $i < $MAXLIST) {
780 $obj = $db->fetch_object($resql);
782 $orderstatic->id = $obj->rowid;
783 $orderstatic->ref = $obj->ref;
784 $orderstatic->total_ht = $obj->total_ht;
785 $orderstatic->total_tva = $obj->total_tva;
786 $orderstatic->total_ttc = $obj->total_ttc;
787 $orderstatic->date = $db->jdate($obj->date);
789 print
'<tr class="oddeven">';
790 print
'<td class="nowraponall">';
791 print $orderstatic->getNomUrl(1);
793 print
'<td class="center" width="80">';
798 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
799 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
806 print
"</table></div>";
817 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
818 $sql =
'SELECT f.rowid as id, f.titre as ref';
819 $sql .=
', f.total_ht';
820 $sql .=
', f.total_tva';
821 $sql .=
', f.total_ttc';
822 $sql .=
', f.datec as dc';
823 $sql .=
', f.date_last_gen, f.date_when';
824 $sql .=
', f.frequency';
825 $sql .=
', f.unit_frequency';
826 $sql .=
', f.suspended as suspended';
827 $sql .=
', s.nom, s.rowid as socid';
828 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture_fourn_rec as f";
829 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
830 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
831 $sql .=
' GROUP BY f.rowid, f.titre, f.total_ht, f.total_tva, f.total_ttc,';
832 $sql .=
' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
833 $sql .=
' f.suspended, f.date_when,';
834 $sql .=
' s.nom, s.rowid';
835 $sql .= $db->order(
"f.date_last_gen, f.datec",
"DESC");
837 $resql = $db->query($sql);
841 $num = $db->num_rows($resql);
843 print
'<div class="div-table-responsive-no-min">';
844 print
'<table class="noborder centpercent lastrecordtable">';
845 print
'<tr class="liste_titre">';
850 print
'<td colspan="'.$colspan.
'">';
851 print
'<table class="centpercent nobordernopadding"><tr>';
852 print
'<td>'.$langs->trans(
"LatestSupplierTemplateInvoices", ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
853 print
'<td class="right">';
854 print
'<a class="notasortlink" href="'.DOL_URL_ROOT.
'/fourn/facture/list-rec.php?socid='.
$object->id.
'">';
855 print
'<span class="hideonsmartphone">'.$langs->trans(
"AllSupplierTemplateInvoices").
'</span><span class="badge marginleftonlyshort">'.$num.
'</span></a></td>';
856 print
'</tr></table>';
862 while ($i < $num && $i < $MAXLIST) {
863 $objp = $db->fetch_object($resql);
865 $invoicetemplate->id = $objp->id;
866 $invoicetemplate->ref = $objp->ref;
867 $invoicetemplate->suspended = $objp->suspended;
868 $invoicetemplate->frequency = $objp->frequency;
869 $invoicetemplate->unit_frequency = $objp->unit_frequency;
870 $invoicetemplate->total_ht = $objp->total_ht;
871 $invoicetemplate->total_tva = $objp->total_tva;
872 $invoicetemplate->total_ttc = $objp->total_ttc;
873 $invoicetemplate->date_last_gen = $objp->date_last_gen;
874 $invoicetemplate->date_when = $objp->date_when;
876 print
'<tr class="oddeven">';
877 print
'<td class="tdoverflowmax250">';
878 print $invoicetemplate->getNomUrl(1);
881 if ($objp->frequency && $objp->date_last_gen > 0) {
882 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),
'day').
'</td>';
885 print
'<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc),
'day').
'</td>';
887 print
'<td class="right"><b>!!!</b></td>';
890 print
'<td class="right nowraponall">';
891 print
price($objp->total_ht);
895 print
'<td class="right nowraponall">';
896 print
price($objp->total_ttc);
900 print
'<td class="nowrap right" style="min-width: 60px">';
901 print $langs->trans(
'FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).
' - ';
902 print($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0));
923 $langs->load(
'bills');
926 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
928 $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,';
929 $sql .=
' SUM(pf.amount) as am';
930 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
931 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
932 $sql .=
' WHERE f.fk_soc = '.((int)
$object->id);
933 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
934 $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';
935 $sql .=
' ORDER BY f.datef DESC';
936 $resql = $db->query($sql);
939 $num = $db->num_rows($resql);
941 print
'<div class="div-table-responsive-no-min">';
942 print
'<table class="noborder centpercent lastrecordtable">';
944 print
'<tr class="liste_titre">';
945 print
'<td colspan="4">';
946 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
947 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>';
948 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>';
949 print
'</tr></table>';
953 while ($i < min($num, $MAXLIST)) {
954 $obj = $db->fetch_object($resql);
956 $facturestatic->id = $obj->rowid;
957 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
958 $facturestatic->ref_supplier = $obj->ref_supplier;
959 $facturestatic->libelle = $obj->label;
960 $facturestatic->label = $obj->label;
961 $facturestatic->total_ht = $obj->total_ht;
962 $facturestatic->total_tva = $obj->total_tva;
963 $facturestatic->total_ttc = $obj->total_ttc;
964 $facturestatic->date = $db->jdate($obj->df);
966 print
'<tr class="oddeven">';
967 print
'<td class="tdoverflowmax200">';
968 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
969 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
970 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
972 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
973 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
974 print
'<td class="right nowrap">';
975 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
982 print
'</table></div>';
990 $parameters = array();
991 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters,
$object, $action);
995 print $hookmanager->resPrint;
998 print
'</div></div>';
999 print
'<div class="clearboth"></div>';
1007 print
'<div class="tabsAction">';
1009 $parameters = array();
1010 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1012 if (empty($reshook)) {
1014 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1017 if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
1018 $langs->load(
"supplier_proposal");
1020 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.
$object->id,
'');
1022 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1026 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
1027 $langs->load(
"orders");
1029 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.
$object->id,
'');
1031 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1035 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1036 if (!empty($orders2invoice) && $orders2invoice > 0) {
1039 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.
$object->id.
'&search_billed=0&autoselectall=1',
'');
1041 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1044 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1048 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
1049 $langs->load(
"bills");
1051 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.
$object->id,
'');
1053 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1059 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
1060 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.
$object->id,
'');
1062 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 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.
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.
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...
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.