dolibarr  18.0.0-alpha
info.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
32 if (isModEnabled('project')) {
33  include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 }
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('companies', 'bills'));
38 
39 $id = GETPOST("facid", "int");
40 $ref = GETPOST("ref", 'alpha');
41 
42 $object = new Facture($db);
43 
44 $extrafields = new ExtraFields($db);
45 
46 // Fetch optionals attributes and labels
47 $extrafields->fetch_name_optionals_label($object->table_element);
48 
49 // Load object
50 if ($id > 0 || !empty($ref)) {
51  $ret = $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
52 }
53 
54 // Security check
55 if ($user->socid) {
56  $socid = $user->socid;
57 }
58 $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
59 
60 $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
61 
62 $usercancreate = $user->hasRight("facture", "creer");
63 
64 
65 /*
66  * View
67  */
68 
69 $form = new Form($db);
70 
71 $title = $object->ref." - ".$langs->trans('Info');
72 $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
73 
74 llxHeader('', $title, $help_url);
75 
76 if (empty($object->id)) {
77  $langs->load('errors');
78  echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
79  llxFooter();
80  exit;
81 }
82 
83 $object->fetch_thirdparty();
84 
85 $object->info($object->id);
86 
87 $head = facture_prepare_head($object);
88 print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill');
89 
90 $totalpaid = $object->getSommePaiement();
91 
92 // Invoice content
93 
94 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
95 
96 $morehtmlref = '<div class="refidno">';
97 // Ref customer
98 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
99 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
100 // Thirdparty
101 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
102 // Project
103 if (isModEnabled('project')) {
104  $langs->load("projects");
105  $morehtmlref .= '<br>';
106  if (0) {
107  $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
108  if ($action != 'classify') {
109  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
110  }
111  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
112  } else {
113  if (!empty($object->fk_project)) {
114  $proj = new Project($db);
115  $proj->fetch($object->fk_project);
116  $morehtmlref .= $proj->getNomUrl(1);
117  if ($proj->title) {
118  $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
119  }
120  }
121  }
122 }
123 $morehtmlref .= '</div>';
124 
125 $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
126 
127 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
128 
129 print '<div class="fichecenter">';
130 print '<div class="underbanner clearboth"></div>';
131 
132 print '<br>';
133 
134 print '<table class="centpercent"><tr><td>';
135 dol_print_object_info($object);
136 print '</td></tr></table>';
137 
138 print '</div>';
139 
140 print dol_get_fiche_end();
141 
142 // End of page
143 llxFooter();
144 $db->close();
Facture\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: facture.class.php:407
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
Project
Class to manage projects.
Definition: project.class.php:35
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:530
facture_prepare_head
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
Definition: invoice.lib.php:36
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
Facture
Class to manage invoices.
Definition: facture.class.php:60
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4539
dol_banner_tab
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.
Definition: functions.lib.php:2097
$help_url
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.
Definition: agenda.php:118
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4025
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1873
restrictedArea
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.
Definition: security.lib.php:341
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11317
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2069
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:147
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_print_object_info
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
Definition: functions2.lib.php:205