Printing of card is now completely correct
This commit is contained in:
parent
bb5e2c55d6
commit
ba36e30de9
7 changed files with 175 additions and 98 deletions
|
|
@ -15,7 +15,8 @@
|
|||
2. Postgresql (version 732 minimum)
|
||||
2.1 Installation
|
||||
2.2 Configuration et démarrage de PostgreSql
|
||||
2.3 Pour la sécurité
|
||||
2.3 Optimisation
|
||||
2.4 Pour la sécurité
|
||||
|
||||
3. Apache
|
||||
3.1 Installation d'Apache
|
||||
|
|
@ -63,12 +64,11 @@
|
|||
Comme d'habitude pour postgres, il faut tout d'abord définir, créer
|
||||
l'utilisateur postgres puis initialiser l'endroit où seront stocké vos
|
||||
données (variable env. PGDATA), exemple
|
||||
|
||||
root#mkdir /data/psql
|
||||
root#chown postgres /data/psql
|
||||
root#su - postgres
|
||||
postgres#initdb -D /data/psql
|
||||
postgres#pg_ctl -D /data/psql -o '-i' start
|
||||
root#mkdir /data/psql
|
||||
root#chown postgres /data/psql
|
||||
root#su - postgres
|
||||
postgres#initdb -D /data/psql
|
||||
postgres#pg_ctl -D /data/psql -o '-i' start
|
||||
|
||||
|
||||
|
||||
|
|
@ -99,7 +99,21 @@
|
|||
/opt/psql732/bin/createuser -a -d $USER
|
||||
|
||||
|
||||
[1m2.3. Pour la sécurité[0m
|
||||
[1m2.3. Optimisation[0m
|
||||
|
||||
Posgresql est une base de données très rapide, cependant, il vous
|
||||
faudra configurer pour pouvoir en bénéficier
|
||||
|
||||
· Augmenter la zone mémoire pour les tri (dans postgres.conf)
|
||||
sort_mem = 8192
|
||||
|
||||
· Faites tourner régulièrement vacumdb -a -z grâce au crontab
|
||||
|
||||
· Dans php.ini, bien utiliser les permanent_connection
|
||||
|
||||
· à compléter
|
||||
|
||||
[1m2.4. Pour la sécurité[0m
|
||||
|
||||
Vous pouvez ajouter la sécurité à votre server Postgresql en changeant
|
||||
dans pg_hba.conf. Mais avant de faire cela, ajoutez un mot de passe à
|
||||
|
|
@ -115,7 +129,6 @@
|
|||
172.16.30.0 255.255.255.0 md5 local all
|
||||
phpcompta 172.16.30.0 255.255.255.0 md5
|
||||
|
||||
|
||||
Ensuite soit vous utilisez la variable d'environnement PGPASSWORD qui
|
||||
contient votre mot de passe soit avec le fichier .pgpass dont la syn-
|
||||
taxe est
|
||||
|
|
@ -129,6 +142,7 @@
|
|||
Ensuite soit vous utilisez la variable d'environnement PGPASSWORD qui
|
||||
contient votre mot de passe soit avec le fichier .pgpass dont la
|
||||
syntaxe est
|
||||
|
||||
host:port:database:username:password
|
||||
|
||||
|
||||
|
|
@ -174,13 +188,14 @@
|
|||
vous-même, les options suivantes fonctionnent
|
||||
|
||||
|
||||
./configure --prefix=/opt/php431 \
|
||||
--with-apxs2=/opt/http2/bin/apxs \
|
||||
--with-fastcgi \
|
||||
--with-zlib \
|
||||
--with-pgsql=/opt/psql732 \
|
||||
--with-mysql \
|
||||
--with-apache2=/software/httpd-2.0.44
|
||||
|
||||
./configure --prefix=/opt/php431 \
|
||||
--with-apxs2=/opt/http2/bin/apxs \
|
||||
--with-fastcgi \
|
||||
--with-zlib \
|
||||
--with-pgsql=/opt/psql732 \
|
||||
--with-mysql \
|
||||
--with-apache2=/software/httpd-2.0.44
|
||||
|
||||
|
||||
|
||||
|
|
@ -197,6 +212,11 @@
|
|||
Sinon, adaptez votre fichier, il doit avoir au minimum les options
|
||||
suivantes
|
||||
|
||||
|
||||
magic_quotes_gpc = Off
|
||||
magic_quotes_runtime = Off
|
||||
magic_quotes_sybase = Off
|
||||
|
||||
register_globals = on
|
||||
|
||||
[Session]
|
||||
|
|
@ -234,7 +254,6 @@
|
|||
|
||||
· Là on vous comptez installer le soft, créer le répertoire, règler
|
||||
les permissions
|
||||
|
||||
· connecter vous en tant que l'utilisateur qu'il a le droit dans le
|
||||
répertoire décrit plus haut, puis taper ./install.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,16 @@ puisse cr
|
|||
</quote>
|
||||
</p>
|
||||
</sect1>
|
||||
<sect1>Optimisation
|
||||
<p> Posgresql est une base de données très rapide, cependant, il vous faudra configurer
|
||||
pour pouvoir en bénéficier
|
||||
<itemize>
|
||||
<item> Augmenter la zone mémoire pour les tri (dans postgres.conf) sort_mem = 8192</item>
|
||||
<item> Faites tourner régulièrement vacumdb -a -z grâce au crontab</item>
|
||||
<item> Dans php.ini, bien utiliser les permanent_connection </item>
|
||||
<item> à compléter </item>
|
||||
</itemize>
|
||||
</sect1>
|
||||
<sect1> Pour la sécurité
|
||||
<p>Vous pouvez ajouter la sécurité à votre server Postgresql en changeant
|
||||
dans pg_hba.conf. Mais avant de faire cela, ajoutez un mot de passe à
|
||||
|
|
|
|||
|
|
@ -42,25 +42,19 @@ if ( isset ($_POST['fd_id'])) {
|
|||
$fiche_def=new fiche_def($cn,$_POST['fd_id']);
|
||||
$fiche=new fiche($cn);
|
||||
$e=$fiche->GetByType($fiche_def->id);
|
||||
// var_dump($e);
|
||||
$old=-1;
|
||||
foreach ($e as $detail) {
|
||||
if ($old == -1 ) {
|
||||
$old=$detail->id;
|
||||
|
||||
$fiche_def->GetAttribut();
|
||||
foreach ($fiche_def->attribut as $attribut)
|
||||
printf("%s\t",$attribut);
|
||||
printf("\n");
|
||||
}
|
||||
if ( $old != $detail->id) {
|
||||
$old=$detail->id;
|
||||
printf("\n");
|
||||
}
|
||||
printf ("%s\t",$detail->attribut_value);
|
||||
}
|
||||
|
||||
// Heading
|
||||
$fiche_def->GetAttribut();
|
||||
foreach ($fiche_def->attribut as $attribut)
|
||||
printf("%s\t",$attribut->ad_text);
|
||||
printf("\n");
|
||||
|
||||
foreach ($e as $detail) {
|
||||
foreach ( $detail->attribut as $dattribut )
|
||||
printf ("%s\t",$dattribut->av_text);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
exit;
|
||||
?>
|
||||
|
|
|
|||
55
include/class_attribut.php
Normal file
55
include/class_attribut.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
class Attribut {
|
||||
var $ad_id; // pk for attribut
|
||||
var $ad_text; // type of content
|
||||
var $av_text; // Description (content)
|
||||
var $cn; // database connection
|
||||
function Attribut($p_ad_id) {
|
||||
$this->ad_id=$p_ad_id;
|
||||
$this->cn=-1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* function SortAttributeById
|
||||
**************************************************
|
||||
* Purpose : Sort an array of object attribut thx the
|
||||
* ad_id
|
||||
* parm :
|
||||
* - array of Attribut objects
|
||||
* gen :
|
||||
* -
|
||||
* return: the ordered array
|
||||
*/
|
||||
function SortAttributeById($p_attribut) {
|
||||
for ($i=0;$i< sizeof($p_attribut)-1;$i++) {
|
||||
if ( $p_attribut[$i]->ad_id > $p_attribut[$i+1]->ad_id ) {
|
||||
// then swap them
|
||||
$t=$p_attribut[$i];
|
||||
$p_attribut[$i]=$p_attribut[$i+1];
|
||||
$p_attribut[$i+1] = $t;
|
||||
$i=0;
|
||||
}
|
||||
}
|
||||
|
||||
return $p_attribut;
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
include_once("class_attribut.php");
|
||||
|
||||
class fiche_def {
|
||||
var $cn; // database connection
|
||||
var $id; // id (fiche_def.fd_id
|
||||
|
|
@ -54,7 +56,9 @@ class fiche_def {
|
|||
return ;
|
||||
for ($i=0;$i < $Max;$i++) {
|
||||
$row=pg_fetch_array($Ret,$i);
|
||||
$this->attribut[$i]=$row['ad_text'];
|
||||
$t = new Attribut($row['ad_id']);
|
||||
$t->ad_text=$row['ad_text'];
|
||||
$this->attribut[$i]=$t;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,9 +123,7 @@ class fiche {
|
|||
var $cn;// database connection
|
||||
var $id; // fiche.f_id
|
||||
var $fiche_def; // fd_id
|
||||
var $attribut_id; // .ad_id
|
||||
var $attribut_def; // ad_text
|
||||
var $attribut_value; // av_text
|
||||
var $attribut; // array of attribut object
|
||||
function fiche($p_cn,$p_id=0) {
|
||||
$this->cn=$p_cn;
|
||||
$this->id=$p_id;
|
||||
|
|
@ -131,19 +133,12 @@ class fiche {
|
|||
if ( $this->id == 0){
|
||||
return;
|
||||
}
|
||||
// $sql="select *
|
||||
// from jnt_fic_att_value
|
||||
// natural join fiche
|
||||
// natural join attr_value
|
||||
// left join attr_def on (attr_def.ad_id=attr_value) where f_id=".$this->id;
|
||||
|
||||
$sql="select *
|
||||
from
|
||||
( select * from fiche_def natural join jnt_fic_attr natural join attr_def where fd_id = (select fd_id from fiche where f_id=$this->id))
|
||||
as w
|
||||
full join ( select * from jnt_fic_att_value where f_id=$this->id ) as a on (w.ad_id=a.ad_id)
|
||||
order by f_id,w.ad_id"
|
||||
;
|
||||
$sql="select *
|
||||
from jnt_fic_att_value
|
||||
natural join fiche
|
||||
natural join attr_value
|
||||
left join attr_def using (ad_id) where f_id=".$this->id.
|
||||
" order by ad_id";
|
||||
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
if ( ($Max=pg_NumRows($Ret)) == 0 )
|
||||
|
|
@ -151,10 +146,37 @@ order by f_id,w.ad_id"
|
|||
for ($i=0;$i<$Max;$i++) {
|
||||
$row=pg_fetch_array($Ret,$i);
|
||||
$this->fiche_def=$row['fd_id'];
|
||||
$this->attribut_id=$row['ad_id'];
|
||||
$this->attribut_value=$row['av_text'];
|
||||
$this->attribut_def=$row['ad_text'];
|
||||
$t=new Attribut ($row['ad_id']);
|
||||
$t->ad_text=$row['ad_text'];
|
||||
$t->av_text=$row['av_text'];
|
||||
$this->attribut[$i]=$t;
|
||||
}
|
||||
$e=new Fiche_def($this->cn,$this->fiche_def);
|
||||
$e->GetAttribut();
|
||||
|
||||
if ( sizeof($this->attribut) != sizeof($e->attribut ) ) {
|
||||
|
||||
// !!! Missing attribute
|
||||
foreach ($e->attribut as $f ) {
|
||||
$flag=0;
|
||||
foreach ($this->attribut as $g ) {
|
||||
if ( $g->ad_id == $f->ad_id )
|
||||
$flag=1;
|
||||
}
|
||||
if ( $flag == 0 ) {
|
||||
// there's a missing one, we insert it
|
||||
$t=new Attribut ($f->ad_id);
|
||||
$t->av_text="";
|
||||
$t->ad_text=$f->ad_text;
|
||||
$this->attribut[$Max]=$t;
|
||||
$Max++;
|
||||
} // if flag == 0
|
||||
|
||||
}// foreach
|
||||
$this->attribut=SortAttributeById($this->attribut);
|
||||
|
||||
|
||||
}//missing attribut
|
||||
}
|
||||
|
||||
function size() {
|
||||
|
|
@ -164,29 +186,11 @@ order by f_id,w.ad_id"
|
|||
return 0;
|
||||
}
|
||||
function GetByType($p_fd_id) {
|
||||
// $sql="select *
|
||||
// from jnt_fic_att_value
|
||||
// natural join fiche
|
||||
// natural join attr_value natural
|
||||
// join attr_def where fd_id=".$p_fd_id.
|
||||
// " order by f_id,ad_id";
|
||||
$sql="select *
|
||||
$sql="select *
|
||||
from
|
||||
( select * from
|
||||
fiche_def
|
||||
natural join jnt_fic_attr
|
||||
natural join attr_def
|
||||
where fd_id = $p_fd_id
|
||||
) as w
|
||||
right join
|
||||
( select *
|
||||
from jnt_fic_att_value
|
||||
inner join attr_def using (ad_id)
|
||||
inner join attr_value using (jft_id)
|
||||
join fiche using (f_id) where fd_id=$p_fd_id
|
||||
) as a on (w.ad_id=a.ad_id)
|
||||
order by f_id,w.ad_id"
|
||||
;
|
||||
fiche
|
||||
where fd_id=".$p_fd_id;
|
||||
|
||||
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
if ( ($Max=pg_NumRows($Ret)) == 0 )
|
||||
|
|
@ -195,11 +199,9 @@ order by f_id,w.ad_id"
|
|||
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$row=pg_fetch_array($Ret,$i);
|
||||
$all[$i]=new fiche($this->cn,$row['f_id']);
|
||||
$all[$i]->fiche_def=$row['fd_id'];
|
||||
$all[$i]->attribut_id=$row['ad_id'];
|
||||
$all[$i]->attribut_value=$row['av_text'];
|
||||
$all[$i]->attribut_def=$row['ad_text'];
|
||||
$t=new fiche($this->cn,$row['f_id']);
|
||||
$t->getAttribut();
|
||||
$all[$i]=$t;
|
||||
|
||||
}
|
||||
return $all;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ $fiche_def=new fiche_def($cn);
|
|||
|
||||
|
||||
$fiche_def->GetAll();
|
||||
// var_dump($fiche);
|
||||
|
||||
$i=0;
|
||||
foreach ($fiche_def->all as $l_fiche) {
|
||||
$a[$i]=array("user_impress.php?type=fiche&fd_id=".$l_fiche->id,$l_fiche->label);
|
||||
|
|
@ -55,24 +55,21 @@ if ( isset ($_GET['fd_id'])) {
|
|||
// var_dump($e);
|
||||
$old=-1;
|
||||
echo "<TABLE>";
|
||||
echo "<TR>";
|
||||
$fiche_def->GetAttribut();
|
||||
foreach ($fiche_def->attribut as $attribut)
|
||||
echo "<TH>".$attribut->ad_text."</TH>";
|
||||
echo "<TR></TR>";
|
||||
|
||||
foreach ($e as $detail) {
|
||||
if ($old == -1 ) {
|
||||
$old=$detail->id;
|
||||
echo "<TR>";
|
||||
$fiche_def->GetAttribut();
|
||||
foreach ($fiche_def->attribut as $attribut)
|
||||
echo "<TH>".$attribut."</TH>";
|
||||
echo "<TR></TR>";
|
||||
}
|
||||
if ( $old != $detail->id) {
|
||||
$old=$detail->id;
|
||||
echo "</TR><TR>";
|
||||
}
|
||||
echo "<TD>".$detail->attribut_value."</TD>";
|
||||
echo "<TR>";
|
||||
foreach ( $detail->attribut as $dattribut ) {
|
||||
echo "<TD>".$dattribut->av_text."</TD>";
|
||||
}
|
||||
echo "</TR>";
|
||||
}
|
||||
|
||||
echo "</tr></TABLE>";
|
||||
echo "</TABLE>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
|
@ -80,7 +80,7 @@ function DbConnect($p_db=-1,$p_type='dossier') {
|
|||
|
||||
|
||||
$password=phpcompta_password;
|
||||
$a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'");
|
||||
$a=pg_pconnect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'");
|
||||
echo_debug ("connect to $p_db");
|
||||
return $a;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue