dolibarr 21.0.0-alpha
note-rec.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';
33require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
34
35if (isModEnabled('project')) {
36 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
37}
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
39
40
41// Load translation files required by the page
42$langs->loadLangs(array('companies', 'bills'));
43
44$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
45$ref = GETPOST('ref', 'alpha');
46$socid = GETPOSTINT('socid');
47$action = GETPOST('action', 'aZ09');
48
49$objecttype = 'facture_rec';
50if ($action == "create" || $action == "add") {
51 $objecttype = '';
52}
53
54$object = new FactureRec($db);
55// Load object
56if ($id > 0 || !empty($ref)) {
57 $object->fetch($id, $ref);
58}
59
60$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php
61
62// Security check
63$socid = 0;
64if ($user->socid) {
65 $socid = $user->socid;
66}
67$hookmanager->initHooks(array('invoicenote'));
68
69$result = restrictedArea($user, 'facture', $object->id, $objecttype);
70
71$usercancreate = $user->hasRight("facture", "creer");
72
73
74/*
75 * Actions
76 */
77
78$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
79if ($reshook < 0) {
80 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
81}
82if (empty($reshook)) {
83 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
84}
85
86
87
88/*
89 * View
90 */
91
92$form = new Form($db);
93
94if (empty($object->id)) {
95 $title = $object->ref." - ".$langs->trans('Notes');
96} else {
97 $title = $langs->trans('Notes');
98}
99$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
100
101llxHeader('', $title, $helpurl);
102
103if (empty($object->id)) {
104 $langs->load('errors');
105 echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
106 llxFooter();
107 exit;
108}
109
110
111if ($id > 0 ) {
112 $object = new FactureRec($db);
113 $object->fetch($id);
114
115 $object->fetch_thirdparty();
116
117 $head = invoice_rec_prepare_head($object);
118
119 $totalpaid = $object->getSommePaiement();
120
121 print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
122
123 // Object card
124 // ------------------------------------------------------------
125 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
126
127 $morehtmlref = '';
128 if ($action != 'editref') {
129 $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, 0, '', '', 0, 2);
130 } else {
131 $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, 0, 'string');
132 }
133
134 $morehtmlref .= '<div class="refidno">';
135 // Thirdparty
136 $morehtmlref .= $object->thirdparty->getNomUrl(1);
137 // Project
138 if (isModEnabled('project')) {
139 $langs->load("projects");
140 $morehtmlref .= '<br>';
141 if (0) {
142 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
143 if ($action != 'classify') {
144 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
145 }
146 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
147 } else {
148 if (!empty($object->fk_project)) {
149 $proj = new Project($db);
150 $proj->fetch($object->fk_project);
151 $morehtmlref .= $proj->getNomUrl(1);
152 if ($proj->title) {
153 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
154 }
155 }
156 }
157 }
158 $morehtmlref .= '</div>';
159
160 $morehtmlstatus = '';
161
162 dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlstatus);
163
164 print '<div class="fichecenter">';
165 print '<div class="underbanner clearboth"></div>';
166
167
168 $cssclass = "titlefield";
169
170 // Help of substitution key
171 $dateexample = dol_now();
172 if (!empty($object->frequency) && !empty($object->date_when)) {
173 $dateexample = $object->date_when;
174 }
175
176 $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
177
178 $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m') . ')';
179 $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%m') . ')';
180 $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%m') . ')';
181 $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B') . ')';
182 $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%B') . ')';
183 $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B') . ')';
184 $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y') . ')';
185 $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%Y') . ')';
186 $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y') . ')';
187 // Only on template invoices
188 $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(($object->date_when ? $object->date_when : dol_now()), 'dayhour') . ')';
189 $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree(($object->date_when ? $object->date_when : dol_now()), $object->frequency, $object->unit_frequency), 'dayhour') . ')';
190 $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $object->nb_gen_done;
191 $substitutionarray['__INVOICE_COUNTER_MAX__'] = $object->nb_gen_max;
192
193 $htmltext = '<i>' . $langs->trans("FollowingConstantsWillBeSubstituted") . ':<br>';
194 foreach ($substitutionarray as $key => $val) {
195 $htmltext .= $key . ' = ' . $langs->trans($val) . '<br>';
196 }
197 $htmltext .= '</i>';
198
199 $textNotePub = $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic', 2);
200 $textNotePrive = $form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
201 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
202
203 print dol_get_fiche_end();
204}
205
206// End of page
207llxFooter();
208$db->close();
$id
Definition account.php:39
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage invoice templates.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
llxFooter()
Footer empty.
Definition document.php:107
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
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.