56 $sql=
"select md_id,md_name,md_affect,dt_value,md_filename from document_modele join document_type on(dt_id=md_type) order by md_name";
62 $r.=
'<p><form method="post">';
63 $r.=dossier::hidden();
65 $r.=
'<table id="document_template_tb" class="result" >';
68 $r.=
th(_(
'Catégorie'));
76 $even=(
$idx%2==0)?
'class="odd"':
'class="even"';
87 $href=http_build_query(array(
'gDossier'=>$dosid,
'md_id'=>
$row[
'md_id'],
'act'=>
'RAW:document_template'));
88 $r.=
'<A HREF="export.php?'.$href.
'">'.
h(
$row[
'md_filename']).
'</a>';
92 $c->name=
"dm_remove_".$row[
'md_id'];
104 $a->value=
"rm_template";
108 echo
h2(_(
"Aucun document"));
109 echo _(
"Il n'y a aucun document, cliquez sur Ajouter pour en ajouter un");
112 $b->label=
"Ajout d'un document";
113 $b->javascript=
"$('add_modele').style.display='block';new Draggable('add_modele',{starteffect:function(){
114 new Effect.Highlight(obj.id,{scroll:window,queue:'end'});}});";
131 if ( trim(strlen($this->md_name))==0)
141 if ( $this->md_id == -1)
145 $this->md_id=$this->
cn->get_next_seq(
'document_modele_md_id_seq');
146 $sql=
"insert into document_modele(md_id,md_name,md_type,md_affect)
147 values ($1,$2,$3,$4)";
149 $Ret=$this->
cn->exec_sql(
$sql,array($this->md_id,$this->md_name,$this->md_type,$this->md_affect));
151 $this->md_sequence=
"document_".$this->cn->get_next_seq(
"document_seq");
155 if ( $this->start != 0 &&
isNumber($this->start) == 1 )
157 $sql=
"alter sequence seq_doc_type_".$this->md_type.
" restart ".
$this->start;
158 $this->
cn->exec_sql(
$sql);
163 $new_name=tempnam($_ENV[
'TMP'],
'document_');
164 if ( strlen ($_FILES[
'doc'][
'tmp_name']) != 0 )
173 echo_error(
'class/class_document_modele.php',__LINE__,
"cannot upload document");
174 $this->
cn->rollback();
178 $ret=$this->
cn->exec_sql(
"select md_lob from document_modele where md_id=".$this->md_id);
182 $old_oid=
$r[
'md_lob'];
183 if (strlen(
""??$old_oid) != 0)
184 $this->
cn->lo_unlink($old_oid);
187 $this->
cn->exec_sql(
"update document_modele set md_lob=".$oid.
", md_mimetype='".$_FILES[
'doc'][
'type'].
"' ,md_filename='".$_FILES[
'doc'][
'name'].
"' where md_id=".$this->md_id);
192 echo
"<H1>"._(
"Erreur opération annulée").
"</H1>";
193 $this->
cn->rollback();
194 throw new Exception(
"DM191 : error loading template".__FILE__.__LINE__);
201 $this->
cn->rollback();
217 $sql=
"select md_lob from document_modele where md_id=$1";
218 $res=$this->
cn->exec_sql(
$sql,[$this->md_id]);
221 if ( !empty (
$r[
'md_lob']) &&$this->
cn->exist_blob(
$r[
'md_lob']) )
224 $this->
cn->lo_unlink(
$r[
'md_lob']);
227 $sql=
"delete from document_modele where md_id =$1";
228 $res=$this->
cn->exec_sql(
$sql,[$this->md_id]);
241 $r=
'<p class="notice">';
242 $r.=
'Veuillez introduire les modèles servant à générer vos documents';
244 $r.=
'<form enctype="multipart/form-data" method="post" onsubmit="return check_file_size(this,'. MAX_FILE_SIZE.
')">';
246 $r.=dossier::hidden();
250 $h->value=
"add_document";
257 $r.=
"<tr><td> Nom </td><td>".$t->input().
"</td>";
260 $r.=
"<tr><td>Catégorie de document </td>";
264 $w->value=$this->
cn->make_array(
'select dt_id,dt_value from document_type order by dt_value');
265 $r.=
"<td>".$w->input().
"</td></tr>";
268 $r.=
td(_(
'Affectation'));
270 $waffect->name=
'md_affect';
271 $waffect->value=$this->
cn->make_array(
"select dc_code,dc_comment from public.document_component order by dc_code");
273 $r.=
td($waffect->input());
278 $f->setAlertOnSize(
true);
279 $r.=
"<tr><td>fichier</td><td> ".$f->input().
"</td></tr>";
286 $r.=
"<tr><td> Numerotation commence a</td><td> ".$start->input().
"</td>";
287 $r.=
'<td class="notice">Si vous laissez à 0, la numérotation ne changera pas, la prochaine facture sera n+1, n étant le n° que vous avez donné</td>';
290 $r.=
'<ul class="aligned-block">';
304 $array=$this->
cn->get_array(
"SELECT md_id, md_name, md_lob, md_type, md_filename, md_mimetype,md_affect".
305 " FROM document_modele where md_id=$1",array($this->md_id));
306 if ( count(
$array) == 0 )
return null;
307 foreach ( array(
'md_name',
'md_lob',
'md_type',
'md_filename',
'md_mimetype',
'md_affect') as
$idx)
319 if ( trim(strlen(
$p_array[
'md_name']))==0)
325 $sql=
"update document_modele set md_name=$1,md_type=$2,md_affect=$3 where md_id=$4";
326 $this->
cn->exec_sql(
$sql,array(
336 $new_name=tempnam($_ENV[
'TMP'],
'document_');
337 if ( strlen ($_FILES[
'doc'][
'tmp_name']) != 0 )
346 echo_error(
'class/class_document_modele.php',__LINE__,
"cannot upload document");
347 $this->
cn->rollback();
351 $ret=$this->
cn->exec_sql(
"select md_lob from document_modele where md_id=".$this->md_id);
355 $old_oid=
$r[
'md_lob'];
356 if (strlen($old_oid) != 0)
357 $this->
cn->lo_unlink($old_oid);
361 $this->
cn->exec_sql(
"update document_modele
367 $_FILES[
'doc'][
'type'],
368 $_FILES[
'doc'][
'name'],
374 echo
"<H1>Error</H1>";
375 $this->
cn->rollback();
376 throw new Exception(
"Erreur".__FILE__.__LINE__);
383 $this->
cn->rollback();
h2($p_string, $p_class="", $raw="")
th($p_string, $p_extra='', $raw='')
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
record_log($p_message)
Record an error message into the log file of the server.
td($p_string='', $p_extra='')
surround the string with td
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
foreach($array as $idx=> $m) $w
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
Class for the document template.
update($p_array)
: update a document_modele in the database,
__construct($p_cn, $p_id=-1)
load()
load the value of a document_modele,the ag_id variable must be set
Save()
: Save a document_modele in the database, if the document_modele doesn't exist yet it will be first c...
move_uploaded_file($temporary_name, $target_path)
form()
show the form for loading a template
myList()
: show all the stored document_modele. return a string containing all the data separate by TD & TR ta...
Delete()
Remove a template.
Html Input for uploading file, must be in a form with enctype="multipart/form-data".
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...