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(
'adherent')) {
41 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
43if (isModEnabled(
'categorie')) {
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')) {
106 $result = $object->fetch($id);
107 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
108 $result = $object->update($object->id, $user, 1, 0, 1);
114 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
115 $result = $object->fetch($id);
116 $object->tva_intra =
GETPOST(
"tva_intra");
117 $result = $object->update($object->id, $user, 1, 0, 0);
123 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
125 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
131 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
133 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
140 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
142 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
149 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
151 $object->supplier_order_min_amount =
price2num(
GETPOST(
'supplier_order_min_amount',
'alpha'));
152 $result = $object->update($object->id, $user);
158 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
164 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
171 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
179 $action =
'edit_extras';
189$contactstatic =
new Contact($db);
190$form =
new Form($db);
192if ($id > 0 && empty($object->id)) {
194 $res = $object->fetch($id);
195 if ($object->id <= 0) {
201if ($object->id > 0) {
202 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
203 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
204 $title = $object->name.
" - ".$langs->trans(
'Supplier');
214 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
216 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
218 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
220 print
'<div class="fichecenter"><div class="fichehalfleft">';
222 print
'<div class="underbanner clearboth"></div>';
223 print
'<table class="border centpercent tableforfield">';
226 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
227 print $object->getTypeUrl(1);
230 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
231 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
234 if ($object->fournisseur) {
236 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
238 $tmpcheck = $object->check_codefournisseur();
239 if ($tmpcheck != 0 && $tmpcheck != -5) {
240 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
245 $langs->load(
'compta');
248 print $form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
250 print $form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
257 print
'<td class="titlefield">';
258 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
260 print
yn($object->tva_assuj);
265 if ($mysoc->useLocalTax(1)) {
266 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
267 print
yn($object->localtax1_assuj);
270 if ($mysoc->useLocalTax(2)) {
271 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
272 print
yn($object->localtax2_assuj);
278 print
'<td class="titlefield">';
279 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
281 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
' disabled>';
286 print
'<tr><td class="nowrap">';
289 print $form->editfieldkey(
"VATIntra",
'tva_intra', $object->tva_intra, $object, $user->hasRight(
'societe',
'creer'));
291 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow, $object, $user->hasRight(
'societe',
'creer'),
'string', $object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped'=>1));
295 $langs->load(
'bills');
296 $form =
new Form($db);
298 print
'<table width="100%" class="nobordernopadding"><tr><td>';
299 print $langs->trans(
'PaymentConditions');
301 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
302 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>';
304 print
'</tr></table>';
306 if ($action ==
'editconditions') {
307 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
309 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'none');
315 print
'<tr><td class="nowrap">';
316 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
317 print $langs->trans(
'PaymentMode');
319 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
320 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>';
322 print
'</tr></table>';
324 if ($action ==
'editmode') {
325 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
327 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'none');
332 if (isModEnabled(
"banque")) {
334 print
'<tr><td class="nowrap">';
335 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
336 print $langs->trans(
'PaymentBankAccount');
338 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
339 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>';
341 print
'</tr></table>';
343 if ($action ==
'editbankaccount') {
344 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'fk_account', 1);
346 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'none');
353 print
'<tr><td class="nowrap">';
354 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
355 print $langs->trans(
"CustomerRelativeDiscountShort");
356 print
'<td><td class="right">';
357 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
358 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>';
360 print
'</td></tr></table>';
361 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
365 print
'<tr><td class="nowrap">';
366 print
'<table width="100%" class="nobordernopadding">';
367 print
'<tr><td class="nowrap">';
368 print $langs->trans(
"CustomerAbsoluteDiscountShort");
369 print
'<td><td class="right">';
370 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
371 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>';
373 print
'</td></tr></table>';
376 $amount_discount = $object->getAvailableDiscounts(
'',
'', 0, 1);
377 if ($amount_discount < 0) {
380 if ($amount_discount > 0) {
381 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>';
387 if (isModEnabled(
"supplier_order") && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
388 print
'<tr class="nowrap">';
390 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight(
"societe",
"creer"));
392 $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ?
'numeric' :
'amount';
393 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) :
''));
399 if (isModEnabled(
'categorie')) {
400 $langs->load(
"categories");
401 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
403 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
408 $parameters = array(
'socid'=>$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
409 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
412 if (isModEnabled(
'adherent')) {
413 $langs->load(
"members");
414 $langs->load(
"users");
415 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
418 $result = $adh->fetch(
'',
'', $object->id);
420 $adh->ref = $adh->getFullName($langs);
421 print $adh->getNomUrl(1);
423 print $langs->trans(
"ThirdpartyNotLinkedToMember");
432 print
'</div><div class="fichehalfright">';
437 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
439 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
443 $boxstat .=
'<div class="box box-halfright">';
444 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
445 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
447 if (isModEnabled(
'supplier_proposal')) {
449 $tmp = $object->getOutstandingProposals(
'supplier');
450 $outstandingOpened = $tmp[
'opened'];
451 $outstandingTotal = $tmp[
'total_ht'];
452 $outstandingTotalIncTax = $tmp[
'total_ttc'];
453 $text = $langs->trans(
"OverAllSupplierProposals");
454 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
457 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
459 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
460 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
461 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
462 $boxstat .=
'</div>';
468 if (isModEnabled(
"supplier_order")) {
470 $tmp = $object->getOutstandingOrders(
'supplier');
471 $outstandingOpened = $tmp[
'opened'];
472 $outstandingTotal = $tmp[
'total_ht'];
473 $outstandingTotalIncTax = $tmp[
'total_ttc'];
474 $text = $langs->trans(
"OverAllOrders");
475 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
478 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
480 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
481 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
482 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
483 $boxstat .=
'</div>';
489 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
491 $tmp = $object->getOutstandingBills(
'supplier');
492 $outstandingOpened = $tmp[
'opened'];
493 $outstandingTotal = $tmp[
'total_ht'];
494 $outstandingTotalIncTax = $tmp[
'total_ttc'];
496 $text = $langs->trans(
"OverAllInvoices");
497 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
500 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
502 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
503 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
504 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
505 $boxstat .=
'</div>';
511 $text = $langs->trans(
"CurrentOutstandingBill");
512 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
515 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
517 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
518 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
519 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
520 $boxstat .=
'</div>';
525 $tmp = $object->getOutstandingBills(
'supplier', 1);
526 $outstandingOpenedLate = $tmp[
'opened'];
527 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
528 $text = $langs->trans(
"CurrentOutstandingBillLate");
529 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
532 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
534 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
535 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
536 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
537 $boxstat .=
'</div>';
545 $parameters = array();
546 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters, $object, $action);
547 if (empty($reshook)) {
548 $boxstat .= $hookmanager->resPrint;
551 $boxstat .=
'</td></tr>';
552 $boxstat .=
'</table>';
553 $boxstat .=
'</div>';
558 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
564 if (isModEnabled(
"product") || isModEnabled(
"service")) {
565 $langs->load(
"products");
567 $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,';
568 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
569 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
570 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
571 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
572 $sql .=
' AND pfp.fk_soc = '.((int) $object->id);
573 $sql .= $db->order(
'pfp.tms',
'desc');
574 $sql .= $db->plimit($MAXLIST);
576 $query = $db->query($sql);
581 $num = $db->num_rows($query);
583 print
'<div class="div-table-responsive-no-min">';
584 print
'<table class="noborder centpercent lastrecordtable">';
585 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
586 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
587 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>';
588 print
'</a></td></tr>';
592 $productstatic =
new Product($db);
594 while ($objp = $db->fetch_object($query)) {
595 $productstatic->id = $objp->rowid;
596 $productstatic->ref = $objp->ref;
597 $productstatic->label = $objp->label;
598 $productstatic->type = $objp->fk_product_type;
599 $productstatic->entity = $objp->entity;
600 $productstatic->status = $objp->status;
601 $productstatic->status_buy = $objp->status_buy;
602 $productstatic->status_batch = $objp->status_batch;
604 print
'<tr class="oddeven">';
605 print
'<td class="nowrap">';
606 print $productstatic->getNomUrl(1);
611 print
'<td class="maxwidthonsmartphone">';
615 print
'<td class="right">';
617 if (isset($objp->price)) {
618 print
'<span class="amount">'.price($objp->price).
'</span>';
619 if ($objp->quantity > 1) {
621 print $objp->quantity;
639 if ($user->hasRight(
"supplier_proposal",
"lire")) {
640 $langs->loadLangs(array(
"supplier_proposal"));
642 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
643 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
644 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
645 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
646 $sql .=
" ORDER BY p.date_valid DESC";
647 $sql .= $db->plimit($MAXLIST);
649 $resql = $db->query($sql);
652 $num = $db->num_rows($resql);
655 print
'<div class="div-table-responsive-no-min">';
656 print
'<table class="noborder centpercent lastrecordtable">';
658 print
'<tr class="liste_titre">';
659 print
'<td colspan="3">';
660 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
661 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>';
663 print
'</tr></table>';
667 while ($i < $num && $i <= $MAXLIST) {
668 $obj = $db->fetch_object($resql);
670 print
'<tr class="oddeven">';
671 print
'<td class="nowrap">';
672 $proposalstatic->id = $obj->rowid;
673 $proposalstatic->ref = $obj->ref;
674 $proposalstatic->total_ht = $obj->total_ht;
675 $proposalstatic->total_tva = $obj->total_tva;
676 $proposalstatic->total_ttc = $obj->total_ttc;
677 print $proposalstatic->getNomUrl(1);
679 print
'<td class="center" width="80">';
686 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
693 print
"</table></div>";
705 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
708 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
709 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
710 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
711 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
712 $sql2 .=
' WHERE c.fk_soc = s.rowid';
713 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
714 $sql2 .=
' AND s.rowid = '.((int) $object->id);
716 if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
720 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).
")";
722 $sql2 .=
" AND c.billed = 0";
726 $resql2 = $db->query($sql2);
728 $orders2invoice = $db->num_rows($resql2);
735 $sql =
"SELECT count(p.rowid) as total";
736 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
737 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
738 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
739 $resql = $db->query($sql);
741 $object_count = $db->fetch_object($resql);
742 $num = $object_count->total;
745 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
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 $sql .=
" ORDER BY p.date_commande DESC";
750 $sql .= $db->plimit($MAXLIST);
752 $resql = $db->query($sql);
757 print
'<div class="div-table-responsive-no-min">';
758 print
'<table class="noborder centpercent lastrecordtable">';
760 print
'<tr class="liste_titre">';
761 print
'<td colspan="4">';
762 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
763 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>';
764 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>';
765 print
'</tr></table>';
769 while ($i < $num && $i < $MAXLIST) {
770 $obj = $db->fetch_object($resql);
772 $orderstatic->id = $obj->rowid;
773 $orderstatic->ref = $obj->ref;
774 $orderstatic->total_ht = $obj->total_ht;
775 $orderstatic->total_tva = $obj->total_tva;
776 $orderstatic->total_ttc = $obj->total_ttc;
777 $orderstatic->date = $db->jdate($obj->date);
779 print
'<tr class="oddeven">';
780 print
'<td class="nowraponall">';
781 print $orderstatic->getNomUrl(1);
783 print
'<td class="center" width="80">';
788 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
789 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
796 print
"</table></div>";
807 $langs->load(
'bills');
810 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
812 $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,';
813 $sql .=
' SUM(pf.amount) as am';
814 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
815 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
816 $sql .=
' WHERE f.fk_soc = '.((int) $object->id);
817 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
818 $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';
819 $sql .=
' ORDER BY f.datef DESC';
820 $resql = $db->query($sql);
823 $num = $db->num_rows($resql);
825 print
'<div class="div-table-responsive-no-min">';
826 print
'<table class="noborder centpercent lastrecordtable">';
828 print
'<tr class="liste_titre">';
829 print
'<td colspan="4">';
830 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
831 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>';
832 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>';
833 print
'</tr></table>';
837 while ($i < min($num, $MAXLIST)) {
838 $obj = $db->fetch_object($resql);
840 $facturestatic->id = $obj->rowid;
841 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
842 $facturestatic->ref_supplier = $obj->ref_supplier;
843 $facturestatic->libelle = $obj->label;
844 $facturestatic->label = $obj->label;
845 $facturestatic->total_ht = $obj->total_ht;
846 $facturestatic->total_tva = $obj->total_tva;
847 $facturestatic->total_ttc = $obj->total_ttc;
848 $facturestatic->date = $db->jdate($obj->df);
850 print
'<tr class="oddeven">';
851 print
'<td class="tdoverflowmax200">';
852 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
853 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
854 print ($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
856 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
857 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
858 print
'<td class="right nowrap">';
859 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
866 print
'</table></div>';
874 $parameters = array();
875 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
879 print $hookmanager->resPrint;
882 print
'</div></div>';
883 print
'<div class="clearboth"></div>';
891 print
'<div class="tabsAction">';
893 $parameters = array();
894 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
896 if (empty($reshook)) {
897 if ($object->status != 1) {
898 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
901 if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
902 $langs->load(
"supplier_proposal");
903 if ($object->status == 1) {
904 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id,
'');
906 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
910 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
911 $langs->load(
"orders");
912 if ($object->status == 1) {
913 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.newToken().
'&socid='.$object->id,
'');
915 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
919 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
920 if (!empty($orders2invoice) && $orders2invoice > 0) {
921 if ($object->status == 1) {
923 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1',
'');
925 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
928 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
932 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
933 $langs->load(
"bills");
934 if ($object->status == 1) {
935 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id,
'');
937 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
942 if (isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
943 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
944 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id,
'');
946 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
954 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
957 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
960 if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
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_todo($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='')
Show html area with actions to do.
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).
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
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.
load_fiche_titre($titre, $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).
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_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.
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='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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.