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') {
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->rights->societe->creer) {
112 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_supplier_id',
'int'));
118 if ($action ==
'setmode' && $user->rights->societe->creer) {
120 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_supplier_id',
'int'));
127 if ($action ==
'setbankaccount' && $user->rights->societe->creer) {
129 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
136 if ($action ==
'setsupplier_order_min_amount') {
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') {
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>';
416 $boxstat .=
'<div class="box box-halfright">';
417 $boxstat .=
'<table summary="'.dol_escape_htmltag($langs->trans(
"DolibarrStateBoard")).
'" class="border boxtable boxtablenobottom boxtablenotop" width="100%">';
418 $boxstat .=
'<tr class="impair nohover"><td colspan="2" class="tdboxstats nohover">';
422 $tmp = $object->getOutstandingProposals(
'supplier');
423 $outstandingOpened = $tmp[
'opened'];
424 $outstandingTotal = $tmp[
'total_ht'];
425 $outstandingTotalIncTax = $tmp[
'total_ttc'];
426 $text = $langs->trans(
"OverAllSupplierProposals");
427 $link = DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->id;
430 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
432 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
433 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
434 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
435 $boxstat .=
'</div>';
441 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
443 $tmp = $object->getOutstandingOrders(
'supplier');
444 $outstandingOpened = $tmp[
'opened'];
445 $outstandingTotal = $tmp[
'total_ht'];
446 $outstandingTotalIncTax = $tmp[
'total_ttc'];
447 $text = $langs->trans(
"OverAllOrders");
448 $link = DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id;
451 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
453 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
454 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
455 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
456 $boxstat .=
'</div>';
462 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_invoice")) {
464 $tmp = $object->getOutstandingBills(
'supplier');
465 $outstandingOpened = $tmp[
'opened'];
466 $outstandingTotal = $tmp[
'total_ht'];
467 $outstandingTotalIncTax = $tmp[
'total_ttc'];
469 $text = $langs->trans(
"OverAllInvoices");
470 $link = DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->id;
473 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
475 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
476 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
477 $boxstat .=
'<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).
'</span>';
478 $boxstat .=
'</div>';
484 $text = $langs->trans(
"CurrentOutstandingBill");
485 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
488 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
490 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
491 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
492 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpened > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
493 $boxstat .=
'</div>';
498 $tmp = $object->getOutstandingBills(
'supplier', 1);
499 $outstandingOpenedLate = $tmp[
'opened'];
500 if ($outstandingOpened != $outstandingOpenedLate && !empty($outstandingOpenedLate)) {
501 $text = $langs->trans(
"CurrentOutstandingBillLate");
502 $link = DOL_URL_ROOT.
'/fourn/recap-fourn.php?socid='.$object->id;
505 $boxstat .=
'<a href="'.$link.
'" class="boxstatsindicator thumbstat nobold nounderline">';
507 $boxstat .=
'<div class="boxstats" title="'.dol_escape_htmltag($text).
'">';
508 $boxstat .=
'<span class="boxstatstext">'.img_object(
"", $icon).
' <span>'.$text.
'</span></span><br>';
509 $boxstat .=
'<span class="boxstatsindicator'.($outstandingOpenedLate > 0 ?
' amountremaintopay' :
'').
'">'.
price($outstandingOpenedLate, 1, $langs, 1, -1, -1, $conf->currency).$warn.
'</span>';
510 $boxstat .=
'</div>';
519 $reshook = $hookmanager->executeHooks(
'addMoreBoxStatsSupplier',
$parameters, $object, $action);
520 if (empty($reshook)) {
521 $boxstat .= $hookmanager->resPrint;
524 $boxstat .=
'</td></tr>';
525 $boxstat .=
'</table>';
526 $boxstat .=
'</div>';
531 $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
548 $langs->load(
"products");
550 $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,';
551 $sql .=
' pfp.tms, pfp.ref_fourn as supplier_ref, pfp.price, pfp.quantity, pfp.unitprice';
552 $sql .=
' FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price as pfp';
553 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = pfp.fk_product";
554 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
555 $sql .=
' AND pfp.fk_soc = '.((int) $object->id);
556 $sql .= $db->order(
'pfp.tms',
'desc');
557 $sql .= $db->plimit($MAXLIST);
559 $query = $db->query($sql);
564 $num = $db->num_rows($query);
566 print
'<div class="div-table-responsive-no-min">';
567 print
'<table class="noborder centpercent lastrecordtable">';
568 print
'<tr class="liste_titre'.(($num == 0) ?
' nobottom' :
'').
'">';
569 print
'<td colspan="3">'.$langs->trans(
"ProductsAndServices").
'</td><td class="right">';
570 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>';
571 print
'</a></td></tr>';
575 $productstatic =
new Product($db);
577 while ($objp = $db->fetch_object($query)) {
578 $productstatic->id = $objp->rowid;
579 $productstatic->ref = $objp->ref;
580 $productstatic->label = $objp->label;
581 $productstatic->type = $objp->fk_product_type;
582 $productstatic->entity = $objp->entity;
583 $productstatic->status = $objp->status;
584 $productstatic->status_buy = $objp->status_buy;
585 $productstatic->status_batch = $objp->status_batch;
587 print
'<tr class="oddeven">';
588 print
'<td class="nowrap">';
589 print $productstatic->getNomUrl(1);
594 print
'<td class="maxwidthonsmartphone">';
598 print
'<td class="right">';
600 if (isset($objp->price)) {
601 print
'<span class="amount">'.price($objp->price).
'</span>';
602 if ($objp->quantity > 1) {
604 print $objp->quantity;
622 if (!empty($user->rights->supplier_proposal->lire)) {
623 $langs->loadLangs(array(
"supplier_proposal"));
625 $sql =
"SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
626 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as p ";
627 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
628 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
629 $sql .=
" ORDER BY p.date_valid DESC";
630 $sql .= $db->plimit($MAXLIST);
632 $resql = $db->query($sql);
635 $num = $db->num_rows(
$resql);
638 print
'<div class="div-table-responsive-no-min">';
639 print
'<table class="noborder centpercent lastrecordtable">';
641 print
'<tr class="liste_titre">';
642 print
'<td colspan="3">';
643 print
'<table class="nobordernopadding centpercent"><tr><td>'.$langs->trans(
"LastSupplierProposals", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
644 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>';
645 print
'<td width="20px" class="right"><a href="'.DOL_URL_ROOT.
'/supplier_proposal/stats/index.php?mode=supplier&socid='.$object->id.
'">'.
img_picto($langs->trans(
"Statistics"),
'stats').
'</a></td>';
646 print
'</tr></table>';
650 while ($i < $num && $i <= $MAXLIST) {
651 $obj = $db->fetch_object(
$resql);
653 print
'<tr class="oddeven">';
654 print
'<td class="nowrap">';
655 $proposalstatic->id = $obj->rowid;
656 $proposalstatic->ref = $obj->ref;
657 $proposalstatic->total_ht = $obj->total_ht;
658 $proposalstatic->total_tva = $obj->total_tva;
659 $proposalstatic->total_ttc = $obj->total_ttc;
660 print $proposalstatic->getNomUrl(1);
662 print
'<td class="center" width="80">';
669 print
'<td class="right" class="nowrap">'.$proposalstatic->LibStatut($obj->fk_statut, 5).
'</td>';
676 print
"</table></div>";
688 if ($user->rights->fournisseur->commande->lire) {
691 $sql2 =
'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_supplier,';
692 $sql2 .=
' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut';
693 $sql2 .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
694 $sql2 .=
', '.MAIN_DB_PREFIX.
'commande_fournisseur as c';
695 $sql2 .=
' WHERE c.fk_soc = s.rowid';
696 $sql2 .=
" AND c.entity IN (".getEntity(
'commande_fournisseur').
")";
697 $sql2 .=
' AND s.rowid = '.((int) $object->id);
699 if (empty($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS)) {
703 $sql2 .=
" AND c.fk_statut IN (".$db->sanitize($conf->global->SUPPLIER_ORDER_TO_INVOICE_STATUS).
")";
705 $sql2 .=
" AND c.billed = 0";
709 $resql2 = $db->query($sql2);
711 $orders2invoice = $db->num_rows($resql2);
718 $sql =
"SELECT count(p.rowid) as total";
719 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
720 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
721 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
722 $resql = $db->query($sql);
724 $object_count = $db->fetch_object(
$resql);
725 $num = $object_count->total;
728 $sql =
"SELECT p.rowid,p.ref, p.date_commande as date, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc";
729 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as p";
730 $sql .=
" WHERE p.fk_soc = ".((int) $object->id);
731 $sql .=
" AND p.entity IN (".getEntity(
'commande_fournisseur').
")";
732 $sql .=
" ORDER BY p.date_commande DESC";
733 $sql .= $db->plimit($MAXLIST);
735 $resql = $db->query($sql);
740 print
'<div class="div-table-responsive-no-min">';
741 print
'<table class="noborder centpercent lastrecordtable">';
743 print
'<tr class="liste_titre">';
744 print
'<td colspan="4">';
745 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
"LastSupplierOrders", ($num < $MAXLIST ?
"" : $MAXLIST)).
'</td>';
746 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>';
747 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>';
748 print
'</tr></table>';
752 while ($i < $num && $i < $MAXLIST) {
753 $obj = $db->fetch_object(
$resql);
755 $orderstatic->id = $obj->rowid;
756 $orderstatic->ref = $obj->ref;
757 $orderstatic->total_ht = $obj->total_ht;
758 $orderstatic->total_tva = $obj->total_tva;
759 $orderstatic->total_ttc = $obj->total_ttc;
760 $orderstatic->date = $db->jdate($obj->date);
762 print
'<tr class="oddeven">';
763 print
'<td class="nowraponall">';
764 print $orderstatic->getNomUrl(1);
766 print
'<td class="center" width="80">';
771 print
'<td class="right nowrap"><span class="amount">'.price($orderstatic->total_ttc).
'</span></td>';
772 print
'<td class="right" class="nowrap">'.$orderstatic->LibStatut($obj->fk_statut, 5).
'</td>';
779 print
"</table></div>";
790 $langs->load(
'bills');
793 if ($user->rights->fournisseur->facture->lire) {
795 $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,';
796 $sql .=
' SUM(pf.amount) as am';
797 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn as f';
798 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn';
799 $sql .=
' WHERE f.fk_soc = '.((int) $object->id);
800 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn').
")";
801 $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';
802 $sql .=
' ORDER BY f.datef DESC';
803 $resql = $db->query($sql);
806 $num = $db->num_rows(
$resql);
808 print
'<div class="div-table-responsive-no-min">';
809 print
'<table class="noborder centpercent lastrecordtable">';
811 print
'<tr class="liste_titre">';
812 print
'<td colspan="4">';
813 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'LastSuppliersBills', ($num <= $MAXLIST ?
"" : $MAXLIST)).
'</td>';
814 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>';
815 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>';
816 print
'</tr></table>';
820 while ($i < min($num, $MAXLIST)) {
821 $obj = $db->fetch_object(
$resql);
823 $facturestatic->id = $obj->rowid;
824 $facturestatic->ref = ($obj->ref ? $obj->ref : $obj->rowid);
825 $facturestatic->ref_supplier = $obj->ref_supplier;
826 $facturestatic->libelle = $obj->label;
827 $facturestatic->label = $obj->label;
828 $facturestatic->total_ht = $obj->total_ht;
829 $facturestatic->total_tva = $obj->total_tva;
830 $facturestatic->total_ttc = $obj->total_ttc;
831 $facturestatic->date = $db->jdate($obj->df);
833 print
'<tr class="oddeven">';
834 print
'<td class="tdoverflowmax200">';
835 print
'<span class="nowraponall">'.$facturestatic->getNomUrl(1).
'</span>';
836 print $obj->ref_supplier ?
' - '.$obj->ref_supplier :
'';
837 print ($obj->label ?
' - ' :
'').dol_trunc($obj->label, 14);
839 print
'<td class="center nowrap">'.dol_print_date($facturestatic->date,
'day').
'</td>';
840 print
'<td class="right nowrap"><span class="amount">'.price($facturestatic->total_ttc).
'</span></td>';
841 print
'<td class="right nowrap">';
842 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $obj->am);
849 print
'</table></div>';
856 print
'</div></div>';
857 print
'<div style="clear:both"></div>';
865 print
'<div class="tabsAction">';
868 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
870 if (empty($reshook)) {
871 if ($object->status != 1) {
872 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'ThirdPartyIsClosed'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
875 if (
isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->creer)) {
876 $langs->load(
"supplier_proposal");
877 if ($object->status == 1) {
878 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierProposal'),
'default', DOL_URL_ROOT.
'/supplier_proposal/card.php?action=create&socid='.$object->id,
'');
880 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierProposal'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
884 if ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer')) {
885 $langs->load(
"orders");
886 if ($object->status == 1) {
887 print
dolGetButtonAction(
'', $langs->trans(
'AddSupplierOrderShort'),
'default', DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&token='.
newToken().
'&socid='.$object->id,
'');
889 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddSupplierOrderShort'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
893 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
894 if (!empty($orders2invoice) && $orders2invoice > 0) {
895 if ($object->status == 1) {
897 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisSupplier'),
'default', DOL_URL_ROOT.
'/fourn/commande/list.php?socid='.$object->id.
'&search_billed=0&autoselectall=1',
'');
899 print
dolGetButtonAction(
'', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
902 print
dolGetButtonAction($langs->trans(
"NoOrdersToInvoice").
' ('.$langs->trans(
"WithReceptionFinished").
')', $langs->trans(
'CreateInvoiceForThisCustomer'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
906 if ($user->hasRight(
'fournisseur',
'facture',
'creer') || $user->hasRight(
'supplier_invoice',
'creer')) {
907 $langs->load(
"bills");
908 if ($object->status == 1) {
909 print
dolGetButtonAction(
'', $langs->trans(
'AddBill'),
'default', DOL_URL_ROOT.
'/fourn/facture/card.php?action=create&socid='.$object->id,
'');
911 print
dolGetButtonAction($langs->trans(
'ThirdPartyIsClosed'), $langs->trans(
'AddBill'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
916 if (
isModEnabled(
'agenda') && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1) {
917 if ($user->rights->agenda->myactions->create) {
918 print
dolGetButtonAction(
'', $langs->trans(
'AddAction'),
'default', DOL_URL_ROOT.
'/comm/action/card.php?action=create&socid='.$object->id,
'');
920 print
dolGetButtonAction($langs->trans(
'NotAllowed'), $langs->trans(
'AddAction'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
928 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
931 show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
934 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.