dolibarr  7.0.0-beta
accounting.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
4  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
33 {
34  global $langs, $conf;
35 
36  $h = 0;
37  $head = array ();
38 
39  $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/card.php?id=' . $object->id;
40  $head[$h][1] = $langs->trans("Card");
41  $head[$h][2] = 'card';
42  $h ++;
43 
44  // Show more tabs from modules
45  // Entries must be declared in modules descriptor with line
46  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47  // $this->tabs = array('entity:-tabname); to remove a tab
48  complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account');
49 
50  complete_head_from_modules($conf, $langs, $object, $head, $h, 'accounting_account', 'remove');
51 
52  return $head;
53 }
54 
61 function clean_account($account)
62 {
63  $account = rtrim($account,"0");
64 
65  return $account;
66 }
67 
74 function length_accountg($account)
75 {
76  global $conf;
77 
78  if ($account < 0 || empty($account)) return '';
79 
80  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
81 
82  $g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
83  if (! empty($g)) {
84  // Clean parameters
85  $i = strlen($account);
86 
87  if ($i >= 1) {
88  while ( $i < $g ) {
89  $account .= '0';
90 
91  $i ++;
92  }
93 
94  return $account;
95  } else {
96  return $account;
97  }
98  } else {
99  return $account;
100  }
101 }
102 
109 function length_accounta($accounta)
110 {
111  global $conf, $langs;
112 
113  if ($accounta < 0 || empty($accounta)) return '';
114 
115  if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
116 
117  $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
118  if (! empty($a)) {
119  // Clean parameters
120  $i = strlen($accounta);
121 
122  if ($i >= 1) {
123  while ( $i < $a ) {
124  $accounta .= '0';
125 
126  $i ++;
127  }
128 
129  return $accounta;
130  } else {
131  return $accounta;
132  }
133  } else {
134  return $accounta;
135  }
136 }
137 
138 
139 
155 function journalHead($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
156 {
157  global $langs;
158 
159  if (empty($hselected)) $hselected='report';
160 
161  print "\n\n<!-- debut cartouche journal -->\n";
162 
163  if(! empty($varlink)) $varlink = '?'.$varlink;
164 
165  $h=0;
166  $head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
167  $head[$h][1] = $langs->trans("Journalization");
168  $head[$h][2] = 'journal';
169 
170  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
171 
172  dol_fiche_head($head, 'journal');
173 
174  foreach($moreparam as $key => $value)
175  {
176  print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
177  }
178  print '<table width="100%" class="border">';
179 
180  // Ligne de titre
181  print '<tr>';
182  print '<td width="110">'.$langs->trans("Name").'</td>';
183  if (! $variantexxx) print '<td colspan="3">';
184  else print '<td>';
185  print $nom;
186  if ($variantexxx) print '</td><td colspan="2">'.$variantexxx;
187  print '</td>';
188  print '</tr>';
189 
190  // Calculation mode
191  if ($calcmode)
192  {
193  print '<tr>';
194  print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
195  if (! $variante) print '<td colspan="3">';
196  else print '<td>';
197  print $calcmode;
198  if ($variante) print '</td><td colspan="2">'.$variante;
199  print '</td>';
200  print '</tr>';
201  }
202 
203  // Ligne de la periode d'analyse du rapport
204  print '<tr>';
205  print '<td>'.$langs->trans("ReportPeriod").'</td>';
206  if (! $periodlink) print '<td colspan="3">';
207  else print '<td>';
208  if ($period) print $period;
209  if ($periodlink) print '</td><td colspan="2">'.$periodlink;
210  print '</td>';
211  print '</tr>';
212 
213  // Ligne de description
214  print '<tr>';
215  print '<td>'.$langs->trans("ReportDescription").'</td>';
216  print '<td colspan="3">'.$description.'</td>';
217  print '</tr>';
218 
219  print '</table>';
220 
221  dol_fiche_end();
222 
223  print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
224 
225  print '</form>';
226 
227  print "\n<!-- fin cartouche journal -->\n\n";
228 }
229 
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_fiche_end($notab=0)
Show tab footer of a card.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
print
Draft customers invoices.
Definition: index.php:91
accounting_prepare_head(AccountingAccount $object)
Prepare array with list of tabs.
Class to manage accounting accounts.
clean_account($account)
Return accounting account without zero on the right.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a VAT report.