dolibarr 21.0.0-beta
note-rec.php
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
34require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture-rec.class.php';
35
36if (isModEnabled('project')) {
37 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38}
39
48// Load translation files required by the page
49$langs->loadLangs(array('companies', 'bills'));
50
51$id = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('facid')); // For backward compatibility
52$ref = GETPOST('ref', 'alpha');
53$socid = GETPOSTINT('socid');
54$action = GETPOST('action', 'aZ09');
55
56$objecttype = 'facture_rec';
57if ($action == "create" || $action == "add") {
58 $objecttype = '';
59}
60
62// Load object
63if (($id > 0 || $title) && $action != 'create' && $action != 'add') {
64 $ret = $object->fetch($id, $title);
65 if (! $ret) {
66 setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
67 }
68}
69
70$permissionnote = $user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"); // Used by the include of actions_setnotes.inc.php
71
72// Security check
73$socid = 0;
74if ($user->socid) {
75 $socid = $user->socid;
76}
77$hookmanager->initHooks(array('invoicenote'));
78
79$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype);
80
81$usercancreate = $user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer");
82
83
84/*
85 * Actions
86 */
87
88$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
89if ($reshook < 0) {
90 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
91}
92if (empty($reshook)) {
93 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
94}
95
96
97
98/*
99 * View
100 */
101
102$form = new Form($db);
103
104if (empty($object->id)) {
105 $title = $object->ref." - ".$langs->trans('Notes');
106} else {
107 $title = $langs->trans('Notes');
108}
109$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
110
111llxHeader('', $title, $helpurl);
112
113if (empty($object->id)) {
114 $langs->load('errors');
115 echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
116 llxFooter();
117 exit;
118}
119
120
121if ($id > 0 ) {
123 $object->fetch($id);
124
125 $object->fetch_thirdparty();
126
127 $head = supplier_invoice_rec_prepare_head($object);
128
129 $totalpaid = $object->getSommePaiement();
130
131 print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill');
132
133 // Object card
134 // ------------------------------------------------------------
135 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
136
137 $morehtmlref = '';
138 if ($action != 'editref') {
139 $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, 0, '', '', 0, 2);
140 } else {
141 $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, 0, 'string');
142 }
143 $morehtmlref .= '<div class="refidno">';
144 //Ref supplier
145 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, '', 'string', '', 0, 1);
146 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', null, null, '', 1);
147 // Thirdparty
148 $morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
149
150 // Project
151 if (isModEnabled('project')) {
152 $langs->load("projects");
153 $morehtmlref .= '<br>';
154 if (0) {
155 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
156 if ($action != 'classify') {
157 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
158 }
159 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
160 } else {
161 if (!empty($object->fk_project)) {
162 $proj = new Project($db);
163 $proj->fetch($object->fk_project);
164 $morehtmlref .= $proj->getNomUrl(1);
165 if ($proj->title) {
166 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
167 }
168 }
169 }
170 }
171 $morehtmlref .= '</div>';
172
173 $morehtmlstatus = '';
174
175 dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlstatus);
176
177 print '<div class="fichecenter">';
178 print '<div class="underbanner clearboth"></div>';
179
180
181 $cssclass = "titlefield";
182
183 $dateexample = dol_now();
184 if (!empty($object->frequency) && !empty($object->date_when)) {
185 $dateexample = $object->date_when;
186 }
187
188 $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
189
190 $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m') . ')';
191 $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%m') . ')';
192 $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%m') . ')';
193 $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B') . ')';
194 $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%B') . ')';
195 $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B') . ')';
196 $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y') . ')';
197 $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date($dateexample, '%Y') . ')';
198 $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice") . ' (' . $langs->trans("Example") . ': ' . dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y') . ')';
199 // Only on template invoices
200 $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') . ')';
201 $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') . ')';
202 $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $object->nb_gen_done;
203 $substitutionarray['__INVOICE_COUNTER_MAX__'] = $object->nb_gen_max;
204
205 $htmltext = '<i>' . $langs->trans("FollowingConstantsWillBeSubstituted") . ':<br>';
206 foreach ($substitutionarray as $key => $val) {
207 $htmltext .= $key . ' = ' . $langs->trans($val) . '<br>';
208 }
209 $htmltext .= '</i>';
210
211 $textNotePub = $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic', 2);
212 $textNotePrive = $form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
213
214 include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
215
216 print dol_get_fiche_end();
217}
218
219// End of page
220llxFooter();
221$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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.
supplier_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.