dolibarr  7.0.0-beta
categ.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2013 Charles-Fr BENKE <charles.fr@benke.fr>
6  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
7  * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
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 <http://www.gnu.org/licenses/>.
21  */
22 
29 require('../../main.inc.php');
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
32 
33 $langs->load("banks");
34 $langs->load("categories");
35 
36 $action=GETPOST('action','aZ09');
37 
38 if (!$user->rights->banque->configurer)
40 
41 $bankcateg = new BankCateg($db);
42 $categid = GETPOST('categid');
43 $label = GETPOST("label");
44 
45 /*
46  * Add category
47  */
48 if (GETPOST('add'))
49 {
50  if ($label) {
51  $bankcateg = new BankCateg($db);
52  $bankcateg->label = GETPOST('label');
53  $bankcateg->create($user);
54  }
55 }
56 
57 if ($categid) {
58  $bankcateg = new BankCateg($db);
59 
60  if ($bankcateg->fetch($categid) > 0) {
61 
62  //Update category
63  if (GETPOST('update') && $label) {
64 
65  $bankcateg->label = $label;
66  $bankcateg->update($user);
67  }
68  //Delete category
69  if ($action == 'delete') {
70  $bankcateg->delete($user);
71  }
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 llxHeader();
81 
82 
83 print load_fiche_titre($langs->trans("RubriquesTransactions"), '', 'title_bank.png');
84 
85 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
86 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
87 
88 print '<table class="noborder" width="100%">';
89 print '<tr class="liste_titre">';
90 print '<td>'.$langs->trans("Ref").'</td><td colspan="2">'.$langs->trans("Label").'</td>';
91 print "</tr>\n";
92 
93 $sql = "SELECT rowid, label";
94 $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ";
95 $sql.= " WHERE entity = ".$conf->entity;
96 $sql.= " ORDER BY label";
97 
98 $result = $db->query($sql);
99 if ($result)
100 {
101  $num = $db->num_rows($result);
102  $i = 0; $total = 0;
103 
104  $var=True;
105  while ($i < $num)
106  {
107  $objp = $db->fetch_object($result);
108 
109  print '<tr class="oddeven">';
110  print '<td><a href="'.DOL_URL_ROOT.'/compta/bank/budget.php?bid='.$objp->rowid.'">'.$objp->rowid.'</a></td>';
111  if (GETPOST('action','aZ09') == 'edit' && GETPOST("categid")== $objp->rowid)
112  {
113  print "<td colspan=2>";
114  print '<input type="hidden" name="categid" value="'.$objp->rowid.'">';
115  print '<input name="label" type="text" size=45 value="'.$objp->label.'">';
116  print '<input type="submit" name="update" class="button" value="'.$langs->trans("Edit").'">';
117 
118  print "</td>";
119  }
120  else
121  {
122  print "<td >".$objp->label."</td>";
123  print '<td style="text-align: center;">';
124  print '<a href="'.$_SERVER["PHP_SELF"].'?categid='.$objp->rowid.'&amp;action=edit">'.img_edit().'</a>&nbsp;&nbsp;';
125  print '<a href="'.$_SERVER["PHP_SELF"].'?categid='.$objp->rowid.'&amp;action=delete">'.img_delete().'</a></td>';
126  }
127  print "</tr>";
128  $i++;
129  }
130  $db->free($result);
131 }
132 
133 
134 /*
135  * Line to add category
136  */
137 if ($action != 'edit')
138 {
139 
140  print '<tr class="oddeven">';
141  print '<td>&nbsp;</td><td><input name="label" type="text" size="45"></td>';
142  print '<td align="center"><input type="submit" name="add" class="button" value="'.$langs->trans("Add").'"></td>';
143  print '</tr>';
144 }
145 
146 print '</table></form>';
147 
148 llxFooter();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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 bank categories.
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
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
print
Draft customers invoices.
Definition: index.php:91
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.