dolibarr/htdocs/compta/facture/info.php

145 lines
4.7 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
2017-12-26 12:13:35 +01:00
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
2004-07-21 17:34:35 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2004-07-21 17:34:35 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2004-07-21 17:34:35 +02:00
*/
/**
* \file htdocs/compta/facture/info.php
* \ingroup facture
* \brief Page des informations d'une facture
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
2022-08-29 11:24:26 +02:00
if (isModEnabled('project')) {
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2017-12-26 12:13:35 +01:00
}
2004-07-21 17:34:35 +02:00
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills'));
$id = GETPOST("facid", "int");
$ref = GETPOST("ref", 'alpha');
2016-12-11 13:16:21 +01:00
2021-03-18 20:27:36 +01:00
$object = new Facture($db);
2021-03-18 20:27:36 +01:00
$extrafields = new ExtraFields($db);
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
2022-05-21 17:27:52 +02:00
$ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
2021-03-18 20:27:36 +01:00
}
// Security check
if ($user->socid) {
$socid = $user->socid;
}
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
2022-06-27 10:45:04 +02:00
$result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
2021-03-18 20:27:36 +01:00
2022-10-21 23:49:45 +02:00
$usercancreate = $user->hasRight("facture", "creer");
2004-07-21 17:34:35 +02:00
/*
2009-08-05 20:22:40 +02:00
* View
2004-07-21 17:34:35 +02:00
*/
2017-08-22 10:02:45 +02:00
$form = new Form($db);
$title = $object->ref." - ".$langs->trans('Info');
2021-03-18 20:27:36 +01:00
$help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $help_url);
2009-08-05 20:22:40 +02:00
if (empty($object->id)) {
$langs->load('errors');
2021-10-31 14:02:34 +01:00
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
llxFooter();
exit;
}
2016-12-11 13:16:21 +01:00
$object->fetch_thirdparty();
2016-12-11 13:16:21 +01:00
$object->info($object->id);
2016-12-11 13:16:21 +01:00
$head = facture_prepare_head($object);
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill');
2004-07-21 17:34:35 +02:00
2022-05-22 17:09:08 +02:00
$totalpaid = $object->getSommePaiement();
2016-12-11 13:16:21 +01:00
// Invoice content
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2016-12-11 13:16:21 +01:00
$morehtmlref = '<div class="refidno">';
2016-12-11 13:16:21 +01:00
// Ref customer
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
2016-12-11 13:16:21 +01:00
// Thirdparty
2022-10-21 15:08:54 +02:00
$morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
2016-12-11 13:16:21 +01:00
// Project
2022-08-29 11:24:26 +02:00
if (isModEnabled('project')) {
2016-12-11 13:16:21 +01:00
$langs->load("projects");
2022-10-21 15:08:54 +02:00
$morehtmlref .= '<br>';
2022-10-22 02:32:43 +02:00
if (0) {
2022-10-21 23:49:45 +02:00
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
2021-02-23 21:09:01 +01:00
if ($action != 'classify') {
2022-10-21 23:49:45 +02:00
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
2016-12-11 13:16:21 +01:00
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
2016-12-11 13:16:21 +01:00
} else {
if (!empty($object->fk_project)) {
2016-12-11 13:16:21 +01:00
$proj = new Project($db);
$proj->fetch($object->fk_project);
2022-10-21 23:49:45 +02:00
$morehtmlref .= $proj->getNomUrl(1);
2021-10-29 09:40:38 +02:00
if ($proj->title) {
2022-10-24 01:25:50 +02:00
$morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
2021-10-29 09:40:38 +02:00
}
2016-12-11 13:16:21 +01:00
}
}
}
$morehtmlref .= '</div>';
2016-12-11 13:16:21 +01:00
2022-05-22 17:09:08 +02:00
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
2016-12-11 13:16:21 +01:00
2018-12-02 14:31:45 +01:00
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
2016-12-11 13:16:21 +01:00
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
2004-07-21 17:34:35 +02:00
2022-05-21 22:55:11 +02:00
print '<table class="centpercent"><tr><td>';
2016-12-11 13:16:21 +01:00
dol_print_object_info($object);
print '</td></tr></table>';
2004-07-21 17:34:35 +02:00
print '</div>';
2004-07-21 17:34:35 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2016-12-11 13:16:21 +01:00
2018-07-30 17:28:44 +02:00
// End of page
llxFooter();
$db->close();