diff --git a/.cvsignore b/.cvsignore deleted file mode 100755 index bfaef7e97..000000000 --- a/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -cache -compile -tmp diff --git a/class_periode.php b/class_periode.php new file mode 100644 index 000000000..4aa2ae6d6 --- /dev/null +++ b/class_periode.php @@ -0,0 +1,274 @@ +cn=$p_cn; + } + function set_jrn($p_jrn) { + $this->jrn_def_id=$p_jrn; + } + function set_periode($pp_id){ + $this->p_id=$pp_id; + } + function is_closed() { + if ( $this->jrn_def_id != 0 ) + $sql="select status from jrn_periode ". + " where jrn_def_id=".$this->jrn_def_id. + " and p_id =".$this->p_id; + else + $sql="select p_closed as status from parm_periode ". + " where ". + " p_id =".$this->p_id; + $res=ExecSql($this->cn,$sql); + $status=pg_fetch_result($res,0,0); + echo_debug(__FILE__.':'.__LINE__.'- is_closed','return ',$status); + if ( $status == 'CL' || $status=='t' ||$status=='CE') + return 1; + return 0; + } + function is_open() { + if ( $this->jrn_def_id != 0 ) + $sql="select status from jrn_periode ". + " where jrn_def_id=".$this->jrn_def_id. + " and p_id =".$this->p_id; + else + $sql="select p_closed as status from parm_periode ". + " where ". + " p_id =".$this->p_id; + $res=ExecSql($this->cn,$sql); + $status=pg_fetch_result($res,0,0); + if ( $status == 'OP' || $status=='f' ) + return 1; + return 0; + } + function is_centralized() { + if ( $this->jrn_def_id != 0 ) + $sql="select status from jrn_periode ". + " where jrn_def_id=".$this->jrn_def_id. + " and p_id =".$this->p_id; + else + $sql="select p_centralized as status from parm_periode ". + " where ". + " p_id =".$this->p_id; + $res=ExecSql($this->cn,$sql); + $status=pg_fetch_result($res,0,0); + if ( $status == 'CE' || $status=='t' ) + return 1; + return 0; + } + function close() { + if ( $this->jrn_def_id == 0 ) { + ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=". + $this->p_id); + ExecSql($this->cn,"update jrn_periode set status='CL' ". + " where p_id = ".$this->p_id); + + return; + }else { + ExecSql($this->cn,"update jrn_periode set status='CL' ". + " where jrn_def_id=".$this->jrn_def_id." and ". + " p_id = ".$this->p_id); + /* if all ledgers have this periode closed then synchro with + the table parm_periode + */ + $nJrn=CountSql( $this->cn,"select * from jrn_periode where ". + " p_id=".$this->p_id); + $nJrnPeriode=CountSql( $this->cn,"select * from jrn_periode where ". + " p_id=".$this->p_id." and status='CL'"); + + if ( $nJrnPeriode==$nJrn) + ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=".$this->p_id); + return; + } + + } + function centralized() { + if ( $this->jrn_def_id == 0 ) { + ExecSql($this->cn,"update parm_periode set p_central=true"); + return; + }else { + ExecSql($this->cn,"update jrn_periode set status='CE' ". + " where ". + " p_id = ".$this->p_id); + return; + } + + } +/*! + * \brief Show all the periode and their status + * + * \param $p_cn database connection + * + * \return nothing + * + * + */ + + function display_form_periode() { + $str_dossier=dossier::get(); + + if ( $this->jrn_def_id==0 ) { + $Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,p_central,p_closed,p_exercice + from parm_periode order by p_start,p_end"); + $Max=pg_NumRows($Res); + echo ''; + echo ""; + echo ''; + echo ''; + echo ''; + echo ""; + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Res,$i); + echo ''; + echo ''; + echo ''; + echo ''; + + if ( $l_line['p_closed'] == 't' ) { + $closed=($l_line['p_central']=='t')?'':''; + $change=''; + $remove=''; + } else { + $closed=''; + + } + echo ''; + echo dossier::hidden(); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + echo '
Date début Date fin Exercice
'.$l_line['date_start'].' '.$l_line['date_end'].' '.$l_line['p_exercice'].'CentraliséeFermée'; + $closed.=' Cloturer'; + $change=''; + $change.=' Changer"; + $remove=''; + $remove.=' Efface"; + + } + echo "$closed"; + echo $change; + + echo $remove; + + echo '
'; + echo '
'; + + } else { + $Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,status,p_exercice + from parm_periode join jrn_periode using (p_id) where jrn_def_id=".$this->jrn_def_id." + order by p_start,p_end"); + $Max=pg_NumRows($Res); + $r=ExecSql($this->cn,'select jrn_Def_name from jrn_Def where jrn_Def_id='. + $this->jrn_def_id); + $jrn_name=pg_fetch_result($r,0,0); + echo '

Journal '.$jrn_name.'

'; + echo ''; + echo ""; + echo ''; + echo ''; + echo ''; + echo ""; + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Res,$i); + echo ''; + echo ''; + echo ''; + echo ''; + + if ( $l_line['status'] != 'OP' ) { + $closed=($l_line['status']=='CE')?'':''; + } else { + $closed=''; + } + echo "$closed"; + + echo ''; + + } + echo '
Date début Date fin Exercice
'.$l_line['date_start'].' '.$l_line['date_end'].' '.$l_line['p_exercice'].'CentraliseeFermée'; + $closed.=' Cloturer'; + $closed.='
'; + + } + } + function insert($p_date_start,$p_date_end,$p_exercice) { + if (isDate($p_date_start) == null || + isDate($p_date_end) == null || + strlen (trim($p_exercice)) == 0 || + (string) $p_exercice != (string)(int) $p_exercice) + { + return 1; + } + $p_id=NextSequence($this->cn,'s_periode'); + $sql=sprintf(" insert into parm_periode(p_id,p_start,p_end,p_closed,p_exercice)". + "values (%d,to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')". + ",'f','%s')", + $p_id, + $p_date_start, + $p_date_end, + $p_exercice); + try { + StartSql($this->cn); + $Res=ExecSql($this->cn,$sql); + $Res=ExecSql($this->cn,"insert into jrn_periode (jrn_def_id,p_id,status) ". + "select jrn_def_id,$p_id,'OP' from jrn_def"); + Commit($this->cn); + } catch (Exception $e) { + Rollback($this->cn); + echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e); + echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e->getMessage()); + return 1; + } + return 0; + } + static function test_me() { + $cn=DbConnect(dossier::id()); + $obj=new Periode($cn); + $obj->set_jrn(1); + $obj->display_form_periode(); + } +} diff --git a/contrib/document_test/facture-calc.ods b/contrib/document_test/facture-calc.ods index 1061427b4..5c450090f 100644 Binary files a/contrib/document_test/facture-calc.ods and b/contrib/document_test/facture-calc.ods differ diff --git a/scripts/add-db.sh b/dev/add-db.sh similarity index 100% rename from scripts/add-db.sh rename to dev/add-db.sh diff --git a/scripts/cleanup.sh b/dev/cleanup.sh similarity index 96% rename from scripts/cleanup.sh rename to dev/cleanup.sh index e31397a22..30f23db97 100755 --- a/scripts/cleanup.sh +++ b/dev/cleanup.sh @@ -1,6 +1,6 @@ #!/bin/bash # clean all phpcompta related DB. -DOMAIN="beta_" +DOMAIN="rel4102_" export PGPASSWORD="dany" export PGUSER="phpcompta" export PGHOST=localhost diff --git a/doc/.cvsignore b/doc/.cvsignore deleted file mode 100644 index 25e1de385..000000000 --- a/doc/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -*.html -*.pdf -*.txt diff --git a/doc/INSTALL-fr.sgml b/doc/INSTALL-fr.sgml deleted file mode 100644 index c044b9a2b..000000000 --- a/doc/INSTALL-fr.sgml +++ /dev/null @@ -1,329 +0,0 @@ - -
- PhpCompta Installation - -originally written by Dany De Bontridder - -$Revision$ $Date$ - -Ce document décrit l'installation complète de PhpCompta et explique comment -ont été installés les programmes dont PhpCompta dépend. -PhpCompta , -site savannah - - - -Avertissement -

Si vous installez sur Linux, l'installation d'apache, postgres et php doit se -faire avec les "packages" standards -fournis; ces "packages" sont largement suffisants. Les explications -données ici sur l'installation de ces produits sont destinées à des -utilisateurs avancés. En général vous pourrez l'installer assez facilement - -Il existe aussi un manuel d'installation exhaustif pour Debian, pleins d'informations utiles -. - - -

Si vous installez sous Windows, il est assez compliqué de recompiler. -Il est préférable d'utiliser les programmes fournis sur - et -. - - -

Cependant, les configurations des différents produits sont importantes -et devraient être lues avant d'appeler à l'aide. - - - -Postgresql (version 8.0.1 minimum) -Installation -

-Soit avec des binaires préparés, soit à partir du code source -

-

Le plus simple est d'utiliser les binaires de votre distribution, ne -compiler ces programmes que si vraiment vous devez le faire ou que vous préfèrez -avoir la dernière version disponible. -

-

-Si vous décidez de le compiler vous-même, les -options suivantes fonctionnent - -./configure -with-tk --with-python --with-perl --prefix=/ou_vous_voulez - -

- -Configuration et démarrage de PostgreSql -Optimisation -

Posgresql est une base de données très rapide, cependant, il vous faudra configurer -pour pouvoir en bénéficier. Les paramètres par défaut sont prévus pour une machine qui n'a -que 16 Mb de RAM... Donc, aller voir la documentation sur Postgresql.org, chapitre -Run-time Configuration. - -

Les paramètres que vous pouvez utiliser si vous avez une machine d'au moins 256 Mb: - - Augmenter la zone mémoire pour les tri (dans postgres.conf) work_mem = 8192; cette -zone mémoire est important car elle a trait à la mémoire utilisée pour les tris et les -jointures! attention ce paramètre donne la consommation mémoire par session ! - - Faites tourner régulièrement vacumdb -a -z grâce au crontab(une fois par jour) - Dans postgres.conf, les shared_buffers: calculées en page de 8Kb, -la valeur par défaut -est de seulement 64, ce qui correspond à 512Kb, une meilleure valeur est 640 - - - - Pour la sécurité -

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 à -vos utilisateurs avec la commande remplacer .1. par le nom de l'utilisateur -et .2. par son mot de passe - -changement mot de passe -alter user .1. password '.2.' - - - -Sécurité -# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD -host all phpcompta 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 syntaxe est - - host:port:database:username:password - -N'oubliez pas de mettre ce fichier en mode 600 !!!! Pour executer sans demande -de mot de passe host = localhost - - - - Apache -Installation d'Apache -

-Si vous décidez de le compiler vous-même, les -options suivantes fonctionnent - -./configure --prefix=/opt/http2/ \ - --enable-ssl \ - --enable-http \ - --enable-cgi \ - --enable-so \ - --enable-usertrack \ - --enable-headers \ - --enable-info - -

-
- - Configuration d'Apache -

-Le fichier httpd.conf doit au moins contenir. - -LoadModule php4_module modules/libphp4.so -AddType application/x-httpd-php .php4 .php3 .php .phtml - -Et si vous décidez d'avoir la même configuration que moi, mais ce -n'est pas obligatoire -Il est possible d'utiliser les virtuals hosts ainsi - -<VirtualHost *> - Servername ... - DocumentRoot /var/www/acapulco/htdocs - <Directory /var/www/acapulco/htdocs/phpcompta/html/> - AddDefaultCharset iso-8859-1 - php_value include_path .:../../include:../include:addon - php_flag magic_quotes_gpc off - php_flag session.auto_start on - php_value session.save_path /tmp - php_value max_execution_time 120 - php_flag short_open_tag on - php_flag session.use_trans_sid on - </Directory> -</VirtualHost> - - -

-Actuellement, le répertoire html, contient un fichier .htaccess -qui contient le nécessaire pour que les variables php soient -correctes (voir ). - -

-Apache se démarre avec apachectl start -

-

-Remarque : Pour plus d'information, voir le manuel d'Apache. - - - - - -PHP -Installation de PHP 4.3.1 -

-Il doit être compilé le dernier !!! -Si vous décidez de le compiler vous-même, les -options suivantes fonctionnent - -./configure --prefix=/opt/php431 \ - --with-apxs2=/opt/http2/bin/apxs \ - --with-fastcgi \ - --with-zlib \ - --with-pgsql=/usr/local/psql \ - --with-mysql \ - --with-apache2=/software/httpd-2.0.44 - - -le répertoire /software/httpd-2.0.44 est le répertoire ou vous installer -les sources d'apache -

-
- -Configuration de PHP : Fichier php.ini -

-s'il n'existe pas, vous devez le créer, l'endroit -où vous le trouverez dépend des options de compilation. Dans le cas, -où vous avez compilé php de la même manière que moi, il se trouve -dans /opt/php431/lib. -Recopier simplement le fichier fourni à cet endroit. - -Sinon, adaptez votre fichier, il doit avoir au minimum les options -suivantes - - -magic_quotes_gpc = Off -magic_quotes_runtime = Off -magic_quotes_sybase = Off - - -[Session] -session.save_handler = files ; handler used to store/retrieve data -session.save_path = /tmp ; argument passed to save_handler - ; in the case of files, this is the - ; path where data files are stored -session.use_cookies = 1 ; whether to use cookies -session.name = PHPSESSID - ; name of the session - ; is used as cookie name -session.auto_start = 1 ; initialize session on request startup -session.cookie_lifetime = 0 ; lifetime in seconds of cookie - ; or if 0, until browser is restarted -session.cookie_path = /tmp ; the path the cookie is valid for - -allow_call_time_pass_reference = on -register_argc_argv = on -session.bug_compat_42 = 1 -session.bug_compat_warn = 0 -session.use_trans_sid = 1 -include_path=".:../include:addon" - -

- configuration de .htaccess
- - -
diff --git a/doc/Makefile b/doc/Makefile index 0425f265e..1093b6500 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,26 +2,12 @@ # html, txt format # $Revision$ -.PHONY: all html .pdf clean .txt devel +.PHONY: clean devel -all: manuel html INSTALL-fr.pdf INSTALL-fr.txt devel +all: devel devel: cd developper && ./create_doc.sh -html: - linuxdoc -B html --charset=latin INSTALL-fr.sgml -manuel: - cp manuel-fr.pdf ../manuel-fr.pdf - -INSTALL-fr.pdf:INSTALL-fr.sgml - linuxdoc -B latex --papersize=a4 --charset=latin --output=pdf INSTALL-fr.sgml - -INSTALL-fr.txt: INSTALL-fr.sgml - linuxdoc -B txt --charset=latin INSTALL-fr.sgml - cp INSTALL-fr.txt .. clean: rm -f *~ - rm -f FAQ-fr.txt FAQ-fr*.html FAQ-fr.pdf FAQ-fr.dvi FAQ-fr.tex - rm -f manuel-fr.txt manuel-fr*.html manuel-fr.pdf manuel-fr.dvi manuel-fr.tex - rm -f INSTALL-fr.txt INSTALL-fr*.html INSTALL-fr.pdf INSTALL-fr.dvi INSTALL-fr.tex diff --git a/doc/developper/.cvsignore b/doc/developper/.cvsignore deleted file mode 100644 index 067823c13..000000000 --- a/doc/developper/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -html/* -latex/* diff --git a/doc/developper/create_doc.sh b/doc/developper/create_doc.sh index 280206662..5b722086a 100755 --- a/doc/developper/create_doc.sh +++ b/doc/developper/create_doc.sh @@ -1,3 +1,6 @@ doxygen -postgresql_autodoc -d mod1 -postgresql_autodoc -d account_repository +cd html; sed -i "s/utf-8/utf-8/g" * +if [ ! -z "$PGUSER" ] ; then + postgresql_autodoc -u $PGUSER --password $PGPASSWORD -h localhost -d mod1 + postgresql_autodoc -u $PGUSER --password $PGPASSWORD -h localhost -d account_repository +fi diff --git a/doc/developper/html/.htaccess b/doc/developper/html/.htaccess new file mode 100644 index 000000000..f111ed173 --- /dev/null +++ b/doc/developper/html/.htaccess @@ -0,0 +1,2 @@ +AddDefaultCharset utf-8 + diff --git a/doc/install_windows_fr.sxw b/doc/install_windows_fr.sxw deleted file mode 100644 index 2b59c72a7..000000000 Binary files a/doc/install_windows_fr.sxw and /dev/null differ diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt index 53a914af2..65391f05e 100644 Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ diff --git a/doc/manuel-fr.pdf b/doc/manuel-fr.pdf deleted file mode 100644 index c7ef46642..000000000 Binary files a/doc/manuel-fr.pdf and /dev/null differ diff --git a/doc/manuel.odt b/doc/manuel.odt deleted file mode 100644 index 53a914af2..000000000 Binary files a/doc/manuel.odt and /dev/null differ diff --git a/doc/manuel_win2.odt b/doc/manuel_win2.odt new file mode 100644 index 000000000..73d169c8a Binary files /dev/null and b/doc/manuel_win2.odt differ diff --git a/doc/testing-scenario.txt b/doc/testing-scenario.txt deleted file mode 100644 index 5f50f29bc..000000000 --- a/doc/testing-scenario.txt +++ /dev/null @@ -1,18 +0,0 @@ -Testing of PhpCompta scenario ------------------------------ -For each month -add invoice, card, expense - -print journal -> pdf, csv - -retrieve operation - -Upload piece - -create an user -create an modele -create an folder based on the last modele -grant to user -check security (what the user can do, check privilege) - - diff --git a/html/.htaccess b/html/.htaccess index 5893c3e8a..4a4ab8d17 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -6,6 +6,6 @@ php_value session.save_path /tmp php_value max_execution_time 240 php_value memory_limit 12M # for php 5 php_value upload_tmp_dir /tmp -AddDefaultCharset latin1 +AddDefaultCharset utf-8 php_value session.use_trans_sid 1 - +php_value error_reporting 10239 diff --git a/html/access.php b/html/access.php index e69de29bb..ea5d27a87 100644 --- a/html/access.php +++ b/html/access.php @@ -0,0 +1,142 @@ +'; +echo menu_tool('access'); +echo ''; +echo '
'; +/* + * Todo list + */ +echo JS_PROTOTYPE; +echo JS_TODO; +if ( isset($_REQUEST['save_todo_list'])) { + /* Save the new elt */ + $add_todo=new Todo_List($cn); + $add_todo->set_parameter('id',$_REQUEST['tl_id']); + $add_todo->set_parameter('title',$_REQUEST['p_title']); + $add_todo->set_parameter('desc',$_REQUEST['p_desc']); + $add_todo->set_parameter('date',$_REQUEST['p_date']); + $add_todo->save(); +} +$todo=new Todo_List($cn); +$array=$todo->load_all(); +echo '
'; +echo '
Liste des tâches'; +echo ''; +echo widget::button('add','Ajout','onClick="add_todo()"'); +if ( ! empty ($array) ) { + echo ''; + $nb=0; + foreach ($array as $row) { +if ( $nb % 2 == 0 ) $odd='class="odd" '; else $odd='class="even" '; +$nb++; + echo ''. + ''. + ''. + ''. + ''; + } + echo '
'. + $row['tl_date']. + ''. + $row['tl_title']. + ''. + widget::button('mod','M','onClick="todo_list_show('.$row['tl_id'].')"'). + widget::button('del','E','onClick="todo_list_remove('.$row['tl_id'].')"'). + '
'; +} +echo '
'; +echo '
'; +/* + * Mini Report + */ +$report=$user->get_mini_report(); +if ( $report != 0 ) { + $rapport=new Acc_Report($cn); + $rapport->id=$report; + echo '
'; + echo '
'.$rapport->get_name().''; + $exercice=$user->get_exercice(); + if ( $exercice == 0 ) { + echo ""; + } else { + $periode=new Periode($cn); + $limit=$periode->limit_year($exercice); + + $result=$rapport->get_row($limit['start'],$limit['end'],'periode'); + $ix=0; + echo ''; + foreach ($result as $row) { + $ix++; + $bgcolor=($ix%2==0)?' style="background-color:lightgrey"':''; + echo ''; + + echo ''. + '"; + echo ''; + } + echo '
'.$row['desc'].''.sprintf("% 10.2f",$row['montant'])." €
'; + } + echo '
'; + echo '
'; + } else { + echo '
'; + echo '
Aucun rapport défini'; + echo ' Cliquez ici pour mettre à jour vos préférences'; + echo '
'; + echo '
'; + } +echo '
'; diff --git a/html/addon/class.ezpdf.php b/html/addon/class.ezpdf.php index dd5d723e3..6012e7aa8 100644 --- a/html/addon/class.ezpdf.php +++ b/html/addon/class.ezpdf.php @@ -604,7 +604,7 @@ function ezPrvtGetTextWidth($size,$text){ // ------------------------------------------------------------------------------ -function ezTable(&$data,$cols='',$title='',$options=''){ +function ezTable(&$data,$cols='',$title='',$options='',$utf8decode=false){ // add a table of information to the pdf document // $data is a two dimensional array // $cols (optional) is an associative array, the keys are the names of the columns from $data @@ -1054,6 +1054,7 @@ function ezTable(&$data,$cols='',$title='',$options=''){ } $this->y -= $options['rowGap']; foreach ($lines as $line){ + if($utf8decode)$line=utf8_decode($line); $line = $this->ezProcessText($line); $start=1; @@ -1552,4 +1553,4 @@ function uline($info){ // ------------------------------------------------------------------------------ } -?> \ No newline at end of file +?> diff --git a/html/addon/class.pdf.php b/html/addon/class.pdf.php index 34a15b17e..00fb086fd 100644 --- a/html/addon/class.pdf.php +++ b/html/addon/class.pdf.php @@ -1232,7 +1232,7 @@ function output($debug=0){ $this->checkAllHere(); $xref=array(); - $content="%PDF-1.3\n%âãÏÓ\n"; + $content="%PDF-1.3\n%âãÃÓ\n"; // $content="%PDF-1.3\n"; $pos=strlen($content); foreach($this->objects as $k=>$v){ diff --git a/html/admin/htaccess.cfg b/html/admin/htaccess.cfg index 93f64799e..efc0742f3 100755 --- a/html/admin/htaccess.cfg +++ b/html/admin/htaccess.cfg @@ -5,5 +5,5 @@ php_value session.save_path c:\temp php_value max_execution_time 240 php_value memory_limit 12M # for php 5 php_value upload_tmp_dir /tmp -AddDefaultCharset latin1 +AddDefaultCharset utf8 diff --git a/html/admin/setup.php b/html/admin/setup.php index 7c63f5b26..a3d5314d6 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -61,188 +61,68 @@ h2.error { $inc_path=get_include_path(); if ( strpos($inc_path,";") != 0 ) { $new_path=$inc_path.';..\..\include;addon'; + $os=0; /* $os is 0 for unix */ } else { $new_path=$inc_path.':../../include:addon'; + $os=1; /* $os is 0 for windos */ } - set_include_path($new_path); +require_once('config_file.php'); +/* The config file is created here */ +if (isset($_POST['save_config'])) { + $url=config_file_create($_POST); + } + + +/* if the config file is not found we propose to create one */ +if ( is_writable ('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'constant.php') == false ) { +echo '

On ne peut pas écrire dans le répertoire de phpcompta, changez-en les droits

'; +exit(); +} +if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php')) { + echo '
'; +echo '

Entrez les informations nécessaires à phpcompta

'; + echo config_file_form(); + echo widget::submit('save_config','Sauver la configuration'); + echo '
'; + exit(); + } include_once('constant.php'); include_once('postgres.php'); include_once('debug.php'); include_once('ac_common.php'); -/*! - ************************************************** - * \brief Get version of a database, the content of the - * table version - * - * \param $p_cn database connection - * - * \return version number - * +/* If htaccess file doesn't exists we create them here + * if os == 1 then windows, 0 means Unix */ -function GetVersion($p_cn) { - $Res=ExecSql($p_cn,"select val from version"); - $a=pg_fetch_array($Res,0); - return $a['val']; +$file='..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'.htaccess'; +if ( ! file_exists ( $file) ) { + $hFile=@fopen($file,'a+'); + if ( ! $hFile ) exit('Impossible d\'écrire dans le répertoire include'); + fwrite($hFile,'order deny,allow'."\n"); + fwrite($hFile,'deny from all'."\n"); + fclose($hFile); } -/*! ExecuteScript - ************************************************** - * \brief Execute a sql script - * - * \param $p_cn database - * \param $script script name - */ -function ExecuteScript($p_cn,$script) { - if ( DEBUG=='false' ) ob_start(); - $hf=fopen($script,'r'); - if ( $hf == false ) { - echo 'Ne peut ouvrir '.$script; - exit(); - } - $sql=""; - $flag_function=false; - while (!feof($hf)) { - $buffer=fgets($hf); - $buffer=str_replace ("$","\$",$buffer); - print $buffer."
"; - // comment are not execute - if ( substr($buffer,0,2) == "--" ) { - //echo "comment $buffer"; - continue; - } - // Blank Lines Are Skipped - If ( Strlen($buffer)==0) { - //echo "Blank $buffer"; - Continue; - } - if ( strpos(strtolower($buffer),"create function")===0 ) { - echo "found a function"; - $flag_function=true; - $sql=$buffer; - continue; - } - if ( strpos(strtolower($buffer),"create or replace function")===0 ) { - echo "found a function"; - $flag_function=true; - $sql=$buffer; - continue; - } - // No semi colon -> multiline command - if ( $flag_function== false && strpos($buffer,';') == false ) { - $sql.=$buffer; - continue; - } - if ( $flag_function ) { - if ( strpos(strtolower($buffer), "language plpgsql") === false && - strpos(strtolower($buffer), "language 'plpgsql'") === false ) { - $sql.=$buffer; - continue; - } - } else { - // cut the semi colon - $buffer=str_replace (';','',$buffer); - } - $sql.=$buffer; -echo_debug('setup.php',__LINE__,"Execute sql $sql"); - if ( ExecSql($p_cn,$sql,false) == false ) { - Rollback($p_cn); - if ( DEBUG=='false' ) ob_end_clean(); - print "ERROR : $sql"; - exit(); - } - $sql=""; - $flag_function=false; - print "
"; - } // while (feof) - fclose($hf); - if ( DEBUG=='false' ) ob_end_clean(); -} -/*!\brief loop to apply all the path to a folder or - * a template - * \param $p_cn database connexion - * \param $p_name database name - * - */ -function apply_patch($p_cn,$p_name) -{ - $MaxVersion=DBVERSION-1; - echo ''; + if ( $os == 0 ) + fwrite($hFile,'php_value include_path .;..\..\include;..\include;addon'."\n"); + else + fwrite($hFile,'php_value include_path .:../../include:../include:addon'."\n"); + foreach ($array as $value ) fwrite($hFile,$value."\n"); + fclose($hFile); } //---------------------------------------------------------------------- // End functions @@ -280,6 +160,12 @@ if ( in_array('pgsql',$module) == false ) $flag_php++; } +if ( in_array('bcmath',$module) == false ) +{ + print '

Désolé mais soit vous n\'avez pas installé le package pour bcmath soit php n\'a pas pas été compilé avec les bonnes options

'; + $flag_php++; +} + if ( ini_get("max_execution_time") < 60 ) { print '

max_execution_time should be set to 60 minimum

'; } @@ -408,35 +294,35 @@ if ($account == 0 ) { echo "Creation of ".domaine."account_repository"; if ( DEBUG=='false') ob_start(); - ExecSql($cn,"create database ".domaine."account_repository encoding='latin1'"); + ExecSql($cn,"create database ".domaine."account_repository encoding='utf8'"); $cn=DbConnect(); StartSql($cn); - ExecuteScript($cn,"sql/account_repository/schema.sql"); - ExecuteScript($cn,"sql/account_repository/data.sql"); - ExecuteScript($cn,"sql/account_repository/constraint.sql"); + execute_script($cn,"sql/account_repository/schema.sql"); + execute_script($cn,"sql/account_repository/data.sql"); + execute_script($cn,"sql/account_repository/constraint.sql"); Commit($cn); if ( DEBUG=='false') ob_end_clean(); echo "Creation of Modele1"; if ( DEBUG=='false') ob_start(); - ExecSql($cn,"create database ".domaine."mod1 encoding='latin1'"); + ExecSql($cn,"create database ".domaine."mod1 encoding='utf8'"); $cn=DbConnect(1,'mod'); StartSql($cn); - ExecuteScript($cn,'sql/mod1/schema.sql'); - ExecuteScript($cn,'sql/mod1/data.sql'); - ExecuteScript($cn,'sql/mod1/constraint.sql'); + execute_script($cn,'sql/mod1/schema.sql'); + execute_script($cn,'sql/mod1/data.sql'); + execute_script($cn,'sql/mod1/constraint.sql'); Commit($cn); if ( DEBUG=='false') ob_end_clean(); echo "Creation of Modele2"; - ExecSql($cn,"create database ".domaine."mod2 encoding='latin1'"); + ExecSql($cn,"create database ".domaine."mod2 encoding='utf8'"); $cn=DbConnect(2,'mod'); StartSql($cn); if ( DEBUG=='false') { ob_start(); } - ExecuteScript($cn,'sql/mod1/schema.sql'); - ExecuteScript($cn,'sql/mod2/data.sql'); - ExecuteScript($cn,'sql/mod1/constraint.sql'); + execute_script($cn,'sql/mod1/schema.sql'); + execute_script($cn,'sql/mod2/data.sql'); + execute_script($cn,'sql/mod1/constraint.sql'); Commit($cn); if ( DEBUG=='false') ob_end_clean(); @@ -457,7 +343,7 @@ if ( ($Res=ExecSql($a,"select * from ac_users") ) == false ) { exit ("

".__LINE__." test has failed !!!

"); } else print "Connect to database success
"; -echo "

Congratulation : Installation réssie

"; +echo "

Félicitation : Installation réussie

"; echo '
'; echo "

Mise a jour du systeme

"; @@ -500,14 +386,14 @@ echo '
'; echo "

Mise à jour Repository

"; $cn=DbConnect(); if ( DEBUG == 'false') ob_start(); - $MaxVersion=7; + $MaxVersion=8; for ($i=4;$i<= $MaxVersion;$i++) { - if ( GetVersion($cn) <= $i ) { - ExecuteScript($cn,'sql/patch/ac-upgrade'.$i.'.sql'); + if ( get_version($cn) <= $i ) { + execute_script($cn,'sql/patch/ac-upgrade'.$i.'.sql'); } } if (DEBUG=='false') ob_end_clean(); - echo "

Voilà tout est installé ;-)

"; + echo "

Voilà tout est installé ;-)

"; ?> diff --git a/html/admin/sql/account_repository/constraint.sql b/html/admin/sql/account_repository/constraint.sql index 83f75685a..0ae84e958 100644 --- a/html/admin/sql/account_repository/constraint.sql +++ b/html/admin/sql/account_repository/constraint.sql @@ -1,4 +1,4 @@ - SET client_encoding = 'LATIN1'; + SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; SET search_path = public, pg_catalog; diff --git a/html/admin/sql/account_repository/data.sql b/html/admin/sql/account_repository/data.sql index f8ccc1b72..31b05fddd 100644 --- a/html/admin/sql/account_repository/data.sql +++ b/html/admin/sql/account_repository/data.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; @@ -59,8 +59,8 @@ INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, u -- Data for Name: modeledef; Type: TABLE DATA; Schema: public; Owner: phpcompta -- -INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, tout doit être adaptée'); -INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'Comptabilité Française, tout doit être adaptée'); +INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, tout doit être adaptée'); +INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'Comptabilité Française, tout doit être adaptée'); -- diff --git a/html/admin/sql/account_repository/make-sql b/html/admin/sql/account_repository/make-sql index ef1d6eb2a..790a29d72 100755 --- a/html/admin/sql/account_repository/make-sql +++ b/html/admin/sql/account_repository/make-sql @@ -5,7 +5,7 @@ awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql ( -echo " SET client_encoding = 'LATIN1';" +echo " SET client_encoding = 'utf8';" echo " SET check_function_bodies = false;" echo " SET client_min_messages = warning;" echo "SET search_path = public, pg_catalog;" diff --git a/html/admin/sql/account_repository/schema.sql b/html/admin/sql/account_repository/schema.sql index 1fe96f50c..8391c754d 100644 --- a/html/admin/sql/account_repository/schema.sql +++ b/html/admin/sql/account_repository/schema.sql @@ -1,4 +1,4 @@ -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; diff --git a/html/admin/sql/mod1/comment.sql b/html/admin/sql/mod1/comment.sql index cba6ad648..ba743d1b1 100644 --- a/html/admin/sql/mod1/comment.sql +++ b/html/admin/sql/mod1/comment.sql @@ -39,7 +39,7 @@ COMMENT ON TABLE plan_analytique IS 'Plan Analytique (max 5)'; COMMENT ON TABLE poste_analytique IS 'Poste Analytique'; COMMENT ON TABLE quant_sold IS 'Contains about invoice for customer'; COMMENT ON TABLE stock_goods IS 'About the goods'; -COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé'; +COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé'; COMMENT ON TABLE tva_rate IS 'Rate of vat'; COMMENT ON TABLE user_local_pref IS 'The user''s local parameter '; COMMENT ON COLUMN user_local_pref.user_id IS 'user''s login '; diff --git a/html/admin/sql/mod1/constraint.sql b/html/admin/sql/mod1/constraint.sql index cfef9172e..75175c3e4 100644 --- a/html/admin/sql/mod1/constraint.sql +++ b/html/admin/sql/mod1/constraint.sql @@ -1,4 +1,4 @@ - SET client_encoding = 'LATIN1'; + SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; SET search_path = public, pg_catalog; diff --git a/html/admin/sql/mod1/data.sql b/html/admin/sql/mod1/data.sql index 983f94cc9..b70d7d92f 100644 --- a/html/admin/sql/mod1/data.sql +++ b/html/admin/sql/mod1/data.sql @@ -1,5 +1,5 @@ -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; @@ -227,24 +227,24 @@ SELECT pg_catalog.setval('seq_doc_type_9', 1, false); INSERT INTO "action" (ac_id, ac_description) VALUES (4, 'Impression'); -INSERT INTO "action" (ac_id, ac_description) VALUES (6, 'Mise à jour Plan Comptable'); +INSERT INTO "action" (ac_id, ac_description) VALUES (6, 'Mise à jour Plan Comptable'); INSERT INTO "action" (ac_id, ac_description) VALUES (7, 'Gestion Journaux'); -INSERT INTO "action" (ac_id, ac_description) VALUES (8, 'Paramètres'); +INSERT INTO "action" (ac_id, ac_description) VALUES (8, 'Paramètres'); INSERT INTO "action" (ac_id, ac_description) VALUES (10, 'Centralise'); INSERT INTO "action" (ac_id, ac_description) VALUES (16, 'Voir le stock'); INSERT INTO "action" (ac_id, ac_description) VALUES (17, 'Modifie le stock'); INSERT INTO "action" (ac_id, ac_description) VALUES (20, 'Voir la balance des comptes'); -INSERT INTO "action" (ac_id, ac_description) VALUES (21, 'Import et export des écritures d''ouverture'); +INSERT INTO "action" (ac_id, ac_description) VALUES (21, 'Import et export des écritures d''ouverture'); INSERT INTO "action" (ac_id, ac_description) VALUES (28, 'Module Suivi Document'); INSERT INTO "action" (ac_id, ac_description) VALUES (22, 'Module Client'); INSERT INTO "action" (ac_id, ac_description) VALUES (24, 'Module Fournisseur'); INSERT INTO "action" (ac_id, ac_description) VALUES (26, 'Module Administration'); INSERT INTO "action" (ac_id, ac_description) VALUES (30, 'Module Gestion'); INSERT INTO "action" (ac_id, ac_description) VALUES (1, 'Lecture du Grand-Livre'); -INSERT INTO "action" (ac_id, ac_description) VALUES (31, 'Gestion des périodes comptables'); +INSERT INTO "action" (ac_id, ac_description) VALUES (31, 'Gestion des périodes comptables'); INSERT INTO "action" (ac_id, ac_description) VALUES (3, 'Lecture des fiches'); INSERT INTO "action" (ac_id, ac_description) VALUES (15, 'Ajout de fiche et modification'); -INSERT INTO "action" (ac_id, ac_description) VALUES (5, 'Création et modifications des rapports'); +INSERT INTO "action" (ac_id, ac_description) VALUES (5, 'Création et modifications des rapports'); INSERT INTO "action" (ac_id, ac_description) VALUES (50, 'Definir les Plans Analytiques et les postes'); INSERT INTO "action" (ac_id, ac_description) VALUES (51, 'Impression CA'); INSERT INTO "action" (ac_id, ac_description) VALUES (52, 'Operations Diverses CA'); @@ -256,28 +256,28 @@ INSERT INTO "action" (ac_id, ac_description) VALUES (52, 'Operations Diverses CA INSERT INTO attr_def (ad_id, ad_text) VALUES (1, 'Nom'); INSERT INTO attr_def (ad_id, ad_text) VALUES (2, 'Taux TVA'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (3, 'Numéro de compte'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (3, 'Numéro de compte'); INSERT INTO attr_def (ad_id, ad_text) VALUES (4, 'Nom de la banque'); INSERT INTO attr_def (ad_id, ad_text) VALUES (5, 'Poste Comptable'); INSERT INTO attr_def (ad_id, ad_text) VALUES (6, 'Prix vente'); INSERT INTO attr_def (ad_id, ad_text) VALUES (7, 'Prix achat'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (8, 'Durée Amortissement'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (8, 'Durée Amortissement'); INSERT INTO attr_def (ad_id, ad_text) VALUES (9, 'Description'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (10, 'Date début'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (10, 'Date début'); INSERT INTO attr_def (ad_id, ad_text) VALUES (11, 'Montant initial'); INSERT INTO attr_def (ad_id, ad_text) VALUES (12, 'Personne de contact '); -INSERT INTO attr_def (ad_id, ad_text) VALUES (13, 'numéro de tva '); +INSERT INTO attr_def (ad_id, ad_text) VALUES (13, 'numéro de tva '); INSERT INTO attr_def (ad_id, ad_text) VALUES (14, 'Adresse '); INSERT INTO attr_def (ad_id, ad_text) VALUES (16, 'pays '); -INSERT INTO attr_def (ad_id, ad_text) VALUES (17, 'téléphone '); +INSERT INTO attr_def (ad_id, ad_text) VALUES (17, 'téléphone '); INSERT INTO attr_def (ad_id, ad_text) VALUES (18, 'email '); INSERT INTO attr_def (ad_id, ad_text) VALUES (19, 'Gestion stock'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (20, 'Partie fiscalement non déductible'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (21, 'TVA non déductible'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (22, 'TVA non déductible récupérable par l''impôt'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (20, 'Partie fiscalement non déductible'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (21, 'TVA non déductible'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (22, 'TVA non déductible récupérable par l''impôt'); INSERT INTO attr_def (ad_id, ad_text) VALUES (23, 'Quick Code'); INSERT INTO attr_def (ad_id, ad_text) VALUES (24, 'Ville'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (25, 'Société'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (25, 'Société'); INSERT INTO attr_def (ad_id, ad_text) VALUES (26, 'Fax'); INSERT INTO attr_def (ad_id, ad_text) VALUES (27, 'GSM'); INSERT INTO attr_def (ad_id, ad_text) VALUES (15, 'code postal'); @@ -489,7 +489,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (109, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (110, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (111, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (112, '610001'); -INSERT INTO attr_value (jft_id, av_text) VALUES (113, 'Electricité'); +INSERT INTO attr_value (jft_id, av_text) VALUES (113, 'Electricité'); INSERT INTO attr_value (jft_id, av_text) VALUES (114, '1'); INSERT INTO attr_value (jft_id, av_text) VALUES (115, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (117, 'Loyer'); @@ -501,7 +501,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (122, '3'); INSERT INTO attr_value (jft_id, av_text) VALUES (120, '610003'); INSERT INTO attr_value (jft_id, av_text) VALUES (123, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (124, '610004'); -INSERT INTO attr_value (jft_id, av_text) VALUES (125, 'Matériel bureau'); +INSERT INTO attr_value (jft_id, av_text) VALUES (125, 'Matériel bureau'); INSERT INTO attr_value (jft_id, av_text) VALUES (126, '1'); INSERT INTO attr_value (jft_id, av_text) VALUES (127, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (134, '7000002'); @@ -517,7 +517,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (131, '15'); INSERT INTO attr_value (jft_id, av_text) VALUES (132, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (133, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (140, '7000003'); -INSERT INTO attr_value (jft_id, av_text) VALUES (141, 'Déplacement'); +INSERT INTO attr_value (jft_id, av_text) VALUES (141, 'Déplacement'); INSERT INTO attr_value (jft_id, av_text) VALUES (142, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (143, '50'); INSERT INTO attr_value (jft_id, av_text) VALUES (144, ''); @@ -558,10 +558,10 @@ INSERT INTO bilan (b_id, b_name, b_file_template, b_file_form, b_type) VALUES (1 -INSERT INTO document_state (s_id, s_value) VALUES (1, 'Envoyé'); +INSERT INTO document_state (s_id, s_value) VALUES (1, 'Envoyé'); INSERT INTO document_state (s_id, s_value) VALUES (2, 'Brouillon'); INSERT INTO document_state (s_id, s_value) VALUES (3, 'A envoyer'); -INSERT INTO document_state (s_id, s_value) VALUES (4, 'Reçu'); +INSERT INTO document_state (s_id, s_value) VALUES (4, 'Reçu'); @@ -613,17 +613,17 @@ INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (1, 'Vente S INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (2, 'Achat Marchandises', 604); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (3, 'Achat Service et biens divers', 61); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (4, 'Banque', 5500); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (5, 'Prêt > a un an', 17); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (6, 'Prêt < a un an', 430); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (5, 'Prêt > a un an', 17); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (6, 'Prêt < a un an', 430); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (8, 'Fournisseurs', 440); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (9, 'Clients', 400); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (10, 'Salaire Administrateur', 6200); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (11, 'Salaire Ouvrier', 6203); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (12, 'Salaire Employé', 6202); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (13, 'Dépenses non admises', 674); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (12, 'Salaire Employé', 6202); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (13, 'Dépenses non admises', 674); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (14, 'Administration des Finances', NULL); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (15, 'Autres fiches', NULL); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (7, 'Matériel à amortir', 2400); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (7, 'Matériel à amortir', 2400); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (16, 'Contact', NULL); @@ -631,10 +631,10 @@ INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (16, 'Contac INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000398, 3000000, 1, 'Prestation [ case 03 ]', '[700%]-[7000005]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000399, 3000000, 2, 'Prestation intra [ case 47 ]', '[7000005]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000400, 3000000, 3, 'Tva due [case 54]', '[4513]+[4512]+[4511] FROM=01.2005'); -INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); +INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000402, 3000000, 7, 'Service et bien divers [case 82]', '[61%]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000403, 3000000, 8, 'bien d''invest [ case 83 ]', '[2400%]'); -INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); +INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000405, 3000000, 8, 'TVA non ded -> voiture', '[610022]*0.21/2'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000406, 3000000, 9, 'Acompte TVA', '[4117]'); @@ -650,7 +650,7 @@ INSERT INTO format_csv_banque (name, include_file) VALUES ('Dexia', 'dexia_be.in -INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); +INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); @@ -887,12 +887,12 @@ INSERT INTO jnt_fic_attr (fd_id, ad_id, jnt_id) VALUES (4, 24, 52); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (2, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (4, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (1, 'Nouvelle', 'Création d''une facture', 'user_jrn.php', 'action=insert_vente&blank', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (10, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'ACH'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (4, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'VEN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (1, 'Nouvelle', 'Création d''une facture', 'user_jrn.php', 'action=insert_vente&blank', 'FR', 'VEN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (10, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'ACH'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (12, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'ACH'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (14, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'ACH'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (20, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'FIN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (14, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'ACH'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (20, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'FIN'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (22, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'FIN'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (30, 'Nouveau', NULL, 'user_jrn.php', 'action=new&blank', 'FR', 'ODS'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (32, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'ODS'); @@ -900,10 +900,10 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_ -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (4, 'Opération Diverses', NULL, NULL, NULL, NULL, 5, 5, false, NULL, 'ODS', 'ODS-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (4, 'Opération Diverses', NULL, NULL, NULL, NULL, 5, 5, false, NULL, 'ODS', 'ODS-01'); INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (1, 'Financier', '5* ', '5*', '3,2,4', '3,2,4', 5, 5, false, NULL, 'FIN', 'FIN-01'); -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (3, 'Achat', '6*', '4*', '5', '4', 1, 3, true, 'échéance', 'ACH', 'ACH-01'); -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (2, 'Vente', '4*', '7*', '2', '6', 2, 1, true, 'échéance', 'VEN', 'VEN-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (3, 'Achat', '6*', '4*', '5', '4', 1, 3, true, 'échéance', 'ACH', 'ACH-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (2, 'Vente', '4*', '7*', '2', '6', 2, 1, true, 'échéance', 'VEN', 'VEN-01'); @@ -913,7 +913,7 @@ INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_ INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('FIN', 'Financier'); INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('VEN', 'Vente'); INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ACH', 'Achat'); -INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses'); +INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses'); @@ -943,15 +943,15 @@ INSERT INTO parameter (pr_id, pr_value) VALUES ('MY_COUNTRY', 'BE'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('DNA', '6740', 'Dépense non déductible'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('DNA', '6740', 'Dépense non déductible'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CUSTOMER', '400', 'Poste comptable de base pour les clients'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('COMPTE_TVA', '451', 'TVA à payer'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('COMPTE_TVA', '451', 'TVA à payer'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('BANQUE', '550', 'Poste comptable de base pour les banques'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VIREMENT_INTERNE', '58', 'Poste Comptable pour les virements internes'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('COMPTE_COURANT', '56', 'Poste comptable pour le compte courant'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CAISSE', '57', 'Poste comptable pour la caisse'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('TVA_DNA', '6740', 'Tva non déductible s'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('TVA_DED_IMPOT', '619000', 'Tva déductible par l''impôt'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('TVA_DNA', '6740', 'Tva non déductible s'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('TVA_DED_IMPOT', '619000', 'Tva déductible par l''impôt'); INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VENTE', '70', 'Poste comptable de base pour les ventes'); @@ -1005,349 +1005,349 @@ INSERT INTO parm_periode (p_id, p_start, p_end, p_exercice, p_closed, p_central) INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (10, 'Capital ', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040003, 'Petit matériel', 604); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (11, 'Prime d''émission ', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (12, 'Plus Value de réévaluation ', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (13, 'Réserve ', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (130, 'Réserve légale', 13); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (131, 'Réserve indisponible', 13); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1310, 'Réserve pour actions propres', 131); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040003, 'Petit matériel', 604); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (11, 'Prime d''émission ', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (12, 'Plus Value de réévaluation ', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (13, 'Réserve ', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (130, 'Réserve légale', 13); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (131, 'Réserve indisponible', 13); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1310, 'Réserve pour actions propres', 131); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040004, 'Assurance', 604); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (55000001, 'Caisse', 5500); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (133, 'Réserves disponibles', 13); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (14, 'Bénéfice ou perte reportée', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (140, 'Bénéfice reporté', 14); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (141, 'Perte reportée', 14); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (133, 'Réserves disponibles', 13); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (14, 'Bénéfice ou perte reportée', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (140, 'Bénéfice reporté', 14); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (141, 'Perte reportée', 14); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (15, 'Subside en capital', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (16, 'Provisions pour risques et charges', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (160, 'Provisions pour pensions et obligations similaires', 16); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (161, 'Provisions pour charges fiscales', 16); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (162, 'Provisions pour grosses réparation et gros entretien', 16); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (17, ' Dettes à plus d''un an', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (170, 'Emprunts subordonnés', 17); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (162, 'Provisions pour grosses réparation et gros entretien', 16); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (17, ' Dettes à plus d''un an', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (170, 'Emprunts subordonnés', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1700, 'convertibles', 170); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1701, 'non convertibles', 170); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (171, 'Emprunts subordonnés', 17); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (171, 'Emprunts subordonnés', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1710, 'convertibles', 170); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1711, 'non convertibles', 170); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (172, ' Dettes de locations financement', 17); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (173, ' Etablissement de crédit', 17); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (173, ' Etablissement de crédit', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1730, 'Dettes en comptes', 173); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1731, 'Promesses', 173); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1732, 'Crédits d''acceptation', 173); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1732, 'Crédits d''acceptation', 173); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (174, 'Autres emprunts', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (175, 'Dettes commerciales', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1750, 'Fournisseurs', 175); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1751, 'Effets à payer', 175); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (176, 'Acomptes reçus sur commandes', 17); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (178, 'Cautionnement reçus en numéraires', 17); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1751, 'Effets à payer', 175); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (176, 'Acomptes reçus sur commandes', 17); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (178, 'Cautionnement reçus en numéraires', 17); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (179, 'Dettes diverses', 17); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (20, 'Frais d''établissement', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (20, 'Frais d''établissement', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (200, 'Frais de constitution et d''augmentation de capital', 20); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (201, ' Frais d''émission d''emprunts et primes de remboursement', 20); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (202, 'Autres frais d''établissement', 20); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (201, ' Frais d''émission d''emprunts et primes de remboursement', 20); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (202, 'Autres frais d''établissement', 20); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (204, 'Frais de restructuration', 20); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (21, 'Immobilisations incorporelles', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (210, 'Frais de recherche et de développement', 21); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (210, 'Frais de recherche et de développement', 21); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (211, 'Concessions, brevet, licence savoir faire, marque et droit similaires', 21); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (212, 'Goodwill', 21); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (213, 'Acomptes versés', 21); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (213, 'Acomptes versés', 21); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (22, 'Terrains et construction', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (220, 'Terrains', 22); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (221, 'Construction', 22); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (222, 'Terrains bâtis', 22); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (223, 'Autres droits réels sur des immeubles', 22); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (222, 'Terrains bâtis', 22); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (223, 'Autres droits réels sur des immeubles', 22); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (23, ' Installations, machines et outillages', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (24, 'Mobilier et Matériel roulant', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (25, 'Immobilisations détenus en location-financement et droits similaires', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (24, 'Mobilier et Matériel roulant', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (25, 'Immobilisations détenus en location-financement et droits similaires', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (250, 'Terrains', 25); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (251, 'Construction', 25); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (252, 'Terrains bâtis', 25); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (253, 'Mobilier et matériels roulants', 25); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (252, 'Terrains bâtis', 25); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (253, 'Mobilier et matériels roulants', 25); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (26, 'Autres immobilisations corporelles', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (27, 'Immobilisations corporelles en cours et acomptes versés', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (28, 'Immobilisations financières', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (280, 'Participation dans des entreprises liées', 28); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (27, 'Immobilisations corporelles en cours et acomptes versés', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (28, 'Immobilisations financières', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (280, 'Participation dans des entreprises liées', 28); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2800, 'Valeur d''acquisition', 280); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2801, 'Montants non-appelés(-)', 280); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2808, 'Plus-values actées', 280); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2809, 'Réductions de valeurs actées', 280); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (281, 'Créance sur des entreprises liées', 28); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2810, 'Créance en compte', 281); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2811, 'Effets à recevoir', 281); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2812, 'Titre à reveny fixe', 281); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2817, 'Créances douteuses', 281); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2819, 'Réduction de valeurs actées', 281); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2801, 'Montants non-appelés(-)', 280); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2808, 'Plus-values actées', 280); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2809, 'Réductions de valeurs actées', 280); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (281, 'Créance sur des entreprises liées', 28); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2810, 'Créance en compte', 281); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2811, 'Effets à recevoir', 281); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2812, 'Titre à reveny fixe', 281); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2817, 'Créances douteuses', 281); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2819, 'Réduction de valeurs actées', 281); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (282, 'Participations dans des entreprises avec lesquelles il existe un lien de participation', 28); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2820, 'Valeur d''acquisition', 282); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2821, 'Montants non-appelés(-)', 282); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2828, 'Plus-values actées', 282); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2829, 'Réductions de valeurs actées', 282); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (283, 'Créances sur des entreprises avec lesquelles existe un lien de participation', 28); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2830, 'Créance en compte', 283); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2831, 'Effets à recevoir', 283); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2821, 'Montants non-appelés(-)', 282); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2828, 'Plus-values actées', 282); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2829, 'Réductions de valeurs actées', 282); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (283, 'Créances sur des entreprises avec lesquelles existe un lien de participation', 28); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2830, 'Créance en compte', 283); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2831, 'Effets à recevoir', 283); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (57, 'Caisse', 5); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2832, 'Titre à revenu fixe', 283); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2837, 'Créances douteuses', 283); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2839, 'Réduction de valeurs actées', 283); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2832, 'Titre à revenu fixe', 283); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2837, 'Créances douteuses', 283); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2839, 'Réduction de valeurs actées', 283); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (284, 'Autres actions et parts', 28); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2840, 'Valeur d''acquisition', 284); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2841, 'Montants non-appelés(-)', 284); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2848, 'Plus-values actées', 284); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2849, 'Réductions de valeurs actées', 284); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (285, 'Autres créances', 28); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2850, 'Créance en compte', 285); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2851, 'Effets à recevoir', 285); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2852, 'Titre à revenu fixe', 285); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2857, 'Créances douteuses', 285); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2859, 'Réductions de valeurs actées', 285); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (288, 'Cautionnements versés en numéraires', 28); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (29, 'Créances à plus d''un an', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (290, 'Créances commerciales', 29); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2841, 'Montants non-appelés(-)', 284); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2848, 'Plus-values actées', 284); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2849, 'Réductions de valeurs actées', 284); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (285, 'Autres créances', 28); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2850, 'Créance en compte', 285); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2851, 'Effets à recevoir', 285); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2852, 'Titre à revenu fixe', 285); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2857, 'Créances douteuses', 285); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2859, 'Réductions de valeurs actées', 285); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (288, 'Cautionnements versés en numéraires', 28); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (29, 'Créances à plus d''un an', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (290, 'Créances commerciales', 29); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2900, 'Clients', 290); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2901, 'Effets à recevoir', 290); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2906, 'Acomptes versés', 290); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2907, 'Créances douteuses', 290); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2909, 'Réductions de valeurs actées', 290); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (291, 'Autres créances', 29); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2910, 'Créances en comptes', 291); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2911, 'Effets à recevoir', 291); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2917, 'Créances douteuses', 291); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2919, 'Réductions de valeurs actées(-)', 291); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (30, 'Approvisionements - Matières premières', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2901, 'Effets à recevoir', 290); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2906, 'Acomptes versés', 290); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2907, 'Créances douteuses', 290); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2909, 'Réductions de valeurs actées', 290); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (291, 'Autres créances', 29); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2910, 'Créances en comptes', 291); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2911, 'Effets à recevoir', 291); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2917, 'Créances douteuses', 291); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2919, 'Réductions de valeurs actées(-)', 291); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (30, 'Approvisionements - Matières premières', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (300, 'Valeur d''acquisition', 30); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (309, 'Réductions de valeur actées', 30); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (309, 'Réductions de valeur actées', 30); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (31, 'Approvisionnements - fournitures', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (310, 'Valeur d''acquisition', 31); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (319, 'Réductions de valeurs actées(-)', 31); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (319, 'Réductions de valeurs actées(-)', 31); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (32, 'En-cours de fabrication', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (320, 'Valeurs d''acquisition', 32); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (329, 'Réductions de valeur actées', 32); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (329, 'Réductions de valeur actées', 32); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (33, 'Produits finis', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (330, 'Valeur d''acquisition', 33); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (339, 'Réductions de valeur actées', 33); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (339, 'Réductions de valeur actées', 33); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (34, 'Marchandises', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (340, 'Valeur d''acquisition', 34); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (349, 'Réductions de valeur actées', 34); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (35, 'Immeubles destinés à la vente', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (349, 'Réductions de valeur actées', 34); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (35, 'Immeubles destinés à la vente', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (350, 'Valeur d''acquisition', 35); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (359, 'Réductions de valeur actées', 35); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (36, 'Acomptes versés sur achats pour stocks', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (359, 'Réductions de valeur actées', 35); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (36, 'Acomptes versés sur achats pour stocks', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (360, 'Valeur d''acquisition', 36); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (369, 'Réductions de valeur actées', 36); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (37, 'Commandes en cours éxécution', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (369, 'Réductions de valeur actées', 36); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (37, 'Commandes en cours éxécution', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (370, 'Valeur d''acquisition', 37); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (371, 'Bénéfice pris en compte ', 37); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (379, 'Réductions de valeur actées', 37); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (40, 'Créances commerciales', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (371, 'Bénéfice pris en compte ', 37); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (379, 'Réductions de valeur actées', 37); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (40, 'Créances commerciales', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (400, 'Clients', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (401, 'Effets à recevoir', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (404, 'Produits à recevoir', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (406, 'Acomptes versés', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (407, 'Créances douteuses', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (409, 'Réductions de valeur actées', 40); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (41, 'Autres créances', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (410, 'Capital appelé non versé', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (411, 'TVA à récupérer', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4111, 'TVA à récupérer 21%', 411); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4112, 'TVA à récupérer 12%', 411); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4113, 'TVA à récupérer 6% ', 411); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4114, 'TVA à récupérer 0%', 411); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (412, 'Impôts et précomptes à récupérer', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4120, 'Impôt belge sur le résultat', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4121, 'Impôt belge sur le résultat', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4122, 'Impôt belge sur le résultat', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4123, 'Impôt belge sur le résultat', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4124, 'Impôt belge sur le résultat', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4125, 'Autres impôts et taxes belges', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4126, 'Autres impôts et taxes belges', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4127, 'Autres impôts et taxes belges', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4128, 'Impôts et taxes étrangers', 412); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (414, 'Produits à recevoir', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (416, 'Créances diverses', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (401, 'Effets à recevoir', 40); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (404, 'Produits à recevoir', 40); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (406, 'Acomptes versés', 40); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (407, 'Créances douteuses', 40); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (409, 'Réductions de valeur actées', 40); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (41, 'Autres créances', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (410, 'Capital appelé non versé', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (411, 'TVA à récupérer', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4111, 'TVA à récupérer 21%', 411); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4112, 'TVA à récupérer 12%', 411); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4113, 'TVA à récupérer 6% ', 411); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4114, 'TVA à récupérer 0%', 411); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (412, 'Impôts et précomptes à récupérer', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4120, 'Impôt belge sur le résultat', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4121, 'Impôt belge sur le résultat', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4122, 'Impôt belge sur le résultat', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4123, 'Impôt belge sur le résultat', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4124, 'Impôt belge sur le résultat', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4125, 'Autres impôts et taxes belges', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4126, 'Autres impôts et taxes belges', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4127, 'Autres impôts et taxes belges', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4128, 'Impôts et taxes étrangers', 412); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (414, 'Produits à recevoir', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (416, 'Créances diverses', 41); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4160, 'Comptes de l''exploitant', 416); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (417, 'Créances douteuses', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (418, 'Cautionnements versés en numéraires', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (419, 'Réductions de valeur actées', 41); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (42, 'Dettes à plus dun an échéant dans l''année', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (420, 'Emprunts subordonnés', 42); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (417, 'Créances douteuses', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (418, 'Cautionnements versés en numéraires', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (419, 'Réductions de valeur actées', 41); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (42, 'Dettes à plus dun an échéant dans l''année', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (420, 'Emprunts subordonnés', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4200, 'convertibles', 420); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4201, 'non convertibles', 420); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (421, 'Emprunts subordonnés', 42); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (421, 'Emprunts subordonnés', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4210, 'convertibles', 420); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4211, 'non convertibles', 420); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (422, ' Dettes de locations financement', 42); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (423, ' Etablissement de crédit', 42); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (423, ' Etablissement de crédit', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4230, 'Dettes en comptes', 423); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4231, 'Promesses', 423); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4232, 'Crédits d''acceptation', 423); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4232, 'Crédits d''acceptation', 423); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (424, 'Autres emprunts', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (425, 'Dettes commerciales', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4250, 'Fournisseurs', 425); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4251, 'Effets à payer', 425); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (426, 'Acomptes reçus sur commandes', 42); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (428, 'Cautionnement reçus en numéraires', 42); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4251, 'Effets à payer', 425); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (426, 'Acomptes reçus sur commandes', 42); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (428, 'Cautionnement reçus en numéraires', 42); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (429, 'Dettes diverses', 42); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43, 'Dettes financières', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (430, 'Etablissements de crédit - Emprunts à compte à terme fixe', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (431, 'Etablissements de crédit - Promesses', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (432, ' Etablissements de crédit - Crédits d''acceptation', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (433, 'Etablissements de crédit -Dettes en comptes courant', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43, 'Dettes financières', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (430, 'Etablissements de crédit - Emprunts à compte à terme fixe', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (431, 'Etablissements de crédit - Promesses', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (432, ' Etablissements de crédit - Crédits d''acceptation', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (433, 'Etablissements de crédit -Dettes en comptes courant', 43); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (439, 'Autres emprunts', 43); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44, 'Dettes commerciales', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (440, 'Fournisseurs', 44); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (441, 'Effets à payer', 44); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (444, 'Factures à recevoir', 44); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (441, 'Effets à payer', 44); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (444, 'Factures à recevoir', 44); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (45, 'Dettes fiscales, salariales et sociales', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (450, 'Dettes fiscales estimées', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4500, 'Impôts belges sur le résultat', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4501, 'Impôts belges sur le résultat', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4502, 'Impôts belges sur le résultat', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4503, 'Impôts belges sur le résultat', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4504, 'Impôts belges sur le résultat', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4505, 'Autres impôts et taxes belges', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4506, 'Autres impôts et taxes belges', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4507, 'Autres impôts et taxes belges', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4508, 'Impôts et taxes étrangers', 450); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (451, 'TVA à payer', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4511, 'TVA à payer 21%', 451); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4512, 'TVA à payer 12%', 451); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4513, 'TVA à payer 6%', 451); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4514, 'TVA à payer 0%', 451); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (452, 'Impôts et taxes à payer', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4520, 'Impôts belges sur le résultat', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4521, 'Impôts belges sur le résultat', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4522, 'Impôts belges sur le résultat', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4523, 'Impôts belges sur le résultat', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4524, 'Impôts belges sur le résultat', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4525, 'Autres impôts et taxes belges', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4526, 'Autres impôts et taxes belges', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4527, 'Autres impôts et taxes belges', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4528, 'Impôts et taxes étrangers', 452); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (453, 'Précomptes retenus', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (454, 'Office National de la Sécurité Sociales', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (455, 'Rémunérations', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (456, 'Pécules de vacances', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (450, 'Dettes fiscales estimées', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4500, 'Impôts belges sur le résultat', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4501, 'Impôts belges sur le résultat', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4502, 'Impôts belges sur le résultat', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4503, 'Impôts belges sur le résultat', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4504, 'Impôts belges sur le résultat', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4505, 'Autres impôts et taxes belges', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4506, 'Autres impôts et taxes belges', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4507, 'Autres impôts et taxes belges', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4508, 'Impôts et taxes étrangers', 450); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (451, 'TVA à payer', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4511, 'TVA à payer 21%', 451); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4512, 'TVA à payer 12%', 451); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4513, 'TVA à payer 6%', 451); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4514, 'TVA à payer 0%', 451); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (452, 'Impôts et taxes à payer', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4520, 'Impôts belges sur le résultat', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4521, 'Impôts belges sur le résultat', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4522, 'Impôts belges sur le résultat', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4523, 'Impôts belges sur le résultat', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4524, 'Impôts belges sur le résultat', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4525, 'Autres impôts et taxes belges', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4526, 'Autres impôts et taxes belges', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4527, 'Autres impôts et taxes belges', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4528, 'Impôts et taxes étrangers', 452); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (453, 'Précomptes retenus', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (454, 'Office National de la Sécurité Sociales', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (455, 'Rémunérations', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (456, 'Pécules de vacances', 45); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (459, 'Autres dettes sociales', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (46, 'Acomptes reçus sur commandes', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (47, 'Dettes découlant de l''affectation du résultat', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (470, 'Dividendes et tantièmes d''exercices antérieurs', 47); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (46, 'Acomptes reçus sur commandes', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (47, 'Dettes découlant de l''affectation du résultat', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (470, 'Dividendes et tantièmes d''exercices antérieurs', 47); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (471, 'Dividendes de l''exercice', 47); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (472, 'Tantièmes de l''exercice', 47); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (472, 'Tantièmes de l''exercice', 47); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (473, 'Autres allocataires', 47); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (48, 'Dettes diverses', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (480, 'Obligations et coupons échus', 48); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (488, 'Cautionnements reçus en numéraires', 48); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (480, 'Obligations et coupons échus', 48); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (488, 'Cautionnements reçus en numéraires', 48); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (489, 'Autres dettes diverses', 48); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4890, 'Compte de l''exploitant', 489); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (49, 'Comptes de régularisation', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (490, 'Charges à reporter', 49); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (49, 'Comptes de régularisation', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (490, 'Charges à reporter', 49); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (491, 'Produits acquis', 49); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (492, 'Charges à imputer', 49); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (493, 'Produits à reporter', 49); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (492, 'Charges à imputer', 49); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (493, 'Produits à reporter', 49); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (499, 'Comptes d''attentes', 49); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (50, 'Actions propres', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (51, 'Actions et parts', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (510, 'Valeur d''acquisition', 51); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (511, 'Montant non appelés', 51); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (519, 'Réductions de valeur actées', 51); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (52, 'Titres à revenu fixe', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (511, 'Montant non appelés', 51); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (519, 'Réductions de valeur actées', 51); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (52, 'Titres à revenu fixe', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (520, 'Valeur d''acquisition', 52); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (529, 'Réductions de valeur actées', 52); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (53, 'Dépôts à terme', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (529, 'Réductions de valeur actées', 52); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (53, 'Dépôts à terme', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (530, 'de plus d''un an', 53); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (531, 'de plus d''un mois et d''un an au plus', 53); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (532, 'd''un mois au plus', 53); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (539, 'Réductions de valeur actées', 53); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (54, 'Valeurs échues à l''encaissement', 5); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (55, 'Etablissement de crédit', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (539, 'Réductions de valeur actées', 53); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (54, 'Valeurs échues à l''encaissement', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (55, 'Etablissement de crédit', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (550, 'Banque 1', 55); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5500, 'Comptes courants', 550); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5501, 'Chèques émis (-)', 550); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5509, 'Réduction de valeur actée', 550); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5501, 'Chèques émis (-)', 550); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5509, 'Réduction de valeur actée', 550); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5510, 'Comptes courants', 551); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5511, 'Chèques émis (-)', 551); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5519, 'Réduction de valeur actée', 551); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5511, 'Chèques émis (-)', 551); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5519, 'Réduction de valeur actée', 551); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5520, 'Comptes courants', 552); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5521, 'Chèques émis (-)', 552); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5529, 'Réduction de valeur actée', 552); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5521, 'Chèques émis (-)', 552); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5529, 'Réduction de valeur actée', 552); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5530, 'Comptes courants', 553); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5531, 'Chèques émis (-)', 553); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5539, 'Réduction de valeur actée', 553); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5531, 'Chèques émis (-)', 553); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5539, 'Réduction de valeur actée', 553); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5540, 'Comptes courants', 554); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5541, 'Chèques émis (-)', 554); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5549, 'Réduction de valeur actée', 554); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5541, 'Chèques émis (-)', 554); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5549, 'Réduction de valeur actée', 554); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5550, 'Comptes courants', 555); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5551, 'Chèques émis (-)', 555); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5559, 'Réduction de valeur actée', 555); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5551, 'Chèques émis (-)', 555); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5559, 'Réduction de valeur actée', 555); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5560, 'Comptes courants', 556); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5561, 'Chèques émis (-)', 556); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5569, 'Réduction de valeur actée', 556); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5561, 'Chèques émis (-)', 556); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5569, 'Réduction de valeur actée', 556); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5570, 'Comptes courants', 557); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5571, 'Chèques émis (-)', 557); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5579, 'Réduction de valeur actée', 557); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5571, 'Chèques émis (-)', 557); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5579, 'Réduction de valeur actée', 557); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5580, 'Comptes courants', 558); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5581, 'Chèques émis (-)', 558); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5589, 'Réduction de valeur actée', 558); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5581, 'Chèques émis (-)', 558); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5589, 'Réduction de valeur actée', 558); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5590, 'Comptes courants', 559); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5591, 'Chèques émis (-)', 559); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5599, 'Réduction de valeur actée', 559); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (56, 'Office des chèques postaux', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5591, 'Chèques émis (-)', 559); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5599, 'Réduction de valeur actée', 559); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (56, 'Office des chèques postaux', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (560, 'Compte courant', 56); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (561, 'Chèques émis', 56); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (561, 'Chèques émis', 56); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (578, 'Caisse timbre', 57); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (58, 'Virement interne', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (60, 'Approvisionnement et marchandises', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (600, 'Achats de matières premières', 60); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (600, 'Achats de matières premières', 60); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (601, 'Achats de fournitures', 60); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (602, 'Achats de services, travaux et études', 60); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (603, 'Sous-traitances générales', 60); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (602, 'Achats de services, travaux et études', 60); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (603, 'Sous-traitances générales', 60); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (604, 'Achats de marchandises', 60); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (605, 'Achats d''immeubles destinés à la vente', 60); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (605, 'Achats d''immeubles destinés à la vente', 60); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (608, 'Remises, ristournes et rabais obtenus(-)', 60); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (609, 'Variation de stock', 60); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6090, 'de matières premières', 609); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6090, 'de matières premières', 609); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6091, 'de fournitures', 609); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6094, 'de marchandises', 609); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6095, 'immeubles achetés destinés à la vente', 609); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6095, 'immeubles achetés destinés à la vente', 609); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (61, 'Services et biens divers', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (62, 'Rémunérations, charges sociales et pensions', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (620, 'Rémunérations et avantages sociaux directs', 62); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6200, 'Administrateurs ou gérants', 620); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (62, 'Rémunérations, charges sociales et pensions', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (620, 'Rémunérations et avantages sociaux directs', 62); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6200, 'Administrateurs ou gérants', 620); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6201, 'Personnel de directions', 620); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6202, 'Employés,620', 6202); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6202, 'Employés,620', 6202); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6203, 'Ouvriers', 620); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6204, 'Autres membres du personnel', 620); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (621, 'Cotisations patronales d''assurances sociales', 62); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (622, 'Primes partonales pour assurances extra-légales', 62); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (622, 'Primes partonales pour assurances extra-légales', 62); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (623, 'Autres frais de personnel', 62); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (624, 'Pensions de retraite et de survie', 62); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6240, 'Administrateurs ou gérants', 624); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6240, 'Administrateurs ou gérants', 624); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6241, 'Personnel', 624); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (63, 'Amortissements, réductions de valeurs et provisions pour risques et charges', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (630, 'Dotations aux amortissements et réduction de valeurs sur immobilisations', 63); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6300, ' Dotations aux amortissements sur frais d''établissement', 630); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (63, 'Amortissements, réductions de valeurs et provisions pour risques et charges', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (630, 'Dotations aux amortissements et réduction de valeurs sur immobilisations', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6300, ' Dotations aux amortissements sur frais d''établissement', 630); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (705, 'Ventes et prestations de services', 70); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6301, 'Dotations aux amortissements sur immobilisations incorporelles', 630); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6302, 'Dotations aux amortissements sur immobilisations corporelles', 630); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6308, 'Dotations aux réductions de valeur sur immobilisations incorporelles', 630); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6309, 'Dotations aux réductions de valeur sur immobilisations corporelles', 630); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (631, 'Réductions de valeur sur stocks', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6308, 'Dotations aux réductions de valeur sur immobilisations incorporelles', 630); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6309, 'Dotations aux réductions de valeur sur immobilisations corporelles', 630); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (631, 'Réductions de valeur sur stocks', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6310, 'Dotations', 631); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6311, 'Reprises(-)', 631); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (632, 'Réductions de valeur sur commande en cours d''éxécution', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (632, 'Réductions de valeur sur commande en cours d''éxécution', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6320, 'Dotations', 632); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6321, 'Reprises(-)', 632); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (633, 'Réductions de valeurs sur créances commerciales à plus d''un an', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (633, 'Réductions de valeurs sur créances commerciales à plus d''un an', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6330, 'Dotations', 633); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6331, 'Reprises(-)', 633); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (634, 'Réductions de valeur sur créances commerciales à un an au plus', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (634, 'Réductions de valeur sur créances commerciales à un an au plus', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6340, 'Dotations', 634); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6341, 'Reprise', 634); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (635, 'Provisions pour pensions et obligations similaires', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6350, 'Dotations', 635); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6351, 'Utilisation et reprises', 635); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (636, 'Provisions pour grosses réparations et gros entretien', 63); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (636, 'Provisions pour grosses réparations et gros entretien', 63); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6360, 'Dotations', 636); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6361, 'Reprises(-)', 636); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (637, 'Provisions pour autres risques et charges', 63); @@ -1355,65 +1355,65 @@ INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6370, 'Dotations INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6371, 'Reprises(-)', 637); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (64, 'Autres charges d''exploitation', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (640, 'Charges fiscales d''exploitation', 64); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (641, 'Moins-values sur réalisations courantes d''immobilisations corporelles', 64); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (642, 'Moins-value sur réalisation de créances commerciales', 64); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (641, 'Moins-values sur réalisations courantes d''immobilisations corporelles', 64); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (642, 'Moins-value sur réalisation de créances commerciales', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (643, 'Charges d''exploitations', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (644, 'Charges d''exploitations', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (645, 'Charges d''exploitations', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (646, 'Charges d''exploitations', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (647, 'Charges d''exploitations', 64); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (648, 'Charges d''exploitations', 64); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (649, 'Charges d''exploitation portées à l''actif au titre de frais de restructuration(-)', 64); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (65, 'Charges financières', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (649, 'Charges d''exploitation portées à l''actif au titre de frais de restructuration(-)', 64); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (65, 'Charges financières', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (650, 'Charges des dettes', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6500, 'Intérêts, commmissions et frais afférents aux dettes', 650); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6501, 'Amortissements des frais d''émissions d''emrunts et des primes de remboursement', 650); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6500, 'Intérêts, commmissions et frais afférents aux dettes', 650); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6501, 'Amortissements des frais d''émissions d''emrunts et des primes de remboursement', 650); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6502, 'Autres charges des dettes', 650); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6503, 'Intérêts intercalaires portés à l''actif(-)', 650); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (651, 'Réductions de valeur sur actifs circulants', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6503, 'Intérêts intercalaires portés à l''actif(-)', 650); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (651, 'Réductions de valeur sur actifs circulants', 65); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6510, 'Dotations', 651); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6511, 'Reprises(-)', 651); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (652, 'Moins-value sur réalisation d''actifs circulants', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (653, 'Charges d''escompte de créances', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (654, 'Différences de changes', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (652, 'Moins-value sur réalisation d''actifs circulants', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (653, 'Charges d''escompte de créances', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (654, 'Différences de changes', 65); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (655, 'Ecarts de conversion des devises', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (656, 'Charges financières diverses', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (657, 'Charges financières diverses', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (658, 'Charges financières diverses', 65); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (659, 'Charges financières diverses', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (656, 'Charges financières diverses', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (657, 'Charges financières diverses', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (658, 'Charges financières diverses', 65); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (659, 'Charges financières diverses', 65); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (66, 'Charges exceptionnelles', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (660, 'Amortissements et réductions de valeur exceptionnels (dotations)', 66); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6600, 'sur frais d''établissement', 660); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (660, 'Amortissements et réductions de valeur exceptionnels (dotations)', 66); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6600, 'sur frais d''établissement', 660); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6601, 'sur immobilisations incorporelles', 660); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6602, 'sur immobilisations corporelles', 660); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (661, 'Réductions de valeur sur immobilisations financières (dotations)', 66); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (661, 'Réductions de valeur sur immobilisations financières (dotations)', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (662, 'Provisions pour risques et charges exceptionnels', 66); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (663, 'Moins-values sur réalisations d''actifs immobilisés', 66); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (663, 'Moins-values sur réalisations d''actifs immobilisés', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (664, 'Autres charges exceptionnelles', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (665, 'Autres charges exceptionnelles', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (666, 'Autres charges exceptionnelles', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (667, 'Autres charges exceptionnelles', 66); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (668, 'Autres charges exceptionnelles', 66); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (669, ' Charges exceptionnelles portées à l''actif au titre de frais de restructuration', 66); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (67, 'impôts sur le résultat', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (670, 'Impôts belge sur le résultat de l''exercice', 67); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6700, 'Impôts et précomptes dus ou versés', 670); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6701, 'Excédents de versement d''impôts et de précomptes portés à l''actifs (-)', 670); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6702, 'Charges fiscales estimées', 670); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (671, 'Impôts belges sur le résultats d''exercices antérieures', 67); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6710, 'Suppléments d''impôt dus ou versés', 671); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6711, 'Suppléments d''impôts estimés', 671); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6712, 'Provisions fiscales constituées', 671); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (672, 'Impôts étrangers sur le résultat de l''exercice', 67); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (673, 'Impôts étrangers sur le résultat d''exercice antérieures', 67); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (68, 'Transferts aux réserves immunisées', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (69, 'Affectations et prélévements', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (690, 'Perte reportée de l''exercice précédent', 69); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (691, 'Dotation à la réserve légale', 69); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (692, 'Dotation aux autres réserves', 69); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (693, 'Bénéfice à reporter', 69); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (694, 'Rémunération du capital', 69); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (695, 'Administrateurs ou gérants', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (669, ' Charges exceptionnelles portées à l''actif au titre de frais de restructuration', 66); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (67, 'impôts sur le résultat', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (670, 'Impôts belge sur le résultat de l''exercice', 67); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6700, 'Impôts et précomptes dus ou versés', 670); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6701, 'Excédents de versement d''impôts et de précomptes portés à l''actifs (-)', 670); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6702, 'Charges fiscales estimées', 670); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (671, 'Impôts belges sur le résultats d''exercices antérieures', 67); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6710, 'Suppléments d''impôt dus ou versés', 671); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6711, 'Suppléments d''impôts estimés', 671); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6712, 'Provisions fiscales constituées', 671); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (672, 'Impôts étrangers sur le résultat de l''exercice', 67); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (673, 'Impôts étrangers sur le résultat d''exercice antérieures', 67); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (68, 'Transferts aux réserves immunisées', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (69, 'Affectations et prélévements', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (690, 'Perte reportée de l''exercice précédent', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (691, 'Dotation à la réserve légale', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (692, 'Dotation aux autres réserves', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (693, 'Bénéfice à reporter', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (694, 'Rémunération du capital', 69); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (695, 'Administrateurs ou gérants', 69); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (696, 'Autres allocataires', 69); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (70, 'Chiffre d''affaire', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (700, 'Ventes et prestations de services', 70); @@ -1423,19 +1423,19 @@ INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (703, 'Ventes et INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (704, 'Ventes et prestations de services', 70); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (706, 'Ventes et prestations de services', 70); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (707, 'Ventes et prestations de services', 70); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (709, 'Remises, ristournes et rabais accordés(-)', 70); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (71, 'Variations des stocks et commandes en cours d''éxécution', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (709, 'Remises, ristournes et rabais accordés(-)', 70); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (71, 'Variations des stocks et commandes en cours d''éxécution', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (712, 'des en-cours de fabrication', 71); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (713, 'des produits finis', 71); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (715, 'des immeubles construits destinés à la vente', 71); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (717, ' des commandes en cours d''éxécution', 71); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (715, 'des immeubles construits destinés à la vente', 71); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (717, ' des commandes en cours d''éxécution', 71); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7170, 'Valeur d''acquisition', 717); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7171, 'Bénéfice pris en compte', 717); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (72, 'Production immobilisée', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7171, 'Bénéfice pris en compte', 717); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (72, 'Production immobilisée', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (74, 'Autres produits d''exploitation', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (740, 'Subsides d'' exploitation et montants compensatoires', 74); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (741, 'Plus-values sur réalisation courantes d'' immobilisations corporelles', 74); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (742, 'Plus-values sur réalisations de créances commerciales', 74); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (741, 'Plus-values sur réalisation courantes d'' immobilisations corporelles', 74); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (742, 'Plus-values sur réalisations de créances commerciales', 74); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (743, 'Produits d''exploitations divers', 74); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (744, 'Produits d''exploitations divers', 74); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (745, 'Produits d''exploitations divers', 74); @@ -1444,76 +1444,76 @@ INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (747, 'Produits d INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (748, 'Produits d''exploitations divers', 74); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (749, 'Produits d''exploitations divers', 74); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (75, 'Produits financiers', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (750, 'Produits sur immobilisations financières', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (750, 'Produits sur immobilisations financières', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (751, 'Produits des actifs circulants', 75); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (752, 'Plus-value sur réalisations d''actis circulants', 75); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (753, 'Subsides en capital et intérêts', 75); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (754, 'Différences de change', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (752, 'Plus-value sur réalisations d''actis circulants', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (753, 'Subsides en capital et intérêts', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (754, 'Différences de change', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (755, 'Ecarts de conversion des devises', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (756, 'Produits financiers divers', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (757, 'Produits financiers divers', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (758, 'Produits financiers divers', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (759, 'Produits financiers divers', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (76, 'Produits exceptionnels', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (760, 'Reprise d''amortissements et de réductions de valeur', 76); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (760, 'Reprise d''amortissements et de réductions de valeur', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7601, 'sur immobilisations corporelles', 760); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7602, 'sur immobilisations incorporelles', 760); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (761, 'Reprises de réductions de valeur sur immobilisations financières', 76); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (761, 'Reprises de réductions de valeur sur immobilisations financières', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (762, 'Reprises de provisions pour risques et charges exceptionnels', 76); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (763, 'Plus-value sur réalisation d''actifs immobilisé', 76); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (763, 'Plus-value sur réalisation d''actifs immobilisé', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (764, 'Autres produits exceptionnels', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (765, 'Autres produits exceptionnels', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (766, 'Autres produits exceptionnels', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (767, 'Autres produits exceptionnels', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (768, 'Autres produits exceptionnels', 76); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (769, 'Autres produits exceptionnels', 76); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (77, 'Régularisations d''impôts et reprises de provisions fiscales', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (771, 'impôts belges sur le résultat', 77); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7710, 'Régularisations d''impôts dus ou versé', 771); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7711, 'Régularisations d''impôts estimés', 771); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (77, 'Régularisations d''impôts et reprises de provisions fiscales', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (771, 'impôts belges sur le résultat', 77); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7710, 'Régularisations d''impôts dus ou versé', 771); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7711, 'Régularisations d''impôts estimés', 771); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7712, 'Reprises de provisions fiscales', 771); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (773, 'Impôts étrangers sur le résultats', 77); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (79, 'Affectations et prélévements', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (790, 'Bénéfice reporté de l''exercice précédent', 79); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (791, 'Prélévement sur le capital et les primes d''émission', 79); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (792, 'Prélévement sur les réserves', 79); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (793, 'Perte à reporter', 79); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (794, 'Intervention d''associés (ou du propriétaire) dans la perte', 79); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1, 'Fonds propres, provisions pour risques et charges à plus d''un an', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2, 'Frais d''établissement, actifs immobilisés et créances à plus d''un an', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (3, 'Stocks et commandes en cours d''éxécution', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4, 'Créances et dettes à un an au plus', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5, 'Placements de trésorerie et valeurs disponibles', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (773, 'Impôts étrangers sur le résultats', 77); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (79, 'Affectations et prélévements', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (790, 'Bénéfice reporté de l''exercice précédent', 79); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (791, 'Prélévement sur le capital et les primes d''émission', 79); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (792, 'Prélévement sur les réserves', 79); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (793, 'Perte à reporter', 79); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (794, 'Intervention d''associés (ou du propriétaire) dans la perte', 79); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1, 'Fonds propres, provisions pour risques et charges à plus d''un an', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2, 'Frais d''établissement, actifs immobilisés et créances à plus d''un an', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (3, 'Stocks et commandes en cours d''éxécution', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4, 'Créances et dettes à un an au plus', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5, 'Placements de trésorerie et valeurs disponibles', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6, 'Charges', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7, 'Produits', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4000001, 'Client 1', 400); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4000002, 'Client 2', 400); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4000003, 'Client 3', 400); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040001, 'Electricité', 604); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040001, 'Electricité', 604); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6040002, 'Loyer', 604); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (55000002, 'Banque 1', 5500); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (55000003, 'Banque 2', 5500); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4400001, 'Fournisseur 1', 440); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4400002, 'Fournisseur 2', 440); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4400003, 'Fournisseur 4', 440); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610001, 'Electricité', 61); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610001, 'Electricité', 61); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610002, 'Loyer', 61); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610003, 'Assurance', 61); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610004, 'Matériel bureau', 61); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (610004, 'Matériel bureau', 61); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7000002, 'Marchandise A', 700); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7000001, 'Prestation', 700); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7000003, 'Déplacement', 700); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (101, 'Capital non appelé', 10); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6190, 'TVA récupérable par l''impôt', 61); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6740, 'Dépense non admise', 67); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7000003, 'Déplacement', 700); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (101, 'Capital non appelé', 10); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6190, 'TVA récupérable par l''impôt', 61); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6740, 'Dépense non admise', 67); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (9, 'Comptes hors Compta', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (100, 'Capital souscrit', 10); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1311, 'Autres réserves indisponibles', 131); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (132, ' Réserves immunisées', 13); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1311, 'Autres réserves indisponibles', 131); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (132, ' Réserves immunisées', 13); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (1, '21%', 0.2100, 'Tva applicable à tout ce qui bien et service divers', '4111,4511'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (1, '21%', 0.2100, 'Tva applicable à tout ce qui bien et service divers', '4111,4511'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (2, '12%', 0.1200, 'Tva ', '4112,4512'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (3, '6%', 0.0600, 'Tva applicable aux journaux et livres', '4113,4513'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (4, '0%', 0.0000, 'Tva applicable lors de vente/achat intracommunautaire', '4114,4514'); diff --git a/html/admin/sql/mod1/make-sql b/html/admin/sql/mod1/make-sql index 6c24f92da..ddacdac7e 100755 --- a/html/admin/sql/mod1/make-sql +++ b/html/admin/sql/mod1/make-sql @@ -5,7 +5,7 @@ awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql ( -echo " SET client_encoding = 'LATIN1';" +echo " SET client_encoding = 'utf8';" echo " SET check_function_bodies = false;" echo " SET client_min_messages = warning;" echo "SET search_path = public, pg_catalog;" diff --git a/html/admin/sql/mod1/schema.sql b/html/admin/sql/mod1/schema.sql index 58845f5dc..bbdf56020 100644 --- a/html/admin/sql/mod1/schema.sql +++ b/html/admin/sql/mod1/schema.sql @@ -1,5 +1,5 @@ -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; @@ -1933,7 +1933,7 @@ CREATE TABLE tmp_pcmn ( -COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé'; +COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé'; diff --git a/html/admin/sql/mod2/data.sql b/html/admin/sql/mod2/data.sql index b80833950..4ca5b1f7e 100644 --- a/html/admin/sql/mod2/data.sql +++ b/html/admin/sql/mod2/data.sql @@ -1,5 +1,5 @@ -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET check_function_bodies = false; SET client_min_messages = warning; @@ -227,24 +227,24 @@ SELECT pg_catalog.setval('seq_doc_type_9', 1, false); INSERT INTO "action" (ac_id, ac_description) VALUES (4, 'Impression'); -INSERT INTO "action" (ac_id, ac_description) VALUES (6, 'Mise à jour Plan Comptable'); +INSERT INTO "action" (ac_id, ac_description) VALUES (6, 'Mise à jour Plan Comptable'); INSERT INTO "action" (ac_id, ac_description) VALUES (7, 'Gestion Journaux'); -INSERT INTO "action" (ac_id, ac_description) VALUES (8, 'Paramètres'); +INSERT INTO "action" (ac_id, ac_description) VALUES (8, 'Paramètres'); INSERT INTO "action" (ac_id, ac_description) VALUES (10, 'Centralise'); INSERT INTO "action" (ac_id, ac_description) VALUES (16, 'Voir le stock'); INSERT INTO "action" (ac_id, ac_description) VALUES (17, 'Modifie le stock'); INSERT INTO "action" (ac_id, ac_description) VALUES (20, 'Voir la balance des comptes'); -INSERT INTO "action" (ac_id, ac_description) VALUES (21, 'Import et export des écritures d''ouverture'); +INSERT INTO "action" (ac_id, ac_description) VALUES (21, 'Import et export des écritures d''ouverture'); INSERT INTO "action" (ac_id, ac_description) VALUES (28, 'Module Suivi Document'); INSERT INTO "action" (ac_id, ac_description) VALUES (22, 'Module Client'); INSERT INTO "action" (ac_id, ac_description) VALUES (24, 'Module Fournisseur'); INSERT INTO "action" (ac_id, ac_description) VALUES (26, 'Module Administration'); INSERT INTO "action" (ac_id, ac_description) VALUES (30, 'Module Gestion'); INSERT INTO "action" (ac_id, ac_description) VALUES (1, 'Lecture du Grand-Livre'); -INSERT INTO "action" (ac_id, ac_description) VALUES (31, 'Gestion des périodes comptables'); +INSERT INTO "action" (ac_id, ac_description) VALUES (31, 'Gestion des périodes comptables'); INSERT INTO "action" (ac_id, ac_description) VALUES (3, 'Lecture des fiches'); INSERT INTO "action" (ac_id, ac_description) VALUES (15, 'Ajout de fiche et modification'); -INSERT INTO "action" (ac_id, ac_description) VALUES (5, 'Création et modifications des rapports'); +INSERT INTO "action" (ac_id, ac_description) VALUES (5, 'Création et modifications des rapports'); INSERT INTO "action" (ac_id, ac_description) VALUES (50, 'Definir les Plans Analytiques et les postes'); INSERT INTO "action" (ac_id, ac_description) VALUES (51, 'Impression CA'); INSERT INTO "action" (ac_id, ac_description) VALUES (52, 'Operations Diverses CA'); @@ -256,28 +256,28 @@ INSERT INTO "action" (ac_id, ac_description) VALUES (52, 'Operations Diverses CA INSERT INTO attr_def (ad_id, ad_text) VALUES (1, 'Nom'); INSERT INTO attr_def (ad_id, ad_text) VALUES (2, 'Taux TVA'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (3, 'Numéro de compte'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (3, 'Numéro de compte'); INSERT INTO attr_def (ad_id, ad_text) VALUES (4, 'Nom de la banque'); INSERT INTO attr_def (ad_id, ad_text) VALUES (5, 'Poste Comptable'); INSERT INTO attr_def (ad_id, ad_text) VALUES (6, 'Prix vente'); INSERT INTO attr_def (ad_id, ad_text) VALUES (7, 'Prix achat'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (8, 'Durée Amortissement'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (8, 'Durée Amortissement'); INSERT INTO attr_def (ad_id, ad_text) VALUES (9, 'Description'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (10, 'Date début'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (10, 'Date début'); INSERT INTO attr_def (ad_id, ad_text) VALUES (11, 'Montant initial'); INSERT INTO attr_def (ad_id, ad_text) VALUES (12, 'Personne de contact '); -INSERT INTO attr_def (ad_id, ad_text) VALUES (13, 'numéro de tva '); +INSERT INTO attr_def (ad_id, ad_text) VALUES (13, 'numéro de tva '); INSERT INTO attr_def (ad_id, ad_text) VALUES (14, 'Adresse '); INSERT INTO attr_def (ad_id, ad_text) VALUES (16, 'pays '); -INSERT INTO attr_def (ad_id, ad_text) VALUES (17, 'téléphone '); +INSERT INTO attr_def (ad_id, ad_text) VALUES (17, 'téléphone '); INSERT INTO attr_def (ad_id, ad_text) VALUES (18, 'email '); INSERT INTO attr_def (ad_id, ad_text) VALUES (19, 'Gestion stock'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (20, 'Partie fiscalement non déductible'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (21, 'TVA non déductible'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (22, 'TVA non déductible récupérable par l''impôt'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (20, 'Partie fiscalement non déductible'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (21, 'TVA non déductible'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (22, 'TVA non déductible récupérable par l''impôt'); INSERT INTO attr_def (ad_id, ad_text) VALUES (23, 'Quick Code'); INSERT INTO attr_def (ad_id, ad_text) VALUES (24, 'Ville'); -INSERT INTO attr_def (ad_id, ad_text) VALUES (25, 'Société'); +INSERT INTO attr_def (ad_id, ad_text) VALUES (25, 'Société'); INSERT INTO attr_def (ad_id, ad_text) VALUES (26, 'Fax'); INSERT INTO attr_def (ad_id, ad_text) VALUES (27, 'GSM'); INSERT INTO attr_def (ad_id, ad_text) VALUES (15, 'code postal'); @@ -381,7 +381,7 @@ INSERT INTO attr_min (frd_id, ad_id) VALUES (18, 9); -INSERT INTO attr_value (jft_id, av_text) VALUES (366, 'Fournisseurs et Comptes rattachés'); +INSERT INTO attr_value (jft_id, av_text) VALUES (366, 'Fournisseurs et Comptes rattachés'); INSERT INTO attr_value (jft_id, av_text) VALUES (367, '400'); INSERT INTO attr_value (jft_id, av_text) VALUES (368, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (369, ''); @@ -392,13 +392,13 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (373, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (374, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (375, 'Q400'); INSERT INTO attr_value (jft_id, av_text) VALUES (376, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (377, 'autres charges externes - Services extérieurs'); +INSERT INTO attr_value (jft_id, av_text) VALUES (377, 'autres charges externes - Services extérieurs'); INSERT INTO attr_value (jft_id, av_text) VALUES (378, '101'); INSERT INTO attr_value (jft_id, av_text) VALUES (379, '61'); INSERT INTO attr_value (jft_id, av_text) VALUES (380, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (381, 'Q61'); INSERT INTO attr_value (jft_id, av_text) VALUES (393, 'Q53'); -INSERT INTO attr_value (jft_id, av_text) VALUES (394, 'valeurs mobilières de placement'); +INSERT INTO attr_value (jft_id, av_text) VALUES (394, 'valeurs mobilières de placement'); INSERT INTO attr_value (jft_id, av_text) VALUES (395, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (396, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (397, '50'); @@ -457,7 +457,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (449, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (450, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (451, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (452, 'Q76'); -INSERT INTO attr_value (jft_id, av_text) VALUES (453, 'Charges financières'); +INSERT INTO attr_value (jft_id, av_text) VALUES (453, 'Charges financières'); INSERT INTO attr_value (jft_id, av_text) VALUES (454, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (455, '66'); INSERT INTO attr_value (jft_id, av_text) VALUES (456, ''); @@ -489,7 +489,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (475, 'achat de marchandises'); INSERT INTO attr_value (jft_id, av_text) VALUES (476, '101'); INSERT INTO attr_value (jft_id, av_text) VALUES (477, '607'); INSERT INTO attr_value (jft_id, av_text) VALUES (478, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (480, 'Fournisseurs et Comptes rattachés'); +INSERT INTO attr_value (jft_id, av_text) VALUES (480, 'Fournisseurs et Comptes rattachés'); INSERT INTO attr_value (jft_id, av_text) VALUES (481, '400'); INSERT INTO attr_value (jft_id, av_text) VALUES (482, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (483, ''); @@ -498,7 +498,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (485, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (486, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (487, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (488, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (489, 'Q408FACTàRECEVOIR'); +INSERT INTO attr_value (jft_id, av_text) VALUES (489, 'Q408FACTàRECEVOIR'); INSERT INTO attr_value (jft_id, av_text) VALUES (490, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (491, 'achat de marchandises'); INSERT INTO attr_value (jft_id, av_text) VALUES (492, '101'); @@ -515,7 +515,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (511, '707'); INSERT INTO attr_value (jft_id, av_text) VALUES (512, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (513, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (514, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (516, 'Produits des activités annexes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (516, 'Produits des activités annexes'); INSERT INTO attr_value (jft_id, av_text) VALUES (517, '101'); INSERT INTO attr_value (jft_id, av_text) VALUES (518, '708'); INSERT INTO attr_value (jft_id, av_text) VALUES (519, ''); @@ -534,17 +534,17 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (532, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (533, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (534, 'Q101'); INSERT INTO attr_value (jft_id, av_text) VALUES (539, 'Q62DEPLACEMENTS'); -INSERT INTO attr_value (jft_id, av_text) VALUES (540, 'autres charges externes - Autres services extérieurs'); +INSERT INTO attr_value (jft_id, av_text) VALUES (540, 'autres charges externes - Autres services extérieurs'); INSERT INTO attr_value (jft_id, av_text) VALUES (541, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (542, '62'); INSERT INTO attr_value (jft_id, av_text) VALUES (543, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (544, 'Q62FRAISMISSIONS'); INSERT INTO attr_value (jft_id, av_text) VALUES (549, 'Q62FRAISTELECOM'); -INSERT INTO attr_value (jft_id, av_text) VALUES (545, 'autres charges externes - Autres services extérieurs'); +INSERT INTO attr_value (jft_id, av_text) VALUES (545, 'autres charges externes - Autres services extérieurs'); INSERT INTO attr_value (jft_id, av_text) VALUES (546, '101'); INSERT INTO attr_value (jft_id, av_text) VALUES (547, '62'); INSERT INTO attr_value (jft_id, av_text) VALUES (548, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (550, 'Associés - Comptes courants'); +INSERT INTO attr_value (jft_id, av_text) VALUES (550, 'Associés - Comptes courants'); INSERT INTO attr_value (jft_id, av_text) VALUES (551, '455'); INSERT INTO attr_value (jft_id, av_text) VALUES (552, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (553, ''); @@ -555,11 +555,11 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (557, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (558, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (559, 'Q455ASSOCIE1'); INSERT INTO attr_value (jft_id, av_text) VALUES (560, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (535, 'autres charges externes - Autres services extérieurs'); +INSERT INTO attr_value (jft_id, av_text) VALUES (535, 'autres charges externes - Autres services extérieurs'); INSERT INTO attr_value (jft_id, av_text) VALUES (536, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (537, '62'); INSERT INTO attr_value (jft_id, av_text) VALUES (538, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (561, 'Impôts, taxes et versements assimiles'); +INSERT INTO attr_value (jft_id, av_text) VALUES (561, 'Impôts, taxes et versements assimiles'); INSERT INTO attr_value (jft_id, av_text) VALUES (562, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (563, '63'); INSERT INTO attr_value (jft_id, av_text) VALUES (564, ''); @@ -576,7 +576,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (574, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (575, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (576, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (577, 'Q75'); -INSERT INTO attr_value (jft_id, av_text) VALUES (583, 'Rémunération du travail de l''exploitant'); +INSERT INTO attr_value (jft_id, av_text) VALUES (583, 'Rémunération du travail de l''exploitant'); INSERT INTO attr_value (jft_id, av_text) VALUES (584, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (585, '644'); INSERT INTO attr_value (jft_id, av_text) VALUES (586, ''); @@ -587,7 +587,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (604, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (605, '646'); INSERT INTO attr_value (jft_id, av_text) VALUES (606, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (607, 'Q646'); -INSERT INTO attr_value (jft_id, av_text) VALUES (652, 'Personnel - Rémunérations dues'); +INSERT INTO attr_value (jft_id, av_text) VALUES (652, 'Personnel - Rémunérations dues'); INSERT INTO attr_value (jft_id, av_text) VALUES (653, '421'); INSERT INTO attr_value (jft_id, av_text) VALUES (654, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (655, ''); @@ -598,7 +598,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (659, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (660, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (661, 'Q421SALAIRENETNICOLE'); INSERT INTO attr_value (jft_id, av_text) VALUES (662, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (663, 'Personnel - Rémunérations dues'); +INSERT INTO attr_value (jft_id, av_text) VALUES (663, 'Personnel - Rémunérations dues'); INSERT INTO attr_value (jft_id, av_text) VALUES (664, '421'); INSERT INTO attr_value (jft_id, av_text) VALUES (665, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (666, ''); @@ -609,17 +609,17 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (670, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (671, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (672, 'Q421SALAIRENETPIERRE'); INSERT INTO attr_value (jft_id, av_text) VALUES (673, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (578, 'Rémunérations du personnel'); +INSERT INTO attr_value (jft_id, av_text) VALUES (578, 'Rémunérations du personnel'); INSERT INTO attr_value (jft_id, av_text) VALUES (580, '641'); INSERT INTO attr_value (jft_id, av_text) VALUES (581, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (582, 'Q641SALAIREBRUTNICOLE'); -INSERT INTO attr_value (jft_id, av_text) VALUES (674, 'Rémunérations du personnel'); +INSERT INTO attr_value (jft_id, av_text) VALUES (674, 'Rémunérations du personnel'); INSERT INTO attr_value (jft_id, av_text) VALUES (675, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (676, '641'); INSERT INTO attr_value (jft_id, av_text) VALUES (677, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (678, 'Q641SALAIREBRUTPIERRE'); INSERT INTO attr_value (jft_id, av_text) VALUES (617, 'Q431RETENUESURSSAFNICOLE'); -INSERT INTO attr_value (jft_id, av_text) VALUES (608, 'Sécurité sociale'); +INSERT INTO attr_value (jft_id, av_text) VALUES (608, 'Sécurité sociale'); INSERT INTO attr_value (jft_id, av_text) VALUES (609, '431'); INSERT INTO attr_value (jft_id, av_text) VALUES (610, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (611, ''); @@ -629,7 +629,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (614, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (615, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (616, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (618, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (679, 'Sécurité sociale'); +INSERT INTO attr_value (jft_id, av_text) VALUES (679, 'Sécurité sociale'); INSERT INTO attr_value (jft_id, av_text) VALUES (680, '431'); INSERT INTO attr_value (jft_id, av_text) VALUES (681, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (682, ''); @@ -640,7 +640,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (686, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (687, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (688, 'Q431RETENUESURSSAFPIERRE'); INSERT INTO attr_value (jft_id, av_text) VALUES (689, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (619, 'Cotis.Sal.+Pat. Retraite salariés dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (619, 'Cotis.Sal.+Pat. Retraite salariés dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (620, '43731'); INSERT INTO attr_value (jft_id, av_text) VALUES (621, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (622, ''); @@ -652,7 +652,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (627, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (628, 'Q43731RETRAITESALARIESNICOLE'); INSERT INTO attr_value (jft_id, av_text) VALUES (629, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (699, 'Q43731RETRAITESALARIESPIERRE'); -INSERT INTO attr_value (jft_id, av_text) VALUES (630, 'Cotis.Sal.+Pat. Retraite cadres dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (630, 'Cotis.Sal.+Pat. Retraite cadres dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (631, '43732'); INSERT INTO attr_value (jft_id, av_text) VALUES (632, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (633, ''); @@ -677,7 +677,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (730, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (731, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (732, 'Q431'); INSERT INTO attr_value (jft_id, av_text) VALUES (733, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (641, 'Cotis.Sal.+Pat. Chômage dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (641, 'Cotis.Sal.+Pat. Chômage dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (642, '4374'); INSERT INTO attr_value (jft_id, av_text) VALUES (643, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (644, ''); @@ -687,7 +687,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (647, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (648, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (649, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (651, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (712, 'Cotis.Sal.+Pat. Chômage dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (712, 'Cotis.Sal.+Pat. Chômage dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (713, '4374'); INSERT INTO attr_value (jft_id, av_text) VALUES (714, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (715, ''); @@ -697,7 +697,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (718, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (719, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (720, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (722, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (701, 'Cotis.Sal.+Pat. Retraite cadres dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (701, 'Cotis.Sal.+Pat. Retraite cadres dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (702, '43732'); INSERT INTO attr_value (jft_id, av_text) VALUES (703, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (704, ''); @@ -707,7 +707,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (707, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (708, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (709, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (711, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (690, 'Cotis.Sal.+Pat. Retraite salariés dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (690, 'Cotis.Sal.+Pat. Retraite salariés dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (691, '43731'); INSERT INTO attr_value (jft_id, av_text) VALUES (692, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (693, ''); @@ -717,7 +717,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (696, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (697, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (698, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (700, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (734, 'Cotis.Sal. Pat. Retraite salariés dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (734, 'Cotis.Sal. Pat. Retraite salariés dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (735, '43731'); INSERT INTO attr_value (jft_id, av_text) VALUES (736, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (737, ''); @@ -729,7 +729,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (742, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (743, 'Q43731'); INSERT INTO attr_value (jft_id, av_text) VALUES (744, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (754, 'Q43732'); -INSERT INTO attr_value (jft_id, av_text) VALUES (756, 'Cotis.Sal. Pat. Chômage dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (756, 'Cotis.Sal. Pat. Chômage dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (757, '4374'); INSERT INTO attr_value (jft_id, av_text) VALUES (758, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (759, ''); @@ -740,7 +740,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (763, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (764, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (765, 'Q4374'); INSERT INTO attr_value (jft_id, av_text) VALUES (766, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (745, 'Cotis.Sal.+Pat. Retraite cadres dûes'); +INSERT INTO attr_value (jft_id, av_text) VALUES (745, 'Cotis.Sal.+Pat. Retraite cadres dûes'); INSERT INTO attr_value (jft_id, av_text) VALUES (746, '43732'); INSERT INTO attr_value (jft_id, av_text) VALUES (747, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (748, ''); @@ -750,7 +750,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (751, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (752, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (753, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (755, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (767, 'Clients et Comptes rattachés'); +INSERT INTO attr_value (jft_id, av_text) VALUES (767, 'Clients et Comptes rattachés'); INSERT INTO attr_value (jft_id, av_text) VALUES (768, '410'); INSERT INTO attr_value (jft_id, av_text) VALUES (769, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (770, ''); @@ -793,7 +793,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (796, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (797, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (798, 'Q410003PINAILLEUR'); INSERT INTO attr_value (jft_id, av_text) VALUES (799, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (800, 'Frais d''établissement'); +INSERT INTO attr_value (jft_id, av_text) VALUES (800, 'Frais d''établissement'); INSERT INTO attr_value (jft_id, av_text) VALUES (801, '201'); INSERT INTO attr_value (jft_id, av_text) VALUES (802, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (803, ''); @@ -804,7 +804,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (807, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (808, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (809, 'Q2011'); INSERT INTO attr_value (jft_id, av_text) VALUES (810, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (811, 'Fournisseurs et Comptes rattachés'); +INSERT INTO attr_value (jft_id, av_text) VALUES (811, 'Fournisseurs et Comptes rattachés'); INSERT INTO attr_value (jft_id, av_text) VALUES (812, '400'); INSERT INTO attr_value (jft_id, av_text) VALUES (813, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (814, ''); @@ -820,7 +820,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (834, 'Amortissements des immobi INSERT INTO attr_value (jft_id, av_text) VALUES (835, '104'); INSERT INTO attr_value (jft_id, av_text) VALUES (836, '281'); INSERT INTO attr_value (jft_id, av_text) VALUES (837, ''); -INSERT INTO attr_value (jft_id, av_text) VALUES (839, 'Autres impôts, taxes et versements assimilés'); +INSERT INTO attr_value (jft_id, av_text) VALUES (839, 'Autres impôts, taxes et versements assimilés'); INSERT INTO attr_value (jft_id, av_text) VALUES (840, '447'); INSERT INTO attr_value (jft_id, av_text) VALUES (841, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (842, ''); @@ -845,7 +845,7 @@ INSERT INTO attr_value (jft_id, av_text) VALUES (860, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (861, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (862, ''); INSERT INTO attr_value (jft_id, av_text) VALUES (863, 'Q701'); -INSERT INTO attr_value (jft_id, av_text) VALUES (864, 'Rabais, remises et ristournes accordés par l''entreprise'); +INSERT INTO attr_value (jft_id, av_text) VALUES (864, 'Rabais, remises et ristournes accordés par l''entreprise'); INSERT INTO attr_value (jft_id, av_text) VALUES (865, '101'); INSERT INTO attr_value (jft_id, av_text) VALUES (866, '709'); INSERT INTO attr_value (jft_id, av_text) VALUES (867, ''); @@ -874,10 +874,10 @@ INSERT INTO bilan (b_id, b_name, b_file_template, b_file_form, b_type) VALUES (1 -INSERT INTO document_state (s_id, s_value) VALUES (1, 'Envoyé'); +INSERT INTO document_state (s_id, s_value) VALUES (1, 'Envoyé'); INSERT INTO document_state (s_id, s_value) VALUES (2, 'Brouillon'); INSERT INTO document_state (s_id, s_value) VALUES (3, 'A envoyer'); -INSERT INTO document_state (s_id, s_value) VALUES (4, 'Reçu'); +INSERT INTO document_state (s_id, s_value) VALUES (4, 'Reçu'); @@ -959,23 +959,23 @@ INSERT INTO fiche_def (fd_id, fd_class_base, fd_label, fd_create_account, frd_id -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (13, 'Dépenses non admises', 674); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (13, 'Dépenses non admises', 674); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (14, 'Administration des Finances', NULL); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (15, 'Autres fiches', NULL); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (4, 'Banque', 51); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (5, 'Prêt > a un an', 27); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (5, 'Prêt > a un an', 27); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (8, 'Fournisseurs', 400); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (6, 'Prêt < a un an', NULL); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (6, 'Prêt < a un an', NULL); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (16, 'Contact', NULL); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (1, 'Vente Service', 706); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (2, 'Achat Marchandises', 603); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (9, 'Clients', 410); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (10, 'Salaire Administrateur', 644); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (11, 'Salaire Ouvrier', 641); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (12, 'Salaire Employé', 641); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (7, 'Matériel à amortir, immobilisation corporelle', 21); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (12, 'Salaire Employé', 641); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (7, 'Matériel à amortir, immobilisation corporelle', 21); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (3, 'Achat Service et biens divers', 61); -INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (17, 'Escomptes accordées', 66); +INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (17, 'Escomptes accordées', 66); INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (18, 'Produits Financiers', 76); @@ -983,10 +983,10 @@ INSERT INTO fiche_def_ref (frd_id, frd_text, frd_class_base) VALUES (18, 'Produi INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000398, 3000000, 1, 'Prestation [ case 03 ]', '[700%]-[7000005]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000399, 3000000, 2, 'Prestation intra [ case 47 ]', '[7000005]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000400, 3000000, 3, 'Tva due [case 54]', '[4513]+[4512]+[4511] FROM=01.2005'); -INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); +INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000402, 3000000, 7, 'Service et bien divers [case 82]', '[61%]'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000403, 3000000, 8, 'bien d''invest [ case 83 ]', '[2400%]'); -INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); +INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000405, 3000000, 8, 'TVA non ded -> voiture', '[610022]*0.21/2'); INSERT INTO form (fo_id, fo_fr_id, fo_pos, fo_label, fo_formula) VALUES (3000406, 3000000, 9, 'Acompte TVA', '[4117]'); @@ -1002,7 +1002,7 @@ INSERT INTO format_csv_banque (name, include_file) VALUES ('Dexia', 'dexia_be.in -INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); +INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); @@ -1550,12 +1550,12 @@ INSERT INTO jnt_fic_attr (fd_id, ad_id, jnt_id) VALUES (4, 24, 52); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (2, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (4, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (1, 'Nouvelle', 'Création d''une facture', 'user_jrn.php', 'action=insert_vente&blank', 'FR', 'VEN'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (10, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'ACH'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (4, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'VEN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (1, 'Nouvelle', 'Création d''une facture', 'user_jrn.php', 'action=insert_vente&blank', 'FR', 'VEN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (10, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'ACH'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (12, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'ACH'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (14, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'ACH'); -INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (20, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'FIN'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (14, 'Voir Impayés', 'Voir toutes les factures non payées', 'user_jrn.php', 'action=voir_jrn_non_paye', 'FR', 'ACH'); +INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (20, 'Nouveau', 'Encode un nouvel achat (matériel, marchandises, services et biens divers)', 'user_jrn.php', 'action=new&blank', 'FR', 'FIN'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (22, 'Voir', 'Voir toutes les factures', 'user_jrn.php', 'action=voir_jrn', 'FR', 'FIN'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (40, 'Soldes', 'Voir les soldes des comptes en banques', 'user_jrn.php', 'action=solde', 'FR', 'FIN'); INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_jrn_type) VALUES (30, 'Nouveau', NULL, 'user_jrn.php', 'action=new&blank', 'FR', 'ODS'); @@ -1563,9 +1563,9 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_ -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (3, 'Achat', '6*', '4*', '5', '4', 1, 3, true, 'échéance', 'ACH', 'ACH-01'); -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (2, 'Vente', '4*', '7*', '2', '6', 2, 1, true, 'échéance', 'VEN', 'VEN-01'); -INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (4, 'Opération Diverses', NULL, NULL, NULL, NULL, 5, 5, false, NULL, 'ODS', 'OD-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (3, 'Achat', '6*', '4*', '5', '4', 1, 3, true, 'échéance', 'ACH', 'ACH-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (2, 'Vente', '4*', '7*', '2', '6', 2, 1, true, 'échéance', 'VEN', 'VEN-01'); +INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (4, 'Opération Diverses', NULL, NULL, NULL, NULL, 5, 5, false, NULL, 'ODS', 'OD-01'); INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_cred, jrn_def_fiche_deb, jrn_def_fiche_cred, jrn_deb_max_line, jrn_cred_max_line, jrn_def_ech, jrn_def_ech_lib, jrn_def_type, jrn_def_code) VALUES (1, 'Financier', '5*', '5*', '3,2,4,5', '3,2,4,5', 5, 5, false, NULL, 'FIN', 'FIN-01'); @@ -1575,7 +1575,7 @@ INSERT INTO jrn_def (jrn_def_id, jrn_def_name, jrn_def_class_deb, jrn_def_class_ INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('VEN', 'Vente'); INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ACH', 'Achat'); -INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses'); +INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses'); INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('FIN', 'Banque'); @@ -1606,11 +1606,11 @@ INSERT INTO parameter (pr_id, pr_value) VALUES ('MY_COUNTRY', 'FR'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('BANQUE', '51', 'Poste comptable par défaut pour les banques'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CAISSE', '53', 'Poste comptable par défaut pour les caisses'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CUSTOMER', '410', 'Poste comptable par défaut pour les clients'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VENTE', '707', 'Poste comptable par défaut pour les ventes'); -INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VIREMENT_INTERNE', '58', 'Poste comptable par défaut pour les virements internes'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('BANQUE', '51', 'Poste comptable par défaut pour les banques'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CAISSE', '53', 'Poste comptable par défaut pour les caisses'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('CUSTOMER', '410', 'Poste comptable par défaut pour les clients'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VENTE', '707', 'Poste comptable par défaut pour les ventes'); +INSERT INTO parm_code (p_code, p_value, p_comment) VALUES ('VIREMENT_INTERNE', '58', 'Poste comptable par défaut pour les virements internes'); @@ -1651,22 +1651,22 @@ INSERT INTO parm_periode (p_id, p_start, p_end, p_exercice, p_closed, p_central) INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1, 'comptes de capitaux', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (101, 'Capital', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (105, 'Ecarts de réévaluation', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1061, 'Réserve légale', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1063, 'Réserves statutaires ou contractuelles', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1064, 'Réserves réglementées', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1068, 'Autres réserves', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (105, 'Ecarts de réévaluation', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1061, 'Réserve légale', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1063, 'Réserves statutaires ou contractuelles', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1064, 'Réserves réglementées', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (1068, 'Autres réserves', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (108, 'Compte de l''exploitant', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (12, 'résultat de l''exercice (bénéfice ou perte)', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (145, 'Amortissements dérogatoires', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (146, 'Provision spéciale de réévaluation', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (147, 'Plus-values réinvesties', 1); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (148, 'Autres provisions réglementées', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (12, 'résultat de l''exercice (bénéfice ou perte)', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (145, 'Amortissements dérogatoires', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (146, 'Provision spéciale de réévaluation', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (147, 'Plus-values réinvesties', 1); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (148, 'Autres provisions réglementées', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (15, 'Provisions pour risques et charges', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (16, 'emprunts et dettes assimilees', 1); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (2, 'comptes d''immobilisations', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (20, 'immobilisations incorporelles', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (201, 'Frais d''établissement', 20); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (201, 'Frais d''établissement', 20); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (206, 'Droit au bail', 20); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (207, 'Fonds commercial', 20); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (208, 'Autres immobilisations incorporelles', 20); @@ -1675,144 +1675,144 @@ INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (23, 'immobilisat INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (27, 'autres immobilisations financieres', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (280, 'Amortissements des immobilisations incorporelles', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (281, 'Amortissements des immobilisations corporelles', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (290, 'Provisions pour dépréciation des immobilisations incorporelles', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (291, 'Provisions pour dépréciation des immobilisations corporelles (même ventilation que celle du compte 21)', 2); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (297, 'Provisions pour dépréciation des autres immobilisations financières', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (290, 'Provisions pour dépréciation des immobilisations incorporelles', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (291, 'Provisions pour dépréciation des immobilisations corporelles (même ventilation que celle du compte 21)', 2); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (297, 'Provisions pour dépréciation des autres immobilisations financières', 2); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (3, 'comptes de stocks et en cours', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (31, 'matieres premières (et fournitures)', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (31, 'matieres premières (et fournitures)', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (32, 'autres approvisionnements', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (33, 'en-cours de production de biens', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (34, 'en-cours de production de services', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (35, 'stocks de produits', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (37, 'stocks de marchandises', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (391, 'Provisions pour dépréciation des matières premières (et fournitures)', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (392, 'Provisions pour dépréciation des autres approvisionnements', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (393, 'Provisions pour dépréciation des en-cours de production de biens', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (394, 'Provisions pour dépréciation des en-cours de production de services', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (395, 'Provisions pour dépréciation des stocks de produits', 3); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (397, 'Provisions pour dépréciation des stocks de marchandises', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (391, 'Provisions pour dépréciation des matières premières (et fournitures)', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (392, 'Provisions pour dépréciation des autres approvisionnements', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (393, 'Provisions pour dépréciation des en-cours de production de biens', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (394, 'Provisions pour dépréciation des en-cours de production de services', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (395, 'Provisions pour dépréciation des stocks de produits', 3); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (397, 'Provisions pour dépréciation des stocks de marchandises', 3); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4, 'comptes de tiers', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (400, 'Fournisseurs et Comptes rattachés', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (409, 'Fournisseurs débiteurs', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (410, 'Clients et Comptes rattachés', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (419, 'Clients créditeurs', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (421, 'Personnel - Rémunérations dues', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (428, 'Personnel - Charges à payer et produits à recevoir', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43, 'Sécurité sociale et autres organismes sociaux', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (431, 'Sécurité sociale', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43731, 'Cotis.Sal.+Pat. Retraite salariés dûes', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43732, 'Cotis.Sal.+Pat. Retraite cadres dûes', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4374, 'Cotis.Sal.+Pat. ASSEDIC dûes', 43); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (444, 'Etat - Impôts sur les bénéfices', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (400, 'Fournisseurs et Comptes rattachés', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (409, 'Fournisseurs débiteurs', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (410, 'Clients et Comptes rattachés', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (419, 'Clients créditeurs', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (421, 'Personnel - Rémunérations dues', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (428, 'Personnel - Charges à payer et produits à recevoir', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43, 'Sécurité sociale et autres organismes sociaux', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (431, 'Sécurité sociale', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43731, 'Cotis.Sal.+Pat. Retraite salariés dûes', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (43732, 'Cotis.Sal.+Pat. Retraite cadres dûes', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (4374, 'Cotis.Sal.+Pat. ASSEDIC dûes', 43); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (444, 'Etat - Impôts sur les bénéfices', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445, 'Etat - Taxes sur le chiffre d''affaires', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44562, 'T.V.A. sur immobilisations', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445661, 'T.V.A. déductible 19,6% sur autres biens et services', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445662, 'T.V.A. déductible 5,5% sur autres biens et services', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445663, 'T.V.A. déductible 2,1% sur autres biens et services', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44571, 'T.V.A. collectée 19,6%', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44572, 'T.V.A. collectée 5,5%', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44573, 'T.V.A. collectée 2,1%', 445); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (447, 'Autres impôts, taxes et versements assimilés', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445661, 'T.V.A. déductible 19,6% sur autres biens et services', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445662, 'T.V.A. déductible 5,5% sur autres biens et services', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (445663, 'T.V.A. déductible 2,1% sur autres biens et services', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44571, 'T.V.A. collectée 19,6%', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44572, 'T.V.A. collectée 5,5%', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (44573, 'T.V.A. collectée 2,1%', 445); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (447, 'Autres impôts, taxes et versements assimilés', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (45, 'Groupe et associes', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (455, 'Associés - Comptes courants', 45); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (46, 'Débiteurs divers et créditeurs divers', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (455, 'Associés - Comptes courants', 45); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (46, 'Débiteurs divers et créditeurs divers', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (47, 'comptes transitoires ou d''attente', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (481, 'Charges à répartir sur plusieurs exercices', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (486, 'Charges constatées d''avance', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (487, 'Produits constatés d''avance', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (491, 'Provisions pour dépréciation des comptes de clients', 4); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (496, 'Provisions pour dépréciation des comptes de débiteurs divers', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (481, 'Charges à répartir sur plusieurs exercices', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (486, 'Charges constatées d''avance', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (487, 'Produits constatés d''avance', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (491, 'Provisions pour dépréciation des comptes de clients', 4); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (496, 'Provisions pour dépréciation des comptes de débiteurs divers', 4); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (5, 'comptes financiers', 0); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (50, 'valeurs mobilières de placement', 5); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (51, 'banques, établissements financiers et assimilés', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (50, 'valeurs mobilières de placement', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (51, 'banques, établissements financiers et assimilés', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (53, 'Caisse', 5); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (54, 'régies d''avance et accréditifs', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (54, 'régies d''avance et accréditifs', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (58, 'virements internes', 5); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (590, 'Provisions pour dépréciation des valeurs mobilières de placement', 5); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (590, 'Provisions pour dépréciation des valeurs mobilières de placement', 5); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6, 'comptes de charges', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (60, 'Achats (sauf 603)', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (607, 'Achats de marchandises', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (603, 'variations des stocks (approvisionnements et marchandises)', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6031, 'Variation des stocks de matières premières (et fournitures)', 603); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6031, 'Variation des stocks de matières premières (et fournitures)', 603); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6032, 'Variation des stocks des autres approvisionnements', 603); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6037, 'Variation des stocks de marchandises', 603); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (61, 'autres charges externes - Services extérieurs', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (62, 'autres charges externes - Autres services extérieurs', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (63, 'Impôts, taxes et versements assimiles', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (641, 'Rémunérations du personnel', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (644, 'Rémunération du travail de l''exploitant', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6451, 'Cotisations à l''URSSAF', 645); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (61, 'autres charges externes - Services extérieurs', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (62, 'autres charges externes - Autres services extérieurs', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (63, 'Impôts, taxes et versements assimiles', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (641, 'Rémunérations du personnel', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (644, 'Rémunération du travail de l''exploitant', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6451, 'Cotisations à l''URSSAF', 645); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6453, 'Cotisations aux caisses de retraites', 645); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6454, 'Cotisations aux ASSEDIC', 645); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (646, 'Cotisations sociales personnelles de l''exploitant', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (65, 'Autres charges de gestion courante', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (66, 'Charges financières', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (66, 'Charges financières', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (67, 'Charges exceptionnelles', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (681, 'Dotations aux amortissements et aux provisions - Charges d''exploitation', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6811, 'Dotations aux amortissements sur immobilisations incorporelles et corporelles', 681); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6815, 'Dotations aux provisions pour risques et charges d''exploitation', 681); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6816, 'Dotations aux provisions pour dépréciation des immobilisations incorporelles et corporelles', 681); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6817, 'Dotations aux provisions pour dépréciation des actifs circulants', 681); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (686, 'Dotations aux amortissements et aux provisions - Charges financières', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6816, 'Dotations aux provisions pour dépréciation des immobilisations incorporelles et corporelles', 681); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (6817, 'Dotations aux provisions pour dépréciation des actifs circulants', 681); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (686, 'Dotations aux amortissements et aux provisions - Charges financières', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (687, 'Dotations aux amortissements et aux provisions - Charges exceptionnelles', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (691, 'Participation des salariés aux résultats', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (695, 'Impôts sur les bénéfices', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (697, 'Imposition forfaitaire annuelle des sociétés', 6); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (699, 'Produits - Reports en arrière des déficits', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (691, 'Participation des salariés aux résultats', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (695, 'Impôts sur les bénéfices', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (697, 'Imposition forfaitaire annuelle des sociétés', 6); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (699, 'Produits - Reports en arrière des déficits', 6); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (7, 'comptes de produits', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (701, 'Ventes de produits finis', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (706, 'Prestations de services', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (707, 'Ventes de marchandises', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (708, 'Produits des activités annexes', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (709, 'Rabais, remises et ristournes accordés par l''entreprise', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (708, 'Produits des activités annexes', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (709, 'Rabais, remises et ristournes accordés par l''entreprise', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (713, 'Variation des stocks (en-cours de production, produits)', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (72, 'Production immobilisée', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (72, 'Production immobilisée', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (74, 'Subventions d''exploitation', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (75, 'Autres produits de gestion courante', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (753, 'Jetons de présence et rémunérations d''administrateurs, gérants,...', 75); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (754, 'Ristournes perçues des coopératives (provenant des excédents)', 75); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (755, 'Quotes-parts de résultat sur opérations faites en commun', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (753, 'Jetons de présence et rémunérations d''administrateurs, gérants,...', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (754, 'Ristournes perçues des coopératives (provenant des excédents)', 75); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (755, 'Quotes-parts de résultat sur opérations faites en commun', 75); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (76, 'Produits financiers', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (77, 'Produits exceptionnels', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (781, 'Reprises sur amortissements et provisions (à inscrire dans les produits d''exploitation)', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (786, 'Reprises sur provisions pour risques (à inscrire dans les produits financiers)', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (787, 'Reprises sur provisions (à inscrire dans les produits exceptionnels)', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (781, 'Reprises sur amortissements et provisions (à inscrire dans les produits d''exploitation)', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (786, 'Reprises sur provisions pour risques (à inscrire dans les produits financiers)', 7); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (787, 'Reprises sur provisions (à inscrire dans les produits exceptionnels)', 7); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (79, 'Transferts de charges', 7); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8, 'Comptes spéciaux', 0); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8, 'Comptes spéciaux', 0); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80, 'Engagements hors bilan', 8); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (801, 'Engagements donnés par l''entité', 80); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (801, 'Engagements donnés par l''entité', 80); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8011, 'Avals, cautions, garanties', 801); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8014, 'Effets circulant sous l''endos de l''entité', 801); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8016, 'Redevances crédit-bail restant à courir', 801); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80161, 'Crédit-bail mobilier', 8016); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80165, 'Crédit-bail immobilier', 8016); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8018, 'Autres engagements donnés', 801); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (802, 'Engagements reçus par l''entité', 80); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8014, 'Effets circulant sous l''endos de l''entité', 801); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8016, 'Redevances crédit-bail restant à courir', 801); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80161, 'Crédit-bail mobilier', 8016); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80165, 'Crédit-bail immobilier', 8016); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8018, 'Autres engagements donnés', 801); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (802, 'Engagements reçus par l''entité', 80); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8021, 'Avals, cautions, garanties', 802); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8024, 'Créances escomptées non échues', 802); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8026, 'Engagements reçus pour utilisation en crédit-bail', 802); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80261, 'Crédit-bail mobilier', 8026); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80265, 'Crédit-bail immobilier', 8026); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8028, 'Autres engagements reçus', 802); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8024, 'Créances escomptées non échues', 802); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8026, 'Engagements reçus pour utilisation en crédit-bail', 802); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80261, 'Crédit-bail mobilier', 8026); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (80265, 'Crédit-bail immobilier', 8026); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8028, 'Autres engagements reçus', 802); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (809, 'Contrepartie des engagements', 80); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8091, 'Contrepartie 801', 809); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (8092, 'Contrepartie 802', 809); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (88, 'Résultat en instance d''affectation', 8); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (88, 'Résultat en instance d''affectation', 8); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (89, 'Bilan', 8); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (890, 'Bilan d''ouverture', 89); -INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (891, 'Bilan de clôture', 89); +INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (891, 'Bilan de clôture', 89); INSERT INTO tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) VALUES (9, 'Comptes hors Compta', 0); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (101, 'TVAFranceNormal', 0.1960, 'TVA 19,6% - France métropolitaine - Taux normal', '445661,44571'); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (102, 'TVAFranceRéduit', 0.0550, 'TVA 5,5% - France métropolitaine - Taux réduit', '445662,44572'); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (103, 'TVAFranceSuperRéduit', 0.0210, 'TVA 2,1% - France métropolitaine - Taux super réduit', '445663,44573'); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (104, 'TVAFranceImmos', 0.1960, 'TVA 19,6% - France métropolitaine - Taux immobilisations', '44562,0'); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (105, 'TVAFranceAnciens', 0.0000, 'TVA x% - France métropolitaine - Taux anciens', '445,445'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (101, 'TVAFranceNormal', 0.1960, 'TVA 19,6% - France métropolitaine - Taux normal', '445661,44571'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (102, 'TVAFranceRéduit', 0.0550, 'TVA 5,5% - France métropolitaine - Taux réduit', '445662,44572'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (103, 'TVAFranceSuperRéduit', 0.0210, 'TVA 2,1% - France métropolitaine - Taux super réduit', '445663,44573'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (104, 'TVAFranceImmos', 0.1960, 'TVA 19,6% - France métropolitaine - Taux immobilisations', '44562,0'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (105, 'TVAFranceAnciens', 0.0000, 'TVA x% - France métropolitaine - Taux anciens', '445,445'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (201, 'TVADomNormal', 0.0850, 'TVA 8,5% - DOM - Taux normal', '445,445'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (202, 'TVADomNPR', 0.0850, 'TVA 8,5% - DOM - Taux normal NPR', '445,445'); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (203, 'TVADomRéduit', 0.0210, 'TVA 2,1% - DOM - Taux réduit', '445,445'); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (203, 'TVADomRéduit', 0.0210, 'TVA 2,1% - DOM - Taux réduit', '445,445'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (204, 'TVADom-I', 0.0175, 'TVA 1,75% - DOM - Taux I', '445,445'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (205, 'TVADomPresse', 0.0105, 'TVA 1,05% - DOM - Taux publications de presse', '445,445'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (206, 'TVADomOctroi', 0.0000, 'TVA x% - DOM - Taux octroi de mer', '445,445'); @@ -1826,7 +1826,7 @@ INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUE INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (402, 'TVAacquisIntracomImmos', 0.0000, 'TVA x% - Acquisitions intracommunautaires immobilisations/Pays', '445,0'); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (501, 'TVAfranchise', 0.0000, 'TVA x% - Non imposable : Achats en franchise', ''); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (502, 'TVAexport', 0.0000, 'TVA x% - Non imposable : Exports hors CE/Pays', ''); -INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (503, 'TVAautres', 0.0000, 'TVA x% - Non imposable : Autres opérations', ''); +INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (503, 'TVAautres', 0.0000, 'TVA x% - Non imposable : Autres opérations', ''); INSERT INTO tva_rate (tva_id, tva_label, tva_rate, tva_comment, tva_poste) VALUES (504, 'TVAlivrIntracom', 0.0000, 'TVA x% - Non imposable : Livraisons intracommunautaires/Pays', ''); diff --git a/html/admin/sql/patch/ac-upgrade8.sql b/html/admin/sql/patch/ac-upgrade8.sql new file mode 100644 index 000000000..a6f14c70e --- /dev/null +++ b/html/admin/sql/patch/ac-upgrade8.sql @@ -0,0 +1,6 @@ +begin; +update modeledef set mod_desc='Comptabilité Belge, à adapter' where mod_id=1; +update modeledef set mod_desc='Comptabilité Française, à adapter' where mod_id=2; +update version set val=9; +commit; + diff --git a/html/admin/sql/patch/downgrade7.sql b/html/admin/sql/patch/downgrade7.sql index 0e42b50ae..ce05a2c79 100644 --- a/html/admin/sql/patch/downgrade7.sql +++ b/html/admin/sql/patch/downgrade7.sql @@ -1,6 +1,6 @@ begin; -insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); +insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); update fiche_def_ref set frd_class_base=2400 where frd_id=7; diff --git a/html/admin/sql/patch/upgrade11.sql b/html/admin/sql/patch/upgrade11.sql index 3b0e806f1..ce2e89bb9 100644 --- a/html/admin/sql/patch/upgrade11.sql +++ b/html/admin/sql/patch/upgrade11.sql @@ -6,15 +6,15 @@ create table parm_code ( p_comment text ); -INSERT INTO parm_code VALUES ('DNA', '6740', 'Dépense non déductible'); +INSERT INTO parm_code VALUES ('DNA', '6740', 'Dépense non déductible'); INSERT INTO parm_code VALUES ('CUSTOMER', '400', 'Poste comptable de base pour les clients'); -INSERT INTO parm_code VALUES ('COMPTE_TVA', '451', 'TVA à payer'); +INSERT INTO parm_code VALUES ('COMPTE_TVA', '451', 'TVA à payer'); INSERT INTO parm_code VALUES ('BANQUE', '550', 'Poste comptable de base pour les banques'); INSERT INTO parm_code VALUES ('VIREMENT_INTERNE', '58', 'Poste Comptable pour les virements internes'); INSERT INTO parm_code VALUES ('COMPTE_COURANT', '56', 'Poste comptable pour le compte courant'); INSERT INTO parm_code VALUES ('CAISSE', '57', 'Poste comptable pour la caisse'); -INSERT INTO parm_code VALUES ('TVA_DNA', '6740', 'Tva non déductible s'); -INSERT INTO parm_code VALUES ('TVA_DED_IMPOT', '619000', 'Tva déductible par l''impôt'); +INSERT INTO parm_code VALUES ('TVA_DNA', '6740', 'Tva non déductible s'); +INSERT INTO parm_code VALUES ('TVA_DED_IMPOT', '619000', 'Tva déductible par l''impôt'); INSERT INTO parm_code VALUES ('VENTE ', '70', 'Poste comptable de base pour les ventes'); -- Function: tva_delete(p_tva_id int4) diff --git a/html/admin/sql/patch/upgrade13.sql b/html/admin/sql/patch/upgrade13.sql index 906b53b9f..9a3343d98 100644 --- a/html/admin/sql/patch/upgrade13.sql +++ b/html/admin/sql/patch/upgrade13.sql @@ -366,7 +366,7 @@ language plpgsql ; delete from form where fo_fr_id=3000000; delete from formdef where fr_id=3000000; -INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); +INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA déclaration Belge'); -- -- Data for TOC entry 2 (OID 315304) -- Name: formdef; Type: TABLE DATA; Schema: public; Owner: dany @@ -376,10 +376,10 @@ INSERT INTO formdef (fr_id, fr_label) VALUES (3000000, 'TVA d INSERT INTO form VALUES (3000398, 3000000, 1, 'Prestation [ case 03 ]', '[700%]-[7000005]'); INSERT INTO form VALUES (3000399, 3000000, 2, 'Prestation intra [ case 47 ]', '[7000005]'); INSERT INTO form VALUES (3000400, 3000000, 3, 'Tva due [case 54]', '[4513]+[4512]+[4511] FROM=01.2005'); -INSERT INTO form VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); +INSERT INTO form VALUES (3000401, 3000000, 4, 'Marchandises, matière première et auxiliaire [case 81 ]', '[60%]'); INSERT INTO form VALUES (3000402, 3000000, 7, 'Service et bien divers [case 82]', '[61%]'); INSERT INTO form VALUES (3000403, 3000000, 8, 'bien d''invest [ case 83 ]', '[2400%]'); -INSERT INTO form VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); +INSERT INTO form VALUES (3000404, 3000000, 9, 'TVA déductible [ case 59 ]', 'abs([4117]-[411%])'); INSERT INTO form VALUES (3000405, 3000000, 8, 'TVA non ded -> voiture', '[610022]*0.21/2'); INSERT INTO form VALUES (3000406, 3000000, 9, 'Acompte TVA', '[4117]'); @@ -414,10 +414,10 @@ COMMENT ON TABLE document_state IS 'State of the document'; SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('document_state', 's_id'), 3, true); -INSERT INTO document_state VALUES (1, 'Envoyé'); +INSERT INTO document_state VALUES (1, 'Envoyé'); INSERT INTO document_state VALUES (2, 'Brouillon'); INSERT INTO document_state VALUES (3, 'A envoyer'); -INSERT INTO document_state VALUES (4, 'Reçu'); +INSERT INTO document_state VALUES (4, 'Reçu'); ALTER TABLE ONLY document_state ADD CONSTRAINT document_state_pkey PRIMARY KEY (s_id); alter sequence s_attr_def restart with 24; @@ -453,7 +453,7 @@ comment on table action_gestion is 'Action for Managing'; alter sequence s_fiche_def_ref restart 16; insert into fiche_def_ref(frd_text) values ('Contact'); -insert into attr_def(ad_text) values ('Société'); +insert into attr_def(ad_text) values ('Société'); insert into attr_def(ad_text) values ('Fax'); insert into attr_min values(16,1); insert into attr_min values(16,17); diff --git a/html/admin/sql/patch/upgrade14.sql b/html/admin/sql/patch/upgrade14.sql index 5b899e2ba..b880124e0 100644 --- a/html/admin/sql/patch/upgrade14.sql +++ b/html/admin/sql/patch/upgrade14.sql @@ -24,7 +24,7 @@ alter table import_tmp add constraint chk_status check (status in ('n','w','d', alter table import_tmp drop column ok ; comment on table import_tmp is 'Table temporaire pour l''importation des banques en format CSV'; -comment on column import_tmp.status is 'Status doit être w pour en attente, t pour transfèrer ou d à effacer'; +comment on column import_tmp.status is 'Status doit être w pour en attente, t pour transfèrer ou d à effacer'; create or replace function trim_cvs_quote() returns trigger as $trim$ diff --git a/html/admin/sql/patch/upgrade28.sql b/html/admin/sql/patch/upgrade28.sql index 88d8a6c2d..950b8956c 100644 --- a/html/admin/sql/patch/upgrade28.sql +++ b/html/admin/sql/patch/upgrade28.sql @@ -5,10 +5,10 @@ delete from action where ac_id=9; delete from action where ac_id=19; delete from action where ac_id=18; update action set ac_description='Lecture du Grand-Livre' where ac_id=1; -insert into action values (31,'Gestion des périodes comptables'); +insert into action values (31,'Gestion des périodes comptables'); update action set ac_description = 'Lecture des fiches' where ac_id=3; update action set ac_description = 'Ajout de fiche et modification' where ac_id=15; -update action set ac_description = 'Création et modifications des rapports' where ac_id=5; +update action set ac_description = 'Création et modifications des rapports' where ac_id=5; update version set val=29; commit; \ No newline at end of file diff --git a/html/admin/sql/patch/upgrade31.sql b/html/admin/sql/patch/upgrade31.sql index 1faaa37f4..38345b2d5 100644 --- a/html/admin/sql/patch/upgrade31.sql +++ b/html/admin/sql/patch/upgrade31.sql @@ -219,7 +219,6 @@ CREATE TABLE poste_analytique ( ); -ALTER TABLE public.poste_analytique OWNER TO phpcompta; -- -- Name: TABLE poste_analytique; Type: COMMENT; Schema: public; Owner: phpcompta @@ -285,7 +284,6 @@ CREATE TABLE operation_analytique ( ); -ALTER TABLE public.operation_analytique OWNER TO phpcompta; -- -- Name: TABLE operation_analytique; Type: COMMENT; Schema: public; Owner: phpcompta @@ -392,7 +390,6 @@ CREATE TABLE bilan ( ); -ALTER TABLE public.bilan OWNER TO phpcompta; -- -- Name: TABLE bilan; Type: COMMENT; Schema: public; Owner: phpcompta @@ -498,7 +495,6 @@ CREATE TABLE op_predef ( ); -ALTER TABLE public.op_predef OWNER TO phpcompta; -- -- Name: TABLE op_predef; Type: COMMENT; Schema: public; Owner: phpcompta @@ -576,7 +572,6 @@ CREATE TABLE op_predef_detail ( ); -ALTER TABLE public.op_predef_detail OWNER TO phpcompta; -- -- Name: TABLE op_predef_detail; Type: COMMENT; Schema: public; Owner: phpcompta diff --git a/html/admin/sql/patch/upgrade36.FR.sql b/html/admin/sql/patch/upgrade36.FR.sql index 0201dfd50..a557b0815 100644 --- a/html/admin/sql/patch/upgrade36.FR.sql +++ b/html/admin/sql/patch/upgrade36.FR.sql @@ -2,7 +2,7 @@ -- PostgreSQL database dump -- -SET client_encoding = 'LATIN1'; +SET client_encoding = 'utf8'; SET standard_conforming_strings = off; SET check_function_bodies = false; SET client_min_messages = warning; diff --git a/html/admin/sql/patch/upgrade36.sql b/html/admin/sql/patch/upgrade36.sql index 9c2ef8200..82e2f3a5d 100644 --- a/html/admin/sql/patch/upgrade36.sql +++ b/html/admin/sql/patch/upgrade36.sql @@ -221,7 +221,6 @@ CREATE SEQUENCE bud_card_bc_id_seq CACHE 1; -ALTER TABLE public.bud_card_bc_id_seq OWNER TO phpcompta; -- -- Name: bc_id; Type: DEFAULT; Schema: public; Owner: phpcompta @@ -265,7 +264,6 @@ CREATE TABLE bud_detail ( ); -ALTER TABLE public.bud_detail OWNER TO phpcompta; -- -- Name: TABLE bud_detail; Type: COMMENT; Schema: public; Owner: phpcompta @@ -313,7 +311,6 @@ CREATE SEQUENCE bud_detail_bd_id_seq CACHE 1; -ALTER TABLE public.bud_detail_bd_id_seq OWNER TO phpcompta; -- @@ -374,7 +371,6 @@ CREATE TABLE bud_detail_periode ( ); -ALTER TABLE public.bud_detail_periode OWNER TO phpcompta; -- -- Name: TABLE bud_detail_periode; Type: COMMENT; Schema: public; Owner: phpcompta @@ -409,7 +405,6 @@ CREATE SEQUENCE bud_detail_periode_bdp_id_seq CACHE 1; -ALTER TABLE public.bud_detail_periode_bdp_id_seq OWNER TO phpcompta; -- -- Name: bdp_id; Type: DEFAULT; Schema: public; Owner: phpcompta @@ -470,7 +465,6 @@ NEW.bc_code:=sCode; return NEW; end;$BODY$ LANGUAGE 'plpgsql' VOLATILE; -ALTER FUNCTION bud_card_ins_upd() OWNER TO phpcompta; -- -- Name: t_bud_card_ins_up; Type: TRIGGER; Schema: public; Owner: phpcompta diff --git a/html/admin/sql/patch/upgrade4.sql b/html/admin/sql/patch/upgrade4.sql index fa8fd8ffc..3d76a1c06 100644 --- a/html/admin/sql/patch/upgrade4.sql +++ b/html/admin/sql/patch/upgrade4.sql @@ -20,7 +20,7 @@ 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 tmp_pcmn is 'Plan comptable minimum normalisé'; comment on table tva_rate is 'Rate of vat'; create sequence s_central; @@ -52,7 +52,7 @@ alter table jrn add jr_pj_type text; delete from user_sec_act WHERE ua_act_id =14; delete from action where ac_id=14; insert into action values (18,'Devise'); -insert into action values (19,'Période'); +insert into action values (19,'Période'); insert into action values (20,'Voir la balance des comptes'); -- task 3374 diff --git a/html/admin/sql/patch/upgrade40.sql b/html/admin/sql/patch/upgrade40.sql index 47ec42da4..d0edf6b95 100644 --- a/html/admin/sql/patch/upgrade40.sql +++ b/html/admin/sql/patch/upgrade40.sql @@ -1,7 +1,7 @@ begin; insert into parm_code values ('DEP_PRIV',4890,'Depense a charge du gerant'); -insert into attr_def values (31,'Depense à charge du gérant (partie privée)'); +insert into attr_def values (31,'Depense à  charge du gérant (partie privée)'); alter table quant_purchase add qp_dep_priv numeric(20,4) default 0.0; CREATE FUNCTION insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric,p_dep_priv numeric , p_client character varying) RETURNS void diff --git a/html/admin/sql/patch/upgrade48.sql b/html/admin/sql/patch/upgrade48.sql new file mode 100644 index 000000000..039a7bcaa --- /dev/null +++ b/html/admin/sql/patch/upgrade48.sql @@ -0,0 +1,71 @@ +begin; +create sequence s_tva start with 1000; + alter table tva_rate alter tva_id set default nextval('s_tva'); + alter table form drop constraint "$1"; + alter table form add constraint formdef_fk foreign key (fo_fr_id) references formdef(fr_id) on update cascade on delete cascade; +drop function tva_insert(integer,text,numeric,text,text); + +CREATE or replace FUNCTION tva_insert( text, numeric, text, text) +RETURNS integer + AS $_$ +declare +l_tva_id integer; +p_tva_label alias for $1; +p_tva_rate alias for $2; +p_tva_comment alias for $3; +p_tva_poste alias for $4; +debit text; +credit text; +nCount integer; +begin +if length(trim(p_tva_label)) = 0 then + return 3; +end if; + +if length(trim(p_tva_poste)) != 0 then + if position (',' in p_tva_poste) = 0 then return 4; end if; + debit = split_part(p_tva_poste,',',1); + credit = split_part(p_tva_poste,',',2); + select count(*) into nCount from tmp_pcmn where pcm_val=debit; + if nCount = 0 then return 4; end if; + select count(*) into nCount from tmp_pcmn where pcm_val=credit; + if nCount = 0 then return 4; end if; + +end if; +select into l_tva_id nextval('s_tva') ; +insert into tva_rate(tva_id,tva_label,tva_rate,tva_comment,tva_poste) + values (l_tva_id,p_tva_label,p_tva_rate,p_tva_comment,p_tva_poste); +return 0; +end; +$_$ + LANGUAGE plpgsql; + +CREATE TABLE todo_list ( + tl_id integer NOT NULL, + tl_date date NOT NULL, + tl_title text NOT NULL, + tl_desc text, + use_login text NOT NULL +); + + +COMMENT ON TABLE todo_list IS 'Todo list'; + + +CREATE SEQUENCE todo_list_tl_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; + + +ALTER TABLE todo_list ALTER COLUMN tl_id SET DEFAULT nextval('todo_list_tl_id_seq'::regclass); + + +ALTER TABLE ONLY todo_list ADD CONSTRAINT todo_list_pkey PRIMARY KEY (tl_id); + +update version set val=49; + +commit; + diff --git a/html/admin/sql/patch/upgrade49.sql b/html/admin/sql/patch/upgrade49.sql new file mode 100644 index 000000000..d3aa7ca19 --- /dev/null +++ b/html/admin/sql/patch/upgrade49.sql @@ -0,0 +1,23 @@ +begin; +alter table jnt_fic_attr add column jnt_order int; +update jnt_fic_attr set jnt_order = 1; +alter table jnt_fic_attr alter jnt_order set not null; +update jnt_fic_attr set jnt_order = 4 where ad_id=5; +update jnt_fic_attr set jnt_order = 120 where ad_id=6; +update jnt_fic_attr set jnt_order = 130 where ad_id=7; +update jnt_fic_attr set jnt_order = 20 where ad_id=9; +update jnt_fic_attr set jnt_order = 30 where ad_id=13; +update jnt_fic_attr set jnt_order = 40 where ad_id=14; +update jnt_fic_attr set jnt_order = 70 where ad_id=16; +update jnt_fic_attr set jnt_order = 80 where ad_id=17; +update jnt_fic_attr set jnt_order = 90 where ad_id=18; +update jnt_fic_attr set jnt_order = 400 where ad_id=23; +update jnt_fic_attr set jnt_order = 60 where ad_id=24; +update jnt_fic_attr set jnt_order = 100 where ad_id=26; +update jnt_fic_attr set jnt_order = 110 where ad_id=27; +update jnt_fic_attr set jnt_order = 50 where ad_id=15; +update jnt_fic_attr set jnt_order = 30 where ad_id=5; +update jnt_fic_attr set jnt_order = 0 where ad_id=1; + +update version set val=50; +commit; diff --git a/html/admin/sql/patch/upgrade50.sql b/html/admin/sql/patch/upgrade50.sql new file mode 100644 index 000000000..f2af255d6 --- /dev/null +++ b/html/admin/sql/patch/upgrade50.sql @@ -0,0 +1,57 @@ +begin; + +CREATE OR REPLACE FUNCTION insert_jrnx(p_date character varying, p_montant numeric, p_poste poste_comptable, p_grpt integer, p_jrn_def integer, p_debit boolean, p_tech_user text, p_tech_per integer, p_qcode text) + RETURNS void AS +$BODY$ +declare + sCode varchar; + nCount_qcode integer; +begin + sCode=trim(p_qcode); + + -- if p_qcode is empty try to find one + if length(sCode) = 0 or p_qcode is null then + + select count(*) into nCount_qcode + from vw_poste_qcode where j_poste=p_poste::text; + -- if we find only one q_code for a accountancy account + -- then retrieve it + if nCount_qcode = 1 then + select j_qcode::text into sCode + from vw_poste_qcode where j_poste=p_poste::text; + else + sCode=NULL; + end if; + + end if; + + insert into jrnx + ( + j_date, + j_montant, + j_poste, + j_grpt, + j_jrn_def, + j_debit, + j_tech_user, + j_tech_per, + j_qcode + ) values + ( + to_date(p_date,'DD.MM.YYYY'), + p_montant, + p_poste, + p_grpt, + p_jrn_def, + p_debit, + p_tech_user, + p_tech_per, + sCode + ); + +return; +end; +$BODY$ + LANGUAGE 'plpgsql' VOLATILE; +update version set val=51; +commit; diff --git a/html/admin/sql/patch/upgrade6.sql b/html/admin/sql/patch/upgrade6.sql index ea425e650..be19a83bd 100644 --- a/html/admin/sql/patch/upgrade6.sql +++ b/html/admin/sql/patch/upgrade6.sql @@ -1,7 +1,7 @@ begin; --make sure that p_start < p_end ALTER TABLE parm_periode ADD CHECK (p_end >= p_start); -insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); +insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); update version set val=7; diff --git a/html/admin/sql/patch/upgrade7.sql b/html/admin/sql/patch/upgrade7.sql index cfbbefb17..7580a3376 100644 --- a/html/admin/sql/patch/upgrade7.sql +++ b/html/admin/sql/patch/upgrade7.sql @@ -1,6 +1,6 @@ begin; -insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); +insert into tva_rate values (5,'0%',0, 'Pas soumis à la TVA',null); update fiche_def_ref set frd_class_base=2400 where frd_id=7; diff --git a/html/admin/sql/patch/upgrade8.sql b/html/admin/sql/patch/upgrade8.sql index 447d4685a..c78a2765b 100644 --- a/html/admin/sql/patch/upgrade8.sql +++ b/html/admin/sql/patch/upgrade8.sql @@ -1,6 +1,6 @@ begin; -insert into action values (21,'Import et export des écritures d''ouverture'); +insert into action values (21,'Import et export des écritures d''ouverture'); create sequence s_quantity; @@ -100,11 +100,11 @@ $trim$ language plpgsql; create trigger trim_quote before insert or update on import_tmp FOR EACH ROW execute procedure trim_cvs_quote(); alter sequence s_attr_def restart 20; -insert into attr_def(ad_text) values ('Partie fiscalement non déductible'); -insert into attr_def(ad_text) values ('TVA non déductible'); -insert into attr_def(ad_text) values ('TVA non déductible récupérable par l''impôt'); -insert into tmp_pcmn( pcm_val,pcm_lib,pcm_val_parent,pcm_country) select distinct 6190,'TVA récupérable par l''impôt',61,'BE' from tmp_pcmn where pcm_country='BE'; -insert into tmp_pcmn( pcm_val,pcm_lib,pcm_val_parent,pcm_country) select distinct 6740,'Dépense non admise',67,'BE' from tmp_pcmn where pcm_country='BE' and not exists (select pcm_val from tmp_pcmn where pcm_val=6740); +insert into attr_def(ad_text) values ('Partie fiscalement non déductible'); +insert into attr_def(ad_text) values ('TVA non déductible'); +insert into attr_def(ad_text) values ('TVA non déductible récupérable par l''impôt'); +insert into tmp_pcmn( pcm_val,pcm_lib,pcm_val_parent,pcm_country) select distinct 6190,'TVA récupérable par l''impôt',61,'BE' from tmp_pcmn where pcm_country='BE'; +insert into tmp_pcmn( pcm_val,pcm_lib,pcm_val_parent,pcm_country) select distinct 6740,'Dépense non admise',67,'BE' from tmp_pcmn where pcm_country='BE' and not exists (select pcm_val from tmp_pcmn where pcm_val=6740); -- Change for Stan alter table tmp_pcmn alter pcm_val type text; update version set val=9; diff --git a/html/admin/test.php b/html/admin/test.php index 3fae38ace..1596a7d4d 100644 --- a/html/admin/test.php +++ b/html/admin/test.php @@ -36,7 +36,7 @@ include_once("ac_common.php"); include_once("postgres.php"); require_once ('class_dossier.php'); if ( ! file_exists('authorized_debug') ) { -echo "Pour pouvoir utiliser ce fichier vous devez créer un fichier nomme authorized_debug +echo "Pour pouvoir utiliser ce fichier vous devez créer un fichier nomme authorized_debug dans le repertoire html du server"; exit(); diff --git a/html/admin/test_me.php b/html/admin/test_me.php index 7ac9a7601..1301b464f 100644 --- a/html/admin/test_me.php +++ b/html/admin/test_me.php @@ -74,10 +74,10 @@ $b=$a->GetRow('1','9999','off'); -echo 'class_jrn il y a '.count($b[0]).' données trouvée
'; +echo 'class_jrn il y a '.count($b[0]).' données trouvée
'; $b=$a->GetRow('1','9999','on'); -echo 'Class_jrn il y a '.sizeof($b[0]).' données Centralisees trouvée
'; +echo 'Class_jrn il y a '.sizeof($b[0]).' données Centralisees trouvée
'; echo '

$a->GetRowSimple

'; $per_from=67;$per_to=70;$jrn=3; $c=0; @@ -99,7 +99,7 @@ foreach ($b as $line) { echo '
'; } -echo "Il y a $c données trouvées par GetRowSimple "; +echo "Il y a $c données trouvées par GetRowSimple "; $s=sql_filter_per($cn,$per_from,$per_to,'p_id','jr_tech_per'); $count_rowS=GetArray($cn,"select count(*) as mcount from jrn where $s and jr_def_id=$jrn"); if ( $c != $count_rowS[0]['mcount'] ) { @@ -138,11 +138,11 @@ echo '

Poste->GetRow

'; $a=new poste($cn,4511); // grand livre $b=$a->GetRow('1','9999'); -echo 'class_poste il y a '.sizeof($b[0]).' données trouvée
'; +echo 'class_poste il y a '.sizeof($b[0]).' données trouvée
'; $a=new Balance($cn,4519); // grand livre $b=$a->GetRow('1','9999'); -echo 'class_balance il y a '.sizeof($b).' données trouvée
'; +echo 'class_balance il y a '.sizeof($b).' données trouvée
'; echo_debug('Testing echo_debug'); echo_error('Testing echo_error'); diff --git a/html/admin_repo.php b/html/admin_repo.php index c4cf9249c..a467b2712 100644 --- a/html/admin_repo.php +++ b/html/admin_repo.php @@ -51,29 +51,33 @@ echo "
".MenuAdmin()."
"; ?>
diff --git a/html/ajax_report.php b/html/ajax_report.php new file mode 100644 index 000000000..a846acccd --- /dev/null +++ b/html/ajax_report.php @@ -0,0 +1,68 @@ +export($file); + fclose ($file); + $name=dirname($_SERVER['REQUEST_URI']).DIRECTORY_SEPARATOR.$name; + + $a='{"answer":"ok","link":"'.$name.'"}'; + +} + else + $a='{"answer":"nok"}'; +echo_debug("fid.php",__LINE__,"Answer is \n $a"); +header("Content-type: text/html; charset: utf8",true); +print $a; +?> diff --git a/html/annulation.php b/html/annulation.php index eb17c3acb..b146dc652 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -136,7 +136,7 @@ if ($p_id != -1 ) { // A if ( $p_id != -1 ) { //B // Test whether date of the operation is in a closed periode // get the period_id - $p=ExecSql($cn,"select jr_tech_per from jrn where jr_grpt_id=".$_REQUEST['jrn_op']); + $p=ExecSqlParam($cn,"select jr_tech_per from jrn where jr_grpt_id=$1",array($_REQUEST['jrn_op'])); $period_id=pg_fetch_result($p,0,0); // thanks jrn_op (jrn.jr_id) we find out the concerned ledger @@ -171,7 +171,7 @@ if ($p_id != -1 ) { // A from jrn where jr_grpt_id=".$_POST['p_id']; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -187,7 +187,7 @@ if ($p_id != -1 ) { // A from jrnx where j_grpt=".$_POST['p_id']; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -196,7 +196,7 @@ if ($p_id != -1 ) { // A // Mark the operation invalid into the ledger // to avoid to nullify twice the same op. $sql="update jrn set jr_comment='Annule : '||jr_comment where jr_grpt_id=".$_POST['p_id']; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -206,16 +206,16 @@ if ($p_id != -1 ) { // A $Res=ExecSql($cn,"update quant_sold set ". - " qs_valid='A' where qs_internal='".$l_array['jr_internal']."'", - false); + " qs_valid='A' where qs_internal='".$l_array['jr_internal']."'" + ); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); $Res=ExecSql($cn,"update quant_purchase set ". - " qp_valid='A' where qp_internal='".$l_array['jr_internal']."'", - false); + " qp_valid='A' where qp_internal='".$l_array['jr_internal']."'" + ); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -235,7 +235,7 @@ if ($p_id != -1 ) { // A // also in the stock table $sql="delete from stock_goods where sg_id = any ( select sg_id from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")"; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -284,7 +284,7 @@ self.opener.RefreshMe(); // delete from the rapt table $sql="delete from jrn_rapt where jr_id = any (select jr_id from jrn ". " where jr_grpt_id = ".$_POST['p_id'].")"; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -292,16 +292,16 @@ self.opener.RefreshMe(); $Res=ExecSql($cn,"delete from quant_sold ". - " where qs_internal='".$l_array['jr_internal']."'", - false); + " where qs_internal='".$l_array['jr_internal']."'" + ); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); $Res=ExecSql($cn,"delete from quant_purchase ". - " where qp_internal='".$l_array['jr_internal']."'", - false); + " where qp_internal='".$l_array['jr_internal']."'" + ); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); @@ -318,27 +318,27 @@ self.opener.RefreshMe(); // delete from the stock table $sql="delete from stock_goods where sg_id = any ( select sg_id from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")"; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); // delete from CA $sql="delete from operation_analytique where j_id in (select j_id from"; $sql.=" jrnx where j_grpt=".$_POST['p_id'].")"; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); // delete from jrnx & jrn $sql="delete from jrnx where j_grpt=".$_POST['p_id']; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); if ( $Res == false) throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]")); // build the sql stmt for jrn $sql= "delete from jrn where jr_grpt_id=".$_POST['p_id']; - $Res=ExecSql($cn,$sql,false); + $Res=ExecSql($cn,$sql); if ( $Res == false) throw (new Exception(__FILE__.__LINE__." sql a echoue [ $sql ]")); diff --git a/html/backup.php b/html/backup.php new file mode 100644 index 000000000..fa6f31319 --- /dev/null +++ b/html/backup.php @@ -0,0 +1,75 @@ +Check(); + + +if ($User->admin != 1) { + echo ""; + return; +} + +/*!\file + * \brief Make and restore backup + */ +if ( isset ($_REQUEST['sa']) ) { + if ( ! isset ($_REQUEST['d']) || + ! isset($_REQUEST['t'])) + { + echo "Erreur : paramètre manquant "; + exit(); + } + + $sa=$_REQUEST['sa']; + // backup + if ( $sa=='b') { + $cmd=escapeshellcmd (PG_DUMP); + putenv("PGPASSWORD=".phpcompta_password); + putenv("PGUSER=".phpcompta_user); + + if ( $_REQUEST['t'] == 'd' ) { + $database=domaine."dossier".$_REQUEST['d']; + $args= " -Fc -Z9 -p ".phpcompta_psql_port." ".$database; + header('Content-type: application/octet'); + header('Content-Disposition:attachment;filename="'.$database.'.bin"',FALSE); + + passthru ($cmd.$args,$a); + + } + + if ( $_REQUEST['t'] == 'm' ) { + $database=domaine."mod".$_REQUEST['d']; + $args= " -Fc -Z9 -p ".phpcompta_psql_port." ".$database; + header('Content-type: bin/x-application'); + header('Content-Disposition: attachment;filename="'.$database.'.bin"',FALSE); + $a=passthru ($cmd.$args); + } + } + } + diff --git a/html/bal_csv.php b/html/bal_csv.php index 3d7569ece..f6bd2eed0 100644 --- a/html/bal_csv.php +++ b/html/bal_csv.php @@ -47,7 +47,7 @@ $t_cent=""; //$per=join(',',$periode); if ( isset($_POST['central']) ) { $bal->central='Y'; - $t_cent="centralisée"; + $t_cent="centralisée"; } else $bal->central='N'; diff --git a/html/bud_ajax.php b/html/bud_ajax.php index 940179eac..afe5d214b 100644 --- a/html/bud_ajax.php +++ b/html/bud_ajax.php @@ -41,7 +41,7 @@ if ( $_POST['action'] == 'delete') { $obj->bd_id=$bd_id; $obj->delete_by_bd_id(); } - header("Content-type: application/json charset=\"ISO8859-1\"",true); + header("Content-type: application/json charset=\"utf8\"",true); echo '{"bd_id":"0","form_id":"'.$form_id.'"}'; } @@ -60,7 +60,7 @@ if ( $_POST['action'] == 'save' ) { $obj->update(); } - header("Content-type: application/json charset=\"ISO8859-1\"",true); + header("Content-type: application/json charset=\"utf8\"",true); echo '{"bd_id":"'.$obj->bd_id.'","form_id":"'.$form_id.'"}'; } diff --git a/html/bud_search_poste.php b/html/bud_search_poste.php index ff2ca8398..8623b90f1 100644 --- a/html/bud_search_poste.php +++ b/html/bud_search_poste.php @@ -79,7 +79,7 @@ echo ''; echo ''; -echo ''; +echo ''; echo ''; if ( ! isset ($p_comment) ) $p_comment=""; echo ''; diff --git a/html/commercial.php b/html/commercial.php index 4a8f1b689..f77cc44a6 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -79,16 +79,17 @@ $p_action=(isset ($_REQUEST['p_action']))?$_REQUEST['p_action']:""; echo '
'; echo ShowItem(array( array('?p_action=client&'.$str_dossier,'Client'), - array('?p_action=facture&'.$str_dossier,'Vente/Facture'), + array('?p_action=ven&'.$str_dossier,'Vente/Facture'), array('?p_action=fournisseur&'.$str_dossier,'Fournisseur'), - array('?p_action=depense&'.$str_dossier,'Achat/Dépense'), + array('?p_action=ach&'.$str_dossier,'Achat/Dépense'), + array('?p_action=bank&'.$str_dossier,'Banque'), array('?p_action=quick_writing&'.$str_dossier,'Ecriture directe'), array('?p_action=impress&'.$str_dossier,'Impression'), array('?p_action=stock&'.$str_dossier,'Stock'), - array('?p_action=bank&'.$str_dossier,'Banque'), array('?p_action=fiche&'.$str_dossier,'Fiche'), array('?p_action=periode&'.$str_dossier,'Ferm. Periode'), array('?p_action=central&'.$str_dossier,'Centralisation'), + array('?p_action=defreport&'.$str_dossier,'Rapport'), array('?p_action=contact&'.$str_dossier,'Contact'), array('?p_action=suivi_courrier&'.$str_dossier,'Suivi Courrier'), ), @@ -111,6 +112,7 @@ if ( $p_action == "pref" ) { require_once("pref.inc.php"); } + //----------------------------------------------------- // p_action == client //----------------------------------------------------- @@ -124,6 +126,7 @@ if ( $p_action == 'fournisseur') { require_once("supplier.inc.php"); } + //----------------------------------------------------- // action if ( $p_action == 'suivi_courrier') @@ -133,9 +136,9 @@ if ( $p_action == 'suivi_courrier') //----------------------------------------------------- // p_action == facture //----------------------------------------------------- -if ( $p_action == "facture" ) +if ( $p_action == "ven" ) { - require_once("facture.inc.php"); + require_once("compta_ven.inc.php"); } //----------------------------------------------------- // Contact @@ -145,15 +148,16 @@ if ( $p_action == 'contact') } //----------------------------------------------------- // Expense -if ( $p_action == 'depense') +if ( $p_action == 'ach') { - require_once("depense.inc.php"); + require_once("compta_ach.inc.php"); } + //----------------------------------------------------- // Banque if ( $p_action == 'bank') { - require_once("bank.inc.php"); + require_once("compta_fin.inc.php"); } if ( $p_action=='quick_writing') { require_once ('quick_writing.inc.php'); @@ -183,3 +187,9 @@ if ( $p_action=='periode') { if ( $p_action=='central') { require_once ('central.inc.php'); } +//----------------------------------------------------- +// Expense +if ( $p_action == 'defreport') +{ + require_once("report.inc.php"); +} diff --git a/html/compta.php b/html/compta.php index e9244e620..9dd59e5b8 100644 --- a/html/compta.php +++ b/html/compta.php @@ -21,12 +21,31 @@ /* $Revision$ */ /*! \file - * \brief Main page for the printing + * \brief Main page for accountancy */ require_once('class_dossier.php'); $gDossier=dossier::id(); include_once ("ac_common.php"); -html_page_start($_SESSION['g_theme']); +$action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:''; +$use_html=1; +//---------------------------------------------------------------------- +/*!\todo find a way to improve performance : the calendar must not + * always be loaded and takes at least 50KB + */ +if ( $action == 'ven' && ! isset ($_REQUEST['sa']) ) + $use_html=1; + +if ( ! isset ($_SESSION['g_theme'])) { + echo '

Vous êtes déconnecté

'; + exit(); +} +if ( $action == 'ven' && isset ($_REQUEST['sa']) && in_array($_REQUEST['sa'],array('n','p') )) + $use_html=1; +if ( $use_html == 1) + html_page_start($_SESSION['g_theme']); +else + html_min_page_start($_SESSION['g_theme']); +//---------------------------------------------------------------------- include_once ("postgres.php"); @@ -41,7 +60,7 @@ $User->Check(); require_once ("check_priv.php"); include_once ("user_menu.php"); echo '
'; -$action=$_REQUEST['p_action']; + echo ShowMenuCompta("user_advanced.php?".dossier::get()); echo '
'; @@ -56,6 +75,7 @@ if ( $action == 'impress' ) { require_once('impress.inc.php'); } + if ( $action == 'fiche') { require_once('fiche.inc.php'); @@ -67,5 +87,20 @@ if ( $action == 'stock') { if ( $action=='quick_writing') { require_once ('quick_writing.inc.php'); } +if ( $action == 'gl' ) { + require_once ('user_action_gl.php'); + } +if ( $action == 'ven' || + $action == 'client') { + require_once ('compta_ven.inc.php'); + } +if ( $action == 'ach' || + $action == 'fournisseur') { + require_once ('compta_ach.inc.php'); + } +if ( $action == 'bank') { + require_once ('compta_fin.inc.php'); + } + html_page_stop(); ?> diff --git a/html/compute.php b/html/compute.php new file mode 100644 index 000000000..c02d8b4d3 --- /dev/null +++ b/html/compute.php @@ -0,0 +1,67 @@ +set_parameter('id',$t); +$tva_rate->load(); + +$total=new Acc_Compute(); +bcscale(4); +$amount=bcmul($p,$q); +$total->set_parameter('amount',$amount); +$total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); +$total->compute_vat(); +$tvac=bcadd($total->get_parameter('amount_vat'),$amount); +header("Content-type: text/html; charset: utf8",true); +echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; +?> + diff --git a/html/confirm_remove.php b/html/confirm_remove.php index ecd3beb19..6c1a85143 100644 --- a/html/confirm_remove.php +++ b/html/confirm_remove.php @@ -36,7 +36,7 @@ html_page_start($User->theme,'onLoad="window.focus();"'); $User->Check(); if ($User->admin != 1) { -print "

Désolé mais vous n' êtes pas administrateur

"; +print "

Désolé mais vous n' êtes pas administrateur

"; html_page_stop(); return; @@ -46,9 +46,9 @@ if ( ! isset ($_REQUEST['p_type'] ) || ! isset ($_REQUEST['ob_id'])) { print '

'; - print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres"; + print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres"; print '

'; - print '
'; + print '
'; return; } $cn=DbConnect(); @@ -61,31 +61,31 @@ switch($_REQUEST['p_type']) if ( strlen(trim($name)) == 0 ) { echo "

$msg inexistant

"; - print '
'; + print '
'; return; } break; case 'mod': - $msg="modèle"; + $msg="modèle"; $name=getDbValue($cn,"select mod_name from modeledef where mod_id=".$_REQUEST['ob_id']); if ( strlen(trim($name)) == 0 ) { echo "

$msg inexistant

"; - print '
'; + print '
'; return; } if ( $_REQUEST['ob_id'] < 3 ) { - echo "

Désolé mais vous ne pouvez pas effacer les modèles de base

"; - print '
'; + echo "

Désolé mais vous ne pouvez pas effacer les modèles de base

"; + print '
'; return; } break; default: print '

'; - print "Désolé mais que voulez-vous effacer ? "; + print "Désolé mais que voulez-vous effacer ? "; print '

'; - print '
'; + print '
'; return; } @@ -106,17 +106,17 @@ if ( isset($_POST['remove']) ) ob_end_clean(); echo "

- Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; - print '
'; + Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord"; + print '
'; exit; } ob_flush(); $sql="delete from modeledef where mod_id=".$_POST['ob_id']; ExecSql($cn,$sql); print '

'; - print "Voilà le modèle $name est effacé"; + print "Voilà le modèle $name est effacé"; print "

"; - print '
'; + print '
'; break; case 'db': $sql="drop database ".domaine."dossier".$_POST['ob_id']; @@ -125,8 +125,8 @@ if ( isset($_POST['remove']) ) ob_end_clean(); echo "

- Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; - print '
'; + Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord"; + print '
'; exit; } ob_flush(); @@ -137,20 +137,20 @@ if ( isset($_POST['remove']) ) $sql="delete from ac_dossier where dos_id=".$_REQUEST['ob_id']; ExecSql($cn,$sql); print '

'; - print "Voilà le modèle $name est effacé"; + print "Voilà le modèle $name est effacé"; print "

"; - print '
'; + print '
'; } } else { print '

'; - print "$msg $name n'est pas effacé"; + print "$msg $name n'est pas effacé"; print '

'; print "
"; - print "Vous n'avez pas coché la case"; - print '
'; + print "Vous n'avez pas coché la case"; + print '
'; } } diff --git a/html/control.php b/html/control.php index c51b93601..131c4907b 100644 --- a/html/control.php +++ b/html/control.php @@ -60,6 +60,12 @@ switch ($m) { case 'pref': get_redirect('user_pref.php?'.dossier::get().$phpsessid); break; + case 'home': + get_redirect('user_login.php'.$phpsessid); + break; + case 'access': + get_redirect('access.php?'.dossier::get().$phpsessid); + break; case 'logout': get_redirect('logout.php'); diff --git a/html/ecrit_ouv.php b/html/ecrit_ouv.php deleted file mode 100644 index f25530930..000000000 --- a/html/ecrit_ouv.php +++ /dev/null @@ -1,199 +0,0 @@ -Check(); - -include_once ("check_priv.php"); - -include_once ("user_menu.php"); -echo '
'; -echo ShowMenuCompta("user_advanced.php?".dossier::get()); -echo '
'; -// \todo add a check for permission - - -echo ShowMenuAdvanced(8); - -$User->can_request($cn,EXP_IMP_ECR); - - -echo ''; -echo '
'; -//----------------------------------------------------- -//EXPORT -//////////////////////////////////////////// -if ( isset ($_GET['export'])) { - // if the year is not set, ask it - // ask the exercice and do the export - $periode=make_array($cn,"select distinct p_exercice,p_exercice from parm_periode order by p_exercice"); - echo '
'; - $w=new widget('select'); - $w->table=0; - $w->label='Periode'; - $w->readonly=false; - $w->value=$periode; - $w->name="p_periode"; - echo 'Période : '.$w->IOValue(); - echo widget::submit('export','Export'); - echo dossier::hidden(); - echo ""; - exit(0); -} -//----------------------------------------------------- IMPORT -//////////////////////////////////////////// -if ( isset ($_GET['import'])) { - // show a form to upload the file - // that form will parse the file, create an ods operation - // and ask you to validate it - // if no file is given - if ( ! isset ($_REQUEST['p_submit']) ) { -?> -
-name='p_jrn'; - $x->value=$ods; - echo "Choississez votre journal ".$x->IOValue(); - - $w=new widget("file"); - $w->name='import_file'; - $w->label='p_file'; - echo $w->IOValue(); - echo widget::submit('p_submit','Charger le fichier'); -?> - -'; - $end=true; - continue; - } - if ( $end ) { - echo $line."
"; - continue; - } - // check if the first line contains the signature - if ( $valid ) - { - // skip blank line - if (strlen (trim($line)) == 0 ) continue; - // put the line into several array with the same index - echo_debug('ecrit_ouv',__LINE__," line $line"); - list($sign,$poste,$label,$amount)=explode(";",$line); - $asign[$idx]=$sign; $aposte[$idx]=$poste;$aamount[$idx]=$amount; - $alabel[$idx]=$label; - $idx++; - } - else - { - $valid = strpos($line, "OUVERTURE") !== false; - - } - } // read the file - // if valid is still false then there is nothing to do - if ( ! $valid) { echo 'Aucun enregistrement valide'; return ;} - // compose the array for the function FormODS - $array_ods['e_comm']='Ecriture d\'ouverture'; - for ($i=0;$i<$idx;$i++) { - $n="e_account$i"; - $array_ods[$n]=$aposte[$i]; - $n="e_account".$i."_type"; - $array_ods[$n]=$asign[$i]; - $n="e_account".$i."_amount"; - $array_ods[$n]=$aamount[$i]; - } - // Check if all the poste exist - // otherwise create it - for ($i=0;$i<$idx;$i++) - { - - $p=new Acc_Account_Ledger($cn,$aposte[$i]); - - // if the poste exists then check the next one - if ( $p->load() == true ) continue; - echo 'Attention creation de '.$p->id.' '.$alabel[$i].'
'; - $sql=sprintf("select account_add(%d,'%s')", - $p->id,$alabel[$i]); - - ExecSql($cn,$sql); - } - - // submit button in the form - $submit=' - '; - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit, - $array_ods,false,$idx,$p_saved=false); - - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - - } - } - } // else -> a file is given - }// if import -// IF import and export are not set then the choice is proposed -echo '
'; -html_page_stop(); -?> diff --git a/html/export_ouv.php b/html/export_ouv.php index 66457121c..88b68e956 100644 --- a/html/export_ouv.php +++ b/html/export_ouv.php @@ -45,7 +45,7 @@ $cn=DbConnect($gDossier); $User->can_request($cn,EXP_IMP_ECR); if ( !isset ($_GET['p_periode'])) { - echo 'Erreur : aucune periode demandée'; + echo 'Erreur : aucune periode demandée'; exit(0); } $sql_from=get_array($cn,"select min(p_id) from parm_periode where p_exercice=".$_GET['p_periode']); @@ -59,7 +59,7 @@ $ret=get_array($cn,"select distinct j_poste::text j_tech_per <= ".$sql_to[0]['max']." and j_poste::text not like '7%' and j_poste::text not like '6%' order by j_poste::text"); -if ( $ret == null ) {echo 'Rien à exporter'; exit();} +if ( $ret == null ) {echo 'Rien à exporter'; exit();} printf ("OUVERTURE\n"); // check if the account are balanced $sum=0; diff --git a/html/fiche.php b/html/fiche.php index 21bf7e636..8edf75989 100644 --- a/html/fiche.php +++ b/html/fiche.php @@ -98,7 +98,7 @@ $r=""; if ( isset ($_POST["add_line"]) ) { $r= '
'; if ( $write ==0) - $r.= "

Pas d'accès

"; + $r.= "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); @@ -114,7 +114,7 @@ if ( isset ($_POST["add_line"]) ) { if ( isset ($_POST["change_name"] ) ) { $r= '
'; if ( $write ==0) - $r.= "

Pas d'accès

"; + $r.= "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); @@ -150,7 +150,7 @@ if ( isset ( $_GET["action"]) ) { $t=false; if ( $write == 0) { - echo '

Vos changements ne seront pas sauvés

'; + echo '

Vos changements ne seront pas sauvés

'; $t=true; } $str=""; @@ -196,7 +196,7 @@ if ( isset ( $_GET["action"]) ) { if ($action == "modifier" ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { @@ -228,7 +228,7 @@ if ( isset ( $_GET["action"]) ) { if ( sizeof($all) != 0 ) { echo '
'; - echo "Nombre de résultat : ".sizeof($all).'
'; + echo "Nombre de résultat : ".sizeof($all).'
'; foreach ($all as $f_id){ $fiche=new fiche($cn,$f_id['f_id']); echo 'IOValue('search_text',$search_text); echo widget::submit('submit','Rechercher'); echo ''; - echo "Aucun résultat trouvé"; + echo "Aucun résultat trouvé"; echo '
'; @@ -259,7 +259,7 @@ if ( isset ( $_GET["action"]) ) { if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $url=$_SERVER['REQUEST_URI']; @@ -282,7 +282,7 @@ if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) ) { if (isset($_POST['delete']) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche=new fiche($cn,$_POST["f_id"]); @@ -300,7 +300,7 @@ if ( isset ($_POST["add_fiche"]) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche=new fiche($cn); @@ -318,7 +318,7 @@ if ( isset ($_POST["add_fiche"]) ) { if ( isset ($_POST["update_fiche"]) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche=new fiche($cn,$_POST['f_id']); diff --git a/html/fiche_new.php b/html/fiche_new.php index 709a60043..e23dff71f 100644 --- a/html/fiche_new.php +++ b/html/fiche_new.php @@ -15,7 +15,7 @@ * 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 -*/ + */ // Auteur Dany De Bontridder ddebontridder@yahoo.fr include_once ("ac_common.php"); include_once ("postgres.php"); @@ -25,6 +25,10 @@ require_once("class_fiche_def.php"); /*! \file * \brief Create a new card in a popup window + * \note parameter (GET) e_type (deb, cred, filter) if filter is + * specified, you can give a p_jrn parameter, otherwise e_type + * contains a list of value + * */ /* $Revision$ */ @@ -34,7 +38,7 @@ include_once ("class_user.php"); $User=new User($rep); $User->Check(); -html_page_start($User->theme,"onLoad='window.focus();'"); +html_min_page_start($User->theme,"onLoad='window.focus();'"); require_once('class_dossier.php'); $gDossier=dossier::id(); @@ -56,7 +60,7 @@ foreach ($_GET as $key=>$element) { echo_debug('fiche_new.php',__LINE__,"e_$key =$element
"); } - +echo JS_TVA; function new_fiche($p_cn,$p_type) { $fiche=new fiche($p_cn); $r='
'; @@ -69,7 +73,7 @@ function new_fiche($p_cn,$p_type) { $r.= '

'.$fiche_def->label.'
Nouveau

'; $r.= $fiche->blank($p_type); - $r.=''; + $r.=''; $r.=''; return $r; @@ -109,11 +113,11 @@ if ( isset($_POST['add_fiche'])) { } else { // We have to find it from the database if ( $e_type == 'deb' ) { $get='jrn_def_fiche_deb'; - $sql="select $get as fiche from jrn_def where jrn_def_id=".$_GET['p_jrn']; + $sql="select $get as fiche from jrn_def where jrn_def_id=$1"; } if ( $e_type == 'cred' ) { $get='jrn_def_fiche_cred'; - $sql="select $get as fiche from jrn_def where jrn_def_id=".$_GET['p_jrn']; + $sql="select $get as fiche from jrn_def where jrn_def_id=$1"; } if ($e_type=='filter') { @@ -121,13 +125,13 @@ if ( isset($_POST['add_fiche'])) { $get_deb='jrn_def_fiche_deb'; - $sql="select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=".$_GET['p_jrn']; + $sql="select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1"; } - $Res=ExecSql($cn,$sql); + $Res=ExecSqlParam($cn,$sql,array($_GET['p_jrn'])); // fetch it $Max=pg_NumRows($Res); @@ -138,7 +142,7 @@ if ( isset($_POST['add_fiche'])) { // Normally Max must be == 1 $list=pg_fetch_array($Res,0); if ( $list['fiche']=="") { - echo_warning("Journal mal paramètré"); + echo_warning("Journal mal paramètré"); return; } } @@ -165,7 +169,7 @@ if ( isset($_POST['cat'])) { // recharger avec var. cat if ( sizeof($a)>1 and !isset ($_POST['cat'])) { - echo "Choix catégories fiche"; + echo "Choix catégories fiche"; echo '
'; echo dossier::hidden(); foreach ($a as $element) { diff --git a/html/fiche_search.php b/html/fiche_search.php index d9e907382..4e817c104 100644 --- a/html/fiche_search.php +++ b/html/fiche_search.php @@ -31,14 +31,15 @@ $rep=DbConnect(); include_once ("class_user.php"); $User=new User($rep); $User->Check(); - +echo JS_SEARCH_CARD; +echo JS_MINTOOLKIT; //determine focus: if ( isset ( $_GET['search']) ) { - html_page_start($User->theme,"onLoad=\"window.focus();SetFocus('select0',0)\""); + html_min_page_start($User->theme,"onLoad=\"window.focus();SetFocus('select0',0)\""); } else { - html_page_start($User->theme,"onLoad=\"window.focus();SetFocus('fic_search',0)\""); + html_min_page_start($User->theme,"onLoad=\"window.focus();SetFocus('fic_search',0)\""); } @@ -51,7 +52,7 @@ $cn=DbConnect($gDossier); // Get The priv on the selected folder if ( $User->check_action($cn,FICHE_READ) == 0 ){ /* Cannot Access */ - echo '

Vous n\' avez pas accès

'; + echo '

Vous n\' avez pas accès

'; return; } @@ -69,7 +70,7 @@ function get_list_fiche($p_cn,$get,$p_jrn) // Normally Max must be == 1 $list=pg_fetch_array($Res,0); if ( $list['fiche']=="") { - echo_warning("Journal mal paramètré"); + echo_warning("Journal mal paramètré"); exit(); } $list_fiche=$list['fiche']; @@ -79,12 +80,18 @@ function get_list_fiche($p_cn,$get,$p_jrn) javascript=sprintf("NewCard('%s','%s','%s')", + $_REQUEST['PHPSESSID'], + $_GET['type'], + "fic_search"); +$add_card->label="Ajout d'une fiche"; foreach ($_GET as $key=>$element) { // The value are e_name e_type e_PHPSESSID @@ -95,9 +102,11 @@ foreach ($_GET as $key=>$element) { $e_fic_search=(isset ($_REQUEST['fic_search']))?$_REQUEST['fic_search']:""; $r.=""; -$r.="Recherche : ".''; +$r.="Recherche : ".''; $r.=''; - +if ( isset ($_REQUEST['p_jrn'])) + echo widget::hidden('p_jrn',$_REQUEST ['p_jrn']); +echo dossier::hidden(); $r.="
"; echo $r; $r=""; @@ -150,8 +159,7 @@ if ( // if e_type contains a list of value for filtering on fiche_def_ref.frd_id else{ $list_fiche=$e_type; - $sql="select * from vw_fiche_attr where frd_id in ( $list_fiche )"; - // $sql="select * from vw_fiche_attr "; + $sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )"; } // e_fic_search contains the pattern @@ -166,7 +174,8 @@ if ( // Test whether rows are returned if ( ($Max = pg_NumRows($Res) ) == 0 ) { - echo_warning("Pas de fiche trouvée"); + echo_warning("Pas de fiche trouvée"); + echo $add_card->IOValue(); return; } // Show the cards @@ -212,6 +221,6 @@ echo $r; ?> IOValue(); html_page_stop(); ?> diff --git a/html/fid.php b/html/fid.php index 86009af80..41c553b8f 100644 --- a/html/fid.php +++ b/html/fid.php @@ -36,16 +36,16 @@ echo_debug('fid.php',__LINE__,"Recherche fid.php".$_GET["FID"]); $cn=DbConnect($gDossier); if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) { - $d=$_GET['d']; - $jrn=$_GET['j']; + $d=FormatString($_GET['d']); + $jrn=FormatString($_GET['j']); switch ($d) { case 'cred': - $filter_jrn=getDbValue($cn,"select jrn_def_fiche_cred from jrn_def where jrn_def_id=$jrn"); + $filter_jrn=getDbValue($cn,"select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn)); $filter_card="and fd_id in ($filter_jrn)"; break; case 'deb': - $filter_jrn=getDbValue($cn,"select jrn_def_fiche_deb from jrn_def where jrn_def_id=$jrn"); + $filter_jrn=getDbValue($cn,"select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn)); $filter_card="and fd_id in ($filter_jrn)"; break; case 'all': @@ -56,7 +56,7 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) $get_deb='jrn_def_fiche_deb'; - $filter_jrn=getDbValue($cn,"select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$jrn"); + $filter_jrn=getDbValue($cn,"select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_id=$1",array($jrn)); $filter_card="and fd_id in ($filter_jrn)"; break; @@ -64,11 +64,12 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) $filter_card="and frd_id in ($d)"; } - - $array=get_array($cn,"select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id + $sql="select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id from vw_fiche_attr - where quick_code=upper('".$_GET['FID']."') $filter_card" - ); + where quick_code=upper($1)". $filter_card; + + $array=get_array($cn,$sql, array($_GET['FID'])); + echo_debug("fid",__LINE__,$array); $name=$array[0]['vw_name']." ".$array[0]['vw_addr']." ".$array[0]['vw_cp']; $sell=$array[0]['vw_sell'] ; @@ -87,6 +88,6 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) else $a='{"answer":"nok"}'; echo_debug("fid.php",__LINE__,"Answer is \n $a"); -header("Content-type: text/html; charset: ISO8859-1",true); +header("Content-type: text/html; charset: utf8",true); print $a; ?> diff --git a/html/form.php b/html/form.php deleted file mode 100644 index ff537c284..000000000 --- a/html/form.php +++ /dev/null @@ -1,109 +0,0 @@ -Check(); - -include_once("form_inc.php"); - -include_once ("user_menu.php"); -echo '
'; -echo ShowMenuCompta("user_advanced.php?".dossier::get()); -echo '
'; - -include ("check_priv.php"); - -$cn=DbConnect($gDossier); -echo ShowMenuAdvanced(6); -// Get The priv on the selected folder -$User->can_request($cn,FORM); - - - - -if ( isset ($_POST["record"] )) { - // echo '
'; - AddForm($cn,$_POST); - //echo "
"; -} -if ( isset ($_POST["del_form"]) ) { - // echo '
'; - DeleteForm($cn,$_POST['fr_id']); - // echo "
"; -} - -ShowMenuComptaForm(); - -if ( isset( $_REQUEST['PHPSESSID'])) { - $sessid = $_REQUEST['PHPSESSID']; -} - - -if ( isset ($_GET["action"]) ) { - $action=$_GET["action"]; - if ($action == "add" ) - { - echo '
'; - EncodeForm(10,$sessid); - echo "
"; - } - if ($action=="view" ) { - echo '
'; - if ( ! $_GET["fr_id"] ) { - echo_error("fr_id n'est pas donné"); - return; - } - ViewForm($cn,$sessid,$_GET["fr_id"]); - echo "
"; - } -} // if $_GET -if ( isset ($_POST["add_line"]) ) { - echo '
'; - $line=$_POST["line"]; - EncodeForm($line+1,$sessid,$_POST); - echo "
"; -} -if ( isset ($_POST["update"]) ) { - echo '
'; - UpdateForm($cn,$_POST); - ViewForm($cn,$sessid,$_POST["fr_id"]); - - echo "
"; -} - - -//echo "
"; -html_page_stop(); -?> diff --git a/html/form_csv.php b/html/form_csv.php index 1c1c6d725..7bdd974f3 100644 --- a/html/form_csv.php +++ b/html/form_csv.php @@ -24,7 +24,7 @@ include_once("ac_common.php"); include_once ("postgres.php"); include ('class_user.php'); -require_once("class_rapport.php"); +require_once("class_acc_report.php"); require_once("impress_inc.php"); header('Content-type: application/csv'); header('Content-Disposition: attachment;filename="rapport.csv"',FALSE); @@ -39,7 +39,7 @@ $User=new User($cn); $User->Check(); -$Form=new rapport($cn,$_GET['form_id']); +$Form=new Acc_Report($cn,$_GET['form_id']); $Form->get_name(); // Step ? //-- diff --git a/html/form_pdf.php b/html/form_pdf.php index 1e4c9ab8e..f4d01687c 100644 --- a/html/form_pdf.php +++ b/html/form_pdf.php @@ -24,7 +24,7 @@ * \brief Send a report in PDF */ -include_once("class_rapport.php"); +include_once("class_acc_report.php"); include_once("ac_common.php"); include_once("postgres.php"); include_once("class.ezpdf.php"); @@ -32,6 +32,8 @@ include_once("impress_inc.php"); require_once('class_user.php'); require_once ('header_print.php'); require_once('class_dossier.php'); +require_once('class_acc_report.php'); + $gDossier=dossier::id(); $cn=DbConnect($gDossier); @@ -45,7 +47,7 @@ $pdf=new Cezpdf(); $pdf->selectFont('./addon/fonts/Helvetica.afm'); header_pdf($cn,$pdf); -$Form=new rapport($cn,$form_id); +$Form=new Acc_Report($cn,$form_id); // Step ?? //-- if ( $_GET['p_step'] == 0 ) @@ -72,7 +74,7 @@ if ( $_GET['p_step'] == 0 ) } -$Libelle=sprintf("(%s) %s ",$Form->id,$Form->get_name()); +$Libelle=utf8_decode(sprintf("(%s) %s ",$Form->id,$Form->get_name())); $pdf->ezText($Libelle,30); // without step @@ -81,13 +83,14 @@ if ( $_GET['p_step'] == 0 ) if ( $_GET['type_periode'] == 0 ) { $q=getPeriodeName($cn,$from_periode); if ( $from_periode != $to_periode){ - $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode)); + $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode)); } else { - $periode=sprintf("Période %s",$q); + $periode=sprintf("Période %s",$q); } } else { $periode=sprintf("Date %s jusque %s",$_GET['from_date'],$_GET['to_date']); } + $periode=utf8_decode($periode); $pdf->ezText($periode,25); $pdf->ezTable($array, array ('desc'=>'Description', @@ -95,7 +98,7 @@ if ( $_GET['p_step'] == 0 ) ),$Libelle, array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('montant'=> array('justification'=>'right'), - ))); + )),true); //New page //$pdf->ezNewPage(); //} @@ -113,7 +116,7 @@ if ( $_GET['p_step'] == 0 ) ),$Libelle, array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('montant'=> array('justification'=>'right'), - ))); + )),true); } } $pdf->ezStream(); diff --git a/html/get_predef.php b/html/get_predef.php new file mode 100644 index 000000000..3f2fc6315 --- /dev/null +++ b/html/get_predef.php @@ -0,0 +1,64 @@ +set('ledger',$l); +$op->set('ledger_type',$t); +$op->set('direct',$d); +$array=$op->get_operation(); +$string='{"count":"'.count($array).'"'; +$idx=0; +if (! empty($array)) + foreach ($array as $a) { + $string.=',"value'.$idx.'":"'.$a['value'].'",'; + $string.='"label'.$idx.'":"'.$a['label'].'"'; + $idx++; + } +$string.="}"; + +header("Content-type: text/json; charset: utf8",true); +echo $string; + + +?> + diff --git a/html/htaccess.cfg b/html/htaccess.cfg index 93f64799e..efc0742f3 100755 --- a/html/htaccess.cfg +++ b/html/htaccess.cfg @@ -5,5 +5,5 @@ php_value session.save_path c:\temp php_value max_execution_time 240 php_value memory_limit 12M # for php 5 php_value upload_tmp_dir /tmp -AddDefaultCharset latin1 +AddDefaultCharset utf8 diff --git a/html/import.php b/html/import.php index c915ae8a1..d898b8248 100644 --- a/html/import.php +++ b/html/import.php @@ -40,7 +40,7 @@ $User=new User($cn); $User->Check(); html_page_start($User->theme); -echo JS_PROTOTYPE_JS; +echo JS_PROTOTYPE; /* Admin. Dossier */ @@ -89,6 +89,7 @@ if ( isset ($_GET["action"]) ) { if ($action == "transfer" ) { echo '
'; + echo ' Seulement les opérations de la période par défaut (voir préférence) seront transfèrées
'; // TransferCSV($cn, ConfirmTransfert($cn,$User->get_periode()); echo "
"; diff --git a/html/index.php b/html/index.php index cf26b6696..821efb343 100644 --- a/html/index.php +++ b/html/index.php @@ -7,20 +7,20 @@ * * \section intro_sec Introduction * - * Cette partie contient de la documentation pour les développeurs. + * Cette partie contient de la documentation pour les développeurs. * * \section convention_code Convention de codage *

* Quelques conventions de codage pour avoir un code plus ou moins - * homogène + * homogène *

    - *
  1. Tant que possible réutiliser ce qui existe déjà,
  2. - *
  3. Améliorer ce qui existe déjà et vérifier que cela fonctionne toujours
  4. + *
  5. Tant que possible réutiliser ce qui existe déjà,
  6. + *
  7. Améliorer ce qui existe déjà et vérifier que cela fonctionne toujours
  8. *
  9. Documenter avec les tags doxygen votre nouveau code,
  10. - *
  11. Dans le répertoire include: Les noms de fichiers sont *.inc.php pour les fichiers à éxécuter
  12. - *
  13. Dans le répertoire include: Les noms de fichiers sont *.php pour les fichiers contenant des fonctions uniquement
  14. - *
  15. Dans le répertoire include: Les noms de fichier sont class_*.php pour les fichiers contenant des classes.
  16. - *
  17. Utiliser sql/upgrade.sql comme fichier temporaire pour modifier la base de données, en général + *
  18. Dans le répertoire include: Les noms de fichiers sont *.inc.php pour les fichiers à éxécuter
  19. + *
  20. Dans le répertoire include: Les noms de fichiers sont *.php pour les fichiers contenant des fonctions uniquement
  21. + *
  22. Dans le répertoire include: Les noms de fichier sont class_*.php pour les fichiers contenant des classes.
  23. + *
  24. Utiliser sql/upgrade.sql comme fichier temporaire pour modifier la base de données, en général * ce fichier deviendra l'un des patch
  25. *
  26. Faire de la doc
  27. *
@@ -28,24 +28,30 @@ *

* \section conseil Conseils *

- * Utiliser cette documentation, elle est générée automatiquement avec Doxygen, + * Utiliser cette documentation, elle est générée automatiquement avec Doxygen, *

    *
  • Related contient tous les \\todo
  • *
  • Global -> function pour lire toute la doc sur les fonctions
  • - *
  • Regarder dans dossier1.html et account_repository.html pour la doc des base de données + *
  • Regarder dans dossier1.html et account_repository.html pour la doc des base de données *
- * et il ne faut connaître que 7 tags + * et il ne faut connaître que 7 tags *
    - *
  • \\file en début de fichier
  • + *
  • \\file en début de fichier
  • *
  • \\todo ajouter un todo
  • *
  • \\enum pour commenter une variable
  • - *
  • \\param pour commenter le paramètre d'une fonction
  • + *
  • \\param pour commenter le paramètre d'une fonction
  • *
  • \\brief Commentaire du fichier, de la fonction ou de la classe
  • *
  • \\note des notes, des exemples
  • *
  • \\return ce que la fonction retourne
  • *
*/ +if ( ! file_exists('..'.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'config.inc.php')) { + $p_string='admin/setup.php'; + echo ' Connecting... '; + +} + echo ' @@ -75,9 +81,13 @@ BODY { - +'; + + + +echo ' -version 4.0.2 +version 4.1.0

@@ -93,11 +103,11 @@ version 4.0.2
Libellé ou poste comptable Libellé ou poste comptable contient
'; echo ''; echo ''; - +echo '

Nombre de lignes affichées est limité

'; // if request search -if ( isset($_GET['search']) or isset($_GET['filter']) ) { - $Res=ExecSql($cn,"select pcm_val,pcm_lib from tmp_pcmn $condition order by pcm_val::text"); +if ( isset($_GET['search']) || isset($_GET['filter']) ) { + $Res=ExecSql($cn,"select pcm_val,pcm_lib from tmp_pcmn $condition order by pcm_val::text ". + " limit 70"); $MaxLine=pg_NumRows($Res); if ( $MaxLine==0) { html_page_stop(); return; } - echo '
- + - + diff --git a/html/jrn_pdf.php b/html/jrn_pdf.php index a06f99601..5913f5222 100644 --- a/html/jrn_pdf.php +++ b/html/jrn_pdf.php @@ -23,7 +23,10 @@ // $Revision$ /*! \file * \brief Send a ledger in a pdf format - */ + * + *\todo for the pdf, which doesn't support unicode you must + translate all the string to latin-1 with the utf8-decode function +*/ require_once('class_dossier.php'); $gDossier=dossier::id(); @@ -42,10 +45,10 @@ require_once ('header_print.php'); echo_debug('jrn_pdf.php',__LINE__,"imp pdf journaux"); $cn=DbConnect($gDossier); $l_type="JRN"; -$centr=" Non centralisé"; +$centr=" Non centralisé"; $l_centr=0; if ($_GET['central'] == 'on' ) { - $centr=" centralisé "; + $centr=utf8_decode(" centralisé "); $l_centr=1; } $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); @@ -102,44 +105,45 @@ if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='ODS' || $_REQUEST['p_simple $pdf->ezText($Jrn->name,30); if ( $l_centr == 1 ) { - // si centralisé montre les montants de rappel - $str_debit=sprintf( "report Débit % 10.2f",$rap_deb); - $str_credit=sprintf("report Crédit % 10.2f",$rap_cred); + // si centralisé montre les montants de rappel + $str_debit=utf8_decode(sprintf( "report Débit % 10.2f",$rap_deb)); + $str_credit=utf8_decode(sprintf("report Crédit % 10.2f",$rap_cred)); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); } - $pdf->ezTable($a_jrn, - array ('j_id'=>' Numéro', + array ('j_id'=>utf8_decode(' Numéro'), 'j_date' => 'Date', 'poste'=>'Poste', 'description' => 'Description', - 'deb_montant'=> 'Débit', - 'cred_montant'=>'Crédit')," ", + 'deb_montant'=>utf8_decode( 'Débit'), + 'cred_montant'=>utf8_decode('Crédit')), + " ", array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('deb_montant'=> array('justification'=>'right'), - 'cred_montant'=> array('justification'=>'right')))); + 'cred_montant'=> array('justification'=>'right'))), + true); $a=1; // Total Page $apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred)); foreach ($apage as $key=>$element) echo_debug('jrn_pdf.php',__LINE__,"apage $key => $element"); $pdf->ezTable($apage, array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", + 'deb'=>utf8_decode( 'Total Débit'), + 'cred'=>utf8_decode('Total Crédit'))," ", array('shaded'=>0,'showHeadings'=>1,'width'=>200, 'xPos'=>'right','xOrientation'=>'left', 'cols'=>array('deb'=> array('justification'=>'right'), - 'cred'=> array('justification'=>'right')))); + 'cred'=> array('justification'=>'right'))),true); $count=count($a_jrn)-1; $last_id=$a_jrn[$count]['int_j_id']; $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); if ( $l_centr == 1) { - // Montant de rappel si centralisé + // Montant de rappel si centralisé list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$Jrn->id,$Exercice,LAST,$filter,$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); + $str_debit=utf8_decode(sprintf( "à reporter Débit % 10.2f",$rap_deb)); + $str_credit=utf8_decode(sprintf("à reporter Crédit % 10.2f",$rap_cred)); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); } @@ -152,25 +156,25 @@ if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='ODS' || $_REQUEST['p_simple $apage=array('deb'=>$tot_deb,'cred'=>$tot_cred); $pdf->ezTable($apage, array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", + 'deb'=>utf8_decode( 'Total Débit'), + 'cred'=>utf8_decode('Total Crédit'))," ", array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('deb'=> array('justification'=>'right'), - 'cred'=> array('justification'=>'right')))); + 'cred'=> array('justification'=>'right'))),true); $count=count($a_jrn)-1; $last_id=$a_jrn[$count]['int_j_id']; $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$Jrn->id,$Exercice,LAST,$filter,$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); + $str_debit=utf8_decode(sprintf( "à reporter Débit % 10.2f",$rap_deb)); + $str_credit=utf8_deccode(sprintf("à reporter Crédit % 10.2f",$rap_cred)); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); } $pdf->ezStream(); exit(0); -} // impression detaillé +} // impression detaillé //---------------------------------------------------------------------- // Simple Printing //--------------------------------------------------------------------- @@ -196,9 +200,12 @@ if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) $tmp1=$line_tva['tva_label']; $rap_tva[$tmp1]=0.0; if ( $space == 0 ) - $col_tva=str_repeat(" ",6).$line_tva['tva_label']; - else - $col_tva.=str_repeat(" ",$space-strlen($line_tva['tva_label'])).$line_tva['tva_label']; + $col_tva=str_repeat(" ",6).utf8_decode($line_tva['tva_label']); + else { + $ecart=$space-strlen($line_tva['tva_label']); + $ecart=($ecart<0)?0:$ecart; + $col_tva.=str_repeat(" ",$ecart).utf8_decode($line_tva['tva_label']); + } $space=9; } @@ -222,7 +229,7 @@ if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) // page Header $t=sprintf("Rappel TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA); foreach($rap_tva as $idx=>$am) { - $t.=sprintf('[ %s = % .2f]',$idx,$am); + $t.=utf8_decode(sprintf('[ %s = % .2f]',$idx,$am)); } $pdf->ezText($t,9,array('justification'=>'left')); @@ -239,7 +246,7 @@ if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) $pdf->ezTable($a_jrn, - array('num'=>'Numéro', + array('num'=>utf8_decode('Numéro'), 'date'=>'Date', 'client'=>'Client', 'jr_internal'=>'Int.', @@ -247,8 +254,9 @@ if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) 'HTVA'=>'HTVA', 'TVA_INLINE'=>$col_tva, 'TVAC'=>'TVAC'), - $Jrn->name, - array('shaded'=>0,'showHeadings'=>1,'fontSize'=>8,'width'=>750,'Maxwidth'=>750) + utf8_decode($Jrn->name), + array('shaded'=>0,'showHeadings'=>1,'fontSize'=>8,'width'=>750,'Maxwidth'=>750), + true @@ -274,13 +282,13 @@ if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) //total page $t=sprintf("total page TVAC = %.2f HTVA= %.2f",$total_tvac_page,$total_htva_page); foreach($page_tva as $idx=>$am) { - $t.=sprintf('[ %s = % .2f ]',$idx,$am); + $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); } $pdf->ezText($t,9,array('justification'=>'left')); - $t=sprintf("total à reporter TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA); + $t=utf8_decode(sprintf("total à reporter TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA)); foreach($rap_tva as $idx=>$am) { - $t.=sprintf('[ %s = % .2f ]',$idx,$am); + $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); } $pdf->ezText($t,9,array('justification'=>'left')); diff --git a/html/jrn_search.php b/html/jrn_search.php index e6b60f234..f41c917d4 100644 --- a/html/jrn_search.php +++ b/html/jrn_search.php @@ -32,7 +32,7 @@ $User=new User($rep); $User->Check(); -html_page_start($User->theme,"onLoad='window.focus();'"); +html_min_page_start($User->theme,"onLoad='window.focus();'"); require_once('class_dossier.php'); $gDossier=dossier::id(); @@ -144,9 +144,9 @@ echo ""; echo '
Loginutilisateur
Password mot de passe
'; echo ''; -echo ''; +echo ''; echo ''; -echo '
'; +echo '
'; // if a search is asked otherwise don't show all the rows if ( isset ($_GET["search"]) ) { $sql="select j_id,to_char(j_date,'DD.MM.YYYY') as j_date, @@ -184,7 +184,7 @@ echo '
'; echo ''; $l_id=""; // if ( $MaxLine > 250 ) { -// echo "Trop de lignes redéfinir la recherche"; +// echo "Trop de lignes redéfinir la recherche"; // html_page_stop(); // return; // } diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index 79169a78f..e001d9bf6 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -53,21 +53,24 @@ function errorFid(request,json) { * \param p_ctl the ctrl to fill * \param p_deb if debit of credit * \param p_jrn the ledger + * \param phpsessid */ -function ajaxFid(p_ctl,p_deb,p_jrn) +function ajaxFid(p_ctl,p_deb,phpsessid) { var gDossier=$('gDossier').value; - var ctl_value=$(p_ctl).value; + var ctl_value=trim($(p_ctl).value); + $(p_ctl).value=ctl_value; + var p_jrn=$('p_jrn').value; if ( trim(ctl_value)==0 ) { nLabel=p_ctl+"_label"; $(nLabel).value=""; - $(nLabel).innerHTML=""; + $(nLabel).innerHTML=" "; clean_Fid(p_ctl); return; } queryString="?FID="+ctl_value; queryString=queryString+"&d="+p_deb+"&j="+p_jrn+'&gDossier='+gDossier; - queryString=queryString+'&ctl='+p_ctl; + queryString=queryString+'&ctl='+p_ctl+'&PHPSESSID='+phpsessid; /* alert(queryString); */ var action=new Ajax.Request ( "fid.php", @@ -92,9 +95,6 @@ function successFid(request,json) { var buy=answer.buy; var tva_id=answer.tva_id; var ctl=answer.ctl; - -/* alert('data:'+data+' sell:'+sell+' Tva id:'+tva_id); */ - var toSet=ctl+'_label'; if (trim(data) == "" ) { $(toSet).innerHTML="Fiche Inconnue"; @@ -112,7 +112,7 @@ function successFid(request,json) { if ( $(nSell ) ) { $(nSell).value=sell; } - $(nBuy).value=buy; + if ( $(nBuy) ) $(nBuy).value=buy; } } diff --git a/html/js/compute_direct.js b/html/js/compute_direct.js index 69a2652e7..ca98a6d36 100644 --- a/html/js/compute_direct.js +++ b/html/js/compute_direct.js @@ -27,7 +27,7 @@ function checkTotalDirect() { var total_cred=0.0; - var nb_item_id=document.getElementById('nb'); + var nb_item_id=document.getElementById('nb_item'); if ( ! nb_item_id ) {return; } diff --git a/html/js/infobulle.js b/html/js/infobulle.js new file mode 100644 index 000000000..f3937b710 --- /dev/null +++ b/html/js/infobulle.js @@ -0,0 +1,54 @@ +/* + * 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 +*/ +/*!\file + * \brief create the infobulle, the internalization is not yet implemented + */ + +var posX=0,posy=0,offsetX=10,offsetY=10; +document.onmousemove=getPosition; +content[0]="Donnez le quickcode ou tapez une partie du nom de la fiche puis cliquer sur rechercher, si la recherche ne donne rien, il vous sera proposé de créer une nouvelle fiche"; +content[1]="(optionnel) La description est un commentaire libre qui sert à identifier cette opération"; +content[2]="Selectionnez le journal où l'opération doit être sauvée"; +content[3]="Les périodes comptables servent comme un second contrôle pour la date de l'opération. Modifiez dans vos préférence pour avoir une autre période par défaut"; +content[4]="(optionnel) L'échéance est la date limite de paiement"; +content[5]="(optionnel)Le numéro d'extrait permet de retrouver plus facilement l'extrait de banque"; +content[6]="Indiquez ici le prix hors tva si vous êtes affilié à la tva et que vous pouvez la déduire , sinon indiquez ici le total tva incluse et utilisez un taux tva de 0%"; +content[7]="(optionnel) Ces champs servent à contrôler que les montants correspondent à l'extrait"; +content[8]="(optionnel) Ce montant correspond au total tva, si vous le laissez à vide, il sera calculé automatiquement en fonction du taux"; +content[9]="Tapez le numéro de poste ou une partie du poste ou du libellé puis sur recherche, Si vous avez donné un quickcode, le poste comptable ne sera pas utilisé"; +function showBulle(p_ctl) { + d=document.getElementById('bulle'); + d.innerHTML=content[p_ctl]; + d.style.top=posY+offsetY; + d.style.left=posX+offsetX; + d.style.visibility="visible"; +} +function getPosition(e) { + if (document.all) { + posX=event.x+document.body.scrollLeft; + posY=event.y+document.body.scrollTop; + } + else { + posX=e.pageX; + posY=e.pageY; + } +} +function hideBulle(p_ctl) { + d=document.getElementById('bulle'); + d.style.visibility="hidden"; +} \ No newline at end of file diff --git a/html/js/mintoolkit.js b/html/js/mintoolkit.js new file mode 100644 index 000000000..abb91da0a --- /dev/null +++ b/html/js/mintoolkit.js @@ -0,0 +1,226 @@ +function $(element) { + if (arguments.length > 1) { + for (var i = 0, elements = [], length = arguments.length; i < length; i++) + elements.push($(arguments[i])); + return elements; + } + if (Object.isString(element)) + element = document.getElementById(element); + return Element.extend(element); +} +Object.extend = function(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; +}; + +Object.extend(Object, { + inspect: function(object) { + try { + if (object === undefined) return 'undefined'; + if (object === null) return 'null'; + return object.inspect ? object.inspect() : object.toString(); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } + }, + + toJSON: function(object) { + var type = typeof object; + switch (type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (Object.isElement(object)) return; + + var results = []; + for (var property in object) { + var value = Object.toJSON(object[property]); + if (value !== undefined) + results.push(property.toJSON() + ': ' + value); + } + + return '{' + results.join(', ') + '}'; + }, + + toQueryString: function(object) { + return $H(object).toQueryString(); + }, + + toHTML: function(object) { + return object && object.toHTML ? object.toHTML() : String.interpret(object); + }, + + keys: function(object) { + var keys = []; + for (var property in object) + keys.push(property); + return keys; + }, + + values: function(object) { + var values = []; + for (var property in object) + values.push(object[property]); + return values; + }, + + clone: function(object) { + return Object.extend({ }, object); + }, + + isElement: function(object) { + return object && object.nodeType == 1; + }, + + isArray: function(object) { + return object && object.constructor === Array; + }, + + isHash: function(object) { + return object instanceof Hash; + }, + + isFunction: function(object) { + return typeof object == "function"; + }, + + isString: function(object) { + return typeof object == "string"; + }, + + isNumber: function(object) { + return typeof object == "number"; + }, + + isUndefined: function(object) { + return typeof object == "undefined"; + } +}); + +Object.extend(Function.prototype, { + argumentNames: function() { + var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); + return names.length == 1 && !names[0] ? [] : names; + }, + + bind: function() { + if (arguments.length < 2 && arguments[0] === undefined) return this; + var __method = this, args = $A(arguments), object = args.shift(); + return function() { + return __method.apply(object, args.concat($A(arguments))); + } + }, + + bindAsEventListener: function() { + var __method = this, args = $A(arguments), object = args.shift(); + return function(event) { + return __method.apply(object, [event || window.event].concat(args)); + } + }, + + curry: function() { + if (!arguments.length) return this; + var __method = this, args = $A(arguments); + return function() { + return __method.apply(this, args.concat($A(arguments))); + } + }, + + delay: function() { + var __method = this, args = $A(arguments), timeout = args.shift() * 1000; + return window.setTimeout(function() { + return __method.apply(__method, args); + }, timeout); + }, + + wrap: function(wrapper) { + var __method = this; + return function() { + return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); + } + }, + + methodize: function() { + if (this._methodized) return this._methodized; + var __method = this; + return this._methodized = function() { + return __method.apply(null, [this].concat($A(arguments))); + }; + } +}); +var Prototype = { + Version: '1.6.0_rc1', + + Browser: { + IE: !!(window.attachEvent && !window.opera), + Opera: !!window.opera, + WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, + Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, + MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) + }, + + BrowserFeatures: { + XPath: !!document.evaluate, + ElementExtensions: !!window.HTMLElement, + SpecificElementExtensions: + document.createElement('div').__proto__ !== + document.createElement('form').__proto__ + }, + + ScriptFragment: ']*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, + + emptyFunction: function() { }, + K: function(x) { return x } +}; + +if (Prototype.Browser.MobileSafari) + Prototype.BrowserFeatures.SpecificElementExtensions = false; + +if (Prototype.Browser.WebKit) + Prototype.BrowserFeatures.XPath = false; +Element.extend = (function() { + if (Prototype.BrowserFeatures.SpecificElementExtensions) + return Prototype.K; + + var Methods = { }, ByTag = Element.Methods.ByTag; + + var extend = Object.extend(function(element) { + if (!element || element._extendedByPrototype || + element.nodeType != 1 || element == window) return element; + + var methods = Object.clone(Methods), + tagName = element.tagName, property, value; + + // extend methods for specific tags + if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); + + for (property in methods) { + value = methods[property]; + if (Object.isFunction(value) && !(property in element)) + element[property] = value.methodize(); + } + + element._extendedByPrototype = Prototype.emptyFunction; + return element; + + }, { + refresh: function() { + // extend methods for all tags (Safari doesn't need this) + if (!Prototype.BrowserFeatures.ElementExtensions) { + Object.extend(Methods, Element.Methods); + Object.extend(Methods, Element.Methods.Simulated); + } + } + }); + + extend.refresh(); + return extend; +})(); diff --git a/html/js/prototype.js b/html/js/prototype.js index f193e81fb..35047ba4a 100644 --- a/html/js/prototype.js +++ b/html/js/prototype.js @@ -1,4152 +1,258 @@ -/* Prototype JavaScript framework, version 1.6.0_rc1 - * (c) 2005-2007 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ -var Prototype = { - Version: '1.6.0_rc1', - - Browser: { - IE: !!(window.attachEvent && !window.opera), - Opera: !!window.opera, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - document.createElement('div').__proto__ !== - document.createElement('form').__proto__ - }, - - ScriptFragment: ']*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - -if (Prototype.Browser.WebKit) - Prototype.BrowserFeatures.XPath = false; - -/* Based on Alex Arnell's inheritance implementation. */ -var Class = { - create: function() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - var subclass = function() { }; - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0; i < properties.length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - - return klass; - } -}; - -Class.Methods = { - addMethods: function(source) { - var ancestor = this.superclass && this.superclass.prototype; - - for (var property in source) { - var value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames().first() == "$super") { - var method = value, value = Object.extend((function(m) { - return function() { return ancestor[m].apply(this, arguments) }; - })(property).wrap(method), { - valueOf: function() { return method }, - toString: function() { return method.toString() } - }); - } - this.prototype[property] = value; - } - - return this; - } -}; - -var Abstract = { }; - -Object.extend = function(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; -}; - -Object.extend(Object, { - inspect: function(object) { - try { - if (object === undefined) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : object.toString(); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch (type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (Object.isElement(object)) return; - - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (value !== undefined) - results.push(property.toJSON() + ': ' + value); - } - - return '{' + results.join(', ') + '}'; - }, - - toQueryString: function(object) { - return $H(object).toQueryString(); - }, - - toHTML: function(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({ }, object); - }, - - isElement: function(object) { - return object && object.nodeType == 1; - }, - - isArray: function(object) { - return object && object.constructor === Array; - }, - - isHash: function(object) { - return object instanceof Hash; - }, - - isFunction: function(object) { - return typeof object == "function"; - }, - - isString: function(object) { - return typeof object == "string"; - }, - - isNumber: function(object) { - return typeof object == "number"; - }, - - isUndefined: function(object) { - return typeof object == "undefined"; - } -}); - -Object.extend(Function.prototype, { - argumentNames: function() { - var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); - return names.length == 1 && !names[0] ? [] : names; - }, - - bind: function() { - if (arguments.length < 2 && arguments[0] === undefined) return this; - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } - }, - - bindAsEventListener: function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } - }, - - curry: function() { - if (!arguments.length) return this; - var __method = this, args = $A(arguments); - return function() { - return __method.apply(this, args.concat($A(arguments))); - } - }, - - delay: function() { - var __method = this, args = $A(arguments), timeout = args.shift() * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - }, - - wrap: function(wrapper) { - var __method = this; - return function() { - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); - } - }, - - methodize: function() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - return __method.apply(null, [this].concat($A(arguments))); - }; - } -}); - -Function.prototype.defer = Function.prototype.delay.curry(0.01); - -Date.prototype.toJSON = function() { - return '"' + this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < length; i++) { - var lambda = arguments[i]; - try { - returnValue = lambda(); - break; - } catch (e) { } - } - - return returnValue; - } -}; - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; - -/*--------------------------------------------------------------------------*/ - -var PeriodicalExecuter = Class.create({ - initialize: function(callback, frequency) { - this.callback = callback; - this.frequency = frequency; - this.currentlyExecuting = false; - - this.registerCallback(); - }, - - registerCallback: function() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - } finally { - this.currentlyExecuting = false; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = count === undefined ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = truncation === undefined ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = new Element('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - }, - - interpolate: function(object, pattern) { - return new Template(this, pattern).evaluate(object); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&').replace(//g,'>'); - }, - unescapeHTML: function() { - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -}; - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -with (String.prototype.escapeHTML) div.appendChild(text); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return ''; - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3]; - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr); - if (match == null) return ''; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }.bind(this)); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = { - each: function(iterator, context) { - var index = 0; - iterator = iterator.bind(context); - try { - this._each(function(value) { - iterator(value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var index = -number, slices = [], array = this.toArray(); - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - }, - - all: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator(value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator(value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator(value, index)); - }); - return results; - }, - - detect: function(iterator, context) { - iterator = iterator.bind(context); - var result; - this.each(function(value, index) { - if (iterator(value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator, context) { - iterator = iterator.bind(context); - var results = []; - this.each(function(value, index) { - if (iterator(value, index)) - results.push(value); - }); - return results; - }, - - grep: function(filter, iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(filter); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator(value, index)); - }); - return results; - }, - - include: function(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = fillWith === undefined ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator, context) { - iterator = iterator.bind(context); - this.each(function(value, index) { - memo = iterator(memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result; - this.each(function(value, index) { - value = iterator(value, index); - if (result == undefined || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var result; - this.each(function(value, index) { - value = iterator(value, index); - if (result == undefined || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator, context) { - iterator = iterator ? iterator.bind(context) : Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator(value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator, context) { - iterator = iterator.bind(context); - var results = []; - this.each(function(value, index) { - if (!iterator(value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator, context) { - iterator = iterator.bind(context); - return this.map(function(value, index) { - return {value: value, criteria: iterator(value, index)}; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#'; - } -}; - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - filter: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray, - every: Enumerable.all, - some: Enumerable.any -}); -function $A(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - var length = iterable.length, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - -if (Prototype.Browser.WebKit) { - function $A(iterable) { - if (!iterable) return []; - if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && - iterable.toArray) return iterable.toArray(); - var length = iterable.length, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; - } -} - -Array.from = $A; - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(Object.isArray(value) ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - intersect: function(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (value !== undefined) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -// use native browser JS 1.6 implementation if available -if (Object.isFunction(Array.prototype.forEach)) - Array.prototype._each = Array.prototype.forEach; - -if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; -}; - -if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; -}; - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (Object.isArray(arguments[i])) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - }; -} -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator) { - $R(0, this, true).each(iterator); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -$w('abs round ceil floor').each(function(method){ - Number.prototype[method] = Math[method].methodize(); -}); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - if (function() { - var i = 0, Test = function(value) { this.key = value }; - Test.prototype.key = 'foo'; - for (var property in new Test('bar')) i++; - return i > 1; - }()) { - function each(iterator) { - var cache = []; - for (var key in this._object) { - var value = this._object[key]; - if (cache.include(key)) continue; - cache.push(key); - var pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - } - } else { - function each(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - } - } - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - return { - initialize: function(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - }, - - _each: each, - - set: function(key, value) { - return this._object[key] = value; - }, - - get: function(key) { - return this._object[key]; - }, - - unset: function(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - }, - - toObject: function() { - return Object.clone(this._object); - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - index: function(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - }, - - merge: function(object) { - return this.clone().update(object); - }, - - update: function(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - }, - - toQueryString: function() { - return this.map(function(pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return values.map(toQueryPair.curry(key)).join('&'); - } - return toQueryPair(key, values); - }).join('&'); - }, - - inspect: function() { - return '#'; - }, - - toJSON: function() { - return Object.toJSON(this.toObject()); - }, - - clone: function() { - return new Hash(this); - } - } -})()); - -Hash.from = $H; -var ObjectRange = Class.create(Enumerable, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -}; - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (Object.isFunction(responder[callback])) { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) { } - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { Ajax.activeRequestCount++ }, - onComplete: function() { Ajax.activeRequestCount-- } -}); - -Ajax.Base = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - } -}); - -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name); - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if(readyState == 4) { - var xml = transport.responseXML; - this.responseXML = xml === undefined ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - try { - return json ? json.evalJSON(this.request.options.sanitizeJSON) : null; - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - try { - if (options.evalJSON == 'force' || (options.evalJSON && - (this.getHeader('Content-type') || '').include('application/json'))) - return this.transport.responseText.evalJSON(options.sanitizeJSON); - return null; - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = options || { }; - var onComplete = options.onComplete; - options.onComplete = (function(response, param) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, param); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - - if (this.success()) { - if (this.onComplete) this.onComplete.bind(this).defer(); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = { }; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (Object.isString(element)) - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!window.Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - // DOM level 2 ECMAScript Language Binding - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - -(function() { - var element = this.Element; - this.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (Prototype.Browser.IE && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - Object.extend(this.Element, element || { }); -}).call(window); - -Element.cache = { }; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - $(element).style.display = 'none'; - return element; - }, - - show: function(element) { - $(element).style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - content = Object.toHTML(content); - element.innerHTML = content.stripScripts(); - content.evalScripts.bind(content).defer(); - return element; - }, - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, t, range; - - for (position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - t = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - t.insert(element, content); - continue; - } - - content = Object.toHTML(content); - - range = element.ownerDocument.createRange(); - t.initializeRange(element, range); - t.insert(element, range.createContextualFragment(content.stripScripts())); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $A($(element).getElementsByTagName('*')).each(Element.extend); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (Object.isString(selector)) - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return expression ? Selector.findElement(ancestors, expression, index) : - ancestors[index || 0]; - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - var descendants = element.descendants(); - return expression ? Selector.findElement(descendants, expression, index) : - descendants[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return expression ? Selector.findElement(previousSiblings, expression, index) : - previousSiblings[index || 0]; - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return expression ? Selector.findElement(nextSiblings, expression, index) : - nextSiblings[index || 0]; - }, - - select: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - adjacent: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element.parentNode, args).without(element); - }, - - identify: function(element) { - element = $(element); - var id = element.readAttribute('id'), self = arguments.callee; - if (id) return id; - do { id = 'anonymous_element_' + self.counter++ } while ($(id)); - element.writeAttribute('id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = value === undefined ? true : value; - - for (var attr in attributes) { - var name = t.names[attr] || attr, value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!element.hasClassName(className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return element[element.hasClassName(className) ? - 'removeClassName' : 'addClassName'](className); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - while (element = element.parentNode) - if (element == ancestor) return true; - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = element.cumulativeOffset(); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = $(element).getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (window.opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = Element.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (element.tagName == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p == 'relative' || p == 'absolute') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (element.getStyle('position') == 'absolute') return; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - var offsets = element.positionedOffset(); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (element.getStyle('position') == 'relative') return; - // Position.prepare(); // To be done manually by Scripty when it needs it. - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: function(element) { - if (element.offsetParent) return $(element.offsetParent); - if (element == document.body) return $(element); - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return $(element); - - return $(document.body); - }, - - viewportOffset: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || element.tagName == 'BODY') { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - // find page position of source - source = $(source); - var p = source.viewportOffset(); - - // find coordinate system to use - element = $(element); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(element, 'position') == 'absolute') { - parent = element.getOffsetParent(); - delta = parent.viewportOffset(); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Element.Methods.identify.counter = 1; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - - -if (!document.createRange || Prototype.Browser.Opera) { - Element.Methods.insert = function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = { bottom: insertions }; - - var t = Element._insertionTranslations, content, position, pos, tagName; - - for (position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - pos = t[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - pos.insert(element, content); - continue; - } - - content = Object.toHTML(content); - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - if (t.tags[tagName]) { - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - if (position == 'top' || position == 'after') fragments.reverse(); - fragments.each(pos.insert.curry(element)); - } - else element.insertAdjacentHTML(pos.adjacency, content.stripScripts()); - - content.evalScripts.bind(content).defer(); - } - - return element; - }; -} - -if (Prototype.Browser.Opera) { - Element.Methods._getStyle = Element.Methods.getStyle; - Element.Methods.getStyle = function(element, style) { - switch(style) { - case 'left': - case 'top': - case 'right': - case 'bottom': - if (Element._getStyle(element, 'position') == 'static') return null; - default: return Element._getStyle(element, style); - } - }; - Element.Methods._readAttribute = Element.Methods.readAttribute; - Element.Methods.readAttribute = function(element, attribute) { - if (attribute == 'title') return element.title; - return Element._readAttribute(element, attribute); - }; -} - -else if (Prototype.Browser.IE) { - $w('positionedOffset getOffsetParent viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - var position = element.getStyle('position'); - if (position != 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - if (!element.currentStyle.hasLayout) element.style.zoom = 1; - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = { - read: { - names: { - 'class': 'className', - 'for': 'htmlFor' - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: function(element, attribute) { - var attribute = element.getAttribute(attribute); - return attribute ? attribute.toString().slice(23, -2) : null; - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - }; - - Element._attributeTranslations.write = { - names: Object.clone(Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr, - src: v._getAttr, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); -} - -else if (Prototype.Browser.Gecko) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if(element.tagName == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - // Safari returns margins on body which is incorrect if the child is absolutely - // positioned. For performance reasons, redefine Position.cumulativeOffset for - // KHTML/WebKit only. - Element.Methods.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return Element._returnOffset(valueL, valueT); - }; -} - -if (Prototype.Browser.IE || Prototype.Browser.Opera) { - // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements - Element.Methods.update = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) return element.update().insert(content); - - content = Object.toHTML(content); - var tagName = element.tagName.toUpperCase(); - - if (tagName in Element._insertionTranslations.tags) { - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { element.appendChild(node) }); - } - else element.innerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -if (document.createElement('div').outerHTML) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(); - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; - div.innerHTML = t[0] + html + t[1]; - t[2].times(function() { div = div.firstChild }); - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: { - adjacency: 'beforeBegin', - insert: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - initializeRange: function(element, range) { - range.setStartBefore(element); - } - }, - top: { - adjacency: 'afterBegin', - insert: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - initializeRange: function(element, range) { - range.selectNodeContents(element); - range.collapse(true); - } - }, - bottom: { - adjacency: 'beforeEnd', - insert: function(element, node) { - element.appendChild(node); - } - }, - after: { - adjacency: 'afterEnd', - insert: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - initializeRange: function(element, range) { - range.setStartAfter(element); - } - }, - tags: { - TABLE: ['
', '
', 1], - TBODY: ['', '
', 2], - TR: ['', '
', 3], - TD: ['
', '
', 4], - SELECT: ['', 1] - } -}; - -(function() { - this.bottom.initializeRange = this.top.initializeRange; - Object.extend(this.tags, { - THEAD: this.tags.TBODY, - TFOOT: this.tags.TBODY, - TH: this.tags.TD - }); -}).call(Element._insertionTranslations); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return node && node.specified; - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div').__proto__) { - window.HTMLElement = { }; - window.HTMLElement.prototype = document.createElement('div').__proto__; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.extend = (function() { - if (Prototype.BrowserFeatures.SpecificElementExtensions) - return Prototype.K; - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || element._extendedByPrototype || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName, property, value; - - // extend methods for specific tags - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - for (property in methods) { - value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - // extend methods for all tags (Safari doesn't need this) - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = { }; - window[klass].prototype = document.createElement(tagName).__proto__; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - -document.viewport = { - getDimensions: function() { - var dimensions = { }; - $w('width height').each(function(d) { - var D = d.capitalize(); - dimensions[d] = self['inner' + D] || - (document.documentElement['client' + D] || document.body['client' + D]); - }); - return dimensions; - }, - - getWidth: function() { - return this.getDimensions().width; - }, - - getHeight: function() { - return this.getDimensions().height; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; -/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - this.compileMatcher(); - }, - - compileMatcher: function() { - // Selectors with namespaced attributes can't use the XPath version - if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression)) - return this.compileXPathMatcher(); - - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; - return; - } - - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - if (this.xpath) return document._getElementsByXPath(this.xpath, root); - return this.matcher(root); - }, - - match: function(element) { - this.tokens = []; - - var e = this.expression, ps = Selector.patterns, as = Selector.assertions; - var le, p, m; - - while (e && le !== e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - // use the Selector.assertions methods unless the selector - // is too complex. - if (as[i]) { - this.tokens.push([i, Object.clone(m)]); - e = e.replace(m[0], ''); - } else { - // reluctantly do a document-wide search - // and look for a match in the array - return this.findElements(document).include(element); - } - } - } - } - - var match = true, name, matches; - for (var i = 0, token; token = this.tokens[i]; i++) { - name = token[0], matches = token[1]; - if (!Selector.assertions[name](element, matches)) { - match = false; break; - } - } - - return match; - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#"; - } -}); - -Object.extend(Selector, { - _cache: { }, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: "[@#{1}]", - attr: function(m) { - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (Object.isFunction(h)) return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", - 'checked': "[@checked]", - 'disabled': "[@disabled]", - 'enabled': "[not(@disabled)]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, m, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/, - attrPresence: /^\[([\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - // for Selector.match and Element#match - assertions: { - tagName: function(element, matches) { - return matches[1].toUpperCase() == element.tagName.toUpperCase(); - }, - - className: function(element, matches) { - return Element.hasClassName(element, matches[1]); - }, - - id: function(element, matches) { - return element.id === matches[1]; - }, - - attrPresence: function(element, matches) { - return Element.hasAttribute(element, matches[1]); - }, - - attr: function(element, matches) { - var nodeValue = Element.readAttribute(element, matches[1]); - return Selector.operators[matches[2]](nodeValue, matches[3]); - } - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._counted = true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._counted = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._counted = true; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - var node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._counted) { - n._counted = true; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, children = [], child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - tagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() == tagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!targetNode) return []; - if (!nodes && root == document) return [targetNode]; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr) { - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._counted) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._counted) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled) results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv.startsWith(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } - }, - - matchElements: function(elements, expression) { - var matches = new Selector(expression).findElements(), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._counted) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (Object.isNumber(expression)) { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - var exprs = expressions.join(','), expressions = []; - exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (options.hash === undefined) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - // a key is already present; construct an array of values - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -}; - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = { }; - pair[element.name] = value; - return Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.blur(); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (value === undefined) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (value === undefined) return element.value; - else element.value = value; - }, - - select: function(element, index) { - if (index === undefined) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, value, single = !Object.isArray(index); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - value = this.optionValue(opt); - if (single) { - if (value == index) { - opt.selected = true; - return; - } - } - else opt.selected = index.include(value); - } - } - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback, this); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -}); - -Form.Element.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) var Event = { }; - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - KEY_INSERT: 45, - - cache: { }, - - relatedTarget: function(event) { - var element; - switch(event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } -}); - -Event.Methods = (function() { - if (Prototype.Browser.IE) { - function isButton(event, code) { - return event.button == ({ 0: 1, 1: 4, 2: 2 })[code]; - } - - } else if (Prototype.Browser.WebKit) { - function isButton(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - } - - } else { - function isButton(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - } - } - - return { - isLeftClick: function(event) { return isButton(event, 0) }, - isMiddleClick: function(event) { return isButton(event, 1) }, - isRightClick: function(event) { return isButton(event, 2) }, - - element: function(event) { - var node = Event.extend(event).target; - return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node); - }, - - findElement: function(event, expression) { - var element = Event.element(event); - return element.match(expression) ? element : element.up(expression); - }, - - pointer: function(event) { - return { - x: event.pageX || (event.clientX + - (document.documentElement.scrollLeft || document.body.scrollLeft)), - y: event.pageY || (event.clientY + - (document.documentElement.scrollTop || document.body.scrollTop)) - }; - }, - - pointerX: function(event) { return Event.pointer(event).x }, - pointerY: function(event) { return Event.pointer(event).y }, - - stop: function(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - } - }; -})(); - -Event.extend = (function() { - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return "[object Event]" } - }); - - return function(event) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - Object.extend(event, { - target: event.srcElement, - relatedTarget: Event.relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - return Object.extend(event, methods); - }; - - } else { - Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__; - Object.extend(Event.prototype, methods); - return Prototype.K; - } -})(); - -Object.extend(Event, (function() { - var cache = Event.cache; - - function getEventID(element) { - if (element._eventID) return element._eventID; - arguments.callee.id = arguments.callee.id || 1; - return element._eventID = ++arguments.callee.id; - } - - function getDOMEventName(eventName) { - if (eventName && eventName.match(/:/)) return "dataavailable"; - return eventName; - } - - function getCacheForID(id) { - return cache[id] = cache[id] || { }; - } - - function getWrappersForEventName(id, eventName) { - var c = getCacheForID(id); - return c[eventName] = c[eventName] || []; - } - - function createWrapper(element, eventName, handler) { - var id = getEventID(element); - var c = getWrappersForEventName(id, eventName); - if (c.pluck("handler").include(handler)) return false; - - var wrapper = function(event) { - if (event.eventName && event.eventName != eventName) - return false; - - Event.extend(event); - handler.call(element, event) - }; - - wrapper.handler = handler; - c.push(wrapper); - return wrapper; - } - - function findWrapper(id, eventName, handler) { - var c = getWrappersForEventName(id, eventName); - return c.find(function(wrapper) { return wrapper.handler == handler }); - } - - function destroyWrapper(id, eventName, handler) { - var c = getCacheForID(id); - if (!c[eventName]) return false; - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); - } - - function destroyCache() { - for (var id in cache) - for (var eventName in cache[id]) - cache[id][eventName] = null; - } - - if (window.attachEvent) { - window.attachEvent("onunload", destroyCache); - } - - return { - observe: function(element, eventName, handler) { - element = $(element); - var name = getDOMEventName(eventName); - - var wrapper = createWrapper(element, eventName, handler); - if (!wrapper) return element; - - if (element.addEventListener) { - element.addEventListener(name, wrapper, false); - } else { - element.attachEvent("on" + name, wrapper); - } - - return element; - }, - - stopObserving: function(element, eventName, handler) { - element = $(element); - var id = getEventID(element), name = getDOMEventName(eventName); - - if (!handler && eventName) { - getWrappersForEventName(id, eventName).each(function(wrapper) { - element.stopObserving(eventName, wrapper.handler); - }); - return element; - - } else if (!eventName) { - Object.keys(getCacheForID(id)).each(function(eventName) { - element.stopObserving(eventName); - }); - return element; - } - - var wrapper = findWrapper(id, eventName, handler); - if (!wrapper) return element; - - if (element.removeEventListener) { - element.removeEventListener(name, wrapper, false); - } else { - element.detachEvent("on" + name, wrapper); - } - - destroyWrapper(id, eventName, handler); - - return element; - }, - - fire: function(element, eventName, memo) { - element = $(element); - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - if (document.createEvent) { - var event = document.createEvent("HTMLEvents"); - event.initEvent("dataavailable", true, true); - } else { - var event = document.createEventObject(); - event.eventType = "ondataavailable"; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) { - element.dispatchEvent(event); - } else { - element.fireEvent(event.eventType, event); - } - - return event; - } - }; -})()); - -Object.extend(Event, Event.Methods); - -Element.addMethods({ - fire: Event.fire, - observe: Event.observe, - stopObserving: Event.stopObserving -}); - -Object.extend(document, { - fire: Element.Methods.fire.methodize(), - observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize() -}); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards and John Resig. */ - - var timer, fired = false; - - function fireContentLoadedEvent() { - if (fired) return; - if (timer) window.clearInterval(timer); - document.fire("dom:loaded"); - fired = true; - } - - if (document.addEventListener) { - if (Prototype.Browser.WebKit) { - timer = window.setInterval(function() { - if (/loaded|complete/.test(document.readyState)) - fireContentLoadedEvent(); - }, 0); - - Event.observe(window, "load", fireContentLoadedEvent); - - } else { - document.addEventListener("DOMContentLoaded", - fireContentLoadedEvent, false); - } - - } else { - document.write("'; echo " @@ -220,13 +220,13 @@ if ( isset($_POST['update_record']) ) { save_upload_document($cn,$_POST['jr_grpt_id']); } if ( isset ($_POST['is_paid'] )) - $Res=ExecSql($cn,"update jrn set jr_rapt='paid' where jr_id=".$_POST['jr_id']); + $Res=ExecSqlParam($cn,"update jrn set jr_rapt='paid' where jr_id=$1",array($_POST['jr_id'])); if ( isset ($_POST['to_remove'] )) { /*! \note we don't remove the document file if another * operation needs it. */ - $ret=ExecSql($cn,"select jr_pj from jrn where jr_id=".$_POST['jr_id']); + $ret=ExecSqlParam($cn,"select jr_pj from jrn where jr_id=$1",array($_POST['jr_id'])); if (pg_num_rows($ret) != 0) { $r=pg_fetch_array($ret,0); $old_oid=$r['jr_pj']; @@ -237,8 +237,8 @@ if ( isset($_POST['update_record']) ) { if ( $c == 1 ) pg_lo_unlink($cn,$old_oid); } - ExecSql($cn,"update jrn set jr_pj=null, jr_pj_name=null, ". - "jr_pj_type=null where jr_id=".$_POST['jr_id']); + ExecSqlParam($cn,"update jrn set jr_pj=null, jr_pj_name=null, ". + "jr_pj_type=null where jr_id=$1",array($_POST['jr_id'])); } } @@ -278,8 +278,8 @@ if ( isset($_POST['update_record']) ) { // so we fetch them all from the db $sql="select j_id,j_poste,to_char(j_date,'DD.MM.YYYY') as j_date,j_debit ". "from jrn join jrnx on (j_grpt=jr_grpt_id) ". - "where jr_id=".$_POST['jr_id']; - $res=ExecSql($cn,$sql); + "where jr_id=$1"; + $res=ExecSqlParam($cn,$sql,array($_POST['jr_id'])); $array_jid=pg_fetch_all($res); // if j_poste match 6 or 7 we insert them diff --git a/html/parametre.php b/html/parametre.php index 6d54ffe65..0b60a1958 100644 --- a/html/parametre.php +++ b/html/parametre.php @@ -40,17 +40,6 @@ $User->Check(); include_once("preference.php"); include_once("user_menu.php"); echo '
'; -/* -echo '
'; -echo "

Paramètre ".dossier::name().'

'. -'

'.' -
- - - - -
-*/ echo menu_tool('param'); echo '
'; @@ -98,6 +87,9 @@ switch ($p_action) { case 'company': $default=1; break; + case 'preod': + $default=12; + break; default: $default="parametre.php?p_action=".$p_action; } @@ -208,7 +200,7 @@ if ( $p_action=='company') { $array=array ( array("value"=>"ob",'label'=>"obligatoire"), array("value"=>"op",'label'=>"optionnel"), - array("value"=>"nu",'label'=>"non utilisé") + array("value"=>"nu",'label'=>"non utilisé") ); $compta=new widget("select"); $compta->table=1; @@ -219,15 +211,15 @@ if ( $p_action=='company') { echo ''; echo dossier::hidden(); echo ""; - echo "".$all->IOValue("p_name",$my->MY_NAME,"Nom société").""; - echo "".$all->IOValue("p_tel",$my->MY_TEL,"Téléphone").""; + echo "".$all->IOValue("p_name",$my->MY_NAME,"Nom société").""; + echo "".$all->IOValue("p_tel",$my->MY_TEL,"Téléphone").""; echo "".$all->IOValue("p_fax",$my->MY_FAX,"Fax").""; echo "".$all->IOValue("p_street",$my->MY_STREET,"Rue ").""; - echo "".$all->IOValue("p_no",$my->MY_NUMBER,"Numéro").""; + echo "".$all->IOValue("p_no",$my->MY_NUMBER,"Numéro").""; echo "".$all->IOValue("p_cp",$my->MY_CP,"Code Postal").""; echo "".$all->IOValue("p_Commune",$my->MY_COMMUNE,"Commune").""; echo "".$all->IOValue("p_pays",$my->MY_PAYS,"Pays").""; - echo "".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva").""; + echo "".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva").""; echo "".$compta->IOValue("p_compta",$array,"Utilisation de la compta. analytique").""; echo "
"; $submit=new widget("submit"); @@ -239,7 +231,7 @@ if ( $p_action=='company') { //----------------------------------------------------- echo "
"; if ( $p_action == 'document' ) { - echo '
'; + echo '
'; require_once('document_modele.inc.php'); echo '
'; } @@ -255,13 +247,25 @@ if ( $p_action == 'pcmn' ) { if ( $p_action == 'sec' ) { require_once('param_sec.inc.php'); } +//---------------------------------------------------------------------- +// Predefined operation +//---------------------------------------------------------------------- +if ( $p_action == 'preod' ) { + require_once('preod.inc.php'); +} +//--------------------------------------------------------------------------- +// Definition of report +//--------------------------------------------------------------------------- +if ( $p_action == 'defrapport' ) { + require_once('report.inc.php'); +} //---------------------------------------------------------------------- // Ledger parameter //---------------------------------------------------------------------- if ( $p_action == 'jrn' ) { $sa=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; - // echo '
'; + // echo '
'; if ( $sa == "add") require_once ('param_jrn_add.inc.php'); elseif ($sa=='detail') diff --git a/html/poste_csv.php b/html/poste_csv.php index fa5e9055d..d63b135a9 100644 --- a/html/poste_csv.php +++ b/html/poste_csv.php @@ -65,15 +65,15 @@ if ( ! isset ($_REQUEST['oper_detail'])) { "\"Code interne\";". "\"Date\";". "\"Description\";". - "\"Débit\";". - "\"Crédit\""; + "\"Débit\";". + "\"Crédit\""; printf("\n"); foreach ( $Poste->row as $op ) { echo '"'.$pos['pcm_val'].'";'. '"'.$op['jr_internal'].'"'.";". - '"'.$op['j_date'].'"'.";". + '"'.$op['jr_date'].'"'.";". '"'.$op['description'].'"'.";". sprintf("%8.4f",$op['deb_montant']).";". sprintf("%8.4f",$op['cred_montant']); @@ -81,7 +81,7 @@ if ( ! isset ($_REQUEST['oper_detail'])) { } - $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; + $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; $diff=abs($tot_deb-$tot_cred); printf( '"'."$solde_type".'"'.";". @@ -123,7 +123,7 @@ if ( ! isset ($_REQUEST['oper_detail'])) { $r['j_poste'], $r['j_qcode'], $r['jr_internal'], - $r['j_date'], + $r['jr_date'], $a['description'], $r['j_montant'], $r['debit']); diff --git a/html/poste_pdf.php b/html/poste_pdf.php index f94473200..5b1519545 100644 --- a/html/poste_pdf.php +++ b/html/poste_pdf.php @@ -66,7 +66,7 @@ foreach ($a_poste as $poste) // $pdf->ezText($Libelle,30); $pdf->ezTable($array, - array ('jr_internal'=>'Opération', + array ('jr_internal'=>'Operation', 'j_date' => 'Date', 'jrn_name'=>'Journal', 'description'=>'Description', @@ -75,9 +75,9 @@ foreach ($a_poste as $poste) ),$Libelle, array('shaded'=>1,'showHeadings'=>1,'width'=>500, 'cols'=>array('montant'=> array('justification'=>'right'), - ))); - $str_debit=sprintf("Débit % 12.2f",$tot_deb); - $str_cred=sprintf("Crédit % 12.2f",$tot_cred); + )),true); + $str_debit=utf8_decode(sprintf("Débit % 12.2f",$tot_deb)); + $str_cred=utf8_decode(sprintf("Crédit % 12.2f",$tot_cred)); $diff_solde=$tot_deb-$tot_cred; if ( $diff_solde < 0 ) { $solde=" C "; diff --git a/html/poste_search.php b/html/poste_search.php index c17d49117..4c7e589ab 100644 --- a/html/poste_search.php +++ b/html/poste_search.php @@ -25,7 +25,7 @@ include_once ("ac_common.php"); require_once('class_acc_ledger.php'); -html_page_start($_SESSION['g_theme'],'onLoad="window.focus();"'); +html_min_page_start($_SESSION['g_theme'],'onLoad="window.focus();"'); include_once ("postgres.php"); include_once("jrn.php"); /* Admin. Dossier */ @@ -46,13 +46,12 @@ $condition=""; $cn=DbConnect($gDossier); if ( isset($_GET['search']) ) { $c1=0; - foreach( $_GET as $key=>$element){ - ${"$key"}=$element; - } + extract ($_GET); + $condition=""; if ( strlen(trim($p_comment)) != 0 ) { - $condition=" where (upper(pcm_lib) like upper('%$p_comment%') or ". - " pcm_val::text like '$p_comment%') "; + $condition=" where (upper(pcm_lib) like upper('%".pg_escape_string($p_comment)."%') or ". + " pcm_val::text like '%".pg_escape_string($p_comment)."%') "; } } @@ -80,9 +79,9 @@ if ( isset($_GET['filter']) && $_GET['filter'] != 'all') { if ( strlen (trim($item_cred))) { if ( strstr($item_cred,"*") == true ) { $item_cred=strtr($item_cred,"*","%"); - $Sql=" pcm_val like '$item_cred' or"; + $Sql=" pcm_val::text like '$item_cred' or"; } else { - $Sql=" pcm_val = '$item_cred' or"; + $Sql=" pcm_val::text = '$item_cred' or"; } $SqlCred=$SqlCred.$Sql; } @@ -98,7 +97,7 @@ if ( isset($_GET['filter']) && $_GET['filter'] != 'all') { echo_debug('poste_search.php',__LINE__,"l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb"); if ( strstr($item_deb,"*") == true ) { $item_cred=strtr($item_deb,"*","%"); - $Sql=" pcm_val like '$item_deb' or"; + $Sql=" pcm_val::text like '$item_deb' or"; } else { $Sql=" pcm_val = '$item_deb' or"; } @@ -126,53 +125,64 @@ echo_debug('poste_search.php',__LINE__,"condition = $condition"); echo ''; echo dossier::hidden(); if ( isset($p_ctl) ) { - if ($p_ctl != 'not') echo ''; + echo ''; } -echo ''; -echo ''; +if (isset ($ret)) echo widget::hidden('ret',$ret); /* echo ''; */ /* if ( ! isset ($p_class) ) $p_class=""; */ /* $opt=" "; */ /* echo ''; */ -echo ''; -echo ''; +echo 'Libellé ou poste comptable '; +echo ' contient '; if ( ! isset ($p_comment) ) $p_comment=""; -echo ''; -echo '
Poste Comptable Commence par Libellé ou poste comptable contient
'; +echo '
'; + echo '
'; $l_id=""; - + $ahref=""; + $end_ahref=""; for ( $i=0; $i < $MaxLine; $i++) { $l_line=pg_fetch_array($Res,$i); - echo ""; + $even=($i%2 == 0)?"odd":"even"; + echo ""; // if p_ctl is set we need to be able to return the value - if (isset($p_ctl) && $p_ctl != 'not' ){ - echo ''; + $end_ahref=''; + } - echo ''; echo ''; echo ""; diff --git a/html/print_balance.php b/html/print_balance.php index 485d6eaf5..d826a3cef 100644 --- a/html/print_balance.php +++ b/html/print_balance.php @@ -61,7 +61,7 @@ $t_cent=""; if ( isset($central) ) { $bal->central='Y'; - $t_cent="centralisée"; + $t_cent=utf8_decode("centralisée"); } else $bal->central='N'; @@ -83,14 +83,14 @@ if ( sizeof($array) == 0 ) { } $a=get_periode($cn,$from_periode); $b=get_periode($cn,$to_periode); -$per_text=" période du ".$a['p_start']." au ".$b['p_end']; +$per_text=utf8_decode(" période du ").$a['p_start']." au ".$b['p_end']; $pdf=new Cezpdf('a4'); $pdf->selectFont('./addon/fonts/Helvetica.afm'); $pdf->ezSetCmMargins(2,2,2,2); header_pdf($cn,$pdf); -$pdf->ezTable($array,array('poste'=>'Poste','label'=>'Libellé','sum_deb'=>'Total Débit', - 'sum_cred'=>'Total crédit','solde_deb'=>'Solde débiteur', - 'solde_cred'=>'Solde créditeur'),'Balance des comptes '.$t_cent.$per_text); +$pdf->ezTable($array,array('poste'=>'Poste','label'=>utf8_decode('Libellé'),'sum_deb'=>utf8_decode('Total Débit'), + 'sum_cred'=>utf8_decode('Total crédit'),'solde_deb'=>utf8_decode('Solde débiteur'), + 'solde_cred'=>utf8_decode('Solde créditeur')),'Balance des comptes '.$t_cent.$per_text,null,true); $pdf->ezStream(); diff --git a/html/priv_user.php b/html/priv_user.php index 56171283b..60ed1379e 100644 --- a/html/priv_user.php +++ b/html/priv_user.php @@ -39,7 +39,7 @@ if ($User->admin != 1) { } if (! isset ($_GET['UID']) && ! isset($_POST['UID']) ) { - //Message d'erreur si UID non positionné + //Message d'erreur si UID non positionné echo_debug('priv_user.php',__LINE__,"UID NOT DEFINED"); html_page_stop(); return; @@ -76,7 +76,7 @@ if ( isset ( $_GET['reset_passwd']) ){ $cn=DbConnect(); $l_pass=md5('phpcompta'); $Res=ExecSql($cn, "update ac_users set use_pass='$l_pass' where use_id=$uid"); - echo '

Password remis à phpcompta

'; + echo '

Password remis à phpcompta

'; } if ( isset ($_POST['SAVE']) ){ $uid = $_POST['UID']; @@ -187,7 +187,7 @@ echo ""; "; echo ''; echo ''; } if ( $right == 1 ) { - echo ''; + echo ''; echo ""; echo ''; } if ( $right == 2 ) { - echo ''; + echo ''; echo ''; echo "'; + echo ''; echo ''; echo ""; $l_change=$l_change."&access=1"; - echo ''; + echo ''; } if ( $right == 1) { $l_change=$l_change."&access=0"; - echo ''; + echo ''; echo ""; } @@ -263,7 +263,7 @@ if ( $action == "view" ) { echo ''; echo ""; } diff --git a/include/.htaccess b/include/.htaccess deleted file mode 100644 index ff2beb844..000000000 --- a/include/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -order deny,allow -deny from all diff --git a/include/ac_common.php b/include/ac_common.php index 47da621ec..f6402ee1e 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -90,12 +90,12 @@ function isNumber(&$p_int) { } /*! - * \brief Verifie qu'une date est bien formaté + * \brief Verifie qu'une date est bien formaté * en d.m.y et est valable * \param $p_date * * \return - * - null si la date est invalide ou malformaté + * - null si la date est invalide ou malformaté * - $p_date si tout est bon * */ @@ -144,7 +144,58 @@ function formatDate($p_date) { function html_page_start($p_theme="",$p_script="",$p_script2="") { - ini_set('magic_quotes_gpc','Off'); + $cn=DbConnect(); + if ( $p_theme != "") { + $Res=ExecSql($cn,"select the_filestyle from theme + where the_name='".$p_theme."'"); + if (pg_NumRows($Res)==0) + $style="style.css"; + else { + $s=pg_fetch_array($Res,0); + $style=$s['the_filestyle']; + } + }else { + $style="style.css"; + } // end if + echo ''; + echo ""; + + + if ( $p_script2 != "" ) + $p_script2=''; + + echo " + PhpCompta + + + ". + $p_script2. " + "; + echo ' + + + + +'; + + echo ""; + /* If we are on the user_login page */ + if ( basename($_SERVER['PHP_SELF']) == 'user_login.php') { + return; + } + +} +/*! + * \brief Minimal page header for each page, used for small popup window + * + * \param p_theme default theme + * \param $p_script + * \param $p_script2 another js script + * + * \return none + */ +function html_min_page_start($p_theme="",$p_script="",$p_script2="") +{ $cn=DbConnect(); if ( $p_theme != "") { @@ -162,26 +213,28 @@ function html_page_start($p_theme="",$p_script="",$p_script2="") echo ''; echo ""; + if ( $p_script2 != "" ) $p_script2=''; echo "PhpCompta - + ". $p_script2. " "; - echo ' - - - - - + echo ' '; echo ""; + /* If we are on the user_login page */ + if ( basename($_SERVER['PHP_SELF']) == 'user_login.php') { + return; + } + } + /*! * \brief end tag * @@ -213,13 +266,13 @@ function NoAccess($js=0) if ( $js == 1 ) { echo ""; } else { echo '
'; - echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; + echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; echo '
'; } exit -1; @@ -474,5 +527,13 @@ function tva_get_label($p_cn,$p_tva_id) $a=getDbValue($p_cn,"select tva_label from tva_rate where tva_id='".$p_tva_id."'"); return $a; } - +/*!\brief alert in javascript + *\param $p_msg is the message + */ +function alert($p_msg) +{ + echo ''; +} ?> diff --git a/include/action.inc.php b/include/action.inc.php index 9e07b2e68..82ee6726f 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -47,8 +47,6 @@ function ShowActionList($cn,$retour,$h_url) Titre ou référence: ', - $a); $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; echo JS_SEARCH_CARD; $w=new widget('js_search_only'); @@ -57,7 +55,10 @@ function ShowActionList($cn,$retour,$h_url) $w->label='Quick Code1'; $w->extra='4,9,14,16,8'; $w->table=0; + echo ''; echo $w->IOValue(); + printf ('Titre ou référence: ', + $a); $sp= new widget("span"); @@ -65,15 +66,15 @@ function ShowActionList($cn,$retour,$h_url) ?> -
+ -
- + + @@ -81,10 +82,11 @@ function ShowActionList($cn,$retour,$h_url) + echo $retour; ?> + -
+
d_state=(isset($_POST['d_state']))?$_POST['d_state']:""; $act->ag_ref=""; $act->ag_title=(isset($_POST['ag_title']))?$_POST['ag_title']:""; - echo '
'; + echo '
'; echo JS_SEARCH_CARD; // Add hidden tag echo '
'; @@ -221,10 +224,10 @@ if ( isset ($_POST['add_action_here']) ) echo $act->Display('NEW',false); echo ''; - echo ''; + echo ''; echo $h_url; - echo '

'. + echo '

'. ''. '
'; @@ -237,8 +240,10 @@ if ( isset ($_POST['add_action_here']) ) // permit the update if ( $sub_action=='detail' ) { - echo '
'; + echo '
'; + echo '
'; echo ''; + echo '
'; $act=new action($cn); $act->ag_id=$_REQUEST['ag_id']; echo $act->get(); @@ -254,7 +259,7 @@ if ( $sub_action=='detail' ) $upload->value=""; echo "Enregistrer le fichier ".$upload->IOValue(); echo widget::submit("save","Sauve"); - echo widget::submit("add_action_here","Ajoute une action à celle-ci"); + echo widget::submit("add_action_here","Ajoute une action à celle-ci"); echo ''; echo '
'; echo dossier::hidden(); @@ -321,7 +326,9 @@ if ( $sub_action == "list" ) // Add an action if ( $sub_action == "add_action" ) { + echo '
'; echo ''; + echo '
'; echo_debug('action',__LINE__,var_export($_POST,true)); echo $retour; $act=new action($cn); @@ -349,40 +356,16 @@ if ( $sub_action == "add_action" ) echo $act->Display('NEW',false); echo ''; - echo ''; + echo ''; echo $h_url; - echo '

'. + echo '

'. ''. '
'; } //-------------------------------------------------------------------------------- // Save Action -// Stage 1 : show the result and confirm -//-------------------------------------------------------------------------------- -if ( $sub_action == "save_action_st1" ) -{ - $act=new action($cn); - $act->ag_timestamp=$_POST['ag_timestamp']; - $act->ag_comment=$_POST['ag_comment']; - $act->ag_timestamp=$_POST['ag_timestamp']; - $act->d_state=$_POST['d_state']; - $act->dt_id=$_POST['dt_id']; - $act->qcode_exp=$_POST['qcode_exp']; - $act->qcode_dest=$_POST['qcode_dest']; - $act->f_id_dest=$_POST['f_id_dest']; - $act->f_id_exp=$_POST['f_id_exp']; - - $act->ag_title=$_POST['ag_title']; - $act->d_id=0; - $act->ag_id=$_POST['ag_id']; - $act->ag_ref_ag_id=(isset($_POST['ag_ref_ag_id']))?$_POST['ag_ref_ag_id']:0; - - echo $act->Confirm(); -} -//-------------------------------------------------------------------------------- -// Save Action // Stage 2 : Save the action and propose to save a file //-------------------------------------------------------------------------------- if ( $sub_action == "save_action_st2" ) diff --git a/include/anc_group.inc.php b/include/anc_group.inc.php index 70f6bc9aa..6b6d49b72 100644 --- a/include/anc_group.inc.php +++ b/include/anc_group.inc.php @@ -50,7 +50,7 @@ if ( isset($_POST['add'])) { } $array=$r->myList(); -echo '
'; +echo '
'; echo '
'; echo dossier::hidden(); echo '
'; + if (isset($ret) && $ret == 'label' ){ $slabel=FormatString($l_line['pcm_lib']); - echo ''; - echo ''; + if (isset($ret) && $ret == 'poste' ){ + $ahref=''; + $end_ahref=''; + + } + + echo ""; + echo $ahref; echo $l_line['pcm_val']; + echo $end_ahref; echo ''; + echo $ahref; echo $l_line['pcm_lib']; + echo $end_ahref; echo '
-

Droit par défaut

+

Droit par défaut

get_row( ); if ( count($Fiche->row ) == 0 ) { - echo "Aucune donnée"; + echo "Aucune donnée"; return; } @@ -55,13 +55,13 @@ echo '"Qcode";'. "\"Code interne\";". "\"Date\";". "\"Description\";". -"\"Débit\";". -"\"Crédit\""; +"\"Débit\";". +"\"Crédit\""; printf("\n"); foreach ( $Fiche->row as $op ) { echo '"'.$op['j_qcode'].'";'. '"'.$op['jr_internal'].'"'.";". - '"'.$op['j_date'].'"'.";". + '"'.$op['jr_date'].'"'.";". '"'.$op['description'].'"'.";". sprintf("%8.4f",$op['deb_montant']).";". sprintf("%8.4f",$op['cred_montant']); @@ -69,7 +69,7 @@ printf("\n"); } }else { - echo '"Poste";"Qcode";"internal"'; + echo '"Poste";"Qcode";"internal";'; echo '"Date";'. "\"Description\";". "\"Montant\";". @@ -86,8 +86,8 @@ printf("\n"); $r['j_poste'], $r['j_qcode'], $r['jr_internal'], - $r['j_date'], - $a['description'], + $r['jr_date'], + $r['description'], $r['j_montant'], $r['debit']); printf("\r\n"); @@ -98,7 +98,7 @@ printf("\n"); } } -$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; +$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; $diff=abs($tot_deb-$tot_cred); printf( '"'."$solde_type".'"'.";". diff --git a/html/quick_code_pdf.php b/html/quick_code_pdf.php index 935f92d18..07d661475 100644 --- a/html/quick_code_pdf.php +++ b/html/quick_code_pdf.php @@ -56,7 +56,7 @@ $Libelle=sprintf("(%s) %s ",$Fiche->id,$Fiche->getName()); header_pdf($cn,$pdf); // $pdf->ezText($Libelle,30); $pdf->ezTable($array, - array ('jr_internal'=>'Opération', + array ('jr_internal'=>'Operation', 'j_date' => 'Date', 'jrn_name'=>'Journal', 'description'=>'Description', @@ -65,9 +65,9 @@ $pdf->ezTable($array, ),$Libelle, array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('montant'=> array('justification'=>'right'), - ))); -$str_debit=sprintf("Débit % 12.2f",$tot_deb); -$str_cred=sprintf("Crédit % 12.2f",$tot_cred); + )),true); +$str_debit=utf8_decode(sprintf("Débit % 12.2f",$tot_deb)); +$str_cred=utf8_decode(sprintf("Crédit % 12.2f",$tot_cred)); $diff_solde=$tot_deb-$tot_cred; if ( $diff_solde < 0 ) { $solde=" C "; diff --git a/html/remove_op.php b/html/remove_op.php index 9fd285809..9eaff8263 100644 --- a/html/remove_op.php +++ b/html/remove_op.php @@ -34,6 +34,6 @@ require_once('class_dossier.php'); $gDossier=dossier::id(); /*!\todo Add the security here */ $cn=DbConnect($gDossier); -ExecSql($cn,"delete from operation_analytique where oa_group=".$_GET['oa']); +ExecSqlParam($cn,"delete from operation_analytique where oa_group=$1",array($_GET['oa'])); echo_debug(__FILE__,__LINE__,$_GET); ?> diff --git a/html/sec_pdf.php b/html/sec_pdf.php index 3752f4148..04160b08a 100755 --- a/html/sec_pdf.php +++ b/html/sec_pdf.php @@ -30,7 +30,7 @@ include_once("ac_common.php"); include_once("postgres.php"); include_once("class.ezpdf.php"); require_once("check_priv.php"); -echo_debug('sec_pdf.php',__LINE__,"imp pdf securité"); +echo_debug('sec_pdf.php',__LINE__,"imp pdf securité"); $cn=DbConnect($gDossier); //----------------------------------------------------- // Security @@ -65,7 +65,7 @@ $str_user=sprintf("( %d ) %s %s [ %s ]", $pdf->ezText($str_user,14,array('justification'=>'center')); if ( $SecUser->active==0) - $pdf->ezText('Bloqué',12,array('justification'=>'center')); + $pdf->ezText('Bloqué',12,array('justification'=>'center')); if ( $SecUser->admin==1) $pdf->ezText('Administrateur',12,array('justification'=>'center')); @@ -78,7 +78,7 @@ for ($e=0;$e < pg_NumRows($Res);$e++) { $priv=CheckJrn($gDossier,$SecUser->login,$row['jrn_def_id']); switch($priv) { case 0: - $a_jrn[$e]['priv']="pas d'accès"; + $a_jrn[$e]['priv']="pas d'accès"; break; case 1: $a_jrn[$e]['priv']="lecture"; @@ -92,7 +92,7 @@ for ($e=0;$e < pg_NumRows($Res);$e++) { } $pdf->ezTable($a_jrn, array ('jrn_name'=>' Journal', - 'priv'=>'Privilège')," ", + 'priv'=>'Privilège')," ", array('shaded'=>0,'showHeadings'=>1,'width'=>500)); //----------------------------------------------------- @@ -108,18 +108,18 @@ for ( $i =0 ; $i < $Max; $i++ ) { $right=check_action($gDossier,$SecUser->login,$l_line['ac_id']); switch ($right) { case 0: - $action['priv']="Pas d'accès"; + $action['priv']="Pas d'accès"; break; case 1: case 2: - $action['priv']="Accès"; + $action['priv']="Accès"; break; } $a_action[$i]=$action; } $pdf->ezTable($a_action , array ('lib'=>'Description', - 'priv'=>'Privilège')," ", + 'priv'=>'Privilège')," ", array('shaded'=>0,'showHeadings'=>1,'width'=>500)); diff --git a/html/send_jrn_pdf.php b/html/send_jrn_pdf.php index 318c273f9..6039e24c9 100644 --- a/html/send_jrn_pdf.php +++ b/html/send_jrn_pdf.php @@ -39,10 +39,10 @@ echo_debug('send_jrn_pdf.php',__LINE__,"imp pdf journaux"); $l_Db=sprintf("dossier%d",$gDossier); $cn=DbConnect($gDossier); $l_type="JRN"; -$centr=" Non centralisé"; +$centr=" Non centralisé"; $l_centr=0; if ( isset ($_POST['central']) ) { - $centr=" centralisé "; + $centr=" centralisé "; $l_centr=1; } $oJrn=new Acc_Ledger($cn,$_GET['p_id']); @@ -78,20 +78,20 @@ while (1) { $pdf->ezText($name_jrn,30); if ( $l_centr == 1 ) { - // si centralisé montre les montants de rappel - $str_debit=sprintf( "report Débit % 10.2f",$rap_deb); - $str_credit=sprintf("report Crédit % 10.2f",$rap_cred); + // si centralisé montre les montants de rappel + $str_debit=sprintf( "report Débit % 10.2f",$rap_deb); + $str_credit=sprintf("report Crédit % 10.2f",$rap_cred); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); } $pdf->ezTable($a_jrn, - array ('internal'=>'Opération', + array ('internal'=>'Opération', 'j_date' => 'Date', 'poste'=>'Poste', 'description' => 'Description', - 'deb_montant'=> 'Débit', - 'cred_montant'=>'Crédit')," ", + 'deb_montant'=> 'Débit', + 'cred_montant'=>'Crédit')," ", array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('deb_montant'=> array('justification'=>'right'), 'cred_montant'=> array('justification'=>'right')))); @@ -101,8 +101,8 @@ while (1) { foreach ($apage as $key=>$element) echo_debug('send_jrn_pdf.php',__LINE__,"apage $key => $element"); $pdf->ezTable($apage, array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", + 'deb'=> 'Total Débit', + 'cred'=>'Total Crédit')," ", array('shaded'=>0,'showHeadings'=>1,'width'=>200, 'xPos'=>'right','xOrientation'=>'left', 'cols'=>array('deb'=> array('justification'=>'right'), @@ -112,10 +112,10 @@ while (1) { $last_id=$a_jrn[$count]['j_id']; $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); if ( $l_centr == 1) { - // Montant de rappel si centralisé + // Montant de rappel si centralisé list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$_GET['filter'],$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); + $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); + $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); } @@ -126,8 +126,8 @@ if ( $a == 1 ) { $apage=array('deb'=>$tot_deb,'cred'=>$tot_cred); $pdf->ezTable($apage, array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", + 'deb'=> 'Total Débit', + 'cred'=>'Total Crédit')," ", array('shaded'=>0,'showHeadings'=>1,'width'=>500, 'cols'=>array('deb'=> array('justification'=>'right'), 'cred'=> array('justification'=>'right')))); @@ -136,8 +136,8 @@ $pdf->ezTable($apage, $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$l_GET['filter'],$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); + $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); + $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); $pdf->ezText($str_debit,12,array('justification'=>'right')); $pdf->ezText($str_credit,12,array('justification'=>'right')); diff --git a/html/send_poste_pdf.php b/html/send_poste_pdf.php index 27b37d83a..ba5736926 100644 --- a/html/send_poste_pdf.php +++ b/html/send_poste_pdf.php @@ -62,7 +62,7 @@ for ( $i =0;$iezText($Libelle,30); $pdf->ezTable($array, - array ('jr_internal'=>'Opération', + array ('jr_internal'=>'Opération', 'j_date' => 'Date', 'jrn_name'=>'Journal', 'description'=>'Description', @@ -72,8 +72,8 @@ for ( $i =0;$i0,'showHeadings'=>1,'width'=>500, 'cols'=>array('montant'=> array('justification'=>'right'), ))); -$str_debit=sprintf("Débit % 12.2f",$tot_deb); -$str_cred=sprintf("Crédit % 12.2f",$tot_cred); +$str_debit=sprintf("Débit % 12.2f",$tot_deb); +$str_cred=sprintf("Crédit % 12.2f",$tot_cred); $diff_solde=$tot_deb-$tot_cred; if ( $diff_solde < 0 ) { $solde=" C "; diff --git a/html/show_fiche.php b/html/show_fiche.php index 782f8a888..2eecc58a4 100644 --- a/html/show_fiche.php +++ b/html/show_fiche.php @@ -49,7 +49,7 @@ if ( ! isset ($_REQUEST['q'])) { $cn=DbConnect($gDossier); if ( $User->check_action($cn,FICHE_READ) == 0 ){ /* Cannot Access */ - echo '

Vous n\' avez pas accès

'; + echo '

Vous n\' avez pas accès

'; return; } diff --git a/html/show_tva.php b/html/show_tva.php index 4fa7f4629..2f801fb84 100644 --- a/html/show_tva.php +++ b/html/show_tva.php @@ -32,7 +32,7 @@ $User->Check(); require_once('class_dossier.php'); $gDossier=dossier::id(); -html_page_start($User->theme,"onLoad='window.focus();'"); +html_min_page_start($User->theme,"onLoad='window.focus();'"); ?> '; +echo '
'; +echo widget::hidden('phpsessid',$_REQUEST['PHPSESSID']); +echo dossier::hidden(); +echo 'title :
'; +echo 'desc :
'; +echo 'date :
'; +echo ''; +echo ''; + diff --git a/html/todo_list.php b/html/todo_list.php new file mode 100644 index 000000000..ce51b2c44 --- /dev/null +++ b/html/todo_list.php @@ -0,0 +1,58 @@ +set_parameter('id',$_REQUEST['id']); + $todo->load(); + header("Content-type: text/html; charset: utf8",true); + echo $todo->toJSON(); + exit(); +} + /*!\todo needs security for the users */ +if (isset($_REQUEST['del'])) { + $cn=DbConnect(dossier::id()); + $todo=new Todo_list($cn); + $todo->set_parameter('id',$_REQUEST['id']); + $todo->delete(); + exit(); +} diff --git a/html/user_advanced.php b/html/user_advanced.php index 9aa9ea411..083474983 100644 --- a/html/user_advanced.php +++ b/html/user_advanced.php @@ -48,7 +48,7 @@ echo_debug('user_advanced.php',__LINE__,"user is ".$_SESSION['g_user']); include_once ("user_menu.php"); echo '
'; -//echo ShowMenuCompta("user_advanced.php?".dossier::get()); + echo ShowMenuCompta(7); echo '
'; $p_action=""; @@ -56,20 +56,25 @@ $p_action=""; $p_action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:""; switch ($p_action) { - case 'preod': - $high=9; - break; - case 'periode'; - $high=2; +case 'preod': + $high=9; + break; +case 'periode'; +$high=2; +break; +case 'verif'; +$high=10; +break; +case 'central'; +$high=3; break; - case 'verif'; - $high=10; - break; - case 'central'; - $high=3; - break; - - default: +case 'defreport': + $high=6; + break; +case 'ouv': + $high=8; + break; +default: $high=0; } @@ -87,84 +92,8 @@ if ($p_action == "periode" ) { //-------------------------------------------------- if ($p_action=="preod") { - echo '
'; - echo '
'; - $sel=new widget('select'); - $sel->name="jrn"; - $sel->value=make_array($cn,"select jrn_def_id,jrn_def_name from ". - " jrn_def order by jrn_def_name"); - // Show a list of ledger - $sa=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; - $sel->selected=$sa; - echo 'Choississez un journal '.$sel->IOValue(); - $wCheck=new widget("checkbox"); - if ( isset($_REQUEST['direct'])) { - $wCheck->selected=true; - } - echo 'Ecriture directe'.$wCheck->IOValue('direct'); + require_once('preod.inc.php'); - echo dossier::hidden(); - $hid=new widget("hidden"); - echo $hid->IOValue("sa","jrn"); - echo $hid->IOValue("p_action","preod"); - echo '
'; - echo widget::submit('Accepter','Accepter'); - echo ''; - - // if $_REQUEST[sa] == del delete the predefined operation - if ( $sa == 'del') { - $op=new Pre_operation($cn); - $op->od_id=$_REQUEST['od_id']; - $op->delete(); - $sa='jrn'; - } - - // if $_REQUEST[sa] == jrn show the predefined operation for this - // ledger - if ( $sa == 'jrn' ) { - $op=new Pre_operation($cn); - $op->set_jrn($_GET['jrn']); - if ( isset($_GET['direct'])) { - $op->od_direct='true'; - } else { - $op->od_direct='false'; - } - $array=$op->get_list_ledger(); - if ( empty($array) == true ) { - echo "Aucun enregistrement"; - exit(); - } - - echo '
'; - $count=0; - foreach ($array as $row ) { - - if ( $count %2 == 0 ) - echo ''; - else - echo ''; - echo ''; - echo ''; - echo ''; - - } - echo '
'.$row['od_name'].''; - echo '
'; - echo dossier::hidden(); - echo $hid->IOValue("sa","del"); - echo $hid->IOValue("p_action","preod"); - echo $hid->IOValue("del",""); - echo $hid->IOValue("od_id",$row['od_id']); - echo $hid->IOValue("jrn",$_GET['jrn']); - - $b=''; - echo $b; - echo '
'; - - echo '
'; - } - echo ''; exit(); } //---------------------------------------------------------------------- @@ -178,5 +107,14 @@ if ( $p_action=='central') require_once ('central.inc.php'); +if ($p_action=='defreport') { + require_once('report.inc.php'); +} +/* -------------------------------------------------- +Import writing (opening exercice) +-------------------------------------------------- */ +if ( $p_action == 'ouv') { + require_once('opening.inc.php'); +} html_page_stop(); ?> diff --git a/html/user_jrn.php b/html/user_jrn.php index 70a0c0c7d..5cdc24e78 100644 --- a/html/user_jrn.php +++ b/html/user_jrn.php @@ -31,7 +31,7 @@ include_once ("postgres.php"); include_once ("check_priv.php"); include_once ("class_widget.php"); require_once("jrn.php"); - +echo '

OBSOLETE FILES USER_JRN.PHP

'; // Check if dossier set $gDossier=dossier::id(); diff --git a/html/user_login.php b/html/user_login.php index 40fbe5f86..4835d9400 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -29,17 +29,46 @@ include_once ("class_user.php"); $User=new User($rep); $User->Check(); -html_page_start($_SESSION['g_theme']); +html_min_page_start($_SESSION['g_theme']); include_once("user_menu.php"); $priv=($User->admin==1)?"Administrateur":"Utilisateur"; +echo '
'; -echo '
Bienvenue '.$User->first_name.' '. - $User->name.',

Vous êtes un '. $priv.'
Selectionnez votre dossier

'; -// Show default menu (preference,...) +$result=""; +$result.=''; +if ( $User->Admin() == 1 ) { + $result.=""; +} +$result.=''; +$result.=''; +$result.=''; +$result.=""; +$result.="
Administration Aide PréférenceDeconnexion
"; + +echo '

Bienvenue '.$User->first_name.' '.$User->name." dans PhpCompta

"; +echo '
Choississez votre dossier'; +echo ''.$result.''; +echo '
'; +?> +
+ +IOValue('p_nom',$p_nom); + +?> +Donnez une partie du nom du dossier à rechercher +
+admin); +$res=u_ShowDossier($_SESSION['g_user'],$User->admin,$filtre); echo $res; ?>

diff --git a/html/user_pref.php b/html/user_pref.php index 0810773f3..547095c98 100644 --- a/html/user_pref.php +++ b/html/user_pref.php @@ -66,6 +66,17 @@ if ( isset ( $_POST['p_size']) ) { } +// Topmenu +//--------------------------------------------------------------------------- +// Here we put all the changes +//--------------------------------------------------------------------------- +if ( isset ($_POST['val']) ){ + // Change the top menu + $_SESSION['g_topmenu']=$_POST['topmenu']; + $User->update_global_pref('TOPMENU',$_POST['topmenu']); + if ( isset ($_POST['minirap'])) $User->set_mini_report($_POST['minirap']); +} + // show the top menu depending of the use_style // comta style @@ -75,7 +86,6 @@ if ( isset ($_REQUEST['gDossier']) ) if ( $_REQUEST['gDossier'] != 0 ) { echo '

'; - // echo ShowMenuCompta(); echo menu_tool('pref'); echo "
"; } diff --git a/html/user_sec.php b/html/user_sec.php index 963b33e24..5bef4e38b 100644 --- a/html/user_sec.php +++ b/html/user_sec.php @@ -150,7 +150,7 @@ if ( $action == "view" ) { if ( $MaxUser == 0 ) return; $l2_line=pg_fetch_array($User,0); - printf ('

Détail utilisateur %s %s (%s)

', + printf ('

Détail utilisateur %s %s (%s)

', $l2_line['use_first_name'], $l2_line['use_name'], $l2_line['use_login']); @@ -185,21 +185,21 @@ if ( $action == "view" ) { } else $right = 3; if ( $right == 0 ) { echo "
"; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Lecture Ecriture Pas d\'accès Pas d\'accès"; echo "Lecture "; echo " Ecriture Pas d\'accès Pas d\'accès Lecture"; @@ -208,7 +208,7 @@ if ( $action == "view" ) { } if ( $right == 3 ) { - echo ' Pas d\'accès Pas d\'accès Lecture "; @@ -246,16 +246,16 @@ if ( $action == "view" ) { } if ( $right == 0 ) { echo ""; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Accès Accès Pas d\'accès Pas d\'accès "; - echo "Accès "; + echo "Accès "; echo " Change "; - echo "Accès "; + echo "Accès "; echo "
'; diff --git a/include/anc_imp.inc.php b/include/anc_imp.inc.php index 2322793f5..fc7a13940 100644 --- a/include/anc_imp.inc.php +++ b/include/anc_imp.inc.php @@ -38,7 +38,7 @@ $menu=array(array("?p_action=ca_imp&sub=listing&$str_dossier","Listing","Listing array("?p_action=ca_imp&sub=bc2&$str_dossier","Balance croisé","Balance croisé de 2 plans analytiques","bc2") ); $sub=(isset($_GET['sub']))?$_GET['sub']:'no'; -echo '
'; +echo '
'; echo ShowItem($menu,"H","mtitle","mtitle",$sub); echo '
'; $hidden=new widget("hidden"); diff --git a/include/anc_od.inc.php b/include/anc_od.inc.php index f7c9823ac..ee7bbe649 100644 --- a/include/anc_od.inc.php +++ b/include/anc_od.inc.php @@ -43,7 +43,7 @@ if ( ! $m ) { echo '

Aucun plan analytique défini

' // show the left menu //---------------------------------------------------------------------- echo ' -
+
diff --git a/include/argenta_be.inc.php b/include/argenta_be.inc.php index 61f5bd2bd..9c16431d6 100644 --- a/include/argenta_be.inc.php +++ b/include/argenta_be.inc.php @@ -22,6 +22,8 @@ * \brief This file must be included to parse the CVS from the CBC Bank */ + + //----------------------------------------------------- // Bank Argenta //----------------------------------------------------- @@ -65,10 +67,10 @@ while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) { //---------------------------------------------------- $code=FormatString($code); $num_compte=FormatString($num_compte); - if ( CountSql($p_cn,"select * from import_tmp where code='$code' and num_compte='$num_compte' limit 2") != 0 ) + if ( CountSql($p_cn,utf8_encode("select * from import_tmp where code='$code' and num_compte='$num_compte' limit 2")) != 0 ) { /* Skip it it already encoded */ - echo "Doublon éliminé ".$detail; + echo "Doublon éliminé ".$detail; echo "
"; continue; } @@ -102,13 +104,13 @@ echo "
"; 'n')"; try { - ExecSql($p_cn,$Sql); + ExecSql($p_cn,$Sql,'latin1'); } catch(Exception $e) { - echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage); + echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode()." msg ".$e->getMessage()); rollback($p_cn); break; } diff --git a/include/balance.inc.php b/include/balance.inc.php index bc7342586..93f414604 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -33,7 +33,7 @@ include_once("class_acc_balance.php"); $User->can_request($cn,BALANCE); -echo '
'; +echo '
'; // Show the form for period echo ''; @@ -49,7 +49,7 @@ if ( isset ($_POST['from_periode']) ) $w->selected=$_POST['from_periode']; echo $w->IOValue('from_periode',$periode_start); -$w->label=" jusqu'à "; +$w->label=" jusqu'à "; $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); if ( isset ($_POST['to_periode']) ) $w->selected=$_POST['to_periode']; @@ -74,7 +74,7 @@ $to_poste->extra2=null; $to_poste->value=(isset($_POST['to_poste']))?$_POST['to_poste']:""; $to_span=new widget("span","to_poste_label","to_poste_label"); $c=new widget("checkbox"); -$c->label="centralisé"; +$c->label="centralisé"; echo $c->IOValue('central'); echo "
"; @@ -140,7 +140,7 @@ if ( isset($_POST['view'] ) ) { //$per=join(',',$periode); if ( isset($_POST['central']) ) { $bal->central='Y'; - $t_cent="centralisée"; + $t_cent="centralisée"; } else $bal->central='N'; @@ -149,7 +149,7 @@ if ( isset($_POST['view'] ) ) { $_POST['to_periode']); $a=get_periode($cn,$_POST['from_periode']); $b=get_periode($cn,$_POST['to_periode']); - echo "

période du ".$a['p_start']." au ".$b['p_end']."

"; + echo "

période du ".$a['p_start']." au ".$b['p_end']."

"; echo '
'; echo ''; diff --git a/include/bank.inc.php b/include/bank.inc.php index 5cf306768..e8b89496d 100644 --- a/include/bank.inc.php +++ b/include/bank.inc.php @@ -24,7 +24,7 @@ require_once('jrn.php'); require_once('class_widget.php'); require_once("class_document.php"); require_once("class_fiche.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once("check_priv.php"); require_once ('class_pre_op_fin.php'); @@ -32,7 +32,7 @@ require_once ('class_pre_op_fin.php'); * \brief the purpose off this file encode expense and to record them * */ - +echo JS_PROTOTYPE; // First we show the menu // If nothing is asked the propose a blank form @@ -81,16 +81,16 @@ if ( $sub_action == "solde" ) // find the bank account // NOTE : those values are in a table because // they are _national_ parameters - $banque=new parm_code($cn,'BANQUE'); - $caisse=new parm_code($cn,'CAISSE'); - $vir_interne=new parm_code($cn,'VIREMENT_INTERNE'); + $banque=new Acc_Parm_Code($cn,'BANQUE'); + $caisse=new Acc_Parm_Code($cn,'CAISSE'); + $vir_interne=new Acc_Parm_Code($cn,'VIREMENT_INTERNE'); $accountSql="select distinct pcm_val::text,pcm_lib from tmp_pcmn where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%' or pcm_val::text like '".$caisse->p_value."%' order by pcm_val::text"; $ResAccount=ExecSql($cn,$accountSql); - echo '
'; + echo '
'; echo "
Poste Comptable
"; // Filter the saldo @@ -130,7 +130,7 @@ if ( $sub_action == "list") ''); echo ''; - echo '
'; + echo '
'; echo ''; @@ -157,7 +157,7 @@ if ( $sub_action == "list") $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; - echo 'Période '.$w->IOValue("p_periode",$periode_start); + echo 'Période '.$w->IOValue("p_periode",$periode_start); $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; echo JS_SEARCH_CARD; $w=new widget('js_search_only'); @@ -233,7 +233,7 @@ if ( $sub_action=="use_opd" ) { ''; $form=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']); - echo '
'; + echo '
'; echo $form; echo '
'; exit(); @@ -260,7 +260,7 @@ if ( isset ($_POST['add_item']) || isset ($_POST['correct']) ) $form=FormFin($cn,$p_jrn,$User->get_periode(),$submit,$_POST,false, $nb_item); //$form=FormFin($cn,$p_jrn,$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; + echo '
'; echo $form; echo JS_CALC_LINE; echo '
'; @@ -284,7 +284,7 @@ if ( isset($_POST['save'])) $form=FormFin($cn,$p_jrn,$User->get_periode(),$submit,$_POST,true,$nb_number,true); - echo '
'; + echo '
'; echo $form; echo '
'; echo ''; @@ -341,7 +341,7 @@ if ( $p_jrn != -1 ) '; // Show an empty form of invoice $form=FormFin($cn,$p_jrn,$User->get_periode(),$submit,null,false,$jrn->GetDefLine('deb')); - echo '
'; + echo '
'; echo $form; echo '
'; $op=new Pre_operation($cn); @@ -356,7 +356,7 @@ if ( $p_jrn != -1 ) echo $hid->IOValue("jrn_type","FIN"); if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); + echo widget::submit('use_opd','Utilisez une op.prédéfinie'); echo $op->show_button(); echo ''; diff --git a/include/bud_detail.inc.php b/include/bud_detail.inc.php index 3c65d5744..135415650 100644 --- a/include/bud_detail.inc.php +++ b/include/bud_detail.inc.php @@ -30,7 +30,7 @@ require_once ('class_widget.php'); require_once ('class_bud_hypo.php'); require_once ('class_anc_account.php'); -echo '
'; +echo '
'; diff --git a/include/bud_sacc.inc.php b/include/bud_sacc.inc.php index f82fb387e..c8eea93d5 100644 --- a/include/bud_sacc.inc.php +++ b/include/bud_sacc.inc.php @@ -25,7 +25,7 @@ */ require_once ('class_bud_synthese_acc.php'); -echo '
'; +echo '
'; $obj=new Bud_Synthese_Acc($cn); $bh_id=(isset($_REQUEST['bh_id']))?$_REQUEST['bh_id']:''; $obj->from_array($_GET); diff --git a/include/bud_sga.inc.php b/include/bud_sga.inc.php index 1cb9ed795..be5e37585 100644 --- a/include/bud_sga.inc.php +++ b/include/bud_sga.inc.php @@ -25,7 +25,7 @@ */ require_once ('class_bud_synthese_hypo.php'); -echo '
'; +echo '
'; $obj=new Bud_Synthese_Hypo($cn); $bh_id=(isset($_REQUEST['bh_id']))?$_REQUEST['bh_id']:''; diff --git a/include/bud_spo.inc.php b/include/bud_spo.inc.php index 8427ecf10..0aa4d34f7 100644 --- a/include/bud_spo.inc.php +++ b/include/bud_spo.inc.php @@ -25,7 +25,7 @@ */ require_once ('class_bud_synthese_anc.php'); -echo '
'; +echo '
'; $obj=new Bud_Synthese_Anc($cn); $bh_id=(isset($_REQUEST['bh_id']))?$_REQUEST['bh_id']:''; diff --git a/include/bud_svglobal.inc.php b/include/bud_svglobal.inc.php index 68b3f217e..3adbad742 100644 --- a/include/bud_svglobal.inc.php +++ b/include/bud_svglobal.inc.php @@ -25,7 +25,7 @@ */ require_once ('class_bud_synthese_group.php'); -echo '
'; +echo '
'; $obj=new Bud_Synthese_Group($cn); $bh_id=(isset($_REQUEST['bh_id']))?$_REQUEST['bh_id']:''; $obj->from_array($_GET); diff --git a/include/cbc_be.inc.php b/include/cbc_be.inc.php index 7a63cd77c..e7160b862 100644 --- a/include/cbc_be.inc.php +++ b/include/cbc_be.inc.php @@ -82,7 +82,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { 'n')"; try { - ExecSql($p_cn,$Sql) ; + ExecSql($p_cn,$Sql,'latin1') ; } catch(Exception $e) { @@ -94,5 +94,5 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $row++; } // file is read fclose($handle); -echo "Encore rien désolé"; +echo "Encore rien désolé"; ?> diff --git a/include/central.inc.php b/include/central.inc.php index e82a6fb9f..3ff641b3e 100644 --- a/include/central.inc.php +++ b/include/central.inc.php @@ -58,7 +58,7 @@ if ( $_POST["periode"] != "" ) { if ($ret==NOERROR) { echo '

La période '.$_POST["periode"].' est centralisée

'; } else { - echo '

La période '.$_POST["periode"].' n\' a pu être centralisée

'; + echo '

La période '.$_POST["periode"].' n\' a pu être centralisée

'; } } }// if ( isset ($_POST["central"] )) @@ -72,7 +72,7 @@ if ( $ret != null) { echo ''; echo ''; } else { - echo '

Aucune période à centraliser

'; + echo '

Aucune période à centraliser

'; } echo "
"; diff --git a/include/check_priv.php b/include/check_priv.php index 48e3a4aed..5207c2a2a 100644 --- a/include/check_priv.php +++ b/include/check_priv.php @@ -27,7 +27,7 @@ include_once("postgres.php"); /*! - * \brief Vérifie les acces d'un utilisateur + * \brief Vérifie les acces d'un utilisateur * sur un journal * * \param $p_dossier le dossier @@ -37,7 +37,7 @@ include_once("postgres.php"); * \return * - 0 pas d'acces * - 1 Lecture - * - 2 écriture + * - 2 écriture * */ @@ -72,14 +72,14 @@ function CheckJrn($p_dossier,$p_user,$p_jrn,$p_detail=False) } - // droit spécifique + // droit spécifique $Res2=ExecSql($cn,"select jrn_def_id,uj_priv from jrn_def left join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='$p_user' and jrn_def_id=$p_jrn"); $PrivJrn=pg_NumRows($Res2); $cn=DbConnect(); - // droit par défaut + // droit par défaut $Res=ExecSql($cn," select * from ac_users left join jnt_use_dos using (use_id) left join priv_user on (priv_jnt=jnt_id) @@ -88,17 +88,17 @@ function CheckJrn($p_dossier,$p_user,$p_jrn,$p_detail=False) $DefRight=pg_NumRows($Res); echo_debug ("PrivJrn = $PrivJrn DefRight $DefRight"); - // Si les droits par défaut == 0, alors user n'a pas accès au dossier + // Si les droits par défaut == 0, alors user n'a pas accès au dossier if ( $DefRight == 0 ) return 0; $Def=pg_fetch_array($Res,0); - // Si les droits par défaut == NO, alors user n'a pas accès au dossier + // Si les droits par défaut == NO, alors user n'a pas accès au dossier if ( $Def['priv_priv'] == "NO" ) return 0; if ( $Def['priv_priv'] == "W") { - // Si droit pas défaut == écriture + // Si droit pas défaut == écriture if ( $PrivJrn == 0 ) { - // Pas de droit spécifique sur jrn => droit par défaut = W + // Pas de droit spécifique sur jrn => droit par défaut = W return 2; } $Priv=pg_fetch_array($Res2,0); @@ -111,9 +111,9 @@ function CheckJrn($p_dossier,$p_user,$p_jrn,$p_detail=False) return 0; } if ( $Def['priv_priv'] == "R") { - // Si droit pas défaut == Lire + // Si droit pas défaut == Lire if ( $PrivJrn == 0 ) { - // Pas de droit spécifique sur jrn => droit par défaut = Lire + // Pas de droit spécifique sur jrn => droit par défaut = Lire return 1; } $Priv=pg_fetch_array($Res2,0); diff --git a/include/class_acc_account.php b/include/class_acc_account.php index 91bd08531..dce35de4d 100644 --- a/include/class_acc_account.php +++ b/include/class_acc_account.php @@ -105,9 +105,9 @@ class Acc_Account { } else { $ret='
Solde
'; - $ret.=sprintf ('',$this->pcm_val); + $ret.=sprintf ('',$this->pcm_val); $ret.=""; - $ret.=sprintf('',urldecode($this->pcm_lib)); + $ret.=sprintf('',urldecode($this->pcm_lib)); $ret.= ""; $ret.=sprintf ('',$this->pcm_val_parent); $ret.=''; diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index 7b9c8d3e7..528089752 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -86,9 +86,9 @@ class Acc_Account_Ledger { * \return string with the pcm_lib */ function get_name() { - $ret=pg_exec($this->db, + $ret=ExecSqlParam($this->db, "select pcm_lib from tmp_pcmn where - pcm_val=".$this->id); + pcm_val=$1",array($this->id)); if ( pg_NumRows($ret) != 0) { $r=pg_fetch_array($ret); $this->name=$r['pcm_lib']; @@ -103,8 +103,8 @@ class Acc_Account_Ledger { */ function load() { - $ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent from - tmp_pcmn where pcm_val=".$this->id); + $ret=ExecSqlParam($this->db,"select pcm_lib,pcm_val_parent from + tmp_pcmn where pcm_val=$1",array($this->id)); $r=pg_fetch_all($ret); if ( ! $r ) return false; @@ -250,7 +250,7 @@ function get_solde_detail($p_cond="") { ""; } - $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; + $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; $diff=round(abs($tot_deb-$tot_cred),2); echo "". "". @@ -338,7 +338,7 @@ function get_solde_detail($p_cond="") { $SqlItem="$or pcm_val::text like '$item_cred'"; $or=" or "; } else { - $SqlItem="$or pcm_val = '$item_cred' "; + $SqlItem="$or pcm_val::text = '$item_cred' "; $or=" or "; } $SqlFilter=$SqlFilter.$SqlItem; diff --git a/include/class_acc_compute.php b/include/class_acc_compute.php new file mode 100644 index 000000000..976bc231c --- /dev/null +++ b/include/class_acc_compute.php @@ -0,0 +1,323 @@ +'amount', + 'amount_vat'=>'amount_vat', + 'amount_vat_rate'=>'amount_vat_rate', + 'nd_vat'=>'nd_vat', + 'nd_vat_rate'=>'nd_vat_rate', + 'nd_ded_vat'=>'nd_ded_vat', + 'nd_ded_vat_rate'=>'nd_ded_vat_rate', + 'amount_nd'=>'amount_nd', + 'amount_nd_rate'=>'amount_nd_rate', + 'nd_vat_rate'=>'nd_vat_rate', + 'amount_perso'=>'amount_perso', + 'amount_perso_rate'=>'amount_perso_rate' ); + + */ + + +class Acc_Compute { + private static $variable=array( 'amount'=>'amount', + 'amount_vat'=>'amount_vat', + 'amount_vat_rate'=>'amount_vat_rate', + 'nd_vat'=>'nd_vat', + 'nd_vat_rate'=>'nd_vat_rate', + 'nd_ded_vat'=>'nd_ded_vat', + 'nd_ded_vat_rate'=>'nd_ded_vat_rate', + 'amount_nd'=>'amount_nd', + 'amount_nd_rate'=>'amount_nd_rate', + 'nd_vat_rate'=>'nd_vat_rate', + 'amount_perso'=>'amount_perso', + 'amount_perso_rate'=>'amount_perso_rate' + ); + + private $order; // check that the compute + // function are called in the + // good order + + var $check; // activate the check of the + // order, valid value are + // false or true + function __construct () { + bcscale(4); + foreach (self::$variable as $key=>$value) $this->$key=0; + $this->order=0; + $this->check=true; + } + + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + + + } + public function get_info() { return var_export(self::$variable,true); } + + function compute_vat() { + if ( $this->check && $this->order != 0 ) throw new Exception ('ORDER NOT RESPECTED'); + $this->amount_vat=bcmul($this->amount,$this->amount_vat_rate); + $this->amount_vat=round($this->amount_vat,2); + $this->order=1; + } + /*!\brief Compute the no deductible part of the amount, it reduce + *also the vat + */ + function compute_nd() { + if ( $this->check && $this->order > 2 ) throw new Exception ('ORDER NOT RESPECTED'); + + $this->amount_nd=bcmul($this->amount,$this->amount_nd_rate); + $this->amount_nd=round($this->amount_nd,2); + // the nd part for the vat + $nd_vat=bcmul($this->amount_vat,$this->amount_nd_rate); + $nd_vat=round($nd_vat,2); + + } + function compute_nd_vat() { + if ( $this->check && $this->order > 3 ) throw new Exception ('ORDER NOT RESPECTED'); + $this->order=4; + + if ($this->amount_vat == 0 ) $this->compute_vat(); + $this->nd_vat=bcmul($this->amount_vat,$this->nd_vat_rate); + $this->nd_vat=round($this->nd_vat,2); + } + + function compute_ndded_vat() { + if ( $this->check && $this->order > 4 ) throw new Exception ('ORDER NOT RESPECTED'); + $this->order=5; + + if ($this->amount_vat == 0 ) $this->compute_vat(); + $this->nd_ded_vat=bcmul($this->amount_vat,$this->nd_ded_vat_rate); + $this->nd_ded_vat=round($this->nd_ded_vat,2); + } + + function compute_perso() { + if ( $this->check && $this->order != 1 ) throw new Exception ('ORDER NOT RESPECTED'); + $this->order=2; + if ( $this->amount == 0 ) return; + $this->amount_perso=bcmul($this->amount,$this->amount_perso_rate); + $this->amount_perso=round($this->amount_perso,2); + + + + } + function correct() { + $this->amount=bcsub($this->amount,$this->amount_perso); + // correct the others amount + $this->amount=bcsub($this->amount,$this->amount_nd); + $this->amount_vat=bcsub($this->amount_vat,$this->nd_ded_vat); + $this->amount_vat=round($this->amount_vat,2); + $this->amount_vat=bcsub($this->amount_vat,$this->nd_vat); + $this->amount_vat=round($this->amount_vat,2); + + } + + /*!\brief verify that all the amount are positive or null + * otherwise throw a exception and the sum of amount + vat must + * equal to the sum of all the amount of the current object + * so you have to copy the object before computing anything and pass + * it as parameter + * \param compare with a object copied before computing, if null + * there is no comparison + */ + function verify($p_obj=null) { + foreach (self::$variable as $key=>$value) + if ( $this->$value < 0 ) + throw new Exception ("Montant invalide "); + + if ( $p_obj != null ) { + $sum=0; + foreach ( array( 'amount','amount_vat','amount_nd','nd_vat','amount_perso','nd_ded_vat') as $value) + $sum=bcadd($sum,$this->$value); + if ( $p_obj->amount_vat == 0 ) $p_obj->compute_vat(); + $cmp=bcadd($p_obj->amount,$p_obj->amount_vat); + $diff=bcsub($sum,$cmp); + if ( $diff != 0.0 ) + throw new Exception ("ECHEC VERIFICATION : valeur totale = $sum valeur attendue = $cmp diff = $diff"); + } + } + function display() { + foreach (self::$variable as $key=>$value) { + echo 'key '.$key.' Description '.$value.' value is '.$this->$key.'
'; + } + } + public static function test_me () { + $a=new Acc_Compute(); + echo $a->get_info(); + echo '
'; + + // Compute some operation to see if the computed amount are + // correct + + //Test VAT + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + + echo '

Test VAT

'; + echo '

Data

'; + $a->display(); + + echo '

Result

'; + $a->compute_vat(); + $a->display(); + $a->verify(); + // Test VAT + perso + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('amount_perso_rate',0.5); + echo '

Test VAT + Perso

'; + echo '

Data

'; + $a->display(); + $b=clone $a; + $a->compute_vat(); + $a->compute_perso(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + // TEST VAT + ND + // Test VAT + perso + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('nd_vat_rate',0.5); + $b=clone $a; + echo '

Test VAT + ND VAT

'; + echo '

Data

'; + $a->display(); + $a->compute_vat(); + $a->compute_nd_vat(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + // TEST VAT + ND + // Test VAT + perso + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('nd_vat_rate',0.5); + $a->set_parameter('amount_perso_rate',0.5); + + $b=clone $a; + echo '

Test VAT + ND VAT + perso

'; + echo '

Data

'; + $a->display(); + $a->compute_vat(); + $a->compute_perso(); + $a->compute_nd_vat(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + // TEST VAT + ND + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('amount_nd_rate',0.5); + + $b=clone $a; + echo '

Test VAT + ND

'; + echo '

Data

'; + $a->display(); + $a->compute_vat(); + $a->compute_nd(); + + $a->compute_perso(); + $a->compute_nd_vat(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + // TEST VAT + ND + // + Perso + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('amount_nd_rate',0.5); + $a->set_parameter('amount_perso_rate',0.2857); + $b=clone $a; + echo '

Test VAT + ND + Perso

'; + echo '

Data

'; + $a->display(); + $a->compute_vat(); + $a->compute_nd(); + + $a->compute_perso(); + $a->compute_nd_vat(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + // TEST VAT + ND + // + Perso + $a=new Acc_Compute(); + $a->set_parameter('amount',1.23); + $a->set_parameter('amount_vat_rate',0.21); + $a->set_parameter('nd_ded_vat_rate',0.5); + + $b=clone $a; + echo '

Test VAT + TVA ND DED

'; + echo '

Data

'; + $a->display(); + $a->compute_vat(); + $a->compute_nd(); + + $a->compute_perso(); + $a->compute_nd_vat(); + $a->compute_ndded_vat(); + $a->correct(); + echo '

Result

'; + $a->display(); + $a->verify($b); + + + } + } \ No newline at end of file diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 675b2b50c..faec5338b 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -32,6 +32,7 @@ require_once ('class_acexception.php'); require_once ('class_acc_reconciliation.php'); require_once ('class_periode.php'); require_once ('class_gestion_purchase.php'); +require_once ('class_acc_account.php'); /*!\file * \brief Class for jrn, class acc_ledger for manipulating the ledger @@ -635,14 +636,14 @@ class Acc_Ledger { { if ( $this->id == 0 ) return; - $Res=ExecSql($this->db,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type, + $Res=ExecSqlParam($this->db,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type, jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code, jrn_def_fiche_deb,jrn_def_fiche_deb from jrn_Def - where jrn_def_id=".$this->id); + where jrn_def_id=$1",array($this->id)); $Count=pg_NumRows($Res); if ( $Count == 0 ) { - echo '

Param�tres journaux non trouv�s

'; + echo '

Parametres journaux non trouves

'; return null; } return pg_fetch_array($Res,0); @@ -657,8 +658,8 @@ class Acc_Ledger { function GetDefLine() { $sql_cred='jrn_deb_max_line'; - $sql="select jrn_deb_max_line as value from jrn_def where jrn_def_id=".$this->id; - $r=ExecSql($this->db,$sql); + $sql="select jrn_deb_max_line as value from jrn_def where jrn_def_id=$1"; + $r=ExecSqlParam($this->db,$sql,array($this->id)); $Res=pg_fetch_all($r); echo_debug('class_acc_ledger',__LINE__,$Res); if ( sizeof($Res) == 0 ) return 1; @@ -706,17 +707,16 @@ class Acc_Ledger { /*! * \brief Show a select list of the ledger you can access in * writing, the security is taken in care but show the readable AND - * writable ledger - * \param - * \param - * \param - * - * + * writable ledger. + * \param $p_type = ALL or the type of the ledger (ACH,VEN,FIN,ODS) + * \param $p_access =3 for READ and WRITE, 2 for write and 1 for readonly * \return object widget select */ - function select_ledger() { + function select_ledger($p_type="ALL",$p_access=3) { $user=new User($this->db); - $array=$user->get_ledger(); + $array=$user->get_ledger($p_type,$p_access); + + if ( $array == null ) return null; $idx=0; $ret=array(); @@ -745,9 +745,9 @@ class Acc_Ledger { function get_fiche_def() { $sql="select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred ". " from jrn_def where ". - " jrn_def_id = ".$this->id; + " jrn_def_id = $1 "; - $r=ExecSql($this->db,$sql); + $r=ExecSqlParam($this->db,$sql,array($this->id)); $res=pg_fetch_all($r); if ( empty($res) ) return null; @@ -757,19 +757,15 @@ class Acc_Ledger { /*! * \brief retrieve the jrn_def_class_deb and return it * - * \param - * \param - * \param - * * * \return return an string */ function get_class_def() { $sql="select jrn_def_class_deb ". " from jrn_def where ". - " jrn_def_id = ".$this->id; + " jrn_def_id = $1"; - $r=ExecSql($this->db,$sql); + $r=ExecSqlParam($this->db,$sql,array($this->id)); $res=pg_fetch_all($r); @@ -811,29 +807,30 @@ class Acc_Ledger { $ret.=$hidden->IOValue('e_comm',$desc); $ret.=$hidden->IOValue('jrn_type',$this->get_type()); $ret.=$hidden->IOValue('p_jrn',$this->id); - $ret.=$hidden->IOValue('nb_item',$this->nb); + $ret.=$hidden->IOValue('nb_item',$nb_item); if ( $this->with_concerned==true) { $ret.=$hidden->IOValue('jrn_concerned',$jrn_concerned); } $ret.=dossier::hidden(); $count=0; - for ($i=0;$i<$this->nb;$i++) { + for ($i=0;$i<$nb_item;$i++) { $ret.="
"; if ( trim(${'qc_'.$i})!="") { $oqc=new fiche($this->db); $oqc->get_by_qcode(${'qc_'.$i},false); $strPoste=$oqc->strAttribut(ATTR_DEF_ACCOUNT); - $ret.="'; + $ret.="'; } if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) != "") { $oposte=new Acc_Account_Ledger($this->db,${'poste'.$i}); $strPoste=$oposte->id; $ret.="'; + $oposte->get_name().$hidden->IOValue('poste'.$i,${'poste'.$i}). + ''; } if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "") @@ -888,13 +885,22 @@ class Acc_Ledger { $ret.=JS_SEARCH_CARD; $ret.=JS_SEARCH_POSTE; $ret.=JS_AJAX_FICHE; + $ret.=JS_PROTOTYPE; + $ret.=JS_INFOBULLE; // $ret.="
Numéro de classe Numéro de classe
Libellé Libellé
Classe Parent
$solde_type
".${'qc_'.$i}.' - '. - $oqc->strAttribut(ATTR_DEF_NAME).$hidden->IOValue('qc_'.$i,${'qc_'.$i}). - '". + ${'qc_'.$i}.' - '. + $oqc->strAttribut(ATTR_DEF_NAME).$hidden->IOValue('qc_'.$i,${'qc_'.$i}). + '".${"poste".$i}." - ". - $oposte->get_name().$hidden->IOValue('poste'.$i,${'poste'.$i}). - '
"; $ret.= ''; @@ -908,32 +914,39 @@ class Acc_Ledger { $ret.= ''; $ret.= '
'; $wDate=new widget('js_date','Date','date'); $wDate->table=1; $wDate->readonly=$p_readonly; - $wDate->value=(isset($date))?$date:''; + $date=(isset($date)&&trim($date)!='')?$date:''; + if (trim($date)=='') { + $user=new User($this->db); + $periode=new Periode($this->db); + list ($l_date_start,$l_date_end)=$periode->get_date_limit($user->get_periode()); + $date=$l_date_start; + } + $wDate->value=$date; $ret.=$wDate->IOValue(); $ret.= '
'; - // $nb_row=(isset($nb))?$nb:$this->GetDefLine(); - $nb_row=$this->nb; - $hidden=new widget('hidden','nb','nb'); - $hidden->value=$nb_row; - $ret.=$hidden->IOValue(); + $nb_row=(isset($nb_item) )?$nb_item:$this->nb; + + $ret.=widget::hidden('nb_item',$nb_row); $ret.=dossier::hidden(); + $hidden=new widget('hidden'); $ret.=$hidden->IOValue('p_jrn',$this->id); $ret.=$hidden->IOValue('jrn_type',$this->get_type()); - $ret.=''; + $info= widget::infobulle(0); + $info_poste=widget::infobulle(9); + $ret.='
'; $ret.=''. - ''. - ''. + ''. + ''. ''. ''. ''; for ($i = 0 ;$i<$nb_row;$i++){ // Quick Code - $quick_code=new widget('js_search'); + $quick_code=new widget('js_search_only'); $quick_code->name='qc_'.$i; $quick_code->value=(isset(${'qc_'.$i}))?${'qc_'.$i}:""; $quick_code->readonly=$p_readonly; - $quick_code->extra2=$this->id; + $quick_code->extra2='QuickCode?'; $quick_code->extra='filter'; - $qc_span=new widget('span','','qc_'.$i.'_label'); + $label=''; + if ( $quick_code->value != '' ) { + $Fiche=new fiche($this->db); + $Fiche->get_by_qcode($quick_code->value); + $label=$Fiche->strAttribut(ATTR_DEF_NAME); + } + $qc_span=new widget('span','','qc_'.$i.'_label',$label); // Account $poste=new widget('js_search_poste'); @@ -942,9 +955,15 @@ class Acc_Ledger { $poste->readonly=$p_readonly; $poste->extra=$this->id; $poste->extra2=$this->get_class_def(); + $label=''; + if ( $poste->value != '' ) { + $Poste=new Acc_Account($this->db); + $Poste->id=$poste->value; + $label=$Poste->get_lib(); + } - $poste_span=new widget('span','','poste'.$i.'_label'); + $poste_span=new widget('span','','poste'.$i.'_label',$label); // Amount $amount=new widget('text'); @@ -1028,7 +1047,7 @@ class Acc_Ledger { throw new AcException('Periode fermee',6); } - for ($i=0;$i<$this->nb;$i++) + for ($i=0;$i<$nb_item;$i++) { $err=0; @@ -1036,9 +1055,6 @@ class Acc_Ledger { if ( ! isset (${'amount'.$i})) continue; - if ( isNumber(${'amount'.$i} ) == 0 ) - throw new AcException('Montant invalide',3); - $amount=round(${'amount'.$i},2); $tot_deb+=(isset(${'ck'.$i}))?$amount:0; $tot_cred+=(! isset(${'ck'.$i}))?$amount:0; @@ -1047,17 +1063,23 @@ class Acc_Ledger { if ( isset (${'qc_'.$i}) && trim(${'qc_'.$i}) !="") { $f=new fiche($this->db); $f->quick_code=${'qc_'.$i}; - if ( $f->belong_ledger($p_jrn) < 0 ) throw new AcException("La fiche quick_code = ". $f->quick_code." n\'est pas dans ce journal",4); + if ( strlen(trim(${'qc_'.$i}))!=0 && isNumber(${'amount'.$i} ) == 0 ) + throw new AcException('Montant invalide',3); + } // Check if the account is permitted - if ( isset (${'poste'.$i})) { + if ( isset (${'poste'.$i}) && strlen (trim(${'poste'.$i})) != 0 ) { $p=new Acc_Account_Ledger($this->db,${'poste'.$i}); if ( $p->belong_ledger ($p_jrn) < 0 ) throw new AcException("Le poste ".$p->id." n\'est pas dans ce journal",5); + if ( strlen(trim(${'poste'.$i}))!=0 && isNumber(${'amount'.$i} ) == 0 ) + throw new AcException('Montant invalide',3); + + } @@ -1065,8 +1087,8 @@ class Acc_Ledger { $tot_deb=round($tot_deb,4); $tot_cred=round($tot_cred,4); if ( $tot_deb != $tot_cred ) { - print_r('$tot_deb'.$tot_deb); - print_r('$tot_cred'.$tot_cred); + /* print_r('$tot_deb'.$tot_deb); + print_r('$tot_cred'.$tot_cred); */ throw new AcException("Balance incorrecte debit = $tot_deb credit=$tot_cred ",1); } @@ -1112,9 +1134,10 @@ class Acc_Ledger { $group=NextSequence($this->db,"s_oa_group"); $own=new own($this->db); $tot_amount=0; - + $tot_deb=0; + $tot_cred=0; $count=0; - for ($i=0;$i<$this->nb;$i++) + for ($i=0;$i<$nb_item;$i++) { if ( ! isset (${'qc_'.$i}) && ! isset(${'poste'.$i})) continue; @@ -1140,7 +1163,8 @@ class Acc_Ledger { $acc_op->qcode=$quick_code; $j_id=$acc_op->insert_jrnx(); $tot_amount+=round($acc_op->amount,2); - + $tot_deb+=($acc_op->type=='d')?$acc_op->amount:0; + $tot_cred+=($acc_op->type=='c')?$acc_op->amount:0; if ( $own->MY_ANALYTIC != "nu" ) { if ( ereg("^[6,7]+",$poste)) { @@ -1156,8 +1180,9 @@ class Acc_Ledger { $count++; } } - } + }// loop for each item $acc_end=new Acc_Operation($this->db); + $acc_end->amount=$tot_deb; $acc_end->date=$date; $acc_end->desc=$desc; $acc_end->grpt=$seq; @@ -1226,6 +1251,16 @@ class Acc_Ledger { $Ret=CountSql($p_cn,"select * from jrn_def where jrn_def_type='".$p_type."'"); return $Ret+1; } + /*!\brief get the first ledger + *\param the type + *\return the j_id + */ + public function get_first($p_type) { + $user=new User($this->db); + $all=$user->get_ledger($p_type); + return $all[0]; + } + /*! * \brief this function is intended to test this class */ @@ -1267,8 +1302,10 @@ class Acc_Ledger { } if ( isset($_POST['post_id' ])) { + echo ''; echo $a->show_form($_POST,1); + echo widget::button('add','Ajout d\'une ligne','onClick="quick_writing_add_row()"'); echo widget::submit('save_it',"Sauver"); echo ''; exit(); @@ -1309,6 +1346,95 @@ class Acc_Ledger { } } + /*!\brief Update the paiment in the list of operation + *\param $p_array is normally $_GET + */ + function update_paid($p_array) { + // reset all the paid flag because the checkbox is post only + // when checked + foreach ($p_array as $name=>$paid) + { + list($ad) = sscanf($name,"set_jr_id%d"); + if ( $ad == null ) continue; + $sql="update jrn set jr_rapt='' where jr_id=$ad"; + $Res=ExecSql($this->db,$sql); + + } + // set a paid flag for the checked box + foreach ($p_array as $name=>$paid) + { + list ($id) = sscanf ($name,"rd_paid%d"); + + if ( $id == null ) continue; + $paid=($paid=='on')?'paid':''; + $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; + $Res=ExecSql($this->db,$sql); + } + + } + function update_internal_code($p_internal) { + if ( ! isset($this->grpt_id) ) + exit( 'ERREUR '.__FILE__.":".__LINE__); + $Res=ExecSql($this->db,"update jrn set jr_internal='".$p_internal."' where ". + " jr_grpt_id = ".$this->grpt_id); + + } + /*!\brief retrieve all the card for this type of ledger, make them + *into a string separated by comma + *\param none + *\return all the card or null is nothing is found + */ + function get_all_fiche_def() { + $sql="select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred ". + " from jrn_def where ". + " jrn_def_type = $1 "; + + $r=ExecSqlParam($this->db,$sql,array($this->type)); + + $res=pg_fetch_all($r); + if ( empty($res) ) return null; + $card=""; + $comma=''; + foreach ($res as $item ) { + if ( strlen(trim($item['deb'])) != 0 ) { + $card.=$comma.$item['deb']; + $comma=','; + } + if ( strlen(trim($item['cred'])) != '') { + $card.=$comma.$item['cred']; + $comma=','; + } + + } + + return $card; + } + /*!\brief get the saldo of an exercice, used for the opening of a folder + *\param $p_exercice is the exercice we want + *\return an array + * index = + * - solde (debit > 0 ; credit < 0) + * - j_poste + * - j_qcode + */ + function get_saldo_exercice($p_exercice) { + $sql="select sum(a.montant) as solde, j_poste, j_qcode + from + (select j_id, case when j_debit='t' then j_montant + else j_montant * (-1) end as montant + from jrnx) as a + join jrnx using (j_id) + join parm_periode on (j_tech_per = p_id ) + where + p_exercice=$1 + and j_poste::text not like '7%' + and j_poste::text not like '6%' + group by j_poste,j_qcode + having (sum(a.montant) != 0 )"; + $res=get_array($this->db,$sql,array($p_exercice)); + return $res; + } + } diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php new file mode 100644 index 000000000..b44b0d1ec --- /dev/null +++ b/include/class_acc_ledger_fin.php @@ -0,0 +1,725 @@ +is_closed($periode)==1 ) + { + throw new AcException('Periode fermee',6); + } + + /* check that the datum is in the choosen periode */ + $per=new Periode($this->db); + list ($min,$max)=$per->get_date_limit($periode); + if ( cmpDate($e_date,$min) < 0 || + cmpDate($e_date,$max) > 0) + throw new AcException('Date et periode ne correspondent pas',6); + $fiche=new fiche($this->db); + $fiche->get_by_qcode($e_bank_account); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.$e_bank_account.'n\'a pas de poste comptable',8); + + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.$e_bank_account.' le poste comptable ['.$poste->id.'] n\'existe pas',9); + } + + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode($e_bank_account); + if ( $fiche->belong_ledger($p_jrn,'deb') !=1 ) + throw new AcException('La fiche '.$e_bank_account.'n\'est pas accessible à ce journal',10); + + $nb=0; + $tot_amount=0; + //---------------------------------------- + // foreach item + //---------------------------------------- + for ($i=0;$i< $nb_item;$i++) { + if ( strlen(trim(${'e_other'.$i}))== 0) continue; + /* check if amount are numeric and */ + if ( isNumber(${'e_other'.$i.'_amount'}) == 0 ) + throw new AcException('La fiche '.${'e_other'.$i}.'a un montant invalide ['.${'e_other'.$i}.']',6); + + /* compute the total */ + $tot_amount+=round(${'e_other'.$i.'_amount'},2); + + /* check if all card has a ATTR_DEF_ACCOUNT*/ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${'e_other'.$i}); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.${'e_other'.$i}.'n\'a pas de poste comptable',8); + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.${'e_other'.$i}.' le poste comptable ['.$poste->id.'n\'existe pas',9); + } + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode(${'e_other'.$i}); + if ( $fiche->belong_ledger($p_jrn,'cred') !=1 ) + throw new AcException('La fiche '.${'e_other'.$i}.'n\'est pas accessible à ce journal',10); + $nb++; + } + if ( $nb == 0 ) + throw new AcException('Il n\'y a aucune opération',12); + + /* Check if the last_saldo and first_saldo are correct */ + if ( strlen(trim($last_sold)) != 0 && isNumber($last_sold) && + strlen(trim($first_sold)) != 0 && isNumber($first_sold)) + { + $diff=$last_sold-$first_sold; + $diff=round($diff,2); + if ( $first_sold != 0 && $last_sold !=0) { + if ( $tot_amount != $diff ) + throw new AcException('Le montant de l\'extrait est incorrect'. + $tot_amount.' extrait '.$diff,13); + } + } + + } + + + /*!\brief + *\param $p_array contains the value usually it is $_POST + *\return string with html code + *\note the form tag are not set here + */ + function display_form($p_array=null) { + if ( $p_array != null) + extract ($p_array); + $pview_only=false; + $user = new User($this->db); + + // The first day of the periode + $pPeriode=new Periode($this->db); + list ($l_date_start,$l_date_end)=$pPeriode->get_date_limit($user->get_periode()); + + $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date; + $ext_no=( ! isset($ext_no) ) ?'':$ext_no; + + $r=""; + + $r.=JS_INFOBULLE; + $r.=JS_SEARCH_CARD; + $r.=JS_AJAX_FICHE; + $r.=JS_CONCERNED_OP; + + $r.=dossier::hidden(); + $r.=widget::hidden('phpsessid',$_REQUEST['PHPSESSID']); + //$r.=widget::hidden('p_jrn',$this->id); + $r.='
Banque, caisse '; + $r.='
QuickcodePosteQuickcode'.$info.'Poste'.$info_poste.' MontantDébit
'; + // Date + //-- + $Date=new widget("js_date"); + $Date->SetReadOnly($pview_only); + $Date->table=1; + $Date->tabindex=1; + $r.=""; + $r.=$Date->IOValue("e_date",$op_date,"Date"); + // Periode + //-- + $l_user_per=$user->get_periode(); + $l_form_per=FormPeriode($this->db,$l_user_per,OPEN); + $r.=""; + $r.=""; + // Ledger (p_jrn) + //-- + $wLedger=$this->select_ledger('FIN',2); + if ($wLedger == null) exit ('Pas de journal disponible'); + $wLedger->table=1; + $wLedger->label=" Journal ".widget::infobulle(2) ; + $r.=''; + $r.=$wLedger->IOValue(); + $r.=''; + + //retrieve bank name + $e_bank_account=( isset ($e_bank_account) )?$e_bank_account:""; + $e_bank_account_label=""; + + // retrieve e_bank_account_label + if ( $e_bank_account != "" ) { + $fBank=new fiche($this->db); + $fBank->get_by_qcode($e_bank_account); + $e_bank_account_label=$fBank->strAttribut(ATTR_DEF_NAME).' '. + ' Adresse : '.$fBank->strAttribut(ATTR_DEF_ADRESS).' '. + $fBank->strAttribut(ATTR_DEF_CP).' '. + $fBank->strAttribut(ATTR_DEF_CITY).' '; + + } + + $W1=new widget("js_search_only"); + $W1->readonly=$pview_only; + $W1->label="Banque ".widget::infobulle(0); + $W1->name="e_bank_account"; + $W1->value=$e_bank_account; + $W1->extra='deb'; // credits + $W1->extra2="Recherche"; + $W1->table=0; + $r.=""; + + $r.="
"; + $label=widget::infobulle(3); + $r.="Période comptable $label".$l_form_per; + $r.="
".$W1->IOValue(); + $Span=new widget ("span"); + $Span->SetReadOnly($pview_only); + $r.=$Span->IOValue("e_bank_account_label",$e_bank_account_label)."
"; + + $r.=''; + + + + + $r.='
Opérations financières'; + //-------------------------------------------------- + // Saldo begin end + //------------------------------------------------- + $r.='
Extrait de compte'; + $r.=''; + $r.=''; + // Extrait + //-- + $wExt=new widget('TEXT'); + $label=widget::infobulle(5); + $wExt->label='Numéro d\'extrait '.$label; + $wExt->table=1; + $r.=$wExt->IOValue("ext_no",$ext_no); + $label=widget::infobulle(7); + $r.=''; + $wFirst=new widget('text'); + $wFist->table=0; + $first_sold=(isset($first_sold))?$first_sold:""; + $r.=''; + $wLast=new widget('text'); + $wLast->table=1; + $last_sold= isset($last_sold)?$last_sold:""; + $r.=''; + $r.=''; + $r.='
Solde début extrait'.$label.' '.$wFirst->IOValue('first_sold',$first_sold).'Solde fin extrait'.$label.' '.$wLast->IOValue('last_sold',$last_sold).'
'; + $r.='
'; + + //-------------------------------------------------- + // financial operation + //------------------------------------------------- + $r.=''; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=''; + $r.=""; + // Parse each " tiers" + for ($i=0; $i < MAX_ARTICLE; $i++) { + $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""; + $tiers_label=""; + $tiers_amount=(isset(${"e_other$i"."_amount"}))?round(${"e_other$i"."_amount"},2):0; + + $tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:""; + // If $tiers has a value + if ( $tiers != "" ) + { + $fTiers=new fiche($this->db); + $fTiers->get_by_qcode($tiers); + + $tiers_label=$fTiers->strAttribut(ATTR_DEF_NAME); + + } + ${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0; + + $W1=new widget("js_search_only"); + $W1->label=""; + $W1->name="e_other".$i; + $W1->value=$tiers; + $W1->extra='cred'; // credits + $W1->extra2='Recherche'; + $W1->readonly=$pview_only; + $r.=""; + // label + $other=new widget("span"); + $r.=''; + } + $r.="
code".widget::infobulle(0)."CommentaireMontant Op. Concernée(s)
".$W1->IOValue()."'; + $r.=$other->IOValue("e_other$i"."_label", $tiers_label); + // Comment + $wComment=new widget("text"); + $wComment->table=1; + $wComment->size=35; + $wComment->SetReadOnly($pview_only); + $r.=$wComment->IOValue("e_other$i"."_comment",$tiers_comment); + // amount + $wAmount=new widget("text"); + $wAmount->table=1; + $wAmount->size=7; + $wAmount->SetReadOnly($pview_only); + $r.=$wAmount->IOValue("e_other$i"."_amount",$tiers_amount); + // concerned + ${"e_concerned".$i}=(isset(${"e_concerned".$i}))?${"e_concerned".$i}:""; + $wConcerned=new widget("js_concerned"); + $wConcerned->SetReadOnly($pview_only); + $wConcerned->extra=0; + $wConcerned->table=1; + $wConcerned->extra2='paid'; + $r.=$wConcerned->IOValue("e_concerned".$i,${"e_concerned".$i}); + $r.='
"; + + $r.='
'; + + + + return $r; + + } + /*!\brief show the summary before inserting into the database, it + *calls the function for adding a attachment. The function verify + *should be called before + *\param $p_array an array usually is $_POST + *\return string with code html + */ + public function confirm($p_array) { + $r=""; + + extract ($p_array); + $pPeriode=new Periode($this->db); + $pPeriode->id=$periode; + list ($l_date_start,$l_date_end)=$pPeriode->get_date_limit($periode); + $exercice=$pPeriode->get_exercice(); + $r.=''; + $r.='
Banque, caisse '; + $r.=''; + // Date + //-- + $r.=""; + $r.='"; + $r.=""; + // Ledger (p_jrn) + //-- + $r.=''; + $r.=''; + $this->id=$p_jrn; + $r.=''; + $r.=''; + + //retrieve bank name + $e_bank_account=( isset ($e_bank_account) )?$e_bank_account:""; + $e_bank_account_label=""; + + $fBank=new fiche($this->db); + $fBank->get_by_qcode($e_bank_account); + $e_bank_account_label=$fBank->strAttribut(ATTR_DEF_NAME).' '. + ' Adresse : '.$fBank->strAttribut(ATTR_DEF_ADRESS).' '. + $fBank->strAttribut(ATTR_DEF_CP).' '. + $fBank->strAttribut(ATTR_DEF_CITY).' '; + + $filter_year=" and j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')"; + + + $solde=get_solde($this->db,$fBank->strAttribut(ATTR_DEF_ACCOUNT),$filter_year); + $new_solde=$solde; + + $r.="
Date : '.$e_date; + // Periode + //-- + $r.=""; + $r.="Période comptable "; + $r.=$l_date_start.' - '.$l_date_end; + $r.="
Journal '; + $r.=$this->get_name(); + $r.='
Banque "; + $r.=$e_bank_account_label; + + $r.="
"; + + $r.='
'; + + $r.='
Opérations financières'; + //-------------------------------------------------- + // Saldo begin end + //------------------------------------------------- + $r.='
Extrait de compte'; + $r.=''; + $r.=''; + // Extrait + //-- + $r.=''.$ext_no; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.='
Numéro d\'extraitSolde début extrait '.$first_sold.'Solde fin extrait '.$last_sold.'
'; + $r.='
'; + + //-------------------------------------------------- + // financial operation + //------------------------------------------------- + $r.=''; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=''; + $r.=""; + // Parse each " tiers" + $tot_amount=0; + //-------------------------------------------------- + // For each items + //-------------------------------------------------- + for ($i=0; $i < $nb_item; $i++) { + + $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""; + + if ( strlen(trim($tiers))==0)continue; + $tiers_label=""; + $tiers_amount=round(${"e_other$i"."_amount"},2); + $tot_amount=bcadd($tot_amount,$tiers_amount); + $tiers_comment=${"e_other$i"."_comment"}; + // If $tiers has a value + $fTiers=new fiche($this->db); + $fTiers->get_by_qcode($tiers); + + $tiers_label=$fTiers->strAttribut(ATTR_DEF_NAME); + + $r.=""; + // label + $other=new widget("span"); + $r.=''; + // Comment + $r.=''; + // amount + $r.=''; + // concerned + $r.=''; + $r.=''; + } + $r.="
codeCommentaireMontant Op. Concernée(s)
".${'e_other'.$i}."'; + $r.=$fTiers->strAttribut(ATTR_DEF_NAME); + $r.=''.$tiers_comment.''.$tiers_amount.''; + $r.=${"e_concerned".$i}; + $r.='
"; + + // saldo + $r.='
Ancien solde = '.$solde; + $new_solde+=$tot_amount; + $r.='
Nouveau solde = '.$new_solde; + // check for upload piece + $file=new widget("file"); + $file->table=0; + $r.="
Ajoutez une pièce justificative "; + $r.=$file->IOValue("pj",""); + + $r.='
'; + //-------------------------------------------------- + // Hidden variables + //-------------------------------------------------- + $r.=dossier::hidden(); + $r.=widget::hidden('phpsessid',$_REQUEST['PHPSESSID']); + $r.=widget::hidden('p_jrn',$this->id); + $r.=widget::hidden('nb_item',$nb_item); + $r.=widget::hidden('last_sold',$last_sold); + $r.=widget::hidden('first_sold',$first_sold); + $r.=widget::hidden('e_bank_account',$e_bank_account); + $r.=widget::hidden('ext_no',$ext_no); + $r.=widget::hidden('e_date',$e_date); + $r.=widget::hidden('periode',$periode); + $r.=dossier::hidden(); + $r.=widget::hidden('sa','n'); + for ($i=0; $i < $nb_item; $i++) { + $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""; + $r.=widget::hidden('e_other'.$i,$tiers); + $r.=widget::hidden('e_other'.$i.'_comment',${'e_other'.$i.'_comment'}); + $r.=widget::hidden('e_other'.$i.'_amount',${'e_other'.$i.'_amount'}); + $r.=widget::hidden('e_concerned'.$i,${'e_concerned'.$i}); + } + + return $r; + } + /*!\brief save the data into the database, included the attachment, + *and the reconciliations + *\param $p_array usually $_POST + *\return string with HTML code + */ + public function insert($p_array) { + $internal_code=""; + $oid=0; + extract ($p_array); + + // Debit = banque + + $fBank=new fiche($this->db); + $fBank->get_by_qcode($e_bank_account); + // Get the saldo + $pPeriode=new Periode($this->db); + $pPeriode->id=$periode; + $exercice=$pPeriode->get_exercice(); + + $filter_year=" and j_tech_per in (select p_id from parm_periode where p_exercice='".$exercice."')"; + $solde=get_solde($this->db,$fBank->strAttribut(ATTR_DEF_ACCOUNT),$filter_year); + $new_solde=$solde; + + try + { + StartSql($this->db); + $amount=0.0; + // Credit = goods + for ( $i = 0; $i < $nb_item;$i++) { + // if tiers is set and amount != 0 insert it into the database + // and quit the loop ? + if ( strlen(trim(${"e_other$i"}))==0 ) continue; + + $fPoste=new fiche($this->db); + $fPoste->get_by_qcode(${"e_other$i"}); + // round it + ${"e_other$i"."_amount"}=round( ${"e_other$i"."_amount"},2); + + $amount+=${"e_other$i"."_amount"}; + // Record a line for the bank + // Compute the j_grpt + $seq=NextSequence($this->db,'s_grpt'); + + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$fPoste->strAttribut(ATTR_DEF_ACCOUNT); + $acc_operation->amount=${"e_other$i"."_amount"}*(-1); + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='d'; + $acc_operation->periode=$periode; + $acc_operation->insert_jrnx(); + + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$fBank->strAttribut(ATTR_DEF_ACCOUNT); + $acc_operation->amount=${"e_other$i"."_amount"}; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='d'; + $acc_operation->periode=$periode; + $acc_operation->insert_jrnx(); + + + if ( FormatString(${"e_other$i"."_comment"}) == null ) { + // if comment is blank set a default one + $comment="ext :".$ext_no." compte : ".$fBank->strAttribut(ATTR_DEF_NAME).' a '. + $fPoste->strAttribut(ATTR_DEF_NAME); + } else { + $comment='ext: '.$ext_no.' '.${'e_other'.$i.'_comment'}; + } + + + $acc_operation=new Acc_Operation($this->db); + $acc_operation->jrn=$p_jrn; + $acc_operation->amount=abs(${"e_other$i"."_amount"}); + $acc_operation->date=$e_date; + $acc_operation->desc=$comment; + $acc_operation->grpt=$seq; + $acc_operation->periode=$periode; + $jr_id=$acc_operation->insert_jrn(); + + $internal=$this->compute_internal_code($seq); + + + if ( trim(${"e_concerned".$i}) != "" ) { + if ( strpos(${"e_concerned".$i},',') !== 0 ) + { + $aRapt=split(',',${"e_concerned".$i}); + foreach ($aRapt as $rRapt) { + if ( isNumber($rRapt) == 1 ) + { + InsertRapt($this->db,$jr_id,$rRapt); + } + } + } else + if ( isNumber(${"e_concerned".$i}) == 1 ) + { + InsertRapt($this->db,$jr_id,${"e_concerned$i"}); + } + } + + // Set Internal code + $this->grpt_id=$seq; + $this->update_internal_code($internal); + + + + if ( $i == 0 ) + { + // first record we upload the files and + // keep variable to update other row of jrn + if ( isset ($_FILES)) + $oid=save_upload_document($this->db,$seq); + + } else { + if ( $oid != 0 ) + { + ExecSql($this->db,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ". + "jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq"); + } + } + + } // for nbitem + } + catch (Exception $e) + { + echo ''. + 'Erreur dans l\'enregistrement '. + __FILE__.':'.__LINE__.' '. + $e->getMessage(); + Rollback($this->db); + exit(); + + } + Commit($this->db); + $r=""; + $r.="
Ancien solde ".$solde; + $new_solde+=$amount; + $r.="
Nouveau solde ".$new_solde; + return $r; + } + /*!\brief + *\param + *\return + *\note + *\see + *\todo + */ + + + function show_ledger() { + echo dossier::hidden(); + $hid=new widget("hidden"); + + $hid->name="p_action"; + $hid->value="bank"; + echo $hid->IOValue(); + + + $hid->name="sa"; + $hid->value="l"; + echo $hid->IOValue(); + + $User=new User($this->db); + + $w=new widget("select"); + // filter on the current year + $filter_year=" where p_exercice='".$User->get_exercice()."'"; + + $periode_start=make_array($this->db,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); + // User is already set User=new User($this->db); + $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); + $w->selected=$current; + + echo JS_SEARCH_CARD; + echo JS_PROTOTYPE; + echo JS_AJAX_FICHE; + echo '
'; + echo 'Période '.$w->IOValue("p_periode",$periode_start); + $wLedger=$this->select_ledger('fin',3); + if ($wLedger == null) exit ('Pas de journal disponible'); + echo 'Journal '.$wLedger->IOValue(); + $w=new widget('js_search_only'); + $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; + echo dossier::hidden(); + echo widget::hidden('p_action','bank'); + echo widget::hidden('sa','l'); + $w->name='qcode'; + $w->value=$qcode; + $w->label=''; + $this->type='FIN'; + $all=$this->get_all_fiche_def(); + $w->extra=$all; + $w->extra2='QuickCode'; + $sp= new widget("span"); + echo $sp->IOValue("qcode_label","",$qcode); + echo $w->IOValue(); + + echo widget::submit('gl_submit','Rechercher'); + echo '
'; + + // Show list of sell + // Date - date of payment - Customer - amount + if ( $current != -1 ) + { + $filter_per=" and jr_tech_per=".$current; + } + else + { + $filter_per=" and jr_tech_per in (select p_id from parm_periode where p_exercice=". + $User->get_exercice().")"; + } + /* security */ + $available_ledger=" and jr_def_id= ".$this->id." and ".$User->get_ledger_sql(); + + // Show list of sell + // Date - date of payment - Customer - amount + $sql=SQL_LIST_ALL_INVOICE.$filter_per." and jr_def_type='FIN'". + " $available_ledger" ; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + $l=""; + + // check if qcode contains something + if ( $qcode != "" ) + { + // add a condition to filter on the quick code + $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode='$qcode') "; + } + + list($max_line,$list)=ListJrn($this->db,0,"where jrn_def_type='FIN' $filter_per $l $available_ledger " + ,null,$offset,0); + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + + echo "
$bar"; + echo $list; + echo "$bar
"; + + + + + } +} diff --git a/include/class_acc_jrn_info.php b/include/class_acc_ledger_info.php similarity index 97% rename from include/class_acc_jrn_info.php rename to include/class_acc_ledger_info.php index 94e11c1f6..41cd2a56b 100644 --- a/include/class_acc_jrn_info.php +++ b/include/class_acc_ledger_info.php @@ -31,7 +31,7 @@ require_once ('postgres.php'); * the order or other info are going to be stored and used in the detail. * this class maps the table jrn_info */ -class Acc_Jrn_Info { +class Acc_Ledger_Info { var $cn; /*!< connection */ var $ji_id; /*!< primary key */ var $id_type; /*!< type id */ @@ -125,7 +125,7 @@ class Acc_Jrn_Info { $array=pg_fetch_all($r); $ret=array(); foreach ($array as $row) { - $o=new Acc_Jrn_Info($this->cn,$row['ji_id']); + $o=new Acc_Ledger_Info($this->cn,$row['ji_id']); $o->load(); $ret[]=clone $o; } @@ -149,7 +149,7 @@ class Acc_Jrn_Info { static function test_me() { echo "Dossier = ".Dossier::id(); $cn=DbConnect(Dossier::id()); - $a=new Acc_Jrn_Info($cn); + $a=new Acc_Ledger_Info($cn); $a->jr_id=3; $a->id_type='BON_COMMANDE'; $a->ji_value='BON'; diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php new file mode 100644 index 000000000..d06dff611 --- /dev/null +++ b/include/class_acc_ledger_purchase.php @@ -0,0 +1,1000 @@ +is_closed($periode)==1 ) + { + throw new AcException('Periode fermee',6); + } + + /* check that the datum is in the choosen periode */ + $per=new Periode($this->db); + list ($min,$max)=$per->get_date_limit($periode); + if ( cmpDate($e_date,$min) < 0 || + cmpDate($e_date,$max) > 0) + throw new AcException('Date et periode ne correspondent pas',6); + $fiche=new fiche($this->db); + $fiche->get_by_qcode($e_client); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.$e_client.'n\'a pas de poste comptable',8); + + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.$e_client.' le poste comptable ['.$poste->id.'] n\'existe pas',9); + } + + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode($e_client,'cred'); + if ( $fiche->belong_ledger($p_jrn) !=1 ) + throw new AcException('La fiche '.$e_client.'n\'est pas accessible à ce journal',10); + + $nb=0; + + //---------------------------------------- + // foreach item + //---------------------------------------- + for ($i=0;$i< $nb_item;$i++) { + if ( strlen(trim(${'e_march'.$i}))== 0) continue; + /* check if amount are numeric and */ + if ( isNumber(${'e_march'.$i.'_buy'}) == 0 ) + throw new AcException('La fiche '.${'e_march'.$i}.'a un montant invalide ['.${'e_march'.$i}.']',6); + if ( isNumber(${'e_quant'.$i}) == 0 ) + throw new AcException('La fiche '.${'e_march'.$i}.'a une quantité invalide ['.${'e_quant'.$i}.']',7); + + /* check if all card has a ATTR_DEF_ACCOUNT*/ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.${'e_march'.$i}.'n\'a pas de poste comptable',8); + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.${'e_march'.$i}.' le poste comptable ['.$poste->id.'n\'existe pas',9); + } + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->belong_ledger($p_jrn,'deb') !=1 ) + throw new AcException('La fiche '.${'e_march'.$i}.'n\'est pas accessible à ce journal',10); + $nb++; + } + if ( $nb == 0 ) + throw new AcException('Il n\'y a aucune marchandise',12); + } + + public function save() { + echo "

Acc_Ledger_Purchase::save Not implemented

"; + } + + /*!\brief insert into the database, it calls first the verify function + *\param $p_array is usually $_POST or a predefined operation + *\return string + *\note throw an AcException + */ + public function insert($p_array) { + extract ($p_array); + $this->verify($p_array) ; + + $own=new own($this->db); + $group=NextSequence($this->db,"s_oa_group"); /* for analytic */ + $seq=NextSequence($this->db,'s_grpt'); + $this->id=$p_jrn; + $internal=$this->compute_internal_code($seq); + $cust=new fiche($this->db); + $cust->get_by_qcode($e_client); + $poste=$cust->strAttribut(ATTR_DEF_ACCOUNT); + bcscale(4); + try { + $tot_amount=0; + $tot_tva=0; + $tot_debit=0; + StartSql($this->db); + $tot_nd=0; + $tot_perso=0; + $tot_tva_nd=0; + $tot_tva_ndded=0; + + /* Save all the items without vat and no deductible vat and expense*/ + for ($i=0;$i< $nb_item;$i++) { + if ( strlen(trim(${'e_march'.$i})) == 0 ) continue; + if ( ${'e_march'.$i.'_buy'} == 0 ) continue; + if ( ${'e_quant'.$i} == 0 ) continue; + + /* First we save all the items without vat */ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${"e_march".$i}); + + /* tva */ + $idx_tva=${'e_march'.$i.'_tva_id'}; + $oTva=new Acc_Tva($this->db); + $oTva->set_parameter('id',$idx_tva); + $oTva->load(); + + /* We have to compute all the amount thanks Acc_Compute */ + $amount=bcmul(${'e_march'.$i.'_buy'},${'e_quant'.$i}); + $acc_amount=new Acc_Compute(); + $acc_amount->check=false; + $acc_amount->set_parameter('amount',$amount); + $acc_amount->set_parameter('amount_vat_rate',$oTva->get_parameter('rate')); + if ( strlen(trim(${'e_march'.$i.'_tva_amount'})) ==0) { + $acc_amount->compute_vat(); + echo_debug( 'vat is computed = '.$acc_amount->amount_vat); + + } else { + $acc_amount->amount_vat= ${'e_march'.$i.'_tva_amount'}; + echo_debug( 'vat is given = '.$acc_amount->amount_vat); + + } + $tot_tva+=$acc_amount->amount_vat; + + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='d'; + $acc_operation->periode=$periode; + $acc_operation->qcode=""; + + + + + if ( ! $fiche->empty_attribute(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE)) { + $acc_amount->amount_nd_rate=$fiche->strAttribut(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); + $acc_amount->compute_nd(); + $tot_nd+=$acc_amount->amount_nd; + + } + + if ( ! $fiche->empty_attribute(ATTR_DEF_DEP_PRIV)) { + $acc_amount->amount_perso_rate=$fiche->strAttribut(ATTR_DEF_DEP_PRIV); + $acc_amount->compute_perso(); + $tot_perso+=$acc_amount->amount_perso; + } + + if ( ! $fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE)) { + $acc_amount->nd_vat_rate=$fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE); + $acc_amount->compute_nd_vat(); + $tot_tva_nd+=$acc_amount->nd_vat; + /* save op. */ + + } + if ( ! $fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP)) { + $acc_amount->nd_ded_vat_rate=$fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP); + $acc_amount->compute_ndded_vat(); + /* save op. */ + $tot_tva_ndded+=$acc_amount->nd_ded_vat; + } + $acc_amount->correct(); + $tot_amount+=$amount; + + $acc_operation->poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT); + $acc_operation->amount=$acc_amount->amount; + $acc_operation->qcode=${"e_march".$i}; + if( $acc_amount->amount > 0 ) $tot_debit=bcadd($tot_debit,$acc_amount->amount); + + $j_id=$acc_operation->insert_jrnx(); + + /* Compute sum vat */ + + + $tva_item=$acc_amount->amount_vat; + + if (isset($tva[$idx_tva] ) ) + $tva[$idx_tva]+=$tva_item; + else + $tva[$idx_tva]=$tva_item; + + + /* Save the stock */ + /* if the quantity is < 0 then the stock increase (return of + * material) + */ + $nNeg=(${"e_quant".$i}<0)?-1:1; + + // always save quantity but in withStock we can find + // what card need a stock management + + InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'d') ; + + if ( $own->MY_ANALYTIC != "nu" ) + { + // for each item, insert into operation_analytique */ + $op=new Anc_Operation($this->db); + $op->oa_group=$group; + $op->j_id=$j_id; + $op->oa_date=$e_date; + $op->oa_debit=($amount < 0 )?'t':'f'; + echo_debug(__FILE__.':'.__LINE__,"Description is $e_comm"); + $op->oa_description=FormatString($e_comm); + $op->save_form_plan($_POST,$i); + } + // insert into quant_purchase + //----- + + $r=ExecSql($this->db,"select insert_quant_purchase ". + "('".$internal."'". + ",".$j_id. + ",'".${"e_march".$i}."'". + ",".${"e_quant".$i}.",". + round($amount,2). + ",".$acc_amount->amount_vat. + ",".$oTva->get_parameter('id'). + ",".$acc_amount->amount_nd. + ",".$acc_amount->nd_vat. + ",".$acc_amount->nd_ded_vat. + ",".$acc_amount->amount_perso. + ",'".$e_client."')"); + + + } // end loop : save all items + /* save total customer */ + $cust_amount=round(bcadd($tot_amount,$tot_tva),2); + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$poste; + $acc_operation->amount=$cust_amount; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='c'; + $acc_operation->periode=$periode; + $acc_operation->qcode=${"e_client"}; + if ( $cust_amount < 0 ) $tot_debit=bcadd($tot_debit,abs($cust_amount)); + $acc_operation->insert_jrnx(); + /* + * Save all the no deductible + */ + if ( $tot_nd != 0) { + /* save op. */ + $dna=new Acc_Parm_Code($this->db,'DNA'); + $acc_operation->type='d'; + $acc_operation->amount=$tot_nd; + $acc_operation->poste=$dna->p_value; + $acc_operation->qcode=''; + if ( $tot_nd > 0 ) $tot_debit=bcadd($tot_debit,$tot_nd); + $j_id=$acc_operation->insert_jrnx(); + + } + if ( $tot_perso != 0) { + /* save op. */ + $acc_operation->type='d'; + $dna=new Acc_Parm_Code($this->db,'DEP_PRIV'); + $acc_operation->amount=$tot_perso; + $acc_operation->poste=$dna->p_value; + $acc_operation->qcode=''; + if ( $tot_perso > 0 ) $tot_debit=bcadd($tot_debit,$tot_perso); + $j_id=$acc_operation->insert_jrnx(); + + } + if ( $tot_tva_nd != 0) { + /* save op. */ + $acc_operation->type='d'; + $acc_operation->qcode=''; + $dna=new Acc_Parm_Code($this->db,'TVA_DNA'); + $acc_operation->amount=$tot_tva_nd; + $acc_operation->poste=$dna->p_value; + if ( $tot_tva_nd > 0 ) $tot_debit=bcadd($tot_debit,$tot_tva_nd); + $j_id=$acc_operation->insert_jrnx(); + + } + if ( $tot_tva_ndded != 0) { + /* save op. */ + $dna=new Acc_Parm_Code($this->db,'TVA_DED_IMPOT'); + + $acc_operation->type='d'; + $acc_operation->qcode=''; + $acc_operation->amount=$tot_tva_ndded; + $acc_operation->poste=$dna->p_value; + if ( $tot_tva_ndded > 0 ) $tot_debit=bcadd($tot_debit,$tot_tva_ndded); + $j_id=$acc_operation->insert_jrnx(); + + + } + + /* save all vat + * $i contains the tva_id and value contains the vat amount + */ + foreach ($tva as $i => $value) { + $oTva=new Acc_Tva($this->db); + $oTva->set_parameter('id',$i); + $oTva->load(); + + $poste_vat=$oTva->get_side('d'); + + $cust_amount=bcadd($tot_amount,$tot_tva); + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$poste_vat; + $acc_operation->amount=$value; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='d'; + $acc_operation->periode=$periode; + if ( $value > 0 ) $tot_debit=bcadd($tot_debit,$value); + $acc_operation->insert_jrnx(); + + } + /* insert into jrn */ + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->echeance=$e_ech; + $acc_operation->amount=abs(round($tot_debit,2)); + $acc_operation->desc=$e_comm; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->periode=$periode; + $acc_operation->insert_jrn(); + + // Set Internal code + $this->grpt_id=$seq; + $this->update_internal_code($internal); + + /* Save the attachment */ + if ( isset ($_FILES)) { + if ( sizeof($_FILES) != 0 ) + save_upload_document($this->db,$seq); + } + }//end try + catch (Exception $e) + { + echo ''. + 'Erreur dans l\'enregistrement '. + __FILE__.':'.__LINE__.' '. + $e->getMessage(); + Rollback($this->db); + exit(); + } + Commit($this->db); + return $internal; + } + + public function update() { + echo "

Acc_Ledger_Purchase::update Not implemented

"; + } + + public function load() { + echo "

Acc_Ledger_Purchase::load Not implemented

"; + + } + /*!\brief Show all the operation, propose a form to select the + *ledger and the periode + *\return none + *\note echo directly, there is no return with the html code + */ + public function show_ledger() { + $w=new widget("select"); + $User=new User($this->db); + // filter on the current year + $filter_year=" where p_exercice='".$User->get_exercice()."'"; + + $periode_start=make_array($this->db,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); + $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); + $w->selected=$current; + + echo 'Période '.$w->IOValue("p_periode",$periode_start); + $wLedger=$this->select_ledger('ACH',3); + if ($wLedger == null) exit ('Pas de journal disponible'); + echo 'Journal '.$wLedger->IOValue(); + $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; + $this->type='ACH'; + $all=$this->get_all_fiche_def(); + echo JS_SEARCH_CARD; + echo JS_PROTOTYPE; + echo JS_AJAX_FICHE; + $w=new widget('js_search_only'); + $w->name='qcode'; + $w->value=$qcode; + $w->label=''; + $w->extra='filter'; + $w->extra2='QuickCode'; + $w->table=0; + $sp= new widget("span"); + echo $sp->IOValue("qcode_label","",$qcode); + echo $w->IOValue(); + + echo widget::submit('gl_submit','Recherche'); + // Show list of sell + // Date - date of payment - Customer - amount + if ( $current == -1) { + $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; + } else { + $cond=" and jr_tech_per=".$current; + } + + $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$this->id ; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + /* security */ + $available_ledger=$User->get_ledger_sql(); + + $l=""; + // check if qcode contains something + if ( $qcode != "" ) + { + $qcode=Formatstring($qcode); + // add a condition to filter on the quick code + $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode=upper('$qcode')) "; + $sql="where jrn_def_type='ACH' $cond $l and $available_ledger "; + } + + list($max_line,$list)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + + echo "
$bar"; + echo '
'; + echo dossier::hidden(); + $hid=new widget("hidden"); + + echo $list; + if ( $max_line !=0 ) + echo widget::submit('paid','Mise à jour paiement'); + echo '
'; + echo "$bar
"; + + echo '
'; + + + } + public function delete() { + echo "

Acc_Ledger_Purchase::delete Not implemented

"; + } + /*!\brief display the form for entering data for invoice + *\param $p_array is null or you can put the predef operation or the $_POST + *\return string + */ + public function display_form($p_array=null) { + if ( $p_array != null ) extract($p_array); + + $user = new User($this->db); + + // The first day of the periode + $oPeriode=new Periode($this->db); + list ($l_date_start,$l_date_end)=$oPeriode->get_date_limit($user->get_periode()); + + $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date; + $e_ech=(isset($e_ech))?$e_ech:""; + $e_comm=(isset($e_comm))?$e_comm:""; + + + $r=""; + + $r.=JS_INFOBULLE; + $r.=JS_SEARCH_CARD; + $r.=JS_SHOW_TVA; + $r.=JS_TVA; + $r.=JS_AJAX_FICHE; + + + $r.=dossier::hidden(); + $r.=widget::hidden('phpsessid',$_REQUEST['PHPSESSID']); + $r.="
"; + $r.="En-tête facture fournisseur "; + + $r.=''; + // Date + //-- + $Date=new widget("js_date"); + $Date->SetReadOnly(false); + $Date->table=1; + $Date->tabindex=1; + $r.=""; + $r.=$Date->IOValue("e_date",$op_date,"Date"); + // Payment limit + //-- + $Echeance=new widget("js_date"); + $Echeance->SetReadOnly(false); + $Echeance->table=1; + $Echeance->tabindex=2; + $label=widget::infobulle(4); + $r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance ".$label); + + // Periode + //-- + $l_user_per=$user->get_periode(); + $def=(isset($periode))?$periode:$l_user_per; + $l_form_per=FormPeriode($this->db,$def,OPEN); + $r.=""; + $r.=""; + // Ledger (p_jrn) + //-- + $wLedger=$this->select_ledger('ACH',2); + if ($wLedger == null) exit ('Pas de journal disponible'); + $wLedger->table=1; + $wLedger->javascript="onChange='update_predef(\"ach\",\"f\")'"; + $wLedger->label=" Journal ".widget::infobulle(2) ; + + $r.=$wLedger->IOValue(); + // Comment + //-- + $Commentaire=new widget("text"); + $Commentaire->table=0; + $Commentaire->SetReadOnly(false); + $Commentaire->size=80; + $Commentaire->tabindex=3; + $label=" Description ".widget::infobulle(1) ; + $r.=""; + $r.=''. + '"; + $r.=""; + + // Display the customer + //-- + $fiche='cred'; + + // Save old value and set a new one + //-- + $e_client=( isset ($e_client) )?$e_client:""; + $e_client_label=" ";//str_pad("",100,"."); + + + // retrieve e_client_label + //-- + + if ( strlen(trim($e_client)) != 0) { + $fClient=new fiche($this->db); + $fClient->get_by_qcode($e_client); + $e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '. + ' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '. + $fClient->strAttribut(ATTR_DEF_CP).' '. + $fClient->strAttribut(ATTR_DEF_CITY).' '; + + + } + + $W1=new widget("js_search_only"); + $W1->label="Fournisseur ".widget::infobulle(0) ; + $W1->name="e_client"; + $W1->tabindex=3; + $W1->value=$e_client; + $W1->table=0; + $W1->extra=$fiche; // list of card + $W1->extra2="Recherche"; + $r.='"; + + $r.="
"; + $label=widget::infobulle(3); + $r.="Période comptable $label".$l_form_per; + $r.="
'.$label.''.$Commentaire->IOValue("e_comm",$e_comm)."
'.$W1->IOValue(); + $client_label=new widget("span"); + $client_label->table=0; + $r.=$client_label->IOValue("e_client_label",$e_client_label)."
"; + + // Record the current number of article + $Hid=new widget('hidden'); + $p_article= ( isset ($p_article))?$p_article:MAX_ARTICLE; + $r.=$Hid->IOValue("nb_item",$p_article); + $e_comment=(isset($e_comment))?$e_comment:""; + $r.="
"; + + // Start the div for item to sell + $r.="
"; + $r.='
Détail articles achetés'; + $r.=''; + $r.=''; + $r.=""; + $label=widget::infobulle(0) ; + $r.=""; + $r.=""; + $label=widget::infobulle(6) ; + $r.=""; + $r.=""; + $label=widget::infobulle(8) ; + $r.=""; + $r.=""; + + $r.=''; + // For each article + //-- + for ($i=0;$i< MAX_ARTICLE;$i++) { + // Code id, price & vat code + //-- + $march=(isset(${"e_march$i"}))?${"e_march$i"}:""; + $march_buy=(isset(${"e_march".$i."_buy"}))?${"e_march".$i."_buy"}:""; + $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:""; + $march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:""; + + + $march_label=" "; + // retrieve the tva label and name + //-- + if ( strlen(trim($march))!=0 ) { + $fMarch=new fiche($this->db); + $fMarch->get_by_qcode($march); + $march_label=$fMarch->strAttribut(ATTR_DEF_NAME); + if ( ! isset($march_tva_id) ) + $march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA); + } + // Show input + //-- + $W1=new widget("js_search_only"); + $W1->label=""; + $W1->name="e_march".$i; + $W1->value=$march; + $W1->table=1; + $W1->extra2="Recherche"; + $W1->extra='deb'; // debits + $W1->javascript=sprintf('onBlur="ajaxFid(\'%s\',\'%s\',\'%s\');compute_purchase(%d)"', + $W1->name, + $W1->extra, //deb or cred + $_REQUEST['PHPSESSID'], + $i + ); + + $W1->readonly=false; + $r.="".$W1->IOValue(); + // For computing we need some hidden field for holding the value + $r.=widget::hidden('tva_march'.$i,0); + $r.=widget::hidden('htva_march'.$i,0); + $r.=widget::hidden('tvac_march'.$i,0); + $r.=""; + $Span=new widget ("span"); + $Span->SetReadOnly(false); + // card's name, price + //-- + $r.='"; + // price + $Price=new widget("text"); + $Price->SetReadOnly(false); + $Price->table=1; + $Price->size=9; + $Price->javascript="onBlur='compute_purchase($i)'"; + $r.=$Price->IOValue("e_march".$i."_buy",$march_buy); + // vat label + //-- + $select_tva=make_array($this->db,"select tva_id,tva_label from tva_rate order by tva_rate desc",0); + $Tva=new widget("select"); + $Tva->javascript="onChange=\"clean_tva($i);compute_purchase($i);\""; + $Tva->table=1; + $Tva->selected=$march_tva_id; + $r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva); + // Tva_amount + // price + $Tva_amount=new widget("text"); + $Tva_amount->SetReadOnly(false); + $Tva_amount->table=1; + $Tva_amount->size=9; + $Tva_amount->javascript="onBlur='compute_purchase($i)'"; + $r.=$Tva_amount->IOValue("e_march".$i."_tva_amount",$march_tva_amount); + + // quantity + //-- + $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"; + $Quantity=new widget("text"); + $Quantity->SetReadOnly(false); + $Quantity->table=1; + $Quantity->size=9; + $Quantity->javascript="onChange=compute_purchase($i)"; + $r.=$Quantity->IOValue("e_quant".$i,$quant); + + $r.=""; + } + + + + $r.="
Code $labelDénomination$label prix / unité htva tva $label Total tvaquantité
'.$Span->IOValue("e_march".$i."_label",$march_label)."
"; + $r.='
'; + $r.=widget::button('act','Actualiser','onClick="compute_all_purchase();"'); + $r.="
"; + + $r.='
'; + $r.='
0.0'; + $r.='
0.0'; + $r.='
0.0'; + $r.="
"; + + + + $r.='
'; + $r.='
Total HTVA'; + $r.='
Total TVA'; + $r.='
Total TVAC'; + $r.="
"; + + $r.="
"; + // Set correctly the REQUEST param for jrn_type + $r.=widget::hidden('jrn_type','ACH'); + + $r.=widget::button('add_item','Ajout article', ' onClick="ledger_sold_add_row()"'); + $r.=widget::submit("view_invoice","Enregistrer"); + $r.=widget::reset('Effacer '); + + $r.="
"; + + $r.=JS_CALC_LINE; + return $r; + } + /*!\brief show the summary of the operation and propose to save it + *\param array contains normally $_POST. It proposes also to save + * the Analytic accountancy + *\return string + */ + function confirm($p_array) { + extract ($p_array); + $this->verify($p_array) ; + + // to show a select list for the analytic + // if analytic is op (optionnel) there is a blank line + $own = new Own($this->db); + + bcscale(4); + $client=new fiche($this->db); + $client->get_by_qcode($e_client,true); + + $client_name=$client->getName(). + ' '.$client->strAttribut(ATTR_DEF_ADRESS).' '. + $client->strAttribut(ATTR_DEF_CP).' '. + $client->strAttribut(ATTR_DEF_CITY); + $lPeriode=new Periode($this->db); + $date_limit=$lPeriode->get_date_limit($periode); + $r=""; + $r.="
"; + $r.="En-tête facture fournisseur "; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.='
Date '.$e_date.'Echeance '.$e_ech.' Période Comptable '.$date_limit['p_start'].'-'.$date_limit['p_end'].'
Journal '.$this->get_name().'
Description '.$e_comm.'
Fournisseur '.$e_client.':'.$client_name.'
'; + $r.='
'; + $r.='
Détail articles achetés'; + $r.=''; + $r.=''; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + + $r.=''; + $r.=''; + $r.=($own->MY_ANALYTIC!='nu')?'':''; + $r.=''; + $tot_amount=0.0; + $tot_tva=0.0; + for ($i = 0; $i < $nb_item;$i++) { + if ( strlen(trim(${"e_march".$i})) == 0 ) continue; + + /* retrieve information for card */ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${"e_march".$i}); + $fiche_name=$fiche->getName(); + $idx_tva=${"e_march".$i."_tva_id"}; + $oTva=new Acc_Tva($this->db); + $oTva->set_parameter('id',$idx_tva); + $oTva->load(); + $amount=bcmul(${"e_march".$i."_buy"},${'e_quant'.$i}); + + //----- if tva_amount is not given we compute the vat ---- + if ( strlen (trim (${'e_march'.$i.'_tva_amount'})) == 0) { + $op=new Acc_Compute(); + + $op->set_parameter("amount",$amount); + $op->set_parameter('amount_vat_rate',$oTva->get_parameter('rate')); + $op->compute_vat(); + $tva_item=$op->get_parameter('amount_vat'); + } else + $tva_item=round(${'e_march'.$i.'_tva_amount'},2); + + if (isset($tva[$idx_tva] ) ) + $tva[$idx_tva]+=$tva_item; + else + $tva[$idx_tva]=$tva_item; + $tot_amount=round(bcadd($tot_amount,$amount),2); + $tot_tva=round(bcadd($tva_item,$tot_tva),2); + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + + $r.=''; + $r.=''; + $r.=''; + + // encode the pa + if ( $own->MY_ANALYTIC!='nu') // use of AA + { + // show form + $anc_op=new Anc_Operation($this->db); + $null=($own->MY_ANALYTIC=='op')?1:0; + $r.=''; + } + + + $r.=''; + + } + + + $r.='
CodeDénominationprixtvaquantité Montant TVAMontant HTVACompt. Analytique
'; + $r.=${"e_march".$i}; + $r.=''; + $r.=$fiche_name; + $r.=''; + $r.=${"e_march".$i."_buy"}; + $r.=''; + $r.=${"e_quant".$i}; + $r.=''; + $r.=$oTva->get_parameter('label'); + $r.=''; + $r.=$tva_item; + $r.=''; + $r.=$amount; + $r.=''; + $p_mode=1; + $r.=$anc_op->display_form_plan($p_array,$null,$p_mode,$i,$amount); + $r.='
'; + if ( $own->MY_ANALYTIC!='nu') // use of AA + $r.=''; + $r.='
'; + + + $r.='
Totaux'; + $tot=round(bcadd($tot_amount,$tot_tva),2); + $r.='
'; + $r.='
Total HTVA'; + + foreach ($tva as $i=>$value) { + $oTva->set_parameter('id',$i); + $oTva->load(); + + $r.='
TVA à '.$oTva->get_parameter('label'); + } + $r.='
Total TVA'; + $r.='
Total TVAC'; + $r.="
"; + + + $r.='
'; + $r.='
'.$tot_amount.''; + + foreach ($tva as $i=>$value) { + $r.='
'.$tva[$i]; + } + $r.='
'.$tot_tva.''; + $r.='
'.$tot.''; + $r.="
"; + + + + $r.='
'; + /* Add hidden */ + $r.=widget::hidden('e_client',$e_client); + $r.=widget::hidden('nb_item',$nb_item); + $r.=widget::hidden('p_jrn',$p_jrn); + $r.=widget::hidden('periode',$periode); + $r.=widget::hidden('e_comm',$e_comm); + $r.=widget::hidden('e_date',$e_date); + $r.=widget::hidden('e_ech',$e_ech); + $r.=widget::hidden('jrn_type',$jrn_type); + for ($i=0;$i < $nb_item;$i++) { + $r.=widget::hidden("e_march".$i,${"e_march".$i}); + $r.=widget::hidden("e_march".$i."_buy",${"e_march".$i."_buy"}); + $r.=widget::hidden("e_march".$i."_tva_id",${"e_march".$i."_tva_id"}); + $r.=widget::hidden('e_march'.$i.'_tva_amount', ${'e_march'.$i.'_tva_amount'}); + $r.=widget::hidden("e_quant".$i,${"e_quant".$i}); + } + // check for upload piece + $file=new widget("file"); + $file->table=0; + $r.="Ajoutez une pièce justificative "; + $r.=$file->IOValue("pj",""); + + return $r; + } + + + /*!\brief update the payment + */ + function show_unpaid() { + // Show list of unpaid sell + // Date - date of payment - Customer - amount + // Nav. bar + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + + $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$this->id ; + list($max_line,$list)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$this->id ; + list($max_line2,$list2)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + + // Get the max line + $m=($max_line2>$max_line)?$max_line2:$max_line; + $bar2=jrn_navigation_bar($offset,$m,$step,$page); + + echo $bar2; + echo '

Echeance dépassée

'; + echo $list; + echo '

Non Payée

'; + echo $list2; + echo $bar2; + // Add hidden parameter + $hid=new widget("hidden"); + + echo '
'; + + if ( $m != 0 ) + echo widget::submit('paid','Mise à jour paiement'); + + + } + /*!\brief + *\param + *\return + *\note + *\see + *\todo + */ + static function test_me() { + } + +} + + + + + diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php new file mode 100644 index 000000000..b5c165b7d --- /dev/null +++ b/include/class_acc_ledger_sold.php @@ -0,0 +1,949 @@ +is_closed($periode)==1 ) + { + throw new AcException('Periode fermee',6); + } + + /* check that the datum is in the choosen periode */ + $per=new Periode($this->db); + list ($min,$max)=$per->get_date_limit($periode); + if ( cmpDate($e_date,$min) < 0 || + cmpDate($e_date,$max) > 0) + throw new AcException('Date et periode ne correspondent pas',6); + $fiche=new fiche($this->db); + $fiche->get_by_qcode($e_client); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.$e_client.'n\'a pas de poste comptable',8); + + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.$e_client.' le poste comptable ['.$poste->id.'] n\'existe pas',9); + } + + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode($e_client,'deb'); + if ( $fiche->belong_ledger($p_jrn) !=1 ) + throw new AcException('La fiche '.$e_client.'n\'est pas accessible à ce journal',10); + + $nb=0; + + //---------------------------------------- + // foreach item + //---------------------------------------- + for ($i=0;$i< $nb_item;$i++) { + if ( strlen(trim(${'e_march'.$i}))== 0) continue; + /* check if amount are numeric and */ + if ( isNumber(${'e_march'.$i.'_sell'}) == 0 ) + throw new AcException('La fiche '.${'e_march'.$i}.'a un montant invalide ['.${'e_march'.$i}.']',6); + if ( isNumber(${'e_quant'.$i}) == 0 ) + throw new AcException('La fiche '.${'e_march'.$i}.'a une quantité invalide ['.${'e_quant'.$i}.']',7); + + /* check if all card has a ATTR_DEF_ACCOUNT*/ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) + throw new AcException('La fiche '.${'e_march'.$i}.'n\'a pas de poste comptable',8); + /* The account exists */ + $poste=new Acc_Account_Ledger($this->db,$fiche->strAttribut(ATTR_DEF_ACCOUNT)); + if ( $poste->load() == false ){ + throw new AcException('Pour la fiche '.${'e_march'.$i}.' le poste comptable ['.$poste->id.'n\'existe pas',9); + } + /* Check if the card belong to the ledger */ + $fiche=new fiche ($this->db); + $fiche->get_by_qcode(${'e_march'.$i}); + if ( $fiche->belong_ledger($p_jrn,'cred') !=1 ) + throw new AcException('La fiche '.${'e_march'.$i}.'n\'est pas accessible à ce journal',10); + $nb++; + } + if ( $nb == 0 ) + throw new AcException('Il n\'y a aucune marchandise',12); + } + + public function save() { + echo "

Acc_Ledger_Sold::save Not implemented

"; + } + + /*!\brief insert into the database, it calls first the verify function + *\param $p_array is usually $_POST or a predefined operation + *\return string + *\note throw an AcException + */ + public function insert($p_array) { + extract ($p_array); + $this->verify($p_array) ; + + $own=new own($this->db); + $group=NextSequence($this->db,"s_oa_group"); /* for analytic */ + $seq=NextSequence($this->db,'s_grpt'); + $this->id=$p_jrn; + $internal=$this->compute_internal_code($seq); + $cust=new fiche($this->db); + $cust->get_by_qcode($e_client); + $poste=$cust->strAttribut(ATTR_DEF_ACCOUNT); + bcscale(4); + try { + $tot_amount=0; + $tot_tva=0; + $tot_debit=0; + StartSql($this->db); + /* Save all the items without vat */ + for ($i=0;$i< $nb_item;$i++) { + if ( strlen(trim(${'e_march'.$i})) == 0 ) continue; + if ( ${'e_march'.$i.'_sell'} == 0 ) continue; + if ( ${'e_quant'.$i} == 0 ) continue; + + /* First we save all the items without vat */ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${"e_march".$i}); + $amount=bcmul(${'e_march'.$i.'_sell'},${'e_quant'.$i}); + $tot_amount+=$amount; + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$fiche->strAttribut(ATTR_DEF_ACCOUNT); + $acc_operation->amount=$amount; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='c'; + $acc_operation->periode=$periode; + $acc_operation->qcode=${"e_march".$i}; + if ( $amount < 0 ) $tot_debit=bcadd($tot_debit,abs($amount)); + + $j_id=$acc_operation->insert_jrnx(); + + /* Compute sum vat */ + $oTva=new Acc_Tva($this->db); + $idx_tva=${'e_march'.$i.'_tva_id'}; + $oTva->set_parameter('id',$idx_tva); + $oTva->load(); + $op_tva=new Acc_Compute(); + $op_tva->set_parameter("amount",$amount); + $op_tva->set_parameter('amount_vat_rate',$oTva->get_parameter('rate')); + $op_tva->compute_vat(); + $tva_item=$op_tva->get_parameter('amount_vat'); + + + if (isset($tva[$idx_tva] ) ) + $tva[$idx_tva]+=$tva_item; + else + $tva[$idx_tva]=$tva_item; + $tot_tva=round(bcadd($tva_item,$tot_tva),2); + + + /* Save the stock */ + /* if the quantity is < 0 then the stock increase (return of + * material) + */ + $nNeg=(${"e_quant".$i}<0)?-1:1; + + // always save quantity but in withStock we can find + // what card need a stock management + + InsertStockGoods($this->db,$j_id,${'e_march'.$i},$nNeg*${'e_quant'.$i},'c') ; + + if ( $own->MY_ANALYTIC != "nu" ) + { + // for each item, insert into operation_analytique */ + $op=new Anc_Operation($this->db); + $op->oa_group=$group; + $op->j_id=$j_id; + $op->oa_date=$e_date; + $op->oa_debit=($amount < 0 )?'t':'f'; + echo_debug(__FILE__.':'.__LINE__,"Description is $e_comm"); + $op->oa_description=FormatString($e_comm); + $op->save_form_plan($_POST,$i); + } + /* save into quant_sold */ + $r=ExecSql($this->db,"select insert_quant_sold ". + "('".$internal."',".$j_id.",'".${'e_march'.$i} + ."',".${'e_quant'.$i}.",".$amount. + ",".$tva_item. + ",".$idx_tva.",'".$e_client."')"); + + } // end loop : save all items + + + /* save total customer */ + $cust_amount=bcadd($tot_amount,$tot_tva); + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$poste; + $acc_operation->amount=$cust_amount; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='d'; + $acc_operation->periode=$periode; + $acc_operation->qcode=${"e_client"}; + if ( $cust_amount > 0 ) $tot_debit=bcadd($tot_debit,$cust_amount); + $acc_operation->insert_jrnx(); + + + /* save all vat + * $i contains the tva_id and value contains the vat amount + */ + foreach ($tva as $i => $value) { + $oTva=new Acc_Tva($this->db); + $oTva->set_parameter('id',$i); + $oTva->load(); + + $poste_vat=$oTva->get_side('c'); + + $cust_amount=bcadd($tot_amount,$tot_tva); + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->poste=$poste_vat; + $acc_operation->amount=$value; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->type='c'; + $acc_operation->periode=$periode; + if ($value < 0 ) $tot_debit=bcadd($tot_debit,abs($value)); + $acc_operation->insert_jrnx(); + + + } + + /* insert into jrn */ + $acc_operation=new Acc_Operation($this->db); + $acc_operation->date=$e_date; + $acc_operation->echeance=$e_ech; + $acc_operation->amount=abs(round($tot_debit,2)); + $acc_operation->desc=$e_comm; + $acc_operation->grpt=$seq; + $acc_operation->jrn=$p_jrn; + $acc_operation->periode=$periode; + $acc_operation->insert_jrn(); + ExecSql($this->db,"update jrn set jr_internal='".$internal."' where ". + " jr_grpt_id = ".$seq); + + /* Save the attachment */ + if ( isset ($_FILES)) { + if ( sizeof($_FILES) != 0 ) + save_upload_document($this->db,$seq); + } else + /* Generate an invoice and save it into the database */ + if ( isset($_POST['gen_invoice'])) { + echo $this->create_invoice($internal,$p_array); + echo '
'; + } + + } + catch (Exception $e) + { + echo ''. + 'Erreur dans l\'enregistrement '. + __FILE__.':'.__LINE__.' '. + $e->getMessage(); + Rollback($this->db); + exit(); + } + Commit($this->db); + return $internal; + } + + public function update() { + echo "

Acc_Ledger_Sold::update Not implemented

"; + } + + public function load() { + echo "

Acc_Ledger_Sold::load Not implemented

"; + + } + /*!\brief Show all the operation, propose a form to select the + *ledger and the periode + *\return none + *\note echo directly, there is no return with the html code + */ + public function show_ledger() { + $w=new widget("select"); + $User=new User($this->db); + // filter on the current year + $filter_year=" where p_exercice='".$User->get_exercice()."'"; + + $periode_start=make_array($this->db,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); + $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); + $w->selected=$current; + + echo 'Période '.$w->IOValue("p_periode",$periode_start); + $wLedger=$this->select_ledger('VEN',3); + + if ( $wLedger == null ) + exit('Pas de journal disponible'); + echo 'Journal '.$wLedger->IOValue(); + echo JS_SEARCH_CARD; + echo JS_PROTOTYPE; + echo JS_AJAX_FICHE; + $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; + $this->type='VEN'; + $all=$this->get_all_fiche_def(); + + $w=new widget('js_search_only'); + $w->name='qcode'; + $w->value=$qcode; + $w->label=''; + $w->extra='filter'; + $w->extra2='QuickCode'; + $w->table=0; + $sp= new widget("span"); + echo $w->IOValue(); + + echo $sp->IOValue("qcode_label","",$qcode); + + echo widget::submit('gl_submit','Valider'); + // Show list of sell + // Date - date of payment - Customer - amount + if ( $current == -1) { + $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; + } else { + $cond=" and jr_tech_per=".$current; + } + + $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$this->id ; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + /* security */ + $available_ledger=$User->get_ledger_sql(); + + $l=""; + // check if qcode contains something + if ( $qcode != "" ) + { + $qcode=Formatstring($qcode); + // add a condition to filter on the quick code + $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode=upper('$qcode')) "; + $sql="where jrn_def_type='VEN' $cond $l and $available_ledger "; + } + + + list($max_line,$list)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + + echo "
$bar"; + echo '
'; + echo dossier::hidden(); + $hid=new widget("hidden"); + + echo $list; + if ( $max_line !=0 ) + echo widget::submit('paid','Mise à jour paiement'); + echo '
'; + echo "$bar
"; + + echo ''; + + + } + public function delete() { + echo "

Acc_Ledger_Sold::delete Not implemented

"; + } + /*!\brief display the form for entering data for invoice + *\param $p_array is null or you can put the predef operation or the $_POST + *\return string + */ + public function display_form($p_array=null) { + if ( $p_array != null ) extract($p_array); + + $user = new User($this->db); + + // The first day of the periode + $oPeriode=new Periode($this->db); + list ($l_date_start,$l_date_end)=$oPeriode->get_date_limit($user->get_periode()); + + $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date; + $e_ech=(isset($e_ech))?$e_ech:""; + $e_comm=(isset($e_comm))?$e_comm:""; + + + $r=""; + + $r.=JS_INFOBULLE; + $r.=JS_SEARCH_CARD; + $r.=JS_SHOW_TVA; + $r.=JS_TVA; + $r.=JS_AJAX_FICHE; + + + $r.=dossier::hidden(); + $r.=widget::hidden('phpsessid',$_REQUEST['PHPSESSID']); + $r.="
"; + $r.="En-tête facture client "; + + $r.=''; + // Date + //-- + $Date=new widget("js_date"); + $Date->SetReadOnly(false); + $Date->table=1; + $Date->tabindex=1; + $r.=""; + $r.=$Date->IOValue("e_date",$op_date,"Date"); + // Payment limit + //-- + $Echeance=new widget("js_date"); + $Echeance->SetReadOnly(false); + $Echeance->table=1; + $Echeance->tabindex=2; + $label=widget::infobulle(4); + $r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance ".$label); + + // Periode + //-- + $l_user_per=$user->get_periode(); + $def=(isset($periode))?$periode:$l_user_per; + $l_form_per=FormPeriode($this->db,$def,OPEN); + $r.=""; + $r.=""; + // Ledger (p_jrn) + //-- + $wLedger=$this->select_ledger('VEN',2); + + if ( $wLedger == null ) + exit('Pas de journal disponible'); + $wLedger->table=1; + $wLedger->javascript="onChange='update_predef(\"ven\",\"f\")'"; + $wLedger->label=" Journal ".widget::infobulle(2) ; + + $r.=$wLedger->IOValue(); + // Comment + //-- + $Commentaire=new widget("text"); + $Commentaire->table=0; + $Commentaire->SetReadOnly(false); + $Commentaire->size=80; + $Commentaire->tabindex=3; + $label=" Description ".widget::infobulle(1) ; + $r.=""; + $r.=''. + '"; + $r.=""; + + // Display the customer + //-- + $fiche='deb'; + echo_debug('user_form_ven.php',__LINE__,"Client Nombre d'enregistrement ".sizeof($fiche)); + // Save old value and set a new one + //-- + $e_client=( isset ($e_client) )?$e_client:""; + $e_client_label=" ";//str_pad("",100,"."); + + + // retrieve e_client_label + //-- + + if ( strlen(trim($e_client)) != 0) { + $fClient=new fiche($this->db); + $fClient->get_by_qcode($e_client); + $e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '. + ' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '. + $fClient->strAttribut(ATTR_DEF_CP).' '. + $fClient->strAttribut(ATTR_DEF_CITY).' '; + + + } + + $W1=new widget("js_search_only"); + $W1->label="Client ".widget::infobulle(0) ; + $W1->name="e_client"; + $W1->tabindex=3; + $W1->value=$e_client; + $W1->table=0; + $W1->extra=$fiche; // list of card + $W1->extra2="Recherche"; + $r.='"; + + $r.="
"; + $label=widget::infobulle(3); + $r.="Période comptable $label $def".$l_form_per; + $r.="
'.$label.''.$Commentaire->IOValue("e_comm",$e_comm)."
'.$W1->IOValue(); + $client_label=new widget("span"); + $client_label->table=0; + $r.=$client_label->IOValue("e_client_label",$e_client_label)."
"; + + // Record the current number of article + $Hid=new widget('hidden'); + $p_article= ( isset ($p_article))?$p_article:MAX_ARTICLE; + $r.=$Hid->IOValue("nb_item",$p_article); + $e_comment=(isset($e_comment))?$e_comment:""; + $r.="
"; + + // Start the div for item to sell + $r.="
"; + $r.='
Détail articles vendus'; + $r.=''; + $r.=''; + $r.=""; + $label=widget::infobulle(0) ; + $r.=""; + $r.=""; + $label=widget::infobulle(6) ; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + + $r.=''; + // For each article + //-- + for ($i=0;$i< MAX_ARTICLE;$i++) { + // Code id, price & vat code + //-- + $march=(isset(${"e_march$i"}))?${"e_march$i"}:""; + $march_sell=(isset(${"e_march".$i."_sell"}))?${"e_march".$i."_sell"}:""; + $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:""; + + + $march_label=" "; + // retrieve the tva label and name + //-- + if ( strlen(trim($march))!=0 ) { + $fMarch=new fiche($this->db); + $fMarch->get_by_qcode($march); + $march_label=$fMarch->strAttribut(ATTR_DEF_NAME); + if ( ! (isset(${"e_march$i"."_tva_id"}))) + $march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA); + } + // Show input + //-- + $W1=new widget("js_search_only"); + $W1->label=""; + $W1->name="e_march".$i; + $W1->value=$march; + $W1->table=1; + $W1->extra2="Recherche"; + $W1->extra='cred'; // credits + $W1->javascript=sprintf('onBlur="ajaxFid(\'%s\',\'%s\',\'%s\');compute_sold(%d)"', + $W1->name, + $W1->extra, //deb or cred + $_REQUEST['PHPSESSID'], + $i + ); + $W1->readonly=false; + $r.="".$W1->IOValue(); + // For computing we need some hidden field for holding the value + $r.=widget::hidden('tva_march'.$i,0); + $r.=widget::hidden('htva_march'.$i,0); + $r.=widget::hidden('tvac_march'.$i,0); + $r.=""; + $Span=new widget ("span"); + $Span->SetReadOnly(false); + // card's name, price + //-- + $r.='"; + // price + $Price=new widget("text"); + $Price->SetReadOnly(false); + $Price->table=1; + $Price->size=9; + $Price->javascript="onBlur='compute_sold($i)'"; + $r.=$Price->IOValue("e_march".$i."_sell",$march_sell); + // vat label + //-- + $select_tva=make_array($this->db,"select tva_id,tva_label from tva_rate order by tva_rate desc",0); + $Tva=new widget("select"); + $Tva->javascript="onChange=compute_sold($i)"; + $Tva->table=1; + $Tva->selected=$march_tva_id; + $r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva); + // vat amount (disable) + //-- + $wTva_amount=new widget("text"); + $wTva_amount->table=1; + $wTva_amount->readonly=true; + $wTva_amount->size=6; + $r.=$wTva_amount->IOValue("tva_march$i"."_show"); + + // quantity + //-- + $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"; + $Quantity=new widget("text"); + $Quantity->SetReadOnly(false); + $Quantity->table=1; + $Quantity->size=9; + $Quantity->javascript="onChange=compute_sold($i)"; + $r.=$Quantity->IOValue("e_quant".$i,$quant); + + $r.=""; + } + + + + $r.="
Code $labelDénomination$label prix / unité htva tvamontant total tvaquantité
'.$Span->IOValue("e_march".$i."_label",$march_label)."
"; + $r.='
'; + $r.=widget::button('act','Actualiser','onClick="compute_all_sold();"'); + $r.="
"; + + $r.='
'; + $r.='
0.0'; + $r.='
0.0'; + $r.='
0.0'; + $r.="
"; + + + + $r.='
'; + $r.='
Total HTVA'; + $r.='
Total TVA'; + $r.='
Total TVAC'; + $r.="
"; + + $r.="
"; + // Set correctly the REQUEST param for jrn_type + $r.=widget::hidden('jrn_type','VEN'); + + $r.=widget::button('add_item','Ajout article', ' onClick="ledger_sold_add_row()"'); + $r.=widget::submit("view_invoice","Enregistrer"); + $r.=widget::reset('Effacer '); + + $r.="
"; + return $r; + } + /*!\brief show the summary of the operation and propose to save it + *\param array contains normally $_POST. It proposes also to save + * the Analytic accountancy + *\return string + */ + function confirm($p_array) { + extract ($p_array); + $this->verify($p_array) ; + + // to show a select list for the analytic + // if analytic is op (optionnel) there is a blank line + $own = new Own($this->db); + + bcscale(4); + $client=new fiche($this->db); + $client->get_by_qcode($e_client,true); + + $client_name=$client->getName(). + ' '.$client->strAttribut(ATTR_DEF_ADRESS).' '. + $client->strAttribut(ATTR_DEF_CP).' '. + $client->strAttribut(ATTR_DEF_CITY); + $lPeriode=new Periode($this->db); + $date_limit=$lPeriode->get_date_limit($periode); + $r=""; + $r.="
"; + $r.="En-tête facture client "; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.='
Date '.$e_date.'Echeance '.$e_ech.' Période Comptable '.$date_limit['p_start'].'-'.$date_limit['p_end'].'
Journal '.$this->get_name().'
Description '.$e_comm.'
Client '.$e_client.':'.$client_name.'
'; + $r.='
'; + $r.='
Détail articles vendus'; + $r.=''; + $r.=''; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + + $r.=''; + $r.=''; + $r.=($own->MY_ANALYTIC!='nu')?'':''; + $r.=''; + $tot_amount=0.0; + $tot_tva=0.0; + for ($i = 0; $i < $nb_item;$i++) { + if ( strlen(trim(${"e_march".$i})) == 0 ) continue; + + /* retrieve information for card */ + $fiche=new fiche($this->db); + $fiche->get_by_qcode(${"e_march".$i}); + $fiche_name=$fiche->getName(); + $oTva=new Acc_Tva($this->db); + $idx_tva=${"e_march".$i."_tva_id"}; + + $oTva->set_parameter('id',$idx_tva); + $oTva->load(); + $op=new Acc_Compute(); + $amount=bcmul(${"e_march".$i."_sell"},${'e_quant'.$i}); + + $op->set_parameter("amount",$amount); + $op->set_parameter('amount_vat_rate',$oTva->get_parameter('rate')); + $op->compute_vat(); + $tva_item=$op->get_parameter('amount_vat'); + if (isset($tva[$idx_tva] ) ) + $tva[$idx_tva]+=$tva_item; + else + $tva[$idx_tva]=$tva_item; + $tot_amount=round(bcadd($tot_amount,$amount),2); + $tot_tva=round(bcadd($tva_item,$tot_tva),2); + $r.=''; + $r.=''; + $r.=''; + $r.=''; + $r.=''; + + $r.=''; + $r.=''; + $r.=''; + + // encode the pa + if ( $own->MY_ANALYTIC!='nu') // use of AA + { + // show form + $anc_op=new Anc_Operation($this->db); + $null=($own->MY_ANALYTIC=='op')?1:0; + $r.=''; + } + + + $r.=''; + + } + + + $r.='
CodeDénominationprixtvaquantité Montant TVAMontant HTVACompt. Analytique
'; + $r.=${"e_march".$i}; + $r.=''; + $r.=$fiche_name; + $r.=''; + $r.=${"e_march".$i."_sell"}; + $r.=''; + $r.=${"e_quant".$i}; + $r.=''; + $r.=$oTva->get_parameter('label'); + $r.=''; + $r.=$tva_item; + $r.=''; + $r.=$amount; + $r.=''; + $p_mode=1; + $r.=$anc_op->display_form_plan($p_array,$null,$p_mode,$i,$amount); + $r.='
'; + if ( $own->MY_ANALYTIC!='nu') // use of AA + $r.=''; + $r.='
'; + $r.=$this->extra_info(); + + + $r.='
'; + $r.='
Totaux'; + $tot=round(bcadd($tot_amount,$tot_tva),2); + $r.='
'; + $r.='
Total HTVA'; + + foreach ($tva as $i=>$value) { + $oTva->set_parameter('id',$i); + $oTva->load(); + + $r.='
TVA à '.$oTva->get_parameter('label'); + } + $r.='
Total TVA'; + $r.='
Total TVAC'; + $r.='
'; + + $r.='
'; + $r.='
'.$tot_amount.''; + + foreach ($tva as $i=>$value) { + $r.='
'.$tva[$i]; + } + $r.='
'.$tot_tva.''; + $r.='
'.$tot.''; + $r.="
"; + + + + $r.='
'; + $r.="
"; + + /* Add hidden */ + $r.=widget::hidden('e_client',$e_client); + $r.=widget::hidden('nb_item',$nb_item); + $r.=widget::hidden('p_jrn',$p_jrn); + $r.=widget::hidden('periode',$periode); + $r.=widget::hidden('e_comm',$e_comm); + $r.=widget::hidden('e_date',$e_date); + $r.=widget::hidden('e_ech',$e_ech); + $r.=widget::hidden('jrn_type',$jrn_type); + for ($i=0;$i < $nb_item;$i++) { + $r.=widget::hidden("e_march".$i,${"e_march".$i}); + $r.=widget::hidden("e_march".$i."_sell",${"e_march".$i."_sell"}); + $r.=widget::hidden("e_march".$i."_tva_id",${"e_march".$i."_tva_id"}); + $r.=widget::hidden("e_quant".$i,${"e_quant".$i}); + } + + return $r; + } + /*!\brief the function extra info allows to + * - add a attachment + * - generate an invoice + * - insert extra info + *\return string + */ + public function extra_info() { + $r=""; + $r.='
'; + $r.='
Facturation'; + // check for upload piece + $file=new widget("file"); + $file->table=0; + $r.="Ajoutez une pièce justificative "; + $r.=$file->IOValue("pj",""); + + if ( CountSql($this->db, + "select md_id,md_name from document_modele where md_type=4") > 0 ) + { + + + $r.='ou générer une facture '; + // We propose to generate the invoice and some template + $doc_gen=new widget("select"); + $doc_gen->name="gen_doc"; + $doc_gen->value=make_array($this->db, + "select md_id,md_name from document_modele where md_type=4"); + $r.=$doc_gen->IOValue().'
'; + } + $r.='
'; + $obj=new widget('TEXT'); + $r.='Numero de bon de commande : '.$obj->IOValue('bon_comm').'
'; + $r.='Autre information : '.$obj->IOValue('other_info').'
'; + + $r.="
"; + $r.='
'; + return $r; + } + /*!\brief create the invoice and saved it as attachment to the + *operation, + *\param $internal is the internal code + *\param $p_array is normally the $_POST + *\return a string + */ + function create_invoice($internal,$p_array) { + extract ($p_array); + $doc=new Document($this->db); + $doc->f_id=$e_client; + $doc->md_id=$gen_doc; + $doc->ag_id=0; + $str_file=$doc->Generate(); + // Move the document to the jrn + $doc->MoveDocumentPj($internal); + // Update the comment with invoice number + $sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'"; + ExecSql($this->db,$sql); + return '

'.$str_file.'

'; + + } + + + /*!\brief update the payment + */ + function show_unpaid() { + // Show list of unpaid sell + // Date - date of payment - Customer - amount + // Nav. bar + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + + + $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$this->id ; + list($max_line,$list)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$this->id ; + list($max_line2,$list2)=ListJrn($this->db,$this->id,$sql,null,$offset,1); + + // Get the max line + $m=($max_line2>$max_line)?$max_line2:$max_line; + $bar2=jrn_navigation_bar($offset,$m,$step,$page); + + echo $bar2; + echo '

Echeance dépassée

'; + echo $list; + echo '

Non Payée

'; + echo $list2; + echo $bar2; + // Add hidden parameter + $hid=new widget("hidden"); + + echo '
'; + + if ( $m != 0 ) + echo widget::submit('paid','Mise à jour paiement'); + + + } + /*!\brief + *\param + *\return + *\note + *\see + *\todo + */ + static function test_me() { + } + +} + + + + + diff --git a/include/class_acc_operation.php b/include/class_acc_operation.php index 94fb192c5..8c146d582 100644 --- a/include/class_acc_operation.php +++ b/include/class_acc_operation.php @@ -65,16 +65,25 @@ var $jr_id; /*!< pk of jrn */ function insert_jrnx() { if ( $this->poste == "") return true; - + /* for negative amount the operation is reversed */ + if ( $this->amount < 0 ) { + $this->type=($this->type=='d')?'c':'d'; + } + $this->amount=abs($this->amount); $debit=($this->type=='c')?'false':'true'; - - $sql=sprintf("select insert_jrnx - ('%s',abs(%.2f),%d,%d,%d,%s,'%s',%d,upper('%s'))", - $this->date,round($this->amount,2), - $this->poste,$this->grpt,$this->jrn, - $debit,$this->user,$this->periode,$this->qcode); - - $Res=ExecSql($this->db,$sql); + + $Res=ExecSqlParam($this->db,"select insert_jrnx + ($1::text,abs($2)::numeric,$3::poste_comptable,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9))", + array( + $this->date, + round($this->amount,2), + $this->poste, + $this->grpt, + $this->jrn, + $debit, + $this->user, + $this->periode, + $this->qcode)); if ( $Res==false) return $Res; $this->jrnx_id=GetSequence($this->db,'s_jrn_op'); return $this->jrnx_id; @@ -90,35 +99,31 @@ var $jr_id; /*!< pk of jrn */ */ function insert_jrn() -{ - $p_comment=FormatString($this->desc); + { + $p_comment=FormatString($this->desc); + + $diff=getDbValue($this->db,"select check_balance ($1)",array($this->grpt)); + if ( $diff != 0 ) { + + echo "Erreur : balance incorrecte :diff = $diff"; + return false; + } + $echeance=( isset( $this->echeance) && strlen(trim($this->echeance)) != 0)?$this->echeance:null; - // retrieve the value from jrnx - // - $montant_deb=getDBValue($this->db,"select sum(j_montant) from jrnx where j_debit='t' and j_grpt=".$this->grpt); - $montant_cred=getDBValue($this->db,"select sum(j_montant) from jrnx where j_debit='f' and j_grpt=".$this->grpt); - echo_debug('InsertJrn',__LINE__,"debit = $montant_deb credit = $montant_cred "); - - $amount=-1.0000; - if ( $montant_deb == $montant_cred ) { - $amount=$montant_deb; - } else { - echo "Erreur : balance incorrecte : débit = $montant_deb crédit = $montant_cred"; - return false; - } - // if amount == -1then the triggers will throw an error - // - $sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per) - values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),null,%d,%d)", - $this->jrn, $amount,$p_comment,$this->date,$this->grpt,$this->periode); - - - $Res=ExecSql($this->db,$sql); - if ( $Res == false) return false; - $this->jr_id=GetSequence($this->db,'s_jrn'); - return $this->jr_id; -} + // if amount == -1then the triggers will throw an error + // + $Res=ExecSqlParam($this->db,"insert into jrn (jr_def_id,jr_montant,jr_comment,". + "jr_date,jr_ech,jr_grpt_id,jr_tech_per) values (". + "$1,$2,$3,". + "to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7)", + array ($this->jrn, $this->amount,$p_comment, + $this->date,$echeance,$this->grpt,$this->periode) + ); + if ( $Res == false) return false; + $this->jr_id=GetSequence($this->db,'s_jrn'); + return $this->jr_id; + } /*! * \brief Return the internal value, the property jr_id must be set before * @@ -150,7 +155,7 @@ function get_internal() { */ function get_jrnx_detail() { if ( $this->jr_id==0 ) return; - $sql=" select j_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit, + $sql=" select jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description, vw_name,pcm_lib from jrnx join jrn on (jr_grpt_id=j_grpt) join tmp_pcmn on (j_poste=pcm_val) left join vw_fiche_attr on (j_qcode=quick_code) diff --git a/include/class_acc_parm_code.php b/include/class_acc_parm_code.php new file mode 100644 index 000000000..da754818d --- /dev/null +++ b/include/class_acc_parm_code.php @@ -0,0 +1,175 @@ +db=$p_cn; + $this->p_code=$p_id; + if ( $p_id != -1 ) + $this->load(); + } +/*! + ************************************************** + * \brief + * Load all parmCode + * return an array of Acc_Parm_Code object + * + * \return array + */ + + function load_all() { + $sql="select * from parm_code order by p_code"; + $Res=ExecSql($this->db,$sql); + $r= pg_fetch_all($Res); + $idx=0; + $array=array(); + + if ( $r === false ) return null; + foreach ($r as $row ) + { + $o=new Acc_Parm_Code($this->db,$row['p_code']); + $array[$idx]=$o; + $idx++; + } + + return $array; + } + /*! + ************************************************** + * \brief update a parm_object into the database + * p_code is _not_ updatable + * \return + * nothing + */ + function save() + { + // if p_code=="" nothing to save + if ( $this->p_code== -1) return; + // check if the account exists + $acc=new Acc_Account_Ledger($this->db,$this->p_value); + if ( $acc->load() == false ) { + echo ""; + } else { + $this->p_comment=FormatString($this->p_comment); + $this->p_value=FormatString($this->p_value); + $this->p_code=FormatString($this->p_code); + $sql="update parm_code set ". + "p_comment='".$this->p_comment."' ". + ",p_value='".$this->p_value."' ". + "where p_code='".$this->p_code."'"; + $Res=ExecSql($this->db,$sql); + } + } +/*! + ************************************************** + * \brief Display an object, with the tag + * + * \return + * string + */ + function display() + { + $r=""; + $r.= ''.$this->p_code.''; + $r.= ''.$this->p_comment.''; + $r.= ''.$this->p_value.''; + + return $r; + } +/*! + ************************************************** + * \brief Display a form to enter info about + * a parm_code object with the tag + * + * \return string + */ + function form() + { + $comment=new widget("text"); + $comment->name='p_comment'; + $comment->value=$this->p_comment; + $comment->size=45; + $value=new widget("js_search_poste"); + $value->name='p_value'; + $value->value=$this->p_value; + $value->size=7; + $poste=new widget("text"); + $poste->SetReadOnly(true); + $poste->size=strlen($this->p_code)+1; + $poste->name='p_code'; + $poste->value=$this->p_code; + $r=""; + $r.=JS_SEARCH_POSTE; + $r.=''; + $r.=' Code '; + $r.= ''.$poste->IOValue().''; + $r.=''; + $r.=''; + $r.=' Commentaire '; + $r.= ''.$comment->IOValue().''; + $r.=''; + $r.=''; + $r.=' Poste comptable '; + $r.= ''.$value->IOValue(); + $r.=''; + $r.=''; + + return $r; + + } + +/*! + ************************************************** + * \brief + * Complete a parm_code object thanks the p_code + * + * \return array + */ + + function load() { + if ( $this->p_code == -1 ) return "p_code non initialisé"; + $sql='select * from parm_code where p_code=$1 '; + + $Res=ExecSqlParam($this->db,$sql,array($this->p_code)); + + if ( pg_NumRows($Res) == 0 ) return 'INCONNU'; + $row= pg_fetch_array($Res,0); + $this->p_value=$row['p_value']; + $this->p_comment=$row['p_comment']; + + } + +} diff --git a/include/class_acc_report.php b/include/class_acc_report.php new file mode 100644 index 000000000..29e1add7e --- /dev/null +++ b/include/class_acc_report.php @@ -0,0 +1,405 @@ +db=$p_cn; + $this->id=$p_id; + $this->name='Nouveau'; + $this->aAcc_Report_row=null; + } + /*!\brief Return the report's name + */ + function get_name() { + $ret=execSql($this->db,"select fr_label from formdef where fr_id=".$this->id); + if (pg_NumRows($ret) == 0) return $this->name; + $a=pg_fetch_array($ret,0); + $this->name=$a['fr_label']; + return $this->name; + } + /*!\brief return all the row and parse formula + * from a report + * \param $p_start start periode + * \param $p_end end periode + * \param $p_type_date type of the date : periode or calendar + */ + + function get_row($p_start,$p_end,$p_type_date) { + + $Res=ExecSql($this->db,"select fo_id , + fo_fr_id, + fo_pos, + fo_label, + fo_formula, + fr_label from form + inner join formdef on fr_id=fo_fr_id + where fr_id =".$this->id. + "order by fo_pos"); + $Max=pg_NumRows($Res); + if ($Max==0) { $this->row=0;return null;} + $col=array(); + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Res,$i); + $col[]=ParseFormula($this->db, + $l_line['fo_label'], + $l_line['fo_formula'], + $p_start, + $p_end, + true, + $p_type_date + ); + + } //for ($i + $this->row=$col; + return $col; + } +/*! + * \brief Display a form for encoding a new report or update one + * + * \param $p_line number of line + * + */ +function form($p_line=0) { + + $r=""; + if ($p_line == 0 ) $p_line=count($this->aAcc_Report_row); + $r.= dossier::hidden(); + $r.= widget::hidden('line',$p_line); + $r.= widget::hidden('fr_id',$this->id); + $wForm=new widget("text"); + $r.="Nom du rapport : "; + $r.=$wForm->IOValue('form_nom',$this->name); + + $r.= ''; + $r.= ""; + $r.= ""; + $r.= ""; + $r.= ""; + + $r.= ''; + $wName=new widget("text"); + $wName->size=50; + $wPos=new widget("text"); + $wPos->size=3; + $wForm=new widget("text"); + $wForm->size=35; + for ( $i =0 ; $i < $p_line;$i++) { + + $r.= ""; + + $r.= "'; + + + $r.= "'; + + $r.= "'; + + $r.=''; + + + $r.= ""; + } + + $r.= "
Position Texte Formule
"; + $wPos->value=( isset($this->aAcc_Report_row[$i]->fo_pos))?$this->aAcc_Report_row[$i]->fo_pos:$i+1; + $r.=$wPos->IOValue("pos".$i); + $r.= '"; + $wName->value=( isset($this->aAcc_Report_row[$i]->fo_label))?$this->aAcc_Report_row[$i]->fo_label:""; + $r.=$wName->IOValue("text".$i); + $r.= '"; + $wForm->value=( isset($this->aAcc_Report_row[$i]->fo_formula))?$this->aAcc_Report_row[$i]->fo_formula:""; + $r.=$wForm->IOValue("form".$i); + + $r.= ''; + $search=new widget('js_search_poste_only'); + $search->extra="form".$i; + $r.=$search->IOValue(); + $r.='
"; + $wButton=new widget("button"); + $wButton->javascript=" rapport_add_row('".dossier::id()."','".$_REQUEST['PHPSESSID']."')"; + $wButton->label="Ajout d'une ligne"; + $r.=$wButton->IOValue(); + return $r; + +} + /*!\brief save into form and form_def + */ + function save() { + + if ( strlen(trim($this->name)) == 0 ) + return; + if ( $this->id == 0 ) + $this->insert(); + else + $this->update(); + + } + function insert() { + try { + startSql($this->db); + $ret_sql=ExecSqlParam($this->db, + "insert into formdef (fr_label) values($1) returning fr_id", + array($this->name) + ); + $this->id=pg_fetch_result($ret_sql,0,0); + $ix=1; + foreach ( $this->aAcc_Report_row as $row) { + if ( strlen(trim($row->get_parameter("name"))) != 0 && + strlen(trim($row->get_parameter("formula"))) != 0 ) + { + $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; + $row->set_parameter("position",$ix); + $ret_sql=ExecSqlParam($this->db, + "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". + " values($1,$2,$3,$4)", + array($this->id, + $row->fo_pos, + $row->fo_label, + $row->fo_formula) + ); + } + } + + } catch (Exception $e) { + Rollback($this->db); + echo $e->getMessage(); + } + Commit($this->db); + + } + function update() { + try { + startSql($this->db); + $ret_sql=ExecSqlParam($this->db, + "update formdef set fr_label=$1 where fr_id=$2", + array($this->name,$this->id)); + $ret_sql=ExecSqlParam($this->db, + "delete from form where fo_fr_id=$1", + array($this->id)); + $ix=0; + + foreach ( $this->aAcc_Report_row as $row) { + if ( strlen(trim($row->get_parameter("name"))) != 0 && + strlen(trim($row->get_parameter("formula"))) != 0 ) + { + + $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; + $row->set_parameter("position",$ix); + $ret_sql=ExecSqlParam($this->db, + "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". + " values($1,$2,$3,$4)", + array($this->id, + $row->fo_pos, + $row->fo_label, + $row->fo_formula) + ); + } + } + + + }catch (Exception $e) { + Rollback($this->db); + echo $e->getMessage(); + } + Commit($this->db); + } + /*!\brief fill a form thanks an array, usually it is $_POST + *\param $p_array keys = fr_id, form_nom,textXX, formXX, posXX where + XX is an number + */ + function from_array($p_array) { + $this->id=(isset($p_array['fr_id']))?$p_array['fr_id']:0; + $this->name=(isset($p_array['form_nom']))?$p_array['form_nom']:""; + $ix=0; + + $rr=new Acc_Report_Row(); + $rr->set_parameter("form_id",$this->id); + $rr->set_parameter('database',$this->db); + + $this->aAcc_Report_row=$rr->from_array($p_array); + + + } + /*!\brief the fr_id MUST be before called + */ + + + function load() { + $sql=ExecSqlParam($this->db, + "select fr_label from formdef where fr_id=$1", + array($this->id)); + if ( pg_NumRows($sql) == 0 ) return; + $this->name=pg_fetch_result($sql,0,0); + $sql=ExecSqlParam($this->db, + "select fo_id,fo_pos,fo_label,fo_formula ". + " from form ". + " where fo_fr_id=$1 order by fo_pos", + array($this->id)); + $f=pg_fetch_all($sql); + $array=array(); + if ( ! empty($f) ) { + foreach ($f as $r) { + $obj=new Acc_Report_Row(); + $obj->set_parameter("name",$r['fo_label']); + $obj->set_parameter("id",$r['fo_id']); + $obj->set_parameter("position",$r['fo_pos']); + $obj->set_parameter("formula",$r['fo_formula']); + $obj->set_parameter('database',$this->db); + $obj->set_parameter('form_id',$this->id); + $array[]=clone $obj; + } + } + $this->aAcc_Report_row=$array; + + } + function delete() { + $ret=ExecSqlParam($this->db, + "delete from formdef where fr_id=$1", + array($this->id) + ); + } + /*!\brief get a list from formdef of all defined form + * + *\return array of object rapport + * + */ + function get_list() + { + $sql="select fr_id,fr_label from formdef order by fr_label"; + $ret=ExecSql($this->db,$sql); + if ( pg_NumRows($ret) == 0 ) return array(); + $array=pg_fetch_all($ret); + $obj=array(); + foreach ($array as $row) { + $tmp=new Acc_Report($this->db); + $tmp->id=$row['fr_id']; + $tmp->name=$row['fr_label']; + $obj[]=clone $tmp; + } + return $obj; + } + /*!\brief To make a SELECT button with the needed value, it is used + *by the SELECT widget + *\return string with html code + */ + function make_array() { + $sql=make_array($this->db,"select fr_id,fr_label from formdef order by fr_label"); + return $sql; + } + + + /*!\brief write to a file the definition of a report + * \param p_file is the file name + */ + function export($p_file) { + $this->load(); + + fputcsv($p_file,array($this->name)); + + foreach ($this->aAcc_Report_row as $row) { + fputcsv($p_file,array($row->get_parameter("name"), + $row->get_parameter('position'), + $row->get_parameter('formula')) + ); + } + + } + /*!\brief upload a definition of a report and insert it into the + * database + */ + function upload() { + if ( empty ($_FILES) ) return; + if ( strlen(trim($_FILES['report']['tmp_name'])) == 0 ) { + echo ''; + return; + } + $file_report=tempnam('tmp','file_report'); + if ( move_uploaded_file($_FILES['report']['tmp_name'],$file_report)) { + // File is uploaded now we can try to parse it + $file=fopen($file_report,'r'); + $data=fgetcsv($file); + if ( empty($data) ) return; + $this->name=$data[0]; + $array=array(); + while($data=fgetcsv($file)) { + $obj=new Acc_Report_Row(); + $obj->set_parameter("name",$data[0]); + $obj->set_parameter("id",0); + $obj->set_parameter("position",$data[1]); + $obj->set_parameter("formula",$data[2]); + $obj->set_parameter('database',$this->db); + $obj->set_parameter('form_id',0); + $array[]=clone $obj; + } + $this->aAcc_Report_row=$array; + $this->insert(); + } + } + + function test_me() { + $cn=DbConnect(dossier::id()); + $a=new Acc_Report($cn); + print_r($a->get_list()); + $array=array("text0"=>"test1", + "form0"=>"7%", + "text1"=>"test2", + "form1"=>"6%", + "fr_id"=>110, + "form_nom"=>"Tableau" + ); + $a->from_array($array); + print_r($a); + echo '
'; + echo $a->form(10); + echo ''; + /* Add a line should be a javascript see comptanalytic */ + // $r.= ''; + echo ''; + + echo "
"; + if ( isset ($_POST['update'])) { + $b=new Acc_Report($cn); + $b->from_array($_POST); + echo '
'; + print_r($b); + } + } +} + +?> diff --git a/include/class_acc_report_row.php b/include/class_acc_report_row.php new file mode 100644 index 000000000..eb5166788 --- /dev/null +++ b/include/class_acc_report_row.php @@ -0,0 +1,111 @@ +"fo_label", + "formula"=>"fo_formula", + "id"=>"fo_id", + "position"=>"fo_pos", + "form_id"=>"fo_fr_id", + "database"=>"db" + ); + function __construct ($p_name=null,$p_formula=null) { + $this->set_parameter("id",0); + + $this->set_parameter("name",$p_name); + $this->set_parameter("formula",$p_formula); + } + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__."$p_string ".'Erreur attribut inexistant'); + + + } + public function get_info() { + return var_export(self::$variable,true); + } + /*!\brief Convert an array into an array of row_rapport object + * the fo_id is 0, position = 0, the fo_frd_id (form_id) is + * the one of the current object, the db is also the current one + *\param $p_array contains the value + *\return an array of Acc_Report_Row object + */ + public function from_array($p_array) { + extract ($p_array); + $ret=array(); + $ix=0; + $found=0; + foreach ( $p_array as $r) { + + if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} )) { + $obj=new Acc_Report_Row( ${'text'.$ix},${'form'.$ix}); + if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 ) + $obj->set_parameter("position",$ix); + else { + $obj->set_parameter("position",$found); + $found++; + } + $obj->fo_id=0; + $obj->fo_fr_id=$this->fo_fr_id; + $obj->db=$this->db; + + $ret[]=clone $obj; + } + $ix++; + + } + return $ret; + } + function test_me() + { + $cn=DbConnect(dossier::id()); + $a=new Acc_Report_Row(); + $array=array("text0"=>"test1", + "form0"=>"7%", + "text1"=>"test2", + "form1"=>"6%" + ); + + $b=$a->from_array($array); + print_r($b); + echo $a->get_info(); + } +} diff --git a/include/class_acc_tva.php b/include/class_acc_tva.php new file mode 100644 index 000000000..97f675544 --- /dev/null +++ b/include/class_acc_tva.php @@ -0,0 +1,179 @@ +"tva_id", + "label"=>"tva_label", + "rate"=>"tva_rate", + "comment"=>"tva_comment", + "account"=>"tva_poste"); + +*/ +class Acc_Tva +{ + private static $cn; /*!< $cn database connection */ + private static $variable=array("id"=>"tva_id", + "label"=>"tva_label", + "rate"=>"tva_rate", + "comment"=>"tva_comment", + "account"=>"tva_poste"); + + function __construct ($p_init) { + $this->cn=$p_init; + $this->tva_id=0; + $this->poste=""; + } + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + + echo (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + + + } + public function get_info() { return var_export(self::$variable,true); } + + public function verify() { + // Verify that the elt we want to add is correct + } + public function save() { + + if ( $this->tva_id == 0 ) + $this->insert(); + else + $this->update(); + } + + public function insert() { + if ( $this->verify() != 0 ) return; + $sql="select tva_insert($1,$2,$3,$4)"; + + $res=ExecSqlParam($this->cn, + $sql, + array($this->tva_label, + $this->tva_rate, + $this->tva_comment, + $this->tva_poste) + ); + $this->tva_id=GetSequence($this->cn,'s_tva'); + $err=pg_fetch_result($res); + } + + public function update() { + if ( $this->verify() != 0 ) return; + $sql="update tva_rate set tva_label=$1,tva_rate=$2,tva_comment=$3,tva_poste=$4 ". + " where tva_id = $5"; + $res=ExecSqlParam($this->cn, + $sql, + array($this->tva_label, + $this->tva_rate, + $this->tva_comment, + $this->tva_poste, + $this->tva_id) + ); + + } + + public function load() { + $sql="select tva_label,tva_rate, tva_comment,tva_poste from tva_rate where tva_id=$1"; + $res=ExecSqlParam($this->cn, + $sql, + array($this->tva_id) + ); + + if ( pg_NumRows($res) == 0 ) return; + + $row=pg_fetch_array($res,0); + foreach ($row as $idx=>$value) { $this->$idx=$value; } + } + /*!\brief get the account of the side (debit or credit) + *\param $p_side is d or C + *\return the account to use + *\note call first load if tva_poste is empty + */ + public function get_side($p_side) { + if ( strlen($this->tva_poste) == 0 ) $this->load(); + list($deb,$cred)=split(",",$this->tva_poste); + switch ($p_side) { + case 'd': + return $deb; + break; + case 'c': + return $cred; + break; + default: + throw (new Exception (__FILE__.':'.__LINE__." param est d ou c, on a recu [ $p_side ]")); + } + } + public function delete() { + $sql="delete from tva_rate where tva_id=$1"; + $res=ExecSqlParam($this->cn,$sql,array($this->tva_id)); + } + /*!\brief + *\param + *\return + *\note + *\see + *\todo + */ + static function test_me() { + $cn=DbConnect(dossier::id()); + $a=new Acc_Tva($cn); + echo $a->get_info(); + $a->set_parameter("id",1); + $a->load(); + $a->set_parameter("id",0); + $a->set_parameter("rate","0.2222"); + $a->set_parameter("label","test"); + $a->save(); + $a->load(); + print_r($a); + + $a->set_parameter("comment","un cht'it test"); + $a->save(); + $a->load(); + print_r($a); + + $a->delete(); + } + +} + +/* test::test_me(); */ diff --git a/include/class_action.php b/include/class_action.php index 20271f4a8..16b85c26e 100644 --- a/include/class_action.php +++ b/include/class_action.php @@ -156,8 +156,8 @@ class action // Description $desc=new widget('RICHTEXT'); - $desc->width=500; - $desc->heigh=250; + $desc->width=700; + $desc->heigh=100; $desc->name="ag_comment"; $desc->readonly=$readonly; /*!\todo Formatstring and urldecode ?? */ @@ -251,7 +251,7 @@ class action // $this->GetAgRef("ag_ref_ag_id").""; $lag_ref_ag_id=''. + $this->ag_ref_ag_id.'&'.dossier::get().'">'. getDbValue($this->db,"select ag_ref from action_gestion where ag_id=".$this->ag_ref_ag_id). ""; } @@ -277,7 +277,7 @@ class action // Preparing the return string $r=""; $r.=JS_SEARCH_CARD; - $r.= '

Date :'.$date->IOValue()." Reference ".$str_ag_ref; + $r.= '

Date :'.$date->IOValue()."
Reference ".$str_ag_ref; $r.="  Concerne :".$lag_ref_ag_id. ' Type d\' action'; echo_debug('class_action',__LINE__,"str_doc_type $str_doc_type"); @@ -290,7 +290,6 @@ class action $r.= "

"; $r.="Expéditeur : ".$w->IOValue(); $r.=$sp->IOValue('qcode_exp_label',$qcode_exp_label).""; - $r.="Destinataire :".$wdest->IOValue(); $r.=$spdest->IOValue('qcode_dest_label',$qcode_dest_label).""; @@ -299,8 +298,8 @@ class action echo_debug('class_action',__LINE__,' ag_id is '.$this->ag_id); $r.= "

Titre : ".$title->IOValue(); - $r.= $doc_ref; $r.= "

".$desc->IOValue()."

"; + $r.= $doc_ref; //hidden $r.="

"; @@ -599,7 +598,7 @@ class action if ( $this->gen == 'on' ) { $r.=''; - $r.="Sauver le document généré :"; + $r.="Sauver le document généré :"; $r.=$str_file; $checkbox=new widget("checkbox"); $checkbox->name="save_generate"; @@ -669,7 +668,7 @@ class action 'Date'. ''.$image_desc.''; $sort_exp=''.$image_asc.''. - 'Expéditeur'. + 'Expéditeur'. ''.$image_desc.''; $sort_dest=''.$image_asc.''. 'Destinataire'. @@ -681,7 +680,7 @@ class action 'Concerne'. ''.$image_desc.''; $sort_reference=''.$image_asc.''. - 'Référence'. + 'Référence'. ''.$image_desc.''; if ( isset($_GET['s'])){ @@ -703,14 +702,14 @@ class action case "exp": $sort_exp=''.$image_sel_asc.''. - 'Expéditeur'. + 'Expéditeur'. ''.$image_asc.''; $sort=" f_id_exp asc"; break; case "exp_d": $sort_exp=''.$image_asc.''. - 'Expéditeur'. + 'Expéditeur'. $image_sel_desc.''; $sort=" f_id_exp desc"; @@ -763,7 +762,7 @@ class action case "ref": $sort_reference=''.$image_sel_asc. - 'Référence'. + 'Référence'. ''.$image_desc.''; $sort=" ag_ref "; @@ -771,7 +770,7 @@ class action case "ref_d": $sort_reference=''.$image_asc.''. - 'Référence'. + 'Référence'. $image_sel_desc.''; $sort=" ag_ref desc"; @@ -793,7 +792,7 @@ class action $max_line=CountSql($this->db,$sql); $step=$_SESSION['g_pagesize']; $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; + $offset=(isset($_GET['offset']))?pg_escape_string($_GET['offset']):0; $limit=" LIMIT $step OFFSET $offset "; $bar=jrn_navigation_bar($offset,$max_line,$step,$page); @@ -819,17 +818,20 @@ class action if ( sizeof ($a_row) == 0 or $a_row == false ) { $r='

'; - $r.='
Aucun enregistrement trouvé'; + $r.='
Aucun enregistrement trouvé'; $r.="
"; return $r; } $r.=JS_SEARCH_CARD; + $i=0; foreach ($a_row as $row ) { - - $r.=""; - $r.="".$row['my_date'].""; + $href=''; + $i++; + $tr=($i%2==0)?'even':'odd'; + $r.=""; + $r.="".$href.$row['my_date'].''.""; // Destinataire $fdest=new fiche($this->db); $fdest->id=$row['f_id_dest']; @@ -840,10 +842,10 @@ class action $_REQUEST['PHPSESSID'],$qdest); if ( $qdest != 'Interne' ) { - $r.="".''.$qdest." : ".$fdest->getName().''; + $r.="".$href.$qdest." : ".$fdest->getName().''; } else - $r.="Interne "; + $r.="$href Interne "; // Expediteur $fexp=new fiche($this->db); @@ -855,10 +857,10 @@ class action $_REQUEST['PHPSESSID'],$qexp); if ( $qexp != 'Interne' ) { - $r.="".''.$qexp." : ".$fexp->getName().''; + $r.="$href".$qexp." : ".$fexp->getName().''; } else - $r.="Interne "; + $r.="$href Interne "; $ref=""; @@ -878,7 +880,7 @@ class action } } - $r.=''. + $r.=''.$href. $row['ag_title'].""; $r.="".$row['dt_value'].""; $r.="".$row['ag_ref'].""; diff --git a/include/class_admin.php b/include/class_admin.php index c0ba7014d..7e131cee2 100644 --- a/include/class_admin.php +++ b/include/class_admin.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("constant.php"); require_once("postgres.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once("class_widget.php"); require_once('class_fiche.php'); diff --git a/include/class_attribut.php b/include/class_attribut.php index 15b6c72d1..e64d0001e 100644 --- a/include/class_attribut.php +++ b/include/class_attribut.php @@ -29,6 +29,7 @@ class Attribut { var $ad_id; /*!< pk for attribut */ var $ad_text; /*!< type of content */ var $av_text; /*!< Description (content) */ + var $jnt_order; /*!< order of the attribut */ var $cn; /*!< database connection */ function Attribut($p_ad_id) { $this->ad_id=$p_ad_id; diff --git a/include/class_contact.php b/include/class_contact.php index 00b8aa501..c86ba2810 100644 --- a/include/class_contact.php +++ b/include/class_contact.php @@ -84,10 +84,10 @@ attr_value using (jft_id) where av_text=upper('".$this->company."') and ad_id=". Quick Code Nom -Téléphone +Téléphone email Fax -Société +Société '; $base=$_SERVER['PHP_SELF']; // Compute the url diff --git a/include/class_customer.php b/include/class_customer.php index be1217b11..7d87666e1 100644 --- a/include/class_customer.php +++ b/include/class_customer.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("constant.php"); require_once("postgres.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once("class_widget.php"); require_once('class_periode.php'); require_once('class_fiche.php'); @@ -87,16 +87,16 @@ class Customer extends fiche{ // BASE ACCOUNT // for belgium - $s=new parm_code($this->cn,'VENTE'); - $s->Get(); + $s=new Acc_Parm_Code($this->cn,'VENTE'); + $s->load(); $SOLD=$s->p_value; - $c=new parm_code($this->cn,'CUSTOMER'); - $c->Get(); + $c=new Acc_Parm_Code($this->cn,'CUSTOMER'); + $c->load(); $CUSTOMER=$c->p_value; - $t=new parm_code($this->cn,'COMPTE_TVA'); - $t->Get(); + $t=new Acc_Parm_Code($this->cn,'COMPTE_TVA'); + $t->load(); $TVA=$t->p_value; // Get all the sell operation //---- @@ -243,7 +243,7 @@ where return $r; foreach ($step_client as $client ) { $r.=""; - $e=sprintf(' ', + $e=sprintf(' ', $script,$client->id,$str_dossier,$url); $r.=" $e".$client->strAttribut(ATTR_DEF_QUICKCODE).""; @@ -263,25 +263,30 @@ where $r.=sprintf(' %15.2f€',$a['debit']); $r.=sprintf(' %15.2f€',$a['credit']); $r.=sprintf(' %15.2f€',$a['solde']); - $r.=""; - $r.=sprintf('Contact', - $script,$client->strAttribut(ATTR_DEF_QUICKCODE),$str_dossier,$url); - $r.=sprintf('Courrier ', - $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); - - - - $r.='Facture'; - $r.=sprintf('Financier', - $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); - - $r.=sprintf('Contact', + $script,$client->strAttribut(ATTR_DEF_QUICKCODE),$str_dossier,$url); + $r.=sprintf('Courrier ', + $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); + + + } + $p_action_ven=( $script == "commercial.php")?"p_action=client&sa=f":"p_action=ven&sa=l"; + $r.='Facture'; + $r.=sprintf('Financier', + $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); + + $r.=sprintf('Operation', - $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); - - $r.=''; - + $script,$client->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); + + $r.=''; + + + $r.=""; } diff --git a/include/class_document.php b/include/class_document.php index 80d7d358e..50d75204a 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -21,6 +21,8 @@ require_once('class_own.php'); require_once('class_acc_account_ledger.php'); require_once('class_action.php'); +require_once('class_acc_tva.php'); + /*! \file * \brief Class Document corresponds to the table document */ @@ -71,8 +73,6 @@ class Document * \brief Generate the document, Call $this-\>Replace to replace * tag by value * - * \param none - * * * \return an array : the url where the generated doc can be found, the name * of the file and his mimetype @@ -190,7 +190,7 @@ class Document { if ( mkdir($temp_dir) == false ) { - echo "Ne peut pas cr�er le r�pertoire ".$temp_dir; + echo "Ne peut pas cr�er le r�pertoire ".$temp_dir; exit(); } } @@ -300,7 +300,7 @@ class Document ); ExecSql($this->db,$sql); $this->d_id=GetSequence($this->db,"document_d_id_seq"); - echo_debug('class_document',__LINE__,'document sauv� : d_id'.$this->d_id); + echo_debug('class_document',__LINE__,'document sauv� : d_id'.$this->d_id); // Clean the file unlink ($p_file); Commit($this->db); @@ -464,11 +464,13 @@ class Document * - [MY_TVA] * - [MY_STREET] * - [MY_NUMBER] + * - TVA_CODE + * - TVA_RATE * - BON_COMMANDE * - OTHER_INFO * - CUST_NUM * - * \param TAG + * \param $p_tag TAG * \return String which must replace the tag */ function Replace($p_tag) @@ -655,6 +657,16 @@ class Document $r=${$id}; break; + case 'TVA_RATE': + extract ($_POST); + $id='e_march'.$counter.'_tva_id'; + if ( !isset (${$id}) ) return ""; + if ( ${$id} == -1 ) return ""; + $tva=new Acc_Tva($this->db); + $tva->set_parameter("id",${$id}); + $tva->load(); + return $tva->get_parameter("rate"); + break; case 'TVA_CODE': extract ($_POST); diff --git a/include/class_document_modele.php b/include/class_document_modele.php index 1d7c5787d..32798bb98 100644 --- a/include/class_document_modele.php +++ b/include/class_document_modele.php @@ -82,11 +82,11 @@ class Document_modele { $a->name="sa"; $a->value="rm_template"; $r.=$a->IOValue(); - $r.=widget::submit("rm_template","Effacer la sélection"); + $r.=widget::submit("rm_template","Effacer la sélection"); $r.="

"; return $r; } - /*! Save + /*! ************************************************** * \brief : Save a document_modele in the database, * if the document_modele doesn't exist yet it will be @@ -95,12 +95,6 @@ class Document_modele { * set before calling Save, the name will be modified * with FormatString * - * parm : - * - none - * gen : - * - none - * return: - * - none */ function Save() { @@ -254,39 +248,50 @@ class Document_modele { /*! * \brief show the form for loading a template * \param p_action for the field action = destination url - * \param - * \param * * * \return string containing the forms */ function form($p_action) { - $r="

"; + $r='

'; + $r.='Veuillez introduire les modèles servant à générer vos documents'; + $r.='

'; $r.='
'; - $r.=dossier::hidden(); - $t=new widget("text"); - $t->name="md_name"; - $r.=" Nom ".$t->IOValue().""; - $r.="Type de document "; - $w=new widget("select"); - $w->name="md_type"; - $w->value=make_array($this->cn,'select dt_id,dt_value from document_type'); - $r.=$w->IOValue(); - $r.="

"; - $f=new widget("file"); - $f->name="doc"; - $r.="fichier ".$f->IOValue().""; + $r.=dossier::hidden(); // we need to add the sub action as hidden $h=new widget("hidden"); $h->name="sa"; $h->value="add_document"; + $r.=$h->IOValue(); + + $r.=''; + $t=new widget("text"); + $t->name="md_name"; + $r.=""; + + $r.=""; + $r.=""; + $w=new widget("select"); + $w->name="md_type"; + + $w->value=make_array($this->cn,'select dt_id,dt_value from document_type'); + $r.=""; + + $f=new widget("file"); + $f->name="doc"; + $r.=""; + $start=new widget("text"); $start->name="start_seq"; $start->size=9; $start->value="0"; - $r.=" Numerotation commence a ".$start->IOValue().""; + + $r.=""; + $r.=''; + $r.=""; + $r.='
Nom ".$t->IOValue()."
Type de document ".$w->IOValue()."
fichier ".$f->IOValue()."
Numerotation commence a ".$start->IOValue()."Si vous laissez à 0, la numérotation ne changera pas
'; $r.=widget::submit('add_document','Ajout'); $r.="

"; return $r; diff --git a/include/class_dossier.php b/include/class_dossier.php index 3ad92d9bf..359ed30d0 100644 --- a/include/class_dossier.php +++ b/include/class_dossier.php @@ -29,6 +29,9 @@ /*! \brief manage the current dossier, everywhere we need to know to * which folder we are connected, because we can't use $_SESSION, we * need to pass the dossier_id via a _GET or a POST variable + * private static $variable=array("id"=>"dos_id", + "name"=>"dos_name", + "desc"=>"dos_description"); * */ require_once('postgres.php'); @@ -36,12 +39,16 @@ include_once('debug.php'); require_once('ac_common.php'); class dossier { - - + private static $variable=array("id"=>"dos_id", + "name"=>"dos_name", + "desc"=>"dos_description"); + function __construct($p_id) { + $this->cn=DbConnect(); // Connect to the repository + $this->dos_id=$p_id; + } /*!\brief return the $_REQUEST['gDossier'] after a check */ static function id() { echo_debug(__FILE__,__LINE__,"id"); - echo_debug(__FILE__,__LINE__,$_REQUEST); self::check(); return $_REQUEST['gDossier']; } @@ -56,7 +63,6 @@ class dossier { /*!\brief return a string to put to gDossier into a GET */ static function get() { echo_debug(__FILE__,__LINE__,"get"); - echo_debug(__FILE__,__LINE__,$_REQUEST); self::check(); return "gDossier=".$_REQUEST['gDossier']; @@ -65,18 +71,74 @@ class dossier { /*!\brief return a string to set gDossier into a FORM */ static function hidden() { echo_debug(__FILE__,__LINE__,"hidden"); - echo_debug(__FILE__,__LINE__,$_REQUEST); self::check(); return ''; } /*!\brief retrieve the name of the current dossier */ - static function name() { + static function name($id=0) { echo_debug(__FILE__,__LINE__,"get_name"); - echo_debug(__FILE__,__LINE__,$_REQUEST); self::check(); $cn=DbConnect(); - $name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=".$_REQUEST['gDossier']); + $id=($id==0)?$_REQUEST['gDossier']:$id; + $name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=$1",array($_REQUEST['gDossier'])); return $name; } + + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + + + } + public function get_info() { return var_export(self::$variable,true); } + + public function save() { + $this->update(); + } + + public function update() { + if ( strlen(trim($this->dos_name))== 0 ) return; + + if ( getDbValue($this->cn,"select count(*) from ac_dossier where dos_name=$1 and dos_id<>$2", + array($this->dos_name,$this->dos_id)) !=0 ) + return ; + + $sql="update ac_dossier set dos_name=$1,dos_description=$2 ". + " where dos_id = $3"; + $res=ExecSqlParam($this->cn, + $sql, + array(trim($this->dos_name), + trim($this->dos_description), + $this->dos_id) + ); + } + + public function load() { + + $sql="select dos_name,dos_description from ac_dossier where dos_id=$1"; + + $res=ExecSqlParam($this->cn, + $sql, + array($this->dos_id) + ); + + if ( pg_NumRows($res) == 0 ) return; + $row=pg_fetch_array($res,0); + foreach ($row as $idx=>$value) { $this->$idx=$value; } + } + + } diff --git a/include/class_fiche.php b/include/class_fiche.php index 3b6b79853..4af19d82a 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -92,8 +92,9 @@ class fiche { 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"; + join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and jnt_fic_attr.ad_id=jnt_fic_att_value.ad_id) + join attr_def on (attr_def.ad_id=jnt_fic_att_value.ad_id) where f_id=".$this->id. + " order by jnt_order"; $Ret=ExecSql($this->cn,$sql); if ( ($Max=pg_NumRows($Ret)) == 0 ) @@ -104,6 +105,7 @@ class fiche { $t=new Attribut ($row['ad_id']); $t->ad_text=$row['ad_text']; $t->av_text=$row['av_text']; + $t->jnt_order=$row['jnt_order']; $this->attribut[$i]=$t; } $e=new Fiche_def($this->cn,$this->fiche_def); @@ -123,6 +125,7 @@ class fiche { $t=new Attribut ($f->ad_id); $t->av_text=""; $t->ad_text=$f->ad_text; + $t->jnt_order=$f->jnt_order; $this->attribut[$Max]=$t; $Max++; } // if flag == 0 @@ -152,9 +155,9 @@ class fiche { ************************************************** * \brief Return array of card from the frd family * - * \param the fiche_def_ref.frd_id - * \param p_search is a filter on the name - * \param p_sql extra sql condition + * \param $p_frd_id the fiche_def_ref.frd_id + * \param $p_search p_search is a filter on the name + * \param $p_sql extra sql condition * * \return array of fiche object */ @@ -179,8 +182,9 @@ class fiche { * \brief Return array of card from the frd family * * - * \param the fiche_def_ref.frd_id - * \param p_search is an optional filter + * \param $p_frd_id the fiche_def_ref.frd_id + * \param $p_offset + * \param $p_search is an optional filter * * \return array of fiche object */ @@ -230,7 +234,7 @@ class fiche { ************************************************** * \brief return the string of the given attribute * (attr_def.ad_id) - * \param the AD_ID from attr_def.ad_id + * \param $p_ad_id the AD_ID from attr_def.ad_id * \see constant.php * \return string */ @@ -238,6 +242,7 @@ class fiche { { if ( sizeof ($this->attribut) == 0 ) { + if ($this->id==0) return '- ERROR -'; // object is not in memory we need to look into the database $sql="select av_text from attr_value join jnt_fic_att_value using(jft_id) @@ -290,14 +295,14 @@ class fiche { $label->name="av_text".$attr->ad_id."_label"; if ( $a['account_auto'] == 't' ) - $msg.="".$label->IOValue()."
Rappel: Poste créé automatiquement ! "; + $msg.="".$label->IOValue()."
Rappel: Poste créé automatiquement ! "; else { // if there is a class base in fiche_def_ref, this account will be the // the default one if ( strlen(trim($f->class_base)) != 0 ) { - $msg.="".$label->IOValue()."
Rappel: Poste par défaut sera ". + $msg.="".$label->IOValue()."
Rappel: Poste par défaut sera ". $f->class_base. " ! "; } @@ -354,7 +359,7 @@ class fiche { $ret=""; if ( empty ($attr) ) { - return "Fiche non trouvée"; + return "Fiche non trouvée"; } foreach ( $attr as $r) { @@ -377,7 +382,8 @@ class fiche { $msg=''; if ( $a['account_auto'] == 't' ) - $msg.=" "; + $msg.=" "; + $msg.=""; } elseif ( $r->ad_id == ATTR_DEF_TVA) { @@ -407,6 +413,7 @@ class fiche { $w->readonly=$p_readonly; $w->table=1; + $ret.="".$w->IOValue()."$msg "; } $ret.="
si vide le Poste sera créé automatiquement si vide le Poste sera créé automatiquement ATTENTION changer le poste comptable d'une fiche modifiera toutes les opérations où cette fiche est utilisée
"; @@ -511,7 +518,7 @@ class fiche { $sql=sprintf("select account_insert(%d,null)", $this->id); } - ExecSql($this->cn,$sql,false); + ExecSql($this->cn,$sql); } catch (Exception $e) { throw new Exception ("Erreur : ce compte [$v] n'a pas de compte parent.". "L'opération est annulée", @@ -659,12 +666,17 @@ class fiche { $sql=sprintf("select account_update(%d,%d)", $this->id,$v); try { - ExecSql($this->cn,$sql,false); + ExecSql($this->cn,$sql); + /* update also the jrnx */ + $sql='update jrnx set j_poste=$1 where j_qcode in (select quick_code from vw_fiche_attr where f_id=$2)'; + ExecSqlParam($this->cn, + $sql, + array($v,$this->id)); + } catch (Exception $e) { throw new Exception(__LINE__."Erreur : ce compte [$v] n'a pas de compte parent.". "L'opération est annulée"); } - continue; } if ( strlen (trim($v)) == 0 ) @@ -673,11 +685,19 @@ class fiche { $sql=sprintf("select account_update(%d,null)", $this->id); try { - $Ret=ExecSql($this->cn,$sql,false); + $Ret=ExecSql($this->cn,$sql); + /* update also the jrnx */ + + $sql='update jrnx set j_poste=$1 where j_qcode in (select quick_code from vw_fiche_attr where f_id=$2)'; + ExecSqlParam($this->cn, + $sql, + array($v,$this->id)); + } catch (Exception $e) { throw new Exception(__LINE__."Erreur : ce compte [$v] n'a pas de compte parent.". "L'opération est annulée"); } + continue; } } @@ -705,7 +725,7 @@ class fiche { if ( $exist == 0 && FormatString($value) != null ) { - $value="Attention : pas de société "; + $value="Attention : pas de société "; } } @@ -743,7 +763,7 @@ class fiche { if ( CountSql($this->cn,"select * from jrnx where j_qcode='".pg_escape_string($qcode)."'") != 0) { - echo ""; + echo ""; return; } @@ -756,7 +776,7 @@ class fiche { // if class is not NULL and if we use it before, we can't remove it if (FormatString($class) != null && $is_used_jrnx != 0 ) { - echo ""; + echo ""; return; } else @@ -767,16 +787,7 @@ class fiche { } } - // Remove from attr_value - $Res=ExecSql($this->cn,"delete from attr_value - where jft_id in (select jft_id - from jnt_fic_att_value - natural join fiche where f_id=".$this->id.")"); - // Remove from jnt_fic_att_value - $Res=ExecSql($this->cn,"delete from jnt_fic_att_value where f_id=".$this->id); - - // Remove from fiche - $Res=ExecSql($this->cn,"delete from fiche where f_id=".$this->id); + $this->delete(); } @@ -841,7 +852,6 @@ class fiche { * * \param $p_from periode from * \param $p_to end periode - * \param $p_qcode quick_code of the card * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) * (tot_deb,tot_credit * @@ -909,8 +919,8 @@ class fiche { " Code interne ". " Date". " Description ". - " Débit ". - " Crédit ". + " Montant ". + " Débit/Crédit ". ""; foreach ( $this->row as $op ) { @@ -926,7 +936,7 @@ class fiche { echo $ac->display_jrnx_detail(1); } - $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; + $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; $diff=round(abs($tot_deb-$tot_cred),2); echo "". "$solde_type". @@ -942,9 +952,7 @@ class fiche { } /*! * \brief HtmlTable, display a HTML of a card for the asked period - * \param none - * - * \return none + * \param $p_array default = null keys = from_periode, to_periode */ function HtmlTable($p_array=null) { @@ -968,8 +976,8 @@ class fiche { " Code interne ". " Date". " Description ". - " Débit ". - " Crédit ". + " Débit ". + " Crédit ". ""; foreach ( $this->row as $op ) { @@ -982,7 +990,7 @@ class fiche { ""; } - $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; + $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur"; $diff=round(abs($tot_deb-$tot_cred),2); echo "". "$solde_type". @@ -1075,11 +1083,28 @@ function get_solde_detail($p_cond="") { 'credit'=>$r['sum_cred'], 'solde'=>abs($r['sum_deb']-$r['sum_cred'])); } +/*!\brief check if an attribute is empty + *\param + *\return return true is the attribute is empty or missing + */ +function empty_attribute($p_attr) { + $sql="select av_text + from jnt_fic_att_value + natural join fiche + natural join attr_value + left join attr_def using (ad_id) where f_id=".$this->id. + " and ad_id = ".$p_attr. + " order by ad_id"; + $res=ExecSql($this->cn,$sql); + if ( pg_NumRows($res) == 0 ) return true; + $text=pg_fetch_result($res,0,0); + return (strlen(trim($text)) > 0)?false:true; + + +} + /*! - * \brief get the fd_id of the card : fd_id - * \param none - * - * \return none + * \brief get the fd_id of the card : fd_id, it set the attribute fd_id */ function get_categorie() { @@ -1098,7 +1123,7 @@ function get_solde_detail($p_cond="") { * or the id must be set * * - * \param $j_jrn journal_id + * \param $p_jrn journal_id * \param $p_type : deb or cred default empty * *\todo fiche::belong_ledger this function will replace fiche_inc.php @@ -1152,16 +1177,26 @@ function belong_ledger($p_jrn,$p_type="") if ( $Max==0) { return -2; } + /* convert the array to a string */ + $list=pg_fetch_all($Res); + $str_list=""; + $comma=''; + foreach ($list as $row) { + if ( $row['fiche'] != '' ) { + $str_list.=$comma.$row['fiche']; + $comma=','; + } + } // Normally Max must be == 1 - $list=pg_fetch_array($Res,0); - if ( $list['fiche']=="") { + + if ( $str_list=="") { return -3; } $sql="select * from fiche where - fd_id in (".$list['fiche'].") and f_id= ".$this->id; + fd_id in (".$str_list.") and f_id= ".$this->id; $Res=ExecSql($this->cn,$sql); $Max=pg_NumRows($Res); @@ -1170,6 +1205,44 @@ function belong_ledger($p_jrn,$p_type="") else return 1; } - +/*!\brief get all the card from a categorie + *\param $p_cn database connx + *\param $pFd_id is the category id + *\return an array of card, but only the fiche->id is set + */ +static function get_fiche_def($p_cn,$pFd_id) { + $sql='select f_id from fiche where fd_id=$1'; + $array=get_array($p_cn,$sql,array($pFd_id)); + if ( empty ($array) ) return null; + foreach ($array as $ret ) { + $r[]=new fiche($p_cn,$ret['f_id']); + } + return $r; +} +/*!\brief check if a card is used + *\return return true is a card is used otherwise false + */ +function is_used() { + /* retrieve first the quickcode */ + $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE); + $sql='select count(*) as c from jrnx where j_qcode=$1'; + $count=getDbValue($this->cn,$sql,array($qcode)); + if ( $count == 0 ) return false; + return true; +} +/*\brief remove a card without verification */ + function delete() { + // Remove from attr_value + $Res=ExecSql($this->cn,"delete from attr_value + where jft_id in (select jft_id + from jnt_fic_att_value + natural join fiche where f_id=".$this->id.")"); + // Remove from jnt_fic_att_value + $Res=ExecSql($this->cn,"delete from jnt_fic_att_value where f_id=".$this->id); + + // Remove from fiche + $Res=ExecSql($this->cn,"delete from fiche where f_id=".$this->id); + +} } ?> diff --git a/include/class_fiche_def.php b/include/class_fiche_def.php index fc21c9e0a..78dbe4611 100644 --- a/include/class_fiche_def.php +++ b/include/class_fiche_def.php @@ -55,7 +55,7 @@ class fiche_def { function GetAttribut() { $sql="select * from jnt_fic_attr ". " natural join attr_def where fd_id=".$this->id. - " order by ad_id"; + " order by jnt_order"; $Ret=ExecSql($this->cn,$sql); @@ -65,6 +65,7 @@ class fiche_def { $row=pg_fetch_array($Ret,$i); $t = new Attribut($row['ad_id']); $t->ad_text=$row['ad_text']; + $t->jnt_order=$row['jnt_order']; $this->attribut[$i]=$t; } return $this->attribut; @@ -217,8 +218,8 @@ class fiche_def { // Add the class_base if needed - $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id) - values (%d,%d)",$fd_id,ATTR_DEF_ACCOUNT); + $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order) + values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT); $Res=ExecSql($this->cn,$sql); } else { @@ -241,9 +242,12 @@ class fiche_def { if (sizeof($def_attr) != 0 ) { // insert all the mandatory fields into jnt_fiche_attr foreach ( $def_attr as $i=>$v) { - $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id) - values (%d,%s)", - $fd_id,$v['ad_id']); + $jnt_order=10; + if ( $v['ad_id'] == ATTR_DEF_NAME ) + $jnt_order=0; + $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order) + values (%d,%s,%d)", + $fd_id,$v['ad_id'],$jnt_order); ExecSql($this->cn,$sql); } } @@ -396,11 +400,19 @@ class fiche_def { $this->attribut[$i]->ad_id); } else - $add_action=""; + $add_action=""; } // The attribut. $a=sprintf('%s ', $this->attribut[$i]->ad_text); $r.=$a.$add_action; + /*---------------------------------------- */ + /* ORDER OF THE CARD */ + /*---------------------------------------- */ + $order=new widget('text'); + $order->name='jnt_order'.$this->attribut[$i]->ad_id; + $order->size=3; + $order->value=$this->attribut[$i]->jnt_order; + $r.=' '.$order->IOValue(); } $r.= ''; } @@ -449,10 +461,13 @@ class fiche_def { function InsertAttribut($p_ad_id) { if ( $this->id == 0 ) return; + /* ORDER */ + $this->GetAttribut(); + $max=sizeof($this->attribut); // Insert a new attribute for the model // it means insert a row in jnt_fic_attr - $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id) values (%d,%d)", - $this->id,$p_ad_id); + $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) values (%d,%d,%d)", + $this->id,$p_ad_id,$max); $Res=ExecSql($this->cn,$sql); // update all the existing card @@ -488,6 +503,57 @@ class fiche_def { } } + /*!\brief save the order of a card, update the column jnt_fic_attr.jnt_order + *\param array containing the order + */ + function save_order($p_array) { + extract($p_array); + + $this->GetAttribut(); + foreach ($this->attribut as $row){ + if ( $row->ad_id == 1 ) continue; + if ( ${'jnt_order'.$row->ad_id} <= 0 ) continue; + $sql='update jnt_fic_attr set jnt_order=$1 where fd_id=$2 and ad_id=$3'; + ExecSqlParam($this->cn,$sql,array(${'jnt_order'.$row->ad_id}, + $this->id, + $row->ad_id)); + } + } + + + /*!\brief remove all the card from a categorie after having verify + *that the card is not used and then remove also the category + *\return the remains items, not equal to 0 if a card remains and + *then the category is not removed + */ + function remove() { + $remain=0; + /* get all the card */ + $aFiche=fiche::get_fiche_def($this->cn,$this->id); + if ( $aFiche != null ) { + /* check if the card is used */ + foreach ($aFiche as $fiche) { + + /* if the card is not used then remove it otherwise increment remains */ + if ( $fiche->is_used() == false ) { + $fiche->delete(); + } else + $remain++; + } + } + /* if remains == 0 then remove cat */ + if ( $remain == 0 ) { + $sql='delete from jnt_fic_attr where fd_id=$1'; + ExecSqlParam($this->cn,$sql,array($this->id)); + $sql='delete from fiche_def where fd_id=$1'; + ExecSqlParam($this->cn,$sql,array($this->id)); + } + + return $remain; + + } + + } ?> diff --git a/include/class_own.php b/include/class_own.php index f3b3d22f2..f68597a52 100644 --- a/include/class_own.php +++ b/include/class_own.php @@ -45,7 +45,7 @@ class Own { * \brief Update a row * * - * \param give the attribut name + * \param $p_attr give the attribut name * */ function UpdateRow($p_attr) { diff --git a/include/class_parm_code.php b/include/class_parm_code.php index 36f8191d8..97e05340b 100644 --- a/include/class_parm_code.php +++ b/include/class_parm_code.php @@ -139,7 +139,7 @@ class parm_code { */ function Get() { - if ( $this->p_code == -1 ) return "p_code non initialisé"; + if ( $this->p_code == -1 ) return "p_code non initialisé"; $sql=sprintf("select * from parm_code where p_code='%s' ", $this->p_code); $Res=ExecSql($this->db,$sql); diff --git a/include/class_periode.php b/include/class_periode.php index 5edd03f6f..62d70bc98 100644 --- a/include/class_periode.php +++ b/include/class_periode.php @@ -46,6 +46,18 @@ class Periode { function set_periode($pp_id){ $this->p_id=$pp_id; } + /*!\brief return the p_id of the start and the end of the exercice + *into an array + *\param $p_exercice + *\return array [start]=>,[end]=> + */ + function limit_year($p_exercice) { + $sql_start="select p_id from parm_periode where p_exercice=$1 order by p_start ASC"; + $start=getDbValue($this->cn,$sql_start,array($p_exercice)); + $sql_end="select p_id from parm_periode where p_exercice=$1 order by p_start ASC"; + $end=getDbValue($this->cn,$sql_end,array($p_exercice)); + return array("start"=>$start,"end"=>$end); + } function is_closed() { if ( $this->jrn_def_id != 0 ) $sql="select status from jrn_periode ". @@ -131,12 +143,7 @@ class Periode { } /*! - * \brief Show all the periode and their status - * - * \param $p_cn database connection - * - * \return nothing - * + * \brief Display all the periode and their status * */ @@ -273,8 +280,6 @@ class Periode { $row=get_array($this->cn,"select p_start,p_end,p_exercice,p_closed,p_central from parm_periode where p_id=$1", array($this->p_id)); - - if ($row == null ) return; $this->p_start=$row[0]['p_start']; @@ -301,8 +306,30 @@ class Periode { $rMin->load(); return array($rMax,$rMin); } +/*! + * \brief Give the start & end date of a periode + * + * \return array containing the start date & the end date + * + * + */ + public function get_date_limit($p_periode) { + $sql="select to_char(p_start,'DD.MM.YYYY') as p_start, + to_char(p_end,'DD.MM.YYYY') as p_end + from parm_periode + where p_id=".$p_periode; + $Res=ExecSql($this->cn,$sql); + if ( pg_NumRows($Res) == 0) return null; + return pg_fetch_array($Res,0); + + } + function get_exercice() { + $sql="select p_exercice from parm_periode where p_id=".$this->id; + $Res=ExecSql($this->cn,$sql); + if ( pg_NumRows($Res) == 0) return null; + return pg_fetch_result($Res,0,0); - + } static function test_me() { $cn=DbConnect(dossier::id()); $obj=new Periode($cn); diff --git a/include/class_pre_op_ach.php b/include/class_pre_op_ach.php index 6e3906b70..6a50ff64c 100644 --- a/include/class_pre_op_ach.php +++ b/include/class_pre_op_ach.php @@ -88,7 +88,7 @@ class Pre_op_ach extends Pre_operation_detail { echo ($e->getMessage()); Rollback($this->db); } - + Commit($this->db); } /*!\brief compute an array accordingly with the FormVenView function */ diff --git a/include/class_pre_op_ven.php b/include/class_pre_op_ven.php index 41bee4454..2b9bf991b 100644 --- a/include/class_pre_op_ven.php +++ b/include/class_pre_op_ven.php @@ -68,6 +68,7 @@ class Pre_op_ven extends Pre_operation_detail { ExecSql($this->db,$sql); // save the selling for ($i=0;$i<$this->operation->nb_item;$i++) { + if ( strlen(trim($this->{"e_march".$i}))==0) continue; $sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,opd_tva_id,opd_quantity,'. 'opd_debit,od_id)'. ' values '. @@ -85,6 +86,7 @@ class Pre_op_ven extends Pre_operation_detail { echo ($e->getMessage()); Rollback($this->db); } + commit($this->db); } /*!\brief compute an array accordingly with the FormVenView function diff --git a/include/class_pre_operation.php b/include/class_pre_operation.php index 93d368737..5fab3b624 100644 --- a/include/class_pre_operation.php +++ b/include/class_pre_operation.php @@ -147,6 +147,9 @@ class Pre_operation $all=pg_fetch_all($res); return $all; } + /*!\brief set the ledger + * \param $p_jrn is the ledger (jrn_id) + */ function set_jrn($p_jrn) { $this->p_jrn=$p_jrn; } @@ -161,9 +164,71 @@ class Pre_operation_detail { function __construct($p_cn) { $this->db=$p_cn; $this->operation=new Pre_operation($this->db); + $this->valid=array('ledger'=>'jrn_def_id','ledger_type'=>'jrn_type','direct'=>'od_direct'); } + + /*!\brief show a form to use pre_op + */ + function form_get () { + + $hid=new widget("hidden"); + $r=$hid->IOValue("action","use_opd"); + $r.=dossier::hidden(); + $r.=$hid->IOValue("p_jrn",$this->get("ledger")); + $r.=$hid->IOValue("jrn_type",$this->get("ledger_type")); + + // if ($this->count() != 0 ) + $r.= widget::submit('use_opd','Utilisez une op.prédéfinie'); + $r.= $this->show_button(); + return $r; + + } + /*!\brief count the number of pred operation for a ledger */ + function count() { + $a=CountSql($this->db,"select od_id,od_name from op_predef ". + " where jrn_def_id=".$this->jrn_def_id. + " and od_direct ='".$this->od_direct."'". + " order by od_name"); + return $a; + } + /*!\brief show the button for selecting a predefined operation */ + function show_button() { + + $select=new widget("select"); + + $value=$this->get_operation(); + // if ( empty($value)==true) return ""; + $select->value=$value; + $r=$select->IOValue("pre_def"); + return $r; + } + public function get_operation() { + $value=make_array($this->db,"select od_id,od_name from op_predef ". + " where jrn_def_id=".FormatString($this->jrn_def_id). + " and od_direct ='".FormatString($this->od_direct)."'". + " order by od_name"); + return $value; + } + function set($p_param,$value) { + if ( ! isset ($this->valid[$p_param] ) ) { + echo(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__); + exit(); + } + $attr=$this->valid[$p_param]; + $this->$attr=$value; + } + function get($p_param) { + + if ( ! isset ($this->valid[$p_param] ) ) { + echo(" le parametre $p_param n'existe pas ".__FILE__.':'.__LINE__); + exit(); + } + $attr=$this->valid[$p_param]; + return $this->$attr; + } + function get_post() { $this->operation->get_post(); } diff --git a/include/class_rapport.php b/include/class_rapport.php index 0ff41e820..e69b2d9eb 100644 --- a/include/class_rapport.php +++ b/include/class_rapport.php @@ -21,19 +21,28 @@ /*! \file * \brief Create, view, modify and parse report */ + +require_once('class_rapport_row.php'); +require_once('class_widget.php'); +require_once('impress_inc.php'); + /*! * \brief Class rapport Create, view, modify and parse report */ -class rapport { +class Rapport { + var $db; /*!< $db database connx */ var $id; /*!< $id formdef.fr_id */ var $name; /*!< $name report's name */ + var $aRapport_row; /*!< array of rapport_row */ + var $nb; /*!\brief Constructor */ - function rapport($p_cn,$p_id) { + function __construct($p_cn,$p_id=0) { $this->db=$p_cn; $this->id=$p_id; - $this->name='UNDEF'; + $this->name='Nouveau'; + $this->aRapport_row=null; } /*!\brief Return the report's name */ @@ -68,17 +77,274 @@ class rapport { for ($i=0;$i<$Max;$i++) { $l_line=pg_fetch_array($Res,$i); $col[]=ParseFormula($this->db, - $l_line['fo_label'], - $l_line['fo_formula'], - $p_start, - $p_end, - true, - $p_type_date - ); + $l_line['fo_label'], + $l_line['fo_formula'], + $p_start, + $p_end, + true, + $p_type_date + ); } //for ($i $this->row=$col; return $col; } +/*! + * \brief Display a form for encoding a new report or update one + * + * \param $p_line number of line + * + */ +function form($p_line=0) { + $search_poste=new widget('JS_SEARCH_POSTE'); + $search_poste->extra='not'; + $r=""; + if ($p_line == 0 ) $p_line=count($this->aRapport_row); + $r.= dossier::hidden(); + $r.= widget::hidden('line',$p_line); + $r.= widget::hidden('fr_id',$this->id); + $wForm=new widget("text"); + $r.="Nom du rapport : "; + $r.=$wForm->IOValue('form_nom',$this->name); + + $r.= ''; + $r.= ""; + $r.= ""; + $r.= ""; + $r.= ""; + + $r.= ''; + $wName=new widget("text"); + $wName->size=50; + $wPos=new widget("text"); + $wPos->size=3; + $wForm=new widget("text"); + $wForm->size=35; + for ( $i =0 ; $i < $p_line;$i++) { + + $r.= ""; + + $r.= "'; + + + $r.= "'; + + $r.= "'; + + $r.= ""; + } + + $r.= "
Position Texte Formule
"; + $wPos->value=( isset($this->aRapport_row[$i]->fo_pos))?$this->aRapport_row[$i]->fo_pos:$i+1; + $r.=$wPos->IOValue("pos".$i); + $r.= '"; + $wName->value=( isset($this->aRapport_row[$i]->fo_label))?$this->aRapport_row[$i]->fo_label:""; + $r.=$wName->IOValue("text".$i); + $r.= '"; + $wForm->value=( isset($this->aRapport_row[$i]->fo_formula))?$this->aRapport_row[$i]->fo_formula:""; + $r.=$wForm->IOValue("form".$i); + + $r.= '
"; + $wButton=new widget("button"); + $wButton->javascript=' rapport_add_row();'; + $wButton->label="Ajout d'une ligne"; + $r.=$wButton->IOValue(); + return $r; + } + /*!\brief save into form and form_def + */ + function save() { + + if ( strlen(trim($this->name)) == 0 ) + return; + if ( $this->id == 0 ) + $this->insert(); + else + $this->update(); + + } + function insert() { + try { + startSql($this->db); + $ret_sql=ExecSqlParam($this->db, + "insert into formdef (fr_label) values($1) returning fr_id", + array($this->name) + ); + $this->id=pg_fetch_result($ret_sql,0,0); + $ix=1; + foreach ( $this->aRapport_row as $row) { + if ( strlen(trim($row->get_parameter("name"))) != 0 && + strlen(trim($row->get_parameter("formula"))) != 0 ) + { + $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; + $row->set_parameter("position",$ix); + $ret_sql=ExecSqlParam($this->db, + "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". + " values($1,$2,$3,$4)", + array($this->id, + $row->fo_pos, + $row->fo_label, + $row->fo_formula) + ); + } + } + + } catch (Exception $e) { + Rollback($this->db); + echo $e->getMessage(); + } + Commit($this->db); + + } + function update() { + try { + startSql($this->db); + $ret_sql=ExecSqlParam($this->db, + "update formdef set fr_label=$1 where fr_id=$2", + array($this->name,$this->id)); + $ret_sql=ExecSqlParam($this->db, + "delete from form where fo_fr_id=$1", + array($this->id)); + $ix=0; + + foreach ( $this->aRapport_row as $row) { + if ( strlen(trim($row->get_parameter("name"))) != 0 && + strlen(trim($row->get_parameter("formula"))) != 0 ) + { + + $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; + $row->set_parameter("position",$ix); + $ret_sql=ExecSqlParam($this->db, + "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". + " values($1,$2,$3,$4)", + array($this->id, + $row->fo_pos, + $row->fo_label, + $row->fo_formula) + ); + } + } + + + }catch (Exception $e) { + Rollback($this->db); + echo $e->getMessage(); + } + Commit($this->db); + } + /*!\brief fill a form thanks an array, usually it is $_POST + *\param $p_array keys = fr_id, form_nom,textXX, formXX, posXX where + XX is an number + */ + function from_array($p_array) { + $this->id=(isset($p_array['fr_id']))?$p_array['fr_id']:0; + $this->name=(isset($p_array['form_nom']))?$p_array['form_nom']:""; + $ix=0; + + $rr=new Rapport_Row(); + $rr->set_parameter("form_id",$this->id); + $rr->set_parameter('database',$this->db); + + $this->aRapport_row=$rr->from_array($p_array); + + + } + /*!\brief the fr_id MUST be before called + */ + + + function load() { + $sql=ExecSqlParam($this->db, + "select fr_label from formdef where fr_id=$1", + array($this->id)); + if ( pg_NumRows($sql) == 0 ) return; + $this->name=pg_fetch_result($sql,0,0); + $sql=ExecSqlParam($this->db, + "select fo_id,fo_pos,fo_label,fo_formula ". + " from form ". + " where fo_fr_id=$1 order by fo_pos", + array($this->id)); + $f=pg_fetch_all($sql); + $array=array(); + if ( ! empty($f) ) { + foreach ($f as $r) { + $obj=new Rapport_Row(); + $obj->set_parameter("name",$r['fo_label']); + $obj->set_parameter("id",$r['fo_id']); + $obj->set_parameter("position",$r['fo_pos']); + $obj->set_parameter("formula",$r['fo_formula']); + $obj->set_parameter('database',$this->db); + $obj->set_parameter('form_id',$this->id); + $array[]=clone $obj; + } + } + $this->aRapport_row=$array; + + } + function delete() { + $ret=ExecSqlParam($this->db, + "delete from formdef where fr_id=$1", + array($this->id) + ); + } + /*!\brief get a list from formdef of all defined form + * + *\return array of object rapport + * + */ + function get_list() + { + $sql="select fr_id,fr_label from formdef order by fr_label"; + $ret=ExecSql($this->db,$sql); + if ( pg_NumRows($ret) == 0 ) return array(); + $array=pg_fetch_all($ret); + $obj=array(); + foreach ($array as $row) { + $tmp=new Rapport($this->db); + $tmp->id=$row['fr_id']; + $tmp->name=$row['fr_label']; + $obj[]=clone $tmp; + } + return $obj; + } + /*!\brief To make a SELECT button with the needed value, it is used + *by the SELECT widget + *\return string with html code + */ + function make_array() { + $sql=make_array($this->db,"select fr_id,fr_label from formdef order by fr_label"); + return $sql; + } + + function test_me() { + $cn=DbConnect(dossier::id()); + $a=new Rapport($cn); + print_r($a->get_list()); + $array=array("text0"=>"test1", + "form0"=>"7%", + "text1"=>"test2", + "form1"=>"6%", + "fr_id"=>110, + "form_nom"=>"Tableau" + ); + $a->from_array($array); + print_r($a); + echo '
'; + echo $a->form(10); + echo ''; + /* Add a line should be a javascript see comptanalytic */ + // $r.= ''; + echo ''; + + echo "
"; + if ( isset ($_POST['update'])) { + $b=new Rapport($cn); + $b->from_array($_POST); + echo '
'; + print_r($b); + } + } +} + ?> diff --git a/include/class_rapport_row.php b/include/class_rapport_row.php new file mode 100644 index 000000000..ef24b3d31 --- /dev/null +++ b/include/class_rapport_row.php @@ -0,0 +1,111 @@ +"fo_label", + "formula"=>"fo_formula", + "id"=>"fo_id", + "position"=>"fo_pos", + "form_id"=>"fo_fr_id", + "database"=>"db" + ); + function __construct ($p_name=null,$p_formula=null) { + $this->set_parameter("id",0); + + $this->set_parameter("name",$p_name); + $this->set_parameter("formula",$p_formula); + } + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__."$p_string ".'Erreur attribut inexistant'); + + + } + public function get_info() { + return var_export(self::$variable,true); + } + /*!\brief Convert an array into an array of row_rapport object + * the fo_id is 0, position = 0, the fo_frd_id (form_id) is + * the one of the current object, the db is also the current one + *\param $p_array contains the value + *\return an array of Rapport_Row object + */ + public function from_array($p_array) { + extract ($p_array); + $ret=array(); + $ix=0; + $found=0; + foreach ( $p_array as $r) { + + if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} )) { + $obj=new Rapport_Row( ${'text'.$ix},${'form'.$ix}); + if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 ) + $obj->set_parameter("position",$ix); + else { + $obj->set_parameter("position",$found); + $found++; + } + $obj->fo_id=0; + $obj->fo_fr_id=$this->fo_fr_id; + $obj->db=$this->db; + + $ret[]=clone $obj; + } + $ix++; + + } + return $ret; + } + function test_me() + { + $cn=DbConnect(dossier::id()); + $a=new Rapport_Row(); + $array=array("text0"=>"test1", + "form0"=>"7%", + "text1"=>"test2", + "form1"=>"6%" + ); + + $b=$a->from_array($array); + print_r($b); + echo $a->get_info(); + } +} diff --git a/include/class_supplier.php b/include/class_supplier.php index 60ccf1094..cd7202a61 100644 --- a/include/class_supplier.php +++ b/include/class_supplier.php @@ -20,7 +20,7 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("constant.php"); require_once("postgres.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once("class_widget.php"); require_once('class_periode.php'); require_once('class_fiche.php'); @@ -82,7 +82,7 @@ class Supplier extends fiche{ $str_dossier=dossier::get(); $p_search=FormatString($p_search); $url=urlencode($_SERVER['REQUEST_URI']); - $script=$_SERVER['PHP_SELF']; + $script=basename($_SERVER['PHP_SELF']); // Creation of the nav bar // Get the max numberRow $all_supplier=$this->CountByDef($this->fiche_def_ref,$p_search); @@ -123,10 +123,10 @@ class Supplier extends fiche{ if ( sizeof ($step_supplier ) == 0 ) return $r; foreach ($step_supplier as $supplier ) { - $r.=""; - $e=sprintf(' ', - $script,$supplier->id,$url); - + $r.=""; + $e=sprintf(' ', + $script,$supplier->id,$url); + $r.=" $e".$supplier->strAttribut(ATTR_DEF_QUICKCODE).""; $r.="".$supplier->strAttribut(ATTR_DEF_NAME).""; $r.="".$supplier->strAttribut(ATTR_DEF_ADRESS). @@ -144,21 +144,22 @@ class Supplier extends fiche{ $r.=sprintf(' %15.2f€',$a['credit']); $r.=sprintf(' %15.2f€',$a['solde']); + if ( $script == 'commercial.php') { - $r.=sprintf('Contact', - $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE),$str_dossier,$url); - $r.=sprintf('Courrier ', - $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); + $r.=sprintf('Contact', + $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE),$str_dossier,$url); + $r.=sprintf('Courrier ', + $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$url); + } + $r.='Facture'; + $r.=sprintf('Financier', + $supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url); - $r.='Facture'; - $r.=sprintf('Financier', - $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$url); - - $r.=sprintf('Operation', - $script,$supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); + $supplier->strAttribut(ATTR_DEF_QUICKCODE) ,$str_dossier,$max->p_id,$min->p_id); $r.=''; diff --git a/include/class_todo_list.php b/include/class_todo_list.php new file mode 100644 index 000000000..e7313b893 --- /dev/null +++ b/include/class_todo_list.php @@ -0,0 +1,179 @@ +"tl_id", + "date"=>"tl_date", + "title"=>"tl_title", + "desc"=>"tl_desc", + "owner"=>"use_login"); + var $cn; + function __construct ($p_init) { + $this->cn=$p_init; + $this->tl_id=0; + $this->tl_desc=""; + $this->use_login=$_SESSION['g_user']; + + } + public function get_parameter($p_string) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + return $this->$idx; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + } + public function set_parameter($p_string,$p_value) { + if ( array_key_exists($p_string,self::$variable) ) { + $idx=self::$variable[$p_string]; + $this->$idx=$p_value; + } + else + exit (__FILE__.":".__LINE__.'Erreur attribut inexistant'); + + + } + public function get_info() { return var_export(self::$variable,true); } + public function verify() { + return 0; + } + public function save() { + if ( $this->get_parameter("id") == 0 ) + $this->insert(); + else + $this->update(); + } + + public function insert() { + if ( $this->verify() != 0 ) return; + + $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login) ". + " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4) returning tl_id"; + $res=ExecSqlParam($this->cn, + $sql, + array($this->tl_date, + $this->tl_title, + $this->tl_desc, + $this->use_login) + ); + $this->tl_id=pg_fetch_result($res,0,0); + + } + + public function update() { + if ( $this->verify() != 0 ) return; + + $sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3 ". + " where tl_id = $4"; + $res=ExecSqlParam($this->cn, + $sql, + array($this->tl_title, + $this->tl_date, + $this->tl_desc, + $this->tl_id) + ); + + } + /*!\brief load all the task + *\return an array of the existing tasks of the current user + */ + public function load_all() { + $sql="select tl_id, tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date +from todo_list where use_login=$1". + " order by tl_date desc"; + $res=ExecSqlParam($this->cn, + $sql, + array($this->use_login)); + $array=pg_fetch_all($res); + return $array; + } + public function load() { + + $sql="select tl_id,tl_title,tl_desc,to_char( tl_date,'DD.MM.YYYY') as tl_date +from todo_list where tl_id=$1"; + + $res=ExecSqlParam($this->cn, + $sql, + array($this->tl_id) + ); + + if ( pg_NumRows($res) == 0 ) return; + $row=pg_fetch_array($res,0); + foreach ($row as $idx=>$value) { $this->$idx=$value; } + } + public function delete() { + $sql="delete from todo_list where tl_id=$1"; + $res=ExecSqlParam($this->cn,$sql,array($this->tl_id)); + + } + public function toJSON() { + $r=''; + $r.='{'; + $r.='"tl_id":"'.$this->tl_id.'",'; + $r.='"tl_title":"'.$this->tl_title.'",'; + $r.='"tl_desc":"'.$this->tl_desc.'",'; + $r.='"tl_date":"'.$this->tl_date.'"'; + $r.='}'; + return $r; + } + /*!\brief static testing function + */ + static function test_me() { + $cn=DbConnect(dossier::id()); + $r=new Todo_List($cn); + $r->set_parameter('title','test'); + $r->use_login='phpcompta'; + $r->set_parameter('date','02.03.2008'); + $r->save(); + $r->set_parameter('id',3); + $r->load(); + print_r($r); + $r->set_parameter('title','Test UPDATE'); + $r->save(); + print_r($r); + $r->set_parameter('id',1); + $r->delete(); + } + +} + + diff --git a/include/class_user.php b/include/class_user.php index fc11f2dc6..d893226e8 100644 --- a/include/class_user.php +++ b/include/class_user.php @@ -41,7 +41,7 @@ class User { // if p_id is not set then check the connected user if ( $p_id == -1 ) { if ( ! isset ($_SESSION['g_user'])) - exit("Utilisateur inexistant"); + exit('

Utilisateur déconnecté

'); echo_debug('class_user.php',__LINE__," g_user = ".$_SESSION['g_user']); $this->id=$_SESSION['g_user']; @@ -126,7 +126,7 @@ class User { echo "





"; echo "

- Invalid user
or
Invalid password + utilisateur ou mot de passe incorrect

"; session_unset(); @@ -140,41 +140,61 @@ class User { } /*! * \brief get all the available ledgers for the current user - * \param none - * \param - * \param - * + * \param $p_type = ALL or the type of the ledger (ACH,VEN,FIN,ODS) + * \param $p_access =3 for READ or WRITE, 2 READ and write, 1 for readonly * * \return an array */ - function get_ledger() { + function get_ledger($p_type='ALL',$p_access=3) { + + if ( $this->admin != 1) { + $sql_type=($p_type=='ALL')?'':"and jrn_def_type=upper('".FormatString($p_type)."')"; + switch($p_access) { + case 3: + $sql_access=" and uj_priv!= 'X'"; + break; + case 2: + $sql_access=" and uj_priv = 'W'"; + break; + + case 1: + $sql_access=" and uj_priv = 'R'"; + break; + + } $sql="select jrn_def_id,jrn_def_type, jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv, jrn_deb_max_line,jrn_cred_max_line from jrn_def join jrn_type on jrn_def_type=jrn_type_id join user_sec_jrn on uj_jrn_id=jrn_def_id where - uj_login='".$this->id."' - and uj_priv !='X' - order by jrn_Def_id"; + uj_login='".$this->id."'". + $sql_type.$sql_access. + " order by jrn_Def_id"; }else { + $sql_type=($p_type=='ALL')?'':"where jrn_def_type=upper('".FormatString($p_type)."')"; $sql="select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line, jrn_type_id,jrn_desc,'W' as uj_priv from jrn_def join jrn_type on jrn_def_type=jrn_type_id + $sql_type order by jrn_Def_id"; } + $res=ExecSql($this->db,$sql); + if ( pg_NumRows($res) == 0 ) return null; $array=pg_fetch_all($res); return $array; } /*!\brief return an sql condition for filtering the permitted ledger + * \param $p_type = ALL or the type of the ledger (ACH,VEN,FIN,ODS) + * \param $p_access =3 for READ or WRITE, 2 READ and write, 1 for readonly * *\return string */ - function get_ledger_sql() { - $aLedger=$this->get_ledger(); + function get_ledger_sql($p_type='ALL',$p_access=3) { + $aLedger=$this->get_ledger($p_type,$p_access); $sql=" jrn_def_id in ("; foreach ($aLedger as $row) { $sql.=$row['jrn_def_id'].','; @@ -227,31 +247,55 @@ function set_periode($p_periode) { $sql="update user_local_pref set parameter_value='$p_periode' where user_id='$this->id' and parameter_type='PERIODE'"; $Res=ExecSql($this->db,$sql); } + /*! * \brief Get the default periode from the user's preferences * - * \param $p_cn connexion - * \param $p_user * \return the default periode * * */ function get_periode() { + $array=$this->get_preference(); return $array['PERIODE']; } + /*!\brief return the mini rapport to display on the welcome page + *\return 0 if nothing if found or the report to display (formdef.fr_id) + */ + function get_mini_report() { + $array=$this->get_preference(); + $fr_id=(isset($array['MINIREPORT']))?$array['MINIREPORT']:0; + return $fr_id; + + } + + /*!\brief set the mini rapport to display on the welcome page + */ + function set_mini_report($p_id) { + $count=getDbValue($this->db,"select count(*) from user_local_pref where user_id=$1 and parameter_type=$2", + array($this->id,'MINIREPORT')); + if ( $count == 1 ) { + $sql="update user_local_pref set parameter_value=$1 where user_id=$2 and parameter_type='MINIREPORT'"; + $Res=ExecSqlParam($this->db,$sql,array($p_id,$this->id)); + } else { + $sql="insert into user_local_pref (user_id,parameter_type,parameter_value)". + "values($1,'MINIREPORT',$2)"; + $Res=ExecSqlParam($this->db,$sql,array($this->id,$p_id)); + } + + + } + + /*! * \brief Get the default user's preferences - * - * - * \param $p_cn connexion - * \param $p_user * \return array of (parameter_type => parameter_value) */ function get_preference () { - // si preference n'existe pas, les créer + // si preference n'existe pas, les créer $sql="select parameter_type,parameter_value from user_local_pref where user_id='".$this->id."'"; $Res=ExecSql($this->db,$sql); if (pg_NumRows($Res) == 0 ) { @@ -264,11 +308,12 @@ function get_preference () $l_array=$this->get_preference(); } else { for ( $i =0;$i < pg_NumRows($Res);$i++) { - $row= pg_fetch_array($Res,0); + $row= pg_fetch_array($Res,$i); $type=$row['parameter_type']; $l_array[$type]=$row['parameter_value']; } } + return $l_array; } /*! @@ -298,7 +343,7 @@ function get_preference () * \brief Get the global preferences from user_global_pref * in the account_repository db * - * \param set g_variable + * \note set $SESSION[g_variable] */ @@ -341,7 +386,8 @@ function load_global_pref() * \brief insert default pref * if no parameter are given insert all the existing * parameter otherwise only the requested - * \param parameter's type or nothing + * \param $p_type parameter's type or nothing + * \param $p_value parameter value * */ function insert_default_global_pref($p_type="",$p_value="") { @@ -349,7 +395,7 @@ function insert_default_global_pref($p_type="",$p_value="") { echo_debug('class_user.php',__LINE__,"parameter p_type $p_type p_value $p_value"); $default_parameter= array("THEME"=>"Light", - "PAGESIZE"=>"50",'TOPMENU'=>'SELECT'); + "PAGESIZE"=>"50",'TOPMENU'=>'TEXT'); $cn=Dbconnect(); $Sql="insert into user_global_pref(user_id,parameter_type,parameter_value) values ('%s','%s','%s')"; @@ -373,8 +419,8 @@ function insert_default_global_pref($p_type="",$p_value="") { * \brief update default pref * if value is not given then use the default value * - * \param parameter's type - * \param parameter's value value of the type + * \param $p_type parameter's type + * \param $p_value parameter's value value of the type */ function update_global_pref($p_type,$p_value="") { $default_parameter= array("THEME"=>"Light", @@ -408,7 +454,7 @@ function get_exercice() /*!\brief Check if the user can access * otherwise warn and exit * \param $p_cn database connx - * \param $action_id + * \param $p_action requested action * \param $p_js = 1 javascript, or 0 just a text * \return nothing the program exits automatically */ @@ -419,14 +465,14 @@ function can_request($p_cn,$p_action,$p_js=0) if ( $p_js == 1 ) { echo ""; } else { echo '
'; - echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; + echo '

Cette action ne vous est pas autorisée Contactez votre responsable

'; echo '
'; } diff --git a/include/class_widget.php b/include/class_widget.php index afb7dbf51..16fe7826e 100644 --- a/include/class_widget.php +++ b/include/class_widget.php @@ -119,15 +119,17 @@ class widget { // Input text type $disabled = $this->disabled ? "readonly" : ""; if (strtoupper($this->type)=="TEXT") { + $t= ((isset($this->title)))?'title="'.$this->title.'" ':' '; + $extra=(isset($this->extra))?$this->extra:""; if ( $this->readonly==true ){ $readonly=" readonly ";$style='style="border:solid 1px grey;color:black;background:lightblue;"'; } else { - $readonly=" ";$style='style="border:solid 1px blue;"'; + $readonly=" ";$style='class="input_text"'; } $this->value=str_replace('"','',$this->value); $r='name.'"'.$t. 'NAME="'.$this->name.'" VALUE="'.$this->value.'" '. 'SIZE="'.$this->size.'" '.$this->javascript." ".$disabled." $readonly $this->extra >"; @@ -148,8 +150,10 @@ class widget { } // Select value if ( strtoupper($this->type) == "SELECT") { + if ($this->readonly==false ) { + $disabled=($this->disabled==true)?"disabled":""; //echo "Selected ".$this->selected; $r=" - Modèle -Année > + Modèle +Année > + + + - +load(); + $wText=new widget('text'); + echo '
'; + echo widget::hidden('action','dossier_mgt'); + echo widget::hidden('d',$dos->get_parameter("id")); + echo 'Nom : '; + echo $wText->IOValue('name',$dos->get_parameter('name')); + echo '
'; + $wDesc=new widget('textarea'); + $wDesc->heigh=5; + echo 'Description :
'; + echo $wDesc->IOValue('desc',$dos->get_parameter('desc')); + echo '
'; + echo widget::submit('upd','Modifie'); + echo widget::button_href('Retour','?action=dossier_mgt'); + echo '
'; + } +//--------------------------------------------------------------------------- +// action = del +//--------------------------------------------------------------------------- +if ( $sa == 'del' ) { + $d=new Dossier($_REQUEST ['d'] ); + $d->load(); + echo '
'; + echo widget::hidden('d',$_REQUEST['d']); + echo widget::hidden('sa','remove'); + echo '

Etes vous sure et certain de vouloir effacer '.$d->dos_name.' ???

'; + $confirm=new widget('checkbox'); + $confirm->name="p_confirm"; + echo 'Cochez la case si vous êtes sûr de vouloir effacer ce dossier'; + echo $confirm->IOValue(); + echo widget::submit('remove','Effacer'); + echo widget::button_href('Retour','?action=dossier_mgt'); + echo '
'; + } +//--------------------------------------------------------------------------- +// action = del +//--------------------------------------------------------------------------- +if ( $sa == 'remove' ) { + if ( ! isset ($_REQUEST['p_confirm'])) {echo('Désolé, vous n\'avez pas coché la case'); echo widget::button_href('Retour','?action=dossier_mgt');exit();} + + $cn=DbConnect(); + $msg="dossier"; + $name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=$1",array($_REQUEST['d'])); + if ( strlen(trim($name)) == 0 ) + { + echo "

$msg inexistant

"; + exit(); + } + $sql="drop database ".domaine."dossier".FormatString($_REQUEST['d']); + ob_start(); + if ( pg_query($cn,$sql)==false) { + ob_end_clean(); + + echo "

+ Base de donnée ".domaine."dossier".$_REQUEST['d']." est accèdée, déconnectez-vous d'abord

"; + exit; + } + ob_flush(); + $sql="delete from priv_user where priv_id in (select jnt_id from jnt_use_dos where dos_id=$1)"; + ExecSqlParam($cn,$sql,array($_REQUEST['d'])); + $sql="delete from jnt_use_dos where dos_id=$1"; + ExecSqlParam($cn,$sql,array($_REQUEST['d'])); + $sql="delete from ac_dossier where dos_id=$1"; + ExecSqlParam($cn,$sql,array($_REQUEST['d'])); + print '

'; + print "Voilà le dossier $name est effacé

"; + echo widget::button_href('Retour','?action=dossier_mgt'); + } +?> diff --git a/include/eub_be.inc.php b/include/eub_be.inc.php index ede84b7c6..86dc6568a 100644 --- a/include/eub_be.inc.php +++ b/include/eub_be.inc.php @@ -71,7 +71,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { '$p_bq_account', $p_jrn, 'n')"; - $Res=ExecSql($p_cn,$Sql); + $Res=ExecSql($p_cn,$Sql,'latin1'); } } // for ($c=0;$c<$num;$c++) $row++; diff --git a/include/facture.inc.php b/include/facture.inc.php index 6b682c986..a98f1d13e 100644 --- a/include/facture.inc.php +++ b/include/facture.inc.php @@ -24,7 +24,7 @@ require_once('jrn.php'); require_once("class_document.php"); require_once("class_fiche.php"); require_once("check_priv.php"); -require_once('class_acc_jrn_info.php'); +require_once('class_acc_ledger_info.php'); $tag_list='Liste'; $tag_list_sel='Liste'; @@ -102,7 +102,7 @@ if ( $sub_action == "list") } - echo '
'; + echo '
'; echo $retour; @@ -132,7 +132,7 @@ if ( $sub_action == "list") $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; - echo 'Période '.$w->IOValue("p_periode",$periode_start); + echo 'Période '.$w->IOValue("p_periode",$periode_start); $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; echo JS_SEARCH_CARD; @@ -179,7 +179,7 @@ echo widget::submit('gl_submit','Rechercher'); echo $list; echo "$bar
"; if ( $max_line !=0 ) - echo widget::submit('paid','Mise à jour paiement'); + echo widget::submit('paid','Mise à jour paiement'); echo ''; echo $retour; @@ -242,9 +242,9 @@ echo '
'; echo '
'; echo dossier::hidden(); echo $bar2; - echo '

Echeance dépassée

'; + echo '

Echeance dépassée

'; echo $list; - echo '

Non Payée

'; + echo '

Non Payée

'; echo $list2; echo $bar2; // Add hidden parameter @@ -260,7 +260,7 @@ echo '
'; echo '
'; if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); + echo widget::submit('paid','Mise à jour paiement'); echo ''; echo ''; @@ -279,7 +279,7 @@ if ( $sub_action=="use_opd" ) { $p_post=$op->compute_array(); echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']); - echo '
'; + echo '
'; echo $form; //-------------------- @@ -296,7 +296,7 @@ if ( $sub_action=="use_opd" ) { echo $hid->IOValue("sa","use_opd"); if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); + echo widget::submit('use_opd','Utilisez une op.prédéfinie'); echo $op->show_button(); echo ''; @@ -320,7 +320,7 @@ if ( isset ($_POST['add_item']) || isset ($_POST["correct_new_invoice"]) ) if ( isset ($_POST['add_item'])) $nb_item++; $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_item); - echo '
'; + echo '
'; echo $form; echo '
'; exit(); @@ -341,7 +341,7 @@ if ( isset($_POST['record_and_print_invoice'])) list ($internal,$e)=RecordInvoice($cn,$_POST,$User,$p_jrn); $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$_POST['nb_item'],'noform',''); - echo '
'; + echo '
'; echo '

Opération '.$internal.' enregistré

'; echo $form; echo '
'; @@ -361,7 +361,7 @@ if ( isset($_POST['record_and_print_invoice'])) $sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'"; ExecSql($cn,$sql); /* Save the additional information into jrn_info */ - $obj=new Acc_Jrn_Info($cn); + $obj=new Acc_Ledger_Info($cn); $jr_id=$obj->search_id_internal($internal); if (strlen(trim($_POST['bon_comm'] )) != 0 ) { $obj->set_type('BON_COMMANDE'); @@ -409,7 +409,7 @@ if ( isset ($_POST['view_invoice']) ) $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_number); } - echo '
'; + echo '
'; echo $form; echo '
'; exit(); @@ -430,7 +430,7 @@ if ( $p_jrn != -1 ) echo_debug('facture.inc.php.php',__LINE__,"Blank form"); // Show an empty form of invoice $form=FormVenInput($cn,$p_jrn,$User->get_periode(),null,false,$jrn->GetDefLine()); - echo '
'; + echo '
'; echo $form; //-------------------- @@ -447,7 +447,7 @@ if ( $p_jrn != -1 ) echo $hid->IOValue("sa","use_opd"); if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); + echo widget::submit('use_opd','Utilisez une op.prédéfinie'); echo $op->show_button(); echo ''; diff --git a/include/fiche.inc.php b/include/fiche.inc.php index acc9a26ac..106a47d98 100644 --- a/include/fiche.inc.php +++ b/include/fiche.inc.php @@ -32,7 +32,6 @@ $str_dossier=dossier::get(); echo JS_SEARCH_POSTE; echo JS_AJAX_FICHE; - if ( !isset($sessid)) { $sessid=$_REQUEST["PHPSESSID"]; @@ -83,13 +82,16 @@ function ShowFicheDefInput($p_fiche_def) $r.= $p_fiche_def->DisplayAttribut("remove"); $r.= ' '; + $r.= ' '; + $r.=widget::submit('remove_cat','Effacer cette catégorie','onclick="return confirm(\'Vous confirmez ?\')"'); // if there is nothing to remove then hide the button if ( strpos ($r,"chk_remove") != 0 ) { $r.=' '; } $r.= ""; - $r.="

Attention : il n'y aura pas de demande de confirmation pour enlèver les -attributs sélectionnés. Il ne sera pas possible de revenir en arrière

"; + $r.="

Attention : il n'y aura pas de demande de confirmation pour enlèver les +attributs sélectionnés. Il ne sera pas possible de revenir en arrière

"; + return $r; } @@ -102,11 +104,20 @@ if ( isset($_POST['add_modele']) and $write != 0) { $fiche_def->Add($_POST); } $r=""; + +if ( isset ($_POST['remove_cat'] )) { + $fd_id=new fiche_def($cn,$_POST['fd_id']); + $remains=$fd_id->remove(); + if ( $remains != 0 ) + /* some card are not removed because it is used */ + alert('Impossible d\'enlever cette catégorie, certaines fiches sont encore utilisées\n'. + 'Les fiches non utilisées ont cependant été effacées'); +} // Add a line in the card model if ( isset ($_POST["add_line"]) ) { $r= '
'; if ( $write ==0) - $r.= "

Pas d'accès

"; + $r.= "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); @@ -119,12 +130,32 @@ if ( isset ($_POST["add_line"]) ) { $r.= '
'; $recherche=false; } +/* ------------------------------------------------- */ +/* SAVE ORDER */ +/* ------------------------------------------------- */ +if ( isset($_POST['save_line'])) { + $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); + $fiche_def->save_order($_POST); + $r= '
'; + if ( $write ==0) + $r.= "

Pas d'accès

"; + else + { + $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); + // Insert Line + $r.=ShowFicheDefInput($fiche_def); + + } + $r.= '
'; + $recherche=false; + +} // Remove lines from a card model if ( isset ($_POST['remove_line'])) { $r= '
'; if ( $write ==0) - $r.= "

Pas d'accès

"; + $r.= "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); @@ -142,7 +173,7 @@ if ( isset ($_POST['remove_line'])) if ( isset ($_POST["change_name"] ) ) { $r= '
'; if ( $write ==0) - $r.= "

Pas d'accès

"; + $r.= "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); @@ -181,7 +212,7 @@ if ( isset ( $_GET["action"]) ) { $t=false; if ( $write == 0) { - echo '

Vos changements ne seront pas sauvés

'; + echo '

Vos changements ne seront pas sauvés

'; $t=true; } $str="&".dossier::get(); @@ -235,7 +266,7 @@ if ( isset ( $_GET["action"]) ) { if ($action == "modifier" ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { @@ -261,7 +292,7 @@ if ( isset ( $_GET["action"]) ) { if ( sizeof($all) != 0 ) { echo '
'; - echo "Nombre de résultat : ".sizeof($all).'
'; + echo "Nombre de résultat : ".sizeof($all).'
'; foreach ($all as $f_id){ $fiche=new fiche($cn,$f_id['f_id']); echo ''; - echo "Aucun résultat trouvé"; + echo "Aucun résultat trouvé"; echo '
'; @@ -285,7 +316,7 @@ if ( isset ( $_GET["action"]) ) { if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche_def=new fiche_def($cn,$_POST['fiche']); @@ -314,7 +345,7 @@ if (isset($_POST['delete']) ) { ShowRecherche(); echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche=new fiche($cn,$_POST["f_id"]); @@ -332,7 +363,7 @@ if ( isset ($_POST["add_fiche"]) ) { if ( $write ==0) { echo '
'; - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; } else { @@ -354,7 +385,7 @@ if ( isset ($_POST["update_fiche"]) ) { echo '
'; if ( $write ==0) - echo "

Pas d'accès

"; + echo "

Pas d'accès

"; else { $fiche=new fiche($cn,$_POST['f_id']); diff --git a/include/fiche_inc.php b/include/fiche_inc.php index 05f89e6e0..9b532f408 100644 --- a/include/fiche_inc.php +++ b/include/fiche_inc.php @@ -54,7 +54,7 @@ function CreateCategory ($p_cn,$p_js,$p_array=null,$p_ligne=1) //Name of the CARD (fiche_def.fd_label) - $display.=' Catégorie de fiche '; + $display.=' Catégorie de fiche '; $display.=''; $display.=''; diff --git a/include/form_inc.php b/include/form_inc.php deleted file mode 100644 index a1231db99..000000000 --- a/include/form_inc.php +++ /dev/null @@ -1,310 +0,0 @@ -'; - include_once("constant.php"); - echo JS_SEARCH_POSTE; - $search='"; - for ( $i =0 ; $i <= $p_line; $i++) { - ${"text$i"}=""; - ${"form$i"}=""; - ${"pos$i"}=""; - } - if ( $p_array != null ) { - foreach ( $p_array as $key=> $element ) { - ${"$key"}=$element; - echo_debug ("EncodeForm $key = $element"); - - } - - } else { - $form_nom=""; - $text0=""; - $form0=""; - } - echo "
"; - echo dossier::hidden(); - printf ("Nom du rapport : ", - $form_nom); - printf (''; - echo ""; - if ( isset($fr_id) ) echo " Position "; - echo " Texte "; - echo " Formule"; - - echo ''; - for ( $i =0 ; $i < $p_line;$i++) { - echo ""; - // si fr_id != null alors les donnees viennent de - // get_dataForm: ce n'est pas un nouvel enregistrement - // - if ( isset($fr_id)) { - echo ""; - printf ('', - $i,${"pos$i"}); - echo ''; - } - - echo ""; - printf ('', - $i,${"text$i"}); - echo ''; - - echo ""; - printf ('', - $i,${"form$i"}); - echo $search; - echo ''; - - echo ""; - } - echo ""; - if ( isset($fr_id)){ - echo ''; - }else { - echo ''; - } - echo ''; - echo ''; - - echo "
"; - -} -/*! - * \brief Show the details of a report - * - * parm : - * \param $p_cn connection - * \param $p_id gives the formdef.fr_id - * \param sessid for the search window - * - */ -function ViewForm($p_cn,$p_sessid,$p_id) { - $array=get_dataForm($p_cn,$p_id); - $l_nom=GetFormName($p_cn,$p_id); - $array['form_nom']=$l_nom; - - $l_line=GetNumberLine($p_cn,$p_id); - EncodeForm($l_line,$p_sessid,$array); - -} -/*! - * \brief Remove a report - * - * parm : - * \param $p_cn connection - * \param $p_id gives the formdef.fr_id - * - */ -function DeleteForm($p_cn,$p_id) { - ExecSql($p_cn,"delete from form where fo_fr_id=$p_id"); - ExecSql($p_cn,"delete from formdef where fr_id=$p_id"); -} -/*! - * \brief - * Get data from a form - * - * \param $p_cn connection - * \param $p_id gives the formdef.fr_id - * - - * \return array(fo_idX=>fo_id,textX=>fo_label,formX=>fo_formula,posX=>fo_pos) - * where X is the row number - * - */ -function get_dataForm($p_cn,$p_id) { - $Res=ExecSql($p_cn,"select fo_id,fo_fr_id,fo_pos,fo_label,fo_formula from form where fo_fr_id=$p_id - order by fo_pos"); - $Max=pg_NumRows($Res); - for ( $i=0;$i<$Max;$i++){ - $l_line=pg_fetch_array($Res,$i); - - // get the fo_id - $text=sprintf("fo_id%d",$i); - $array[$text]=$l_line['fo_id']; - // get the fo_label - $text=sprintf("text%d",$i); - $array[$text]=$l_line['fo_label']; - // get the fo_formula - $text=sprintf("form%d",$i); - $array[$text]=$l_line['fo_formula']; - // get the pos - $text=sprintf("pos%d",$i); - $array[$text]=$l_line['fo_pos']; - } //for - $array["fr_id"]=$p_id; - return $array; -} -/*! - * \brief Get the number of line of a form - * - * \param $p_cn connection - * \param $p_id gives the formdef.fr_id - * \return integer - * - */ -function GetNumberLine($p_cn,$p_id) { - $Res=ExecSql($p_cn,"select * from form where fo_fr_id=".$p_id); - $count=pg_NumRows($Res); - return $count; -} -/*! - * \brief Get the name of the report - * - * \param $p_cn connection - * \param $p_id formdef.fr_id - * - * \return string name - * - * - */ -function GetFormName($p_cn,$p_id) { - $Res=ExecSql($p_cn,"select fr_label from formdef where fr_id=".$p_id); - if ( pg_NumRows($Res) == 0 ) return null; - $name=pg_fetch_array($Res,0); - return $name['fr_label']; -} -/*! - * \brief Update a report - * - * \param $p_cn connexion - * \param $array - * - */ -function UpdateForm($p_cn,$p_array) { - foreach ($p_array as $key=>$element) { - echo_debug ("UpdateForm $key = $element"); - ${"$key"}=$element; - } - $Res=ExecSql($p_cn,"update formdef set fr_label='".FormatString($form_nom)."' where fr_id=".$fr_id); - $Res=ExecSql($p_cn,"delete from form where fo_fr_id=".$fr_id); - // Test les positions - for ($i =0; $i <$line;$i++) { - echo_debug ("position =".${"pos$i"}); - if ( (string) ${"pos$i"} != (string) (int) ${"pos$i"}) { - ${"pos$i"}=$i+1; - } - if ( ${"pos$i"} > $line || ${"pos$i"} < 0) { - ${"pos$i"}=$i+1; - echo_debug('form_inc.php',__LINE__,"position trop grand max = $line+1 "); - } - } - for ($i =0; $i <$line;$i++) { - for ( $o=$i+1; $o < $line;$o++) { - if ( ${"pos$i"} == ${"pos$o"} ) { - ${"pos$o"}=$o+1; - } - } - } - for ( $i=0;$i<$line;$i++) { - if ( strlen(trim(${"text$i"})) != 0) { - ${"text$i"}=FormatString(${"text$i"}); - ${"form$i"}=FormatString(${"form$i"}); - if ( ${"text$i"} != null ) { - if ( CheckFormula(${"form$i"}) == false ) - ${"form$i"}="!!!!!!! FORMULE INVALIDE ".${"form$i"}; - - ${"form$i"}=(${"form$i"}==null)?"null":"'".${"form$i"}."'"; - $sql=sprintf("insert into form (fo_fr_id, - fo_pos, - fo_label, - fo_formula) values - ( %d, - %d, - '%s', - %s)", - $fr_id,${"pos$i"}, - ${"text$i"}, - ${"form$i"} - ); - $Res=ExecSql($p_cn,$sql); - } - }//if - }//for - -} -/*! - * \brief Add a report - * - * \param $p_cn connexion - * \param $array - * - */ -function AddForm($p_cn,$p_array) { - foreach ($p_array as $key=>$element) { - echo_debug ("AddForm $key = $element"); - ${"$key"}=$element; - } - - if ( !isset ($form_nom) || - ! isset ($line) ) { - echo_error("Nom ou ligne non défini"); - return; - } - $form_nom=(FormatString($form_nom)==null)?"NoName":FormatString($form_nom); - $sql="insert into formdef (fr_label) values ('".$form_nom."')"; - $Res=ExecSql($p_cn,$sql); - $n=GetSequence($p_cn,"s_formdef"); - - for ($i=0;$i < $line;$i++) { - ${"text$i"}=FormatString(${"text$i"}); - ${"form$i"}=FormatString(${"form$i"}); - if ( ${"text$i"} != null ) { - // ${"form$i"}=(${"form$i"}==null)?${"form$i"}:"'".${"form$i"}."'"; - ${"form$i"}=(${"form$i"}==null)?"null":"'".${"form$i"}."'"; - CheckFormula(${"form$i"}); - $sql=sprintf("insert into form (fo_fr_id, - fo_pos, - fo_label, - fo_formula) values - ( %d, - %d, - '%s', - %s)", - $n,$i+1,${"text$i"},${"form$i"} - ); - $Res=ExecSql($p_cn,$sql); - }//if - }//for $i -} - -?> diff --git a/include/fortis_be.inc.php b/include/fortis_be.inc.php index 1e9cdf2cd..9e857f99f 100644 --- a/include/fortis_be.inc.php +++ b/include/fortis_be.inc.php @@ -42,7 +42,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { //corrige un bug de date $date_exec = str_replace(chr(34),"", $date_exec); - // Si LTXXXXX ou LT XXXXX dans le détail + // Si LTXXXXX ou LT XXXXX dans le détail if ((ereg ("LT+([0-9]{5})", $detail, $regs)) || (ereg ("LT+[ ]+([0-9]{5})", $detail, $regs))) { $iduser = $regs[1]; } @@ -72,6 +72,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { where code='".$code."' and num_compte='".$num_compte."'"; + $sql=utf8_encode($sql); $Res=ExecSql($p_cn,$sql); $Num=pg_NumRows($Res); @@ -102,7 +103,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $p_jrn, 'n')"; - $Res=ExecSql($p_cn,$Sql); + $Res=ExecSql($p_cn,$Sql,'latin1'); } } diff --git a/include/import_inc.php b/include/import_inc.php index f45160a98..9ac213766 100644 --- a/include/import_inc.php +++ b/include/import_inc.php @@ -29,7 +29,8 @@ require_once('class_user.php'); require_once('class_widget.php'); require_once('class_fiche.php'); require_once('class_acc_ledger.php'); -require_once('class_parm_code.php'); +require_once("class_acc_parm_code.php"); +require_once('class_acc_operation.php'); /*! ************************************************** * \brief Parse the file and insert the record @@ -58,7 +59,7 @@ StartSql($p_cn); require_once($p_format_csv); - echo "Importation terminée."; + echo "Importation terminée."; // if importation succeeds then we can commit the change Commit($p_cn); @@ -72,8 +73,8 @@ function UpdateCSV($p_cn){ $count=FormatString($_POST['count']); $poste=FormatString($_POST['poste'.$count]); $concern=FormatString($_POST['e_concerned'.$count]); - $sql = "update import_tmp set poste_comptable='$poste' ,status='w',". - "jr_rapt='$concern' where code='$code'"; + $sql = utf8_encode("update import_tmp set poste_comptable='$poste' ,status='w',". + "jr_rapt='$concern' where code='$code'"); $Res=ExecSql($p_cn,$sql); } @@ -91,8 +92,8 @@ function UpdateCSV($p_cn){ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ $w=new widget('js_search_only'); $w->name='poste'.$counter; - $w->extra='cred'; - $w->extra2=$p_val['jrn']; + $w->extra='filter'; + $w->extra2='QuickCode'; $w->label=''; $w->table=0; if ( $p_form == 'remove' ) @@ -124,6 +125,7 @@ $oJrn=new Acc_Ledger($p_cn,$p_val['jrn']); } echo ''; echo ''; + echo widget::hidden('p_jrn',$p_val['jrn']); echo ''; echo ''; echo ""; @@ -132,7 +134,7 @@ $oJrn=new Acc_Ledger($p_cn,$p_val['jrn']); echo '"; - echo ""; + echo ""; if ( $p_form == 'form') { $str_update=sprintf("import_update('%s','%s','%s');", $_REQUEST['PHPSESSID'], @@ -169,13 +171,13 @@ function VerifImport($p_cn){ " order by date_exec,code"; $Res=ExecSql($p_cn,$sql); $Num=pg_NumRows($Res); - echo $Num." opérations à complèter.

"; + echo $Num." opérations à complèter.

"; $i=1; // include javascript for popup echo JS_SEARCH_CARD; echo JS_CONCERNED_OP; echo JS_AJAX_FICHE; - echo JS_PROTOTYPE_JS; + echo JS_PROTOTYPE; while($val = pg_fetch_array($Res)){ echo ''; echo dossier::hidden(); @@ -199,7 +201,7 @@ function ConfirmTransfert($p_cn,$periode){ if ( $val == false ) { echo ""; exit(); } @@ -215,7 +217,7 @@ function ConfirmTransfert($p_cn,$periode){ $Res=ExecSql($p_cn,$sql); $Num=pg_NumRows($Res); - echo $Num." opérations à transfèrer.

"; + echo $Num." opérations à transfèrer.

"; if ( $Num == 0 ) return; $i=1; while($val = pg_fetch_array($Res)){ @@ -244,11 +246,11 @@ function ConfirmTransfert($p_cn,$periode){ */ function TransferCSV($p_cn, $periode){ - //on obtient la période courante + //on obtient la période courante $User=new User($p_cn); $periode = $User->get_periode(); - // on trouve les dates frontières de cette période + // on trouve les dates frontières de cette période $sql = "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end". " from parm_periode where p_id = '".$periode."'"; @@ -257,7 +259,7 @@ function TransferCSV($p_cn, $periode){ if ( $val == false ) { echo ""; exit(); } @@ -274,7 +276,7 @@ function TransferCSV($p_cn, $periode){ StartSql($p_cn); $ResAll=ExecSql($p_cn,$sql); $Max=pg_NumRows($ResAll); - echo $Max." opérations à transférer.
"; + echo $Max." opérations à transférer.
"; for ($i = 0;$i < $Max;$i++) { $val=pg_fetch_array($ResAll,$i); @@ -294,7 +296,7 @@ function TransferCSV($p_cn, $periode){ $f->get_by_qcode($poste_comptable,false); $poste_comptable=$f->strAttribut(ATTR_DEF_ACCOUNT); - // Vérification que le poste comptable trouvé existe + // Vérification que le poste comptable trouvé existe if ( $poste_comptable == '- ERROR -') $test=0; else @@ -309,7 +311,7 @@ function TransferCSV($p_cn, $periode){ if($test == 0) { $sqlupdate = "update import_tmp set status='n' WHERE code='".$code."' AND num_compte='".$num_compte."' or num_compte is null"; $Resupdate=ExecSql($p_cn,$sqlupdate); - echo "Poste comptable erronné pour l'opération ".$num_compte."-".$code.", réinitialisation du poste comptable
"; + echo "Poste comptable erronné pour l'opération ".$num_compte."-".$code.", réinitialisation du poste comptable
"; continue; } @@ -319,67 +321,68 @@ function TransferCSV($p_cn, $periode){ $seq=NextSequence($p_cn,'s_grpt'); $p_user = $_SESSION['g_user']; - $r=InsertJrnx($p_cn,"d",$p_user,$jrn,$bq_account,$date_exec,$montant,$seq,$periode); + $acc_op=new Acc_Operation($p_cn); + $acc_op->amount=$montant; + $acc_op->desc=$detail; + $acc_op->type="d"; + $acc_op->date=$date_exec; + $acc_op->user=$p_user; + $acc_op->poste=$bq_account; + $acc_op->grpt=$seq; + $acc_op->jrn=$jrn; + $acc_op->periode=$periode; + $acc_op->qcode=""; + $r=$acc_op->insert_jrnx(); - $r=InsertJrnx($p_cn,"c",$p_user,$jrn,$poste_comptable,$date_exec,$montant,$seq,$periode); + $acc_op->type="c"; + $acc_op->poste=$poste_comptable; + $acc_op->amount=$montant; + $r=$acc_op->insert_jrnx(); + //remove annoying double-quote $num_compte=str_replace('"','',$num_compte); $code=str_replace('\"','',$code); + $acc_op->comment=$detail.$num_compte." ".$code; + + $jr_id=$acc_op->insert_jrn(); - $jr_id=InsertJrn($p_cn,$date_exec,NULL,$jrn,$detail.$num_compte." ".$code,$seq,$periode); $internal=$oJrn->compute_internal_code($seq); $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". " jr_id = ".$jr_id); // insert rapt - if ( trim($jr_rapt) != "" ) { - if ( strpos($jr_rapt,',') !== 0 ) - { - $aRapt=split(',',$jr_rapt); - foreach ($aRapt as $rRapt) { - if ( isNumber($rRapt) == 1 ) - { - InsertRapt($p_cn,$jr_id,$rRapt); - } - } - } - elseif ( isNumber($jr_rapt) == 1 ) - { - InsertRapt($p_cn,$jr_id,$jr_rapt); - } - } - - /* if ( isNumber($jr_rapt) == 1) - InsertRapt($p_cn,$jr_id,$jr_rapt); - */ - - echo "Tranfer de l'opération ".$code." effectué
"; - $sql2 = "update import_tmp set status='t' where code='".$code."'"; - $Res2=ExecSql($p_cn,$sql2); - } -} catch (Exception $e) { - Rollback($p_cn); - echo ''. - 'Erreur dans '.__FILE__.':'.__LINE__. - ' Message = '.$e->getMessage(). - ''; - } + + $acc_reconc=new Acc_Reconciliation($p_cn); + $acc_reconc->set_jr_id=$jr_id; + $acc_reconc->insert($jr_rapt); + + echo "Tranfert de l'opération ".$code." effectué
"; + $sql2 = "update import_tmp set status='t' where code='".$code."'"; + $Res2=ExecSql($p_cn,$sql2); + } + } catch (Exception $e) { + Rollback($p_cn); + echo ''. + 'Erreur dans '.__FILE__.':'.__LINE__. + ' Message = '.$e->getMessage(). + ''; + } Commit($p_cn); } /*! - ************************************************** - * \brief ShowForm for getting data about - * the bank transfert in cvs - * - * \param $p_cn database connection - * - * \return none - */ +************************************************** +* \brief ShowForm for getting data about +* the bank transfert in cvs +* +* \param $p_cn database connection +* +* \return none +*/ function ShowFormTransfert($p_cn){ $w=new widget("select"); @@ -391,7 +394,7 @@ $w=new widget("select"); $w->label='Journal'; echo $w->label." :".$w->IOValue('import_jrn',$jrn)."
"; // choose the bank account - $banque=new parm_code($p_cn,'BANQUE'); + $banque=new Acc_Parm_Code($p_cn,'BANQUE'); $bq=make_array($p_cn,"select pcm_val,pcm_lib from tmp_pcmn where pcm_val::text like '".$banque->p_value."%'"); $w->label='Banque'; echo "Compte en banque :".$w->IOValue('import_bq',$bq)."
"; diff --git a/include/impress_bilan.inc.php b/include/impress_bilan.inc.php index 43b91a9f2..6b08e39e8 100644 --- a/include/impress_bilan.inc.php +++ b/include/impress_bilan.inc.php @@ -39,7 +39,7 @@ include_once("postgres.php"); //----------------------------------------------------- $filter_year=" where p_exercice='".$User->get_exercice()."'"; $bilan=new Acc_Bilan($cn); -echo '
'; +echo '
'; echo ''; echo widget::hidden('p_action','impress'); diff --git a/include/impress_fiche.inc.php b/include/impress_fiche.inc.php index 84a06b373..b2c8a55cc 100644 --- a/include/impress_fiche.inc.php +++ b/include/impress_fiche.inc.php @@ -34,7 +34,7 @@ if ( isset ($_REQUEST['fd_id'])) { if ($with_amount) include_once("class_acc_account_ledger.php"); - echo '
'; + echo '
'; $submit=new widget(); $hid=new widget("hidden"); $fiche_id=new widget("hidden"); @@ -91,12 +91,12 @@ if ( isset ($_REQUEST['fd_id'])) { $fiche_def->GetAttribut(); foreach ($fiche_def->attribut as $attribut) { echo "
"; - // si solde demandé affiche la col + // si solde demandé affiche la col //-- if ($attribut->ad_id==ATTR_DEF_ACCOUNT && $with_amount==true) { - echo ""; - echo ""; + echo ""; + echo ""; echo ""; } } diff --git a/include/impress_inc.php b/include/impress_inc.php index 2ff8e3016..90734c948 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -183,7 +183,7 @@ function get_dataJrnPdf($p_cn,$p_array,$p_limit,$p_offset) if ( $p_array['filter']==YES) { $cond=CreatePeriodeCond($p_array['periode']); if ( ! isset ($p_array['central']) ) { - // Journaux non centralisés + // Journaux non centralisés $Res=ExecSql($p_cn,"select j_id,to_char(j_date,'DD.MM.YYYY') as j_date, jr_internal, case j_debit when 't' then j_montant::text else ' ' end as deb_montant, @@ -197,7 +197,7 @@ function get_dataJrnPdf($p_cn,$p_array,$p_limit,$p_offset) " and ".$cond." order by j_date::date asc,jr_internal,j_debit desc". " limit ".$p_limit." offset ".$p_offset); }else { - // Journaux centralisés + // Journaux centralisés $cond=CreatePeriodeCond($p_array['periode'],"c_periode"); $Sql="select c_id as j_id, c_j_id, @@ -224,7 +224,7 @@ function get_dataJrnPdf($p_cn,$p_array,$p_limit,$p_offset) } else { // Grand Livre if (! isset($p_array['central'])) { - // Non centralisé + // Non centralisé $cond=CreatePeriodeCond($p_array['periode']); $Res=ExecSql($p_cn,"select j_id,to_char(j_date,'DD.MM.YYYY') as j_date, jr_internal, @@ -239,7 +239,7 @@ function get_dataJrnPdf($p_cn,$p_array,$p_limit,$p_offset) " limit ".$p_limit." offset ".$p_offset); } else { - // Centralisé + // Centralisé $cond=CreatePeriodeCond($p_array['periode'],"c_periode"); $Sql="select c_id as j_id, c_j_id, @@ -438,11 +438,11 @@ function get_rappel($p_cn,$p_jrnx_id,$p_jrn_id,$p_exercice,$which,$p_type,$p_cen if ( $p_type == 1 ) { // Vue filtree => Journaux - if ( $p_central == 0 ) { // Vue non centralisée + if ( $p_central == 0 ) { // Vue non centralisée return array(0,0); } // p_central == 0 - // Vue filtree => Journaux & Jrn centralisé + // Vue filtree => Journaux & Jrn centralisé if ( $p_central == 1 ) { $c_line=CountSql($p_cn,"select * from centralized left join parm_periode on c_periode=p_id ". " where c_jrn_def=$p_jrn_id and p_exercice='".$p_exercice."'". @@ -478,7 +478,7 @@ function get_rappel($p_cn,$p_jrnx_id,$p_jrn_id,$p_exercice,$which,$p_type,$p_cen } } // Type = jrn - if ($p_type==0 ) { // Si Grand Livre, prendre donnée centralisée{ + if ($p_type==0 ) { // Si Grand Livre, prendre donnée centralisée{ if ( $p_central == 1) { $c_line=CountSql($p_cn,"select * from centralized left join parm_periode on c_periode=p_id ". "where p_exercice='".$p_exercice."'". @@ -511,9 +511,9 @@ function get_rappel($p_cn,$p_jrnx_id,$p_jrn_id,$p_exercice,$which,$p_type,$p_cen $a=array($deb,$cred); return $a; } // central == 1 - else // Donnée non centralisée => pas de rappel + else // Donnée non centralisée => pas de rappel { - if ($p_central== 0) { // Si Grand Livre, prendre donnée non centralisée{ + if ($p_central== 0) { // Si Grand Livre, prendre donnée non centralisée{ return array(0,0); } }//else diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index bf95bf7c7..0ef84e431 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -41,7 +41,7 @@ require_once("class_acc_ledger.php"); $Jrn->get_name(); if ( $_POST['p_simple']==0 ) { - $Jrn->get_row( $_POST['from_periode'], + $Row=$Jrn->get_row( $_POST['from_periode'], $_POST['to_periode'], $p_cent); } @@ -55,7 +55,7 @@ require_once("class_acc_ledger.php"); $rep=""; $submit=new widget(); $hid=new widget("hidden"); - echo '
'; + echo '
'; echo '

'.$Jrn->name.'

'; echo "
'.$p_val['code'].''.$p_val['date_exec'].''.$p_val['montant'].' EUR
Journal : ".$oJrn->get_name()."poste comptable Destination : ".$p_val['bq_account']."
'.$w->IOValue().' '.$s->IOValue('poste'.$counter.'_label'). "n° compte : ".$p_val['num_compte']."n° compte : ".$p_val['num_compte']."
".$attribut->ad_text."DébitCréditDébitCréditSolde
"; echo ''; @@ -123,7 +123,7 @@ require_once("class_acc_ledger.php"); "". "". "". - /* "". */ + /* "". */ "". ""; // set a filter for the FIN @@ -217,7 +217,7 @@ if ( count($ret) < 1 ) //----------------------------------------------------- // Form //----------------------------------------------------- -echo '
'; +echo '
'; echo ''.dossier::hidden(); echo '
Date commentaire internalPièce justificativePièce justificative montant
'; $w=new widget("select"); @@ -232,16 +232,16 @@ $filter_year=" where p_exercice='".$User->get_exercice()."'"; $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); $w->label="Depuis"; print $w->IOValue('from_periode',$periode_start); -$w->label=" jusqu'à "; +$w->label=" jusqu'à "; $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); print $w->IOValue('to_periode',$periode_end); print ""; $centralise=new widget("checkbox"); -$centralise->label="Depuis les journaux centralisés"; +$centralise->label="Depuis les journaux centralisés"; $centralise->table=1; print $centralise->IOValue('cent'); $a=array( - array('value'=>0,'label'=>'Detaillé'), + array('value'=>0,'label'=>'Detaillé'), array('value'=>1,'label'=>'Simple') ); $w->selected=1; @@ -251,7 +251,7 @@ echo '
'; print widget::submit('bt_html','Visualisation'); echo ''; - echo ' Attention : en-cas d\'impression de journaux centralisés, dans le PDF, les montants débit et crédit calculés par page sont la somme des montants de la page uniquement. Si une opération est sur 2 pages ces montants diffèreront évidemment. Ces montants doivent être égaux sur la dernière page. Pour vérifier la balance, utilisez la balance des comptes ou Avancé->Vérification'; + echo ' Attention : en-cas d\'impression de journaux centralisés, dans le PDF, les montants débit et crédit calculés par page sont la somme des montants de la page uniquement. Si une opération est sur 2 pages ces montants diffèreront évidemment. Ces montants doivent être égaux sur la dernière page. Pour vérifier la balance, utilisez la balance des comptes ou Avancé->Vérification'; echo '
'; ?> diff --git a/include/impress_listing_client.inc.php b/include/impress_listing_client.inc.php index 775066f10..574bf1786 100644 --- a/include/impress_listing_client.inc.php +++ b/include/impress_listing_client.inc.php @@ -38,13 +38,13 @@ echo "
". dossier::hidden()." - + - + @@ -80,7 +80,7 @@ if ( sizeof($year) == 0 ) echo "Aucun enregistrement dans les journaux"; exit(); } -$w->label="Année concernée"; +$w->label="Année concernée"; print $w->IOValue('year',$year); print ""; echo '
Nom Numéro TVA Numéro TVA Montant HTVA Montant TVA
'; diff --git a/include/impress_poste.inc.php b/include/impress_poste.inc.php index dc40441ac..903cc7bfa 100644 --- a/include/impress_poste.inc.php +++ b/include/impress_poste.inc.php @@ -34,9 +34,10 @@ include_once("postgres.php"); //----------------------------------------------------- // Form //----------------------------------------------------- -echo '
'; +echo '
'; echo JS_SEARCH_POSTE; echo JS_SEARCH_CARD; +echo JS_PROTOTYPE; echo '
'; echo widget::hidden('p_action','impress'); echo widget::hidden('type','poste'); @@ -67,14 +68,14 @@ $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from pa $select->label="Depuis"; $select->selected=(isset($_REQUEST['from_periode']))?$_REQUEST['from_periode']:""; print $select->IOValue('from_periode',$periode_start); -$select->label=" jusqu'à "; +$select->label=" jusqu'à "; $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); $select->selected=(isset($_REQUEST['to_periode']))?$_REQUEST['to_periode']:""; print $select->IOValue('to_periode',$periode_end); print ""; print ""; $all=new widget("checkbox"); -$all->label="Tous les postes qui en dépendent"; +$all->label="Tous les postes qui en dépendent"; $all->disabled=false; $all->selected=(isset($_REQUEST['poste_fille']))?true:false; echo $all->IOValue("poste_fille"); @@ -101,7 +102,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) { require_once("class_acc_account_ledger.php"); $go=0; // we ask a poste_id - if ( strlen(trim($_GET['poste_id'])) != 0 && isNumber($_GET['poste_id']) ) + if ( isset($_GET['poste_id']) && strlen(trim($_GET['poste_id'])) != 0 && isNumber($_GET['poste_id']) ) { if ( isset ($_GET['poste_fille']) ) { @@ -130,7 +131,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) { // A account is given if ( $go == 1) { - echo '
'; + echo '
'; if ( ! isset($_REQUEST['oper_detail']) ) { Acc_Account_Ledger::HtmlTableHeader(); $Poste->HtmlTable(); @@ -167,14 +168,14 @@ if ( isset( $_REQUEST['bt_html'] ) ) { if ( $go == 2) { if ( ! isset($_REQUEST['oper_detail']) ) { - echo '
'; + echo '
'; $fiche->HtmlTableHeader(); $fiche->HtmlTable(); $fiche->HtmlTableHeader(); echo "
"; } else { // Detail // - echo '
'; + echo '
'; $fiche->HtmlTableHeader(); $fiche->HtmlTableDetail(); $fiche->HtmlTableHeader(); @@ -189,7 +190,7 @@ if ( isset( $_REQUEST['bt_html'] ) ) { if ( sizeof($a_poste) == 0 ) exit; - echo '
'; + echo '
'; if ( ! isset ($_REQUEST['oper_detail'])) { diff --git a/include/impress_rapport.inc.php b/include/impress_rapport.inc.php index c4928d528..1763275a3 100644 --- a/include/impress_rapport.inc.php +++ b/include/impress_rapport.inc.php @@ -32,8 +32,8 @@ include_once("class_widget.php"); // after in pdf or cvs //----------------------------------------------------- if ( isset( $_GET['bt_html'] ) ) { - require_once("class_rapport.php"); - $Form=new rapport($cn,$_GET['form_id']); + require_once("class_acc_report.php"); + $Form=new Acc_Report($cn,$_GET['form_id']); $Form->get_name(); // step asked ? //-- @@ -59,7 +59,7 @@ if ( isset( $_GET['bt_html'] ) ) { $rep=""; $submit=new widget(); $hid=new widget("hidden"); - echo '
'; + echo '
'; if ( $_GET['type_periode'] == 0) { $t=($_GET['from_periode']==$_GET['to_periode'])?"":" -> ".getPeriodeName($cn,$_GET['to_periode'],'p_end'); echo '

'.$Form->id." ".$Form->name. @@ -151,7 +151,7 @@ if ( sizeof($ret) == 0 ) { //----------------------------------------------------- // Form //----------------------------------------------------- -echo '
'; +echo '
'; echo ''; $hidden=new widget("hidden"); echo $hidden->IOValue("p_action","impress"); @@ -171,7 +171,7 @@ $filter_year=" where p_exercice='".$User->get_exercice()."'"; $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); $w->label="Période comptable : Depuis"; print $w->IOValue('from_periode',$periode_start); -$w->label=" jusqu'à "; +$w->label=" jusqu'à "; $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); print $w->IOValue('to_periode',$periode_end); print ""; @@ -192,17 +192,17 @@ echo ''; echo $w->IOValue('type_periode',$aCal); echo ''; $aStep=array( - array('value'=>0,'label'=>'Pas d\'étape'), + array('value'=>0,'label'=>'Pas d\'étape'), array('value'=>1,'label'=>'1 mois') ); -$w->label='Par étape de'; +$w->label='Par étape de'; echo ' '.$w->IOValue('p_step',$aStep); echo ''; echo ''; echo ' Attention : vous ne pouvez pas utiliser les étapes avec les dates calendriers.'; echo '
'; -echo ' Les clauses FROM sont ignorés avec les dates calendriers'; +echo ' Les clauses FROM sont ignorés avec les dates calendriers'; echo '
'; print widget::submit('bt_html','Visualisation'); diff --git a/include/ing_be.inc.php b/include/ing_be.inc.php index c41efc659..17a7a1ad0 100644 --- a/include/ing_be.inc.php +++ b/include/ing_be.inc.php @@ -38,9 +38,10 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { list($num_compte, $code, $date_exec, $date_valeur, $montant, $devise, $montant2, $devise2, $rubriques, $detail, $zzz, $zzz, $date_comptable) = split(";", $data[$c]); # Bug CSV ING : "424 au lieu de 424 +#" $code = str_replace("\"", "", $code); - # Bug CSV ING : espace après la date + # Bug CSV ING : espace apres la date $date_exec = str_replace(" ", "", $date_exec); $date_valeur = str_replace(" ", "", $date_valeur); $date_exec = str_replace("\"", "", $date_exec); @@ -50,7 +51,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num_compte = $regs[0]; } - // Si LTXXXXX ou LT XXXXX dans le détail + // Si LTXXXXX ou LT XXXXX dans le détail if ((ereg ("LT+([0-9]{5})", $detail, $regs)) || (ereg ("LT+[ ]+([0-9]{5})", $detail, $regs))) { $iduser = $regs[1]; } @@ -81,7 +82,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $code = $annee."-".$code; $sql = "select * from import_tmp where code='".$code."' and num_compte='".$num_compte."'"; - $Res=ExecSql($p_cn,$sql); + $Res=ExecSql($p_cn,$sql,'latin1'); $Num=pg_NumRows($Res); if($Num > 0) { @@ -110,7 +111,7 @@ while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $p_jrn, 'n')"; echo $sql; - $Res=ExecSql($p_cn,$Sql); + $Res=ExecSql($p_cn,$Sql,'latin1'); } } diff --git a/include/jrn.php b/include/jrn.php index d13e5d68e..3f95cbef2 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -30,7 +30,7 @@ require_once ('class_anc_plan.php'); require_once ('class_anc_operation.php'); require_once ('class_acc_ledger.php'); require_once ('class_acc_operation.php'); -require_once ('class_acc_jrn_info.php'); +require_once ('class_acc_ledger_info.php'); /*! * \brief Display the form to UPDATE account operation in the expert view @@ -100,7 +100,7 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1) // Is Paid $r.=""; $check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED"; - $r.='Payé '; + $r.='Payé '; } $r.=""; $r.=""; @@ -158,25 +158,44 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1) if ( $p_mode == 1 ) { $r.="
"; $r.= ""; - $r.="".$file->IOValue("pj","","Pièce justificative").""; + $r.="".$file->IOValue("pj","","Pièce justificative").""; $r.="
"; } $r.="
"; $r.=""; $r.="Total ".$content['jr_montant']."
"; + if ( $content['jrn_def_type'] == 'VEN' ) { + /* count the number of additionnal info */ + $acc_jrn_info=new Acc_Ledger_Info($p_cn); + $acc_jrn_info->set_jrn_id($p_jr_id); + + /* if additional info > 0 show them */ + if ( $acc_jrn_info->count() > 0 ) { + $array=$acc_jrn_info->load_all(); + foreach ($array as $row) { + if ( strpos($row->id_type,'BON_COMMANDE') ===0) { + $r.="Num bon de commande : ".$row->ji_value.'
'; + } + if ( strpos($row->id_type,'OTHER') ===0) { + $r.="Autre info : ".$row->ji_value.'
'; + } + + } + } + } if ( $p_mode==1) { // show all the related operation $a=GetConcerned($p_cn,$content['jr_id']); $sessid=$_REQUEST["PHPSESSID"]; if ( $a != null ) { - $r.="Operation concernée
"; + $r.="Operation concernée
"; $r.= '
'; foreach ($a as $key => $element) { $operation=new Acc_operation($p_cn); $operation->jr_id=$element; - $r.=sprintf ('%s ', + $r.=sprintf ('%s ', $operation->get_internal($p_cn,$element), $element, $sessid, @@ -270,7 +289,7 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) // Is Paid $r.=""; $check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED"; - $r.='Payé '; + $r.='Payé '; $r.=""; @@ -494,7 +513,7 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) $r.=""; if ( $content['jrn_def_type'] == 'VEN' ) { /* count the number of additionnal info */ - $acc_jrn_info=new Acc_Jrn_Info($p_cn); + $acc_jrn_info=new Acc_Ledger_Info($p_cn); $acc_jrn_info->set_jrn_id($p_jr_id); /* if additional info > 0 show them */ @@ -515,7 +534,7 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) if ( $p_mode == 1 ) { $r.= ""; - $r.="".$file->IOValue("pj","","Pièce justificative").""; + $r.="".$file->IOValue("pj","","Pièce justificative").""; $r.="
"; $r.="
"; @@ -526,13 +545,13 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) $sessid=$_REQUEST["PHPSESSID"]; if ( $a != null ) { - $r.="Operation concernée
"; + $r.="Operation concernée
"; $r.= '
'; foreach ($a as $key => $element) { $operation=new Acc_operation($p_cn); $operation->jr_id=$element; - $r.=sprintf ('%s ', + $r.=sprintf ('%s ', $operation->get_internal(), $element, $sessid, @@ -554,7 +573,7 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) } /*! - * \brief Vue des écritures comptables + * \brief Vue des écritures comptables * * parm : * - p_dossier, diff --git a/include/modele.inc.php b/include/modele.inc.php index 3f01dd985..6e171b407 100644 --- a/include/modele.inc.php +++ b/include/modele.inc.php @@ -27,12 +27,49 @@ * */ require_once ('class_widget.php'); +$sa=(isset ( $_REQUEST['sa']))?$_REQUEST['sa']:'list'; +if ( isset ($_POST['upd']) && + isset($_POST['m'])){ + if ( isset($_POST['name']) && isset($_POST['desc'])) { + extract($_POST); + $cn=DbConnect(); + if ( strlen(trim($name)) !=0 + && getDbValue($cn,'select count(*) from modeledef where '. + 'mod_name=$1 and mod_id !=$2', + array(trim($name),$m)) == 0 + ) + { + ExecSqlParam($cn,"update modeledef set mod_name=$1, ". + " mod_desc=$2 where mod_id=$3 ", + array(trim($name),trim($desc),$m)); + + + } + } + $sa="list"; + } echo JS_CONFIRM; $cn=DbConnect(); + + + // IF FMOD_NAME is posted then must add a template if ( isset ($_POST["FMOD_NAME"]) ) { + $encoding=getDbValue($cn,"select encoding from pg_database where ". + " datname='".domaine.'dossier'.FormatString($_POST["FMOD_DBID"])."'"); + + if ( $encoding != 6 ) { + echo ""; + echo 'la base de donnée '. + domaine.'mod'.$_POST["FMOD_DBID"]." doit être migrée en unicode"; + echo ' Pour le passer en unicode, faites-en un backup puis restaurez le fichier reçu'; + + echo widget::button_href('Retour','admin_repo.php?action=dossier_mgt'); + exit(); + } + $mod_name=FormatString($_POST["FMOD_NAME"]); $mod_desc=FormatString($_POST["FMOD_DESC"]); if ( $mod_name != null) { @@ -43,11 +80,11 @@ if ( isset ($_POST["FMOD_NAME"]) ) { // get the mod_id $l_id=GetSequence($cn,'s_modid'); if ( $l_id != 0 ) { - $Sql=sprintf("CREATE DATABASE %sMOD%d encoding='ISO8859-1' TEMPLATE %sDOSSIER%s",domaine,$l_id,domaine,$_POST["FMOD_DBID"]); + $Sql=sprintf("CREATE DATABASE %sMOD%d encoding='UTF8' TEMPLATE %sDOSSIER%s",domaine,$l_id,domaine,$_POST["FMOD_DBID"]); ob_start(); if ( pg_query($cn,$Sql)==false) { ob_end_clean(); - echo "

Base de donnée ".domaine."dossier".$_POST['FMOD_DBID']." est accèdée, déconnectez-vous en d'abord

"; + echo "

Base de donnée ".domaine."dossier".$_POST['FMOD_DBID']." est accèdée, déconnectez-vous en d'abord

"; $Res=ExecSql($cn,"delete from modeledef where mod_id=".$l_id); exit; @@ -160,42 +197,52 @@ if ( isset ($_POST["FMOD_NAME"]) ) { $Res=ExecSql($cn,"select mod_id,mod_name,mod_desc from modeledef order by mod_name"); $count=pg_NumRows($Res); +echo '
'; +echo "

Modèles

"; +if ( $sa=='list') { + if ( $count == 0 ) { + echo "No template available"; + } else { + -if ( $count == 0 ) { - echo "No template available"; - } else { - echo "

Modèles

"; - echo '
'; - echo widget::button_href('Rafraîchir','admin_repo.php?action=modele_mgt'); - echo ''; - echo "". - "". - "". - ""; + echo widget::button_href('Rafraîchir','admin_repo.php?action=modele_mgt'); + echo widget::button_href('Ajouter','admin_repo.php?action=modele_mgt&sa=add'); + + echo '
NomDescription
'; + echo "". + "". + "". + ""; - for ($i=0;$i<$count;$i++) { - $mod=pg_fetch_array($Res,$i); - printf(''. - ''. - ''. - ''. - - '', - $mod['mod_id'], - $mod['mod_name'], - $mod['mod_desc']); + for ($i=0;$i<$count;$i++) { + $mod=pg_fetch_array($Res,$i); + printf(''. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + '', + $mod['mod_id'], + $mod['mod_name'], + $mod['mod_desc']); }// for echo "
NomDescription
%d %s %s '. - ' '. - '
%d %s %s '. + widget::button_href('Effacer','?action=modele_mgt&sa=del&m='.$mod['mod_id']).''.widget::button_href('Modifie','?action=modele_mgt&sa=mod&m='.$mod['mod_id']).''.widget::button_href('Backup','backup.php?action=backup&sa=b&t=m&d=' + .$mod['mod_id']).'
"; }// if count = 0 echo "Si vous voulez récupérer toutes les adaptations d'un dossier ". -" dans un autre dossier, vous pouvez en faire un modèle.". +" dans un autre dossier, vous pouvez en faire un modèle.". " Seules les fiches, la structure des journaux, les périodes,... seront reprises ". "et aucune donnée du dossier sur lequel le dossier est basé."; - + } +//--------------------------------------------------------------------------- +// Add a template +//--------------------------------------------------------------------------- +if ( $sa == 'add') { // Show All available folder $Res=ExecSql($cn,"select dos_id, dos_name,dos_description from ac_dossier order by dos_name"); @@ -224,19 +271,103 @@ if ( $count != 0 ) { Basé sur -Nettoyage des Documents et courriers (ce qui n'effacera pas les modèles de documents) +Nettoyage des Documents et courriers (ce qui n'effacera pas les modèles de documents) Nettoyage de toutes les fiches (ce qui effacera client, opérations prédéfinies fournisseurs et documents) Nettoyage de la comptabilité analytique : effacement des plans et des postes, les opérations sont de toute façon effacées - - - - - - + +' + + + + + + echo '
'; + $name=getDbValue($cn, + "select mod_name from modeledef where ". + " mod_id=$1", + array($_GET['m'])); + $desc=getDbValue($cn, + "select mod_desc from modeledef where ". + " mod_id=$1", + array($_GET['m'])); + $wText=new widget('text'); + echo 'Nom : '.$wText->IOValue('name',$name); + $wDesc=new widget('textarea'); + $wDesc->heigh=5; + echo '
Description :
'; + echo $wDesc->IOValue('desc',$desc); + echo widget::hidden('m',$_GET['m']); + echo widget::hidden('action','modele_mgt'); + echo '
'; + echo widget::button_href('Retour','?action=modele_mgt'); + echo widget::submit('upd','Modifie'); + echo '
'; + } + +//--------------------------------------------------------------------------- +// action = del +//--------------------------------------------------------------------------- +if ( $sa == 'del' ) { + $cn=DbConnect(); + $name=getDbValue($cn,'select mod_name from modeledef where mod_id=$1',array($_REQUEST['m'])); + echo '
'; + echo widget::hidden('d',$_REQUEST['m']); + echo widget::hidden('sa','remove'); + echo '

Etes vous sure et certain de vouloir effacer '.$name.' ???

'; + $confirm=new widget('checkbox'); + $confirm->name="p_confirm"; + echo 'Cochez la case si vous êtes sûr de vouloir effacer ce modèle'; + echo $confirm->IOValue(); + echo widget::submit('remove','Effacer'); + echo widget::button_href('Retour','?action=modele_mgt'); + echo '
'; + } +//--------------------------------------------------------------------------- +// action = del +//--------------------------------------------------------------------------- +if ( $sa == 'remove' ) { + if ( ! isset ($_REQUEST['p_confirm'])) { + echo('Désolé, vous n\'avez pas coché la case'); + echo widget::button_href('Retour','?action=modele_mgt'); + exit(); + } + + $cn=DbConnect(); + $msg="dossier"; + $name=getDbValue($cn,"select mod_name from modeledef where mod_id=$1",array($_REQUEST['m'])); + if ( strlen(trim($name)) == 0 ) + { + echo "

$msg inexistant

"; + exit(); + } + $sql="drop database ".domaine."mod".FormatString($_REQUEST['m']); + ob_start(); + if ( pg_query($cn,$sql)==false) { + ob_end_clean(); + + echo "

+ Base de donnée ".domaine."mod".$_REQUEST['m']." est accèdée, déconnectez-vous d'abord

"; + exit; + } + ob_flush(); + $sql="delete from modeledef where mod_id=$1"; + ExecSqlParam($cn,$sql,array($_REQUEST['m'])); + print '

'; + print "Voilà le modèle $name est effacé

"; + echo widget::button_href('Retour','?action=modele_mgt'); + } + echo '
'; +?> diff --git a/include/opening.inc.php b/include/opening.inc.php new file mode 100644 index 000000000..37a9e13e3 --- /dev/null +++ b/include/opening.inc.php @@ -0,0 +1,170 @@ +'; + echo '
Etape 1 '; + + echo 'Choississez le dossier où sont les soldes à importer'; + $avail=GetAvailableFolder($User->id,$User->Admin()); + + if ( empty( $avail) ) { echo '*** Aucun dossier ***';exit();} + echo '
'; + echo widget::hidden('p_action','ouv'); + echo widget::hidden('sa','step2'); + echo dossier::hidden(); + $wAvail=new widget('select'); + /* compute select list */ + $array=array(); + $i=0; + foreach ($avail as $r) { + $array[$i]['value']=$r['dos_id']; + $array[$i]['label']=$r['dos_name']; + $i++; + } + + $wAvail->value=$array; + echo 'Choix du dossier :'.$wAvail->IOValue('f'); + echo widget::submit('ok','Continuer'); + + echo '
'; + echo '
'; + echo '
'; + exit(); +} +/* -------------------------------------------------- + * Step 2 choose now the exercice of this folder + */ +$back='user_advanced.php?p_action=ouv&'.dossier::get(); +if ( $sa=='step2') { + echo '
'. + '
Etape 2'. + '

'.dossier::name($_REQUEST['f']).'

'. + '
'. + ' Choississez l\'exercice du dossier '; + echo dossier::hidden(); + echo widget::hidden('p_action','ouv'); + echo widget::hidden('sa','step3'); + echo widget::hidden('f',$_REQUEST['f']); + $periode=make_array($cn,"select distinct p_exercice,p_exercice from parm_periode order by p_exercice"); + $w=new widget('select'); + $w->table=0; + $w->label='Periode'; + $w->readonly=false; + $w->value=$periode; + $w->name="p_periode"; + echo 'Période : '.$w->IOValue(); + echo widget::submit('ok','Continuer'); + echo dossier::hidden(); + echo "
"; + echo widget::button_href('Retour',$back); + exit(0); +} +/* -------------------------------------------------- + * select the ledger where we will import the data + */ +if ( $sa == 'step3') { + echo '
'. + '
Etape 3'. + '

'.dossier::name($_REQUEST['f']).'

'. + '
'. + ' Choississez le journal qui contiendra l\'opération d\'ouverture '; + echo dossier::hidden(); + echo widget::hidden('p_action','ouv'); + echo widget::hidden('sa','step4'); + echo widget::hidden('f',$_REQUEST['f']); + echo widget::hidden('p_periode',$_REQUEST['p_periode']); + $wLedger=new widget("select"); + $User=new User(DbConnect(dossier::id())); + $avail=$User->get_ledger('ODS'); + /* compute select list */ + $array=array(); + $i=0; + foreach ($avail as $r) { + $array[$i]['value']=$r['jrn_def_id']; + $array[$i]['label']=$r['jrn_def_name']; + $i++; + } + $wLedger->value=$array; + echo $wLedger->IOValue('p_jrn'); + echo widget::submit('ok','Continuer'); + echo dossier::hidden(); + echo "
"; + echo widget::button_href('Retour',$back); + exit(0); + +} +/* -------------------------------------------------- + * Step 4 we import data from the selected folder and year and + * transform it into a misc operation + */ +if ( $sa=='step4') { + echo '
'; + echo '
Dernière étape'; + $cn_target=DbConnect($_REQUEST['f']); + $saldo=new Acc_Ledger($cn_target,0); + $array=$saldo->get_saldo_exercice($_REQUEST['p_periode']); + /* we need to transform the array into a Acc_Ledger array */ + $result=array(); + $result['desc']='Ecriture d\'ouverture'; + $result['nb_item']=sizeof($array); + $result['p_jrn']=$_REQUEST['p_jrn']; + $idx=0; + + foreach ($array as $row ) { + $qcode='qc_'.$idx; + $poste='poste'.$idx; + $amount='amount'.$idx; + $ck='ck'.$idx; + $result[$qcode] = $row['j_qcode']; + if ( $row['j_qcode']=='') + $result[$poste] = $row['j_poste']; + $result[$amount] = abs($row['solde']); + if ( $row['solde'] > 0 ) $result[$ck]='on'; + $idx++; + } + $cn=DbConnect(dossier::id()); + $User=new User($cn); + $jrn=new Acc_Ledger($cn,$_REQUEST['p_jrn']); + echo '
'; + echo widget::hidden('p_action','quick_writing'); + echo dossier::hidden(); + echo widget::hidden('p_jrn',$_REQUEST['p_jrn']); + echo $jrn->show_form($result,0); + echo '
'; + echo '

Ne corrigez pas encore, cliquez continuer pour passer à l\'étape suivante

'; + echo widget::submit('correct_it','Continuer'); + echo '
'; + echo widget::button_href('Retour',$back); + + echo '
'; +} \ No newline at end of file diff --git a/include/param_jrn_add.inc.php b/include/param_jrn_add.inc.php index 705e8d36d..0ce5c4ef0 100644 --- a/include/param_jrn_add.inc.php +++ b/include/param_jrn_add.inc.php @@ -50,7 +50,7 @@ echo JS_SEARCH_POSTE; If ( isset ($_POST["JRN_ADD"]) ) { if ( !isset($_POST["p_jrn_name"]) || ! isset($_POST["p_jrn_type"] )) { - echo '

Un paramètre manque

'; + echo '

Un paramètre manque

'; } else { if ( $_POST['p_ech'] == 'no' ) { @@ -120,30 +120,30 @@ echo ' '; echo ''; echo ''; -echo ' Postes utilisables journal (débit/crédit) '; +echo ' Postes utilisables journal (débit/crédit) '; echo ' '.$search.''; echo ''; echo ''; -echo ' Nombre de lignes par défaut '; +echo ' Nombre de lignes par défaut '; echo ' '; echo ''; /* echo ''; -echo ' Postes utilisables journal (crédit) '; +echo ' Postes utilisables journal (crédit) '; echo ' '.$search.''; echo ''; */ echo ''; -echo ' Date d\'échéance '; +echo ' Date d\'échéance '; echo ' Oui'; echo 'Non'; echo ''; echo ''; -echo ' Libellé echéance '; +echo ' Libellé echéance '; echo ' '; echo ''; @@ -170,8 +170,8 @@ $num=pg_NumRows($Res); echo ''; -echo ' Fiches Dédit'; -echo ' Fiches Crébit'; +echo ' Fiches Dédit'; +echo ' Fiches Crébit'; echo ''; // Show the fiche in deb section for ($i=0;$i<$num;$i++) { diff --git a/include/param_jrn_detail.inc.php b/include/param_jrn_detail.inc.php index e4b71b95c..4fd757293 100644 --- a/include/param_jrn_detail.inc.php +++ b/include/param_jrn_detail.inc.php @@ -52,10 +52,10 @@ if ( isset( $_REQUEST['p_jrn'] )) { if ( isset($_POST["efface"])) { if ( CountSql($cn,"select * from jrn where jr_def_id=".$_POST['p_jrn']." limit 3") == 0 ) { - ExecSql($cn,"delete from jrn_def where jrn_def_id=".$_POST['p_jrn']); + ExecSqlParam($cn,"delete from jrn_def where jrn_def_id=$1",array($_POST['p_jrn'])); } else { echo ' '; } @@ -66,7 +66,7 @@ if ( isset($_POST["efface"])) { // Update ledger If ( isset ($_POST["JRN_UPD"] )) { if ( !isset($_POST["p_jrn_name"]) ) { - echo '

Un paramètre manque

'; + echo '

Un paramètre manque

'; } else { if ( $_POST['p_ech'] == 'no' ) { @@ -155,18 +155,18 @@ echo ' '; echo ''; /*echo ''; -echo ' Postes utilisables journal (crédit) '; +echo ' Postes utilisables journal (crédit) '; echo ' '.$search.''; echo ''; */ echo ''; -echo ' Date d\'échéance '; +echo ' Date d\'échéance '; if ( $l_line['jrn_def_ech'] == 't' ) { echo ' Oui'; echo 'Non '; @@ -178,7 +178,7 @@ if ( $l_line['jrn_def_ech'] == 'f' ) { echo ''; echo ''; -echo ' Libellé echéance '; +echo ' Libellé echéance '; echo ' '; echo ''; @@ -210,8 +210,8 @@ $rdeb=split(',',$l_line['jrn_def_fiche_deb']); $rcred=split(',',$l_line['jrn_def_fiche_cred']); echo ''; echo ''; -echo ''; -echo ''; +echo ''; +echo ''; echo ''; // Show the fiche in deb section for ($i=0;$i<$num;$i++) { diff --git a/include/param_pcmn.inc.php b/include/param_pcmn.inc.php index 4380cfd42..8c9325fac 100644 --- a/include/param_pcmn.inc.php +++ b/include/param_pcmn.inc.php @@ -64,7 +64,7 @@ echo ''; echo '
'; -/* Analyse ce qui est demandé */ +/* Analyse ce qui est demandé */ /* Effacement d'une ligne */ if (isset ($_GET['action'])) { //----------------------------------------------------- @@ -74,15 +74,15 @@ if (isset ($_GET['action'])) { /* Ligne a enfant*/ $R=ExecSqlParam($cn,"select pcm_val from tmp_pcmn where pcm_val_parent=$1",array($_GET['l'])); if ( pg_NumRows($R) != 0 ) { - echo ""; + echo ""; } else { - /* Vérifier que le poste n'est pas utilisé qq part dans les journaux */ + /* Vérifier que le poste n'est pas utilisé qq part dans les journaux */ $Res=ExecSqlParam($cn,"select * from jrnx where j_poste=$1",array($_GET['l'])); if ( pg_NumRows($Res) != 0 ) { - echo ""; + echo ""; } else { - $Del=ExecSql($cn,"delete from tmp_pcmn where pcm_val=".$_GET['l']); + $Del=ExecSqlParam($cn,"delete from tmp_pcmn where pcm_val=$1",array($_GET['l'])); } // if pg_NumRows } // if pg_NumRows } // isset ($l) @@ -120,11 +120,11 @@ if ( isset ( $_POST["Ajout"] ) ) { if ( $Count != 0 ) { // Alert message account already exists - echo ''; + echo ''; } else { - $Ret=ExecSqlParam($cn,"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) values ($1,$2,$3,$4)", array($p_val,$p_lib,$p_parent,$p_type)); + $Ret=ExecSqlParam($cn,"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) values ($1,$2,$3,$4)",array($p_val,$p_lib,$p_parent,$p_type)); } } } else { @@ -147,7 +147,7 @@ echo dossier::hidden();
Fiches Débit Fiches Crédit Fiches Débit Fiches Crédit
- + diff --git a/include/param_sec.inc.php b/include/param_sec.inc.php index 84176f92a..44a1b93a0 100644 --- a/include/param_sec.inc.php +++ b/include/param_sec.inc.php @@ -52,7 +52,7 @@ $User=ExecSql($cn,"select use_id,use_first_name,use_name,use_login from ac_user $MaxUser=pg_NumRows($User); -echo '
'; +echo '
'; echo '
Classe Libellé Libellé Parent Type
'; for ($i = 0;$i < $MaxUser;$i++) { @@ -140,7 +140,7 @@ if ( $action == "view" ) { if ( $MaxUser == 0 ) return; $l2_line=pg_fetch_array($User,0); - printf ('

Détail utilisateur %s %s (%s)

', + printf ('

Détail utilisateur %s %s (%s)

', $l2_line['use_first_name'], $l2_line['use_name'], $l2_line['use_login']); @@ -176,21 +176,21 @@ if ( $action == "view" ) { } else $right = 3; if ( $right == 0 ) { echo ""; echo ''; echo ''; } if ( $right == 1 ) { - echo ''; + echo ''; echo ""; echo ''; } if ( $right == 2 ) { - echo ''; + echo ''; echo ''; echo "'; + echo ''; echo ''; echo ""; $l_change=$l_change."&access=1"; - echo ''; + echo ''; } if ( $right == 1) { $l_change=$l_change."&access=0"; - echo ''; + echo ''; echo ""; } @@ -257,7 +257,7 @@ if ( $action == "view" ) { echo ''; echo ""; } diff --git a/include/param_user.inc.php b/include/param_user.inc.php index 9c64445f3..8f1908e70 100644 --- a/include/param_user.inc.php +++ b/include/param_user.inc.php @@ -52,7 +52,7 @@ $User=ExecSql($cn,"select use_id,use_first_name,use_name,use_login from ac_user $MaxUser=pg_NumRows($User); -echo '
'; +echo '
'; echo '
"; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Lecture Ecriture Pas d\'accès Pas d\'accès"; echo "Lecture "; echo " Ecriture Pas d\'accès Pas d\'accès Lecture"; @@ -199,7 +199,7 @@ if ( $action == "view" ) { } if ( $right == 3 ) { - echo ' Pas d\'accès Pas d\'accès Lecture "; @@ -240,16 +240,16 @@ if ( $action == "view" ) { } if ( $right == 0 ) { echo ""; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Accès Accès Pas d\'accès Pas d\'accès "; - echo "Accès "; + echo "Accès "; echo " Change "; - echo "Accès "; + echo "Accès "; echo "
'; for ($i = 0;$i < $MaxUser;$i++) { @@ -140,7 +140,7 @@ if ( $action == "view" ) { if ( $MaxUser == 0 ) return; $l2_line=pg_fetch_array($User,0); - printf ('

Détail utilisateur %s %s (%s)

', + printf ('

Détail utilisateur %s %s (%s)

', $l2_line['use_first_name'], $l2_line['use_name'], $l2_line['use_login']); @@ -176,21 +176,21 @@ if ( $action == "view" ) { } else $right = 3; if ( $right == 0 ) { echo ""; echo ''; echo ''; } if ( $right == 1 ) { - echo ''; + echo ''; echo ""; echo ''; } if ( $right == 2 ) { - echo ''; + echo ''; echo ''; echo "'; + echo ''; echo ''; echo ""; $l_change=$l_change."&access=1"; - echo ''; + echo ''; } if ( $right == 1) { $l_change=$l_change."&access=0"; - echo ''; + echo ''; echo ""; } @@ -254,7 +254,7 @@ if ( $action == "view" ) { echo ''; echo ""; } diff --git a/include/periode.inc.php b/include/periode.inc.php index 56d3d36e6..cefd0a5b6 100644 --- a/include/periode.inc.php +++ b/include/periode.inc.php @@ -25,7 +25,7 @@ $gDossier=dossier::id(); require_once ('class_widget.php'); require_once("preference.php"); require_once ('class_periode.php'); -echo '
'; +echo '
'; $cn=DbConnect($gDossier); //----------------------------------------------------- // Periode @@ -100,7 +100,7 @@ if ( $action== "delete_per" ) { $p_per=$_GET["p_per"]; // Check if the periode is not used if ( CountSql($cn,"select * from jrnx where j_tech_per=$p_per") != 0 ) { - echo '

Désolé mais cette période est utilisée

'; + echo '

Désolé mais cette période est utilisée

'; } else { $Res=ExecSql($cn,"delete from parm_periode where p_id=$p_per"); @@ -123,7 +123,7 @@ if ( $choose=="yes" ) { $wSel=new widget("select"); $wSel->value=$sel_jrn; $wSel->name='jrn_def_id'; - echo "Choississez global ou uniquement le journal à fermer".$wSel->IOValue(); + echo "Choississez global ou uniquement le journal à fermer".$wSel->IOValue(); echo widget::submit('choose','Valider'); echo widget::hidden('p_action','periode'); echo ""; diff --git a/include/poste.inc.php b/include/poste.inc.php index 02e756c7b..9db48878e 100644 --- a/include/poste.inc.php +++ b/include/poste.inc.php @@ -22,26 +22,26 @@ * \brief p_action contains the main action (always poste here) * action contains the sub action */ -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); //----------------------------------------------------- // confirm mod if ( isset( $_POST['confirm_mod'] ) ) { extract($_POST); - $update=new parm_code($cn,$p_code); + $update=new Acc_Parm_Code($cn,$p_code); $update->p_comment=$p_comment; $update->p_value=$p_value; - $update->Save(); + $update->save(); } -$object=new parm_code($cn); +$object=new Acc_Parm_Code($cn); -$all=$object->LoadAll(); +$all=$object->load_all(); echo '
'; echo '
"; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Lecture Ecriture Pas d\'accès Pas d\'accès"; echo "Lecture "; echo " Ecriture Pas d\'accès Pas d\'accès Lecture"; @@ -199,7 +199,7 @@ if ( $action == "view" ) { } if ( $right == 3 ) { - echo ' Pas d\'accès Pas d\'accès Lecture "; @@ -237,16 +237,16 @@ if ( $action == "view" ) { } if ( $right == 0 ) { echo ""; - echo "Pas d'accès"; + echo "Pas d'accès"; echo " Accès Accès Pas d\'accès Pas d\'accès "; - echo "Accès "; + echo "Accès "; echo " Change "; - echo "Accès "; + echo "Accès "; echo "
'; for ($i=0;$i'; - echo $all[$i]->Display(); + echo $all[$i]->display(); echo ' + + +update_global_pref('TOPMENU',$_POST['topmenu']); -} $topmenu=new widget('select'); $topmenu->name='topmenu'; $topmenu->selected=$_SESSION['g_topmenu']; @@ -108,58 +109,62 @@ $array=array( array('value'=>'SELECT','label'=>'Menu deroulant') ); $topmenu->value=$array; -echo '

Style de menu

'; -echo ''; -echo '
'; -echo $topmenu->IOValue(); -echo widget::submit('sub_topmenu','Sauver'); -echo ''; -echo '
'; +?> + + + +cn=$cn; + + if ( isset ($_POST['periode'])) + { $periode=$_POST["periode"]; $User->set_periode($periode); echo_debug('pref.inc',__LINE__,"Periode returns ".PeriodeClosed($cn,$periode)); + } $l_user_per=$User->get_periode(); + if ( $l_user_per=="") + $l_user_per=getDbValue($cn,"select min(p_id) from parm_periode where p_closed='f'"); + // if periode is closed then warns the users if ( PeriodeClosed($cn,$l_user_per)=='t') { - $msg= '

Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable

'; + $msg= '

Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable

'; } $l_form_per=FormPeriode($cn,$l_user_per,ALL); ?> -

Période

- - -
'; $w=new widget('hidden'); $w->name='id'; @@ -59,12 +59,13 @@ echo ""; if ( isset ($_POST['mod'] )) { echo '
'; - echo "Voulez-vous vraiment modifier ?"; + echo '
'; + echo "Voulez-vous vraiment modifier ?"; echo ''; echo ""; $id=$_POST['id']; - echo $all[$id]->Input(); + echo $all[$id]->form(); echo "
"; $h=new widget('hidden'); $h->name='p_action'; @@ -73,6 +74,7 @@ if ( isset ($_POST['mod'] )) echo widget::submit('confirm_mod','Confirme'); echo widget::submit('no','Cancel'); echo ""; + echo '
'; echo "
"; } diff --git a/include/poste.php b/include/poste.php index 9673d1b74..4f0efe4c7 100644 --- a/include/poste.php +++ b/include/poste.php @@ -67,7 +67,7 @@ function GetNumberLine($p_dossier,$p_jrn) $cn=DbConnect($p_dossier); $Res=ExecSql($cn,"select jrn_deb_max_line,jrn_cred_max_line from jrn_def where jrn_def_id=$p_jrn"); if ( pg_NumRows($Res) == 0 ) { - echo "

Journal non trouvé

"; + echo "

Journal non trouvé

"; // return (3,3); } $l_line=pg_fetch_array($Res,0); diff --git a/include/postgres.php b/include/postgres.php index 685732d66..a465da48e 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -127,14 +127,14 @@ de données"); * \param $p_string sql string * \return false if error otherwise true */ -function ExecSql($p_connection, $p_string) { +function ExecSql($p_connection, $p_string,$p_encoding='utf8') { echo_debug('postgres.php',__LINE__,"SQL = $p_string"); // probl. with Ubuntu & UTF8 //---- - pg_set_client_encoding($p_connection,'latin1'); + pg_set_client_encoding($p_connection,$p_encoding); ob_start(); - $ret=@pg_query($p_connection,$p_string); + $ret=pg_query($p_connection,$p_string); if ( ! $ret ) { ob_end_clean(); throw new Exception (" SQL ERROR $p_string ",1); @@ -158,15 +158,15 @@ function ExecSqlParam($p_connection, $p_string,$p_array) { // probl. with Ubuntu & UTF8 //---- - pg_set_client_encoding($p_connection,'latin1'); - ob_start(); + pg_set_client_encoding($p_connection,'utf8'); + //ob_start(); $ret=pg_query_params($p_connection,$p_string,$p_array); if ( ! $ret ) { - ob_end_clean(); - $r=$p_string."array ".var_export($p_array,TRUE); - throw new Exception (" SQL ERROR $r",1); + //ob_end_clean(); + $r=$p_string."array ".var_export($p_array,TRUE); + throw new Exception (" SQL ERROR $r",1); } - ob_end_clean(); + //ob_end_clean(); return $ret; } @@ -341,7 +341,7 @@ function get_login($p_uid) } /*! SyncRight - * \brief Synchronize les droits par d�faut + * \brief Synchronize les droits par d�faut * avec les journaux existants *\param $p_dossier dossier id * \param $p_user user id @@ -482,20 +482,23 @@ function save_upload_document ($cn,$seq) { * with the value * \param $p_cn database connection * \param $p_sql the sql stmt example :select s_value from - * document_state where s_id=2 - * \param $p_array if not null we use execSqlParam - * \return only the first value + document_state where s_id=2 + *\param $p_array if array is not null we use the ExecSqlParm (safer) + *\see ExecSqlParm + * \return only the first value or an empty string if nothing is found */ -function getDbValue($p_cn,$sql,$p_array=null) +function getDbValue($p_cn,$p_sql,$p_array=null) { - if ( $p_array == null ) - $ret=ExecSql($p_cn,$sql); - else - $ret=ExecSqlParam($p_cn,$sql,$p_array); + if ( $p_array == null) { + $ret=ExecSql($p_cn,$p_sql); + } else { + $ret=ExecSqlParam($p_cn,$p_sql,$p_array); + } if ( pg_NumRows($ret) == 0 ) return ""; $r=pg_fetch_row($ret,0); return $r[0]; + } /*!\brief test if a sequence exist */ /* \return true if the seq. exist otherwise false @@ -510,4 +513,179 @@ function create_sequence($p_cn,$p_name) { $sql="create sequence ".$p_name; ExecSql($p_cn,$sql); } + +/*! + ************************************************** + * \brief Get version of a database, the content of the + * table version + * + * \param $p_cn database connection + * + * \return version number + * + */ +function get_version($p_cn) { + $Res=ExecSql($p_cn,"select val from version"); + $a=pg_fetch_array($Res,0); + return $a['val']; +} +/*! execute_script + ************************************************** + * \brief Execute a sql script + * + * \param $p_cn database + * \param $script script name + */ +function execute_script($p_cn,$script) { + + if ( DEBUG=='false' ) ob_start(); + $hf=fopen($script,'r'); + if ( $hf == false ) { + echo 'Ne peut ouvrir '.$script; + exit(); + } + $sql=""; + $flag_function=false; + while (!feof($hf)) { + $buffer=fgets($hf); + $buffer=str_replace ("$","\$",$buffer); + print $buffer."
"; + // comment are not execute + if ( substr($buffer,0,2) == "--" ) { + //echo "comment $buffer"; + continue; + } + // Blank Lines Are Skipped + If ( Strlen($buffer)==0) { + //echo "Blank $buffer"; + Continue; + } + if ( strpos(strtolower($buffer),"create function")===0 ) { + echo "found a function"; + $flag_function=true; + $sql=$buffer; + continue; + } + if ( strpos(strtolower($buffer),"create or replace function")===0 ) { + echo "found a function"; + $flag_function=true; + $sql=$buffer; + continue; + } + // No semi colon -> multiline command + if ( $flag_function== false && strpos($buffer,';') == false ) { + $sql.=$buffer; + continue; + } + if ( $flag_function ) { + if ( strpos(strtolower($buffer), "language plpgsql") === false && + strpos(strtolower($buffer), "language 'plpgsql'") === false ) { + $sql.=$buffer; + continue; + } + } else { + // cut the semi colon + $buffer=str_replace (';','',$buffer); + } + $sql.=$buffer; +echo_debug('setup.php',__LINE__,"Execute sql $sql"); + if ( ExecSql($p_cn,$sql) == false ) { + Rollback($p_cn); + if ( DEBUG=='false' ) ob_end_clean(); + print "ERROR : $sql"; + exit(); + } + $sql=""; + $flag_function=false; + print "
"; + } // while (feof) + fclose($hf); + if ( DEBUG=='false' ) ob_end_clean(); +} +/*!\brief loop to apply all the path to a folder or + * a template + * \param $p_cn database connexion + * \param $p_name database name + * + */ +function apply_patch($p_cn,$p_name,$from_setup=1) +{ + $MaxVersion=DBVERSION-1; + echo '
    '; + $add=($from_setup==0)?'admin/':''; + for ( $i = 4;$i <= $MaxVersion;$i++) + { + $to=$i+1; + if ( get_version($p_cn) <= $i ) { + echo "
  • Patching ".$p_name. + " from the version ".get_version($p_cn)." to $to
  • "; + + execute_script($p_cn,$add.'sql/patch/upgrade'.$i.'.sql'); + if ( DEBUG=='false' ) ob_start(); + // specific for version 4 + if ( $i == 4 ) + { + $sql="select jrn_def_id from jrn_def "; + $Res=ExecSql($p_cn,$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($p_cn,$sql); + } + } + // specific to version 7 + if ( $i == 7 ) + { + // now we use sequence instead of computing a max + // + $Res2=ExecSql($p_cn,'select coalesce(max(jr_grpt_id),1) as l from jrn'); + $Max2= pg_NumRows($Res2) ; + if ( $Max2 == 1) { + $Row=pg_fetch_array($Res2,0); + var_dump($Row); + $M=$Row['l']; + ExecSql($p_cn,"select setval('s_grpt',$M,true)"); + } + } + // specific to version 17 + if ( $i == 17 ) + { + execute_script($p_cn,$add.'sql/patch/upgrade17.sql'); + $max=getDbValue($p_cn,'select last_value from s_jnt_fic_att_value'); + AlterSequence($p_cn,'s_jnt_fic_att_value',$max+1); + } // version + + // reset sequence in the modele + //-- + if ( $i == 30 && $p_name=="mod" ) + { + $a_seq=array('s_jrn','s_jrn_op','s_centralized', + 's_stock_goods','c_order','s_central'); + foreach ($a_seq as $seq ) { + $sql=sprintf("select setval('%s',1,false)",$seq); + $Res=ExecSql($p_cn,$sql); + } + $sql="select jrn_def_id from jrn_def "; + $Res=ExecSql($p_cn,$sql); + $Max=pg_NumRows($Res); + for ($seq=0;$seq<$Max;$seq++) { + $row=pg_fetch_array($Res,$seq); + $sql=sprintf ("select setval('s_jrn_%d',1,false)",$row['jrn_def_id']); + ExecSql($p_cn,$sql); + } + + } + if ( $i == 36 ) { + /* check the country and apply the path */ + $res=ExecSql($p_cn,"select pr_value from parameter where pr_id='MY_COUNTRY'"); + $country=pg_fetch_result($res,0,0); + execute_script($p_cn,$add."sql/patch/upgrade36.".$country.".sql"); + ExecSql($p_cn,'update tmp_pcmn set pcm_type=find_pcm_type(pcm_val)'); + } + if ( DEBUG == 'false') ob_end_clean(); + } + } + echo '
'; +} ?> diff --git a/include/pref.inc.php b/include/pref.inc.php index bb050aa9e..7616c0e41 100644 --- a/include/pref.inc.php +++ b/include/pref.inc.php @@ -24,19 +24,22 @@ */ require_once('class_widget.php'); require_once('class_user.php'); +require_once('class_acc_report.php'); +echo '
'; +//---------------------------------------------------------------------- +// Change password -echo '
'; - -if ( isset ($_POST['spass']) ) { - if ( $_POST['pass_1'] != $_POST['pass_2'] ) { -?> +if ( isset($_POST['pass_1']) + && strlen(trim($_POST['pass_1'])) != 0 ) { + if ($_POST['pass_1'] != $_POST['pass_2'] ) { + ?> Mot de passe est modifié"; } } + $url=$_SERVER['REQUEST_URI']; if ( ! isset ($_REQUEST['gDossier']) ) { echo ''; + } else { + echo '

Changez vos préférences

'; } ?> -

Mot de passe

-
- - - - -
-
+
+ +
+
Options Générales + + +"; ?> -

Thème

- -
+Mot de passe : + + +
- - - - - - - -
Style
- +

+

+Thème + + +
+Style de menu + +IOValue();?> +
- - %s ',$l_form_per); ?> - -
PERIODE
- + Période + + + + -

Taille des pages

-
- - - + + - -
Taille des pages + +
Taille des pages -
-
+ + + +
'; + echo ' Options pour la page d\'accueil'; + echo 'Mini-Rapport : '; + $rapport=new Acc_Report($cn); + $aRapport=$rapport->make_array(); + $aRapport[]=array("value"=>0,"label"=>'Aucun mini rapport'); + $wRapport=new widget("select"); + $wRapport->name="minirap"; + $wRapport->selected=$User->get_mini_report(); + $wRapport->value=$aRapport; + echo $wRapport->IOValue(); + echo 'Le mini rapport est un rapport qui s\'affiche sur votre page d\'accueil'; + echo '
'; +} + + + +echo widget::submit("val","Valider"); +echo ''; +if ( ! $inside_dossier ) { echo ''; - } +} diff --git a/include/preference.php b/include/preference.php index 7a8209ea1..7dec74084 100644 --- a/include/preference.php +++ b/include/preference.php @@ -119,7 +119,8 @@ function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="") * \param p_periode * * \return array containing the start date & the end date - * + * \todo the function get_periode@preference.php must be replaced + * by Periode::get_limit * */ function get_periode($p_cn,$p_periode) @@ -188,7 +189,7 @@ function ShowDevise($p_cn) echo ''; echo ""; echo ''; - echo ''; + echo ''; echo ""; $Res=ExecSql($p_cn,"select pm_id,pm_code,pm_rate from parm_money order by pm_code"); diff --git a/include/preod.inc.php b/include/preod.inc.php new file mode 100644 index 000000000..b0ed018c5 --- /dev/null +++ b/include/preod.inc.php @@ -0,0 +1,109 @@ +'; + echo ''; + $sel=new widget('select'); + $sel->name="jrn"; + $sel->value=make_array($cn,"select jrn_def_id,jrn_def_name from ". + " jrn_def order by jrn_def_name"); + // Show a list of ledger + $sa=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; + $sel->selected=$sa; + echo 'Choississez un journal '.$sel->IOValue(); + $wCheck=new widget("checkbox"); + if ( isset($_REQUEST['direct'])) { + $wCheck->selected=true; + } + echo 'Ecriture directe'.$wCheck->IOValue('direct'); + + echo dossier::hidden(); + $hid=new widget("hidden"); + echo $hid->IOValue("sa","jrn"); + echo $hid->IOValue("p_action","preod"); + echo '
'; + echo widget::submit('Accepter','Accepter'); + echo ''; + + // if $_REQUEST[sa] == del delete the predefined operation + if ( $sa == 'del') { + $op=new Pre_operation($cn); + $op->od_id=$_REQUEST['od_id']; + $op->delete(); + $sa='jrn'; + } + + // if $_REQUEST[sa] == jrn show the predefined operation for this + // ledger + if ( $sa == 'jrn' ) { + $op=new Pre_operation($cn); + $op->set_jrn($_GET['jrn']); + if ( isset($_GET['direct'])) { + $op->od_direct='true'; + } else { + $op->od_direct='false'; + } + $array=$op->get_list_ledger(); + if ( empty($array) == true ) { + echo "Aucun enregistrement"; + exit(); + } + + echo '
CODE Valeur
(par rapport à l\'euro)
Valeur
(par rapport à l\'euro)
'; + $count=0; + foreach ($array as $row ) { + + if ( $count %2 == 0 ) + echo ''; + else + echo ''; + echo ''; + echo ''; + echo ''; + + } + echo '
'.$row['od_name'].''; + echo '
'; + echo dossier::hidden(); + echo $hid->IOValue("sa","del"); + echo $hid->IOValue("p_action","preod"); + echo $hid->IOValue("del",""); + echo $hid->IOValue("od_id",$row['od_id']); + echo $hid->IOValue("jrn",$_GET['jrn']); + + $b=''; + echo $b; + echo '
'; + + echo '
'; + } + echo '
'; +?> \ No newline at end of file diff --git a/include/quick_writing.inc.php b/include/quick_writing.inc.php index c48694559..01e043715 100644 --- a/include/quick_writing.inc.php +++ b/include/quick_writing.inc.php @@ -44,17 +44,15 @@ function show_direct_form($cn,$ledger,$p_array) { // Show the predef operation // Don't forget the p_jrn echo '
'; - echo dossier::hidden(); echo widget::hidden('p_action',$_REQUEST['p_action']); - - echo ''; - $op=new Pre_operation($cn); - $op->p_jrn=$id; - $op->od_direct='t'; - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); + $op=new Pre_operation_detail($cn); + $op->set('ledger',$_REQUEST ['p_jrn']); + $op->set('ledger_type',$ledger->get_type()); + $op->set('direct','t'); + echo $op->form_get(); echo '
'; + + echo '
'; echo dossier::hidden(); @@ -62,6 +60,9 @@ function show_direct_form($cn,$ledger,$p_array) { echo $ledger->show_form($p_array); + + echo widget::button('add','Ajout d\'une ligne','onClick="quick_writing_add_row()"'); + echo widget::submit('summary','Sauvez'); echo '
Débit = @@ -72,6 +73,8 @@ function show_direct_form($cn,$ledger,$p_array) { echo ''; + echo ""; + echo "
".JS_CALC_LINE."
"; echo '
'; @@ -83,7 +86,7 @@ $ledger->with_concerned=true; // no ledger selected, propose one if ($id == -1 ) { - echo '
'; + echo '
'; // Vide echo '
'; @@ -100,7 +103,7 @@ if ( $User->AccessJrn($cn,$id) == false ) { "; exit(); } -echo '
'; +echo '
'; echo '

Journal : '.$ledger->get_name().'

'; echo widget::button_href('Autre journal','?p_action='.$_REQUEST['p_action'].'&'.dossier::get()); // User can write ? @@ -129,32 +132,42 @@ if ( isset($_GET['show_form']) || isset($_POST['correct_it']) ) { // if ( isset ($_GET['use_opd'])) { $op=new Pre_op_advanced($cn); - $op->set_od_id($_REQUEST['pre_def']); - //$op->p_jrn=$id; - - $p_post=$op->compute_array(); + $p_post=null; + if ( isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != ''){ + $op->set_od_id($_REQUEST['pre_def']); + //$op->p_jrn=$id; + + $p_post=$op->compute_array(); + } show_direct_form($cn,$ledger,$p_post); exit(); } if ( isset($_POST['summary'])) { - echo ''; - echo $ledger->show_form($_POST,1); - echo dossier::hidden(); - echo widget::hidden('p_action',$_REQUEST['p_action']); - - echo widget::submit('save_it',"Sauver"); - echo widget::submit('correct_it','Corriger'); - - $chk=new widget('checkbox'); - $chk->selected=false; - echo "Sauvez l'opération ?"; - echo $chk->IOValue('save_opd'); - - echo ''; - exit(); + try { + $ledger->verify($_POST ); + } catch (AcException $e) { + echo '"; + show_direct_form($cn,$ledger,$_POST); + exit(); + } + echo '
'; + echo $ledger->show_form($_POST,1); + echo dossier::hidden(); + echo widget::hidden('p_action',$_REQUEST['p_action']); + + echo widget::submit('save_it',"Sauver"); + echo widget::submit('correct_it','Corriger'); + + $chk=new widget('checkbox'); + $chk->selected=false; + echo "Sauvez l'opération ?"; + echo $chk->IOValue('save_opd'); + echo '
'; + exit(); + } if ( isset($_POST['save_it' ])) { $array=$_POST; @@ -162,7 +175,12 @@ if ( isset($_POST['save_it' ])) { try { $ledger->save($array); echo '

Opération enregistrée

'; - // echo $ledger->show_form($array,true); + echo widget::button_href('Autre opération dans ce journal', + "?".dossier::get(). + '&show_form'. + '&p_action=quick_writing&p_jrn='. + $_REQUEST['p_jrn']); + } catch (AcException $e) { echo '"; show_direct_form($cn,$ledger,$_POST); diff --git a/include/report.inc.php b/include/report.inc.php new file mode 100644 index 000000000..48fd8fe02 --- /dev/null +++ b/include/report.inc.php @@ -0,0 +1,150 @@ +Check(); +$User->can_request($cn,FORM); + + +$cn=DbConnect($gDossier); + +$nocookie='&PHPSESSID='.$_REQUEST['PHPSESSID']; +$rap=new Acc_Report($cn); + +if ( isset ($_POST["del_form"]) ) { + $rap->id=$_POST['fr_id']; + $rap->delete(); + // header('Location:'.$_SERVER["SCRIPT_URI"].'?'.$str_dossier.$nocookie); +} +if ( isset ($_POST["record"] )) { + $rap->from_array($_POST); + $rap->save(); + // header('Location:'.$_SERVER["SCRIPT_URI"].'?'.$str_dossier.$nocookie); +} +if ( isset($_POST['update'])) { + $rap->from_array($_POST); + $rap->save($_POST); + + } +if ( isset($_POST['upload'])) { + $rap->upload(); + +} + +$lis=$rap->get_list(); +$p_action='p_action=defreport'; +echo ''; + echo JS_SEARCH_POSTE; + echo JS_PROTOTYPE; +if ( isset($_POST['upload'])) { + exit(); + } +if ( isset ($_REQUEST["action"]) ) { + + $action=$_REQUEST ["action"]; + $rap->id=(isset($_REQUEST ['fr_id']))?$_REQUEST['fr_id']:0; + + if ($action == "add" && ! isset($_REQUEST['fr_id'])) + { + + echo '
'; + echo '

Définition

'; + echo '
'; + echo dossier::hidden(); + $rap->id=0; + echo $rap->form(15); + + echo widget::submit("record","Sauve"); + echo '
'; + echo 'Les lignes vides seront effacées'; + echo "
"; + echo '
'; + + echo '
'; + echo '

Importation

'; + echo dossier::hidden(); + $rap->id=0; + $wUpload=new widget('file'); + $wUpload->name='report'; + $wUpload->value='report_value'; + echo 'Importer ce rapport '; + echo $wUpload->IOValue(); + echo widget::submit("upload","Sauve"); + echo '
'; + echo 'Les lignes vides seront effacées'; + echo "
"; + + } + if ($action=="view" ) + { + echo '
'; + $rap->id=$_REQUEST ['fr_id']; + echo '
'; + $rap->load(); + echo $rap->form(); + echo widget::hidden("fr_id",$rap->id); + echo widget::hidden("action","record"); + echo widget::submit("update","Mise a jour"); + echo widget::submit("del_form","Effacement"); + $w=new widget('button'); + $w->name="export"; + $w->javascript="report_export('".$_REQUEST['PHPSESSID']."','".$gDossier."','".$rap->id."')"; + $w->label='Export'; + echo $w->IOValue(); + echo ''; + echo '
'; + echo 'Les lignes vides seront effacées'; + echo "
"; + } + +} + + + +html_page_stop(); +?> diff --git a/include/restore.inc.php b/include/restore.inc.php new file mode 100644 index 000000000..f5f28c9a5 --- /dev/null +++ b/include/restore.inc.php @@ -0,0 +1,171 @@ +'.widget::button_href("Retour","?action=restore&PHPSESSID=".$_REQUEST['PHPSESSID']); + if ( ! isset($_REQUEST['t'])) { + echo '
'; + echo ("Vous devez préciser s'il s'agit d'un modèle ou d'un dossier"); + echo $retour; + echo '
'; + exit(); + } + if ( empty ($_FILES['file']['name']) || + strlen(trim($_FILES['file']['name']))==0 + ) { + echo '
'; + + echo ("Vous devez donner un fichier "); + echo $retour; + echo '
'; + exit(); + } + //--------------------------------------------------------------------------- + // Restore a folder (dossier) + if ( $_REQUEST['t']=='d') { + ini_set('upload_max_filesize','5M'); + echo '
'; + + $cn=DbConnect(); + $id=NextSequence($cn,'dossier_id'); + + if ( strlen(trim($_REQUEST['database'])) == 0 ) + $lname=$id." Restauration :".FormatString($_FILES['file']['name']); + else + $lname=$id." ".$_REQUEST['database']; + + + $sql="insert into ac_dossier (dos_id,dos_name) values (".$id.",'".$lname."') "; + StartSql($cn); + try{ + getDbValue($cn,$sql); + + + } catch ( Exception $e) { + echo ''."Echec de la restauration ".''; + print_r($e); + Rollback($cn); + exit(); + } + Commit($cn); + $name=domaine."dossier".$id; + echo $name; + ExecSql($cn,"create database ".$name." encoding='utf8'"); + $args=" -d $name ".$_FILES['file']['tmp_name']; + + $status=system(PG_RESTORE.$args); + echo '

Restauration réussie du dossier '.$lname.'

'; + + $new_cn=DbConnect($id); + + apply_patch($new_cn,$name,0); + echo ''.'Ne pas recharger la page, sinon votre base de données sera restaurée une fois de plus'.''; + echo $retour; + + echo '
'; + } + //--------------------------------------------------------------------------- + // Restore a modele + + if ( $_REQUEST['t']=='m') { + ini_set('upload_max_filesize','5M'); + echo '
'; + + $cn=DbConnect(); + $id=NextSequence($cn,'s_modid'); + + if ( strlen(trim($_REQUEST['database'])) == 0 ) + $lname=$id." Restauration :".FormatString($_FILES['file']['name']); + else + $lname=$id." ".$_REQUEST['database']; + + + $sql="insert into modeledef (mod_id,mod_name) values (".$id.",'Restauration".$lname."') "; + StartSql($cn); + try{ + getDbValue($cn,$sql); + + } catch ( Exception $e) { + echo ''."Echec de la restauration ".''; + print_r($e); + Rollback($cn); + exit(); + } + Commit($cn); + + $name=domaine."mod".$id; + ExecSql($cn,"create database ".$name." encoding='utf8'"); + $args=" -d $name ".$_FILES['file']['tmp_name']; + $status=exec(PG_RESTORE.$args); + + echo '

Restauration réussie du modèle '.$lname.'

'; + $new_cn=DbConnect($id); + + apply_patch($new_cn,$name,0); + + echo ''.'Ne pas recharger la page, sinon votre base de données sera restaurée une fois de plus'.''; + echo $retour; + + echo '
'; + } + } else { + echo '
'; + ini_set('upload_max_filesize','5M'); + echo '
'; + echo widget::hidden('action','restore'); + echo widget::hidden('sa','r'); + echo ''; + echo ''; + $wNom=new widget("text"); + $wNom->name="database"; + $wNom->size=12; + echo ''; + echo ''; + $chk=new widget("radio"); + $chk->name="t"; + $chk->value="d"; + echo ''; + echo ''; + $chk->name="t"; + $chk->value="m"; + echo ''; + echo ''; + $file=new widget("file"); + $file->name="file"; + $file->value="mod"; + $file->label="Fichier"; + $file->table=1; + echo $file->IOValue(); + echo ''; + echo '
'."Nom de la base de donnée".''.$wNom->IOValue().'
'."Type de backup :".''.$chk->IOValue()."Dossier".'
'.$chk->IOValue()."Modele".'
'; + echo widget::submit("","Restauration"); + echo '
'; + echo '
'; + } \ No newline at end of file diff --git a/include/stock.inc.php b/include/stock.inc.php index 1346a4854..00d141c9a 100644 --- a/include/stock.inc.php +++ b/include/stock.inc.php @@ -85,7 +85,7 @@ if ( isset ($_POST['sub_change'])) or isNumber($change) == 0 or isNumber($year) == 0 ) { - $msg="Stock données non conformes"; + $msg="Stock données non conformes"; echo ""; echo_error($msg); } else diff --git a/include/stock_inc.php b/include/stock_inc.php index 7c7d0ebeb..57137cfb8 100644 --- a/include/stock_inc.php +++ b/include/stock_inc.php @@ -61,7 +61,7 @@ where $result.=""; $result.='Code'; $result.='Noms'; - $result.='Entrée'; + $result.='Entrée'; $result.='Sortie'; $result.='Solde'; $result.=""; @@ -195,11 +195,11 @@ $sql="select sg_code, $r.=''; $r.=""; $r.=""; - $r.=""; + $r.=""; $r.=""; $r.=""; $r.=""; - $r.=""; + $r.=""; $r.=""; $r.=""; // compute sessid diff --git a/include/supplier.inc.php b/include/supplier.inc.php index 5a362af81..79e3613a5 100644 --- a/include/supplier.inc.php +++ b/include/supplier.inc.php @@ -28,6 +28,7 @@ $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; */ $User->can_request($cn,SUPPL); +$script=basename($_SERVER['PHP_SELF']); ?> can_request($cn,SUPPL); // Remove a card if ( isset ($_POST['delete']) ) { - echo 'delete'; + $f_id=$_REQUEST['f_id']; $fiche=new Supplier($cn,$f_id); @@ -46,6 +47,8 @@ if ( isset ($_POST['delete']) ) // Add card if ( $sub_action=="insert" ) { + echo '
'; + $retour=widget::button_href("Retour", urldecode($_REQUEST['url'])); $supplier=new Supplier($cn); @@ -55,7 +58,7 @@ if ( $sub_action=="insert" ) echo $supplier->Display(true); echo "
Date Entrée / Sortie Entrée / Sortie DescriptionOpérationMontantQuantitéQuantitéPrix/Cout Unitaire
"; echo $retour; - + echo '
'; } //----------------------------------------------------- // Save modification @@ -74,12 +77,12 @@ if ( $sub_action == "" ) //Display a blank card if ( $sub_action=="blank") { - $retour=widget::button_href('Retour','commercial.php?p_action=fournisseur&'.dossier::get()); - echo '
'; + $retour=widget::button_href('Retour','?p_action=fournisseur&'.dossier::get()); + echo '
'; echo $retour; $c=new Supplier($cn); - echo '
'; echo ''; echo ''; @@ -97,9 +100,9 @@ if ( $sub_action=="blank") if ( $sub_action == "list" ) { ?> -
+
- + - + '; - echo '
'; + echo '
'; echo $sup->Summary($search); echo '
'; echo '
'; @@ -145,7 +148,7 @@ if ( $sub_action == "list" ) if ( $sub_action == 'detail' ) { $f_id=$_REQUEST['f_id']; - echo '
'; + echo '
'; $sup=new Supplier($cn,$f_id); $retour=widget::button_href("Retour", urldecode($_REQUEST['url'])); @@ -162,7 +165,7 @@ if ( $sub_action == 'detail' ) echo widget::submit('mod','Sauver les modifications'); echo widget::reset("Annuler"); - echo widget::submit('delete','Effacer cette fiche'); + echo widget::submit('delete','Effacer cette fiche','onclick="return confirm(\'Confirmer effacement ?\');"'); echo ''; echo $retour; echo '
'; diff --git a/include/tva.inc.php b/include/tva.inc.php index e864c8a11..b485a8504 100644 --- a/include/tva.inc.php +++ b/include/tva.inc.php @@ -21,11 +21,11 @@ /*! \file * \brief included file for customizing with the vat (account,rate...) */ -echo '
'; +echo '
'; // Confirm remove if ( isset ($_POST['confirm_rm'])) { - ExecSql($cn,'select tva_delete('.$_POST['tva_id'].')'); + ExecSql($cn,'select tva_delete('.pg_escape_string($_POST['tva_id']).')'); } //----------------------------------------------------- // Record Change @@ -33,7 +33,6 @@ echo '
'; || isset ($_POST['confirm_add'])) { extract($_POST); - $tva_id=FormatString($tva_id); $tva_label=FormatString($tva_label); $tva_rate=FormatString($tva_rate); $tva_comment=FormatString($tva_comment); @@ -41,39 +40,44 @@ echo '
'; // remove space $tva_poste=str_replace (" ","",$tva_poste); $err=0; // Error code - if ( isNumber($tva_id) == 0 ) { - $err=1; - - } + if ( isNumber($tva_rate) == 0 ) { $err=2; - } + } if ( $err == 0 ) { if ( isset ($_POST['confirm_add']) ) { - $Res=ExecSql($cn, - "select tva_insert($tva_id,'$tva_label', - '$tva_rate','$tva_comment','$tva_poste')"); - + $sql="select tva_insert($1,$2,$3,$4)"; + + $res=ExecSqlParam($cn, + $sql, + array($tva_label, + $tva_rate, + $tva_comment, + $tva_poste) + ); + $ret_sql=pg_fetch_row($res); + $err=$ret_sql[0]; } if ( isset ($_POST['confirm_mod']) ) { - $Res=ExecSql($cn, + $Res=ExecSql($cn, "select tva_modify($tva_id,'$tva_label', '$tva_rate','$tva_comment','$tva_poste')"); + $ret_sql=pg_fetch_row($Res); + $err=$ret_sql[0]; } - $ret_sql=pg_fetch_row($Res); - $err=$ret_sql[0]; + } if ( $err != 0 ) { $err_code=array(1=>"Tva id n\'est pas un nombre", 2=>"Taux tva invalide", - 3=>"Label ne peut être vide", + 3=>"Label ne peut être vide", 4=>"Poste invalide", - 5=>"Tva id doit être unique"); + 5=>"Tva id doit être unique"); $str_err=$err_code[$err]; echo "";; } @@ -81,12 +85,11 @@ echo '
'; //----------------------------------------------------- // Display - $sql="select tva_id,tva_label,tva_rate,tva_comment,tva_poste from tva_rate order by tva_id"; + $sql="select tva_id,tva_label,tva_rate,tva_comment,tva_poste from tva_rate order by tva_rate"; $Res=ExecSql($cn,$sql); ?> - @@ -108,11 +111,10 @@ echo '
'; echo "
"; echo ''; - echo ""; + echo ""; @@ -197,24 +199,24 @@ if ( ! isset ($_POST['add']) if ( isset ( $_REQUEST['add'])) { echo_debug("parametre",__LINE__,"add a line "); - echo "Tva à ajouter, l'id doit être différent pour chaque taux"; + echo "
Ajout d'un taux de tva "; echo ''; ?>
Id Label Taux Commentaire
"; - echo $row['tva_id']; - echo ""; + echo widget::hidden('tva_id',$row['tva_id']); echo $row['tva_label']; echo "
- - - - - - - - - + + + + + + + + +
idLabelTauxCommentairePoste
size=5; echo $w->IOValue('tva_id','') ?>
Label (ce que vous verrez dans les journaux) size=20; echo $w->IOValue('tva_label','') ?>
Taux de tva size=5; echo $w->IOValue('tva_rate','') ?>
Commentaire heigh=2;$w->width=20;echo $w->IOValue('tva_comment','') ?>
Poste comptable utilisés format :debit,credit size=10;echo $w->IOValue('tva_poste','') ?>
@@ -222,6 +224,7 @@ if ( ! isset ($_POST['add']) + Modification d'un taux de tva "; echo '
'; echo ''; ?> - - - - - - - + + + + + + + + + + +
LabelTauxCommentairePoste
Label (ce que vous verrez dans les journaux) size=20; echo $w->IOValue('tva_label',$a[$index]['tva_label']) ?>
Taux de tva size=5; echo $w->IOValue('tva_rate',$a[$index]['tva_rate']) ?>
Commentaire heigh=2;$w->width=20; echo $w->IOValue('tva_comment',$a[$index]['tva_comment']) ?>
Poste comptable utilisés format :debit,credit size=5; echo $w->IOValue('tva_poste',$a[$index]['tva_poste']) ?>
+ '; + echo '
'; ?> diff --git a/include/user_action_ach.php b/include/user_action_ach.php index bbf136722..6517b9b37 100644 --- a/include/user_action_ach.php +++ b/include/user_action_ach.php @@ -58,19 +58,11 @@ if ( $action=="use_opd" ) { //-------------------- // predef op. echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; + $op->set('ledger',$_GET['p_jrn']); + $op->set('ledger_type',"ACH"); + $op->set('direct','f'); - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","ACH"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); + echo $op->form_get(); echo '
'; @@ -97,9 +89,11 @@ if ( $action == 'new' ) { $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false,$jrn->getDefLine()); //-------------------- // predef op. - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; + $op=new Pre_operation_detail($cn); + $op->set('ledger',$_GET['p_jrn']); + $op->set('ledger_type',"ACH"); + $op->set('direct','f'); + echo '
'; echo $r; @@ -107,20 +101,7 @@ if ( $action == 'new' ) { //-------------------- // predef op. echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","ACH"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - + echo $op->form_get(); echo '
'; echo "
".JS_CALC_LINE."
"; diff --git a/include/user_action_fin.php b/include/user_action_fin.php index ba4ae2e56..a47b2bc3b 100644 --- a/include/user_action_fin.php +++ b/include/user_action_fin.php @@ -25,7 +25,7 @@ echo_debug('user_action_fin.php',__LINE__,"include user_action_fin.php"); require_once("user_form_fin.php"); include_once("class_widget.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once("class_acc_ledger.php"); require_once ('class_pre_op_fin.php'); @@ -37,7 +37,7 @@ if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) { include_once ("preference.php"); include_once ("user_common.php"); if ( ! isset($_REQUEST['action'])) { - echo "Aucune Action demandée"; + echo "Aucune Action demandée"; exit(); } @@ -55,7 +55,7 @@ if ( $action=="use_opd" ) { ''; $form=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']); - echo '
'; + echo '
'; echo $form; echo '
'; exit(); @@ -81,7 +81,7 @@ if ( $action == 'new' ) { $jrn=new Acc_Ledger($cn, $p_jrn); $r=FormFin($cn,$p_jrn,$User->get_periode(),$submit,null,false,$jrn->GetDefLine()); - echo '
'; + echo '
'; echo $r; echo "
"; //-------------------- @@ -98,7 +98,7 @@ if ( $action == 'new' ) { echo $hid->IOValue("jrn_type","FIN"); if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); + echo widget::submit('use_opd','Utilisez une op.prédéfinie'); echo $op->show_button(); echo ''; @@ -121,7 +121,7 @@ if ( $action == 'new' ) { '; $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; + echo '
'; echo $r; echo "

On-line calculator

".JS_CALC_LINE."
"; @@ -201,7 +201,7 @@ if ( $action == 'voir_jrn' ) { exit -1; } ?> -
+
@@ -232,7 +232,7 @@ $User=new User($cn); $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); +echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); ?>
p_value."%' or pcm_val::text like '".$vir_interne->p_value."%' diff --git a/include/user_action_gl.php b/include/user_action_gl.php index f13007313..93db18ba9 100644 --- a/include/user_action_gl.php +++ b/include/user_action_gl.php @@ -18,7 +18,7 @@ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /* $Revision$ */ -echo_debug('user_action_gl.php',__LINE__,"include user_action_gl.php"); + /*! \file * \brief included file for the great ledger */ @@ -31,20 +31,10 @@ require_once("jrn.php"); $cn=DbConnect($gDossier); -?> -
-
-name="jrn_type"; -$hid->value="NONE"; -echo $hid->IOValue(); - -$hid->name="action"; -$hid->value="voir_jrn"; -echo $hid->IOValue(); +echo '
+ '; +echo dossier::hidden(); +echo widget::hidden('p_action','gl'); $w=new widget("select"); // filter on the current year @@ -53,17 +43,19 @@ $filter_year=" where p_exercice='".$User->get_exercice()."'"; $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -?> - -get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } +echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -$sql=SQL_LIST_ALL_INVOICE.$cond; +echo ''; + +if ( $current == -1) { + $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; + } else { + $cond=" and jr_tech_per=".$current; + } +/* security filter on the ledger */ +$sql_ledger=''; +if ( $User->Admin() == 0 ) { $sql_ledger=' and '.$User->get_ledger_sql();} +$sql=SQL_LIST_ALL_INVOICE.$cond.$sql_ledger; // Nav. bar $step=$_SESSION['g_pagesize']; $page=(isset($_GET['offset']))?$_GET['page']:1; diff --git a/include/user_action_ods.php b/include/user_action_ods.php index 01cecb65f..142d453ff 100644 --- a/include/user_action_ods.php +++ b/include/user_action_ods.php @@ -63,19 +63,11 @@ if ( $action=="use_opd" ) { //-------------------- // predef op. echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","ODS"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); + $op=new Pre_operation_detail($cn); + $op->set('ledger',$_GET['p_jrn']); + $op->set('ledger_type',"ODS"); + $op->set('direct','f'); + echo $op->form_get(); echo '
'; @@ -107,21 +99,14 @@ if ( $action == 'new' ) { //-------------------- // predef op. echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","ODS"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); + $op=new Pre_operation_detail($cn); + $op->set('ledger',$_GET['p_jrn']); + $op->set('ledger_type',"ODS"); + $op->set('direct','f'); + echo $op->form_get(); echo '
'; + echo "

On-line calculator

".JS_CALC_LINE."
"; echo "
"; @@ -263,7 +248,7 @@ $User=new User($cn); $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); +echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); ?> set_od_id($_REQUEST['pre_def']); - $op->od_direct='f'; $p_post=$op->compute_array(); echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); @@ -60,20 +59,11 @@ if ( $action=="use_opd" ) { //-------------------- // predef op. echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","VEN"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - + $op->set('ledger',$_GET['p_jrn']); + $op->set('ledger_type',"VEN"); + $op->set('direct','f'); + + echo $op->form_get(); echo '
'; echo '
'; @@ -114,31 +104,23 @@ if ( $action == 'insert_vente' ) { // We want a blank form if ( $blank==1) { - $jrn=new Acc_Ledger($cn, $_GET['p_jrn']); - echo_debug('user_action_ven.php',__LINE__,"Blank form"); - // Show an empty form of invoice - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),null,false,$jrn->GetDefLine()); - echo '
'; - echo $form; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; + $jrn=new Acc_Ledger($cn, $_GET['p_jrn']); + $op=new Pre_op_ven($cn); + echo_debug('user_action_ven.php',__LINE__,"Blank form"); + // Show an empty form of invoice + $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),null,false,$jrn->GetDefLine()); + echo '
'; + echo $form; + //-------------------- + // predef op. - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","VEN"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo ''; - echo '
'; + echo '
'; + $op->set('ledger',$_REQUEST['p_jrn']); + $op->set('ledger_type',"VEN"); + $op->set('direct','f'); + echo $op->form_get(); + echo '
'; + echo '
'; } } @@ -240,7 +222,7 @@ $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from pa $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); $w->selected=$current; -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); +echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); ?> '; echo "$bar
"; @@ -365,9 +347,9 @@ if ( $action == 'voir_jrn_non_paye' ) { echo '
'; echo dossier::hidden(); echo $bar2; - echo '

Echeance dépassée

'; + echo '

Echeance dépassée

'; echo $list; - echo '

Non Payée

'; + echo '

Non Payée

'; echo $list2; echo $bar2; // Add hidden parameter @@ -389,7 +371,7 @@ if ( $action == 'voir_jrn_non_paye' ) { echo '
'; if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); + echo widget::submit('paid','Mise à jour paiement'); echo '
'; echo '
'; diff --git a/include/user_common.php b/include/user_common.php index 2999d1636..8089f20a8 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -276,104 +276,7 @@ function GetTvaPoste($p_cn,$p_tva_id,$p_cred) { -/*! InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_grpt,$p_periode - ************************************************** - *\brief Insert into the table Jrn - * - * - * \param $p_cn database connection - * \param $p_type debit or credit - * \param $p_user the current user - * \param $p_jrn the current 'journal' (folder) - * \param $p_poste the account - * \param $p_date - * \param $p_amount amount to insert - * \param $p_periode the concerned periode - * - * \return nothing - * - */ -function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_grpt,$p_periode,$p_qcode="") -{ - echo_debug ('user_common.php',__LINE__,"InsertJrnx param - type = $p_type p_user $p_user - p_date $p_date p_poste $p_poste - p_amount $p_amount p_grpt = $p_grpt p_periode = $p_periode"); - - //if ( $p_amount == 0) return true; - - $debit=($p_type=='c')?'false':'true'; - - // if negative value the operation is inversed - if ( $p_amount < 0 ) { - $debit=($debit=='false')?'true':'false'; - } - - $sql=sprintf("select insert_jrnx - ('%s',abs(%.2f),%d,%d,%d,%s,'%s',%d,upper('%s'))", - $p_date,round($p_amount,2),$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode,$p_qcode); - - echo_debug('user_common.php',__LINE__,"InsertJrnx $sql"); - $Res=ExecSql($p_cn,$sql); - if ( $Res==false) return $Res; - return GetSequence($p_cn,'s_jrn_op'); - -} -/*! InsertJrn($p_cn,$p_date,$p_jrn,$p_comment,$p_amount,$p_grpt,$p_periode - ************************************************** - *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the - * group id ($p_grpt) - * - * \param $p_cn database connection - * \param $p_date date - * \param $p_jrn the current 'journal' (folder) - * \param $p_poste the account - * \param $p_periode the concerned periode - * \param $p_comment comment - * - * \return nothing - * - */ - -function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_grpt,$p_periode) -{ - echo_debug ('user_common.php',__LINE__,"InsertJrn param - p_date $p_date p_poste $p_comment p_amount -p_grpt = $p_grpt p_periode = $p_periode p_echeance = $p_echeance -comment = $p_comment"); - $p_comment=FormatString($p_comment); - - if ( $p_echeance == "" or $p_echeance==null) { - $p_echeance='null'; - } else { - $p_echeance=sprintf("to_date('%s','DD.MM.YYYY')",$p_echeance); - } - // retrieve the value from jrnx - // - $montant_deb=getDBValue($p_cn,"select sum(j_montant) from jrnx where j_debit='t' and j_grpt=$p_grpt"); - $montant_cred=getDBValue($p_cn,"select sum(j_montant) from jrnx where j_debit='f' and j_grpt=$p_grpt"); - echo_debug('InsertJrn',__LINE__,"debit = $montant_deb credit = $montant_cred "); - - $amount=-1.0000; - if ( $montant_deb == $montant_cred ) { - $amount=$montant_deb; - } else { - echo "Erreur : balance incorrecte : débit = $montant_deb crédit = $montant_cred"; - return false; - } - // if amount == -1then the triggers will throw an error - // - $sql=sprintf("insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_ech,jr_grpt_id,jr_tech_per) - values ( %d,abs(%.2f),'%s',to_date('%s','DD.MM.YYYY'),%s,%d,%d)", - $p_jrn, $amount,$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode); - - - echo_debug('user_common.php',__LINE__,"InsertJrn $sql"); - $Res=ExecSql($p_cn,$sql); - if ( $Res == false) return false; - return GetSequence($p_cn,'s_jrn'); -} /*! *\brief show all the lines of the asked jrn, uses also the $_GET['o'] for the sort * @@ -652,7 +555,7 @@ $sort_echeance=" $image_ascEch& switch ($href) { // user_jrn.php - case 'user_jrn.php': + case 'compta.php': $vue="E"; //Expert View break; case 'commercial.php': @@ -798,7 +701,7 @@ $sort_echeance=" $image_ascEch& * \param $p_cn database connection * * \param $p_j_id the j_id - * \param $p_goods the goods + * \param $p_good the goods * \param $p_quant quantity * \param $p_type c for credit or d for debit * @@ -809,7 +712,9 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type) { echo_debug('user_common.php',__LINE__,"function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)"); // Retrieve the good account for stock - $code_marchandise=GetFicheAttribut($p_cn,$p_good,ATTR_DEF_STOCK); + $code=new fiche($p_cn); + $code->get_by_qcode($p_good); + $code_marchandise=$code->strAttribut(ATTR_DEF_STOCK); $p_good=FormatString($p_good); $sql="select f_id from vw_poste_qcode where j_qcode=upper('$p_good')"; $Res=ExecSql($p_cn,$sql); @@ -1027,14 +932,11 @@ function UpdateComment ($p_cn,$p_jr_id,$p_comment) { ************************************************** *\brief test if a jrn op is valid * - * parm : - * - db connection - * - p_grpt_id - * gen : - * - none - * return: - * 1 is valid - * 0 is not valid + * \param $p_cn db + * \param $p_grpt_id + * \return: + * - 1 is valid + * - 0 is not valid */ function isValid ($p_cn,$p_grpt_id) { $Res=ExecSql($p_cn,"select jr_valid from jrn where jr_grpt_id=$p_grpt_id"); diff --git a/include/user_form_ach.php b/include/user_form_ach.php index f80072697..fd9f491af 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -27,7 +27,7 @@ require_once("class_widget.php"); require_once("preference.php"); require_once("fiche_inc.php"); require_once("user_common.php"); -require_once("class_parm_code.php"); +require_once("class_acc_parm_code.php"); require_once ('class_anc_plan.php'); require_once ('class_own.php'); require_once ('class_anc_operation.php'); @@ -487,7 +487,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } - // Periode ferm� + // Periode ferm� $per=new Periode($p_cn); $per->set_jrn($p_jrn); $per->set_periode($p_periode); @@ -854,7 +854,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2); // save it echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);"); - $dna=new parm_code($p_cn,'DNA'); + $dna=new Acc_Parm_Code($p_cn,'DNA'); $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); $amount=$amount-$nd_amount; @@ -873,7 +873,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $nd_amount+=$tva_nd; // save it - $dna=new parm_code($p_cn,'DEP_PRIV'); + $dna=new Acc_Parm_Code($p_cn,'DEP_PRIV'); $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); // modify sum @@ -898,7 +898,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $sum_tva_nd+=$ded_vat; // compute the NDA TVA - $tva_dna=new parm_code($p_cn,'TVA_DNA'); + $tva_dna=new Acc_Parm_Code($p_cn,'TVA_DNA'); echo_debug('user_form_ach.php',__LINE__, "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_dna->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); @@ -918,7 +918,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $aTva_ded_impot_recup[$i]=round($ded_vat,2); // Save it - $tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT'); + $tva_ded_impot=new Acc_Parm_Code($p_cn,'TVA_DED_IMPOT'); echo_debug('user_form_ach.php',__LINE__, "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); diff --git a/include/user_form_fin.php b/include/user_form_fin.php index a09cfcea1..1b90416a2 100644 --- a/include/user_form_fin.php +++ b/include/user_form_fin.php @@ -112,7 +112,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } - // Periode ferm� + // Periode ferm� $per=new Periode($p_cn); $per->set_jrn($p_jrn); $per->set_periode($p_periode); diff --git a/include/user_form_ods.php b/include/user_form_ods.php deleted file mode 100644 index c42143d67..000000000 --- a/include/user_form_ods.php +++ /dev/null @@ -1,453 +0,0 @@ -$v) { - ${"$a"}=$v; - } - } - $own = new Own($p_cn); - - // The date - list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode); - $flag=(isset($e_date))?1:0; - // $e_date=( ! isset($e_date) ) ? - // substr($l_date_start,2,8):$e_date; - $e_date=( ! isset($e_date) ) ? $l_date_start:$e_date; - $per=new Periode($p_cn); - $per->set_jrn($p_jrn); - $per->set_periode($p_periode); - - // Periode ferme - if ( $per->is_open()==0) - { - $msg="Cette periode est fermee pour ce journal"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - - // Verify if valid date - if ( $flag==1 and VerifyOperationDate($p_cn,$p_periode,$e_date) == null) { - if ( $pview_only == true) - return null; - else - $e_date=substr($l_date_start,2,8); - } - - $e_comm=(isset($e_comm))?$e_comm:""; - // Save old value and set a new one - - $r=""; - - if ( $pview_only == false) { - $r.=JS_SEARCH_POSTE; - $r.=JS_COMPUTE_ODS; - } - - //$r.="
"; -$r.=""; - $hid=new widget('hidden'); - $r.=$hid->IOValue('p_jrn',$p_jrn); - $r.=$hid->IOValue('action','new'); - - $r.=dossier::hidden(); - $r.=''; - // Date - $wDate=new widget('js_date'); - $wDate->SetReadOnly($pview_only); - $wDate->table=1; - $r.="".$wDate->IOValue("e_date",$e_date,'Date').""; - - // Description - $Commentaire=new widget("text"); - $Commentaire->table=1; - $Commentaire->SetReadOnly($pview_only); - $Commentaire->size=80; - $r.=""; - $r.=$Commentaire->IOValue("e_comm",$e_comm,"Description"); - $r.=""; - - include_once("fiche_inc.php"); - - // Record the current number of article - $r.=''; - $e_comment=(isset($e_comment))?$e_comment:""; - - // Start the div for item to encode - $r.="
"; - $r.='

Opérations Diverses

'; - $r.='
'; - $r.=""; - if ( $pview_only == false) $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $sum_deb=0.0; - $sum_cred=0.0; - $count=0; - // for each good - for ($i=0;$i< $p_article;$i++) { - - $account=(isset(${"e_account$i"}))?${"e_account$i"}:""; - - $lib=''; - // If $account has a value - if ( isNumber($account) == 1 ) { - if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=$account") == 0 ) { - $msg="Poste comptable inexistant !!! "; - echo_error($msg); echo_error($msg); - echo ""; - $account=""; - if ( $pview_only == true ) return null; - } else { - // retrieve the tva label and name - $lib=''.GetPosteLibelle($p_cn, $account,1).''; - } - } - - ${"e_account$i"."_amount"}=(isset(${"e_account$i"."_amount"}))?abs(round(${"e_account$i"."_amount"},2)):0; - if ( isNumber(${"e_account$i"."_amount"}) == 0 ) { - if ( $pview_only==true) { - $msg="Montant invalide !!! "; - echo_error($msg); - echo ""; - return null; - } - ${"e_account$i"."_amount"}=0; - } - // code - // Do we need a filter ? - $jrn=new Acc_Ledger($p_cn,$p_jrn); - $l_line=$jrn->get_propertie(); - if( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 || - strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) { - $filter=1; - } - else - $filter=null; - $W = new widget('js_search_poste'); - $W->readonly=$pview_only; - $W->label=""; - $W->extra=$p_jrn; - $W->extra2=$filter; - // $r.=''.InputType("","js_search_poste","e_account".$i,$account,$pview_only,$filter); - $r.=""; - //amount - $wAmount=new widget("text"); - $wAmount->table=1; - $wAmount->SetReadOnly($pview_only); - $wAmount->javascript=' onChange="checkTotal()"'; - - $r.=$wAmount->IOValue("e_account".$i."_amount",${"e_account$i"."_amount"}); - - - // Type is debit or credit, retrieve the old values - ${"e_account$i"."_type"}=(isset (${"e_account$i"."_type"}))?${"e_account$i"."_type"}:'d'; - $c_check=( ${"e_account$i"."_type"} == 'c')?"CHECKED":""; - $d_check=( ${"e_account$i"."_type"} == 'd' )?"CHECKED":""; - $r.=''; - $count++; - } - - } - $r.=''; - $r.=''; - $sum_deb+=(${"e_account$i"."_type"}=='d')?${"e_account$i"."_amount"}:0; - $sum_cred+=(${"e_account$i"."_type"}=='c')?${"e_account$i"."_amount"}:0; - } - } // End for - $r.="
ComptePosteMontantCrédit ou débit
".$W->IOValue("e_account".$i, $account).''; - //libelle - $r.=" $lib '; - if ( $pview_only == false ) { - $r.=' Débit ou '; - $r.=' Crédit '; - }else { - $r.=(${"e_account$i"."_type"} == 'c' )?"Crédit":"Débit"; - $r.=''; - // Add CA - //-------------------------------------------------- - if ( ereg("^7+",${"e_account$i"}) || - ereg("^6+",${"e_account$i"})) - { - - if ( $own->MY_ANALYTIC!='nu') // use of AA - { - // show form - $op=new Anc_Operation($p_cn); - $null=($own->MY_ANALYTIC=='op')?1:0; - $r.=''; - $p_mode=($p_saved)?0:1; - $r.=$op->display_form_plan($_POST,$null,$p_mode,$count,${"e_account$i"."_amount"}); - $r.='
"; - - if ( $pview_only==true && $p_saved==false) { - // pre_operation - $chk=new widget('checkbox'); - $chk->selected=true; - $r.="Sauvez l'opération ?"; - $r.=$chk->IOValue('opd_save'); - -// check for upload piece - $file=new widget("file"); - $file->table=1; - $r.="
"; - $r.= ""; - $r.="".$file->IOValue("pj","","Pièce justificative").""; - $r.="
"; - $r.="
"; - } else { - $r.= '
- Débit = - Crédit = - Difference = -
- '; - } - // Set correctly the REQUEST param for jrn_type - $h=new widget('hidden'); - $h->name='jrn_type'; - $h->value='ODS'; - $r.=$h->IOValue(); - - $r.=$p_submit; - // $r.="
"; - $r.=""; - //TODO if view only show total - $tmp= abs($sum_deb-$sum_cred); - echo_debug('user_form_ods.php',__LINE__,"Diff = ".$tmp); - if ( $pview_only==true) { - - if ( abs($sum_deb-$sum_cred) > 0.0001 ) { - $msg=sprintf("Montant non correspondant credit = %.5f debit = %.5f diff = %.5f", - $sum_cred,$sum_deb,$sum_cred-$sum_deb); - echo ""; - return null; - } - - // Verify that we have a non-null operation - if ($sum_cred == 0) - { - $msg=sprintf("Montant null"); - echo ""; - return null; - } - } - /* if not view only then a javascript will compute and check the - total */ - if ( ! $pview_only ) { - // Start compute - $r.=''; - } - return $r; - - -} - -/*! - ************************************************** - * \brief Record an buy in the table jrn & - * jrnx - * - * - * \param $p_cn Database connection - * \param $p_array contains all the data - * e_date => e : 01.01.2003 - * nb_item => e : 3 - * e_account0 => e : 6 - * e_account0_amount=>e:1 - * - $p_user userid - * - $p_jrn current folder (journal) - * - * \return - * true on success - */ -function RecordODS($p_cn,$p_array,$p_user,$p_jrn) -{ - - foreach ( $p_array as $v => $e) - { - ${"$v"}=$e; - } - // Get the default period - $periode=$p_user->get_periode(); - $amount=0.0; - // Computing total customer - - $sum_deb=0.0; - $sum_cred=0.0; - $own=new own($p_cn); - // verify first the CA - /// - if ( $own->MY_ANALYTIC != "nu" ) - { - // Check the total only for mandatory - // - if ( $own->MY_ANALYTIC == "ob") { - $tab=0; $row=1; - while (1) { - if ( !isset ($_POST['nb_t'.$tab])) - break; - $tot_tab=0; - for ($i_row=1;$i_row <= MAX_COMPTE;$i_row++) { - if ( ! isset($_POST['val'.$tab.'l'.$i_row])) - break; - $tot_tab+=$_POST['val'.$tab.'l'.$i_row]; - } - if ( $tot_tab != $_POST['amount_t'.$tab]) { - echo '
'; - echo "Erreur dans les CA, les montants ne correspondent pas
"; - echo "ligne".$tab."
";; - echo "Total poste ".$_POST['amount_t'.$tab]."
"; - echo "Total CA encodé = $tot_tab
"; - - echo "Opération annulée"; - echo '
'; - return null; - } - $tot_tab=0; - $tab++; - } - } - } - - // Compute the j_grpt - $seq=NextSequence($p_cn,'s_grpt'); - // Set Internal code and Comment - $oJrn=new Acc_Ledger($p_cn,$p_jrn); - $internal=$oJrn->compute_internal_code($seq); - - try - { - StartSql($p_cn); - $group=NextSequence($p_cn,"s_oa_group"); - $count=0; - // store into the database - for ( $i = 0; $i < $nb_item;$i++) { - if ( isNumber(${"e_account$i"}) == 0 ) continue; - $sum_deb+=(${"e_account$i"."_type"}=='d')?round(${"e_account$i"."_amount"},2):0; - $sum_cred+=(${"e_account$i"."_type"}=='c')?round(${"e_account$i"."_amount"},2):0; - - if ( ${"e_account$i"."_amount"} == 0 ) continue; - ${"e_account$i"."_amount"}=round(${"e_account$i"."_amount"},2); - $j_id=InsertJrnx($p_cn,${"e_account$i"."_type"},$p_user->id,$p_jrn,${"e_account$i"},$e_date,${"e_account$i"."_amount"},$seq,$periode); - if ( ereg("^7+",${"e_account$i"}) || - ereg("^6+",${"e_account$i"})) - { - - // insert into ca - if ( $own->MY_ANALYTIC != "nu" ) - { - // for each item, insert into operation_analytique */ - $op=new Anc_Operation($p_cn); - $op->oa_group=$group; - $op->j_id=$j_id; - $op->oa_date=$e_date; - $op->oa_debit=($op->oa_amount < 0 )?'t':'f'; - $op->oa_description=$e_comm; - $op->save_form_plan($_POST,$count); - $count++; - } - } - - - } - InsertJrn($p_cn,$e_date,"",$p_jrn,$e_comm,$seq,$periode) ; - - // Set Internal code and Comment - // Set Internal code and Comment - $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". - " jr_grpt_id = ".$seq); - - if ( $e_comm=="" ) { - // Update comment if comment is blank - $Res=ExecSql($p_cn,"update jrn set jr_comment='".$internal."' where jr_grpt_id=".$seq); - } - if ( isset ($_FILES)) - save_upload_document($p_cn,$seq); - // Save the operation - if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ - echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); - $opd=new Pre_op_ods($p_cn); - $opd->get_post(); - $opd->save(); - echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd); - } - - } - catch (Exception $e) - { - echo ''. - 'Erreur dans l\'enregistrement '. - __FILE__.':'.__LINE__.' '. - $e->getMessage(); - Rollback($p_cn); - exit(); - } - Commit($p_cn); - return $internal; -} - - -?> diff --git a/include/user_form_ven.php b/include/user_form_ven.php index ac1454627..a2e5dec29 100644 --- a/include/user_form_ven.php +++ b/include/user_form_ven.php @@ -414,7 +414,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } - // Periode ferm� + // Periode ferm� $per=new Periode($p_cn); $per->set_jrn($p_jrn); $per->set_periode($p_periode); diff --git a/include/user_menu.php b/include/user_menu.php index 538badfe9..1716b3de5 100644 --- a/include/user_menu.php +++ b/include/user_menu.php @@ -37,23 +37,13 @@ require_once ('class_widget.php'); * \return table in HTML * */ -function u_ShowDossier($p_user,$p_admin) +function u_ShowDossier($p_user,$p_admin,$p_filtre="") { - $p_array=GetAvailableFolder($p_user,$p_admin); + $p_array=GetAvailableFolder($p_user,$p_admin,$p_filtre); $result=""; - $result.=""; - $result.=''; - if ( $p_admin == 1 ) { - $result.=""; - } - $result.=''; - $result.=''; - $result.=''; - $result.=""; - $result.="
Administration Aide Préférence Sortir
"; if ( $p_array == 0 ) return $result." * Aucun dossier *"; - $result.=""; + $result.="
"; for ($i=0;$i"; + + $result.=""; - $result.=""; - $result.=""; - $result.=""; - - $result.=""; - -/* $result.=""; */ - $result.=""; + } $result.="
"; + $result.="
"; + $result.=""; $result.=$id." $name"; - $result.=""; - $result.=$desc; - $result.=""; - $result.="Comptabilité"; + $result.=""; $result.=""; - $result.="Gestion"; + $desc=($desc=="")?"Aucune description":$desc; + $desc="".$desc.""; + $result.="".$desc; $result.=""; - $result.="Analytique"; - $result.=""; - $result.="Budget"; - $result.=""; - $result.="Paramètres"; - $result.=""; */ -/* $result.="Caisse Enregistreuse"; */ -/* $result.="
"; return $result; @@ -104,7 +82,7 @@ function u_ShowDossier($p_user,$p_admin) * - ac_dossier.dos_description * */ -function GetAvailableFolder($p_user,$p_admin) +function GetAvailableFolder($p_user,$p_admin,$p_filter="") { $filter=""; if ($p_admin==0) { @@ -116,16 +94,16 @@ function GetAvailableFolder($p_user,$p_admin) join priv_user on ( priv_jnt=jnt_id) where use_active=1 and use_login='$p_user' - and priv_priv != 'NO' order by dos_name"; + and priv_priv != 'NO' and dos_name ilike '%$p_filter%' + order by dos_name"; } else { - $sql="select distinct dos_id,dos_name,dos_description from ac_users - natural join jnt_use_dos - natural join ac_dossier - where use_active=1 order by dos_name "; + $sql="select distinct dos_id,dos_name,dos_description from ac_dossier + where dos_name ilike '%$p_filter%' order by dos_name"; } include_once("postgres.php"); $cn=DbConnect(); + $Res=ExecSql($cn,$sql); $max=pg_numRows($Res); if ( $max == 0 ) return 0; @@ -140,9 +118,8 @@ function GetAvailableFolder($p_user,$p_admin) * and highight the selected one * \param p_high what to hightlight, by default it is autodetected * but sometimes it must be given. Default value="" - * \todo clean param p_dossier * - * \return none + * \return string * */ function ShowMenuCompta($p_high="") @@ -164,36 +141,57 @@ function ShowMenuCompta($p_high="") } if ( $p_high !== "" ) $default=$p_high; - echo_debug('user_menu.php',__LINE__,'defaut is '.$default); if ( isset($_REQUEST['p_action'])) { - if ( $_REQUEST['p_action']=='impress') - $default=5; - if ( $_REQUEST['p_action']=='fiche') - $default=6; - if ( $_REQUEST['p_action']=='quick_writing') - $default=4; + switch ($_REQUEST['p_action'] ) { + case 'impress': + $default=5; + break; + case 'fiche': + $default=6; + break; + case 'quick_writing': + $default=4; + break; + case 'gl': + $default=0; + break; + case 'ven': + $default=1; + break; + case 'client': + $default=1; + break; + case 'ach': + case 'fournisseur': + $default=2; + break; + case 'bank': + $default=3; + break; + } } + echo_debug('user_menu.php',__LINE__,'defaut is '.$default); + $str_dossier=dossier::get(); $p_array=array( - array("user_jrn.php?jrn_type=NONE&".$str_dossier ,"Grand Livre"), - array("user_jrn.php?jrn_type=VEN&".$str_dossier ,"Vente"), - array("user_jrn.php?jrn_type=ACH&".$str_dossier,"Dépense"), - array("user_jrn.php?jrn_type=FIN&".$str_dossier,"Financier"), - array("user_jrn.php?jrn_type=ODS&".$str_dossier,"Op. Diverses"), + array("compta.php?p_action=gl&".$str_dossier ,"Grand Livre","Grand livre : toutes les opérations",0), + array("compta.php?p_action=ven&".$str_dossier ,"Vente","Journal de vente / produit",1), + array("compta.php?p_action=ach&".$str_dossier,"Dépense","Journaux de dépense, d'achat",2 ), + array("compta.php?p_action=bank&".$str_dossier,"Financier","Journaux financiers: les banques, la caisse",3), array('compta.php?p_action=quick_writing&'.$str_dossier,'Ecriture directe','Ecriture directe dans les journaux',4), array("compta.php?p_action=impress&".$str_dossier,"Impression","Impression",5), array("compta.php?p_action=fiche&".$str_dossier,"Fiche","Ajouter, modifier ou effacer des fiches",6), - array("user_advanced.php?".$str_dossier,"Avancé","Opérations délicates",7), + array("user_advanced.php?".$str_dossier,"Avancé","Opérations délicates",7), ); $result=ShowItem($p_array,'H',"mtitle","mtitle",$default,' width="100%"'); $str_dossier=dossier::get(); $r=""; $r.=menu_tool("compta"); - $r.='
'; + $r.='
'; $r.=$result; $r.='
'; // $r.='
'; @@ -246,7 +244,7 @@ function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="") include_once ("debug.php"); include_once("constant.php"); include_once("class_user.php"); - echo_debug('user_menu.php',__LINE__,"U_SHOWMENUJRNUSER PTYPE=$p_type"); + echo ''; include_once("postgres.php"); @@ -264,13 +262,13 @@ function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="") where uj_login='".$User->id."' and uj_priv !='X' - and jrn_def_type='$p_type' order by jrn_Def_id + and jrn_def_type=upper('$p_type') order by jrn_Def_id "); } else { $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line, jrn_type_id,jrn_desc,'W' as uj_priv from jrn_def join jrn_type on jrn_def_type=jrn_type_id where - jrn_def_type='$p_type' order by jrn_Def_id"); + jrn_def_type=upper('$p_type') order by jrn_Def_id"); } $Max=pg_NumRows($Ret); @@ -302,9 +300,9 @@ function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="") $add='&p_action='.$_REQUEST['p_action']; } echo '', + printf ('%s', $href, - $l_line['jrn_def_type'], + $p_type, $l_line['jrn_def_id'], $add, $l_line['jrn_def_name'] @@ -318,7 +316,7 @@ function ShowMenuJrnUser($p_dossier,$p_type,$p_jrn,$p_extra="") if ( $p_extra !="" ) echo $p_extra; echo ''; echo "
'; - printf ('%s
"; - //echo '
'; + } /*! @@ -475,7 +473,7 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) $r.= ''; $r.=' Internal code '; $r.=''; - $r.='vous pouvez spécifier uniquement
une partie (VEN, numéro d\'opération...)
'; + $r.='vous pouvez spécifier uniquement
une partie (VEN, numéro d\'opération...)
'; $r.=""; @@ -483,7 +481,7 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null) $r.= ""; $r.= ""; $W=new widget("js_search_poste"); - $W->label="Numéro de poste
Vous pouvez utilisez le %"; + $W->label="Numéro de poste
Vous pouvez utilisez le %"; $W->name="poste"; $W->value=$p_poste; $r.="".$W->IOValue(); @@ -543,9 +541,9 @@ function ShowMenuAdvanced($default="") { array('user_advanced.php?p_action=central&'.$str_dossier,'Centralise',"Centralisation",3), array('compta.php?p_action=stock&'.$str_dossier,'Stock',"Gestion des stocks",5), - array('form.php?'.$str_dossier,'Rapport',"Rapport",6), + array('user_advanced.php?p_action=defreport&'.$str_dossier,'Rapport',"Rapport",6), array('import.php?'.$str_dossier,'Import Banque',"Banque",7), - array('ecrit_ouv.php?'.$str_dossier,'Ecriture ouverture',"",8), + array('user_advanced.php?p_action=ouv&'.$str_dossier,'Ecriture ouverture',"",8), array('user_advanced.php?p_action=verif&'.$str_dossier,'Vérification',"",10) ), 'H',"mtitle","mtitle",$default); @@ -565,8 +563,8 @@ function ShowJrn($p_menu="") $p_array=array( array("user_jrn.php?jrn_type=NONE" ,"Grand Livre"), - array("user_jrn.php?jrn_type=VEN" ,"Entrée"), - array("user_jrn.php?jrn_type=ACH","Dépense"), + array("user_jrn.php?jrn_type=VEN" ,"Entrée"), + array("user_jrn.php?jrn_type=ACH","Dépense"), array("user_jrn.php?jrn_type=FIN","Financier"), array("user_jrn.php?jrn_type=ODS","Op. Diverses") ); @@ -639,11 +637,15 @@ function MenuAdmin() case 'modele_mgt': $def=2; break; + case 'restore'; + $def=3; + break; } } $item=array (array("admin_repo.php?action=user_mgt","Utilisateurs",'Gestion des utilisateurs',0), - array("admin_repo.php?action=dossier_mgt","Dossiers",'Gestion des dossiers',1), - array("admin_repo.php?action=modele_mgt","Modèles",'Gestion des modèles',2), + array("admin_repo.php?action=dossier_mgt","Dossiers",'Gestion des dossiers',1), + array("admin_repo.php?action=modele_mgt","Modèles",'Gestion des modèles',2), + array("admin_repo.php?action=restore","Restore","Restaure une base de données",3), array("login.php","Accueil"), array("logout.php","Logout") ); @@ -681,18 +683,21 @@ function ShowMenuDocument() */ function ShowMenuParam($p_action="") { - $s=dossier::get(); + // The phpsessid is set manually to avoid problem when the server is + // misconfigured and the cookies are not sent (or accepted) + $s=dossier::get().'&PHPSESSID='.$_REQUEST['PHPSESSID']; $sub_menu=ShowItem(array( - array('parametre.php?p_action=company&'.$s,'Sociétés','Parametre societe',1), + array('parametre.php?p_action=company&'.$s,'Sociétés','Parametre societe',1), array('parametre.php?p_action=devise&'.$s,'Devises','Devise',2), array('parametre.php?p_action=tva&'.$s,'Tva','Taux & poste pour la TVA',3), array('parametre.php?p_action=poste&'.$s,'Poste Comptable','Poste comptable constant',4), array('parametre.php?p_action=pcmn&'.$s,'Plan Comptable','Modification du plan comptable',11), array('parametre.php?p_action=fiche&'.$s,'Fiche','Modifie les classe de base',5), - array('parametre.php?p_action=sec&'.$s,'Sécurité','securite',8), + array('parametre.php?p_action=sec&'.$s,'Sécurité','securite',8), + array('parametre.php?p_action=preod&'.$s,'Ecritures définies','Ecritures définies ',12), array('parametre.php?p_action=document&'.$s,'Document','Facture, lettre de rappel, proposition...',7), - array('parametre.php?p_action=jrn&'.$s,'Journaux','Creation et modification de journaux',10) + array('parametre.php?p_action=jrn&'.$s,'Journaux','Creation et modification de journaux',10) ), 'H',"mtitle","mtitle",$p_action,' width="100%"'); @@ -715,7 +720,7 @@ function MenuJrn() { $str_dossier=dossier::get(); echo '
'; - echo ''; + echo ''; include_once("postgres.php"); $Cn=DbConnect(dossier::id()); $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name, @@ -747,7 +752,7 @@ function ShowMenuPcmn($p_start=1) { $str_dossier="&".dossier::get(); echo '
Création
Création
'; - echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -758,35 +763,7 @@ function ShowMenuPcmn($p_start=1) echo ''; echo "
1 Immobilisé
1 Immobilisé
2 Actif a un an au plus
3 Stock et commande
4 Compte tiers
9 Hors Comptabilité
"; } -/*! - * \brief Show the left menu for the report (add a report, view it) - * - * \param $p_dossier dossier id - * - * - * - * \return nothing - * - * - */ -function ShowMenuComptaForm() { - $cn=DbConnect(dossier::id()); - $str_dossier=dossier::get(); - echo ''; -} /*! * \brief Show the menu for importing, verify and transfert Bank CSV @@ -837,13 +814,15 @@ $r.='