IMPROVE setup html based, ability to patch
This commit is contained in:
parent
f27599b4d3
commit
8419edba4d
2 changed files with 109 additions and 6 deletions
|
|
@ -41,7 +41,47 @@ include_once('postgres.php');
|
|||
include_once('debug.php');
|
||||
include_once('ac_common.php');
|
||||
include_once('variable.php');
|
||||
/* function ExecuteScript
|
||||
**************************************************
|
||||
* Purpose : Execute a sql script
|
||||
*
|
||||
* parm :
|
||||
* - $p_cn database connection
|
||||
* - $script script name
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* none
|
||||
*/
|
||||
function ExecuteScript($p_cn,$script) {
|
||||
$hf=fopen($script,'r');
|
||||
$sql="";
|
||||
while (!feof($hf)) {
|
||||
$buffer=fgets($hf);
|
||||
// comment are not execute
|
||||
if ( strrpos($buffer,"--") == true) {
|
||||
continue;
|
||||
}
|
||||
// Blank Lines Are Skipped
|
||||
If ( Strlen($buffer)==0) {
|
||||
Echo "Blank";
|
||||
Continue;
|
||||
}
|
||||
|
||||
// No semi colon -> multiline command
|
||||
if ( strpos($buffer,';') == false ) {
|
||||
$sql.=$buffer;
|
||||
continue;
|
||||
}
|
||||
// cut the semi colon
|
||||
$buffer=str_replace (';','',$buffer);
|
||||
$sql.=$buffer;
|
||||
print "Execute $sql <hr>";
|
||||
ExecSql($p_cn,$sql);
|
||||
$sql="";
|
||||
} // while (feof)
|
||||
fclose($hf);
|
||||
}
|
||||
|
||||
// Verify some PHP parameters
|
||||
// magic_quotes_gpc = Off
|
||||
|
|
@ -67,7 +107,7 @@ if ( ereg("\.\.\/include",ini_get('include_path')) == false )
|
|||
$cn=DbConnect(-2,'phpcompta');
|
||||
|
||||
if ($cn == false ) {
|
||||
print "<p> Vous devez absolument taper dans une console la commande 'createuser -d phpcompta'
|
||||
print "<p> Vous devez absolument taper dans une console la commande 'createuser -d phpcompta -P dany'
|
||||
puis la commande 'createdb -O phpcompta phpcompta'. </p>
|
||||
<p>Ces commandes créeront l'utilisateur phpcompta
|
||||
puis la base de données par défaut de phpcompta.</p>";
|
||||
|
|
@ -87,12 +127,20 @@ if ($account == 0 ) {
|
|||
$r=system("$psql -U phpcompta account_repository -f sql/account_repository/data.sql",$r);
|
||||
echo "Creation of Démo";
|
||||
ExecSql($cn,"create database dossier1 encoding='latin1'");
|
||||
$r=system("$psql -U phpcompta dossier1 -f sql/dossier1/schema.sql",$r);
|
||||
$r=system("$psql -U phpcompta dossier1 -f sql/dossier1/data.sql",$r);
|
||||
// $r=system("$psql -U phpcompta dossier1 -f sql/dossier1/schema.sql",$r);
|
||||
// $r=system("$psql -U phpcompta dossier1 -f sql/dossier1/data.sql",$r);
|
||||
$cn=DbConnect(1,'dossier');
|
||||
ExecuteScript($cn,'sql/dossier1/schema.sql');
|
||||
ExecuteScript($cn,'sql/dossier1/data.sql');
|
||||
|
||||
echo "Creation of Modele1";
|
||||
ExecSql($cn,"create database mod1 encoding='latin1'");
|
||||
$r=system("$psql -U phpcompta mod1 -f sql/mod1/schema.sql",$r);
|
||||
$r=system("$psql -U phpcompta mod1 -f sql/mod1/data.sql",$r);
|
||||
$cn=DbConnect(1,'mod');
|
||||
ExecuteScript($cn,'sql/mod1/schema.sql');
|
||||
ExecuteScript($cn,'sql/mod1/data.sql');
|
||||
|
||||
// $r=system("$psql -U phpcompta mod1 -f sql/mod1/schema.sql",$r);
|
||||
// $r=system("$psql -U phpcompta mod1 -f sql/mod1/data.sql",$r);
|
||||
ob_end_clean();
|
||||
|
||||
}
|
||||
|
|
@ -107,4 +155,28 @@ if ( ($Res=ExecSql($a,"select * from ac_users") ) == false ) {
|
|||
exit ("<h2 class=\"error\">".__LINE__." test has failed !!!</h2>");
|
||||
} else
|
||||
print "Connect to database success <br>";
|
||||
echo "<h2 class=\"info\"> Congratulation : Test successfull</h2>";
|
||||
echo "<h2 class=\"info\"> Congratulation : Test successfull</h2>";
|
||||
|
||||
echo "<h2 class=\"info\"> Patching databases</h2>";
|
||||
|
||||
$cn=DbConnect();
|
||||
$Res=ExecSql($cn,"select dos_id, dos_name from ac_dossier");
|
||||
$MaxDossier=pg_NumRows($Res);
|
||||
|
||||
for ($e=0;$e < $MaxDossier;$e++) {
|
||||
$db_row=pg_fetch_array($Res,$e);
|
||||
echo "Patching ".$db_row['dos_name'];
|
||||
if ( GetVersion($db_row['dos_id']) == 3 ) {
|
||||
$db=DbConnect($db_row['dos_id'],'dossier');
|
||||
ExecuteScript($db,'sql/patch/upgrade4.sql');
|
||||
|
||||
$sql="select jrn_def_id from jrn_def ";
|
||||
$Res=ExecSql($db,$sql);
|
||||
$Max=pg_NumRows($Res);
|
||||
for ($seq=0;$seq<$Max;$seq++) {
|
||||
$row=pg_fetch_array($Res,$seq);
|
||||
$sql=sprintf ("create sequence s_jrn_%d",$row['jrn_def_id']);
|
||||
ExecSql($db,$sql);
|
||||
}
|
||||
} // version == 3
|
||||
}
|
||||
|
|
|
|||
31
html/admin/sql/patch/upgrade4.sql
Normal file
31
html/admin/sql/patch/upgrade4.sql
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-- upgrade
|
||||
comment on table action is 'The different privileges';
|
||||
comment on table attr_def is 'The available attributs for the cards';
|
||||
comment on table attr_min is 'The minimum attributs for the cards';
|
||||
comment on table attr_min is 'The value of attributs for the cards';
|
||||
comment on table centralized is 'The centralized journal';
|
||||
comment on table fiche is 'Cards';
|
||||
comment on table fiche_def is 'Cards definition';
|
||||
comment on table fiche_def_ref is 'Family Cards definition';
|
||||
comment on table form is 'Forms';
|
||||
comment on table form is 'Forms content';
|
||||
comment on table jnt_fic_att_value is 'join between the card and the attribut definition';
|
||||
comment on table jnt_fic_attr is 'join between the family card and the attribut definition';
|
||||
comment on table jrn is 'Journal: content one line for a group of accountancy writing';
|
||||
comment on table jrnx is 'Journal: content one line for each accountancy writing';
|
||||
comment on table jrn_action is 'Possible action when we are in journal (menu)';
|
||||
comment on table jrn_def is 'Definition of a journal, his properties';
|
||||
comment on table jrn_rapt is 'Rapprochement between operation';
|
||||
comment on table jrn_type is 'Type of journal (Sell, Buy, Financial...)';
|
||||
comment on table parm_money is 'Currency conversion';
|
||||
comment on table parm_periode is 'Periode definition';
|
||||
comment on table stock_goods is 'About the goods';
|
||||
comment on table tmp_pcmn is 'Plan comptable minimum normalisé';
|
||||
comment on table tva_rate is 'Rate of vat';
|
||||
create index x_jr_grpt_id on jrn (jr_grpt_id);
|
||||
create index x_j_grpt on jrnx(j_grpt);
|
||||
create index x_poste on jrnx(j_poste );delete from jrn_action where ja_name='Impression';
|
||||
delete from fiche where f_id not in (select f_id from jnt_fic_att_value);
|
||||
alter table jrn add j_pj int4;
|
||||
alter table jrn add jr_opid int4;
|
||||
upgrade version set val=4;
|
||||
Loading…
Add table
Add a link
Reference in a new issue