33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48 $langs->loadLangs(array(
57 $action =
GETPOST(
'action',
'aZ09');
58 $cancel =
GETPOST(
'cancel',
'alpha');
65 $result =
restrictedArea($user,
'societe&fournisseur', $id,
'&societe',
'',
'rowid');
71 $extrafields->fetch_name_optionals_label($object->table_element);
74 $hookmanager->initHooks(array(
'thirdpartysupplier',
'globalcard'));
77 $result =
restrictedArea($user,
'societe', $id,
'&societe',
'',
'fk_soc',
'rowid', 0);
79 if ($object->id > 0) {
80 if (!($object->fournisseur > 0) || empty($user->rights->fournisseur->lire)) {
91 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
96 if (empty($reshook)) {
101 if ($action ==
'setsupplieraccountancycode' && $user->hasRight(
'societe',
'creer')) {
102 $result = $object->fetch($id);
103 $object->code_compta_fournisseur =
GETPOST(
"supplieraccountancycode");
104 $result = $object->update($object->id, $user, 1, 0, 1);
110 if ($action ==
'setconditions' && $user->hasRight(
'societe',
'creer')) {
112 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
118 if ($action ==
'setmode' && $user->hasRight(
'societe',
'creer')) {
120 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
127 if ($action ==
'setbankaccount' && $user->hasRight(
'societe',
'creer')) {
129 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
136 if ($action ==
'setsupplier_order_min_amount' && $user->hasRight(
'societe',
'creer')) {
138 $object->supplier_order_min_amount =
price2num(
GETPOST(
'supplier_order_min_amount',
'alpha'));
139 $result = $object->update($object->id, $user);
145 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'creer')) {
151 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
158 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
166 $action =
'edit_extras';
176 $contactstatic =
new Contact($db);
179 if ($id > 0 && empty($object->id)) {
181 $res = $object->fetch($id);
182 if ($object->id <= 0) {
188 if ($object->id > 0) {
189 $title = $langs->trans(
"ThirdParty").
" - ".$langs->trans(
'Supplier');
190 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
191 $title = $object->name.
" - ".$langs->trans(
'Supplier');
201 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), -1,
'company');
203 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
205 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
207 print
'<div class="fichecenter"><div class="fichehalfleft">';
209 print
'<div class="underbanner clearboth"></div>';
210 print
'<table class="border centpercent tableforfield">';
213 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
214 print $object->getTypeUrl(1);
217 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
218 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
221 if ($object->fournisseur) {
223 print
'<td class="titlefield">'.$langs->trans(
"SupplierCode").
'</td><td>';
225 $tmpcheck = $object->check_codefournisseur();
226 if ($tmpcheck != 0 && $tmpcheck != -5) {
227 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
232 $langs->load(
'compta');
235 print
$form->editfieldkey(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
237 print
$form->editfieldval(
"SupplierAccountancyCode",
'supplieraccountancycode', $object->code_compta_fournisseur, $object, $user->hasRight(
'societe',
'creer'));
244 print
'<td class="titlefield">';
245 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
247 print
yn($object->tva_assuj);
252 if ($mysoc->useLocalTax(1)) {
253 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
254 print
yn($object->localtax1_assuj);
257 if ($mysoc->useLocalTax(2)) {
258 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
259 print
yn($object->localtax2_assuj);
264 print
'<tr><td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
269 $langs->load(
'bills');
272 print
'<table width="100%" class="nobordernopadding"><tr><td>';
273 print $langs->trans(
'PaymentConditions');
275 if (($action !=
'editconditions') && $user->hasRight(
'societe',
'creer')) {
276 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>';
278 print
'</tr></table>';
280 if ($action ==
'editconditions') {
281 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'cond_reglement_supplier_id', 1);
283 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->cond_reglement_supplier_id,
'none');
289 print
'<tr><td class="nowrap">';
290 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
291 print $langs->trans(
'PaymentMode');
293 if (($action !=
'editmode') && $user->hasRight(
'societe',
'creer')) {
294 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>';
296 print
'</tr></table>';
298 if ($action ==
'editmode') {
299 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'mode_reglement_supplier_id',
'DBIT', 1, 1);
301 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->mode_reglement_supplier_id,
'none');
308 print
'<tr><td class="nowrap">';
309 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
310 print $langs->trans(
'PaymentBankAccount');
312 if (($action !=
'editbankaccount') && $user->hasRight(
'societe',
'creer')) {
313 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>';
315 print
'</tr></table>';
317 if ($action ==
'editbankaccount') {
318 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'fk_account', 1);
320 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->fk_account,
'none');
327 print
'<tr><td class="nowrap">';
328 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
329 print $langs->trans(
"CustomerRelativeDiscountShort");
330 print
'<td><td class="right">';
331 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
332 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>';
334 print
'</td></tr></table>';
335 print
'</td><td>'.($object->remise_supplier_percent ?
'<a href="'.DOL_URL_ROOT.
'/comm/remise.php?id='.$object->id.
'">'.$object->remise_supplier_percent.
'%</a>' :
'').
'</td>';
339 print
'<tr><td class="nowrap">';
340 print
'<table width="100%" class="nobordernopadding">';
341 print
'<tr><td class="nowrap">';
342 print $langs->trans(
"CustomerAbsoluteDiscountShort");
343 print
'<td><td class="right">';
344 if ($user->hasRight(
'societe',
'creer') && !$user->socid > 0) {
345 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>';
347 print
'</td></tr></table>';
350 $amount_discount = $object->getAvailableDiscounts(
'',
'', 0, 1);
351 if ($amount_discount < 0) {
354 if ($amount_discount > 0) {
355 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>';
361 if (((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) {
362 print
'<tr class="nowrap">';
364 print
$form->editfieldkey(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer);
366 $limit_field_type = (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ?
'numeric' :
'amount';
367 print
$form->editfieldval(
"OrderMinAmount",
'supplier_order_min_amount', $object->supplier_order_min_amount, $object, $user->rights->societe->creer, $limit_field_type, ($object->supplier_order_min_amount !=
'' ?
price($object->supplier_order_min_amount) :
''));
374 $langs->load(
"categories");
375 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
377 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
382 $parameters = array(
'socid'=>$object->id,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
383 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
387 $langs->load(
"members");
388 $langs->load(
"users");
389 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
392 $result = $adh->fetch(
'',
'', $object->id);
394 $adh->ref = $adh->getFullName($langs);
395 print $adh->getNomUrl(1);
397 print $langs->trans(
"ThirdpartyNotLinkedToMember");
406 print
'</div><div class="fichehalfright">';
411 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
413 print
'<div class="underbanner underbanner-before-box clearboth"></div>';
417 $boxstat .=
'<div class="box box-halfright">';
418 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
419 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
423 $tmp = $object->getOutstandingProposals(
'supplier');
424 $outstandingOpened = $tmp[
'opened'];
425 $outstandingTotal = $tmp[
'total_ht'];
426 $outstandingTotalIncTax = $tmp[
'total_ttc'];
427 $text = $langs->trans(
"OverAllSupplierProposals");
428 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
431 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
433 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
434 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
435 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
436 $boxstat .=
'</div>';
442 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
444 $tmp = $object->getOutstandingOrders(
'supplier');
445 $outstandingOpened = $tmp[
'opened'];
446 $outstandingTotal = $tmp[
'total_ht'];
447 $outstandingTotalIncTax = $tmp[
'total_ttc'];
448 $text = $langs->trans(
"OverAllOrders");
449 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
452 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
454 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
455 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
456 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
457 $boxstat .=
'</div>';
463 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_invoice")) {
465 $tmp = $object->getOutstandingBills(
'supplier');
466 $outstandingOpened = $tmp[
'opened'];
467 $outstandingTotal = $tmp[
'total_ht'];
468 $outstandingTotalIncTax = $tmp[
'total_ttc'];
470 $text = $langs->trans(
"OverAllInvoices");
471 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
474 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
476 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
477 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
478 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
479 $boxstat .=
'</div>';
485 $text = $langs->trans(
"CurrentOutstandingBill");
486 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
489 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
491 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
492 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
493 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
494 $boxstat .=
'</div>';
499 $tmp = $object->getOutstandingBills(
'supplier', 1);
500 $outstandingOpenedLate = $tmp[
'opened'];
501 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
502 $text = $langs->trans(
"CurrentOutstandingBillLate");
503 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
506 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
508 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
509 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
510 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
511 $boxstat .=
'</div>';
520 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier',
$parameters, $object, $action);
521 if (empty($reshook)) {
522 $boxstat .= $hookmanager->resPrint;
525 $boxstat .=
'</td></tr>';
526 $boxstat .=
'</table>';
527 $boxstat .=
'</div>';
532 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
539 $langs->load(
"products");
541 $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,';
542 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
543 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
544 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
545 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
546 $sql .=
' AND pfp.fk_soc = '.((int) $object->id);
547 $sql .= $db->order(
'pfp.tms',
'desc');
548 $sql .= $db->plimit($MAXLIST);
550 $query = $db->query($sql);
555 $num = $db->num_rows($query);
557 print
'<div class="div-table-responsive-no-min">';
558 print
'<table class="noborder centpercent lastrecordtable">';
559 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
560 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
561 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>';
562 print
'</a></td></tr>';
566 $productstatic =
new Product($db);
568 while ($objp = $db->fetch_object($query)) {
569 $productstatic->id = $objp->rowid;
570 $productstatic->ref = $objp->ref;
571 $productstatic->label = $objp->label;
572 $productstatic->type = $objp->fk_product_type;
573 $productstatic->entity = $objp->entity;
574 $productstatic->status = $objp->status;
575 $productstatic->status_buy = $objp->status_buy;
576 $productstatic->status_batch = $objp->status_batch;
578 print
'<tr class="oddeven">';
579 print
'<td class="nowrap">';
580 print $productstatic->getNomUrl(1);
585 print
'<td class="maxwidthonsmartphone">';
589 print
'<td class="right">';
591 if (isset($objp->price)) {
592 print
'<span class="amount">'.price($objp->price).
'</span>';
593 if ($objp->quantity > 1) {
595 print $objp->quantity;
613 if (!empty($user->rights->supplier_proposal->lire)) {
614 $langs->loadLangs(array(
"supplier_proposal"));
616 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
617 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
618 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
619 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
620 $sql .=
" ORDER BY p.date_valid DESC";
621 $sql .= $db->plimit($MAXLIST);
623 $resql = $db->query($sql);
626 $num = $db->num_rows(
$resql);
629 print
'<div class="div-table-responsive-no-min">';
630 print
'<table class="noborder centpercent lastrecordtable">';
632 print
'<tr class="liste_titre">';
633 print
'<td colspan="3">';
634 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
635 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>';
637 print
'</tr></table>';
641 while ($i < $num && $i <= $MAXLIST) {
642 $obj = $db->fetch_object(
$resql);
644 print
'<tr class="oddeven">';
645 print
'<td class="nowrap">';
646 $proposalstatic->id = $obj->rowid;
647 $proposalstatic->ref = $obj->ref;
648 $proposalstatic->total_ht = $obj->total_ht;
649 $proposalstatic->total_tva = $obj->total_tva;
650 $proposalstatic->total_ttc = $obj->total_ttc;
651 print $proposalstatic->getNomUrl(1);
653 print
'<td class="center" width="80">';
660 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
667 print
"</table></div>";
679 if ($user->rights->fournisseur->commande->lire) {
682 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
683 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
684 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
685 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
686 $sql2 .=
' WHERE c.fk_soc = s.rowid';
687 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
688 $sql2 .=
' AND s.rowid = '.((int) $object->id);
690 if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
694 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).
")";
696 $sql2 .=
" AND c.billed = 0";
700 $resql2 = $db->query($sql2);
702 $orders2invoice = $db->num_rows($resql2);
709 $sql =
"SELECT count(p.rowid) as total";
710 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
711 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
712 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
713 $resql = $db->query($sql);
715 $object_count = $db->fetch_object(
$resql);
716 $num = $object_count->total;
719 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
720 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
721 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
722 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
723 $sql .=
" ORDER BY p.date_commande DESC";
724 $sql .= $db->plimit($MAXLIST);
726 $resql = $db->query($sql);
731 print
'<div class="div-table-responsive-no-min">';
732 print
'<table class="noborder centpercent lastrecordtable">';
734 print
'<tr class="liste_titre">';
735 print
'<td colspan="4">';
736 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
737 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>';
738 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>';
739 print
'</tr></table>';
743 while ($i < $num && $i < $MAXLIST) {
744 $obj = $db->fetch_object(
$resql);
746 $orderstatic->id = $obj->rowid;
747 $orderstatic->ref = $obj->ref;
748 $orderstatic->total_ht = $obj->total_ht;
749 $orderstatic->total_tva = $obj->total_tva;
750 $orderstatic->total_ttc = $obj->total_ttc;
751 $orderstatic->date = $db->jdate($obj->date);
753 print
'<tr class="oddeven">';
754 print
'<td class="nowraponall">';
755 print $orderstatic->getNomUrl(1);
757 print
'<td class="center" width="80">';
762 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
763 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
770 print
"</table></div>";
781 $langs->load(
'bills');
784 if ($user->rights->fournisseur->facture->lire) {
786 $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,';
787 $sql .=
' SUM(pf.amount) as am';
788 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
789 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
790 $sql .=
' WHERE f.fk_soc = '.((int) $object->id);
791 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
792 $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';
793 $sql .=
' ORDER BY f.datef DESC';
794 $resql = $db->query($sql);
797 $num = $db->num_rows(
$resql);
799 print
'<div class="div-table-responsive-no-min">';
800 print
'<table class="noborder centpercent lastrecordtable">';
802 print
'<tr class="liste_titre">';
803 print
'<td colspan="4">';
804 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
805 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>';
806 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>';
807 print
'</tr></table>';
811 while ($i < min($num, $MAXLIST)) {
812 $obj = $db->fetch_object(
$resql);
814 $facturestatic->id = $obj->rowid;
815 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
816 $facturestatic->ref_supplier = $obj->ref_supplier;
817 $facturestatic->libelle = $obj->label;
818 $facturestatic->label = $obj->label;
819 $facturestatic->total_ht = $obj->total_ht;
820 $facturestatic->total_tva = $obj->total_tva;
821 $facturestatic->total_ttc = $obj->total_ttc;
822 $facturestatic->date = $db->jdate($obj->df);
824 print
'<tr class="oddeven">';
825 print
'<td class="tdoverflowmax200">';
826 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
827 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
828 print ($obj->label ?
' - ' :
'').dol_trunc($obj->label, 14);
830 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
831 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
832 print
'<td class="right nowrap">';
833 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
840 print
'</table></div>';
847 print
'</div></div>';
848 print
'<div style="clear:both"></div>';
856 print
'<div class="tabsAction">';
859 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
861 if (empty($reshook)) {
862 if ($object->status != 1) {
863 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
866 if (
isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->creer)) {
867 $langs->load(
"supplier_proposal");
868 if ($object->status == 1) {
869 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id,
'');
871 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
875 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
876 $langs->load(
"orders");
877 if ($object->status == 1) {
878 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.$object->id,
'');
880 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
884 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
885 if (!empty($orders2invoice) && $orders2invoice > 0) {
886 if ($object->status == 1) {
888 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1',
'');
890 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
893 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
897 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
898 $langs->load(
"bills");
899 if ($object->status == 1) {
900 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id,
'');
902 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
907 if (
isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
908 if ($user->rights->agenda->myactions->create) {
909 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id,
'');
911 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
919 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
922 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
925 if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB)) {
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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)
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_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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.