Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 678 lines (566 sloc) 23.697 kb
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
1 <?php
9162956 Rodolphe Quiédeville Ajout creation des categories fournisseurs
rodo authored
2 /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
c9053e1 problem synchro git<->cvs !!!
Regis Houssin authored
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
1f435c4 Fix: rights problem in supplier module
Regis Houssin authored
4 * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
9162956 Rodolphe Quiédeville Ajout creation des categories fournisseurs
rodo authored
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
7 * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
072b322 Philippe Grand To enable use of custom directory
grandoc authored
8 * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
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 2 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
e2c0073 Laurent Destailleur Fix: Avoid errors into rpm packages
eldy authored
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
22 */
23
24 /**
68c1571 Qual: First change to remove pre.inc.php
Regis Houssin authored
25 * \file htdocs/admin/fournisseur.php
26 * \ingroup fournisseur
27 * \brief Page d'administration-configuration du module Fournisseur
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
28 */
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
29
68c1571 Qual: First change to remove pre.inc.php
Regis Houssin authored
30 require("../main.inc.php");
63d60a3 [task #216] Move lib in core directory
Regis Houssin authored
31 require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
3f4bee1 Philippe Grand according to new tree directory
grandoc authored
32 require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php');
33 require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php');
4550d07 Juanjo Menent Task #8618: works in setup module
simnandez authored
34 require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
35
36 $langs->load("admin");
37
38 if (!$user->admin)
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
39 accessforbidden();
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
40
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
41 $type=GETPOST('type', 'alpha');
42 $value=GETPOST('value', 'alpha');
43 $action=GETPOST('action', 'alpha');
559a798 Fix: problem to select a model
Regis Houssin authored
44
3d1d607 Laurent Destailleur Fix: Task 8618
eldy authored
45 $specimenthirdparty=new Societe($db);
46 $specimenthirdparty->initAsSpecimen();
47
34bd512 Laurent Destailleur New: A generic supplier order numbering module (depreciate all others)
eldy authored
48
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
49 /*
50 * Actions
51 */
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
52
559a798 Fix: problem to select a model
Regis Houssin authored
53 if ($action == 'updateMask')
34bd512 Laurent Destailleur New: A generic supplier order numbering module (depreciate all others)
eldy authored
54 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
55 $maskconstorder=GETPOST('maskconstorder','alpha');
56 $maskorder=GETPOST('maskorder','alpha');
57
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
58 if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
8d46ae1 Laurent Destailleur Qual: Better error managment on numbering setup
eldy authored
59
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
60 if (! $res > 0) $error++;
937d432 Juanjo Menent Uniformize code
simnandez authored
61
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
62 if (! $error)
937d432 Juanjo Menent Uniformize code
simnandez authored
63 {
64 $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
65 }
66 else
67 {
68 $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
69 }
34bd512 Laurent Destailleur New: A generic supplier order numbering module (depreciate all others)
eldy authored
70 }
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
71
559a798 Fix: problem to select a model
Regis Houssin authored
72 if ($action == 'specimen') // For orders
fc415a0 Laurent Destailleur Gestion apercu modele dans page config pour commande fournisseur.
eldy authored
73 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
74 $modele=GETPOST('module','alpha');
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
75
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
76 $commande = new CommandeFournisseur($db);
77 $commande->initAsSpecimen();
3d1d607 Laurent Destailleur Fix: Task 8618
eldy authored
78 $commande->thirdparty=$specimenthirdparty;
6aa7e90 Fix: merge problem
Regis Houssin authored
79
80 // Search template files
81 $file=''; $classname=''; $filefound=0;
ddedb68 Fix: php unit test warning
Regis Houssin authored
82 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
6aa7e90 Fix: merge problem
Regis Houssin authored
83 foreach($dirmodels as $reldir)
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
84 {
6aa7e90 Fix: merge problem
Regis Houssin authored
85 $file=dol_buildpath($reldir."core/modules/supplier_order/pdf/pdf_".$modele.".modules.php",0);
86 if (file_exists($file))
87 {
88 $filefound=1;
89 $classname = "pdf_".$modele;
90 break;
91 }
92 }
93
94 if ($filefound)
95 {
96 require_once($file);
97
98 $module = new $classname($db);
99
100 if ($module->write_file($commande,$langs) > 0)
101 {
102 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
103 return;
104 }
105 else
106 {
107 $mesg='<font class="error">'.$module->error.'</font>';
108 dol_syslog($module->error, LOG_ERR);
109 }
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
110 }
111 else
112 {
6aa7e90 Fix: merge problem
Regis Houssin authored
113 $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
114 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
115 }
fc415a0 Laurent Destailleur Gestion apercu modele dans page config pour commande fournisseur.
eldy authored
116 }
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
117
559a798 Fix: problem to select a model
Regis Houssin authored
118 if ($action == 'specimenfacture') // For invoices
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
119 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
120 $modele=GETPOST('module','alpha');
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
121
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
122 $facture = new FactureFournisseur($db);
123 $facture->initAsSpecimen();
1aaf65c Laurent Destailleur PDF works with us letter format
eldy authored
124 $facture->thirdparty=$specimenthirdparty; // Define who should has build the invoice (so the supplier)
6aa7e90 Fix: merge problem
Regis Houssin authored
125
126 // Search template files
127 $file=''; $classname=''; $filefound=0;
ddedb68 Fix: php unit test warning
Regis Houssin authored
128 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
6aa7e90 Fix: merge problem
Regis Houssin authored
129 foreach($dirmodels as $reldir)
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
130 {
6aa7e90 Fix: merge problem
Regis Houssin authored
131 $file=dol_buildpath($reldir."core/modules/supplier_invoice/pdf/pdf_".$modele.".modules.php",0);
132 if (file_exists($file))
133 {
134 $filefound=1;
135 $classname = "pdf_".$modele;
136 break;
137 }
138 }
139
140 if ($filefound)
141 {
142 require_once($file);
143
144 $module = new $classname($db);
145
146 if ($module->write_file($facture,$langs) > 0)
147 {
148 header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
149 return;
150 }
151 else
152 {
153 $mesg='<font class="error">'.$module->error.'</font>';
154 dol_syslog($module->error, LOG_ERR);
155 }
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
156 }
157 else
158 {
6aa7e90 Fix: merge problem
Regis Houssin authored
159 $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
160 dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
161 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
162 }
163
559a798 Fix: problem to select a model
Regis Houssin authored
164 if ($action == 'set')
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
165 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
166 $label = GETPOST('label','alpha');
167 $scandir = GETPOST('scandir','alpha');
168
0560de9 Laurent Destailleur Work on ODT generation
eldy authored
169 $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
559a798 Fix: problem to select a model
Regis Houssin authored
170 $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
171 $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
172 $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
0560de9 Laurent Destailleur Work on ODT generation
eldy authored
173 $sql.= ")";
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
174 $res=$db->query($sql);
175 if ($res)
176 {
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
177
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
178 }
179 // else dol_print_error($db);
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
180 }
181
559a798 Fix: problem to select a model
Regis Houssin authored
182 if ($action == 'del')
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
183 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
184 $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
185 $sql.= " WHERE nom = '".$value."'";
186 $sql.= " AND type = '".$type."'";
187 $sql.= " AND entity = ".$conf->entity;
188 $db->query($sql);
189 if ($res)
190 {
191
192 }
193 // else dol_print_error($db);
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
194 }
195
559a798 Fix: problem to select a model
Regis Houssin authored
196 if ($action == 'setdoc')
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
197 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
198 $label = GETPOST('label','alpha');
199 $scandir = GETPOST('scandir','alpha');
200
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
201 $db->begin();
7deb33c Laurent Destailleur Maxi debug for UTF8 support
eldy authored
202
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
203 if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
204 {
205 $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
206 }
d9bc203 Laurent Destailleur Doxygen
eldy authored
207
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
208 if ($type == 'invoice_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
209 {
210 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
211 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
212
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
213 // On active le modele
214 $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
215 $sql_del.= " WHERE nom = '".$db->escape($value)."'";
216 $sql_del.= " AND type = '".$type."'";
217 $sql_del.= " AND entity = ".$conf->entity;
218 $result1=$db->query($sql_del);
0560de9 Laurent Destailleur Work on ODT generation
eldy authored
219
220 $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
559a798 Fix: problem to select a model
Regis Houssin authored
221 $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
222 $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
223 $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
0560de9 Laurent Destailleur Work on ODT generation
eldy authored
224 $sql.= ")";
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
225 $result2=$db->query($sql);
226 if ($result1 && $result2)
227 {
228 $db->commit();
229 }
230 else
231 {
232 $db->rollback();
233 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
234 }
235
559a798 Fix: problem to select a model
Regis Houssin authored
236 if ($action == 'setmod')
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
237 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
238 // TODO Verifier si module numerotation choisi peut etre active
239 // par appel methode canBeActivated
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
240
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
241 dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity);
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
242 }
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
243
559a798 Fix: problem to select a model
Regis Houssin authored
244 if ($action == 'addcat')
9162956 Rodolphe Quiédeville Ajout creation des categories fournisseurs
rodo authored
245 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
246 $fourn = new Fournisseur($db);
247 $fourn->CreateCategory($user,$_POST["cat"]);
9162956 Rodolphe Quiédeville Ajout creation des categories fournisseurs
rodo authored
248 }
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
249
559a798 Fix: problem to select a model
Regis Houssin authored
250 if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
5b115ab Juanjo Menent Task #8618: Add supplier invoice free text
simnandez authored
251 {
a0cae77 Juanjo Menent Fix: Sanitize data
simnandez authored
252 $free = GETPOST('SUPPLIER_INVOICE_FREE_TEXT','alpha');
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
253 $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
8d46ae1 Laurent Destailleur Qual: Better error managment on numbering setup
eldy authored
254
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
255 if (! $res > 0) $error++;
937d432 Juanjo Menent Uniformize code
simnandez authored
256
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
257 if (! $error)
937d432 Juanjo Menent Uniformize code
simnandez authored
258 {
259 $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
260 }
261 else
262 {
263 $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
264 }
5b115ab Juanjo Menent Task #8618: Add supplier invoice free text
simnandez authored
265 }
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
266
267
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
268 /*
1772463 Laurent Destailleur New: Add ability for numbering module to not be shown if a condition is ...
eldy authored
269 * View
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
270 */
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
271
ddedb68 Fix: php unit test warning
Regis Houssin authored
272 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
273
d4fdb23 Laurent Destailleur Move all modules into includes/modules directory
eldy authored
274 llxHeader();
275
6aa7e90 Fix: merge problem
Regis Houssin authored
276 $form=new Form($db);
277
a81f652 Laurent Destailleur New: Ajout lien "Retour liste des modules" dans page config modules
eldy authored
278 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
279 print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
280
281 print "<br>";
282
d4fdb23 Laurent Destailleur Move all modules into includes/modules directory
eldy authored
283
284 // Supplier order numbering module
285
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
286 print_titre($langs->trans("OrdersNumberingModules"));
287
288 print '<table class="noborder" width="100%">';
289 print '<tr class="liste_titre">';
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
290 print '<td width="100">'.$langs->trans("Name").'</td>';
291 print '<td>'.$langs->trans("Description").'</td>';
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
292 print '<td>'.$langs->trans("Example").'</td>';
d5d9291 Laurent Destailleur Qual: Uniformize code
eldy authored
293 print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
294 print '<td align="center" width="16">'.$langs->trans("Info").'</td>';
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
295 print "</tr>\n";
296
297 clearstatcache();
298
6aa7e90 Fix: merge problem
Regis Houssin authored
299 foreach ($dirmodels as $reldir)
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
300 {
6aa7e90 Fix: merge problem
Regis Houssin authored
301 $dir = dol_buildpath($reldir."core/modules/supplier_order/");
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
302
303 if (is_dir($dir))
304 {
305 $handle = opendir($dir);
306 if (is_resource($handle))
307 {
308 $var=true;
309
310 while (($file = readdir($handle))!==false)
311 {
312 if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php')
313 {
314 $file = substr($file, 0, dol_strlen($file)-4);
315
316 require_once($dir.$file.".php");
317
318 $module = new $file;
319
320 if ($module->isEnabled())
321 {
322 // Show modules according to features level
323 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
324 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
325
326 $var=!$var;
327 print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
328 print $module->info();
329 print '</td>';
330
331 // Show example of numbering module
332 print '<td nowrap="nowrap">';
8d46ae1 Laurent Destailleur Qual: Better error managment on numbering setup
eldy authored
333 $tmp=$module->getExample();
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
334 if (preg_match('/^Error/',$tmp)) {
335 $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
336 }
8d46ae1 Laurent Destailleur Qual: Better error managment on numbering setup
eldy authored
337 elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
338 else print $tmp;
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
339 print '</td>'."\n";
340
341 print '<td align="center">';
342 if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file")
343 {
344 print img_picto($langs->trans("Activated"),'switch_on');
345 }
346 else
347 {
348 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
349 }
350 print '</td>';
351
352 $commande=new CommandeFournisseur($db);
353 $commande->initAsSpecimen();
354
355 // Info
356 $htmltooltip='';
357 $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
358 $facture->type=0;
359 $nextval=$module->getNextValue($mysoc,$commande);
360 if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
361 {
362 $htmltooltip.=''.$langs->trans("NextValue").': ';
363 if ($nextval)
364 {
365 $htmltooltip.=$nextval.'<br>';
366 }
367 else
368 {
369 $htmltooltip.=$langs->trans($module->error).'<br>';
370 }
371 }
372
373 print '<td align="center">';
374 print $form->textwithpicto('',$htmltooltip,1,0);
375 print '</td>';
376
377 print '</tr>';
378 }
379 }
380 }
381 closedir($handle);
382 }
383 }
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
384 }
385
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
386 print '</table><br>';
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
387
d4fdb23 Laurent Destailleur Move all modules into includes/modules directory
eldy authored
388
3d1d607 Laurent Destailleur Fix: Task 8618
eldy authored
389
390
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
391 /*
d4fdb23 Laurent Destailleur Move all modules into includes/modules directory
eldy authored
392 * Modeles documents for supplier orders
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
393 */
d4fdb23 Laurent Destailleur Move all modules into includes/modules directory
eldy authored
394
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
395 print_titre($langs->trans("OrdersModelModule"));
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
396
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
397 // Defini tableau def de modele
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
398 $def = array();
b866848 New: early development of multi-company module
Regis Houssin authored
399
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
400 $sql = "SELECT nom";
401 $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
559a798 Fix: problem to select a model
Regis Houssin authored
402 $sql.= " WHERE type = 'order_supplier'";
b866848 New: early development of multi-company module
Regis Houssin authored
403 $sql.= " AND entity = ".$conf->entity;
404
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
405 $resql=$db->query($sql);
406 if ($resql)
407 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
408 $i = 0;
409 $num_rows=$db->num_rows($resql);
410 while ($i < $num_rows)
411 {
412 $array = $db->fetch_array($resql);
413 array_push($def, $array[0]);
414 $i++;
415 }
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
416 }
417 else
418 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
419 dol_print_error($db);
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
420 }
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
421
eabf8c3 Fix: uniformize code
Regis Houssin authored
422 print '<table class="noborder" width="100%">'."\n";
423 print '<tr class="liste_titre">'."\n";
424 print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
425 print '<td>'.$langs->trans("Description").'</td>'."\n";
426 print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
427 print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
c8013ac Laurent Destailleur Fix: Can't enable document for supplier invoice/order
eldy authored
428 print '<td align="center" width="40" colspan="2">'.$langs->trans("Info").'</td>';
eabf8c3 Fix: uniformize code
Regis Houssin authored
429 print '</tr>'."\n";
b62a214 Laurent Destailleur L'activation des mod�les de documents de commande forunisseurs se base s...
eldy authored
430
431 clearstatcache();
432
6aa7e90 Fix: merge problem
Regis Houssin authored
433 foreach ($dirmodels as $reldir)
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
434 {
6aa7e90 Fix: merge problem
Regis Houssin authored
435 $dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
436
437 if (is_dir($dir))
438 {
439 $var=true;
440
441 $handle=opendir($dir);
442
443
444 if (is_resource($handle))
445 {
446 while (($file = readdir($handle))!==false)
447 {
448 if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
449 {
450 $name = substr($file, 4, dol_strlen($file) -16);
451 $classname = substr($file, 0, dol_strlen($file) -12);
452
453 $var=!$var;
454 print "<tr ".$bc[$var].">\n";
455 print "<td>".$name."</td>\n";
456 print "<td>\n";
457 require_once($dir.$file);
458 $module = new $classname($db,$specimenthirdparty);
459 print $module->description;
460 print "</td>\n";
461
462 // Active
463 if (in_array($name, $def))
464 {
465 print '<td align="center">'."\n";
466 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name")
467 {
468 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">';
469 print img_picto($langs->trans("Enabled"),'switch_on');
470 print '</a>';
471 }
472 else
473 {
474 print img_picto($langs->trans("Enabled"),'switch_on');
475 }
476 print "</td>";
477 }
478 else
479 {
480 print '<td align="center">'."\n";
481 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
482 print "</td>";
483 }
484
485 // Defaut
486 print '<td align="center">';
487 if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
488 {
489 print img_picto($langs->trans("Default"),'on');
490 }
491 else
492 {
493 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
494 }
495 print '</td>';
496
497 // Info
498 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
499 $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
500 $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
501 $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
502 $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
503 $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
504 $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
505 print '<td align="center">';
506 print $form->textwithpicto('',$htmltooltip,1,0);
507 print '</td>';
508 print '<td align="center">';
509 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
510 print '</td>';
511
512 print "</tr>\n";
513 }
514 }
515
516 closedir($handle);
517 }
518 }
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
519 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
520
521 print '</table><br/>';
522
523 /*
524 * Modeles documents for supplier invoices
525 */
526
f0d2da7 Juanjo Menent Task #8618: works in setup module
simnandez authored
527 print_titre($langs->trans("BillsPDFModules"));
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
528
529 // Defini tableau def de modele
530 $def = array();
531
532 $sql = "SELECT nom";
533 $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
559a798 Fix: problem to select a model
Regis Houssin authored
534 $sql.= " WHERE type = 'invoice_supplier'";
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
535 $sql.= " AND entity = ".$conf->entity;
536
537 $resql=$db->query($sql);
538 if ($resql)
539 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
540 $i = 0;
541 $num_rows=$db->num_rows($resql);
542 while ($i < $num_rows)
543 {
544 $array = $db->fetch_array($resql);
545 array_push($def, $array[0]);
546 $i++;
547 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
548 }
549 else
550 {
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
551 dol_print_error($db);
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
552 }
553
dcd3ab4 Laurent Destailleur Qual: Removed no more used external libraries (fpdi_protection)
eldy authored
554
eabf8c3 Fix: uniformize code
Regis Houssin authored
555 print '<table class="noborder" width="100%">'."\n";
556 print '<tr class="liste_titre">'."\n";
557 print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
558 print '<td>'.$langs->trans("Description").'</td>'."\n";
559 print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
560 print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
c8013ac Laurent Destailleur Fix: Can't enable document for supplier invoice/order
eldy authored
561 print '<td align="center" width="40" colspan="2">'.$langs->trans("Info").'</td>';
eabf8c3 Fix: uniformize code
Regis Houssin authored
562 print '</tr>'."\n";
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
563
564 clearstatcache();
565
6aa7e90 Fix: merge problem
Regis Houssin authored
566 foreach ($dirmodels as $reldir)
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
567 {
6aa7e90 Fix: merge problem
Regis Houssin authored
568 $dir = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/");
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
569
570 if (is_dir($dir))
571 {
572 $var=true;
573
574 $handle=opendir($dir);
575
576 if (is_resource($handle))
577 {
578 while (($file = readdir($handle)) !== false)
579 {
580 if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
581 {
582 $name = substr($file, 4, dol_strlen($file) -16);
583 $classname = substr($file, 0, dol_strlen($file) -12);
584
585 $var=!$var;
586 print "<tr ".$bc[$var].">\n";
587 print "<td>".$name."</td>\n";
588 print "<td>";
589 require_once($dir.$file);
590 $module = new $classname($db,$specimenthirdparty);
591 print $module->description;
592 print "</td>\n";
593
594 // Active
595 if (in_array($name, $def))
596 {
597 print "<td align=\"center\">\n";
598 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name")
599 {
600 print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">';
601 print img_picto($langs->trans("Enabled"),'switch_on');
602 print '</a>';
603 }
604 else
605 {
606 print img_picto($langs->trans("Enabled"),'switch_on');
607 }
608 print "</td>";
609 }
610 else
611 {
612 print "<td align=\"center\">\n";
613 print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
614 print "</td>";
615 }
616
617 // Defaut
618 print "<td align=\"center\">";
619 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
620 {
621 print img_picto($langs->trans("Default"),'on');
622 }
623 else
624 {
625 print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
626 }
627 print '</td>';
628
629 // Info
630 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
631 $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
632 $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
633 $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
634 $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
635 $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
636 $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
637 print '<td align="center">';
638 print $form->textwithpicto('',$htmltooltip,1,0);
639 print '</td>';
640 print '<td align="center">';
641 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimenfacture&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
642 print '</td>';
643
644 print "</tr>\n";
645 }
646 }
647 closedir($handle);
648 }
649 }
7e4d04d Juanjo Menent Task #8618: works in setup module
simnandez authored
650 }
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
651
9162956 Rodolphe Quiédeville Ajout creation des categories fournisseurs
rodo authored
652 print '</table><br/>';
653
5b115ab Juanjo Menent Task #8618: Add supplier invoice free text
simnandez authored
654 print_titre($langs->trans("OtherOptions"));
655 print '<table class="noborder" width="100%">';
656 print '<tr class="liste_titre">';
657 print '<td>'.$langs->trans("Parameter").'</td>';
658 print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
659 print '<td width="80">&nbsp;</td>';
660 print "</tr>\n";
661
662 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
663 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
664 print '<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
665 print '<tr '.$bc[$var].'><td colspan="2">';
666 print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')<br>';
667 print '<textarea name="SUPPLIER_INVOICE_FREE_TEXT" class="flat" cols="120">'.$conf->global->SUPPLIER_INVOICE_FREE_TEXT.'</textarea>';
668 print '</td><td align="right">';
669 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
670 print "</td></tr>\n";
671 print '</form>';
672
937d432 Juanjo Menent Uniformize code
simnandez authored
673 dol_htmloutput_mesg($mesg);
674
fd7d2fe Laurent Destailleur Test format to removed scope warnings
eldy authored
675 $db->close();
6aa7e90 Fix: merge problem
Regis Houssin authored
676 llxFooter();
92f8579 D�but ajout mod�les commande et facture fournisseur
Regis Houssin authored
677 ?>
Something went wrong with that request. Please try again.