dolibarr  7.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-2017 Alexandre Spangaro <aspangaro@zendsi.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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
29 require '../../main.inc.php';
30 
31 // Class
32 require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
34 
35 // Langs
36 $langs->load("bills");
37 $langs->load("accountancy");
38 $langs->load("trips");
39 
40 $action = GETPOST('action', 'alpha');
41 $cancel = GETPOST('cancel', 'alpha');
42 $backtopage = GETPOST('backtopage', 'alpha');
43 
44 $codeventil = GETPOST('codeventil');
45 $id = GETPOST('id');
46 
47 // Security check
48 if ($user->societe_id > 0)
50 
51 
52 /*
53  * Actions
54  */
55 
56 if ($action == 'ventil' && $user->rights->accounting->bind->write)
57 {
58  if (! $cancel)
59  {
60  if ($codeventil < 0) $codeventil = 0;
61 
62  $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det";
63  $sql .= " SET fk_code_ventilation = " . $codeventil;
64  $sql .= " WHERE rowid = " . $id;
65 
66  $resql = $db->query($sql);
67  if (! $resql) {
68  setEventMessages($db->lasterror(), null, 'errors');
69  }
70  else
71  {
72  setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
73  if ($backtopage)
74  {
75  header("Location: ".$backtopage);
76  exit();
77  }
78  }
79  } else {
80  header("Location: ./lines.php");
81  exit();
82  }
83 }
84 
85 
86 
87 /*
88  * View
89  */
90 llxHeader("", $langs->trans('FicheVentilation'));
91 
92 if ($cancel == $langs->trans("Cancel")) {
93  $action = '';
94 }
95 
96 // Create
97 $form = new Form($db);
98 $expensereport_static = new ExpenseReport($db);
99 $formaccounting = new FormAccounting($db);
100 
101 if (! empty($id)) {
102  $sql = "SELECT er.ref, er.rowid as facid, erd.fk_c_type_fees, erd.comments, erd.rowid, erd.fk_code_ventilation,";
103  $sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
104  $sql .= " aa.account_number, aa.label";
105  $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
106  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees";
107  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON erd.fk_code_ventilation = aa.rowid";
108  $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport as er ON er.rowid = erd.fk_expensereport";
109  $sql .= " WHERE er.fk_statut > 0 AND erd.rowid = " . $id;
110  $sql .= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy
111 
112  dol_syslog("/accounting/expensereport/card.php sql=" . $sql, LOG_DEBUG);
113  $result = $db->query($sql);
114 
115  if ($result) {
116  $num_lines = $db->num_rows($result);
117  $i = 0;
118 
119  if ($num_lines) {
120  $objp = $db->fetch_object($result);
121 
122  print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '" method="post">' . "\n";
123  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
124  print '<input type="hidden" name="action" value="ventil">';
125  print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
126 
127  print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_setup');
128 
129  dol_fiche_head();
130 
131  print '<table class="border" width="100%">';
132 
133  // Ref
134  print '<tr><td class="titlefield">' . $langs->trans("ExpenseReport") . '</td>';
135  $expensereport_static->ref = $objp->ref;
136  $expensereport_static->id = $objp->erid;
137  print '<td>' . $expensereport_static->getNomUrl(1) . '</td>';
138  print '</tr>';
139 
140  print '<tr><td>' . $langs->trans("Line") . '</td>';
141  print '<td>' . stripslashes(nl2br($objp->rowid)) . '</td></tr>';
142 
143  print '<tr><td>' . $langs->trans("Description") . '</td>';
144  print '<td>' . stripslashes(nl2br($objp->comments)) . '</td></tr>';
145 
146  print '<tr><td>' . $langs->trans("TypeFees") . '</td>';
147  print '<td>' . ($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))) . '</td>';
148 
149  print '<tr><td>' . $langs->trans("Account") . '</td><td>';
150  print $formaccounting->select_account($objp->fk_code_ventilation, 'codeventil', 1);
151  print '</td></tr>';
152  print '</table>';
153 
154  dol_fiche_end();
155 
156  print '<div class="center">';
157  print '<input class="button" type="submit" value="' . $langs->trans("Save") . '">';
158  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
159  print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
160  print '</div>';
161 
162  print '</form>';
163  } else {
164  print "Error";
165  }
166  } else {
167  print "Error";
168  }
169 } else {
170  print "Error ID incorrect";
171 }
172 
173 llxFooter();
174 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
Class to manage Trips and Expenses.
print
Draft customers invoices.
Definition: index.php:91
Class to manage generation of HTML components for accounting management.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013