dolibarr 21.0.0-beta
card.php
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
4 * Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
6 * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 *
24 */
30require '../../main.inc.php';
31
32require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
34
43// Load translation files required by the page
44$langs->loadLangs(array("bills", "accountancy", "trips"));
45
46$action = GETPOST('action', 'aZ09');
47$cancel = GETPOST('cancel', 'alpha');
48$backtopage = GETPOST('backtopage', 'alpha');
49
50$codeventil = GETPOSTINT('codeventil');
51$id = GETPOSTINT('id');
52
53// Security check
54if (!isModEnabled('accounting')) {
56}
57if ($user->socid > 0) {
59}
60if (!$user->hasRight('accounting', 'bind', 'write')) {
62}
63
64
65/*
66 * Actions
67 */
68
69if ($action == 'ventil' && $user->hasRight('accounting', 'bind', 'write')) {
70 if (!$cancel) {
71 if ($codeventil < 0) {
72 $codeventil = 0;
73 }
74
75 $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
76 $sql .= " SET fk_code_ventilation = ".((int) $codeventil);
77 $sql .= " WHERE rowid = ".((int) $id);
78
79 $resql = $db->query($sql);
80 if (!$resql) {
81 setEventMessages($db->lasterror(), null, 'errors');
82 } else {
83 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
84 if ($backtopage) {
85 header("Location: ".$backtopage);
86 exit();
87 }
88 }
89 } else {
90 header("Location: ./lines.php");
91 exit();
92 }
93}
94
95
96
97/*
98 * View
99 */
100$help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
101
102llxHeader("", $langs->trans('FicheVentilation'), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-expensereport page-card');
103
104if ($cancel == $langs->trans("Cancel")) {
105 $action = '';
106}
107
108// Create
109$form = new Form($db);
110$expensereport_static = new ExpenseReport($db);
111$formaccounting = new FormAccounting($db);
112
113if (!empty($id)) {
114 $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
115 $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
116 $sql .= " aa.account_number, aa.label";
117 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
118 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees";
119 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
120 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
121 $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = ".((int) $id);
122 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
123
124 dol_syslog("/accounting/expensereport/card.php", LOG_DEBUG);
125 $result = $db->query($sql);
126
127 if ($result) {
128 $num_lines = $db->num_rows($result);
129 $i = 0;
130
131 if ($num_lines) {
132 $objp = $db->fetch_object($result);
133
134 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="post">'."\n";
135 print '<input type="hidden" name="token" value="'.newToken().'">';
136 print '<input type="hidden" name="action" value="ventil">';
137 print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
138
139 print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_accountancy');
140
141 print dol_get_fiche_head();
142
143 print '<table class="border centpercent">';
144
145 // Ref
146 print '<tr><td class="titlefield">'.$langs->trans("ExpenseReport").'</td>';
147 $expensereport_static->ref = $objp->ref;
148 $expensereport_static->id = $objp->erid;
149 print '<td>'.$expensereport_static->getNomUrl(1).'</td>';
150 print '</tr>';
151
152 print '<tr><td>'.$langs->trans("Line").'</td>';
153 print '<td>'.stripslashes(nl2br($objp->rowid)).'</td></tr>';
154
155 print '<tr><td>'.$langs->trans("Description").'</td>';
156 print '<td>'.stripslashes(nl2br($objp->comments)).'</td></tr>';
157
158 print '<tr><td>'.$langs->trans("TypeFees").'</td>';
159 print '<td>'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
160
161 print '<tr><td>'.$langs->trans("Account").'</td><td>';
162 print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
163 print '</td></tr>';
164 print '</table>';
165
166 print dol_get_fiche_end();
167
168 print '<div class="center">';
169 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
170 print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
171 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
172 print '</div>';
173
174 print '</form>';
175 } else {
176 print "Error";
177 }
178 } else {
179 print "Error";
180 }
181} else {
182 print "Error ID incorrect";
183}
184
185// End of page
186llxFooter();
187$db->close();
$id
Definition account.php:48
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 Trips and Expenses.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.