29if ( !defined (
'ALLOWED')) die(
'Forbidden');
38 $mod_id=
$http->post(
"m",
"number",0);
40 if (trim(
$name) !=
"" && $mod_id != 0 &&
isNumber($mod_id)==1)
43 $cn->exec_sql(
"update modeledef set mod_name=$1, " .
44 " mod_desc=$2 where mod_id=$3 ",
55if (isset(
$_POST[
"FMOD_NAME"]))
57 $encoding =
$cn->get_value(
"select encoding from pg_database where " .
62 alert(_(
'Désolé vous devez migrer ce modèle en unicode'));
63 echo
'<span class="error">';
64 printf (_(
'la base de donnée %smod%s doit être migrée en unicode'),
domaine,
$fmod_dbid);
66 echo
'<span class="error"> '._(
"Pour le passer en unicode, faites-en un backup puis restaurez le fichier reçu").
'</span>';
72 $mod_name =
$http->post(
"FMOD_NAME");
73 $mod_desc =
$http->post(
"FMOD_DESC");
74 if ($mod_name !=
null || trim ($mod_name) !=
"")
76 $Res =
$cn->exec_sql(
"insert into modeledef(mod_name,mod_desc)
77 values ($1,$2)",array($mod_name,$mod_desc));
80 $l_id =
$cn->get_current_seq(
's_modid');
83 $Sql = sprintf(
"CREATE DATABASE %sMOD%d encoding='UTF8' TEMPLATE %sDOSSIER%s",
domaine, $l_id,
domaine,
$_POST[
"FMOD_DBID"]);
85 if (
$cn->exec_sql($Sql) ==
false)
88 echo
"<h2 class=\"error\">";
89 printf(_(
'Base de donnée %sdossier%d" est accèdée, déconnectez-vous en d\'abord'),
domaine,
$fmod_dbid);
91 $Res =
$cn->exec_sql(
"delete from modeledef where mod_id=$1",array($l_id));
99 alert(_(
'Le nom est vide'));
102 $cn_mod =
new Database($l_id,
'mod');
106 $Res = $cn_mod->exec_sql(
"select distinct jr_pj from jrn where jr_pj is not null ");
110 $nb_lob=($a_lob == FALSE)?0:count($a_lob);
111 for (
$i = 0;
$i < $nb_lob;
$i++)
112 $cn_mod->lo_unlink($a_lob[
$i][
'jr_pj']);
114 $Res = $cn_mod->exec_sql(
"truncate table centralized");
115 $Res = $cn_mod->exec_sql(
"truncate table jrn cascade");
116 $Res = $cn_mod->exec_sql(
"delete from del_jrn");
117 $Res = $cn_mod->exec_sql(
"delete from del_jrnx");
118 $Res = $cn_mod->exec_sql(
"truncate table jrnx cascade ");
119 $Res = $cn_mod->exec_sql(
"truncate table todo_list cascade ");
120 $Res = $cn_mod->exec_sql(
"delete from del_action");
121 $Res = $cn_mod->exec_sql(
"delete from profile_user");
122 $Res = $cn_mod->exec_sql(
"delete from jnt_letter");
124 $Res = $cn_mod->exec_sql(
'delete from operation_analytique');
126 $Res = $cn_mod->exec_sql(
'delete from user_sec_act');
127 $Res = $cn_mod->exec_sql(
'delete from user_sec_action_profile');
128 $Res = $cn_mod->exec_sql(
'delete from user_local_pref');
129 $Res = $cn_mod->exec_sql(
'delete from user_sec_jrn');
130 $Res = $cn_mod->exec_sql(
'delete from bookmark');
133 $Res = $cn_mod->exec_sql(
"update parm_periode set p_closed='f'");
134 $Res = $cn_mod->exec_sql(
'delete from jrn_periode');
135 $Res = $cn_mod->exec_sql(
' insert into jrn_periode(p_id,jrn_def_id,status) ' .
136 ' select p_id,jrn_def_id,\'OP\' ' .
138 ' parm_periode cross join jrn_def');
141 $a_seq = array(
's_jrn',
's_jrn_op',
's_centralized',
's_stock_goods',
's_internal');
142 foreach ($a_seq as
$seq)
144 $sql = sprintf(
"select setval('%s',1,false)",
$seq);
147 $sql =
"select jrn_def_id from jrn_def ";
154 if ($cn_mod->exist_sequence(
's_jrn_' .
$row[
'jrn_def_id']) ==
false)
156 $cn_mod->create_sequence(
's_jrn_' .
$row[
'jrn_def_id']);
160 $sql = sprintf(
"select setval('s_jrn_%d',1,false)",
$row[
'jrn_def_id']);
161 $cn_mod->exec_sql(
$sql);
163 $sql = sprintf(
"select setval('s_jrn_pj%d',1,false)",
$row[
'jrn_def_id']);
164 $cn_mod->exec_sql(
$sql);
165 $sql = sprintf(
"select setval('jnt_letter_jl_id_seq',1,false)");
166 $cn_mod->exec_sql(
$sql);
173 $Res = $cn_mod->exec_sql(
"delete from action_gestion_related");
174 $Res = $cn_mod->exec_sql(
"delete from action_gestion_comment");
175 $Res = $cn_mod->exec_sql(
"delete from action_gestion_related");
176 $Res = $cn_mod->exec_sql(
"delete from action_person");
177 $Res = $cn_mod->exec_sql(
"delete from action_gestion");
178 $Res = $cn_mod->exec_sql(
"delete from tags");
179 $Res = $cn_mod->exec_sql(
"delete from action_tags");
180 $Res = $cn_mod->exec_sql(
"delete from document");
183 $a_seq=$cn_mod->get_array(
" select sequence_name "
184 .
" from information_schema.sequences "
185 .
"where sequence_name like 'seq_doc_type%'"
187 $n_seq=count($a_seq);
188 for (
$i = 0;
$i < $n_seq;
$i++) {
189 $cn_mod->alter_seq($a_seq[
$i][
'sequence_name'], 1);
192 if (isset(
$_POST[
'CARD']))
196 $a_schema=$cn_mod->get_array(
"
197 select nspname from pg_namespace
199 nspname not like 'pg_%'
200 and nspname in ('amortissement')
202 $nb_schema=count($a_schema);
203 for (
$i=0;
$i < $nb_schema;
$i++)
205 $cn_mod->exec_sql(
" drop schema ".$a_schema[
$i][
'nspname'].
" cascade");
207 $Res = $cn_mod->exec_sql(
"delete from action_gestion");
208 $Res = $cn_mod->exec_sql(
"delete from fiche_detail");
209 $Res = $cn_mod->exec_sql(
"delete from fiche");
210 $Res = $cn_mod->exec_sql(
"delete from document");
211 $Res = $cn_mod->exec_sql(
"delete from document_modele");
212 $Res = $cn_mod->exec_sql(
"delete from op_predef");
216 if (isset(
$_POST[
'CANAL']))
218 $Res = $cn_mod->exec_sql(
'delete from poste_analytique');
219 $Res = $cn_mod->exec_sql(
'delete from plan_analytique');
221 if ( isset (
$_POST[
'PLUGIN'])) {
222 $a_schema=$cn_mod->get_array(
"
223 select nspname from pg_namespace
225 nspname not like 'pg_%'
226 and nspname not in ('information_schema','public','comptaproc')
228 $nb_schema=count($a_schema);
229 for (
$i=0;
$i < $nb_schema;
$i++)
231 $cn_mod->exec_sql(
" drop schema ".$a_schema[
$i][
'nspname'].
" cascade");
235 $cn_mod->clean_orphan_lob();
239$url=$_SERVER[
'PHP_SELF'].
"?".http_build_query(array(
"sa"=>
"list",
"action"=>
$http->request(
'action')));
242$header->add(_(
"id"),
$url,
" order by mod_id asc",
" order by mod_id desc",
"ia",
"id");
243$header->add(_(
"Nom"),
$url,
" order by mod_name asc",
" order by mod_name desc",
"na",
"nd");
244$header->add(_(
"Description"),
$url,
" order by mod_desc asc",
" order by mod_desc desc",
"da",
"dd");
249$Res =
$cn->exec_sql(
"select mod_id,mod_name,mod_desc from
250 modeledef $sql_order");
253echo
'<div class="content">';
254echo
"<H2>"._(
'Modèles').
"</H2>";
258 echo
HtmlInput::button(_(
'Ajouter'),_(
'Ajouter un modèle'),
" onclick=\$('folder_add_id').show()");
261 echo
"<p class=\"notice\">" . _(
"Si vous voulez récupérer toutes les adaptations d'un dossier " .
262 " dans un autre dossier, vous pouvez en faire un modèle." .
263 " Seules les fiches, la structure des journaux, les périodes,... seront reprises " .
264 "et aucune donnée du dossier sur lequel le dossier est basé. Les données contenues dans les extensions ne sont pas effacées") .
"</p>";
265 echo
h2(_(
"Modèles locaux"));
268 echo _(
"Aucun modèle disponible");
273 echo
'<span style="display:block;margin-top:10">';
274 echo _(
'Filtre').Icon_Action::infobulle(23);
277 echo
'<table id="t_modele" class="table_large" style="border-spacing:10;border-collapse:separate" >';
279 "<TH>".$header->get_header(0).
"</TH>" .
280 "<TH>".$header->get_header(1).
"</TH>" .
281 "<TH>".$header->get_header(2).
"</TH>" .
282 "<TH>"._(
'Nom base de données').
"</TH>" .
290 $class = (
$i % 2 == 0) ?
"odd" :
"even";
297 $mod_status=_(
'Inexistant');
300 $mod_cn=
new Database($mod[
'mod_id'],
'mod');
301 if ( $mod_cn->exist_table(
"version")==0) {
303 $mod_status=_(
'Invalide');
306 printf(
'<TR class="' .
$class .
'" style="vertical-align:top">' .
307 '<TD>%d </td><td><b> %s</b> </TD>' .
308 '<TD><I> %s </I></TD>' .
312 HtmlInput::anchor(_(
'Effacer'),
'?action=modele_mgt&sa=del&m=' . $mod[
'mod_id'],
" onclick = \"modele_drop('{$mod['mod_id']}') \"") .
'</td>' .
314 '<td>' .
HtmlInput::anchor(_(
'Modifie'),
'?action=modele_mgt&sa=mod&m=' . $mod[
'mod_id'],
" onclick = \"modele_modify('{$mod['mod_id']}') \"") .
'</td>' .
317 . $mod[
'mod_id']) .
'</td>' .
318 '</TR>', $mod[
'mod_id'], $mod[
'mod_name'], $mod[
'mod_desc']);
322 echo
h2(_(
"Modèles disponibles dans le dépôt"));
324 require NOALYSS_INCLUDE .
"/upgrade-template.php";
328<div
id=
"folder_add_id" class=
"inner_box" style=
"display:none;top:50px">
336 $Res =
$cn->exec_sql(
"select dos_id, dos_name,dos_description from ac_dossier
346 $available.=
'<OPTION VALUE="' . $db[
'dos_id'] .
'">' . $db[
'dos_name'] .
':' . $db[
'dos_description'];
351 <form action=
"admin-noalyss.php?action=modele_mgt" METHOD=
"post" onsubmit=
"waiting_box();return true;">
354 <
td><?php echo _(
'Nom')?> </TD>
355 <TD><INPUT TYPE=
"TEXT" class=
"input_text" VALUE=
"" NAME=
"FMOD_NAME"></TD>
358 <TD><?php echo _(
'Description')?></TD>
359 <TD><TEXTAREA ROWS=
"2" class=
"input_text" COLS=
"60" NAME=
"FMOD_DESC"></Textarea></TD>
362 <TD> <?php echo _(
"Basé sur")?> </TD>
366 <ol
style=
"list-style: none">
368 <input
type=
"checkbox" class=
"input_text" name=
"DOC">
369 <?php echo _(
"Nettoyage des Documents et courriers (ce qui n'effacera pas les modèles de documents)")?>
372 <input
type=
"checkbox" class=
"input_text" name=
"CARD">
373 <?php echo _(
"Nettoyage de toutes les fiches (ce qui effacera client,
374 opérations prédéfinies fournisseurs modèles de documents et documents)")?>
377 <input
class=
"input_text" type=
"checkbox" name=
"CANAL">
378 <?php echo _(
"Nettoyage de la comptabilité analytique : effacement des plans et des postes, les opérations
379 sont de toute façon effacées")?>
382 <input
class=
"input_text" type=
"checkbox" name=
"PLUGIN">
383 <?php echo _(
"Effacement de toutes les données des plugins")?>
386 <INPUT TYPE=
"SUBMIT" class=
"button" VALUE=
"<?php echo _("Ajout d
'un modele")?>" >
391 //---------------------------------------------------------------------------
393 //---------------------------------------------------------------------------
396 if (!isset($_REQUEST['p_confirm
']))
398 echo _('Désolé, vous
n\
'avez pas coché la case');
403 $mod_id=
$http->request(
'm',
"number");
408 echo _(
'Donnée invalide');
413 $name =
$cn->get_value(
"select mod_name from modeledef where mod_id=$1", array($mod_id));
416 echo
"<h2 class=\"error\"> $msg inexistant</h2>";
420 if (
$cn->exist_database(
domaine.
'mod'.$mod_id) == 1)
424 if (
$cn->exec_sql(
$sql) ==
false)
428 echo
"<h2 class=\"error\">";
429 printf (_(
"Base de donnée %s mod %s est accèdée, déconnectez-vous d'abord"),
domaine,$mod_id )
435 $sql =
"delete from modeledef where mod_id=$1";
436 $cn->exec_sql(
$sql, array($mod_id));
438 printf (_(
"Le modèle %s est effacé").
"</H2>",
$name );
h2($p_string, $p_class="", $raw="")
noalyss_strlentrim($p_string)
tr($p_string, $p_extra='')
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
alert($p_msg, $buffer=false)
alert in javascript
static fetch_all($ret)
wrapper for the function pg_fetch_all
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
contains the class for connecting to Noalyss
static echo_file($msg, $print=true)
display the file
Description of class_syn_sort_table.
for($e=0; $e< count($afiche); $e++) exit
if(isset($_POST['upd']) &&isset($_POST['m'])) $cn
if(noalyss_strlentrim( $name)==0) if( $cn->exist_database(domaine. 'mod'. $mod_id)==1) $sql
if(isset($_POST["FMOD_NAME"])) $url