dolibarr 20.0.0
note.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
33if (isModEnabled('project')) {
34 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
35}
36
37// Load translation files required by the page
38$langs->loadLangs(array('companies', 'bills'));
39
40$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
41$ref = GETPOST('ref', 'alpha');
42$socid = GETPOSTINT('socid');
43$action = GETPOST('action', 'aZ09');
44
45$object = new Facture($db);
46// Load object
47if ($id > 0 || !empty($ref)) {
48 $object->fetch($id, $ref, '', '', (getDolGlobalString('INVOICE_USE_SITUATION') ? $conf->global->INVOICE_USE_SITUATION : 0));
49}
50
51$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
52
53// Security check
54$socid = 0;
55if ($user->socid) {
56 $socid = $user->socid;
57}
58$hookmanager->initHooks(array('invoicenote'));
59
60$result = restrictedArea($user, 'facture', $id, '');
61
62$usercancreate = $user->hasRight("facture", "creer");
63
64
65/*
66 * Actions
67 */
68
69$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
70if ($reshook < 0) {
71 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
72}
73if (empty($reshook)) {
74 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
75}
76
77
78
79/*
80 * View
81 */
82
83$form = new Form($db);
84
85if (empty($object->id)) {
86 $title = $object->ref." - ".$langs->trans('Notes');
87} else {
88 $title = $langs->trans('Notes');
89}
90$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
91
92llxHeader('', $title, $helpurl);
93
94if (empty($object->id)) {
95 $langs->load('errors');
96 echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
97 llxFooter();
98 exit;
99}
100
101
102if ($id > 0 || !empty($ref)) {
103 $object = new Facture($db);
104 $object->fetch($id, $ref);
105
106 $object->fetch_thirdparty();
107
108 $head = facture_prepare_head($object);
109
110 $totalpaid = $object->getSommePaiement();
111
112 print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
113
114 // Invoice content
115
116 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
117
118 $morehtmlref = '<div class="refidno">';
119 // Ref customer
120 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_customer, $object, 0, 'string', '', 0, 1);
121 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
122 // Thirdparty
123 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
124 // Project
125 if (isModEnabled('project')) {
126 $langs->load("projects");
127 $morehtmlref .= '<br>';
128 if (0) {
129 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
130 if ($action != 'classify') {
131 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
132 }
133 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
134 } else {
135 if (!empty($object->fk_project)) {
136 $proj = new Project($db);
137 $proj->fetch($object->fk_project);
138 $morehtmlref .= $proj->getNomUrl(1);
139 if ($proj->title) {
140 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
141 }
142 }
143 }
144 }
145 $morehtmlref .= '</div>';
146
147 $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
148
149 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0);
150
151 print '<div class="fichecenter">';
152 print '<div class="underbanner clearboth"></div>';
153
154
155 $cssclass = "titlefield";
156 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
157
158 print dol_get_fiche_end();
159}
160
161// End of page
162llxFooter();
163$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
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.