dolibarr  9.0.0
chequereceipts.php
1 <?php
2 /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
5  * Copyright (C) 2015 Jean-Fran├žois Ferry <jfefe@aternatik.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("admin","companies","bills","other","banks"));
36 
37 if (!$user->admin)
39 
40 $action = GETPOST('action','alpha');
41 $value = GETPOST('value','alpha');
42 
43 
44 if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php';
45 
46 
47 
48 /*
49  * Actions
50  */
51 
52 if ($action == 'updateMask')
53 {
54  $maskconstchequereceipts=GETPOST('maskconstchequereceipts','alpha');
55  $maskchequereceipts=GETPOST('maskchequereceipts','alpha');
56  if ($maskconstchequereceipts) $res = dolibarr_set_const($db,$maskconstchequereceipts,$maskchequereceipts,'chaine',0,'',$conf->entity);
57 
58  if (! $res > 0) $error++;
59 
60  if (! $error)
61  {
62  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
63  }
64  else
65  {
66  setEventMessages($langs->trans("Error"), null, 'errors');
67  }
68 }
69 
70 if ($action == 'setmod')
71 {
72  dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON",$value, 'chaine', 0, '', $conf->entity);
73 }
74 
75 if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT')
76 {
77  $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT','none'); // No alpha here, we want exact string
78 
79  $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
80 
81  if (! $res > 0) $error++;
82 
83  if (! $error)
84  {
85  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
86  }
87  else
88  {
89  setEventMessages($langs->trans("Error"), null, 'errors');
90  }
91 }
92 
93 /*
94  * view
95  */
96 
97 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
98 llxHeader("",$langs->trans("BankSetupModule"));
99 
100 $form=new Form($db);
101 
102 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
103 print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup');
104 
105 $head = bank_admin_prepare_head(null);
106 dol_fiche_head($head, 'checkreceipts', $langs->trans("BankSetupModule"), -1, 'account');
107 
108 /*
109  * Numbering module
110  */
111 
112 print load_fiche_titre($langs->trans("ChequeReceiptsNumberingModule"), '', '');
113 
114 print '<table class="noborder" width="100%">';
115 print '<tr class="liste_titre">';
116 print '<td>'.$langs->trans("Name").'</td>';
117 print '<td>'.$langs->trans("Description").'</td>';
118 print '<td class="nowrap">'.$langs->trans("Example").'</td>';
119 print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
120 print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
121 print '</tr>'."\n";
122 
123 clearstatcache();
124 
125 foreach ($dirmodels as $reldir)
126 {
127  $dir = dol_buildpath($reldir."core/modules/cheque/");
128  if (is_dir($dir))
129  {
130  $handle = opendir($dir);
131  if (is_resource($handle))
132  {
133  while (($file = readdir($handle))!==false)
134  {
135  if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
136  {
137  $filebis = $file;
138  $name = substr($file, 4, dol_strlen($file) -16);
139  $classname = preg_replace('/\.php$/','',$file);
140  // For compatibility
141  if (! is_file($dir.$filebis))
142  {
143  $filebis = $file."/".$file.".modules.php";
144  $classname = "mod_chequereceipt_".$file;
145  }
146  // Check if there is a filter on country
147  preg_match('/\-(.*)_(.*)$/',$classname,$reg);
148  if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
149 
150  $classname = preg_replace('/\-.*$/','',$classname);
151  if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
152  {
153  // Charging the numbering class
154  require_once $dir.$filebis;
155 
156  $module = new $classname($db);
157 
158  // Show modules according to features level
159  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
160  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
161 
162  if ($module->isEnabled())
163  {
164  print '<tr class="oddeven"><td width="100">';
165  print (empty($module->name)?$name:$module->name);
166  print "</td><td>\n";
167 
168  print $module->info();
169 
170  print '</td>';
171 
172  // Show example of numbering module
173  print '<td class="nowrap">';
174  $tmp=$module->getExample();
175  if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
176  elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
177  else print $tmp;
178  print '</td>'."\n";
179 
180  print '<td align="center">';
181  if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file)
182  {
183  print img_picto($langs->trans("Activated"),'switch_on');
184  }
185  else
186  {
187  print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/','',$file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
188  }
189  print '</td>';
190 
191  $chequereceipts=new RemiseCheque($db);
192  $chequereceipts->initAsSpecimen();
193 
194  // Example
195  $htmltooltip='';
196  $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
197  $nextval=$module->getNextValue($mysoc,$chequereceipts);
198  if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
199  $htmltooltip.=$langs->trans("NextValue").': ';
200  if ($nextval) {
201  if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
202  $nextval = $langs->trans($nextval);
203  $htmltooltip.=$nextval.'<br>';
204  } else {
205  $htmltooltip.=$langs->trans($module->error).'<br>';
206  }
207  }
208 
209  print '<td align="center">';
210  print $form->textwithpicto('',$htmltooltip,1,0);
211 
212  if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) // If module is the one used, we show existing errors
213  {
214  if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1);
215  }
216 
217  print '</td>';
218 
219  print "</tr>\n";
220  }
221  }
222  }
223  }
224  closedir($handle);
225  }
226  }
227 }
228 
229 print '</table>';
230 
231 print '<br>';
232 
233 
234 /*
235  * Other options
236  *
237  */
238 print load_fiche_titre($langs->trans("OtherOptions"),'','');
239 
240 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
241 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
242 print '<input type="hidden" name="action" value="set_BANK_CHEQUERECEIPT_FREE_TEXT">';
243 
244 print '<table class="noborder" width="100%">';
245 print '<tr class="liste_titre">';
246 print '<td>'.$langs->trans("Parameters").'</td>';
247 print '<td align="center" width="60">&nbsp;</td>';
248 print '<td width="80">&nbsp;</td>';
249 print "</tr>\n";
250 
251 $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
252 $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
253 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
254 foreach($substitutionarray as $key => $val) $htmltext.=$key.'<br>';
255 $htmltext.='</i>';
256 
257 print '<tr class="oddeven"><td colspan="2">';
258 print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
259 $variablename='BANK_CHEQUERECEIPT_FREE_TEXT';
260 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
261 {
262  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
263 }
264 else
265 {
266  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
267  $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes');
268  print $doleditor->Create();
269 }
270 print '</td><td align="right">';
271 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
272 print "</td></tr>\n";
273 print '</table>';
274 print "<br>";
275 
276 print '</table>'."\n";
277 
278 dol_fiche_end();
279 
280 print '</form>';
281 
282 // End of page
283 llxFooter();
284 $db->close();
bank_admin_prepare_head($object)
Prepare array with list of tabs.
Definition: bank.lib.php:125
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:510
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(! GETPOST('transkey', 'alphanohtml') &&! GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:43
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_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:623
Class to manage a WYSIWYG editor.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Class to manage cheque delivery receipts.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).