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);
111 $action =
'editsupplieraccountancycode';
115 if ($action ==
'settva_intra' && $user->hasRight(
'societe',
'creer')) {
116 $result = $object->fetch($id);
117 $object->tva_intra =
GETPOST(
"tva_intra");
118 $result = $object->update($object->id, $user, 1, 0, 0);
124 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
126 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
132 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
134 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
141 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
143 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
150 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
152 $object->supplier_order_min_amount =
price2num(
GETPOST(
'supplier_order_min_amount',
'alpha'));
153 $result = $object->update($object->id, $user);
159 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
162 $object->oldcopy =
dol_clone($object, 2);
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)) {
195 $res = $object->fetch($id);
196 if ($object->id <= 0) {
202if ($object->id > 0) {
203 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
204 if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
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>';
228 print $object->getTypeUrl(1);
232 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
235 if ($object->fournisseur) {
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'));
261 print
yn($object->tva_assuj);
266 if ($mysoc->useLocalTax(1)) {
267 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
268 print
yn($object->localtax1_assuj);
271 if ($mysoc->useLocalTax(2)) {
272 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
273 print
yn($object->localtax2_assuj);
279 print
'<td class="titlefield">';
280 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
282 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
' disabled>';
287 print
'<tr><td class="nowrap">';
290 print $form->editfieldkey(
"VATIntra",
'tva_intra', $object->tva_intra, $object, $user->hasRight(
'societe',
'creer'));
292 print $form->editfieldval(
"VATIntra",
'tva_intra', $vattoshow, $object, $user->hasRight(
'societe',
'creer'),
'string', $object->tva_intra,
null,
null,
'', 1,
'',
'id',
'auto', array(
'valuealreadyhtmlescaped'=>1));
296 $langs->load(
'bills');
297 $form =
new Form($db);
299 print
'<table width="100%" class="nobordernopadding"><tr><td>';
300 print $langs->trans(
'PaymentConditions');
302 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
303 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>';
305 print
'</tr></table>';
307 if ($action ==
'editconditions') {
308 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
310 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'none');
316 print
'<tr><td class="nowrap">';
317 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
318 print $langs->trans(
'PaymentMode');
320 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
321 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>';
323 print
'</tr></table>';
325 if ($action ==
'editmode') {
326 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
328 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'none');
333 if (isModEnabled(
"banque")) {
335 print
'<tr><td class="nowrap">';
336 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
337 print $langs->trans(
'PaymentBankAccount');
339 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
340 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>';
342 print
'</tr></table>';
344 if ($action ==
'editbankaccount') {
345 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'fk_account', 1);
347 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'none');
354 print
'<tr><td class="nowrap">';
355 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
356 print $langs->trans(
"CustomerRelativeDiscountShort");
357 print
'<td><td class="right">';
358 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
359 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>';
361 print
'</td></tr></table>';
362 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
366 print
'<tr><td class="nowrap">';
367 print
'<table width="100%" class="nobordernopadding">';
368 print
'<tr><td class="nowrap">';
369 print $langs->trans(
"CustomerAbsoluteDiscountShort");
370 print
'<td><td class="right">';
371 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
372 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>';
374 print
'</td></tr></table>';
377 $amount_discount = $object->getAvailableDiscounts(
'',
'', 0, 1);
378 if ($amount_discount < 0) {
381 if ($amount_discount > 0) {
382 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>';
388 if (isModEnabled(
"supplier_order") &&
getDolGlobalString(
'ORDER_MANAGE_MIN_AMOUNT')) {
389 print
'<tr class="nowrap">';
391 print $form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->hasRight(
"societe",
"creer"));
393 $limit_field_type = (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE')) ?
'numeric' :
'amount';
394 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) :
''));
400 if (isModEnabled(
'categorie')) {
401 $langs->load(
"categories");
402 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
404 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
409 $parameters = array(
'socid'=>$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
410 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
413 if (isModEnabled(
'adherent')) {
414 $langs->load(
"members");
415 $langs->load(
"users");
416 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
419 $result = $adh->fetch(
'',
'', $object->id);
421 $adh->ref = $adh->getFullName($langs);
422 print $adh->getNomUrl(1);
424 print $langs->trans(
"ThirdpartyNotLinkedToMember");
433 print
'</div><div class="fichehalfright">';
438 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
440 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
444 $boxstat .=
'<div class="box box-halfright">';
445 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
446 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
448 if (isModEnabled(
'supplier_proposal')) {
450 $tmp = $object->getOutstandingProposals(
'supplier');
451 $outstandingOpened = $tmp[
'opened'];
452 $outstandingTotal = $tmp[
'total_ht'];
453 $outstandingTotalIncTax = $tmp[
'total_ttc'];
454 $text = $langs->trans(
"OverAllSupplierProposals");
455 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
458 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
460 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
461 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
462 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
463 $boxstat .=
'</div>';
469 if (isModEnabled(
"supplier_order")) {
471 $tmp = $object->getOutstandingOrders(
'supplier');
472 $outstandingOpened = $tmp[
'opened'];
473 $outstandingTotal = $tmp[
'total_ht'];
474 $outstandingTotalIncTax = $tmp[
'total_ttc'];
475 $text = $langs->trans(
"OverAllOrders");
476 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
479 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
481 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
482 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
483 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
484 $boxstat .=
'</div>';
490 if (isModEnabled(
"supplier_invoice") && ($user->hasRight(
'fournisseur',
'facture',
'lire') || $user->hasRight(
'supplier_invoice',
'read'))) {
492 $tmp = $object->getOutstandingBills(
'supplier');
493 $outstandingOpened = $tmp[
'opened'];
494 $outstandingTotal = $tmp[
'total_ht'];
495 $outstandingTotalIncTax = $tmp[
'total_ttc'];
497 $text = $langs->trans(
"OverAllInvoices");
498 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
501 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
503 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
504 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
505 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
506 $boxstat .=
'</div>';
512 $text = $langs->trans(
"CurrentOutstandingBill");
513 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
516 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
518 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
519 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
520 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
521 $boxstat .=
'</div>';
526 $tmp = $object->getOutstandingBills(
'supplier', 1);
527 $outstandingOpenedLate = $tmp[
'opened'];
528 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
529 $text = $langs->trans(
"CurrentOutstandingBillLate");
530 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
533 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
535 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
536 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
537 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
538 $boxstat .=
'</div>';
546 $parameters = array();
547 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier', $parameters, $object, $action);
548 if (empty($reshook)) {
549 $boxstat .= $hookmanager->resPrint;
552 $boxstat .=
'</td></tr>';
553 $boxstat .=
'</table>';
554 $boxstat .=
'</div>';
559 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
565 if (isModEnabled(
"product") || isModEnabled(
"service")) {
566 $langs->load(
"products");
568 $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,';
569 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
570 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
571 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
572 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
573 $sql .=
' AND pfp.fk_soc = '.((int) $object->id);
574 $sql .= $db->order(
'pfp.tms',
'desc');
575 $sql .= $db->plimit($MAXLIST);
577 $query = $db->query($sql);
582 $num = $db->num_rows($query);
584 print
'<div class="div-table-responsive-no-min">';
585 print
'<table class="noborder centpercent lastrecordtable">';
586 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
587 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
588 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>';
589 print
'</a></td></tr>';
593 $productstatic =
new Product($db);
595 while ($objp = $db->fetch_object($query)) {
596 $productstatic->id = $objp->rowid;
597 $productstatic->ref = $objp->ref;
598 $productstatic->label = $objp->label;
599 $productstatic->type = $objp->fk_product_type;
600 $productstatic->entity = $objp->entity;
601 $productstatic->status = $objp->status;
602 $productstatic->status_buy = $objp->status_buy;
603 $productstatic->status_batch = $objp->status_batch;
605 print
'<tr class="oddeven">';
606 print
'<td class="nowrap">';
607 print $productstatic->getNomUrl(1);
612 print
'<td class="maxwidthonsmartphone">';
616 print
'<td class="right">';
618 if (isset($objp->price)) {
619 print
'<span class="amount">'.price($objp->price).
'</span>';
620 if ($objp->quantity > 1) {
622 print $objp->quantity;
640 if ($user->hasRight(
"supplier_proposal",
"lire")) {
641 $langs->loadLangs(array(
"supplier_proposal"));
643 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
644 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
645 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
646 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
647 $sql .=
" ORDER BY p.date_valid DESC";
648 $sql .= $db->plimit($MAXLIST);
650 $resql = $db->query($sql);
653 $num = $db->num_rows($resql);
656 print
'<div class="div-table-responsive-no-min">';
657 print
'<table class="noborder centpercent lastrecordtable">';
659 print
'<tr class="liste_titre">';
660 print
'<td colspan="3">';
661 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
662 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>';
664 print
'</tr></table>';
668 while ($i < $num && $i <= $MAXLIST) {
669 $obj = $db->fetch_object($resql);
671 print
'<tr class="oddeven">';
672 print
'<td class="nowrap">';
673 $proposalstatic->id = $obj->rowid;
674 $proposalstatic->ref = $obj->ref;
675 $proposalstatic->total_ht = $obj->total_ht;
676 $proposalstatic->total_tva = $obj->total_tva;
677 $proposalstatic->total_ttc = $obj->total_ttc;
678 print $proposalstatic->getNomUrl(1);
680 print
'<td class="center" width="80">';
687 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
694 print
"</table></div>";
706 if ($user->hasRight(
"fournisseur",
"commande",
"lire")) {
709 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
710 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
711 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
712 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
713 $sql2 .=
' WHERE c.fk_soc = s.rowid';
714 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
715 $sql2 .=
' AND s.rowid = '.((int) $object->id);
721 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).
")";
723 $sql2 .=
" AND c.billed = 0";
727 $resql2 = $db->query($sql2);
729 $orders2invoice = $db->num_rows($resql2);
736 $sql =
"SELECT count(p.rowid) as total";
737 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
738 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
739 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
740 $resql = $db->query($sql);
742 $object_count = $db->fetch_object($resql);
743 $num = $object_count->total;
746 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
747 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
748 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
749 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
750 $sql .=
" ORDER BY p.date_commande DESC";
751 $sql .= $db->plimit($MAXLIST);
753 $resql = $db->query($sql);
758 print
'<div class="div-table-responsive-no-min">';
759 print
'<table class="noborder centpercent lastrecordtable">';
761 print
'<tr class="liste_titre">';
762 print
'<td colspan="4">';
763 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
764 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>';
765 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>';
766 print
'</tr></table>';
770 while ($i < $num && $i < $MAXLIST) {
771 $obj = $db->fetch_object($resql);
773 $orderstatic->id = $obj->rowid;
774 $orderstatic->ref = $obj->ref;
775 $orderstatic->total_ht = $obj->total_ht;
776 $orderstatic->total_tva = $obj->total_tva;
777 $orderstatic->total_ttc = $obj->total_ttc;
778 $orderstatic->date = $db->jdate($obj->date);
780 print
'<tr class="oddeven">';
781 print
'<td class="nowraponall">';
782 print $orderstatic->getNomUrl(1);
784 print
'<td class="center" width="80">';
789 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
790 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
797 print
"</table></div>";
808 $langs->load(
'bills');
811 if ($user->hasRight(
'fournisseur',
'facture',
'lire')) {
813 $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,';
814 $sql .=
' SUM(pf.amount) as am';
815 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
816 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
817 $sql .=
' WHERE f.fk_soc = '.((int) $object->id);
818 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
819 $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';
820 $sql .=
' ORDER BY f.datef DESC';
821 $resql = $db->query($sql);
824 $num = $db->num_rows($resql);
826 print
'<div class="div-table-responsive-no-min">';
827 print
'<table class="noborder centpercent lastrecordtable">';
829 print
'<tr class="liste_titre">';
830 print
'<td colspan="4">';
831 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
832 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>';
833 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>';
834 print
'</tr></table>';
838 while ($i < min($num, $MAXLIST)) {
839 $obj = $db->fetch_object($resql);
841 $facturestatic->id = $obj->rowid;
842 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
843 $facturestatic->ref_supplier = $obj->ref_supplier;
844 $facturestatic->libelle = $obj->label;
845 $facturestatic->label = $obj->label;
846 $facturestatic->total_ht = $obj->total_ht;
847 $facturestatic->total_tva = $obj->total_tva;
848 $facturestatic->total_ttc = $obj->total_ttc;
849 $facturestatic->date = $db->jdate($obj->df);
851 print
'<tr class="oddeven">';
852 print
'<td class="tdoverflowmax200">';
853 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
854 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
855 print($obj->label ?
' - ' :
'').
dol_trunc($obj->label, 14);
857 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
858 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
859 print
'<td class="right nowrap">';
860 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
867 print
'</table></div>';
875 $parameters = array();
876 $reshook = $hookmanager->executeHooks(
'addMoreRecentObjects', $parameters, $object, $action);
880 print $hookmanager->resPrint;
883 print
'</div></div>';
884 print
'<div class="clearboth"></div>';
892 print
'<div class="tabsAction">';
894 $parameters = array();
895 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
897 if (empty($reshook)) {
898 if ($object->status != 1) {
899 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
902 if (isModEnabled(
'supplier_proposal') && $user->hasRight(
"supplier_proposal",
"creer")) {
903 $langs->load(
"supplier_proposal");
904 if ($object->status == 1) {
905 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id,
'');
907 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
911 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
912 $langs->load(
"orders");
913 if ($object->status == 1) {
914 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.newToken().
'&socid='.$object->id,
'');
916 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
920 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
921 if (!empty($orders2invoice) && $orders2invoice > 0) {
922 if ($object->status == 1) {
924 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1',
'');
926 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
929 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
933 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
934 $langs->load(
"bills");
935 if ($object->status == 1) {
936 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id,
'');
938 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
943 if (isModEnabled(
'agenda') &&
getDolGlobalString(
'MAIN_REPEATTASKONEACHTAB') && $object->status == 1) {
944 if ($user->hasRight(
"agenda",
"myactions",
"create")) {
945 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id,
'');
947 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
958 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.