VERS='5.68.06'

echo "Mise a jour de la base de donnees pour Version $VERS"

isql - - <<EOT

database gc;

UPDATE 
  gc_parsys 
SET 
  version='$VERS'
WHERE
  version<'$VERS';

create table gc_crtf 
  (
    cmpt  char(6),
    refer char(10),
    debit smallint,
    libel char(30),
    dtcrtf date,
    mont  float,
    coef  float,
    valeur float,
    numdep smallint,
    flag  smallint,
    nseek serial not null
  );

create index ixcrtf1 on gc_crtf (cmpt,refer,dtcrtf);
create index ixcrtf2 on gc_crtf (cmpt,dtcrtf);
create index ixcrtf3 on gc_crtf (nseek);
create index ixcrtf4 on gc_crtf (dtcrtf,numdep);


alter table gc_soc add (
  cf_nbach  integer,
  cf_trchpt integer,
  cf_vtpt  float
);

alter table gc_soc add (
  cf_nbmaxach  integer,
  cf_nbmaxtrch  integer
);

update gc_soc set cf_nbach  = 10 where cf_nbach is null;
update gc_soc set cf_trchpt = 0 where cf_trchpt is null;
update gc_soc set cf_vtpt   = 1 where cf_vtpt is null;
update gc_soc set cf_nbmaxach  = 30 where cf_nbmaxach is null;
update gc_soc set cf_nbmaxtrch  = 0 where cf_nbmaxtrch is null;


alter table gc_fam add ( cf_ptfm float );

update gc_fam set cf_ptfm   = 1 where cf_ptfm is null;

delete from gc_cli where code="C_CRTF";
insert into gc_cli (
  code, rsoc, ad1, ad2, cpv, codpost, respon, tel, sect, vnd, categ, typcli, 
  nbfact, codtar, mdreg, delreg, delmoyreg, jreg, typreg, bank, codbank, 
  guich, compte, plafcr, solde, bloque, activite, statrel, creat, objectif, 
  remise, devise, nbcom, valcom, fax, vnda, cmpt, identsoc, crtf, datcf, 
  birth, datvl, siret, siren, fctrdet, clascmpt, cdtrn, freq, dtvisite, subroge,
  classub, coefsav1, coefsav2, rel)
values  (
  'C_CRTF', 'CLIENT CARTE FIDELITE', '', '', 'FDF', '97200', '', '', '00', '00', 
  '00', 1, 1, 1, 0, 0, 0, 0, 0, '', '', '', '', 0, 0, 0, 1, 0, '01-01-1980',
  0, 0, 0, 0, 0, '', '00', 'C_CRTF', 0, 1, '01-01-1980', '01-01-1980',
  '01-01-1980', '', '', 1, 'C', '', 0, '01-01-1980', 
  0, 'C', 1, 1, 0);

CLOSE DATABASE;

EOT

chmod 666 $DBPATH/gc.dbs/*.idx
chmod 666 $DBPATH/gc.dbs/*.dat

echo "Mise a jour terminee"



