Future version 3.0, added CA
This commit is contained in:
parent
26c466804d
commit
e1522f93bb
88 changed files with 5474 additions and 1669 deletions
|
|
@ -14,11 +14,11 @@ site savannah
|
|||
<!-- Table of contents -->
|
||||
<toc>
|
||||
<sect>Avertissement
|
||||
<p> Si vous installez sur Linux, l'installation d'apache, postgres et php peut se
|
||||
<p> 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 à ceux
|
||||
préfèrant le faire manuellement. En général vous pourrez l'installer assez facilement
|
||||
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
|
||||
<url url= "http://www.phpcompta.org/pmwiki.php/Documentation/InstallationRapide" name="Installation Rapide">
|
||||
Il existe aussi un manuel d'installation exhaustif pour Debian, pleins d'informations utiles
|
||||
<url url="http://www.blanchin.eu/?p=12" Name="Manuel pour Debian">.
|
||||
|
|
@ -32,6 +32,7 @@ Il est pr
|
|||
|
||||
<p> Cependant, les configurations des différents produits sont importantes
|
||||
et devraient être lues avant d'appeler à l'aide.
|
||||
|
||||
</sect>
|
||||
|
||||
<sect>Postgresql (version 8.0.1 minimum)
|
||||
|
|
@ -106,7 +107,7 @@ Run-time Configuration.
|
|||
|
||||
<p> Les paramètres que vous pouvez utiliser si vous avez une machine d'au moins 256 Mb:
|
||||
<itemize>
|
||||
<item> Augmenter la zone mémoire pour les tri (dans postgres.conf) sort_mem = 8192; cette
|
||||
<item> 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 !
|
||||
</item>
|
||||
|
|
@ -289,7 +290,6 @@ On suppose que postgresql est install
|
|||
<item> Se connecter en tant que postgres et taper les commandes
|
||||
<verb>
|
||||
createuser -h localhost -d -P postgres phpcompta
|
||||
createdb -h localhost -O phpcompta phpcompta
|
||||
</verb>
|
||||
|
||||
<item>Décompacter le package dans le répertoire de votre choix, et configurer Apache pour qu'il
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,5 +3,7 @@ php_flag magic_quotes_gpc off
|
|||
php_flag session.auto_start on
|
||||
php_value session.save_path /tmp
|
||||
php_value max_execution_time 120
|
||||
# for php 5 php_value upload_tmp_dir /tmp
|
||||
AddDefaultCharset latin1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ function GetVersion($p_cn) {
|
|||
* \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;
|
||||
|
|
@ -144,7 +146,7 @@ function ExecuteScript($p_cn,$script) {
|
|||
$sql.=$buffer;
|
||||
if ( ExecSql($p_cn,$sql,false) == false ) {
|
||||
Rollback($p_cn);
|
||||
if ( DEBUG=='false' ) ob_end_flush();
|
||||
if ( DEBUG=='false' ) ob_clean();
|
||||
print "ERROR : $sql";
|
||||
exit();
|
||||
}
|
||||
|
|
@ -153,6 +155,7 @@ function ExecuteScript($p_cn,$script) {
|
|||
print "<hr>";
|
||||
} // while (feof)
|
||||
fclose($hf);
|
||||
if ( DEBUG=='false' ) ob_clean();
|
||||
}
|
||||
/*! \brief loop to apply all the path to a folder or
|
||||
* a template
|
||||
|
|
@ -162,15 +165,15 @@ function ExecuteScript($p_cn,$script) {
|
|||
*/
|
||||
function apply_patch($p_cn,$p_name)
|
||||
{
|
||||
$MaxVersion=29;
|
||||
$MaxVersion=30;
|
||||
for ( $i = 4;$i <= $MaxVersion;$i++)
|
||||
{
|
||||
if ( DEBUG=='false' ) ob_start();
|
||||
if ( GetVersion($p_cn) <= $i ) {
|
||||
echo "Patching ".$p_name.
|
||||
" from the version $i to the version ".GetVersion($p_cn)." <hr>";
|
||||
|
||||
ExecuteScript($p_cn,'sql/patch/upgrade'.$i.'.sql');
|
||||
if ( DEBUG=='false' ) ob_start();
|
||||
// specific for version 4
|
||||
if ( $i == 4 )
|
||||
{
|
||||
|
|
@ -205,10 +208,29 @@ function apply_patch($p_cn,$p_name)
|
|||
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 ( DEBUG == 'false') ob_end_clean();
|
||||
if ( DEBUG == 'false') ob_clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
|
@ -381,7 +403,7 @@ if ($account == 0 ) {
|
|||
ExecuteScript($cn,"sql/account_repository/constraint.sql");
|
||||
Commit($cn);
|
||||
|
||||
if ( DEBUG=='false') ob_end_clean();
|
||||
if ( DEBUG=='false') ob_clean();
|
||||
|
||||
echo "Creation of Modele1";
|
||||
if ( DEBUG=='false') ob_start();
|
||||
|
|
@ -392,7 +414,7 @@ if ($account == 0 ) {
|
|||
ExecuteScript($cn,'sql/mod1/data.sql');
|
||||
ExecuteScript($cn,'sql/mod1/constraint.sql');
|
||||
Commit($cn);
|
||||
if ( DEBUG=='false') ob_end_clean();
|
||||
if ( DEBUG=='false') ob_clean();
|
||||
|
||||
echo "Creation of Modele2";
|
||||
ExecSql($cn,"create database ".domaine."mod2 encoding='latin1'");
|
||||
|
|
@ -404,7 +426,7 @@ if ($account == 0 ) {
|
|||
ExecuteScript($cn,'sql/mod2/constraint.sql');
|
||||
Commit($cn);
|
||||
|
||||
if ( DEBUG=='false') ob_end_clean();
|
||||
if ( DEBUG=='false') ob_clean();
|
||||
|
||||
}// end if
|
||||
// Add a french accountancy model
|
||||
|
|
@ -467,5 +489,6 @@ for ($e=0;$e < $MaxDossier;$e++) {
|
|||
}
|
||||
}
|
||||
|
||||
if (DEBUG=='false') ob_end_clean();
|
||||
if (DEBUG=='false') ob_clean();
|
||||
echo "<h2 class=\"info\">Voilà tout est installé ;-)</h2>";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -47,9 +47,6 @@ SELECT pg_catalog.setval('users_id', 5, true);
|
|||
-- Data for Name: ac_dossier; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
INSERT INTO ac_dossier (dos_id, dos_name, dos_description, dos_jnt_user) VALUES (1, 'Demo', 'Base de données pour développement & démo', 0);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: ac_users; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
|
@ -58,14 +55,6 @@ INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, u
|
|||
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin) VALUES (1, NULL, NULL, 'phpcompta', 1, 'b1cc88e1907cde80cb2595fa793b3da9', 1);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: jnt_use_dos; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (1, 1, 1);
|
||||
INSERT INTO jnt_use_dos (jnt_id, use_id, dos_id) VALUES (13, 4, 1);
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: modeledef; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
|
|
|||
|
|
@ -1075,8 +1075,8 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_
|
|||
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', 'OD ');
|
||||
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', 'OD ');
|
||||
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');
|
||||
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');
|
||||
|
||||
|
||||
|
|
@ -1084,7 +1084,7 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_
|
|||
-- Data for Name: jrn_def; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
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, 'OD ', '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 (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');
|
||||
|
|
@ -1103,7 +1103,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 ('OD ', 'Opérations Diverses');
|
||||
INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses');
|
||||
|
||||
|
||||
--
|
||||
|
|
|
|||
|
|
@ -709,8 +709,8 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_
|
|||
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', 'OD ');
|
||||
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', 'OD ');
|
||||
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');
|
||||
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');
|
||||
|
||||
|
||||
|
|
@ -718,7 +718,7 @@ INSERT INTO jrn_action (ja_id, ja_name, ja_desc, ja_url, ja_action, ja_lang, ja_
|
|||
-- Data for Name: jrn_def; Type: TABLE DATA; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
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, 'OD ', '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 (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');
|
||||
|
|
@ -737,7 +737,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 ('OD ', 'Opérations Diverses');
|
||||
INSERT INTO jrn_type (jrn_type_id, jrn_desc) VALUES ('ODS', 'Opérations Diverses');
|
||||
|
||||
|
||||
--
|
||||
|
|
|
|||
15
html/admin/sql/patch/upgrade30.sql
Normal file
15
html/admin/sql/patch/upgrade30.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
begin ;
|
||||
alter table jrn_action drop constraint "$1";
|
||||
alter table jrn_def drop constraint "$1";
|
||||
|
||||
update jrn_action set ja_jrn_type='ODS' where ja_jrn_type='OD ';
|
||||
update jrn_def set jrn_def_type='ODS' where jrn_def_type = 'OD ';
|
||||
update jrn_type set jrn_type_id='ODS' where jrn_type_id ='OD ';
|
||||
|
||||
alter table jrn_action add constraint "$1" foreign key (ja_jrn_type) references jrn_type(jrn_type_id);
|
||||
|
||||
alter table jrn_def add constraint "$1" FOREIGN KEY (jrn_def_type) REFERENCES jrn_type(jrn_type_id);
|
||||
update version set val=31;
|
||||
commit;
|
||||
|
||||
commit;
|
||||
|
|
@ -71,6 +71,10 @@ if ( isset ($_POST['annul']) ) {
|
|||
<p>
|
||||
<h2 class="info">Confirmation</h2>
|
||||
<br>
|
||||
<p><span class="error">Attention: l'effacement d'une opération peut rompre la séquence de la numérotation des factures surtout celles générées automatiquement, soyez très prudent quand vous effacez. La pièce jointe sera elle aussi effacée.
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Voulez-vous vraiment annuler cette information soit par une remise à zéro des montants
|
||||
soit par son écriture inverse ?
|
||||
|
|
@ -104,7 +108,7 @@ return;
|
|||
|
||||
// Test if date is valid
|
||||
if ( isDate ($e_op_date) == null ) {
|
||||
$msg='Invalid Date';
|
||||
$msg=' Date non valide';
|
||||
echo "<script> alert('$msg');</script>";
|
||||
// set an incorrect pid to get out from here
|
||||
$p_id=-1;
|
||||
|
|
@ -117,18 +121,23 @@ if ($p_id != -1 ) { // A
|
|||
// Periode fermée
|
||||
if ( PeriodeClosed ($cn,$userPref)=='t' )
|
||||
{
|
||||
$msg="Votre periode par defaut est fermee, changez vos preferences";
|
||||
$msg="Votre periode par defaut est fermee, changez vos préférences";
|
||||
echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
// set an incorrect pid to get out from here
|
||||
$p_id=-1;
|
||||
}
|
||||
|
||||
if ( $p_id != -1 ) { //B
|
||||
// Test whether date of the operation is in a closed periode
|
||||
// get the period_id
|
||||
$period_id=getPeriodeFromDate($cn,$e_op_date);
|
||||
// Check the period_id
|
||||
if ( PeriodeClosed($cn,$period_id) == 't' ){
|
||||
if ( PeriodeClosed($cn,$period_id) == 't' )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// if the operation is in a closed or centralized period
|
||||
// the operation is voided thanks the opposite operation
|
||||
StartSql($cn);
|
||||
|
|
@ -146,49 +155,98 @@ if ($p_id != -1 ) { // A
|
|||
from
|
||||
jrn
|
||||
where jr_grpt_id=".$_POST['p_id'];
|
||||
$Res=ExecSql($cn,$sql);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
// Check return code
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
|
||||
// Make also the change into jrnx
|
||||
$sql= "insert into jrnx (
|
||||
j_date,j_montant,j_poste,j_grpt,
|
||||
j_jrn_def,j_debit,j_text,j_internal,j_tech_user,j_tech_per
|
||||
j_jrn_def,j_debit,j_text,j_internal,j_tech_user,j_tech_per,j_qcode
|
||||
) select now(),j_montant,j_poste,$grp_new,
|
||||
j_jrn_def,not (j_debit),j_text,'$p_internal','".$User->id."',
|
||||
$userPref
|
||||
$userPref,j_qcode
|
||||
from
|
||||
jrnx
|
||||
where j_grpt=".$_POST['p_id'];
|
||||
$Res=ExecSql($cn,$sql);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
// Check return code
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
|
||||
// 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);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
// Check return code
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
|
||||
// Set the record to A (annulate) in quant_sold and quand_purchase
|
||||
|
||||
|
||||
$Res=ExecSql($cn,"update quant_sold set ".
|
||||
" qs_valid='A' where qs_internal='".$l_array['jr_internal']."'",
|
||||
false);
|
||||
|
||||
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);
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Add a "concerned operation to bound these op.together
|
||||
//
|
||||
$Res=InsertRapt($cn,$seq,$l_array['jr_id']);
|
||||
// Check return code
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false ) { throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));}
|
||||
|
||||
|
||||
// the table stock must updated
|
||||
// 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);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
// Check return code
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Rollback($cn);
|
||||
$msg="Désolé mais il n a pas été possible d'annuler ".
|
||||
"cette opération";
|
||||
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
|
||||
echo '<span class="error">'.
|
||||
'Erreur : '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
echo '<p>';
|
||||
echo 'Postez ce message sur '.
|
||||
'<A HREF="http://www.phpcompta.org/pmwiki.php/Forum/Forum">'.
|
||||
'le forum de www.phpcompta.org</A> '.
|
||||
'</p>';
|
||||
$p_id=-1;
|
||||
exit(-1);
|
||||
}
|
||||
Commit($cn);
|
||||
// close the window
|
||||
echo '<h2 class="info"> Opération Annulée</h2>';
|
||||
echo '<h2 class="info"> Opération Annulée</h2>';
|
||||
?>
|
||||
<script>
|
||||
window.close();
|
||||
|
|
@ -200,27 +258,89 @@ self.opener.RefreshMe();
|
|||
// operation is not in a closed period
|
||||
// Check only if a line is valid or not
|
||||
if ( isValid($cn,$p_id) == 1 ) {
|
||||
// Start Sql
|
||||
StartSql($cn);
|
||||
try
|
||||
{
|
||||
// Start Sql
|
||||
StartSql($cn);
|
||||
// Set the record to A (annulate) in quant_sold and quand_purchase
|
||||
// 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);
|
||||
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
// delete from the stock table
|
||||
$sql="delete from stock_goods where sg_id = any ( select sg_id
|
||||
|
||||
|
||||
$Res=ExecSql($cn,"delete from quant_sold ".
|
||||
" where qs_internal='".$l_array['jr_internal']."'",
|
||||
false);
|
||||
|
||||
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);
|
||||
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
if ( $l_array['jr_pj'] != "")
|
||||
{
|
||||
$Res=pg_lo_unlink($cn,$l_array['jr_pj']);
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__.
|
||||
"Echec Effacement lob [ $sql ]"));
|
||||
|
||||
}
|
||||
|
||||
// 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);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
// delete from jrnx & jrn
|
||||
$sql="update jrnx set j_montant = 0 where j_grpt=".$_POST['p_id'];
|
||||
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);
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));
|
||||
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
// build the sql stmt for jrn
|
||||
$sql= "delete from jrn where jr_grpt_id=".$_POST['p_id'];
|
||||
$Res=ExecSql($cn,$sql,false);
|
||||
|
||||
// build the sql stmt for jrn
|
||||
$sql= "update jrn set jr_montant=0,jr_valid='f',jr_comment='Erreur:'||jr_comment where jr_grpt_id=".$_POST['p_id'];
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
if ( $Res == false ) { Rollback($cn);exit(-1);}
|
||||
if ( $Res == false)
|
||||
throw (new Exception(__FILE__.__LINE__." sql a echoue [ $sql ]"));
|
||||
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
Rollback($cn);
|
||||
$msg="Désolé mais il n a pas été possible d'annuler ".
|
||||
"cette opération";
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
|
||||
echo '<span class="error">'.
|
||||
'Erreur : '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
echo '<p>';
|
||||
echo 'Postez ce message sur '.
|
||||
'<A HREF="http://www.phpcompta.org/pmwiki.php/Forum/Forum">'.
|
||||
'le forum de www.phpcompta.org</A> '.
|
||||
'</p>';
|
||||
$p_id=-1;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
Commit($cn);
|
||||
echo '<h2 class="info"> Opération Annulée</h2>';
|
||||
?>
|
||||
|
|
@ -282,7 +402,7 @@ if ( $a != null ) {
|
|||
echo '
|
||||
|
||||
<input type="hidden" name="p_id" value="'.$_GET['jrn_op'].'">
|
||||
<input type="submit" name="annul" value="Mise à zéro">
|
||||
<input type="submit" name="annul" value="Mise à zéro ou effacement">
|
||||
<input type="button" name="cancel" value="Retour" onClick="window.close();">
|
||||
</form>';
|
||||
|
||||
|
|
|
|||
54
html/caisse.php
Normal file
54
html/caisse.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<script language="javascript">
|
||||
function set_code(p_code) {
|
||||
|
||||
for (i=0;i<10;i++) {
|
||||
if ( document.getElementById("id_"+i).value == "") {
|
||||
document.getElementById("id_"+i).value=p_code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
function f_reset(p_code) {
|
||||
document.getElementById("id_"+p_code).value="";
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
/* CSS goes here */
|
||||
body {
|
||||
font-size:14px;
|
||||
font-color:green;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-size: 4px;
|
||||
border-color:blue;
|
||||
border-style: sunken;
|
||||
background: inherit;
|
||||
font: inherit;
|
||||
color: blue;
|
||||
padding: 2px;
|
||||
width:150px;
|
||||
height:60px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<?php
|
||||
echo '<form method="post" action="result.php">';
|
||||
|
||||
for ($i=0;$i<10;$i++)
|
||||
{
|
||||
echo 'montant <input type="TEXT" name="in'.$i.'" id="id_'.$i.'">';
|
||||
echo '<input type="BUTTON" value="Efface" onClick="f_reset('.$i.')">';
|
||||
echo '<BR>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
for ($i=0; $i < 5;$i++)
|
||||
{
|
||||
echo '<INPUT TYPE="BUTTON" class="btn" name="button" value="code '.$i.'" onClick="set_code('.$i.')">';
|
||||
}
|
||||
?>
|
||||
<input type="submit">
|
||||
<input type="reset">
|
||||
</form>
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
include_once ("ac_common.php");
|
||||
require_once("constant.php");
|
||||
include_once ("postgres.php");
|
||||
|
||||
echo JS_AJAX_FICHE;
|
||||
|
||||
if ( isset ($_REQUEST['dos'] ) ) {
|
||||
$_SESSION['g_dossier']=$_REQUEST['dos'];
|
||||
|
|
@ -65,7 +65,7 @@ if ( isset ( $_POST['p_size']) ) {
|
|||
html_page_start($_SESSION['g_theme'],"","richtext.js");
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "You must choose a Dossier ";
|
||||
echo "Vous devez choisir un dossier ";
|
||||
exit -2;
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +77,8 @@ echo '<div align="right" title="Recherche">
|
|||
<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$_SESSION['g_dossier'].');">
|
||||
<A HREF="?p_action=pref" title="Préférence"><IMG SRC="image/preference.png" width="36" border="0" ></A>
|
||||
<A HREF="user_compta.php?dos='.$_SESSION['g_dossier'].'" title="Comptabilité"><IMG SRC="image/compta.png" width="36" border="0" ></A>
|
||||
<A HREF="comptanalytic.php?dos='.$_SESSION['g_dossier'].'" title="CA"><IMG SRC="image/undefined.png" width="36" border="0" ></A>
|
||||
|
||||
<A HREF="parametre.php?dos='.$_SESSION['g_dossier'].'" title="Paramètre"><IMG SRC="image/param.png" width="36" border="0" ></A>
|
||||
<A HREF="login.php" title="Accueil"><IMG src="image/home.png" width="36" title="Accueil" border="0" ></A>
|
||||
<A HREF="logout.php" title="Sortie"><IMG src="image/logout.png" title="Logout" width="36" border="0"></A>
|
||||
|
|
@ -107,6 +109,8 @@ echo '</div>';
|
|||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
$User->AccessRequest($cn,SEC_GESTION);
|
||||
echo JS_VIEW_JRN_MODIFY;
|
||||
echo JS_AJAX_FICHE;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// p_action == pref
|
||||
//-----------------------------------------------------
|
||||
|
|
@ -138,7 +142,6 @@ if ( $p_action == 'suivi_courrier')
|
|||
//-----------------------------------------------------
|
||||
if ( $p_action == "facture" )
|
||||
{
|
||||
echo JS_AJAX_FICHE;
|
||||
require_once("facture.inc.php");
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
|
|
@ -151,7 +154,6 @@ if ( $p_action == 'contact')
|
|||
// Expense
|
||||
if ( $p_action == 'depense')
|
||||
{
|
||||
echo JS_AJAX_FICHE;
|
||||
require_once("depense.inc.php");
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
|
|
@ -164,7 +166,6 @@ if ( $p_action == 'admin')
|
|||
// Banque
|
||||
if ( $p_action == 'bank')
|
||||
{
|
||||
echo JS_AJAX_FICHE;
|
||||
require_once("bank.inc.php");
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
|
|
|
|||
114
html/comptanalytic.php
Normal file
114
html/comptanalytic.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief Analytic accountancy
|
||||
*
|
||||
*/
|
||||
require_once("constant.php");
|
||||
require_once("postgres.php");
|
||||
require_once("ac_common.php");
|
||||
|
||||
if ( isset ($_GET['dos']) )
|
||||
$_SESSION['g_dossier']=$_GET['dos'];
|
||||
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
echo "Vous devez choisir un dossier ";
|
||||
exit -2;
|
||||
}
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
require_once ("class_user.php");
|
||||
$User=new cl_user($cn);
|
||||
$User->Check();
|
||||
|
||||
|
||||
|
||||
$g_name=GetDossierName($_SESSION['g_dossier']);
|
||||
$_SESSION["g_name"]=$g_name;
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//Header
|
||||
echo '<div class="u_tmenu">';
|
||||
echo "<H2 class=\"info\">Analytique ".$_SESSION['g_name']." ";
|
||||
echo '<div align="right" title="Recherche">
|
||||
<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$_SESSION['g_dossier'].');">
|
||||
<A HREF="?p_action=pref" title="Préférence"><IMG SRC="image/preference.png" width="36" border="0" ></A>
|
||||
<A HREF="user_compta.php?dos='.$_SESSION['g_dossier'].'" title="Comptabilité"><IMG SRC="image/compta.png" width="36" border="0" ></A>
|
||||
<A HREF="parametre.php?dos='.$_SESSION['g_dossier'].'" title="Paramètre"><IMG SRC="image/param.png" width="36" border="0" ></A>
|
||||
<A HREF="login.php" title="Accueil"><IMG src="image/home.png" width="36" title="Accueil" border="0" ></A>
|
||||
<A HREF="logout.php" title="Sortie"><IMG src="image/logout.png" title="Logout" width="36" border="0"></A>
|
||||
</div> </h2>';
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
$def=-1;
|
||||
if ( isset ($_REQUEST['p_action']))
|
||||
{
|
||||
switch ($_REQUEST['p_action'])
|
||||
{
|
||||
case 'ca_pa':
|
||||
$def=0;
|
||||
break;
|
||||
case 'ca_od':
|
||||
$def=1;
|
||||
break;
|
||||
case 'ca_imp':
|
||||
$def=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo ShowItem(array(
|
||||
array('?p_action=ca_pa','Plan Analytique',"Plan Analytique",0),
|
||||
array('?p_action=ca_od','Opérations Diverses',"Permet d'enregistrer des opérations sur la compta analytique",1),
|
||||
array('?p_action=ca_imp','Impression',"impression de rapport",2)
|
||||
),
|
||||
'H',"mtitle","mtitle",$def,' width="100%"');
|
||||
echo '</div>';
|
||||
|
||||
if ( !isset($_REQUEST['p_action']))
|
||||
exit();
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// p_action
|
||||
//---------------------------------------------------------------------------
|
||||
// Plan Analytique
|
||||
if ($_REQUEST['p_action'] == 'ca_pa' )
|
||||
{
|
||||
require_once('ca_pa.inc.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Operations Diverses
|
||||
if ($_REQUEST['p_action'] == 'ca_od' )
|
||||
{
|
||||
require_once('ca_od.inc.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
// Impression
|
||||
if ($_REQUEST['p_action'] == 'ca_imp' )
|
||||
{
|
||||
require_once('ca_imp.inc.php');
|
||||
exit();
|
||||
}
|
||||
|
|
@ -76,7 +76,8 @@ if ( isset ($_GET['export'])) {
|
|||
echo "</form>";
|
||||
exit(0);
|
||||
}
|
||||
//----------------------------------------------------- IMPORT ////////////////////////////////////////////
|
||||
//----------------------------------------------------- IMPORT
|
||||
////////////////////////////////////////////
|
||||
if ( isset ($_GET['import'])) {
|
||||
// show a form to upload the file
|
||||
// that form will parse the file, create an ods operation
|
||||
|
|
@ -87,7 +88,7 @@ if ( isset ($_GET['import'])) {
|
|||
<FORM NAME="form_detail" enctype="multipart/form-data" ACTION="ecrit_ouv.php?import" METHOD="POST">
|
||||
<?php
|
||||
// TODO propose ODS ledger
|
||||
$ods=make_array($cn,"select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type = 'OD'");
|
||||
$ods=make_array($cn,"select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type = 'ODS'");
|
||||
$x=new widget("select");
|
||||
$x->name='p_jrn';
|
||||
$x->value=$ods;
|
||||
|
|
|
|||
55
html/fid.php
55
html/fid.php
|
|
@ -1,28 +1,61 @@
|
|||
<?
|
||||
header("Content-type: text/xml charset=\"ISO8859-1\"",true);
|
||||
|
||||
include ("constant.php");
|
||||
include ("postgres.php");
|
||||
include("user_common.php");
|
||||
include("debug.php");
|
||||
|
||||
echo_debug('fid.php',__LINE__,"Recherche fid.php".$_GET["FID"]);
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1)
|
||||
{
|
||||
$deb_cred=($_GET['d']=='cred')?"jrn_def_fiche_cred":"jrn_def_fiche_deb";
|
||||
$d=$_GET['d'];
|
||||
$jrn=$_GET['j'];
|
||||
$filter_jrn=Getdbvalue($cn,"select $deb_cred from jrn_def where jrn_def_id=$jrn");
|
||||
|
||||
switch ($d) {
|
||||
case 'cred':
|
||||
$filter_jrn=Getdbvalue($cn,"select jrn_def_fiche_cred from jrn_def where jrn_def_id=$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_card="and fd_id in ($filter_jrn)";
|
||||
break;
|
||||
case 'all':
|
||||
$filter_card="";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$array=GetArray($cn,"select vw_name,vw_addr,vw_cp,vw_buy,vw_sell,tva_id
|
||||
from vw_fiche_attr
|
||||
where quick_code=upper('".$_GET['FID']."') and fd_id in ($filter_jrn)"
|
||||
where quick_code=upper('".$_GET['FID']."') $filter_card"
|
||||
);
|
||||
echo_debug("fid",__LINE__,$array);
|
||||
$name=$array[0]['vw_name']." ".$array[0]['vw_addr']." ".$array[0]['vw_cp'];
|
||||
$sell=$array[0]['vw_sell'];
|
||||
$buy=$array[0]['vw_buy'];
|
||||
$tva_id=$array[0]['tva_id'];
|
||||
$a=( $array != null)?"$name/$sell/$buy/$tva_id":"";
|
||||
echo_debug("fid",__LINE__,$array);
|
||||
$name=$array[0]['vw_name']." ".$array[0]['vw_addr']." ".$array[0]['vw_cp'];
|
||||
$sell=$array[0]['vw_sell'] ;
|
||||
$buy=$array[0]['vw_buy'];
|
||||
$tva_id=$array[0]['tva_id'];
|
||||
|
||||
// Check null
|
||||
$name=($name==null)?" ":$name;
|
||||
$sell=($sell==null)?" ":$sell;
|
||||
$buy=($buy==null)?" ":$buy;
|
||||
$tva_id=($tva_id==null)?" ":$tva_id;
|
||||
|
||||
$a='<?xml version="1.0" encoding="iso8859-1" standalone="yes"?>';
|
||||
$a.="<data>";
|
||||
$a.="<name>".$name."</name>";
|
||||
$a.="<sell>".$sell."</sell>";
|
||||
$a.="<buy>".$buy."</buy>";
|
||||
$a.="<tva_id>".$tva_id."</tva_id>";
|
||||
$a.="</data>";
|
||||
|
||||
}
|
||||
else
|
||||
$a="not connected";
|
||||
echo_debug("fid.php",__LINE__,"Answer is $a");
|
||||
echo_debug("fid.php",__LINE__,"Answer is \n $a");
|
||||
|
||||
print $a;
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
BIN
html/image/undefined.png
Normal file
BIN
html/image/undefined.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
|
|
@ -55,7 +55,7 @@ $cn=DbConnect($_SESSION['g_dossier']);
|
|||
echo ShowMenuAdvanced("import.php");
|
||||
$User->AccessRequest($cn,IMP_BQE);
|
||||
|
||||
|
||||
echo JS_AJAX_FICHE;
|
||||
echo '<div class="lmenu">';
|
||||
ShowMenuImport();
|
||||
echo '</div>';
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ BODY {
|
|||
<script src="js/scripts.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<BODY onLoad="SetFocus(\'login\',0)">
|
||||
Version 2.3.3-cvs
|
||||
Version 3.0.0
|
||||
<div class="remark">
|
||||
<p class="gras">Il est conseillé de ne PAS utiliser Internet Explorer.
|
||||
</p><p>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ if ( $User->CheckAction($cn,IMP) == 0 ||
|
|||
$Jrn=new jrn($cn,$_GET['jrn_id']);
|
||||
|
||||
$Jrn->GetName();
|
||||
$jrn_type=$Jrn->GetType();
|
||||
$jrn_type=$Jrn->get_type();
|
||||
// Detailled printing
|
||||
//---
|
||||
if ( $_GET['p_simple'] == 0 )
|
||||
|
|
@ -66,8 +66,9 @@ if ( $_GET['p_simple'] == 0 )
|
|||
$desc=str_replace("<i>","",$desc);
|
||||
$desc=str_replace("</i>","",$desc);
|
||||
$desc=str_replace('"',"'",$desc);
|
||||
$desc=str_replace(";",",",$desc);
|
||||
|
||||
printf("\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t\"%s\"\t%8.4f\t%8.4f\n",
|
||||
printf("\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";%8.4f;%8.4f\n",
|
||||
$op['j_id'],
|
||||
$op['internal'],
|
||||
$op['j_date'],
|
||||
|
|
@ -89,11 +90,11 @@ if ( $_GET['p_simple'] == 0 )
|
|||
//-----------------------------------------------------
|
||||
if ( $jrn_type == 'ODS' || $jrn_type == 'FIN' || $jrn_type=='GL')
|
||||
{
|
||||
printf ('" operation; "'.
|
||||
'"Date;"'.
|
||||
'"commentaire;"'.
|
||||
'"internal;"'.
|
||||
'"montant;"'.
|
||||
printf ('" operation";'.
|
||||
'"Date";'.
|
||||
'"commentaire";'.
|
||||
'"internal";'.
|
||||
'"montant";'.
|
||||
"\r\n");
|
||||
|
||||
foreach ($Row as $line)
|
||||
|
|
|
|||
|
|
@ -65,13 +65,13 @@ $ret="";
|
|||
|
||||
// filter : 0 for Grand Livre otherwise 1
|
||||
$filter=( $Jrn->id == 0)?0:1;
|
||||
$jrn_type=$Jrn->GetType();
|
||||
$jrn_type=$Jrn->get_type();
|
||||
echo_debug('jrn_pdf',__LINE__,'Jrn type '.$jrn_type);
|
||||
echo_debug('jrn_pdf',__LINE__,'p_simple = '.$_REQUEST['p_simple']);
|
||||
//----------------------------------------------------------------------
|
||||
// Detailled Printing
|
||||
//---------------------------------------------------------------------
|
||||
if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='OD ' || $_REQUEST['p_simple']== 0 )
|
||||
if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='ODS' || $_REQUEST['p_simple']== 0 )
|
||||
{
|
||||
$pdf=& new Cezpdf("A4");
|
||||
$pdf->selectFont('./addon/fonts/Helvetica.afm');
|
||||
|
|
|
|||
|
|
@ -93,10 +93,14 @@ if ( isset ($_GET["search"]) ) {
|
|||
$part=" and ";
|
||||
|
||||
}
|
||||
|
||||
$condition=$c_comment.$c_montant.$c_date.$c_internal;
|
||||
echo_debug('jrn_search.php',__LINE__,"condition = $condition");
|
||||
}
|
||||
$c_paid="";
|
||||
if (isset($paid)) {
|
||||
$c_paid=$part." (jr_rapt != 'paid' or jr_rapt is null) ";
|
||||
$part=" and ";
|
||||
}
|
||||
$condition=$c_comment.$c_montant.$c_date.$c_internal.$c_paid;
|
||||
echo_debug('jrn_search.php',__LINE__,"condition = $condition");
|
||||
}
|
||||
$condition=$condition." ".$part;
|
||||
|
||||
// If the usr is admin he has all right
|
||||
|
|
@ -109,6 +113,11 @@ if ( $User->admin != 1 ) {
|
|||
<div style="font-size:11px;">
|
||||
<?php
|
||||
echo '<FORM ACTION="jrn_search.php" METHOD="GET">';
|
||||
if (isset($paid))
|
||||
echo '<div class="info"> Uniquement les non opérations non payées<input type="hidden" name="paid" value="paid"></div>';
|
||||
else
|
||||
echo '<div class="info"> Toutes les opérations </div>';
|
||||
|
||||
echo '<TABLE>';
|
||||
echo '<TR>';
|
||||
if ( ! isset ($p_date)) $p_date="";
|
||||
|
|
@ -141,7 +150,7 @@ echo '<div class="u_content">';
|
|||
// 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,
|
||||
j_montant,j_poste,j_debit,j_tech_per,jr_id,jr_comment,j_grpt,pcm_lib,jr_internal from jrnx inner join
|
||||
j_montant,j_poste,j_debit,j_tech_per,jr_id,jr_comment,j_grpt,pcm_lib,jr_internal,jr_rapt from jrnx inner join
|
||||
jrn on jr_grpt_id=j_grpt inner join tmp_pcmn on j_poste=pcm_val ".
|
||||
" inner join user_sec_jrn on uj_jrn_id=j_jrn_def".
|
||||
$condition." order by jr_date,jr_id,j_debit desc";
|
||||
|
|
@ -194,7 +203,12 @@ if ( isset ($_GET["search"]) ) {
|
|||
echo $l_line['jr_internal'];
|
||||
echo "</TD>";
|
||||
$l_id=$l_line['j_grpt'];
|
||||
echo '<TD COLSPAN="4">'.$l_line['jr_comment'].'</TD></TR>';
|
||||
if ( $l_line['jr_rapt'] == 'paid')
|
||||
$lpay=" (Payé) ";
|
||||
else
|
||||
$lpay="";
|
||||
|
||||
echo '<TD COLSPAN="4">'.$l_line['jr_comment'].$lpay.'</TD></TR>';
|
||||
}
|
||||
if ( $l_line['j_debit'] == 't' ) {
|
||||
echo '<TR style="background-color:#E7FBFF;">';
|
||||
|
|
|
|||
|
|
@ -24,6 +24,42 @@
|
|||
* info from fiche
|
||||
*
|
||||
*/
|
||||
|
||||
/*!\brief this function fills the data from fid.php,
|
||||
* \param p_ctl the ctrl to fill
|
||||
* \param p_deb if debit of credit
|
||||
* \param p_jrn the ledger
|
||||
*/
|
||||
function trim(s) {
|
||||
return s.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||
}
|
||||
/*!\brief clean the row (the label, price and vat)
|
||||
* \param p_ctl the calling ctrl
|
||||
*/
|
||||
function clean_Fid(p_ctl)
|
||||
{
|
||||
nSell=p_ctl+"_sell";
|
||||
nBuy=p_ctl+"_buy";
|
||||
nTva_id=p_ctl+"_tva_id";
|
||||
|
||||
if ( document.getElementById(nSell) != null ) {
|
||||
document.getElementById(nSell).value="";
|
||||
}
|
||||
if ( document.getElementById(nBuy) != null ) {
|
||||
document.getElementById(nBuy).value="";
|
||||
}
|
||||
|
||||
if ( document.getElementById(nTva_id) != null ) {
|
||||
document.getElementById(nTva_id).value="";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!\brief this function fills the data from fid.php,
|
||||
* \param p_ctl the ctrl to fill
|
||||
* \param p_deb if debit of credit
|
||||
* \param p_jrn the ledger
|
||||
*/
|
||||
function ajaxFid(p_ctl,p_deb,p_jrn){
|
||||
var ajaxRequest; // The variable that makes Ajax possible!
|
||||
;
|
||||
|
|
@ -47,49 +83,61 @@ function ajaxFid(p_ctl,p_deb,p_jrn){
|
|||
// Create a function that will receive data sent from the server
|
||||
ajaxRequest.onreadystatechange = function(){
|
||||
if(ajaxRequest.readyState == 4){
|
||||
resp=String(ajaxRequest.responseText);
|
||||
|
||||
a_resp=resp.split("/");
|
||||
if ( ajaxRequest.status == 200 ) {
|
||||
|
||||
xmldoc = ajaxRequest.responseXML.documentElement;
|
||||
data = xmldoc.getElementsByTagName('name');
|
||||
|
||||
label = data[0].firstChild.nodeValue;
|
||||
sell = xmldoc.getElementsByTagName('sell')[0].firstChild.nodeValue;
|
||||
buy = xmldoc.getElementsByTagName('buy')[0].firstChild.nodeValue;
|
||||
tva_id = xmldoc.getElementsByTagName('tva_id')[0].firstChild.nodeValue;
|
||||
|
||||
toSet=p_ctl+"_label";
|
||||
if ( resp.length == 0 )
|
||||
|
||||
if ( trim(label) == "" )
|
||||
{
|
||||
var ctl_toSet=document.getElementById(toSet);
|
||||
ctl_toSet.innerHTML="Fiche inconnue";
|
||||
ctl_toSet.style.color='red';
|
||||
clean_Fid(p_ctl);
|
||||
}
|
||||
else {
|
||||
var ctl_toSet=document.getElementById(toSet);
|
||||
ctl_toSet.style.color='black';
|
||||
ctl_toSet.innerHTML=a_resp[0];
|
||||
ctl_toSet.innerHTML=label;
|
||||
nSell=p_ctl+"_sell";
|
||||
nBuy=p_ctl+"_buy";
|
||||
nTva_id=p_ctl+"_tva_id";
|
||||
|
||||
if ( document.getElementById(nSell) != null ) {
|
||||
|
||||
document.getElementById(nSell).value=a_resp[1];
|
||||
document.getElementById(nSell).value=sell;
|
||||
}
|
||||
if ( document.getElementById(nBuy) != null ) {
|
||||
|
||||
document.getElementById(nBuy).value=a_resp[2];
|
||||
document.getElementById(nBuy).value=buy;
|
||||
}
|
||||
|
||||
if ( document.getElementById(nTva_id) != null ) {
|
||||
|
||||
document.getElementById(nTva_id).value=a_resp[3];
|
||||
document.getElementById(nTva_id).value=tva_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (document.getElementById(p_ctl).value.length == 0 ) {
|
||||
var toSet=p_ctl+"_label";
|
||||
var ctl_toSet=document.getElementById(toSet);
|
||||
ctl_toSet.innerHTML="";
|
||||
// clean other fields
|
||||
clean_Fid(p_ctl);
|
||||
|
||||
} else {
|
||||
queryString="?FID="+document.getElementById(p_ctl).value;
|
||||
queryString=queryString+"&d="+p_deb+"&j="+p_jrn;
|
||||
|
||||
|
||||
ajaxRequest.open("GET", "fid.php"+queryString, true);
|
||||
ajaxRequest.send(null);
|
||||
}
|
||||
|
|
|
|||
74
html/js/compute.js
Normal file
74
html/js/compute.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
function checkTotal() {
|
||||
var ie4=false;
|
||||
if ( document.all ) {
|
||||
ie4=true;
|
||||
}// Ajouter getElementById par document.all[str]
|
||||
var total_deb=0.0;
|
||||
var total_cred=0.0;
|
||||
|
||||
|
||||
var nb_item=document.getElementById('nb_item').value;
|
||||
|
||||
for (var i=0;i <nb_item ;i++) {
|
||||
var doc_amount=document.getElementById("e_account"+i+"_amount");
|
||||
|
||||
var side=document.getElementsByName("e_account"+i+"_type");
|
||||
|
||||
var amount=parseFloat(doc_amount.value);
|
||||
|
||||
if ( isNaN(amount) == true) {
|
||||
amount=0.0;
|
||||
}
|
||||
for (var e=0;e<side.length;e++) {
|
||||
if ( side[e].checked == true) {
|
||||
// alert('checked !!! '+side[e].value);
|
||||
deb=side[e].value;
|
||||
}
|
||||
}
|
||||
if ( deb == 'c' ) {
|
||||
total_cred+=amount;
|
||||
}
|
||||
if ( deb == 'd' ) {
|
||||
total_deb+=amount;
|
||||
}
|
||||
|
||||
// alert("amount ="+i+"="+amount+" cred/deb = "+deb+"total d/b"+total_deb+"/"+total_cred);
|
||||
}
|
||||
|
||||
|
||||
|
||||
r_total_cred=Math.round(total_cred*100)/100;
|
||||
r_total_deb=Math.round(total_deb*100)/100;
|
||||
document.getElementById('totalDeb').innerHTML=r_total_deb;
|
||||
document.getElementById('totalCred').innerHTML=r_total_cred;
|
||||
|
||||
if ( r_total_deb != r_total_cred ) {
|
||||
document.getElementById("totalDiff").style.color="red";
|
||||
document.getElementById("totalDiff").style.fontWeight="bold";
|
||||
document.getElementById("totalDiff").innerHTML="Différence";
|
||||
diff=total_deb-total_cred;
|
||||
diff=Math.round(diff*100)/100;
|
||||
document.getElementById("totalDiff").innerHTML=diff
|
||||
|
||||
} else {
|
||||
document.getElementById("totalDiff").innerHTML="0.0";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
* \param p_ctl ctl name
|
||||
* \param p_montant amount to search (if 0 get it from the e_other_amount
|
||||
*/
|
||||
function SearchJrn(p_sessid,p_ctl,p_montant)
|
||||
function SearchJrn(p_sessid,p_ctl,p_montant,p_paid)
|
||||
{
|
||||
var url='jrn_search.php?p_ctl='+p_ctl+'&PHPSESSID='+p_sessid;
|
||||
var url='jrn_search.php?p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+'&'+p_paid;
|
||||
|
||||
|
||||
if ( p_montant == 0 ) {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,16 @@
|
|||
/*! \file
|
||||
* \brief
|
||||
* open a windows for modifying a operation
|
||||
* \param p_value jrn.jr_id
|
||||
* \param p_sessid PHPSESSID
|
||||
* \param p_jrn ledger number
|
||||
* \param p_vue easy or expert view of the operation
|
||||
*/
|
||||
|
||||
function modifyOperation(p_value,p_sessid,p_jrn)
|
||||
function modifyOperation(p_value,p_sessid,p_jrn,p_vue)
|
||||
{
|
||||
var win=window.open('modify_op.php?action=update&p_jrn='+p_jrn+'&line='+p_value+'&PHPSESSID='+p_sessid,'','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes');
|
||||
var win=window.open('modify_op.php?action=update&p_jrn='+p_jrn+'&line='+p_value+'&PHPSESSID='+p_sessid+'&p_view='+p_vue,'','toolbar=no,width=690,height=410,scrollbars=yes,resizable=yes');
|
||||
win.focus();
|
||||
}
|
||||
function RefreshMe() {
|
||||
window.location.reload();
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ function HandleSubmit(e) {
|
|||
/*
|
||||
* Open the search screen
|
||||
*/
|
||||
function openRecherche(p_sessid,p_dossier) {
|
||||
var w=window.open("recherche.php?p_dossier="+p_dossier+"&PHPSESSID="+p_sessid,'','statusbar=no,scrollbars=yes,toolbar=no');
|
||||
function openRecherche(p_sessid,p_dossier,p_style) {
|
||||
if ( p_style == 'E' ) { p_style="expert";}
|
||||
var w=window.open("recherche.php?p_dossier="+p_dossier+"&PHPSESSID="+p_sessid+'&'+p_style,'','statusbar=no,scrollbars=yes,toolbar=no');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ function showfiche(p_sessid,qcode)
|
|||
*/
|
||||
function SearchCard(p_sessid,type,name,jrn)
|
||||
{
|
||||
var search=document.getElementById(name).value;
|
||||
|
||||
var search=document.getElementById(name).value;
|
||||
var a=window.open('fiche_search.php?first&search&fic_search='+search+'&p_jrn='+jrn+'&PHPSESSID='+p_sessid+'&type='+type+'&name='+name,'item','toolbar=no,width=350,height=450,scrollbars=yes,statusbar=no');
|
||||
}
|
||||
function NewCard(p_sessid,type,name,jrn)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@
|
|||
|
||||
function SearchPoste(p_sessid,p_ctl,p_jrn)
|
||||
{
|
||||
var win=window.open('poste_search.php?p_jrn='+p_jrn+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid,'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes');
|
||||
var comment=document.getElementById(p_ctl).value;
|
||||
|
||||
var win=window.open('poste_search.php?p_jrn='+p_jrn+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+"&p_comment="+comment+"&search",'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes');
|
||||
}
|
||||
function SearchPosteFilter(p_sessid,p_ctl,p_filter,jrn)
|
||||
{
|
||||
|
|
@ -35,16 +37,17 @@ function SearchPosteFilter(p_sessid,p_ctl,p_filter,jrn)
|
|||
function GetIt() {
|
||||
window.close();
|
||||
}
|
||||
function SetItChild(p_ctl,p_value) {
|
||||
self.opener.SetItParent(p_ctl,p_value);
|
||||
function SetItChild(p_ctl,p_value,p_label) {
|
||||
|
||||
self.opener.SetItParent(p_ctl,p_value,p_label);
|
||||
window.close();
|
||||
}
|
||||
function SetItParent(p_ctl,p_value) {
|
||||
function SetItParent(p_ctl,p_value,p_label) {
|
||||
|
||||
var f=document.getElementsByName(p_ctl);
|
||||
for (var h=0; h < f.length; h++) {
|
||||
f[h].value=p_value;
|
||||
}
|
||||
var f=document.getElementById(p_ctl);
|
||||
f.value=p_value;
|
||||
var f1=document.getElementById(p_ctl+"_label");
|
||||
f1.innerHTML=p_label;
|
||||
|
||||
}
|
||||
/* SetValue( p_ctl,p_value )
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/* $Revision*/
|
||||
/*! \file
|
||||
* \brief Update a operation in a popup window : add a document
|
||||
* \brief show a detailled operation in a popup window
|
||||
* Update : add a document , change the comment, the concerned op....
|
||||
*
|
||||
*/
|
||||
include_once ("ac_common.php");
|
||||
include_once ("poste.php");
|
||||
|
|
@ -58,6 +60,7 @@ if ( isset ( $_GET['action'] ) ) {
|
|||
}
|
||||
$_SESSION["p_jrn"]=$p_jrn;
|
||||
|
||||
$p_view=(isset($_REQUEST['p_view']))?$_REQUEST['p_view']:"error";
|
||||
|
||||
if ( isset ( $_POST['action'] ) ) {
|
||||
$action=$_POST['action'];
|
||||
|
|
@ -69,6 +72,25 @@ if ( ! isset ( $action )) {
|
|||
|
||||
// Javascript
|
||||
echo JS_VIEW_JRN_MODIFY;
|
||||
?>
|
||||
<script language="javascript">
|
||||
function show (p_div) {
|
||||
// show the div
|
||||
// hide the div
|
||||
if ( document.getElementById(p_div) ) {
|
||||
var a=document.getElementById(p_div);
|
||||
a.style.display="block";
|
||||
}
|
||||
}
|
||||
function hide (p_div) {
|
||||
// hide the div
|
||||
if ( document.getElementById(p_div) ) {
|
||||
var a=document.getElementById(p_div);
|
||||
a.style.display="none";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
//-----------------------------------------------------
|
||||
if ( $action == 'update' ) {
|
||||
if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn'],true)) < 1 ) {
|
||||
|
|
@ -81,60 +103,136 @@ if ( $action == 'update' ) {
|
|||
echo_debug('modify_op.php',__LINE__," action = update p_id = $p_id");
|
||||
|
||||
echo JS_CONCERNED_OP;
|
||||
$r ='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
|
||||
$r.=UpdateJrn($cn,$p_id);
|
||||
|
||||
$r.='<INPUT TYPE="Hidden" name="action" value="update_record">';
|
||||
$r.="<br>";
|
||||
$r.="<br>";
|
||||
$r.="<br>";
|
||||
$r.='<input type="SUBMIT" name="update_record" value="Enregistre">';
|
||||
$r.=" ";
|
||||
$r.='<input type="button" value="Fermer" onClick="window.close(); self.opener.RefreshMe();">';
|
||||
$r.='</FORM>';
|
||||
|
||||
// echo '<div class="redcontent">';
|
||||
echo $r;
|
||||
// echo '</div>';
|
||||
}
|
||||
echo_debug(__FILE__.":".__LINE__."Selected view is $view");
|
||||
|
||||
|
||||
$view='<h2 class="error">Erreur vue inconnue</h2>';
|
||||
|
||||
// show the detailled operation
|
||||
if ( $p_view == 'S' )
|
||||
$view='<div id="simple">';
|
||||
else
|
||||
$view='<div id="simple" style="display:none">';
|
||||
|
||||
$view.='<h2 class="info">Vue simple</h2>';
|
||||
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
|
||||
$view.=ShowOperationUser($cn,$p_id);
|
||||
$view.='<input type="button" onclick="hide(\'simple\');show(\'expert\');" value="autre vue">';
|
||||
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
|
||||
$view.="<br>";
|
||||
$view.="<br>";
|
||||
$view.="<br>";
|
||||
$view.='<input type="SUBMIT" name="update_record" value="Enregistre">';
|
||||
$view.=" ";
|
||||
$view.='<input type="button" value="Fermer" onClick="window.close(); self.opener.RefreshMe();">';
|
||||
$view.='</FORM>';
|
||||
$view.='</div>';
|
||||
|
||||
if ( $p_view == 'S' )
|
||||
$view.='<div id="expert" style="display:none">';
|
||||
else
|
||||
$view.='<div id="expert" style="display:block">';
|
||||
|
||||
$view.='<h2 class="info">Vue expert</h2>';
|
||||
$view.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
|
||||
$view.=ShowOperationExpert($cn,$p_id);
|
||||
$view.='<input type="button" onclick="hide(\'expert\');show(\'simple\')" value="autre vue">';
|
||||
$view.='<INPUT TYPE="Hidden" name="action" value="update_record">';
|
||||
$view.="<br>";
|
||||
$view.="<br>";
|
||||
$view.="<br>";
|
||||
$view.='<input type="SUBMIT" name="update_record" value="Enregistre">';
|
||||
$view.=" ";
|
||||
$view.='<input type="button" value="Fermer" onClick="window.close(); self.opener.RefreshMe();">';
|
||||
$view.='</div>';
|
||||
|
||||
|
||||
echo $view;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// update the record and upload files
|
||||
//----------------------------------------------------------------------
|
||||
if ( isset($_POST['update_record']) ) {
|
||||
if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn,true)) !=2 ) {
|
||||
NoAccess();
|
||||
exit -1;
|
||||
|
||||
}
|
||||
try {
|
||||
// NO UPDATE except rapt & comment && upload pj
|
||||
StartSql($cn);
|
||||
|
||||
// NO UPDATE except rapt & comment && upload pj
|
||||
StartSql($cn);
|
||||
|
||||
UpdateComment($cn,$_POST['jr_id'],$_POST['comment']);
|
||||
InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']);
|
||||
if ( isset ($_FILES)) {
|
||||
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']);
|
||||
|
||||
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']);
|
||||
if (pg_num_rows($ret) != 0) {
|
||||
$r=pg_fetch_array($ret,0);
|
||||
$old_oid=$r['jr_pj'];
|
||||
if (strlen($old_oid) != 0)
|
||||
{
|
||||
// check if this pj is used somewhere else
|
||||
$c=CountSql($cn,"select * from jrn where jr_pj=".$old_oid);
|
||||
if ( $c == 1 )
|
||||
pg_lo_unlink($cn,$old_oid);
|
||||
}
|
||||
ExecSql($cn,"update jrn set jr_pj=null, jr_pj_name=null, ".
|
||||
UpdateComment($cn,$_POST['jr_id'],$_POST['comment']);
|
||||
InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']);
|
||||
if ( isset ($_FILES)) {
|
||||
echo_debug("modify_op.php",__LINE__, "start upload doc.");
|
||||
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']);
|
||||
|
||||
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']);
|
||||
if (pg_num_rows($ret) != 0) {
|
||||
$r=pg_fetch_array($ret,0);
|
||||
$old_oid=$r['jr_pj'];
|
||||
if (strlen($old_oid) != 0)
|
||||
{
|
||||
// check if this pj is used somewhere else
|
||||
$c=CountSql($cn,"select * from jrn where jr_pj=".$old_oid);
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//-------------------------------------
|
||||
// CA
|
||||
//------------------------------------
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
// for each item, insert into operation_analytique
|
||||
$plan=new PlanAnalytic($cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
foreach ($_POST as $post_name=>$post_value) {
|
||||
$a="plan_".$r_plan['id']."_";
|
||||
$po=sscanf($post_name,$a."%d");
|
||||
echo_debug(__FILE__.":".__LINE__,"post ",$post_name);
|
||||
echo_debug(__FILE__.":".__LINE__,"post ",$post_value);
|
||||
echo_debug(__FILE__.":".__LINE__,"a = ",$a);
|
||||
echo_debug(__FILE__.":".__LINE__,"po = ".var_export($po,true));
|
||||
|
||||
if ( $po[0] != null ) {
|
||||
|
||||
$op=new operation($cn);
|
||||
$op->j_id=$po[0];
|
||||
$op->pa_id=$r_plan['id'];
|
||||
$op->po_id=$post_value;
|
||||
$op->update_from_jrnx($post_value);
|
||||
}
|
||||
} // foreach ($_POST
|
||||
}// foreach ($a_plan
|
||||
|
||||
}// if ( $own->MY_ANALYTIC != "un" )
|
||||
} catch (Exception $e) {
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($cn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Commit($cn);
|
||||
|
||||
|
|
|
|||
|
|
@ -162,10 +162,21 @@ if ( $p_action=='company') {
|
|||
$m->MY_TEL=$p_tel;
|
||||
$m->MY_FAX=$p_fax;
|
||||
$m->MY_PAYS=$p_pays;
|
||||
$m->MY_ANALYTIC=$p_compta;
|
||||
$m->Save();
|
||||
}
|
||||
|
||||
$my=new Own($cn);
|
||||
///// Compta analytic
|
||||
$array=array (
|
||||
array("value"=>"ob",label=>"obligatoire"),
|
||||
array("value"=>"op",label=>"optionnel"),
|
||||
array("value"=>"nu",label=>"non utilisé")
|
||||
);
|
||||
$compta=new widget("select");
|
||||
$compta->table=1;
|
||||
$compta->selected=$my->MY_ANALYTIC;
|
||||
// other parameters
|
||||
$all=new widget("text");
|
||||
$all->table=1;
|
||||
echo '<form method="post" action="?p_action=company">';
|
||||
|
|
@ -179,7 +190,7 @@ if ( $p_action=='company') {
|
|||
echo "<tr>".$all->IOValue("p_Commune",$my->MY_COMMUNE,"Commune")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_pays",$my->MY_PAYS,"Pays")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva")."</tr>";
|
||||
|
||||
echo "<tr>".$compta->IOValue("p_compta",$array,"Utilisation de la compta. analytique")."</tr>";
|
||||
echo "</table>";
|
||||
$submit=new widget("submit");
|
||||
echo $submit->Submit("record_company","Enregistre");
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ foreach ($a_poste as $pos)
|
|||
if ( count($Poste->row ) == 0 )
|
||||
continue;
|
||||
|
||||
echo '"Poste;"'.
|
||||
echo '"Poste";'.
|
||||
"\"Code interne\";".
|
||||
"\"Date\";".
|
||||
"\"Description\";".
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* \brief Search a account in a popup window
|
||||
*/
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['g_theme'],"onLoad='window.focus();'");
|
||||
html_page_start($_SESSION['g_theme'],'onLoad="window.focus();"');
|
||||
include_once ("postgres.php");
|
||||
include_once("jrn.php");
|
||||
/* Admin. Dossier */
|
||||
|
|
@ -44,37 +44,31 @@ $c_class="";
|
|||
|
||||
$condition="";
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
if ( isset($_POST['search']) ) {
|
||||
if ( isset($_GET['search']) ) {
|
||||
$c1=0;
|
||||
foreach( $_POST as $key=>$element){
|
||||
foreach( $_GET as $key=>$element){
|
||||
${"$key"}=$element;
|
||||
}
|
||||
$condition="";
|
||||
if ( strlen(trim($p_comment)) != 0 ) {
|
||||
$c_comment=" where upper(pcm_lib) like upper('%$p_comment%')";
|
||||
$c1=1;
|
||||
$condition=" where (upper(pcm_lib) like upper('%$p_comment%') or ".
|
||||
" pcm_val::text like '$p_comment%') ";
|
||||
}
|
||||
if ( strlen(trim($p_class)) != 0 &&
|
||||
(string) $p_class == (int)(string) $p_class) {
|
||||
if ($c1==1)
|
||||
$clause=" and ";
|
||||
else
|
||||
$clause = " where ";
|
||||
$c_class=sprintf(" %s pcm_val::text like '%s%%'",$clause,$p_class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$condition=$c_comment.$c_class;
|
||||
}
|
||||
$url="";
|
||||
// Filter ???
|
||||
if ( isset($_GET['filter'])) {
|
||||
|
||||
//--------------------------------------------------
|
||||
// Filter defined in the ledger's parameter
|
||||
//
|
||||
if ( isset($_GET['filter']) && $_GET['filter'] != 'all') {
|
||||
$url="?filter=1";
|
||||
// There is a filter, the value of the filter is the journal id, we
|
||||
// have to find what account are available
|
||||
$SqlCred="";
|
||||
|
||||
// Load the property
|
||||
$l_line=GetJrnProp($cn,$_GET['p_jrn']);
|
||||
$l_line=GetJrnProp($_SESSION['g_dossier'],$_GET['p_jrn']);
|
||||
if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) {
|
||||
$valid_cred=split(" ",$l_line['jrn_def_class_cred']);
|
||||
|
||||
|
|
@ -117,29 +111,29 @@ if ( isset($_GET['filter'])) {
|
|||
$condition .= ($SqlCred=="")?"":" and ( ".substr($SqlCred,0,strlen($SqlCred)-2)." ) ";
|
||||
}
|
||||
}// if (isset($_GET['filter']))
|
||||
|
||||
|
||||
// Control to update in the calling doc.
|
||||
if ( isset($_GET['p_ctl'])) {
|
||||
$p_ctl=$_GET['p_ctl'];
|
||||
}
|
||||
if ( isset($_POST['p_ctl'])) {
|
||||
$p_ctl=$_POST['p_ctl'];
|
||||
}
|
||||
|
||||
|
||||
echo_debug('poste_search.php',__LINE__,"condition = $condition");
|
||||
|
||||
echo '<FORM ACTION="poste_search.php'.$url.'" METHOD="POST">';
|
||||
echo '<FORM ACTION="poste_search.php'.$url.'" METHOD="GET">';
|
||||
if ( isset($p_ctl) ) {
|
||||
if ($p_ctl != 'not') echo '<INPUT TYPE="hidden" name="p_ctl" value="'.$p_ctl.'">';
|
||||
}
|
||||
echo '<TABLE>';
|
||||
echo '<TR>';
|
||||
|
||||
echo '<TD>Poste Comptable Commence par </TD>';
|
||||
/* echo '<TD>Poste Comptable Commence par </TD>'; */
|
||||
/* if ( ! isset ($p_class) ) $p_class=""; */
|
||||
/* $opt=" <INPUT TYPE=\"text\" value=\"$p_class\" name=\"st_with\">"; */
|
||||
/* echo '<TD> <INPUT TYPE="text" name="p_class" VALUE="'.$p_class.'"></TD>'; */
|
||||
|
||||
if ( ! isset ($p_class) ) $p_class="";
|
||||
$opt=" <INPUT TYPE=\"text\" value=\"$p_class\" name=\"st_with\">";
|
||||
echo '<TD> <INPUT TYPE="text" name="p_class" VALUE="'.$p_class.'"></TD>';
|
||||
|
||||
echo '<TD> Libellé </TD>';
|
||||
echo '<TD> Libellé ou poste comptable</TD>';
|
||||
echo '<TD> contient </TD>';
|
||||
if ( ! isset ($p_comment) ) $p_comment="";
|
||||
echo '<TD> <INPUT TYPE="text" name="p_comment" VALUE="'.$p_comment.'"></TD></TR>';
|
||||
|
|
@ -148,8 +142,8 @@ echo '<INPUT TYPE="submit" name="search" value="cherche">';
|
|||
echo '</FORM>';
|
||||
|
||||
// if request search
|
||||
if ( isset($_POST['search']) or isset($_GET['filter']) ) {
|
||||
$Res=ExecSql($cn,"select * from tmp_pcmn $condition order by pcm_val::text");
|
||||
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");
|
||||
|
||||
$MaxLine=pg_NumRows($Res);
|
||||
if ( $MaxLine==0) {
|
||||
|
|
@ -163,9 +157,11 @@ if ( isset($_POST['search']) or isset($_GET['filter']) ) {
|
|||
$l_line=pg_fetch_array($Res,$i);
|
||||
echo "<TR>";
|
||||
// if p_ctl is set we need to be able to return the value
|
||||
if (isset($p_ctl) and $p_ctl != 'not' ){
|
||||
if (isset($p_ctl) && $p_ctl != 'not' ){
|
||||
echo '<TD>';
|
||||
echo '<input type="checkbox" onClick="SetItChild(\''.$p_ctl.'\',\''.$l_line['pcm_val'].'\')">';
|
||||
$slabel=FormatString($l_line['pcm_lib']);
|
||||
echo '<input type="checkbox" onClick="SetItChild(\''.$p_ctl.'\',\''.$l_line['pcm_val'].'\',\''.
|
||||
$slabel.'\')">';
|
||||
echo '</td>';
|
||||
}
|
||||
echo '<TD>';
|
||||
|
|
|
|||
|
|
@ -222,7 +222,9 @@ foreach ( $Dossier as $rDossier) {
|
|||
|
||||
|
||||
<TR><TD><input type="Submit" NAME="SAVE" VALUE="Save changes"></TD>
|
||||
<TD><input type="RESET" NAME="Reset" VALUE="Cancel Change"></TD>
|
||||
<TD>
|
||||
<A class="mtitle" HREF="admin_repo.php?action=user_mgt"><input type="button" value="Retour"></A>
|
||||
</TD>
|
||||
<TD><input type="Submit" NAME="DELETE" VALUE="Delete User"></TD>
|
||||
</TR>
|
||||
</FORM>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ if ( count($Fiche->row ) == 0 )
|
|||
echo "Aucune donnée";
|
||||
return;
|
||||
}
|
||||
echo '"Qcode;"'.
|
||||
echo '"Qcode";'.
|
||||
"\"Code interne\";".
|
||||
"\"Date\";".
|
||||
"\"Description\";".
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
|||
echo "You must choose a Dossier ";
|
||||
exit -2;
|
||||
}
|
||||
|
||||
include_once ("postgres.php");
|
||||
include_once ("check_priv.php");
|
||||
/* Admin. Dossier */
|
||||
|
|
@ -54,6 +55,7 @@ echo "</div>";
|
|||
// Display search result
|
||||
//-----------------------------------------------------
|
||||
if ( isset ($_GET['viewsearch'])) {
|
||||
|
||||
// Navigation bar
|
||||
$step=$_SESSION['g_pagesize'];
|
||||
$page=(isset($_GET['offset']))?$_GET['page']:1;
|
||||
|
|
@ -62,11 +64,15 @@ if ( isset ($_GET['viewsearch'])) {
|
|||
$array=null;
|
||||
else
|
||||
$array=$_GET;
|
||||
|
||||
|
||||
list($max_line,$a)=ListJrn($cn,0,"",$array,$offset,2);
|
||||
|
||||
$bar=jrn_navigation_bar($offset,$max_line,$step,$page);
|
||||
|
||||
|
||||
echo '<div class="u_redcontent">';
|
||||
|
||||
|
||||
echo $bar;
|
||||
echo $a;
|
||||
echo $bar;
|
||||
|
|
|
|||
655
html/style.css
655
html/style.css
|
|
@ -1,306 +1,431 @@
|
|||
/* <style type="text/css"> */
|
||||
<!--
|
||||
body {
|
||||
background-color:#FFFFFF;
|
||||
font-size:12px;
|
||||
font-family:sans-serif;
|
||||
|
||||
BODY {
|
||||
background-color:#EDF3FF;
|
||||
font-size:0.7em;
|
||||
font-family:Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
table.result {
|
||||
font-size:10px;
|
||||
color:blue;
|
||||
border:blue solid 1px;
|
||||
width:80%;
|
||||
|
||||
}
|
||||
table.result th {
|
||||
font-size:11px;
|
||||
font-weight:bold;
|
||||
font-family:sans-serif;
|
||||
border-bottom:1px solid blue;
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
font-size:10px;
|
||||
color:blue;
|
||||
border:blue solid 1px;
|
||||
width:80%;
|
||||
|
||||
}
|
||||
table.result th {
|
||||
font-size:11px;
|
||||
font-weight:bold;
|
||||
font-family:sans-serif;
|
||||
border-bottom:1px solid blue;
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family:sans-serif;
|
||||
font-size:14px;
|
||||
color:grey;
|
||||
font-family:sans-serif;
|
||||
font-size:1.5em;
|
||||
color:grey;
|
||||
}
|
||||
div.info {
|
||||
background:#879ed4;
|
||||
color:white;
|
||||
font-size:16pt;
|
||||
text-align:center;
|
||||
background:#879ed4;
|
||||
color:white;
|
||||
font-size:16pt;
|
||||
text-align:center;
|
||||
background-color: #879ed4;
|
||||
}
|
||||
|
||||
h2.info {
|
||||
color:blue;
|
||||
font-size:20px;
|
||||
background-color:#879ed4;
|
||||
color:white;
|
||||
font-size:2.5em;
|
||||
text-align:center;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
font-style:italic;
|
||||
}
|
||||
u_redcontent h2.info {
|
||||
background:#879ed5;
|
||||
color:white;
|
||||
font-size:14pt;
|
||||
text-align:center;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
}
|
||||
h3.info {
|
||||
background:#879ed4;
|
||||
color:white;
|
||||
font-size:10pt;
|
||||
text-align:center;
|
||||
background-color: #879ed4;
|
||||
}
|
||||
|
||||
h2.info2 {
|
||||
color:blue;
|
||||
font-size:20px;
|
||||
color:blue;
|
||||
font-size:20px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
h2.error {
|
||||
color:red;
|
||||
font-size:20px;
|
||||
background:red;
|
||||
color:white;
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
color: blue;
|
||||
font-size:25px;
|
||||
color: blue;
|
||||
font-size:25px;
|
||||
}
|
||||
|
||||
div.u_subtmenu {
|
||||
background-color:lightblue ;
|
||||
left:10px;
|
||||
|
||||
}
|
||||
div.u_subt2menu {
|
||||
background-color:lightgrey;
|
||||
left:1%;
|
||||
|
||||
}
|
||||
|
||||
div.lmenu {
|
||||
position: float;
|
||||
float:left;
|
||||
}
|
||||
div.lextmenu {
|
||||
position: float;
|
||||
float:left;
|
||||
font-size:11pt;
|
||||
left:30px;
|
||||
width:200px;
|
||||
}
|
||||
div.searchmenu {
|
||||
font-size:11pt;
|
||||
left:30px;
|
||||
width:200px;
|
||||
}
|
||||
div.recherche_form{
|
||||
width:700px;
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
border-style:outset;
|
||||
border-width:1px;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent{
|
||||
position: float;
|
||||
float:left;
|
||||
}
|
||||
div.u_content{
|
||||
position: float;
|
||||
float:left;
|
||||
width:100%;
|
||||
font-size:12px;
|
||||
font-family:sans-serif;
|
||||
}
|
||||
div.no span{
|
||||
position:static;
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
font-weight:bold;
|
||||
font-color:red;
|
||||
|
||||
}
|
||||
|
||||
|
||||
div.u_content span {
|
||||
position :float;
|
||||
float:left;
|
||||
margin-left:40px;
|
||||
}
|
||||
div.u_content table {
|
||||
width:100%;
|
||||
border:solid blue 2px ;
|
||||
border-style:outset;
|
||||
}
|
||||
div.u_content table th {
|
||||
background-color:lightgrey;
|
||||
}
|
||||
|
||||
table.mtitle {
|
||||
border:0;
|
||||
align:center
|
||||
}
|
||||
td.mshort {
|
||||
color:gray;
|
||||
background-color:#0F4CD0;
|
||||
font-size:11pt;
|
||||
border-style:groove
|
||||
}
|
||||
|
||||
|
||||
td.mtitle {
|
||||
color:gray;
|
||||
background-color:#0F4CD0;
|
||||
font-size:11pt;
|
||||
border-style:groove
|
||||
}
|
||||
|
||||
span.mtitle {
|
||||
color:gray;
|
||||
background-color:blue;
|
||||
font-size:12px;
|
||||
border-style:groove
|
||||
}
|
||||
span.odd {
|
||||
background-color:#ECF3FF;
|
||||
display:block;
|
||||
}
|
||||
span.even {
|
||||
background-color:#DDE6FF;
|
||||
display:block;
|
||||
}
|
||||
|
||||
tr.odd {
|
||||
background-color:#DDE6FF;
|
||||
|
||||
}
|
||||
td.odd{
|
||||
background-color:#DDE6FF ;
|
||||
border:Opt
|
||||
}
|
||||
td.cell{
|
||||
color:blue;
|
||||
background-color:#C5CACD;
|
||||
border-style:solid;
|
||||
border-width:1pt;
|
||||
font-size:11pt;
|
||||
}
|
||||
td.selectedcell{
|
||||
border-style:solid;
|
||||
border-width:1pt;
|
||||
font-size:11pt;
|
||||
background:blue ;
|
||||
color:white;
|
||||
}
|
||||
|
||||
td.mtitle a.mtitle {
|
||||
text-decoration:none;
|
||||
color:white;
|
||||
}
|
||||
|
||||
a.mtitle {
|
||||
text-decoration:none;
|
||||
color:grey;
|
||||
}
|
||||
a.mtitle:hover {
|
||||
background:#4BCCD0;
|
||||
}
|
||||
|
||||
a.mtitle2 {
|
||||
text-decoration:none;
|
||||
color:white;
|
||||
}
|
||||
a.mtitle2:hover {
|
||||
background:#4BCCD0;
|
||||
}
|
||||
|
||||
a.one:link {
|
||||
text-decoration:underline;
|
||||
color:#3010FF
|
||||
}
|
||||
a.one:visited {
|
||||
text-decoration:underline;
|
||||
color:#3010FF
|
||||
}
|
||||
a.one:active {
|
||||
background: #0000FF
|
||||
}
|
||||
|
||||
a.one:hover {
|
||||
background:#3010FF;
|
||||
color:#FFFFFF
|
||||
}
|
||||
|
||||
a.two:link {
|
||||
text-decoration:none;
|
||||
color:#3010FF
|
||||
}
|
||||
a.two:visited {
|
||||
text-decoration:none;
|
||||
color:#3010FF
|
||||
}
|
||||
a.two:active {
|
||||
background: #0000FF;
|
||||
}
|
||||
|
||||
a.two:hover {
|
||||
background:#3010FF;
|
||||
color:#FFFFFF;
|
||||
font-size:19px
|
||||
}
|
||||
a.detail
|
||||
{
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.detail:hover
|
||||
{
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: white;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
li.menuv,ol.menuv {
|
||||
display:inline;
|
||||
padding:1em 1em;
|
||||
div.mtitle {
|
||||
position: absolute;
|
||||
right:300px;
|
||||
width:100px;
|
||||
background-color:yellow;
|
||||
}
|
||||
|
||||
div.u_tmenu {
|
||||
position:float;
|
||||
width:100%;
|
||||
background-color:white;
|
||||
position: float;
|
||||
margin-top:1px;
|
||||
width:100%;
|
||||
background-color:#36559b;
|
||||
}
|
||||
div.u_subtmenu {
|
||||
left:10px;
|
||||
background-color:#C0E6E9;
|
||||
}
|
||||
div.u_subt2menu {
|
||||
left:1%;
|
||||
background-color:#36559b;
|
||||
}
|
||||
div.lmenu {
|
||||
position: float;
|
||||
float:left;
|
||||
left:20px;
|
||||
width:15em;
|
||||
font-size:9px;
|
||||
background-color:#EDF3FF;
|
||||
background-image: url(image/lmenu_back.png);
|
||||
background-repeat: repeat-y;
|
||||
}
|
||||
|
||||
span.odd {
|
||||
background-color:#ECF3FF;
|
||||
display:block;
|
||||
div.lextmenu {
|
||||
position: float;
|
||||
float:left;
|
||||
font-family:sans-serif;
|
||||
font-size:9px;
|
||||
background-color:blue;
|
||||
}
|
||||
span.even {
|
||||
background-color:#DDE6FF;
|
||||
display:block;
|
||||
|
||||
div.searchmenu {
|
||||
left:30px;
|
||||
width:95px;
|
||||
top:100px;
|
||||
position:absolute;
|
||||
background-color:green;
|
||||
}
|
||||
|
||||
div.recherche_form{
|
||||
width:700px;
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
border-style:outset;
|
||||
border-width:1px;
|
||||
}
|
||||
|
||||
div.u_redcontent{
|
||||
position: float;
|
||||
float:left;
|
||||
width:80%;
|
||||
padding-top:7px;
|
||||
padding-left:8px;
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
background-color:#BBBBEE;
|
||||
}
|
||||
|
||||
div.u_content{
|
||||
position: float;
|
||||
float:left;
|
||||
width:100%;
|
||||
font-size:12px;
|
||||
|
||||
font-family:sans-serif;
|
||||
background-color:lightgreen;
|
||||
}
|
||||
div.no span{
|
||||
position:static;
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
font-weight:bold;
|
||||
font-color:red;
|
||||
}
|
||||
|
||||
div.u_content span {
|
||||
position :float;
|
||||
float:left;
|
||||
margin-left:40px;
|
||||
}
|
||||
table.document {
|
||||
border:solid blue 2px ;
|
||||
width:100%;
|
||||
border-style:outset;
|
||||
}
|
||||
table.document th{
|
||||
background-color:lightgrey;
|
||||
color:darkblue;
|
||||
}
|
||||
|
||||
table.mtitle {
|
||||
border:0;
|
||||
text-align:center
|
||||
}
|
||||
td.mshort {
|
||||
height:15px;
|
||||
width:60px;
|
||||
text-align:center;
|
||||
color:#5D90CD;
|
||||
background-color:#DDE6FF;
|
||||
}
|
||||
td.mtitle {
|
||||
border-color:#CC0000;
|
||||
text-align:center;
|
||||
width:120px;
|
||||
height :30px;
|
||||
font-size:10px;
|
||||
// border: 1px solid;
|
||||
// padding:3px;
|
||||
background-color:#DDE6FF;
|
||||
border: 5px;
|
||||
}
|
||||
|
||||
td.mtitle:hover, td.mtitle:hover a {
|
||||
background-color:#36559b;
|
||||
color:#FFFFFF;
|
||||
}
|
||||
|
||||
span.mtitle {
|
||||
color:gray;
|
||||
background-color:blue;
|
||||
font-size:10px;
|
||||
border-style:groove
|
||||
}
|
||||
span.odd {
|
||||
background-color:#ECF3FF;
|
||||
display:block;
|
||||
}
|
||||
span.even {
|
||||
background-color:#DDE6FF;
|
||||
display:block;
|
||||
}
|
||||
|
||||
tr.odd {
|
||||
background-color:#DDE6FF;
|
||||
font-size:10px;
|
||||
border-size:0px;
|
||||
}
|
||||
tr {
|
||||
font-size:10px;
|
||||
}
|
||||
td.odd{
|
||||
background-color:#DDE6FF ;
|
||||
border-size:0px;
|
||||
font-size:10px;
|
||||
}
|
||||
td.even{
|
||||
border:0px;
|
||||
font-size:10px;
|
||||
}
|
||||
td.cell{
|
||||
// border:1px solid blue;
|
||||
height:32px;
|
||||
padding: 1px;
|
||||
width:120px;
|
||||
}
|
||||
td.selectedcell{
|
||||
border-style:none;
|
||||
border-color:#36559b;
|
||||
border-width:1pt ;
|
||||
font-size:1.3em;
|
||||
background:#36559b ;
|
||||
color:white;
|
||||
text-align:center;
|
||||
width:120px;
|
||||
}
|
||||
|
||||
a.mtitle {
|
||||
font-size:1em;
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
color:blue;
|
||||
}
|
||||
|
||||
a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
border-style:none;
|
||||
border-color:yellow;
|
||||
background-color:#36559b;
|
||||
}
|
||||
|
||||
a.cell {
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
color:blue;
|
||||
background-color:white;
|
||||
font-size:9px;
|
||||
}
|
||||
|
||||
a.cell:hover {
|
||||
font-size:9px;
|
||||
color:white;
|
||||
background-color:#5D90CD;
|
||||
text-decoration:none;
|
||||
display:block;
|
||||
}
|
||||
|
||||
|
||||
a.one:link {
|
||||
text-decoration:none;
|
||||
color:#3010FF
|
||||
}
|
||||
a.one:visited {
|
||||
text-decoration:none;
|
||||
color:#3010FF
|
||||
}
|
||||
|
||||
a.one:active {
|
||||
background: #0000FF;
|
||||
background-color: #0000FF;
|
||||
}
|
||||
|
||||
a.one:hover {
|
||||
text-decoration:underline;
|
||||
background-color:#3010FF;
|
||||
color:#FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
a.detail
|
||||
{
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a.detail:hover
|
||||
{
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: white;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
li.menuv,ol.menuv {
|
||||
display:inline;
|
||||
padding:1em 1em;
|
||||
}
|
||||
div.u_redcontent a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: darkblue;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: red;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
div.u_content a {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
color: darkblue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a:hover {
|
||||
font-size:9px;
|
||||
font-family:sans-serif;
|
||||
color: red;
|
||||
background-color: rgb(93, 144, 205);
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
|
||||
}
|
||||
|
||||
div.u_redcontent a.mtitle {
|
||||
font-size:18px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
}
|
||||
|
||||
div.u_redcontent a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
div.u_content a.mtitle {
|
||||
font-size:10px;
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
color:blue;
|
||||
|
||||
}
|
||||
|
||||
div.u_content a.mtitle:hover {
|
||||
text-decoration:none;
|
||||
display:inline;
|
||||
background-color:yellow;
|
||||
|
||||
|
||||
}
|
||||
div.u_redcontent input.text {
|
||||
font-family:sans-serif;
|
||||
font-weight:normal;
|
||||
border-color:336699;
|
||||
border-style:solid;
|
||||
background-color:white;
|
||||
border-width:1px;
|
||||
color:blue;
|
||||
font-family:sans-serif;
|
||||
font-weight:normal;
|
||||
border-color:336699;
|
||||
border-style:solid;
|
||||
background-color:white;
|
||||
border-width:1px;
|
||||
color:blue;
|
||||
}
|
||||
div.u_content input.text {
|
||||
font-family:sans-serif;
|
||||
font-weight:normal;
|
||||
border-color:336699;
|
||||
border-style:solid;
|
||||
border-width:1px;
|
||||
background-color:white;
|
||||
color:blue;
|
||||
font-family:sans-serif;
|
||||
font-weight:normal;
|
||||
border-color:336699;
|
||||
border-style:solid;
|
||||
border-width:1px;
|
||||
background-color:white;
|
||||
color:blue;
|
||||
}
|
||||
|
||||
div.u_redcontent input:focus {
|
||||
background-color:fff6aa;
|
||||
background-color:cfffe4;
|
||||
}
|
||||
div.u_content input:focus {
|
||||
background-color:fff6aa;
|
||||
background-color:cfffe4;
|
||||
}
|
||||
div.u_redcontent textarea:focus{
|
||||
background-color: orange;
|
||||
}
|
||||
-->
|
||||
/*</style>*/
|
||||
|
||||
/*input{
|
||||
font-size:0.9em;
|
||||
}
|
||||
*/
|
||||
/* </style> */
|
||||
|
|
|
|||
111
html/test.php
111
html/test.php
|
|
@ -11,7 +11,7 @@ h2.error {
|
|||
}
|
||||
-->
|
||||
</style>
|
||||
<?phpphp
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
|
|
@ -34,40 +34,83 @@ h2.error {
|
|||
include_once("ac_common.php");
|
||||
include_once("postgres.php");
|
||||
// Test the connection
|
||||
$a=DbConnect();
|
||||
if ( $a==false) {
|
||||
exit ("<h2 class=\"error\">__LINE__ test has failed !!!</h2>");
|
||||
echo __FILE__.":".__LINE__;
|
||||
|
||||
}
|
||||
if ( ($Res=ExecSql($a,"select * from ac_users") ) == false ) {
|
||||
exit ("<h2 class=\"error\">__LINE__ test has failed !!!</h2>");
|
||||
} else
|
||||
print "Connect to database success <br>";
|
||||
require_once('class_plananalytic.php');
|
||||
$cn=DbConnect(14);
|
||||
echo "<h1>Plan analytique : test</h1>";
|
||||
echo "clean";
|
||||
ExecSql($cn,"delete from plan_analytique");
|
||||
|
||||
// Verify some PHP parameters
|
||||
// magic_quotes_gpc = Off
|
||||
// magic_quotes_runtime = Off
|
||||
// magic_quotes_sybase = Off
|
||||
// include_path
|
||||
// register_global
|
||||
foreach (array('magic_quotes_gpc','magic_quotes_runtime') as $a) {
|
||||
|
||||
if ( ini_get($a) == false ) print $a.': Ok <br>';
|
||||
else {
|
||||
print ("<h2 class=\"error\">$a has a bad value !!!</h2>");
|
||||
}
|
||||
|
||||
}
|
||||
if ( ereg("\.\.\/include",ini_get('include_path')) == false )
|
||||
print ("<h2 class=\"error\">include_path incorrect !!!".ini_get('include_path')."</h2>");
|
||||
else
|
||||
print 'include_path : ok ('.ini_get('include_path').')<br>';
|
||||
|
||||
echo "<h2 class=\"info\"> Congratulation : Test successfull</h2>";
|
||||
?>
|
||||
<script type="text/javascript" language="javascript" src="js/jrn_concerned.js">
|
||||
alert("Include me");
|
||||
SearchJrn('a','b');
|
||||
</script>
|
||||
$p=new PlanAnalytic($cn);
|
||||
echo "<h2>Add</h2>";
|
||||
$p->name="Nouveau 1";
|
||||
$p->description="C'est un test";
|
||||
echo "Add<hr>";
|
||||
$p->add();
|
||||
$p->name="Nouveau 2";
|
||||
$p->add();
|
||||
$pa_id=$p->id;
|
||||
echo $p->id."/";
|
||||
$p->name="Nouveau 3";
|
||||
$p->add();
|
||||
echo $p->id."/";
|
||||
|
||||
|
||||
$p->name="Nouveau 4";
|
||||
$p->add();
|
||||
echo $p->id;
|
||||
|
||||
echo "<h2>get</h2>";
|
||||
$p->get();
|
||||
var_dump($p);
|
||||
echo "<h2>Update</h2> ";
|
||||
$p->name="Update ";
|
||||
$p->description="c'est changé";
|
||||
$p->update();
|
||||
$p->get;
|
||||
var_dump($p);
|
||||
echo "<h2>get_list</h2>";
|
||||
$a=$p->get_list();
|
||||
var_dump($a);
|
||||
echo "<h2>delete </h2>";
|
||||
$p->delete();
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
require_once("class_poste_analytic.php");
|
||||
$o=new Poste_Analytique($cn);
|
||||
echo "<h1>Poste_Analytique</h1>";
|
||||
echo "<h2>get_list</h2>";
|
||||
$ee=$o->get_list();
|
||||
|
||||
//var_dump($ee);
|
||||
echo "<h2>Add some </h2>";
|
||||
$o->pa_id=$pa_id;
|
||||
$o->name="test1";
|
||||
$o->add();
|
||||
|
||||
|
||||
$o->name="test2";
|
||||
$o->add();
|
||||
|
||||
$o->name="test3";
|
||||
$o->add();
|
||||
|
||||
$o->name="test4";
|
||||
$o->add();
|
||||
|
||||
$o->name="test5";
|
||||
$o->add();
|
||||
|
||||
echo "<h2> remove test1</h2>";
|
||||
$o->get_by_name("test1");
|
||||
$o->delete();
|
||||
$o->display_list();
|
||||
|
||||
$o->get_by_name("test4");
|
||||
echo "<hr>".$o->id."<hr>";
|
||||
$o->name="Test Four";
|
||||
$o->update();
|
||||
$o->display_list();
|
||||
$o->delete();
|
||||
$o->display_list();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ $User=new cl_user($cn);
|
|||
$User->Check();
|
||||
|
||||
html_page_start($User->theme,
|
||||
"OnLoad=\"SetFocus('e_date',0); AttachEvent(document, 'keydown', HandleSubmit, true);\" ");
|
||||
"OnLoad=\"SetFocus('e_date',0);checkTotal();\" ",
|
||||
"js/compute.js");
|
||||
|
||||
// Check if dossier set
|
||||
if ( ! isset ( $_SESSION['g_dossier'] ) ) {
|
||||
|
|
@ -95,7 +96,7 @@ echo JS_AJAX_FICHE;
|
|||
if ( $jrn_type=='VEN' ) require('user_action_ven.php');
|
||||
if ( $jrn_type=='ACH' ) require('user_action_ach.php');
|
||||
if ( $jrn_type=='FIN' ) require('user_action_fin.php');
|
||||
if ( $jrn_type=='OD' ) require('user_action_ods.php');
|
||||
if ( $jrn_type=='ODS' ) require('user_action_ods.php');
|
||||
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
|
|
@ -34,10 +32,13 @@ $User->Check();
|
|||
html_page_start($_SESSION['g_theme']);
|
||||
include_once("user_menu.php");
|
||||
|
||||
$priv=($User->admin==1)?"Administrator":"User";
|
||||
if ( isset ($_SESSION['g_dossier']))
|
||||
unset ($_SESSION['g_dossier']);
|
||||
|
||||
echo '<div class="info"> Welcome '.$User->first_name.' '.
|
||||
$User->name.',<h3 class="info"> your are an '. $priv.' <br>Please Select your folder</h3></div>';
|
||||
$priv=($User->admin==1)?"Administrateur":"Utilisateur";
|
||||
|
||||
echo '<div class="info"> Bienvenue '.$User->first_name.' '.
|
||||
$User->name.',<h3 class="info"> Vous êtes un '. $priv.' <br>Selectionnez votre dossier</h3></div>';
|
||||
// Show default menu (preference,...)
|
||||
|
||||
// If admin show everything otherwise only the available dossier
|
||||
|
|
|
|||
|
|
@ -28,16 +28,34 @@ include_once ("postgres.php");
|
|||
/* Admin. Dossier */
|
||||
$Rep=DbConnect();
|
||||
include_once ("class_user.php");
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
|
||||
$cn=DbConnect();
|
||||
|
||||
/* if the dossier is not set then we have to connect to the
|
||||
* account_repository database
|
||||
*/
|
||||
|
||||
if ( isset ($_SESSION['g_dossier']))
|
||||
{
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cn=DbConnect();
|
||||
}
|
||||
|
||||
|
||||
$User=new cl_user($cn);
|
||||
$User->Check();
|
||||
|
||||
// Met a jour le theme utilisateur (style)
|
||||
if ( isset ( $_POST['style_user']) ) {
|
||||
$User->update_global_pref('THEME',$_POST['style_user']);
|
||||
$_SESSION['g_theme']=$_POST['style_user'];
|
||||
|
||||
}
|
||||
|
||||
if ( isset ( $_POST['style_user']) )
|
||||
{
|
||||
$User->update_global_pref('THEME',$_POST['style_user']);
|
||||
$_SESSION['g_theme']=$_POST['style_user'];
|
||||
|
||||
}
|
||||
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
|
||||
// Met a jour le pagesize
|
||||
|
|
@ -51,12 +69,18 @@ if ( isset ( $_POST['p_size']) ) {
|
|||
// comta style
|
||||
|
||||
include_once ("user_menu.php");
|
||||
if ( isset ($_SESSION['g_dossier']) ) {
|
||||
if ( $_SESSION['g_dossier'] != 0 )
|
||||
echo '<div class="u_tmenu">';
|
||||
|
||||
echo ShowMenuCompta($_SESSION['g_dossier']);
|
||||
echo "</div>";
|
||||
if ( isset ($_SESSION['g_dossier']) )
|
||||
{
|
||||
if ( $_SESSION['g_dossier'] != 0 )
|
||||
{
|
||||
echo '<div class="u_tmenu">';
|
||||
echo ShowMenuCompta($_SESSION['g_dossier']);
|
||||
echo "</div>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<h2 class=\"info\"> Préférences</h2>";
|
||||
}
|
||||
require_once("pref.inc.php");
|
||||
html_page_stop();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function echo_error ($p_log, $p_line="", $p_message="") {
|
|||
fclose($fdebug);
|
||||
echo_debug($p_log,$p_line,$p_message);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Compare 2 dates
|
||||
* \param p_date
|
||||
|
|
@ -218,7 +218,7 @@ function NoAccess($js=0)
|
|||
* \brief Fix the problem with the quote char for the database
|
||||
*
|
||||
* \param $p_string
|
||||
*
|
||||
* \todo replace par pg_escape_string !!!
|
||||
* \return a string which won't let strange char for the database
|
||||
*/
|
||||
function FormatString($p_string)
|
||||
|
|
@ -249,23 +249,32 @@ function ShowItem($p_array,$p_dir='V',$class="mtitle",$class_ref="mtitle",$defau
|
|||
foreach ($p_array as $all=>$href){
|
||||
$title="";
|
||||
if ( isset ($href[2] ))
|
||||
$title=$href[2];
|
||||
$title=$href[2];
|
||||
$ret.='<TR><TD CLASS="'.$class.'"><A class="'.$class_ref.'" HREF="'.$href[0].'" title="'.$title.'">'.$href[1].'</A></TD></TR>';
|
||||
}
|
||||
}
|
||||
//direction Horizontal
|
||||
else if ( $p_dir == 'H' ) {
|
||||
|
||||
$ret.="<TR>";
|
||||
foreach ($p_array as $all=>$href){
|
||||
$title="";
|
||||
|
||||
$set="A";
|
||||
if ( isset ($href[2] ))
|
||||
$title=$href[2];
|
||||
if ( $default== $href[0]) {
|
||||
$ret.='<TD CLASS="selectedcell">'.$href[1].'</TD>';
|
||||
$title=$href[2];
|
||||
|
||||
if ( isset($href[3]))
|
||||
$set=$href[3];
|
||||
|
||||
if ( $default=== $href[0]||$set===$default ) {
|
||||
|
||||
$ret.='<TD CLASS="selectedcell">'.$href[1].'</TD>';
|
||||
|
||||
} else {
|
||||
$ret.='<TD CLASS="'.$class.'"><A class="'.$class_ref.'" HREF="'.$href[0].'" title="'.$title.'">'.$href[1].'</A></TD>';
|
||||
$ret.='<TD CLASS="'.$class.'"><A class="'.$class_ref.'" HREF="'.$href[0].'" title="'.$title.'">'.$href[1].'</A></TD>';
|
||||
}
|
||||
|
||||
}
|
||||
$ret.="</TR>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,16 @@ function ShowActionList($cn,$retour,$h_url)
|
|||
$w=new widget('js_search_only');
|
||||
$w->name='qcode';
|
||||
$w->value=$qcode;
|
||||
$w->label='Quick Code';
|
||||
$w->label='Quick Code1';
|
||||
$w->extra='4,9,14,16,8';
|
||||
$w->table=0;
|
||||
$sp= new widget("span");
|
||||
|
||||
echo $sp->IOValue("qcode_label","",$qcode);
|
||||
echo $w->IOValue();
|
||||
|
||||
|
||||
$sp= new widget("span");
|
||||
echo $sp->IOValue("qcode_label","",$qcode);
|
||||
|
||||
|
||||
?>
|
||||
<br>
|
||||
<input type="submit" name="submit_query" value="recherche">
|
||||
|
|
@ -67,8 +70,6 @@ function ShowActionList($cn,$retour,$h_url)
|
|||
</form>
|
||||
</span>
|
||||
|
||||
<?php
|
||||
?>
|
||||
<br>
|
||||
<form style="position:float;float:left" method="get" action="commercial.php">
|
||||
<input type="submit" name="submit_query" value="Ajout Action">
|
||||
|
|
|
|||
|
|
@ -99,10 +99,19 @@ echo "<br>";
|
|||
'$p_bq_account',
|
||||
$p_jrn,
|
||||
'n')";
|
||||
if ( ExecSql($p_cn,$Sql) == false )
|
||||
try
|
||||
{
|
||||
Rollback($p_cn); break;
|
||||
ExecSql($p_cn,$Sql);
|
||||
}
|
||||
|
||||
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage);
|
||||
rollback($p_cn);
|
||||
break;
|
||||
}
|
||||
|
||||
} // for ($c=0;$c<$num;$c++)
|
||||
$line++;
|
||||
} // file is read
|
||||
|
|
|
|||
29
include/ca_imp.inc.php
Normal file
29
include/ca_imp.inc.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief this file is included for printing the analytic
|
||||
* accountancy.
|
||||
*
|
||||
*/
|
||||
129
include/ca_od.inc.php
Normal file
129
include/ca_od.inc.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief Misc Operation for analytic accountancy
|
||||
*
|
||||
*/
|
||||
require_once("class_poste_analytic.php");
|
||||
require_once ("class_widget.php");
|
||||
require_once ("class_operation.php");
|
||||
require_once ("class_groupop.php");
|
||||
|
||||
|
||||
$pa=new PlanAnalytic($cn);
|
||||
$m=$pa->get_list();
|
||||
echo '<div class="u_subt2menu">';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
if ( isset ($_REQUEST['pa_id'])){
|
||||
$pa_id=$_REQUEST['pa_id'];
|
||||
} else $pa_id=-1;
|
||||
foreach ($m as $line)
|
||||
{
|
||||
if ( $line['id'] == $pa_id ) {
|
||||
echo '<td class="selectedcell">'.
|
||||
$line['name'].
|
||||
'</td>';
|
||||
|
||||
} else {
|
||||
echo '<td class="mtitle">'.
|
||||
'<a class="mtitle" href="?p_action=ca_od&sa=pa&pa_id='.$line['id'].'&new"> '.
|
||||
$line['name'].
|
||||
'</a>'.'</td>';
|
||||
}
|
||||
}
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
if ( ! isset($_REQUEST['pa_id']) )
|
||||
exit();
|
||||
//----------------------------------------------------------------------
|
||||
// show the left menu
|
||||
//----------------------------------------------------------------------
|
||||
echo '
|
||||
<div class="lmenu">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="mtitle" >
|
||||
<A class="mtitle" HREF="?p_action=ca_od&pa_id='.$_REQUEST['pa_id'].'&new"> Nouveau </A>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="mtitle" >
|
||||
<A class="mtitle" HREF="?p_action=ca_od&pa_id='.$_REQUEST['pa_id'].'&see"> Liste opérations </A
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>';
|
||||
//----------------------------------------------------------------------
|
||||
// the pa_id is set
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
if ( isset($_GET['see'])) {
|
||||
// Show the list for the period
|
||||
// and exit
|
||||
//-----------------------------
|
||||
$a=new operation($cn);
|
||||
$a->pa_id=$_REQUEST['pa_id'];
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $a->get_list();
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
if ( isset($_POST['save'])) {
|
||||
// record the operation and exit
|
||||
// and exit
|
||||
//-----------------------------
|
||||
echo '<div class="u_redcontent">'.
|
||||
'Opération sauvée';
|
||||
$a=new groupop($cn);
|
||||
$a->pa_id=$_POST['pa_id'];
|
||||
$a->from_POST();
|
||||
$a->save();
|
||||
echo $a->show();
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( isset($_GET['new'])) {
|
||||
//show the form for entering a new operation
|
||||
//------------------------------------------
|
||||
$a=new groupop($cn);
|
||||
$a->pa_id=$_GET['pa_id'];
|
||||
$wSubmit=new widget('hidden',"p_action","ca_od");
|
||||
$wSubmit->table=0;
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<form method="post">';
|
||||
echo $wSubmit->IOValue();
|
||||
echo $a->form();
|
||||
echo $wSubmit->Submit("save","Sauver");
|
||||
echo '</form>';
|
||||
|
||||
echo '</div>';
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="u_redcontent">
|
||||
299
include/ca_pa.inc.php
Normal file
299
include/ca_pa.inc.php
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief Plan Analytique
|
||||
*
|
||||
*/
|
||||
require_once("class_plananalytic.php");
|
||||
require_once("class_poste_analytic.php");
|
||||
$ret="";
|
||||
//---------------------------------------------------------------------------
|
||||
// action
|
||||
// Compute the u_redcontent div
|
||||
//---------------------------------------------------------------------------
|
||||
if ( isset($_REQUEST['sa']))
|
||||
{
|
||||
$sa=$_REQUEST['sa'];
|
||||
|
||||
// show the form for adding a pa
|
||||
if ( $sa == "add_pa")
|
||||
{
|
||||
$wAction=new widget("hidden","","p_action","ca_pa");
|
||||
$new=new PlanAnalytic($cn);
|
||||
if ( $new->isAppend() == true)
|
||||
{
|
||||
$ret.= '<div class="u_redcontent">';
|
||||
$ret.= '<h2 class="info">Nouveau plan</h2>';
|
||||
$ret.= '<form method="post">';
|
||||
$ret.= $new->form();
|
||||
$wSa=new widget("HIDDEN","","sa","pa_write");
|
||||
$wSa->value="pa_write";
|
||||
$ret.= $wSa->IOValue();
|
||||
$ret.= $wAction->IOValue();
|
||||
$ret.= $wSa->Submit("submit","Enregistre");
|
||||
$ret.= '</form>';
|
||||
$ret.= '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret.= '<div class="u_redcontent">'.
|
||||
'<h2 class="info">'.
|
||||
"Maximum de plan analytique est atteint".
|
||||
"</h2></div>";
|
||||
}
|
||||
}
|
||||
// Add
|
||||
if ( $sa == "pa_write")
|
||||
{
|
||||
$new=new PlanAnalytic($cn);
|
||||
|
||||
|
||||
if ( $new->isAppend() == false)
|
||||
{
|
||||
$ret.= '<h2 class="info">'.
|
||||
"Maximum de plan analytique est atteint".
|
||||
"</h2>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$new=new PlanAnalytic($cn);
|
||||
$new->name=$_POST['pa_name'];
|
||||
$new->description=$_POST['pa_description'];
|
||||
$new->add();
|
||||
}
|
||||
}
|
||||
// show the detail
|
||||
if ( $sa == "pa_detail" )
|
||||
{
|
||||
$new=new PlanAnalytic($cn,$_GET['pa_id']);
|
||||
$wAction=new widget("hidden","","p_action","ca_pa");
|
||||
$wSa=new widget("HIDDEN","","sa","pa_update");
|
||||
|
||||
$new->get();
|
||||
|
||||
$ret.= '<div class="u_redcontent">';
|
||||
$ret.= '<h2 class="info">Mise à jour</h2>';
|
||||
$ret.= '<form method="post">';
|
||||
$ret.= $new->form();
|
||||
$ret.= $wSa->IOValue();
|
||||
$ret.= $wAction->IOValue();
|
||||
$ret.= $wSa->Submit("submit","Enregistre");
|
||||
$ret.=sprintf('<A class="mtitle" HREF="%s">'.
|
||||
'<input type="button" value="Efface"></A>',
|
||||
"?p_action=ca_pa&pa_id=".$_GET['pa_id']."&sa=pa_delete");
|
||||
|
||||
$ret.= '</form>';
|
||||
$ret.= '</div>';
|
||||
|
||||
}
|
||||
// Update the PA
|
||||
if ( $sa == "pa_update" )
|
||||
{
|
||||
$new=new PlanAnalytic($cn,$_GET['pa_id']);
|
||||
$new->name=$_POST['pa_name'];
|
||||
$new->description=$_POST['pa_description'];
|
||||
$new->update();
|
||||
$ret='<div class="u_redcontent">';
|
||||
$ret.='<h2 class="info">Mis à jour</h2>';
|
||||
$ret.="</div>";
|
||||
}
|
||||
// show the form for add a poste
|
||||
if ( $sa=='po_add')
|
||||
{
|
||||
$po=new Poste_analytique($cn);
|
||||
$po->pa_id=$_REQUEST['pa_id'];
|
||||
$wSa=new widget("hidden","sa","sa","po_write");
|
||||
$ret.='<div class="u_redcontent">';
|
||||
$ret.='<form method="post">';
|
||||
$ret.=$po->form();
|
||||
$ret.=$wSa->IOValue();
|
||||
$ret.=$wSa->Submit("add","Ajout");
|
||||
$ret.="</div>";
|
||||
}
|
||||
// record the poste
|
||||
if ( $sa=="po_write")
|
||||
{
|
||||
// var_dump($_POST);
|
||||
$po=new Poste_analytique($cn);
|
||||
$po->fill_from_POST();
|
||||
$po->add();
|
||||
$sa="list";
|
||||
|
||||
}
|
||||
/* delete pa */
|
||||
if ( $sa == "pa_delete")
|
||||
{
|
||||
$delete=new PlanAnalytic($cn,$_GET['pa_id']);
|
||||
$delete->delete();
|
||||
}
|
||||
/* po detail
|
||||
*
|
||||
*/
|
||||
if ( $sa=="po_detail")
|
||||
{
|
||||
$wHidden=new widget('hidden','','sa','po_update');
|
||||
$po=new Poste_analytique($cn,$_GET['po_id']);
|
||||
$po->get_by_id();
|
||||
$ret.='<div class="u_redcontent">';
|
||||
$ret.='<form method="post">';
|
||||
$ret.=$po->form();
|
||||
$ret.=$wHidden->IOValue();
|
||||
$ret.='<input type="submit" value="Correction">';
|
||||
$ret.=sprintf('<A class="mtitle" HREF="?p_action=ca_pa&sa=po_delete&po_id=%s&pa_id=%s">'.
|
||||
'<input type="button" value="Efface"></A>',
|
||||
$po->id,
|
||||
$_REQUEST['pa_id']
|
||||
);
|
||||
|
||||
$ret.='</form>';
|
||||
$ret.='</div>';
|
||||
}
|
||||
if ( $sa=="po_update")
|
||||
{
|
||||
$po=new Poste_analytique($cn);
|
||||
$po->fill_from_POST();
|
||||
$po->update();
|
||||
$sa="list";
|
||||
}
|
||||
if ( $sa=="po_delete")
|
||||
{
|
||||
$po=new Poste_analytique($cn,$_REQUEST['po_id']);
|
||||
$po->delete();
|
||||
$sa="list";
|
||||
}
|
||||
/* List poste */
|
||||
if ( $sa == "list" )
|
||||
{
|
||||
$count=0;
|
||||
|
||||
$new=new PlanAnalytic($cn,$_REQUEST['pa_id']);
|
||||
$new->get();
|
||||
$array=$new->get_poste_analytique();
|
||||
$ret.='<div class="u_redcontent">';
|
||||
$ret.='<table style="width:100%;border:solid blue 2px ;border-style:outset;">';
|
||||
$ret.="<tr>";
|
||||
$ret.="<th> Nom </td>";
|
||||
$ret.="<th> Montant </td>";
|
||||
$ret.="<th> Description </td>";
|
||||
$ret.="<th> Plan A </td>";
|
||||
$ret.="</tr>";
|
||||
$class="";
|
||||
foreach ($array as $obj)
|
||||
{
|
||||
$count++;
|
||||
if ( $count %2 == 0 )
|
||||
$class="even";
|
||||
else
|
||||
$class="odd";
|
||||
|
||||
$ret.="<TR class=\"$class\">";
|
||||
$ret.="<TD>".
|
||||
'<a class="mtitle" href="?p_action=ca_pa&sa=po_detail&po_id='.$obj->id.'&pa_id='.$_REQUEST['pa_id'].'">'.
|
||||
$obj->name.
|
||||
'</a>';
|
||||
"</td>";
|
||||
$ret.="<TD align=\"right\">".$obj->amount."</td>";
|
||||
$ret.="<TD>".$obj->description."</td>";
|
||||
$ret.="<TD>".$new->name."</td>";
|
||||
$ret.="</tr>";
|
||||
|
||||
}
|
||||
$ret.="</table>";
|
||||
$ret.=sprintf('<A class="mtitle" HREF="?p_action=ca_pa&sa=po_add&pa_id=%s">'.
|
||||
'<input type="button" value="Ajout"></A>',
|
||||
$_GET['pa_id']
|
||||
);
|
||||
$ret.='</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Show lmenu
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
$obj=new PlanAnalytic($cn);
|
||||
$list=$obj->get_list();
|
||||
|
||||
|
||||
|
||||
|
||||
if ( empty($list) )
|
||||
{
|
||||
echo '<div class="lmenu">';
|
||||
echo '<TABLE>';
|
||||
echo '<TR><TD class="mtitle">';
|
||||
echo '<a class="mtitle" href="?p_action=ca_pa&sa=add_pa">Ajout d\'un plan comptable</a>';
|
||||
echo '</TD></TR>';
|
||||
echo '</TABLE>';
|
||||
|
||||
echo '</div>';
|
||||
if ( ! isset ( $_REQUEST['sa']))
|
||||
echo '<div class="u_redcontent">'.
|
||||
"Aucun plan analytique n'est défini".
|
||||
'</div>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<div class="lmenu">';
|
||||
|
||||
echo '<table>';
|
||||
foreach ($list as $line)
|
||||
{
|
||||
echo '<TR>';
|
||||
echo '<TD >'.
|
||||
'<a class="mtitle" href="?p_action=ca_pa&sa=pa_detail&pa_id='.$line['id'].'">'.
|
||||
$line['name'].
|
||||
'</TD>';
|
||||
echo '<td class="mtitle">'.
|
||||
'<a class="mtitle" href="?p_action=ca_pa&sa=list&pa_id='.$line['id'].'">'.
|
||||
"Postes".
|
||||
"</a>";
|
||||
|
||||
echo '</TR>';
|
||||
}
|
||||
echo '</table>';
|
||||
if ($obj->isAppend()==true )
|
||||
{
|
||||
echo '<TABLE>';
|
||||
echo '<TR><TD class="mtitle">';
|
||||
echo '<a class="mtitle" href="?p_action=ca_pa&sa=add_pa">Ajout d\'un plan comptable</a>';
|
||||
echo '</TD></TR>';
|
||||
echo '</TABLE>';
|
||||
}
|
||||
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
// show the u_redcontent part
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
echo $ret;
|
||||
|
|
@ -80,8 +80,13 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
|
|||
'$p_bq_account',
|
||||
$p_jrn,
|
||||
'n')";
|
||||
if ( ExecSql($p_cn,$Sql) == false )
|
||||
try
|
||||
{
|
||||
ExecSql($p_cn,$Sql) ;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage);
|
||||
Rollback($p_cn);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,21 +61,22 @@ $sql="insert into centralized( c_j_id,
|
|||
where
|
||||
j_tech_per =".$p_periode."
|
||||
order by j_date,j_grpt,j_debit desc ";
|
||||
$Res=StartSql($p_cn);
|
||||
$Res=ExecSql($p_cn,$sql);
|
||||
if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
$Res=ExecSql($p_cn,"update jrnx set j_centralized='t' where j_tech_per=".$p_periode);
|
||||
if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
// Set correctly the number of operation id (jr_opid) for each journal
|
||||
// get the existing jrn_def_id
|
||||
//--
|
||||
$Res = ExecSql($p_cn,"select jrn_def_id from jrn_def");
|
||||
$MaxJrn=pg_NumRows($Res);
|
||||
// for each jrn_def_id
|
||||
for ( $i=0; $i < $MaxJrn;$i++) {
|
||||
$row=pg_fetch_array($Res,$i);
|
||||
// get the op related to that jrn_def_id
|
||||
$sql=sprintf("select jr_id from jrn
|
||||
try
|
||||
{
|
||||
$Res=StartSql($p_cn);
|
||||
$Res=ExecSql($p_cn,$sql);
|
||||
$Res=ExecSql($p_cn,"update jrnx set j_centralized='t' where j_tech_per=".$p_periode);
|
||||
|
||||
// Set correctly the number of operation id (jr_opid) for each journal
|
||||
// get the existing jrn_def_id
|
||||
//--
|
||||
$Res = ExecSql($p_cn,"select jrn_def_id from jrn_def");
|
||||
$MaxJrn=pg_NumRows($Res);
|
||||
// for each jrn_def_id
|
||||
for ( $i=0; $i < $MaxJrn;$i++) {
|
||||
$row=pg_fetch_array($Res,$i);
|
||||
// get the op related to that jrn_def_id
|
||||
$sql=sprintf("select jr_id from jrn
|
||||
where
|
||||
jr_tech_per=%d
|
||||
and jr_def_id = %d
|
||||
|
|
@ -84,60 +85,64 @@ $sql="insert into centralized( c_j_id,
|
|||
$row['jrn_def_id']
|
||||
);
|
||||
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
$MaxLine=pg_NumRows($Res2);
|
||||
for ($e=0;$e < $MaxLine;$e++) {
|
||||
// each line is updated with a sequence
|
||||
$line=pg_fetch_array($Res2,$e);
|
||||
$jr_id=$line['jr_id'];
|
||||
$sql=sprintf ("update jrn set
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
$MaxLine=pg_NumRows($Res2);
|
||||
for ($e=0;$e < $MaxLine;$e++) {
|
||||
// each line is updated with a sequence
|
||||
$line=pg_fetch_array($Res2,$e);
|
||||
$jr_id=$line['jr_id'];
|
||||
$sql=sprintf ("update jrn set
|
||||
jr_opid = (select nextval('s_jrn_%d'))
|
||||
where jr_id =%d",
|
||||
$row['jrn_def_id'],
|
||||
$jr_id);
|
||||
$Ret=ExecSql($p_cn,$sql);
|
||||
if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
}
|
||||
}
|
||||
// Put jr_c_opid in centralized
|
||||
// for each jrn_def_id
|
||||
// get the op related to that jrn_def_id
|
||||
$sql=sprintf("select jr_id from jrn
|
||||
$row['jrn_def_id'],
|
||||
$jr_id);
|
||||
$Ret=ExecSql($p_cn,$sql);
|
||||
|
||||
}
|
||||
}
|
||||
// Put jr_c_opid in centralized
|
||||
// for each jrn_def_id
|
||||
// get the op related to that jrn_def_id
|
||||
$sql=sprintf("select jr_id from jrn
|
||||
where
|
||||
jr_tech_per=%d
|
||||
order by jr_date,jr_grpt_id desc",
|
||||
$p_periode
|
||||
);
|
||||
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
$MaxLine=pg_NumRows($Res2);
|
||||
for ($e=0;$e < $MaxLine;$e++) {
|
||||
// each line is updated with a sequence
|
||||
$line=pg_fetch_array($Res2,$e);
|
||||
$jr_id=$line['jr_id'];
|
||||
$sql=sprintf ("update jrn set
|
||||
$p_periode
|
||||
);
|
||||
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
$MaxLine=pg_NumRows($Res2);
|
||||
for ($e=0;$e < $MaxLine;$e++) {
|
||||
// each line is updated with a sequence
|
||||
$line=pg_fetch_array($Res2,$e);
|
||||
$jr_id=$line['jr_id'];
|
||||
$sql=sprintf ("update jrn set
|
||||
jr_c_opid = (select nextval('s_central'))
|
||||
where jr_id =%d",
|
||||
$jr_id);
|
||||
$Ret=ExecSql($p_cn,$sql);
|
||||
if ($Ret==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
}
|
||||
// Set the order of the jrn
|
||||
$Res=ExecSql($p_cn,"select c_id from centralized
|
||||
$jr_id);
|
||||
$Ret=ExecSql($p_cn,$sql);
|
||||
}
|
||||
// Set the order of the jrn
|
||||
$Res=ExecSql($p_cn,"select c_id from centralized
|
||||
inner join jrn on c_grp = jr_grpt_id
|
||||
order by jr_c_opid, c_debit desc");
|
||||
for ( $e=0;$e < pg_NumRows($Res);$e++) {
|
||||
$row=pg_fetch_array($Res,$e);
|
||||
$sql=sprintf ("update centralized set
|
||||
for ( $e=0;$e < pg_NumRows($Res);$e++) {
|
||||
$row=pg_fetch_array($Res,$e);
|
||||
$sql=sprintf ("update centralized set
|
||||
c_order = (select nextval('s_central_order'))
|
||||
where c_id = %d",$row['c_id']);
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
if ($Res2==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
$Res2=ExecSql($p_cn,$sql);
|
||||
|
||||
}
|
||||
ExecSql($p_cn,"update parm_periode set p_central=true where p_id=$p_periode");
|
||||
}
|
||||
if ( ExecSql($p_cn,"update parm_periode set p_central=true where p_id=$p_periode") == false)
|
||||
{ rollback($p_cn); EndSql($p_cn); return ERROR;}
|
||||
|
||||
catch(Exception $e)
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage);
|
||||
rollback($p_cn);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -93,9 +93,8 @@ class action
|
|||
* it is a new document
|
||||
*
|
||||
* \param $p_view if set to true the form will be in readonly mode
|
||||
* \\param $p_gen true we show the tag for generating a doc
|
||||
* \todo change this parameter by UPD : ag_ref and document type are read only,
|
||||
* the other are writable, NEW: everything is writable, READ readonly mode
|
||||
* \param $p_gen true we show the tag for generating a doc
|
||||
*
|
||||
* \note update the reference number or the document type is not allowed
|
||||
*
|
||||
*
|
||||
|
|
@ -108,25 +107,25 @@ class action
|
|||
|
||||
|
||||
if ( $p_view=='UPD')
|
||||
{
|
||||
$upd=true;
|
||||
$readonly=false;
|
||||
}
|
||||
{
|
||||
$upd=true;
|
||||
$readonly=false;
|
||||
}
|
||||
elseif ($p_view=="NEW")
|
||||
{
|
||||
$upd=false;
|
||||
$readonly=false;
|
||||
}
|
||||
{
|
||||
$upd=false;
|
||||
$readonly=false;
|
||||
}
|
||||
elseif ($p_view=='READ')
|
||||
{
|
||||
$upd=true;
|
||||
$readonly=true;
|
||||
}
|
||||
{
|
||||
$upd=true;
|
||||
$readonly=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
exit('class_action'.__LINE__.'Action::Display error unknown parameter'.$p_view);
|
||||
|
||||
}
|
||||
{
|
||||
exit('class_action'.__LINE__.'Action::Display error unknown parameter'.$p_view);
|
||||
|
||||
}
|
||||
// Compute the widget
|
||||
// Date
|
||||
$date=new widget("text");
|
||||
|
|
@ -161,6 +160,7 @@ class action
|
|||
$desc->heigh=250;
|
||||
$desc->name="ag_comment";
|
||||
$desc->readonly=$readonly;
|
||||
/*!\todo Formatstring and urldecode ?? */
|
||||
$desc->value=FormatString(urldecode($this->ag_comment));
|
||||
|
||||
// state
|
||||
|
|
@ -209,7 +209,8 @@ class action
|
|||
$title=new widget("text");
|
||||
$title->readonly=$readonly;
|
||||
$title->name="ag_title";
|
||||
$title->value=FormatString($this->ag_title);
|
||||
// $title->value=FormatString($this->ag_title);
|
||||
$title->value=$this->ag_title;
|
||||
$title->size=80;
|
||||
|
||||
// ag_ref
|
||||
|
|
@ -376,12 +377,12 @@ class action
|
|||
{
|
||||
echo_debug('class_action',__LINE__,'confirm() :'.var_export($_POST,true));
|
||||
echo_debug('class_action',__LINE__,'confirm $this :'.var_export($this,true));
|
||||
/*! \todo add the hour */
|
||||
|
||||
if ( isDate($this->ag_timestamp) == null )
|
||||
{
|
||||
// if the date is invalid, default date is today
|
||||
$this->ag_timestamp=date("d.m.Y");
|
||||
}
|
||||
{
|
||||
// if the date is invalid, default date is today
|
||||
$this->ag_timestamp=date("d.m.Y");
|
||||
}
|
||||
// Compute the widget
|
||||
// Date
|
||||
$date=new widget("text");
|
||||
|
|
@ -652,7 +653,6 @@ class action
|
|||
*/
|
||||
function myList($p_filter="",$p_search="")
|
||||
{
|
||||
/*!\todo idea to add a sort */
|
||||
// for the sort
|
||||
$sort="";
|
||||
$image_asc='<IMAGE SRC="image/down.png" border="0" >';
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ require_once('user_common.php');
|
|||
//
|
||||
class Customer extends fiche{
|
||||
|
||||
var $poste; /*! \enum $poste poste comptable */
|
||||
var $name; /*! \enum $name name of the company */
|
||||
var $street; /*! \enum $street Street */
|
||||
var $country; /*! \enum $country Country */
|
||||
var $cp; /*! \enum $cp Zip code */
|
||||
var $vat_number; /*! \enum $vat_number vat number */
|
||||
var $poste; /*!< $poste poste comptable */
|
||||
var $name; /*!< $name name of the company */
|
||||
var $street; /*!< $street Street */
|
||||
var $country; /*!< $country Country */
|
||||
var $cp; /*!< $cp Zip code */
|
||||
var $vat_number; /*!< $vat_number vat number */
|
||||
|
||||
/*! \brief Constructor
|
||||
/* only a db connection is needed */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once('class_own.php');
|
||||
require_once('class_poste.php');
|
||||
require_once('class_action.php');
|
||||
/*! \file
|
||||
* \brief Class Document corresponds to the table document
|
||||
*/
|
||||
|
|
@ -210,13 +211,13 @@ class Document
|
|||
// compute the regex
|
||||
if ( $p_type=='OOo')
|
||||
{
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$lt="<";
|
||||
$gt=">";
|
||||
}
|
||||
else
|
||||
{
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$regex="<<[A-Z]+_*[A-Z]*_*[A-Z]*_*[A-Z]*_*[0-9]*>>";
|
||||
$lt="<";
|
||||
$gt=">";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,71 +105,80 @@ class Document_modele {
|
|||
// if name is empty return immediately
|
||||
if ( trim(strlen($this->md_name))==0)
|
||||
return;
|
||||
// Start transaction
|
||||
StartSql($this->cn);
|
||||
// Save data into the table invoice
|
||||
// if $this->md_id == -1 it means it is a new document model
|
||||
// so first we have to insert it
|
||||
// the name and the type must be set before calling save
|
||||
if ( $this->md_id == -1)
|
||||
try
|
||||
{
|
||||
|
||||
// insert into the table document_modele
|
||||
$this->name=FormatString($this->md_name);
|
||||
$this->md_id=NextSequence($this->cn,'document_modele_md_id_seq');
|
||||
$sql=sprintf("insert into document_modele(md_id,md_name,md_type)
|
||||
// Start transaction
|
||||
StartSql($this->cn);
|
||||
// Save data into the table invoice
|
||||
// if $this->md_id == -1 it means it is a new document model
|
||||
// so first we have to insert it
|
||||
// the name and the type must be set before calling save
|
||||
if ( $this->md_id == -1)
|
||||
{
|
||||
|
||||
// insert into the table document_modele
|
||||
$this->name=FormatString($this->md_name);
|
||||
$this->md_id=NextSequence($this->cn,'document_modele_md_id_seq');
|
||||
$sql=sprintf("insert into document_modele(md_id,md_name,md_type)
|
||||
values (%d,'%s',%d)",
|
||||
$this->md_id,$this->name,$this->md_type);
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
// create the sequence for this modele of document
|
||||
$this->md_sequence="document_".NextSequence($this->cn,"document_seq");
|
||||
// if start is not equal to 0 and he's a number than the user
|
||||
// request a number change
|
||||
echo_debug('class_document_modele',__LINE__, "this->start ".$this->start." a number ".isNumber($this->start));
|
||||
|
||||
if ( $this->start != 0 && isNumber($this->start) == 1 )
|
||||
{
|
||||
$sql="alter sequence seq_doc_type_".$this->md_type." restart ".$this->start;
|
||||
ExecSql($this->cn,$sql);
|
||||
$this->md_id,$this->name,$this->md_type);
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
// create the sequence for this modele of document
|
||||
$this->md_sequence="document_".NextSequence($this->cn,"document_seq");
|
||||
// if start is not equal to 0 and he's a number than the user
|
||||
// request a number change
|
||||
echo_debug('class_document_modele',__LINE__, "this->start ".$this->start." a number ".isNumber($this->start));
|
||||
|
||||
if ( $this->start != 0 && isNumber($this->start) == 1 )
|
||||
{
|
||||
$sql="alter sequence seq_doc_type_".$this->md_type." restart ".$this->start;
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
|
||||
}
|
||||
// Save the file
|
||||
$new_name=tempnam($_ENV['TMP'],'document_');
|
||||
echo_debug('class_document_modele.php',__LINE__,"new name=".$new_name);
|
||||
if ( strlen ($_FILES['doc']['tmp_name']) != 0 )
|
||||
{
|
||||
if (move_uploaded_file($_FILES['doc']['tmp_name'],
|
||||
$new_name))
|
||||
{
|
||||
// echo "Image saved";
|
||||
$oid= pg_lo_import($this->cn,$new_name);
|
||||
if ( $oid == false )
|
||||
{
|
||||
echo_error('class_document_modele.php',__LINE__,"cannot upload document");
|
||||
Rollback($cn);
|
||||
return;
|
||||
}
|
||||
echo_debug('class_document_modele.php',__LINE__,"Loading document");
|
||||
// Remove old document
|
||||
$ret=ExecSql($this->cn,"select md_lob from document_modele where md_id=".$this->md_id);
|
||||
if (pg_num_rows($ret) != 0)
|
||||
{
|
||||
$r=pg_fetch_array($ret,0);
|
||||
$old_oid=$r['md_lob'];
|
||||
if (strlen($old_oid) != 0)
|
||||
pg_lo_unlink($this->cn,$old_oid);
|
||||
}
|
||||
// Load new document
|
||||
ExecSql($this->cn,"update document_modele set md_lob=".$oid.", md_mimetype='".$_FILES['doc']['type']."' ,md_filename='".$_FILES['doc']['name']."' where md_id=".$this->md_id);
|
||||
Commit($this->cn);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<H1>Error</H1>";
|
||||
Rollback($this->cn);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Save the file
|
||||
$new_name=tempnam($_ENV['TMP'],'document_');
|
||||
echo_debug('class_document_modele.php',__LINE__,"new name=".$new_name);
|
||||
if ( strlen ($_FILES['doc']['tmp_name']) != 0 )
|
||||
catch (Exception $e)
|
||||
{
|
||||
if (move_uploaded_file($_FILES['doc']['tmp_name'],
|
||||
$new_name))
|
||||
{
|
||||
// echo "Image saved";
|
||||
$oid= pg_lo_import($this->cn,$new_name);
|
||||
if ( $oid == false )
|
||||
{
|
||||
echo_error('class_document_modele.php',__LINE__,"cannot upload document");
|
||||
Rollback($cn);
|
||||
return;
|
||||
}
|
||||
echo_debug('class_document_modele.php',__LINE__,"Loading document");
|
||||
// Remove old document
|
||||
$ret=ExecSql($this->cn,"select md_lob from document_modele where md_id=".$this->md_id);
|
||||
if (pg_num_rows($ret) != 0)
|
||||
{
|
||||
$r=pg_fetch_array($ret,0);
|
||||
$old_oid=$r['md_lob'];
|
||||
if (strlen($old_oid) != 0)
|
||||
pg_lo_unlink($this->cn,$old_oid);
|
||||
}
|
||||
// Load new document
|
||||
ExecSql($this->cn,"update document_modele set md_lob=".$oid.", md_mimetype='".$_FILES['doc']['type']."' ,md_filename='".$_FILES['doc']['name']."' where md_id=".$this->md_id);
|
||||
Commit($this->cn);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<H1>Error</H1>";
|
||||
Rollback($this->cn);
|
||||
exit;
|
||||
}
|
||||
echo_debug(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage);
|
||||
rollback($p_cn);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
/*!
|
||||
|
|
@ -281,4 +290,4 @@ class Document_modele {
|
|||
}
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
46
include/class_dossier.php
Normal file
46
include/class_dossier.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file the class for the dossier
|
||||
*/
|
||||
|
||||
/* \brief manage the current dossier
|
||||
*
|
||||
*/
|
||||
class dossier {
|
||||
var $id;
|
||||
|
||||
function dossier() {
|
||||
if ( ! isset ($_REQUEST['gDossier'])){
|
||||
echo_error ('Dossier Invalide');
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->id=$_REQUEST['gDossier'];
|
||||
}
|
||||
function get() {
|
||||
return $this->id;
|
||||
}
|
||||
function hidden {
|
||||
return '<input type="hidden" name="gDossier" value="'.$this->id.'">';
|
||||
}
|
||||
}
|
||||
|
|
@ -37,12 +37,12 @@ require_once('class_widget.php');
|
|||
// class fiche
|
||||
//-----------------------------------------------------
|
||||
class fiche {
|
||||
var $cn; /*! \enum $cn database connection */
|
||||
var $id; /*! \enum $id fiche.f_id */
|
||||
var $fiche_def; /*! \enum $fiche_def fd_id */
|
||||
var $attribut; /*! \enum $attribut array of attribut object */
|
||||
var $fiche_def_ref; /*!\enum $fiche_def_ref Type of the card here always FICHE_TYPE_CONTACT */
|
||||
var $row; /*! \enum All the row from the ledgers */
|
||||
var $cn; /*! < $cn database connection */
|
||||
var $id; /*! < $id fiche.f_id */
|
||||
var $fiche_def; /*! < $fiche_def fd_id */
|
||||
var $attribut; /*! < $attribut array of attribut object */
|
||||
var $fiche_def_ref; /*!< $fiche_def_ref Type */
|
||||
var $row; /*! < All the row from the ledgers */
|
||||
function fiche($p_cn,$p_id=0) {
|
||||
$this->cn=$p_cn;
|
||||
$this->id=$p_id;
|
||||
|
|
@ -51,7 +51,8 @@ class fiche {
|
|||
* \brief Retrieve a card thx his quick_code
|
||||
* complete the object
|
||||
* \param $p_qcode quick_code (ad_id=23)
|
||||
* \param $p_all retrieve all the attribut of the card, possible value are true false
|
||||
* \param $p_all retrieve all the attribut of the card, possible value
|
||||
* are true, false retrieve only the f_id
|
||||
* \return 0 success 1 error not found
|
||||
*/
|
||||
|
||||
|
|
@ -423,101 +424,107 @@ class fiche {
|
|||
$this->id=$fiche_id;
|
||||
// first we create the card
|
||||
StartSql($this->cn);
|
||||
$sql=sprintf("insert into fiche(f_id,fd_id)".
|
||||
" values (%d,%d)",
|
||||
$fiche_id,$p_fiche_def);
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
// parse the $_POST array
|
||||
foreach ($_POST as $name=>$value )
|
||||
try
|
||||
{
|
||||
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
|
||||
list ($id) = sscanf ($name,"av_text%d");
|
||||
if ( $id == null ) continue;
|
||||
echo_debug("class_fiche",__LINE__,"add $id");
|
||||
|
||||
// Special traitement
|
||||
// quickcode
|
||||
if ( $id == ATTR_DEF_QUICKCODE)
|
||||
$sql=sprintf("insert into fiche(f_id,fd_id)".
|
||||
" values (%d,%d)",
|
||||
$fiche_id,$p_fiche_def);
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
// parse the $_POST array
|
||||
foreach ($_POST as $name=>$value )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_QUICKCODE");
|
||||
$sql=sprintf("select insert_quick_code(%d,'%s')",
|
||||
$fiche_id,FormatString($value));
|
||||
ExecSql($this->cn,$sql);
|
||||
continue;
|
||||
}
|
||||
// name
|
||||
if ( $id == ATTR_DEF_NAME )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_NAME");
|
||||
if ( strlen(trim($value)) == 0 )
|
||||
$value="pas de nom";
|
||||
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
|
||||
list ($id) = sscanf ($name,"av_text%d");
|
||||
if ( $id == null ) continue;
|
||||
echo_debug("class_fiche",__LINE__,"add $id");
|
||||
|
||||
}
|
||||
// account
|
||||
if ( $id == ATTR_DEF_ACCOUNT )
|
||||
{
|
||||
echo_debug("insert ATTR_DEF_ACCOUNT");
|
||||
$v=FormatString($value);
|
||||
ob_start();
|
||||
if (
|
||||
isNumber($v) == 1
|
||||
)
|
||||
// Special traitement
|
||||
// quickcode
|
||||
if ( $id == ATTR_DEF_QUICKCODE)
|
||||
{
|
||||
$sql=sprintf("select account_insert(%d,%f)",
|
||||
$this->id,$v);
|
||||
echo_debug("Modify ATTR_DEF_QUICKCODE");
|
||||
$sql=sprintf("select insert_quick_code(%d,'%s')",
|
||||
$fiche_id,FormatString($value));
|
||||
ExecSql($this->cn,$sql);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
// name
|
||||
if ( $id == ATTR_DEF_NAME )
|
||||
{
|
||||
$sql=sprintf("select account_insert(%d,null)",
|
||||
$this->id);
|
||||
echo_debug("Modify ATTR_DEF_NAME");
|
||||
if ( strlen(trim($value)) == 0 )
|
||||
$value="pas de nom";
|
||||
|
||||
}
|
||||
$ret=ExecSql($this->cn,$sql,false);
|
||||
ob_end_clean();
|
||||
if ( $ret == false ) {
|
||||
echo "<span class=\"error\"Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulé</span>";
|
||||
Rollback($this->cn);
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// TVA
|
||||
if ( $id == ATTR_DEF_TVA )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_TVA");
|
||||
// Verify if the rate exists, if not then do not update
|
||||
if ( strlen(trim($value)) != 0 )
|
||||
// account
|
||||
if ( $id == ATTR_DEF_ACCOUNT )
|
||||
{
|
||||
if ( CountSql($this->cn,"select * from tva_rate where tva_id=".$value) == 0)
|
||||
echo_debug("insert ATTR_DEF_ACCOUNT");
|
||||
$v=FormatString($value);
|
||||
try {
|
||||
if (
|
||||
isNumber($v) == 1
|
||||
)
|
||||
{
|
||||
$sql=sprintf("select account_insert(%d,%f)",
|
||||
$this->id,$v);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql=sprintf("select account_insert(%d,null)",
|
||||
$this->id);
|
||||
}
|
||||
ExecSql($this->cn,$sql,false);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception ("Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulée",
|
||||
1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// TVA
|
||||
if ( $id == ATTR_DEF_TVA )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_TVA");
|
||||
// Verify if the rate exists, if not then do not update
|
||||
if ( strlen(trim($value)) != 0 )
|
||||
{
|
||||
echo_debug("class_fiche",__LINE__,"Tva invalide $value");
|
||||
continue;
|
||||
if ( CountSql($this->cn,"select * from tva_rate where tva_id=".$value) == 0)
|
||||
{
|
||||
echo_debug("class_fiche",__LINE__,"Tva invalide $value");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The contact has a company attribut
|
||||
if ( $id == ATTR_DEF_COMPANY )
|
||||
{
|
||||
$exist=CountSql($this->cn,"select f_id from fiche join fiche_def using (fd_id) ".
|
||||
" join jnt_fic_att_value using (f_id) join attr_value using (jft_id) ".
|
||||
" where frd_id in (8,9,14) and ad_id=".ATTR_DEF_QUICKCODE.
|
||||
" and av_text='".FormatString($value)."'");
|
||||
if ( $exist == 0 && FormatString($value) != null )
|
||||
// The contact has a company attribut
|
||||
if ( $id == ATTR_DEF_COMPANY )
|
||||
{
|
||||
$value="";
|
||||
$exist=CountSql($this->cn,"select f_id from fiche join fiche_def using (fd_id) ".
|
||||
" join jnt_fic_att_value using (f_id) join attr_value using (jft_id) ".
|
||||
" where frd_id in (8,9,14) and ad_id=".ATTR_DEF_QUICKCODE.
|
||||
" and av_text='".FormatString($value)."'");
|
||||
if ( $exist == 0 && FormatString($value) != null )
|
||||
{
|
||||
$value="";
|
||||
}
|
||||
}
|
||||
// Normal traitement
|
||||
$value2=FormatString($value);
|
||||
|
||||
$sql=sprintf("select attribut_insert(%d,%d,'%s')",
|
||||
$fiche_id,$id,trim($value2));
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
// Normal traitement
|
||||
$value2=FormatString($value);
|
||||
|
||||
$sql=sprintf("select attribut_insert(%d,%d,'%s')",
|
||||
$fiche_id,$id,trim($value2));
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
echo '<span class="error">'.
|
||||
$e->getMessage().
|
||||
'</span>';
|
||||
Rollback($this->cn);
|
||||
return;
|
||||
}
|
||||
Commit($this->cn);
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -527,136 +534,137 @@ class fiche {
|
|||
*/
|
||||
function update()
|
||||
{
|
||||
// parse the $_POST array
|
||||
foreach ($_POST as $name=>$value )
|
||||
{
|
||||
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
|
||||
list ($id) = sscanf ($name,"av_text%d");
|
||||
if ( $id == null ) continue;
|
||||
echo_debug("class_fiche",__LINE__,"modify $id");
|
||||
|
||||
// retrieve jft_id to update table attr_value
|
||||
$sql=" select jft_id from jnt_fic_att_value where ad_id=$id and f_id=$this->id";
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
if ( pg_NumRows($Ret) != 1 ) {
|
||||
// we need to insert this new attribut
|
||||
echo_debug ("class_fiche ".__LINE__." adding id !!! ");
|
||||
$jft_id=NextSequence($this->cn,'s_jnt_fic_att_value');
|
||||
|
||||
$sql2=sprintf("insert into jnt_fic_att_value(jft_id,ad_id,f_id) values (%s,%s,%s)",
|
||||
$jft_id,$id,$this->id);
|
||||
|
||||
$ret2=ExecSql($this->cn,$sql2);
|
||||
// insert a null value for this attribut
|
||||
$sql3=sprintf("insert into attr_value(jft_id,av_text) values (%s,null)",
|
||||
$jft_id);
|
||||
$ret3=ExecSql($this->cn,$sql3);
|
||||
} else
|
||||
{
|
||||
try {
|
||||
StartSql($this->cn);
|
||||
// parse the $_POST array
|
||||
foreach ($_POST as $name=>$value )
|
||||
{
|
||||
echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ;
|
||||
list ($id) = sscanf ($name,"av_text%d");
|
||||
if ( $id == null ) continue;
|
||||
echo_debug("class_fiche",__LINE__,"modify $id");
|
||||
|
||||
// retrieve jft_id to update table attr_value
|
||||
$sql=" select jft_id from jnt_fic_att_value where ad_id=$id and f_id=$this->id";
|
||||
$Ret=ExecSql($this->cn,$sql);
|
||||
if ( pg_NumRows($Ret) != 1 ) {
|
||||
// we need to insert this new attribut
|
||||
echo_debug ("class_fiche ".__LINE__." adding id !!! ");
|
||||
$jft_id=NextSequence($this->cn,'s_jnt_fic_att_value');
|
||||
|
||||
$sql2=sprintf("insert into jnt_fic_att_value(jft_id,ad_id,f_id) values (%s,%s,%s)",
|
||||
$jft_id,$id,$this->id);
|
||||
|
||||
$ret2=ExecSql($this->cn,$sql2);
|
||||
// insert a null value for this attribut
|
||||
$sql3=sprintf("insert into attr_value(jft_id,av_text) values (%s,null)",
|
||||
$jft_id);
|
||||
$ret3=ExecSql($this->cn,$sql3);
|
||||
} else
|
||||
{
|
||||
$tmp=pg_fetch_array($Ret,0);
|
||||
$jft_id=$tmp['jft_id'];
|
||||
}
|
||||
// Special traitement
|
||||
// quickcode
|
||||
if ( $id == ATTR_DEF_QUICKCODE)
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_QUICKCODE");
|
||||
$sql=sprintf("select update_quick_code(%d,'%s')",
|
||||
$jft_id,FormatString($value));
|
||||
ExecSql($this->cn,$sql);
|
||||
continue;
|
||||
}
|
||||
// Special traitement
|
||||
// quickcode
|
||||
if ( $id == ATTR_DEF_QUICKCODE)
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_QUICKCODE");
|
||||
$sql=sprintf("select update_quick_code(%d,'%s')",
|
||||
$jft_id,FormatString($value));
|
||||
ExecSql($this->cn,$sql);
|
||||
continue;
|
||||
}
|
||||
// name
|
||||
if ( $id == ATTR_DEF_NAME )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_NAME");
|
||||
echo_debug("Value = $v");
|
||||
if ( strlen(trim($value)) == 0 )
|
||||
continue;
|
||||
|
||||
echo_debug("Value = $v");
|
||||
// name
|
||||
if ( $id == ATTR_DEF_NAME )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_NAME");
|
||||
if ( strlen(trim($value)) == 0 )
|
||||
continue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// account
|
||||
if ( $id == ATTR_DEF_ACCOUNT )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_ACCOUNT");
|
||||
$v=FormatString($value);
|
||||
echo_debug("Value = $v");
|
||||
if ( isNumber($v) == 1 )
|
||||
{
|
||||
ob_start();
|
||||
|
||||
$sql=sprintf("select account_update(%d,%d)",
|
||||
$this->id,$v);
|
||||
$Ret=ExecSql($this->cn,$sql,false);
|
||||
|
||||
ob_end_clean();
|
||||
if ( $Ret == false ) {
|
||||
echo "<span class=\"error\">Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulée</span>";
|
||||
Rollback($this->cn);
|
||||
return;
|
||||
}
|
||||
|
||||
// account
|
||||
if ( $id == ATTR_DEF_ACCOUNT )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_ACCOUNT");
|
||||
$v=FormatString($value);
|
||||
echo_debug("Value = $v");
|
||||
if ( isNumber($v) == 1 )
|
||||
{
|
||||
$sql=sprintf("select account_update(%d,%d)",
|
||||
$this->id,$v);
|
||||
try {
|
||||
ExecSql($this->cn,$sql,false);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception(__LINE__."Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulée");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ( strlen (trim($v)) == 0 )
|
||||
if ( strlen (trim($v)) == 0 )
|
||||
{
|
||||
|
||||
$sql=sprintf("select account_update(%d,null)",
|
||||
$this->id);
|
||||
$Ret=ExecSql($this->cn,$sql,false);
|
||||
|
||||
ob_end_clean();
|
||||
if ( $Ret == false ) {
|
||||
echo "<span class=\"error\">Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulée</span>";
|
||||
Rollback($this->cn);
|
||||
return;
|
||||
try {
|
||||
$Ret=ExecSql($this->cn,$sql,false);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception(__LINE__."Erreur : ce compte [$v] n'a pas de compte parent.".
|
||||
"L'opération est annulée");
|
||||
}
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// TVA
|
||||
if ( $id == ATTR_DEF_TVA )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_TVA");
|
||||
// Verify if the rate exists, if not then do not update
|
||||
if ( strlen(trim($value)) != 0 )
|
||||
{
|
||||
if ( CountSql($this->cn,"select * from tva_rate where tva_id=".$value) == 0)
|
||||
{
|
||||
echo_debug("class_fiche",__LINE__,"Tva invalide $value");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $id == ATTR_DEF_COMPANY )
|
||||
{
|
||||
$exist=CountSql($this->cn,"select f_id from fiche join fiche_def using (fd_id) ".
|
||||
" join jnt_fic_att_value using (f_id) join attr_value using (jft_id) ".
|
||||
// TVA
|
||||
if ( $id == ATTR_DEF_TVA )
|
||||
{
|
||||
echo_debug("Modify ATTR_DEF_TVA");
|
||||
// Verify if the rate exists, if not then do not update
|
||||
if ( strlen(trim($value)) != 0 )
|
||||
{
|
||||
if ( CountSql($this->cn,"select * from tva_rate where tva_id=".$value) == 0)
|
||||
{
|
||||
echo_debug("class_fiche",__LINE__,"Tva invalide $value");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $id == ATTR_DEF_COMPANY )
|
||||
{
|
||||
$exist=CountSql($this->cn,"select f_id from fiche join fiche_def using (fd_id) ".
|
||||
" join jnt_fic_att_value using (f_id) join attr_value using (jft_id) ".
|
||||
" where frd_id in (8,9,14) and ad_id=".ATTR_DEF_QUICKCODE.
|
||||
" and av_text='".FormatString($value)."'");
|
||||
|
||||
|
||||
if ( $exist == 0 && FormatString($value) != null )
|
||||
{
|
||||
$value="Attention : pas de société ";
|
||||
}
|
||||
}
|
||||
|
||||
// Normal traitement
|
||||
$value2=FormatString($value);
|
||||
$sql=sprintf("update attr_value set av_text='%s' where jft_id=%d",
|
||||
trim($value2),$jft_id);
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
" and av_text='".FormatString($value)."'");
|
||||
|
||||
|
||||
if ( $exist == 0 && FormatString($value) != null )
|
||||
{
|
||||
$value="Attention : pas de société ";
|
||||
}
|
||||
}
|
||||
|
||||
// Normal traitement
|
||||
$value2=FormatString($value);
|
||||
$sql=sprintf("update attr_value set av_text='%s' where jft_id=%d",
|
||||
trim($value2),$jft_id);
|
||||
ExecSql($this->cn,$sql);
|
||||
}
|
||||
} catch (Exception $e ) {
|
||||
echo '<span class="error">'.
|
||||
$e->getMessage().
|
||||
'</span>';
|
||||
Rollback($this->cn);
|
||||
return;
|
||||
}
|
||||
Commit($this->cn);
|
||||
return;
|
||||
|
||||
}
|
||||
/*!\brief remove a card
|
||||
*/
|
||||
/*!\brief remove a card
|
||||
*/
|
||||
function remove()
|
||||
{
|
||||
if ( $this->id==0 ) return;
|
||||
|
|
@ -737,7 +745,8 @@ class fiche {
|
|||
{
|
||||
return fiche::GetByDef($this->fiche_def_ref,$p_offset,$p_search);
|
||||
}
|
||||
/*!\brief retrieve the frd_id of the fiche
|
||||
/*!\brief retrieve the frd_id of the fiche it is the type of the
|
||||
* card (bank, purchase...)
|
||||
* (fiche_def_ref primary key)
|
||||
*/
|
||||
function get_fiche_def_ref_id()
|
||||
|
|
@ -931,7 +940,5 @@ function GetSoldeDetail($p_cond="") {
|
|||
else
|
||||
$this->fd_id=$R;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
82
include/class_gestion_purchase.php
Normal file
82
include/class_gestion_purchase.php
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file concern the table quant_sold
|
||||
*/
|
||||
|
||||
/*! \brief this object handles the table quant_purchase
|
||||
*
|
||||
*/
|
||||
require_once ('class_gestion_table.php');
|
||||
|
||||
|
||||
class gestion_purchase extends gestion_table
|
||||
{
|
||||
var $qp_id; /*!< id */
|
||||
var $qp_internal; /*!< internal code */
|
||||
var $qp_fiche; /*!< card id (fiche.f_id) */
|
||||
var $qp_quantite; /*!< quantity */
|
||||
var $qp_price; /*!< quantity */
|
||||
var $qp_vat; /*!< vat amount */
|
||||
var $qp_vat_code; /*!< vat_code */
|
||||
var $qp_nd_amount; /*!< no deductible */
|
||||
var $qp_nd_tva; /*!< tva not deductible */
|
||||
var $qp_nd_tva_recup; /*!< tva ded via taxe */
|
||||
var $qp_supplier; /*!< supplier code (f_id) */
|
||||
var $qp_valid;
|
||||
var $j_id; /*!< jrnx.j_id */
|
||||
/*!\brief return an array of gestion_table, the object are
|
||||
* retrieved thanks the qs_internal
|
||||
*/
|
||||
function get_list() {
|
||||
if ($this->qp_internal=="")
|
||||
exit (__FILE__.__LINE__." qs_internal est vide");
|
||||
$sql="select qp_id,
|
||||
qp_internal,
|
||||
qp_fiche,
|
||||
qp_quantite,
|
||||
qp_price,
|
||||
qp_vat,
|
||||
qp_vat_code,
|
||||
qp_nd_amount,
|
||||
qp_nd_tva,
|
||||
qp_nd_tva_recup,
|
||||
qp_supplier,
|
||||
j_id
|
||||
from quant_purchase
|
||||
where qp_internal='".$this->qp_internal."'";
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
// $res contains all the line
|
||||
$res=pg_fetch_all($ret);
|
||||
|
||||
if ( sizeof($res)==0) return null;
|
||||
$count=0;
|
||||
foreach ($res as $row) {
|
||||
$t_gestion_purchase=new gestion_purchase($this->db);
|
||||
foreach ($row as $idx=>$value)
|
||||
$t_gestion_purchase->$idx=$value;
|
||||
$array[$count]=clone $t_gestion_purchase;
|
||||
$count++;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
79
include/class_gestion_sold.php
Normal file
79
include/class_gestion_sold.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file concern the table quant_sold
|
||||
*/
|
||||
|
||||
/*! \brief this object handles the table quant_sold
|
||||
*
|
||||
*/
|
||||
/*!\todo the qs_valid field is not used it should be delete into
|
||||
* the table quant_sold
|
||||
*/
|
||||
require_once ('class_gestion_table.php');
|
||||
|
||||
|
||||
class gestion_sold extends gestion_table
|
||||
{
|
||||
var $qs_id; /*!< $qs_id primary key */
|
||||
var $qs_internal; /*!< qs_internal */
|
||||
var $qs_fiche; /*!< f_id code */
|
||||
var $qs_quantite; /*!< quantity of the card */
|
||||
var $qs_price; /*!< price */
|
||||
var $qs_vat; /*!< vat_amount */
|
||||
var $qs_vat_code; /*!< vat_code */
|
||||
var $qs_client; /*!< f_id of the customer */
|
||||
var $qs_valid; /*!< will not be used */
|
||||
var $j_id; /*!< jrnx.j_id */
|
||||
/*!\brief return an array of gestion_table, the object are
|
||||
* retrieved thanks the qs_internal
|
||||
*/
|
||||
function get_list() {
|
||||
if ($this->qs_internal=="")
|
||||
exit (__FILE__.__LINE__." qs_internal est vide");
|
||||
$sql="select qs_id,
|
||||
qs_internal,
|
||||
qs_fiche,
|
||||
qs_quantite,
|
||||
qs_price,
|
||||
qs_vat,
|
||||
qs_vat_code,
|
||||
qs_client,
|
||||
j_id
|
||||
from quant_sold
|
||||
where qs_internal='".$this->qs_internal."'";
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
// $res contains all the line
|
||||
$res=pg_fetch_all($ret);
|
||||
|
||||
if ( sizeof($res)==0) return null;
|
||||
$count=0;
|
||||
foreach ($res as $row) {
|
||||
$t_gestion_sold=new gestion_sold($this->db);
|
||||
foreach ($row as $idx=>$value)
|
||||
$t_gestion_sold->$idx=$value;
|
||||
$array[$count]=clone $t_gestion_sold;
|
||||
$count++;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
36
include/class_gestion_table.php
Normal file
36
include/class_gestion_table.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief
|
||||
*
|
||||
*/
|
||||
class gestion_table
|
||||
{
|
||||
var $db; /*!< $db database connection */
|
||||
/*!\brief contains only the dabase connx */
|
||||
function gestion_table($p_cn) {
|
||||
$this->db=$p_cn;
|
||||
}
|
||||
}
|
||||
185
include/class_groupop.php
Normal file
185
include/class_groupop.php
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/*! \brief group of object operations, used for misc operation
|
||||
*
|
||||
*/
|
||||
require_once ("class_operation.php");
|
||||
require_once ("postgres.php");
|
||||
require_once ("class_widget.php");
|
||||
|
||||
class groupop
|
||||
{
|
||||
var $db; /*!< database connection */
|
||||
var $id; /*!< oa_group, a group contains
|
||||
several rows of
|
||||
operation_analytique linked by the
|
||||
group id */
|
||||
|
||||
var $a_operation; /*!< array of operations */
|
||||
var $date; /*!< date of the operations */
|
||||
var $pa_id; /*!< the concerned pa_id */
|
||||
|
||||
/*!\brief constructor */
|
||||
function groupop($p_cn,$p_id=0)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
$this->date=date("d.m.Y");
|
||||
$this->nMaxRow=10;
|
||||
}
|
||||
/*!\brief add several rows */
|
||||
function add() {
|
||||
/*!\todo add a control to check that the amount are balanced if
|
||||
not throw an exception
|
||||
*/
|
||||
foreach ($this->a_operation as $row) {
|
||||
$row->add();
|
||||
}
|
||||
}
|
||||
/*!\brief show a form for the operation (several rows)
|
||||
* \return the string containing the form but without the form tag
|
||||
*
|
||||
*/
|
||||
function form($p_readonly=0){
|
||||
$wDate=new widget("text","Date : ","pdate",$this->date);
|
||||
$wDate->table=1;
|
||||
$wDate->size=10;
|
||||
$wDate->readonly=$p_readonly;
|
||||
|
||||
$wDescription=new widget("text","Description","pdesc".$i);
|
||||
$wDescription->table=0;
|
||||
$wDescription->size=80;
|
||||
$wDescription->readonly=$p_readonly;
|
||||
// Show an existing operation
|
||||
//
|
||||
if ( isset ($this->a_operation[0])) {
|
||||
$wDate->value=$this->a_operation[0]->oa_date;
|
||||
$wDescription->value=$this->a_operation[0]->oa_description;
|
||||
}
|
||||
|
||||
$wPa_id=new widget("hidden","","pa_id",$this->pa_id);
|
||||
$ret="";
|
||||
$ret.=$wPa_id->IOValue();
|
||||
$ret.='<table style="border: 2px outset blue; width: 100%;" >';
|
||||
// $ret.="<table border=1>";
|
||||
$ret.="<TR>".$wDate->IOValue()."</tr>";
|
||||
$ret.='<tr><td style="border:1px groove blue">Description</td>'.
|
||||
'<td colspan="3">'.
|
||||
$wDescription->IOValue()."</td></tr>";
|
||||
|
||||
/* array of possible value for the select */
|
||||
$aPoste=make_array($this->db,"select po_id as value,po_name||':'||po_description as label".
|
||||
" from poste_analytique ".
|
||||
" where pa_id = ".$this->pa_id.
|
||||
" order by po_name ");
|
||||
|
||||
/* show 10 rows */
|
||||
$ret.="<tr>".
|
||||
"<th> Poste </th>".
|
||||
"<th></th>".
|
||||
"<th> Montant</th>".
|
||||
"<th>Débit</th>".
|
||||
"</tr>";
|
||||
|
||||
for ($i = 0;$i < $this->nMaxRow;$i++)
|
||||
{
|
||||
// init variable
|
||||
$wSelect=new widget("select","","pop".$i);
|
||||
$wSelect->value=$aPoste;
|
||||
$wSelect->table=1;
|
||||
$wSelect->size=12;
|
||||
$wSelect->readonly=$p_readonly;
|
||||
|
||||
$wAmount=new widget("text","","pamount$i",0.0);
|
||||
$wAmount->size=12;
|
||||
$wAmount->table=1;
|
||||
$wAmount->readonly=$p_readonly;
|
||||
|
||||
$wDebit=new widget("checkbox","","pdeb$i");
|
||||
$wDebit->table=1;
|
||||
$wDebit->readonly=$p_readonly;
|
||||
if ( isset ($this->a_operation[$i])) {
|
||||
$wSelect->selected=$this->a_operation[$i]->po_id;
|
||||
$wAmount->value=$this->a_operation[$i]->oa_amount;
|
||||
$wDebit->value=$this->a_operation[$i]->oa_debit;
|
||||
if ( $wDebit->value=='t') { $wDebit->selected=true;}
|
||||
}
|
||||
|
||||
// build the table
|
||||
$ret.="<tr>";
|
||||
$ret.=$wSelect->IOValue();
|
||||
$ret.="<TD></TD>";
|
||||
$ret.=$wAmount->IOValue();
|
||||
$ret.=$wDebit->IOValue();
|
||||
$ret.="</tr>";
|
||||
}
|
||||
$ret.="</table>";
|
||||
return $ret;
|
||||
}
|
||||
/*!\brief fill row from $_POST data
|
||||
*
|
||||
*/
|
||||
function from_POST() {
|
||||
for ( $i = 0;$i <$this->nMaxRow;$i++) {
|
||||
$p=new operation($this->db);
|
||||
$p->po_id=$_POST["pop$i"];
|
||||
$p->oa_amount=$_POST["pamount$i"];
|
||||
|
||||
$p->oa_description=$_POST["pdesc"];
|
||||
$p->oa_date=$_POST['pdate'];
|
||||
$p->j_id=0;
|
||||
$p->oa_debit=(isset ($_POST["pdeb$i"]))?'t':'f';
|
||||
$p->oa_group=0;
|
||||
$p->pa_id=$_POST['pa_id'];
|
||||
$this->a_operation[]=clone $p;
|
||||
}
|
||||
}
|
||||
/*!\brief save the group of operation but only if the amount is
|
||||
balanced */
|
||||
function save() {
|
||||
StartSql($this->db);
|
||||
try {
|
||||
$oa_group=NextSequence($this->db,'s_oa_group');
|
||||
for ($i=0;$i<$this->nMaxRow;$i++) {
|
||||
$this->a_operation[$i]->oa_group=$oa_group;
|
||||
$this->a_operation[$i]->add();
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$ex->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
|
||||
}
|
||||
Commit($this->db);
|
||||
}
|
||||
/*!\brief show the form */
|
||||
function show() {
|
||||
return $this->form(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ class jrn {
|
|||
var $name;
|
||||
var $db;
|
||||
var $row;
|
||||
var $type;
|
||||
function jrn ($p_cn,$p_id){
|
||||
$this->id=$p_id;
|
||||
$this->db=$p_cn;
|
||||
|
|
@ -36,7 +37,7 @@ class jrn {
|
|||
* \brief Return the type of a ledger (ACH,VEN,ODS or FIN) or GL
|
||||
*
|
||||
*/
|
||||
function GetType() {
|
||||
function get_type() {
|
||||
if ( $this->id==0 ) {
|
||||
$this->name=" Grand Livre ";
|
||||
$this->type="GL";
|
||||
|
|
@ -95,14 +96,15 @@ class jrn {
|
|||
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
|
||||
|
||||
$cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:"";
|
||||
|
||||
// Grand livre == 0
|
||||
if ( $this->id != 0 ) {
|
||||
|
||||
if ( $cent=='off' ) {
|
||||
echo_debug('class_jrn.php',__LINE__,"journaux non centralisé");
|
||||
// Journaux non centralisés
|
||||
$Res=ExecSql($this->db,"select j_id,j_id as int_j_id,to_char(j_date,'DD.MM.YYYY') as j_date,
|
||||
// retrieve the type
|
||||
$this->get_type();
|
||||
// Grand livre == 0
|
||||
if ( $this->id != 0 ) {
|
||||
|
||||
if ( $cent=='off' ) {
|
||||
echo_debug('class_jrn.php',__LINE__,"journaux non centralisé");
|
||||
// Journaux non centralisés
|
||||
$Res=ExecSql($this->db,"select j_id,j_id as int_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,
|
||||
case j_debit when 'f' then j_montant::text else ' ' end as cred_montant,
|
||||
|
|
@ -168,7 +170,6 @@ class jrn {
|
|||
// Centralisé
|
||||
$Sql="select jr_c_opid as j_id,
|
||||
c_order as int_j_id,
|
||||
|
||||
c_j_id,
|
||||
to_char (c_date,'DD.MM.YYYY') as j_date ,
|
||||
c_internal as jr_internal,
|
||||
|
|
@ -177,10 +178,10 @@ class jrn {
|
|||
c_debit as j_debit,
|
||||
c_poste as poste,
|
||||
pcm_lib as description,
|
||||
jr_comment||' ('||c_internal||')' as jr_comment,
|
||||
jr_comment||' ('||c_internal||'/ PJ :'||jr_opid||')' as jr_comment,
|
||||
jr_montant,
|
||||
c_grp as grp,
|
||||
c_comment||' ('||c_internal||')' as comment,
|
||||
c_comment||' ('||c_internal||' '||jr_opid||')' as comment,
|
||||
c_rapt as oc,
|
||||
c_periode as periode
|
||||
from centralized left join jrn on ".
|
||||
|
|
@ -200,16 +201,19 @@ class jrn {
|
|||
$case="";
|
||||
$tot_deb=0;
|
||||
$tot_cred=0;
|
||||
$row=pg_fetch_all($Res);
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$fiche=new fiche($this->db);
|
||||
$line=pg_fetch_array($Res,$i);
|
||||
$line=$row[$i];
|
||||
$mont_deb=($line['deb_montant']!=0)?sprintf("% 8.2f",$line['deb_montant']):"";
|
||||
$mont_cred=($line['cred_montant']!=0)?sprintf("% 8.2f",$line['cred_montant']):"";
|
||||
$jr_montant=($line['jr_montant']!=0)?sprintf("% 8.2f",$line['jr_montant']):"";
|
||||
$tot_deb+=$line['deb_montant'];
|
||||
$tot_cred+=$line['cred_montant'];
|
||||
$tot_op=$line['jr_amount'];
|
||||
echo_debug('class_jrn.php',__LINE__," GetRow : mont_Deb ".$mont_deb);
|
||||
echo_debug('class_jrn.php',__LINE__," GetRow : mont_cred ".$mont_cred);
|
||||
|
||||
/* Check first if there is a quickcode */
|
||||
if ( strlen(trim($line['j_qcode'])) != 0 )
|
||||
{
|
||||
|
|
@ -220,13 +224,32 @@ class jrn {
|
|||
}
|
||||
if ( $case != $line['grp'] ) {
|
||||
$case=$line['grp'];
|
||||
// for financial, we show if the amount is or not in negative
|
||||
if ( $this->type=='FIN') {
|
||||
echo_debug(__FILE__,__LINE__,"Journal FIN");
|
||||
$eMax=(($i+50) < $Max)?$i+50:$Max;
|
||||
// check in $row if the BQE is in deb or cred
|
||||
for ($e=$i;$e<$Max;$e++) {
|
||||
echo_debug(__FILE__,__LINE__,$row[$e]);
|
||||
if ( $row[$e]['grp'] != $case ) continue;
|
||||
if ( strlen(trim($row[$e]['j_qcode'])) == 0 ) continue;
|
||||
|
||||
$f=new fiche($this->db);
|
||||
$f->GetByQCode($row[$e]['j_qcode'],false);
|
||||
echo_debug(__FILE__,__LINE__,$f);
|
||||
if ( $f->get_fiche_def_ref_id() == FICHE_TYPE_FIN ) {
|
||||
$tot_op=($row[$e]['debit'] == 't')?$jr_montant:" - ".$jr_montant;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$array[]=array (
|
||||
'int_j_id' => $line['int_j_id'],
|
||||
'j_id'=>$line['j_id'],
|
||||
'j_date' => $line['j_date'],
|
||||
'internal'=>$line['jr_internal'],
|
||||
'deb_montant'=>'',
|
||||
'cred_montant'=>'<b><i>'.$jr_montant.'</i></b>',
|
||||
'cred_montant'=>'<b><i>'.$tot_op.'</i></b>',
|
||||
'description'=>'<b><i>'.$line['jr_comment'].'</i></b>',
|
||||
'poste' => $line['oc'],
|
||||
'qcode' => $line['j_qcode'],
|
||||
|
|
@ -340,7 +363,7 @@ class jrn {
|
|||
{
|
||||
return null;
|
||||
}
|
||||
$type=$this->GetType();
|
||||
$type=$this->get_type();
|
||||
// for type ACH and Ven we take more info
|
||||
if ( $type == 'ACH' || $type == 'VEN')
|
||||
{
|
||||
|
|
@ -489,28 +512,28 @@ class jrn {
|
|||
list($tva_deb,$tva_cred)=split(',',$line_tva['tva_poste']);
|
||||
if ( $code['j_poste'] == $tva_deb ||
|
||||
$code['j_poste'] == $tva_cred )
|
||||
{
|
||||
|
||||
// For the reversed operation
|
||||
if ( $p_jrn_type == 'ACH' && $code['j_debit'] == 'f')
|
||||
{
|
||||
$code['j_montant']=-1*$code['j_montant'];
|
||||
}
|
||||
if ( $p_jrn_type == 'VEN' && $code['j_debit'] == 't')
|
||||
{
|
||||
$code['j_montant']=-1*$code['j_montant'];
|
||||
}
|
||||
|
||||
$p_array['AMOUNT_TVA']+=$code['j_montant'];
|
||||
|
||||
$p_array['TVA'][$c]=array($idx_tva,array($line_tva['tva_id'],$line_tva['tva_label'],$code['j_montant']));
|
||||
echo_debug('class_jrn',__LINE__,'Montant TVA = '.$p_array['AMOUNT_TVA']);
|
||||
$c++;
|
||||
|
||||
$idx_tva++;
|
||||
}
|
||||
{
|
||||
|
||||
// For the reversed operation
|
||||
if ( $p_jrn_type == 'ACH' && $code['j_debit'] == 'f')
|
||||
{
|
||||
$code['j_montant']=-1*$code['j_montant'];
|
||||
}
|
||||
if ( $p_jrn_type == 'VEN' && $code['j_debit'] == 't')
|
||||
{
|
||||
$code['j_montant']=-1*$code['j_montant'];
|
||||
}
|
||||
|
||||
$p_array['AMOUNT_TVA']+=$code['j_montant'];
|
||||
|
||||
$p_array['TVA'][$c]=array($idx_tva,array($line_tva['tva_id'],$line_tva['tva_label'],$code['j_montant']));
|
||||
echo_debug('class_jrn',__LINE__,'Montant TVA = '.$p_array['AMOUNT_TVA']);
|
||||
$c++;
|
||||
|
||||
$idx_tva++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// isDNA
|
||||
// If operation is reversed then amount are negatif
|
||||
|
||||
|
|
@ -524,11 +547,11 @@ class jrn {
|
|||
{
|
||||
foreach ($a_TVA as $tva)
|
||||
{
|
||||
if ( $tva['tva_id'] == $linetva[1][0] )
|
||||
{
|
||||
$a=$tva['tva_id'];
|
||||
$a_tva_amount[$a]=$linetva[1][2];
|
||||
}
|
||||
if ( $tva['tva_id'] == $linetva[1][0] )
|
||||
{
|
||||
$a=$tva['tva_id'];
|
||||
$a_tva_amount[$a]=$linetva[1][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($a_TVA as $line_tva)
|
||||
|
|
@ -568,4 +591,43 @@ class jrn {
|
|||
if ( sizeof($Res) == 0 ) return 1;
|
||||
return $Res[0]['value'];
|
||||
}
|
||||
/*!\brief get the saldo of a ledger for a specific period
|
||||
* \param $p_from start period
|
||||
* \param $p_to end period
|
||||
* \param $p_cent 1 for a centralized period otherwise 0
|
||||
*/
|
||||
function get_solde($p_from,$p_to,$p_cent) {
|
||||
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','j_tech_per');
|
||||
|
||||
if ( $this->id != 0 && $p_cent=='off') {
|
||||
$ledger=" and j_jrn_def = ".$this->id;
|
||||
}
|
||||
|
||||
if ( $this->id != 0 && $p_cent=='on') {
|
||||
$ledger=" and c_jrn_def = ".$this->id;
|
||||
}
|
||||
|
||||
// we ask for a specific ledger
|
||||
if ( $p_cent == 'off') {
|
||||
$sql='select j_montant as montant,j_debit as deb from jrnx where '
|
||||
.$periode.$ledger;
|
||||
}else {
|
||||
$sql='select c_montant as montant,c_debit as deb from centralized where '
|
||||
.$periode.$ledger;
|
||||
}
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
$array=pg_fetch_all($ret);
|
||||
$deb=0.0;
|
||||
$cred=0.0;
|
||||
foreach ($array as $line) {
|
||||
|
||||
if ( $line['deb']=='t' )
|
||||
$deb+=$line['montant'];
|
||||
else
|
||||
$cred+=$line['montant'];
|
||||
}
|
||||
$response=array($deb,$cred);
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
243
include/class_operation.php
Normal file
243
include/class_operation.php
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/*! \brief this class is used to show the form for entering an
|
||||
* operation
|
||||
* to save it, to display or to get a list from a certain period
|
||||
*
|
||||
*/
|
||||
class operation
|
||||
{
|
||||
var $db; /*!< database connection */
|
||||
var $row; /*!< array of row for one operation*/
|
||||
var $list; /*!< array of all operation */
|
||||
var $id; /*!< = oa_id (one row) */
|
||||
var $po_id; /*!< poste analytique */
|
||||
var $oa_amount; /*!< amount for one row */
|
||||
var $oa_description; /*!< comment for one row */
|
||||
var $oa_debit; /*!< true for debit or false */
|
||||
var $j_id; /*!< foreign key to a jrnx operation
|
||||
(or null if none */
|
||||
var $oa_group; /*!< group of operation */
|
||||
var $oa_date; /*!< equal to j_date if j_id is not
|
||||
null */
|
||||
var $pa_id; /*!< the plan analytique id */
|
||||
|
||||
/*!\brief constructor
|
||||
*
|
||||
*/
|
||||
function operation ($p_cn,$p_id=0) {
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
}
|
||||
/*!\brief add a row to the table operation_analytique
|
||||
* \note if $this->oa_group if 0 then a sequence id will be computed for
|
||||
* the oa_group, if $this->j_id=0 then it will be null
|
||||
*
|
||||
*/
|
||||
function add($p_seq=0) {
|
||||
|
||||
if ( $this->oa_group == 0) {
|
||||
$this->oa_group=NextSequence($this->db,'s_oa_group');
|
||||
}
|
||||
|
||||
if ( $this->j_id == 0 ) {
|
||||
$this->j_id="null";
|
||||
}
|
||||
|
||||
|
||||
// we don't save null operations
|
||||
if ( $this->oa_amount == 0 )
|
||||
return;
|
||||
$sql='insert into operation_analytique (
|
||||
po_id,
|
||||
pa_id,
|
||||
oa_amount,
|
||||
oa_description,
|
||||
oa_debit,
|
||||
oa_group,
|
||||
j_id,
|
||||
oa_date
|
||||
) values ('.
|
||||
$this->po_id.",".
|
||||
$this->pa_id.",".
|
||||
$this->oa_amount.",".
|
||||
"'".FormatString($this->description)."',".
|
||||
"'".$this->oa_debit."',".
|
||||
$this->oa_group.",".
|
||||
$this->j_id.",".
|
||||
"to_date('".$this->oa_date."','DD.MM.YYYY'))";
|
||||
|
||||
|
||||
ExecSql($this->db,$sql);
|
||||
|
||||
}
|
||||
/*!\brief delete a row from the table operation_analytique
|
||||
* \note be carefull : do not delete a row when we have a group
|
||||
*/
|
||||
function delete() {
|
||||
$sql="delete from operation_analytique where oa_id=".$this->oa_id;
|
||||
|
||||
ExecSql($this->db,$sql);
|
||||
}
|
||||
|
||||
/*!\brief update a row in the table operation_analytique
|
||||
* \todo update
|
||||
*/
|
||||
function update() {
|
||||
$sql="update operation_analytique set po_id=".$this->po_id." where oa_id=".$this->oa_id;
|
||||
ExecSql($this->db,$sql);
|
||||
}
|
||||
|
||||
/*!\brief get a list of row from a certain periode
|
||||
* \todo to be done
|
||||
*/
|
||||
function get_list($p_range="") {
|
||||
|
||||
$sql="select oa_id,po_name,oa_description,".
|
||||
"oa_debit,oa_date,oa_amount,oa_group,j_id ".
|
||||
" from operation_analytique as B".
|
||||
" join poste_analytique using(po_id) ".
|
||||
"where B.pa_id=".$this->pa_id." and oa_amount <> 0.0 ".
|
||||
" order by oa_date ,oa_group,oa_debit,oa_id";
|
||||
$RetSql=ExecSql($this->db,$sql);
|
||||
|
||||
if ( pg_NumRows($RetSql) == 0 )
|
||||
return "Pas d'enregistrement trouvé";
|
||||
|
||||
$array=pg_fetch_all($RetSql);
|
||||
|
||||
$ret.="";
|
||||
$count=0;
|
||||
$group=0;
|
||||
$oldgroup=0;
|
||||
foreach ($array as $row) {
|
||||
$group=$row['oa_group'];
|
||||
if ( $group !=$oldgroup ) {
|
||||
if ( $oldgroup!=0 )
|
||||
{
|
||||
$ret.='<tr><td>'.$row['j_id'].'</td></tr>';
|
||||
//! \todo add a delete and a detail button
|
||||
// result must be displayed thanks ajax
|
||||
$ret.='</table>';
|
||||
|
||||
}
|
||||
$ret.='<table id="'.$row['oa_group'].'" style="border: 2px outset blue; width: 70%;">';
|
||||
// $ret.='<tr><td colspan="4"><hr></td></tr>';
|
||||
$ret.="<td>".
|
||||
"Groupe id : ".$row['oa_group'].
|
||||
"</td>";
|
||||
|
||||
$ret.="<td>".
|
||||
$row['oa_date'].
|
||||
"</td>".
|
||||
"<td>".
|
||||
$row['oa_description'].
|
||||
"</td>";
|
||||
|
||||
$oldgroup=$group;
|
||||
}
|
||||
$class=($count%2==0)?"odd":"";
|
||||
$count++;
|
||||
$cred= ( $row['oa_debit'] == 'f')?"CREDIT":"DEBIT";
|
||||
$ret.="<tr class=\"$class\">";
|
||||
$ret.= "<td>".
|
||||
$row['po_name'].
|
||||
"</td>".
|
||||
"<td>".
|
||||
$row['oa_description'].
|
||||
"</td>".
|
||||
"<td>".
|
||||
$row['oa_amount'].
|
||||
"</td>".
|
||||
"<td>".
|
||||
$cred.
|
||||
"</td>".
|
||||
|
||||
"</tr>";
|
||||
}
|
||||
$ret.="</table>";
|
||||
return $ret;
|
||||
}
|
||||
/*!\brief retrieve an operation thanks a jrnx.j_id
|
||||
* \param the jrnx.j_id
|
||||
* \return false if nothing is found other true
|
||||
*/
|
||||
function get_operation_by_jid($p_jid) {
|
||||
$sql="select oa_id,
|
||||
po_id,
|
||||
oa_amount,
|
||||
oa_description,
|
||||
oa_debit,
|
||||
j_id,
|
||||
oa_group,
|
||||
oa_date,
|
||||
pa_id
|
||||
from operation_analytique
|
||||
where
|
||||
j_id=$p_jid";
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
$res=pg_fetch_all($ret);
|
||||
echo_debug(__FILE__.":".__LINE__."count res is ",count($res));
|
||||
echo_debug(__FILE__.":".__LINE__," res =",$res);
|
||||
if ( $res== false) return null;
|
||||
|
||||
foreach ($res as $row) {
|
||||
$a=new operation($this->db);
|
||||
foreach ( $row as $attr=>$value )
|
||||
{
|
||||
$a->$attr=$row[$attr];
|
||||
}
|
||||
$array[]=clone $a;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
/*!\brief modify an op from modify_op.php
|
||||
*
|
||||
*/
|
||||
function update_from_jrnx($p_po_id){
|
||||
$a=$this->get_operation_by_jid($this->j_id);
|
||||
if ( $a == null ) {
|
||||
// retrieve data from jrnx
|
||||
$sql="select jr_date,j_amount,j_debit from jrnx ".
|
||||
" join jrn using (jr_grpt_id = j_grpt) ".
|
||||
"where j_id=".$this->j_id;
|
||||
$res=ExecSql($this->db,$sql);
|
||||
if (pg_NumRows($res) == 0 ) return;
|
||||
$row=pg_fetch_array($res,0);
|
||||
$this->oa_amount=$row['j_amount'];
|
||||
$this->oa_date=$row['jr_date'];
|
||||
$this->oa_debit=$row['j_debit'];
|
||||
$this->add();
|
||||
} else {
|
||||
foreach ($a as $row ) {
|
||||
if ( $row->pa_id == $this->pa_id ) {
|
||||
$row->po_id=$p_po_id;
|
||||
$row->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -69,7 +69,8 @@ class Own {
|
|||
$this->UpdateRow('MY_PAYS');
|
||||
$this->UpdateRow('MY_COMMUNE');
|
||||
$this->UpdateRow('MY_FAX');
|
||||
$this->UpdateRow('MY_ANALYTIC');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
158
include/class_plananalytic.php
Normal file
158
include/class_plananalytic.php
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/* !\file
|
||||
*/
|
||||
|
||||
/* \brief
|
||||
* Concerns the Analytic class
|
||||
*/
|
||||
require_once("constant.php");
|
||||
require_once("postgres.php");
|
||||
require_once("class_widget.php");
|
||||
require_once("class_poste_analytic.php");
|
||||
|
||||
class PlanAnalytic
|
||||
{
|
||||
var $db; /*!<database connection */
|
||||
var $name; /*!< name plan_analytique.pa_name */
|
||||
var $description; /*!< description of the PA plan_analytique.pa_description*/
|
||||
var $id; /*!< id = plan_analytique.pa_id */
|
||||
|
||||
function PlanAnalytic($p_cn,$p_id=0)
|
||||
{
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
$this->name="";
|
||||
$this->description="";
|
||||
$this->get();
|
||||
}
|
||||
/*!\brief get the list of all existing PA
|
||||
* \return an array of PA (not object)
|
||||
*
|
||||
*/
|
||||
function get_list()
|
||||
{
|
||||
$array=array();
|
||||
$sql="select pa_id as id,pa_name as name,".
|
||||
"pa_description as description from plan_analytique order by pa_name";
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
$array=pg_fetch_all($ret);
|
||||
return $array;
|
||||
}
|
||||
|
||||
function get()
|
||||
{
|
||||
if ( $this->id==0) return;
|
||||
|
||||
$sql="select pa_name,pa_description from plan_analytique where pa_id=".$this->id;
|
||||
$ret= ExecSql($this->db,$sql);
|
||||
if ( pg_NumRows($ret) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
$a= pg_fetch_array($ret,0);
|
||||
$this->name=$a['pa_name'];
|
||||
$this->description=$a['pa_description'];
|
||||
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
if ( $this->id == 0 ) return;
|
||||
ExecSql($this->db,"delete from plan_analytique where pa_id=".$this->id);
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
if ( $this->id==0) return;
|
||||
$name=FormatString($this->name);
|
||||
if ( strlen($name) == 0)
|
||||
return;
|
||||
|
||||
$description=FormatString($this->description);
|
||||
ExecSql($this->db,"update plan_analytique set pa_name='".$name."'".
|
||||
", pa_description='".$description."'".
|
||||
" where pa_id=".$this->id);
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
$name=FormatString($this->name);
|
||||
if ( strlen($name) == 0)
|
||||
return;
|
||||
|
||||
$description=FormatString($this->description);
|
||||
ExecSql($this->db,"insert into plan_analytique(pa_name,pa_description)".
|
||||
" values (".
|
||||
"'".$name."',".
|
||||
"'".$description."')");
|
||||
$this->id=getSequence($this->db,'plan_analytique_pa_id_seq');
|
||||
|
||||
}
|
||||
function form()
|
||||
{
|
||||
|
||||
$wName=new widget('TEXT','Nom','pa_name',$this->name);
|
||||
$wName->table=1;
|
||||
$wDescription=new widget('TEXT','Description','pa_description',$this->description);
|
||||
$wDescription->table=1;
|
||||
$wId=new widget("HIDDEN","pa_id",$this->id);
|
||||
$ret="<TABLE>";
|
||||
$ret.='<tr>'.$wName->IOValue().'</tr>';
|
||||
$ret.="<tr>".$wDescription->IOValue()."</tr>";
|
||||
$ret.="</table>";
|
||||
$ret.=$wId->IOValue();
|
||||
return $ret;
|
||||
}
|
||||
function isAppend()
|
||||
{
|
||||
$count=getDbValue($this->db,"select count(pa_id) from plan_analytique");
|
||||
|
||||
if ( $count > 4)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
/*!\brief get all the poste related to the current
|
||||
* Analytic plan
|
||||
* \return an array of Poste_analytic object
|
||||
*/
|
||||
function get_poste_analytique()
|
||||
{
|
||||
$sql="select po_id from poste_analytique where pa_id=".$this->id;
|
||||
$r=ExecSql($this->db,$sql);
|
||||
$ret=array();
|
||||
if ( pg_NumRows($r) == 0 )
|
||||
return $ret;
|
||||
|
||||
$all=pg_fetch_all($r);
|
||||
foreach ($all as $line)
|
||||
{
|
||||
$obj=new Poste_analytique($this->db,$line['po_id']);
|
||||
$obj->get_by_id();
|
||||
$ret[]=clone $obj;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
||||
249
include/class_poste_analytic.php
Normal file
249
include/class_poste_analytic.php
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*!\file
|
||||
*/
|
||||
|
||||
/*!\brief contains the object for the poste_analytique (table poste_analytique)
|
||||
*
|
||||
*/
|
||||
require_once("class_widget.php");
|
||||
require_once("postgres.php");
|
||||
require_once("class_plananalytic.php");
|
||||
|
||||
class Poste_analytique
|
||||
{
|
||||
var $id; /*!< $id is po_id */
|
||||
var $name; /*!< po_name */
|
||||
var $pa_id; /*!< pa_id fk to the plan_analytique(pa_id) */
|
||||
var $amount; /*!< po_amount just an amount */
|
||||
var $description; /*!< po_description description of
|
||||
the post */
|
||||
var $db; /*!< database connection */
|
||||
|
||||
function Poste_analytique($p_db,$p_id=0)
|
||||
{
|
||||
$this->db=$p_db;
|
||||
$this->id=$p_id;
|
||||
}
|
||||
/*! \brief retrieve data from the database and
|
||||
* fill the object
|
||||
* \param $p_where the where clause
|
||||
*/
|
||||
private function fetch_from_db($p_where)
|
||||
{
|
||||
$sql="select po_id,
|
||||
po_name ,
|
||||
pa_id,
|
||||
po_amount,
|
||||
po_description
|
||||
from poste_analytique
|
||||
where ".
|
||||
$p_where;
|
||||
|
||||
$ret=ExecSql($this->db,$sql);
|
||||
if ( pg_NumRows($ret) == 0 )return null;
|
||||
$line=pg_fetch_array($ret);
|
||||
|
||||
$this->id=$line['po_id'];
|
||||
$this->name=$line['po_name'];
|
||||
$this->pa_id=$line['pa_id'];
|
||||
$this->amount=$line['po_amount'];
|
||||
$this->description=$line['po_description'];
|
||||
|
||||
|
||||
|
||||
}
|
||||
function get_by_id()
|
||||
{
|
||||
$this->fetch_from_db("po_id=".$this->id);
|
||||
}
|
||||
/*!
|
||||
* \brief retrieve data thanks the name
|
||||
* \param $p_name name of the analytic account
|
||||
*
|
||||
*/
|
||||
function get_by_name($p_name)
|
||||
{
|
||||
$p_name=FormatString($p_name);
|
||||
if ( $p_name == null )
|
||||
$p_name=$this->name;
|
||||
|
||||
$this->fetch_from_db("po_name='".$p_name."'");
|
||||
echo "id = ".$this->id;
|
||||
}
|
||||
function add()
|
||||
{
|
||||
$this->format_data();
|
||||
if ( strlen($this->name) == 0)
|
||||
return;
|
||||
|
||||
$sql="insert into poste_analytique (
|
||||
po_name ,
|
||||
pa_id,
|
||||
po_amount,
|
||||
po_description
|
||||
) values (".
|
||||
"'".$this->name."',".
|
||||
$this->pa_id.",".
|
||||
$this->amount.",".
|
||||
"'".$this->description."')";
|
||||
|
||||
ExecSql($this->db,$sql);
|
||||
|
||||
}
|
||||
function update()
|
||||
{
|
||||
|
||||
$this->format_data();
|
||||
if ( strlen($this->name) == 0)
|
||||
return;
|
||||
$sql="update poste_analytique ".
|
||||
" set po_name='".$this->name."',".
|
||||
" pa_id=".$this->pa_id.",".
|
||||
" po_amount=".$this->amount.",".
|
||||
" po_description='".$this->description."'".
|
||||
" where po_id=".$this->id;
|
||||
ExecSql($this->db,$sql);
|
||||
|
||||
}
|
||||
private function format_data()
|
||||
{
|
||||
$this->name=FormatString($this->name);
|
||||
$this->pa_id=FormatString($this->pa_id);
|
||||
$this->amount=FormatString($this->amount);
|
||||
if (strlen($this->amount) == 0 )
|
||||
$this->amount=0.0;
|
||||
|
||||
$this->description=FormatString($this->description);
|
||||
}
|
||||
function delete()
|
||||
{
|
||||
$sql="delete from poste_analytique where po_id=".$this->id;
|
||||
ExecSql($this->db,$sql);
|
||||
}
|
||||
/*! \brief return an array of object Poste_Analytique
|
||||
*
|
||||
*/
|
||||
function get_list()
|
||||
{
|
||||
$sql="select po_id,
|
||||
po_name ,
|
||||
pa_id,
|
||||
po_amount,
|
||||
po_description
|
||||
from poste_analytique ".
|
||||
" order by po_name";
|
||||
|
||||
$ex=ExecSql($this->db,$sql);
|
||||
$ret=pg_fetch_all($ex);
|
||||
if ( $ret == null )
|
||||
return null;
|
||||
|
||||
$array=array();
|
||||
foreach ($ret as $line)
|
||||
{
|
||||
$objet=new Poste_Analytique($this->db);
|
||||
|
||||
$object->id=$line['po_id'];
|
||||
$object->name=$line['po_name'];
|
||||
$object->pa_id=$line['pa_id'];
|
||||
$object->amount=$line['po_amount'];
|
||||
$object->description=$line['po_description'];
|
||||
$array[]=clone $object;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
function display_list()
|
||||
{
|
||||
$array=$this->get_list();
|
||||
|
||||
foreach ($array as $line)
|
||||
{
|
||||
echo $line->id." / ".$line->name." / ".$line->description."/".
|
||||
$line->amount." / ".$line->pa_id."<br>";
|
||||
}
|
||||
}
|
||||
function debug()
|
||||
{
|
||||
echo "id ".$this->id."<br>";
|
||||
echo "name ".$this->name."<br>";
|
||||
echo "pa_id ".$this->pa_id."<br>";
|
||||
echo "amount ".$this->amount."<br>";
|
||||
echo "description ".$this->description."<br>";
|
||||
}
|
||||
function form()
|
||||
{
|
||||
$wId=new widget("hidden","po_id","po_id",$this->id);
|
||||
$wName=new widget("text","Nom","po_name",$this->name);
|
||||
$wPa_id=new widget("hidden","pa_id","pa_id",$this->pa_id);
|
||||
$wAmount=new widget("text","Montant","po_amount",$this->amount);
|
||||
$wDescription=new widget("text","Description","po_description",$this->description);
|
||||
|
||||
$pa=new PlanAnalytic($this->db,$this->pa_id);
|
||||
$pa->get();
|
||||
$wPaName=new widget("text","Plan A.","",$pa->name);
|
||||
$wPaName->table=1;
|
||||
$wPaName->readonly=true;
|
||||
|
||||
$wName->table=1;
|
||||
$wPa_id->table=1;
|
||||
$wAmount->table=1;
|
||||
$wDescription->table=1;
|
||||
|
||||
$r=$wId->IOValue();
|
||||
$r.=$wPa_id->IOValue();
|
||||
|
||||
$r.="<table>";
|
||||
|
||||
$r.="<tr>";
|
||||
$r.=$wName->IOValue();
|
||||
$r.="</tr>";
|
||||
|
||||
$r.="<tr>";
|
||||
$r.=$wAmount->IOValue();
|
||||
$r.="</tr>";
|
||||
|
||||
|
||||
$r.="<tr>";
|
||||
$r.=$wDescription->IOValue();
|
||||
$r.="</tr>";
|
||||
|
||||
$r.="<tr>";
|
||||
$r.=$wPaName->IOValue();
|
||||
$r.="</tr>";
|
||||
|
||||
$r.="</table>";
|
||||
return $r;
|
||||
|
||||
}
|
||||
function fill_from_POST()
|
||||
{
|
||||
$this->name=$_POST['po_name'];
|
||||
$this->description=$_POST['po_description'];
|
||||
$this->pa_id=$_POST['pa_id'];
|
||||
$this->amount=$_POST['po_amount'];
|
||||
$this->id=$_POST['po_id'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -38,7 +38,10 @@
|
|||
* $type
|
||||
* - TEXT
|
||||
* - HIDDEN
|
||||
* - SELECT
|
||||
* - BUTTON in this->js you have the javascript code
|
||||
* - SELECT the options are passed via this->value, this array is
|
||||
* build thanks the make_array function, each array (of the
|
||||
* array) aka row must contains a field value and a field label
|
||||
* - PASSWORD
|
||||
* - CHECKBOX
|
||||
* - RADIO
|
||||
|
|
@ -52,6 +55,7 @@
|
|||
* - JS_TVA open a popup window for the VAT
|
||||
* - JS_CONCERNED open a popup window for search a operation, if extra == 0 then
|
||||
* get the amount thx javascript
|
||||
|
||||
*
|
||||
* For JS_SEARCH_POST,JS_SEARCH or JS_SEARCH_ONLY
|
||||
* - $extra contains 'cred', 'deb', 'all' or a list of fiche_def_ref (frd_id)
|
||||
|
|
@ -62,44 +66,36 @@
|
|||
*
|
||||
*/
|
||||
class widget {
|
||||
/*! \enum $type type of the input tag (text, select, files, js_search,...)
|
||||
* \enum $name name of the input tag
|
||||
* \enum $value value
|
||||
* \enum $readonly if set to false cannot modify
|
||||
* \enum $size size for the text type
|
||||
* \enum $selected selected value for the radio or select
|
||||
* \enum $table if we want to make a HTML table row the value is return with <TD>
|
||||
* \enum $label text before the input tag
|
||||
* \enum $disabled to disable the type
|
||||
* \enum $extra depends of the input type
|
||||
* \enum $extra2 depends of the input type
|
||||
* \enum $tabindex the tabindex
|
||||
* \brief
|
||||
*/
|
||||
|
||||
var $type; /*! \enum $type type of the widget */
|
||||
var $name; /*! \enum $name field NAME of the INPUT */
|
||||
var $value; /*! \enum $value what the INPUT contains */
|
||||
var $readonly; /*! \enum $readonly true : we cannot change value */
|
||||
var $size; /*! \enum $size size of the input */
|
||||
var $selected; /*! \enum $selected for SELECT RADIO and CHECKBOX the selected value */
|
||||
var $table; /*! \enum $table =1 add the table tag */
|
||||
var $label; /*! \enum $label the question before the input */
|
||||
var $disabled; /*! \enum $disabled poss. value == true or nothing, to disable INPUT*/
|
||||
var $extra; /*! \enum $extra different usage, it depends of the $type */
|
||||
var $extra2; /*! \enum $extra2 different usage, it depends of the $type */
|
||||
var $type; /*!< $type type of the widget */
|
||||
var $name; /*!< $name field NAME of the INPUT */
|
||||
var $value; /*!< $value what the INPUT contains */
|
||||
var $readonly; /*!< $readonly true : we cannot change value */
|
||||
var $size; /*!< $size size of the input */
|
||||
var $selected; /*!< $selected for SELECT RADIO and CHECKBOX the selected value */
|
||||
var $table; /*!< $table =1 add the table tag */
|
||||
var $label; /*!< $label the question before the input */
|
||||
var $disabled; /*!< $disabled poss. value == true or nothing, to disable INPUT*/
|
||||
var $extra; /*!< $extra different usage, it depends of the $type */
|
||||
var $extra2; /*!< $extra2 different usage,
|
||||
it depends of the $type */
|
||||
var $javascript;
|
||||
|
||||
var $tabindex;
|
||||
function widget($p_type="") {
|
||||
function widget($p_type="",$p_label="",$p_name="",$p_value="") {
|
||||
$this->type=$p_type;
|
||||
$this->name=$p_name;
|
||||
$this->readonly=false;
|
||||
$this->size=20;
|
||||
$this->width=50;
|
||||
$this->heigh=20;
|
||||
$this->value="";
|
||||
$this->value=$p_value;
|
||||
$this->selected="";
|
||||
$this->table=0;
|
||||
$this->label="";
|
||||
$this->label=$p_label;
|
||||
$this->disabled=false;
|
||||
$this->javascript="";
|
||||
$this->extra2="all";
|
||||
}
|
||||
function SetReadOnly($p_read) {
|
||||
$this->readonly=$p_read;
|
||||
|
|
@ -124,7 +120,8 @@ class widget {
|
|||
$disabled = $this->disabled ? "DISABLED" : "";
|
||||
if (strtoupper($this->type)=="TEXT") {
|
||||
if ( $this->readonly==false) {
|
||||
$r="<INPUT style=\"border:solid 1px blue;\" TYPE=\"TEXT\" id=\"$this->name\" NAME=\"$this->name\" VALUE=\"$this->value\" SIZE=\"$this->size\" ".$disabled.">";
|
||||
$r="<INPUT style=\"border:solid 1px blue;\" TYPE=\"TEXT\" id=\"$this->name\" ".
|
||||
" NAME=\"$this->name\" VALUE=\"$this->value\" SIZE=\"$this->size\" ".$this->javascript." ".$disabled.">";
|
||||
} else {
|
||||
$r=sprintf('<span>%s</span><input type="hidden" id="%s" name="%s" value="%s">', $this->value,$this->name,$this->name,$this->value);
|
||||
}
|
||||
|
|
@ -173,7 +170,7 @@ class widget {
|
|||
}
|
||||
if ( $this->table==1) {
|
||||
$r="<TD> $r </TD>";
|
||||
if ( $this->label != "") $r="<TD> $this->label</TD>".$r;
|
||||
if ( $this->label != "") $r="<TD style=\"border: 1px groove blue;\"> $this->label</TD>".$r;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
|
@ -321,7 +318,8 @@ class widget {
|
|||
if ( $this->table==1) $r="<TD>$this->label</TD><TD>$r</TD>";
|
||||
return $r;
|
||||
}
|
||||
// input type == js_search_poste => button search for the account
|
||||
//----------------------------------------------------------------------
|
||||
// input type == js_search_poste => button search for the account
|
||||
if ( strtolower($this->type)=="js_search_poste") {
|
||||
|
||||
$l_sessid=$_REQUEST['PHPSESSID'];
|
||||
|
|
@ -332,13 +330,14 @@ class widget {
|
|||
<INPUT class="inp" TYPE="button" onClick=SearchPoste(\'%s\',\'%s\',\'%s\') value="Recherche">
|
||||
%s</TD><TD>
|
||||
|
||||
<INPUT TYPE="Text" NAME="%s" VALUE="%s" SIZE="8">
|
||||
<INPUT TYPE="Text" NAME="%s" ID="%s" VALUE="%s" SIZE="8">
|
||||
</TD>',
|
||||
$l_sessid,
|
||||
$this->name,
|
||||
$this->extra,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->name,
|
||||
$this->value
|
||||
);
|
||||
|
||||
|
|
@ -383,7 +382,7 @@ class widget {
|
|||
</TD><TD>
|
||||
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Recherche">
|
||||
%s
|
||||
<INPUT style="border:solid 1px blue;" TYPE="Text" ID="%s" NAME="%s" VALUE="%s" SIZE="8" onChange="ajaxFid(\'%s\',\'%s\',\'%s\')">
|
||||
<INPUT style="border:solid 1px blue;" TYPE="Text" ID="%s" NAME="%s" VALUE="%s" SIZE="8" onBlur="ajaxFid(\'%s\',\'%s\',\'%s\')">
|
||||
|
||||
',
|
||||
$l_sessid,
|
||||
|
|
@ -427,32 +426,41 @@ class widget {
|
|||
if ( $this->table==1)
|
||||
{
|
||||
$r=sprintf('<TD>
|
||||
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="QuickCode">
|
||||
<INPUT TYPE="button" onClick="SearchCard(\'%s\',\'%s\',\'%s\',\'%s\')" value="QuickCode">
|
||||
%s</TD><TD> <INPUT style="border:solid 1px blue;" TYPE="Text" style="border:solid 1px blue;" '.
|
||||
' NAME="%s" VALUE="%s" SIZE="8" >
|
||||
',
|
||||
$l_sessid,
|
||||
$this->extra,
|
||||
$this->name,
|
||||
$this->extra2,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->value
|
||||
);
|
||||
' NAME="%s" ID="%s" VALUE="%s" SIZE="8" onBlur="ajaxFid(\'%s\',\'%s\',\'%s\')">',
|
||||
$l_sessid,
|
||||
$this->extra,
|
||||
$this->name,
|
||||
$this->extra2,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->name,
|
||||
$this->value,
|
||||
$this->name,
|
||||
$this->extra, //deb or cred
|
||||
$this->extra2 //jrn
|
||||
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$r=sprintf('
|
||||
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="QuickCode">
|
||||
<INPUT TYPE="button" onClick="SearchCard(\'%s\',\'%s\',\'%s\',\'%s\')" value="QuickCode">
|
||||
%s <INPUT TYPE="Text" style="border:solid 1px blue;" '.
|
||||
' NAME="%s" VALUE="%s" SIZE="8" > ',
|
||||
$l_sessid,
|
||||
$this->extra,
|
||||
$this->name,
|
||||
$this->extra2,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->value
|
||||
' NAME="%s" ID="%s" VALUE="%s" SIZE="8" onBlur="ajaxFid(\'%s\',\'%s\',\'%s\')">',
|
||||
$l_sessid,
|
||||
$this->extra,
|
||||
$this->name,
|
||||
$this->extra2,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->name,
|
||||
$this->value,
|
||||
$this->name,
|
||||
$this->extra, //deb or cred
|
||||
$this->extra2 //jrn
|
||||
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -523,16 +531,17 @@ class widget {
|
|||
$l_sessid=$_REQUEST['PHPSESSID'];
|
||||
|
||||
$r=sprintf("$td
|
||||
<INPUT TYPE=\"button\" onClick=SearchJrn('%s','%s',%s) value=\"Recherche\">
|
||||
<INPUT TYPE=\"button\" onClick=SearchJrn('%s','%s',%s,'%s') value=\"Recherche\">
|
||||
%s $etd $td
|
||||
<INPUT TYPE=\"Text\" style=\"border:solid 1px blue;\" NAME=\"%s\" VALUE=\"%s\" SIZE=\"8\">
|
||||
$etd",
|
||||
$l_sessid,
|
||||
$this->name,
|
||||
$this->extra,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->value
|
||||
$l_sessid,
|
||||
$this->name,
|
||||
$this->extra,
|
||||
$this->extra2,
|
||||
$this->label,
|
||||
$this->name,
|
||||
$this->value
|
||||
);
|
||||
} else {
|
||||
$r=sprintf("$td<span>%s <b>%s</b></span>",$this->label,$this->value);
|
||||
|
|
@ -541,6 +550,17 @@ class widget {
|
|||
|
||||
return $r;
|
||||
}// end js_concerned
|
||||
//----------------------------------------------------------------------
|
||||
// BUTTON
|
||||
//----------------------------------------------------------------------
|
||||
if ( strtolower($this->type)=="button") {
|
||||
if ( $this->readonly==true) return "";
|
||||
$r='<input type="BUTTON" name="'.$this->name.'"'.
|
||||
' id="'.$this->name.'"'.
|
||||
' value="'.$this->label.'"'.
|
||||
' onClick="'.$this->js."'>";
|
||||
return $r;
|
||||
}
|
||||
return "INVALID WIDGET $this->type ";
|
||||
} //end function
|
||||
/* Debug
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ $_ENV['TMP']="/tmp";
|
|||
define ("phpcompta_password","dany");
|
||||
define ("phpcompta_psql_port","5432");
|
||||
define ("phpcompta_user","phpcompta");
|
||||
define ("domaine","");
|
||||
define ("domaine","rel240_");
|
||||
|
||||
|
||||
define ("DEBUG","true");
|
||||
|
|
@ -179,6 +179,9 @@ define ("JS_CALC_LINE",'
|
|||
</div>
|
||||
'
|
||||
);
|
||||
define ("JS_COMPUTE_ODS",
|
||||
"<SCRIPT language=\"javascript\" src=\"js/compute.js\"> </SCRIPT>");
|
||||
|
||||
define ("JS_SHOW_TVA","<SCRIPT language=\"javascript\">
|
||||
function ShowTva(p_sessid,ctl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,6 +121,30 @@ if ( $sub_action == "list" )
|
|||
<input type="submit" name="submit_query" value="recherche">
|
||||
<input type="hidden" name="p_action" value="contact">
|
||||
</form>
|
||||
|
||||
|
||||
<form>
|
||||
<?php
|
||||
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
|
||||
echo JS_SEARCH_CARD;
|
||||
$w=new widget('js_search_only');
|
||||
$w->name='qcode';
|
||||
$w->value=$qcode;
|
||||
$w->label='qcode';
|
||||
$w->table=0;
|
||||
$w->extra='4,8,9,14';
|
||||
echo $w->IOValue();
|
||||
|
||||
|
||||
$sp= new widget("span");
|
||||
echo $sp->IOValue("qcode_label",$qcode)."</TD></TR>";
|
||||
|
||||
|
||||
?>
|
||||
<input type="submit" name="submit_query" value="recherche">
|
||||
<input type="hidden" name="p_action" value="contact">
|
||||
|
||||
</FORM>
|
||||
</span>
|
||||
<span>
|
||||
<form method="get" action="commercial.php">
|
||||
|
|
@ -146,26 +170,6 @@ if ( $sub_action == "list" )
|
|||
|
||||
</form>
|
||||
</span>
|
||||
|
||||
<form>
|
||||
<?php
|
||||
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
|
||||
echo JS_SEARCH_CARD;
|
||||
$w=new widget('js_search_only');
|
||||
$w->name='qcode';
|
||||
$w->value=$qcode;
|
||||
$w->label='qcode';
|
||||
$w->extra='4,8,9,14';
|
||||
$sp= new widget("span");
|
||||
echo $sp->IOValue("qcode_label",$qcode)."</TD></TR>";
|
||||
|
||||
echo $w->IOValue();
|
||||
|
||||
?>
|
||||
<input type="submit" name="submit_query" value="recherche">
|
||||
<input type="hidden" name="p_action" value="contact">
|
||||
|
||||
</FORM>
|
||||
<?php
|
||||
$contact=new Contact($cn);
|
||||
$search=(isset($_GET['query']))?$_GET['query']:"";
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ function echo_debug ($file,$line="",$msg="") {
|
|||
if ( DEBUG=='true' ) {
|
||||
$f=fopen ($_ENV['TMP'].DIRECTORY_SEPARATOR."phpcompta.log","a+");
|
||||
$a=var_export($msg,true);
|
||||
fwrite($f,"$file $line $a\n");
|
||||
$e=basename($file);
|
||||
fwrite($f,"$e : $line $a\n");
|
||||
fclose ($f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,71 +33,72 @@ $LinesImported=0;
|
|||
$LinesDup=0;
|
||||
$row=1;
|
||||
StartSql($p_cn);
|
||||
while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
|
||||
$num = count($data);
|
||||
echo_debug('dexia_be',__LINE__,$num);
|
||||
echo_debug('dexia_be',__LINE__,var_export($data,true));
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Parsing CSV comes here
|
||||
//-----------------------------------------------------
|
||||
|
||||
echo_debug('dexia_be',__LINE__,'$row = '.var_export($row,true));
|
||||
echo_debug('dexia_be',__LINE__,'sizeof($row)'.sizeof($row));
|
||||
$row=split(';',$data[0]);
|
||||
//to avoid a level of if
|
||||
if (!(isset($row[2]))) $row[2]='';
|
||||
|
||||
|
||||
// Skipping all the lines whith a blank operation reference ('numéro extrait')
|
||||
if ( $row[2] == '' ||
|
||||
!(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
|
||||
{
|
||||
$LinesSkipped++;
|
||||
continue;
|
||||
}
|
||||
// Alternative filter : import all the operations even without a reference
|
||||
// !! Disable check of doubles as all the unreferenced operations have hte smae
|
||||
//NULL' reference
|
||||
// Just use the following test : if (
|
||||
//!(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
|
||||
|
||||
// Parsing the remaining lines
|
||||
$num_compte=$row[3]; // Third party bank account
|
||||
$date_exec=$row[1]; // Execution date of the operation
|
||||
$date_val=$row[8]; // Effective date of the operation
|
||||
// remove the thousand sep. ** UNUSED by DEXIA
|
||||
//$montant=str_replace('.','',$row[9]);
|
||||
// remove the sign ** UNUSED by DEXIA
|
||||
//$montant=str_replace('+','',$montant);
|
||||
// replace the coma by a period
|
||||
$montant=str_replace(',','.',$row[9]); // Amount of the operation
|
||||
$ref_extrait=$row[2]; // Operation reference
|
||||
$devise=$row[10]; // Curency used
|
||||
$compte_ordre=$row[0]; // Your own bank account
|
||||
$detail=trim($row[4]).' '.trim($row[5]).' '.trim($row[6]).'
|
||||
while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE)
|
||||
{
|
||||
$num = count($data);
|
||||
echo_debug('dexia_be',__LINE__,$num);
|
||||
echo_debug('dexia_be',__LINE__,var_export($data,true));
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Parsing CSV comes here
|
||||
//-----------------------------------------------------
|
||||
|
||||
echo_debug('dexia_be',__LINE__,'$row = '.var_export($row,true));
|
||||
echo_debug('dexia_be',__LINE__,'sizeof($row)'.sizeof($row));
|
||||
$row=split(';',$data[0]);
|
||||
//to avoid a level of if
|
||||
if (!(isset($row[2]))) $row[2]='';
|
||||
|
||||
|
||||
// Skipping all the lines whith a blank operation reference ('numéro extrait')
|
||||
if ( $row[2] == '' ||
|
||||
!(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
|
||||
{
|
||||
$LinesSkipped++;
|
||||
continue;
|
||||
}
|
||||
// Alternative filter : import all the operations even without a reference
|
||||
// !! Disable check of doubles as all the unreferenced operations have hte smae
|
||||
//NULL' reference
|
||||
// Just use the following test : if (
|
||||
//!(ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[0],$r)))
|
||||
|
||||
// Parsing the remaining lines
|
||||
$num_compte=$row[3]; // Third party bank account
|
||||
$date_exec=$row[1]; // Execution date of the operation
|
||||
$date_val=$row[8]; // Effective date of the operation
|
||||
// remove the thousand sep. ** UNUSED by DEXIA
|
||||
//$montant=str_replace('.','',$row[9]);
|
||||
// remove the sign ** UNUSED by DEXIA
|
||||
//$montant=str_replace('+','',$montant);
|
||||
// replace the coma by a period
|
||||
$montant=str_replace(',','.',$row[9]); // Amount of the operation
|
||||
$ref_extrait=$row[2]; // Operation reference
|
||||
$devise=$row[10]; // Curency used
|
||||
$compte_ordre=$row[0]; // Your own bank account
|
||||
$detail=trim($row[4]).' '.trim($row[5]).' '.trim($row[6]).'
|
||||
'.trim($row[7]);
|
||||
//Details-Communicaion
|
||||
//Details-Communicaion
|
||||
|
||||
//----------------------------------------------------
|
||||
// Skip dubbel
|
||||
//----------------------------------------------------
|
||||
$Sql="select * from import_tmp where code='$ref_extrait' and
|
||||
//----------------------------------------------------
|
||||
// Skip dubbel
|
||||
//----------------------------------------------------
|
||||
$Sql="select * from import_tmp where code='$ref_extrait' and
|
||||
compte_ordre='$compte_ordre' limit 2";
|
||||
if ( CountSql($p_cn,$Sql) > 0)
|
||||
{
|
||||
/* Skip it it already encoded */
|
||||
echo "Double skipped : $ref_extrait $detail <BR>";
|
||||
$LinesDup++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// SQL request to insert into import_tmp
|
||||
// Adapt the format of the import's date in the ** to_date ** function
|
||||
//--------------------------------------------------------------------
|
||||
$Sql="insert into import_tmp (code,
|
||||
if ( CountSql($p_cn,$Sql) > 0)
|
||||
{
|
||||
/* Skip it it already encoded */
|
||||
echo "Double skipped : $ref_extrait $detail <BR>";
|
||||
$LinesDup++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// SQL request to insert into import_tmp
|
||||
// Adapt the format of the import's date in the ** to_date ** function
|
||||
//--------------------------------------------------------------------
|
||||
$Sql="insert into import_tmp (code,
|
||||
date_exec ,
|
||||
date_valeur,
|
||||
montant,
|
||||
|
|
@ -122,21 +123,22 @@ compte_ordre='$compte_ordre' limit 2";
|
|||
//-----------------------------------------------------
|
||||
// Check if no need to rollback when executing the SQL
|
||||
//-----------------------------------------------------
|
||||
if ( ExecSql($p_cn,$Sql) == false ) {
|
||||
Rollback($p_cn);
|
||||
echo "Rollbacking : $ref_extrait $detail <BR>";
|
||||
$LinesSkipped++;
|
||||
break;
|
||||
try {
|
||||
ExecSql($p_cn,$Sql);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Rollback($p_cn);
|
||||
echo "Rollbacking : $ref_extrait $detail <BR>";
|
||||
$LinesSkipped++;
|
||||
continue;
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// The import is OK
|
||||
//-----------------------------------------------------
|
||||
|
||||
else {
|
||||
|
||||
$LinesImported++;
|
||||
$row++;
|
||||
echo "Record imported: $ref_extrait $detail <BR>";
|
||||
}
|
||||
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
|
|
@ -146,4 +148,4 @@ compte_ordre='$compte_ordre' limit 2";
|
|||
fclose($handle);
|
||||
echo "<BR><B>$LinesImported operation(s) imported, $LinesSkipped text or invalid
|
||||
line(s) skipped, $LinesDup operation(s) skipped as already imported<BR>";
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -112,12 +112,14 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
|
|||
//-----------------------------------------------------
|
||||
// Check if no need to rollback when executing the SQL
|
||||
//-----------------------------------------------------
|
||||
if ( ExecSql($p_cn,$Sql) == false ) {
|
||||
Rollback($p_cn);
|
||||
echo "Rollbacking : $ref_extrait $detail <BR>";
|
||||
$LinesSkipped++;
|
||||
break;
|
||||
}
|
||||
try {
|
||||
ExecSql($p_cn,$Sql) ;
|
||||
} catch (Exception $e) {
|
||||
Rollback($p_cn);
|
||||
echo "Rollbacking : $ref_extrait $detail <BR>";
|
||||
$LinesSkipped++;
|
||||
break;
|
||||
}
|
||||
//-----------------------------------------------------
|
||||
// The import is OK
|
||||
//-----------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -71,24 +71,6 @@ if ( isset ($_POST["DATABASE"]) ) {
|
|||
$Res=ExecSql($cn,"insert into jnt_use_dos (use_id,dos_id) values (1,$l_id)");
|
||||
// Connect to the new database
|
||||
$cn=DbConnect($l_id);
|
||||
//---
|
||||
// Cleaning Action
|
||||
//--
|
||||
if ( isset($_POST['DOC'] ))
|
||||
{
|
||||
$Res=ExecSql($cn,"delete from action_gestion");
|
||||
$Res=ExecSql($cn,"delete from document");
|
||||
}
|
||||
if ( isset($_POST['CARD']))
|
||||
{
|
||||
$Res=ExecSql($cn,"delete from attr_value");
|
||||
$Res=ExecSql($cn,"delete from jnt_fic_att_value");
|
||||
$Res=ExecSql($cn,"delete from fiche");
|
||||
$Res=ExecSql($cn,"delete from action_gestion");
|
||||
$Res=ExecSql($cn,"delete from document");
|
||||
|
||||
|
||||
}
|
||||
//--year --
|
||||
$Res=ExecSql($cn,"delete from parm_periode");
|
||||
if ( ($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0 )
|
||||
|
|
@ -101,19 +83,19 @@ if ( isset ($_POST["DATABASE"]) ) {
|
|||
$m=1;
|
||||
foreach ($nb_day as $day)
|
||||
{
|
||||
$p_start=sprintf("01-%d-%s",$m,$year);
|
||||
$p_end=sprintf("%d-%d-%s",$day,$m,$year);
|
||||
$sql=sprintf("insert into parm_periode (p_start,p_end,p_exercice)
|
||||
$p_start=sprintf("01-%d-%s",$m,$year);
|
||||
$p_end=sprintf("%d-%d-%s",$day,$m,$year);
|
||||
$sql=sprintf("insert into parm_periode (p_start,p_end,p_exercice)
|
||||
values (to_date('%s','DD-MM-YYYY'),to_date('%s','DD-MM-YYYY'),'%s')",
|
||||
$p_start,$p_end,$year);
|
||||
$Res=ExecSql($cn,$sql);
|
||||
$m++;
|
||||
$Res=ExecSql($cn,$sql);
|
||||
$m++;
|
||||
}
|
||||
$sql=sprintf("insert into parm_periode (p_start,p_end,p_exercice)
|
||||
values (to_date('31-12-%s','DD-MM-YYYY'),to_date('31-12-%s','DD-MM-YYYY'),'%s')",
|
||||
$year,$year,$year);
|
||||
$year,$year,$year);
|
||||
$Res=ExecSql($cn,$sql);
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // if $l_id != 0
|
||||
|
|
@ -123,11 +105,11 @@ if ( isset ($_POST["DATABASE"]) ) {
|
|||
|
||||
<?php
|
||||
|
||||
$cn=DbConnect();
|
||||
$cn=DbConnect();
|
||||
$offset=(isset($_REQUEST['offset']))?$_REQUEST['offset']:0;
|
||||
$page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
|
||||
$count=getDbValue($cn,"select count(*) from ac_dossier");
|
||||
$size=10;
|
||||
$size=10;
|
||||
|
||||
echo jrn_navigation_bar($offset,$count,$size,$page);
|
||||
$Res=ShowDossier('all',$offset,$size);
|
||||
|
|
@ -191,8 +173,6 @@ if ( $count == 0 ) {
|
|||
<TD> Description</td><td> <TEXTAREA COLS="60" ROWS="2" NAME="DESCRIPTION" ></TEXTAREA> </TD>
|
||||
</TR>
|
||||
<TR> <TD> Modèle</td><td> <?php echo $template; ?> </TD></TR>
|
||||
<TR><TD>Nettoyage des Documents et courriers (ce qui n'effacera pas les modèles de documents)</TD><TD> <input type="checkbox" name="DOC"></TD></TR>
|
||||
<TR><TD>Nettoyage de toutes les fiches (ce qui effacera client, fournisseurs et documents)</TD><TD> <input type="checkbox" name="CARD"></TD></TR>
|
||||
<TR><TD>Année </TD><TD><input type="text" size=4 name="YEAR" value=<?php echo '"'.$m_date.'"'; ?>></TD></TR>
|
||||
<TR>
|
||||
<TD> <INPUT TYPE=SUBMIT VALUE="Creation Dossier"></TD>
|
||||
|
|
@ -200,4 +180,4 @@ if ( $count == 0 ) {
|
|||
</TABLE>
|
||||
</FORM>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -27,12 +27,9 @@ include_once ("postgres.php");
|
|||
include_once ("user_menu.php");
|
||||
require_once ("check_priv.php");
|
||||
|
||||
// echo '<div class="u_tmenu">';
|
||||
// var_dump($_SERVER);
|
||||
|
||||
// echo ShowMenuCompta($_SESSION['g_dossier']);
|
||||
// echo '</div>';
|
||||
echo JS_SEARCH_POSTE;
|
||||
echo JS_AJAX_FICHE;
|
||||
|
||||
|
||||
if ( !isset($sessid))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ function UpdateCSV($p_cn){
|
|||
* modify the Quick Code or remove record poss.value are form, remove
|
||||
*/
|
||||
function ShowBox($p_val,$counter,$p_cn,$p_form='form'){
|
||||
|
||||
echo JS_AJAX_FICHE;
|
||||
$w=new widget('js_search_only');
|
||||
$w->name='poste'.$counter;
|
||||
$w->extra='cred';
|
||||
|
|
@ -98,6 +98,7 @@ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){
|
|||
// widget concerned
|
||||
$wConcerned=new widget('js_concerned');
|
||||
$wConcerned->extra=abs($p_val['montant']);
|
||||
$wConcerned->extra2='paid';
|
||||
$wConcerned->label='op. concernée';
|
||||
$wConcerned->table=0;
|
||||
$s=new widget('span');
|
||||
|
|
@ -253,78 +254,84 @@ function TransferCSV($p_cn, $periode){
|
|||
|
||||
$Max=pg_NumRows($Res);
|
||||
echo $Max." opérations à transférer.<br/>";
|
||||
StartSql($p_cn);
|
||||
|
||||
for ($i = 0;$i < $Max;$i++) {
|
||||
$val=pg_fetch_array($Res,$i);
|
||||
try
|
||||
{
|
||||
StartSql($p_cn);
|
||||
|
||||
for ($i = 0;$i < $Max;$i++) {
|
||||
$val=pg_fetch_array($Res,$i);
|
||||
|
||||
$code=$val['code'];
|
||||
$date_exec=$val['date_exec'];
|
||||
$montant=$val['montant'];
|
||||
$num_compte=$val['num_compte'];
|
||||
$poste_comptable=$val['poste_comptable'];
|
||||
$bq_account=$val['bq_account'];
|
||||
$jrn=$val['jrn'];
|
||||
$detail=$val['detail'];
|
||||
$jr_rapt=$val['jr_rapt'];
|
||||
|
||||
$code=$val['code'];
|
||||
$date_exec=$val['date_exec'];
|
||||
$montant=$val['montant'];
|
||||
$num_compte=$val['num_compte'];
|
||||
$poste_comptable=$val['poste_comptable'];
|
||||
$bq_account=$val['bq_account'];
|
||||
$jrn=$val['jrn'];
|
||||
$detail=$val['detail'];
|
||||
$jr_rapt=$val['jr_rapt'];
|
||||
|
||||
// Retrieve the account thx the quick code
|
||||
$f=new fiche($p_cn);
|
||||
$f->GetByQCode($poste_comptable,false);
|
||||
$poste_comptable=$f->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
// Retrieve the account thx the quick code
|
||||
$f=new fiche($p_cn);
|
||||
$f->GetByQCode($poste_comptable,false);
|
||||
$poste_comptable=$f->strAttribut(ATTR_DEF_ACCOUNT);
|
||||
|
||||
// Vérification que le poste comptable trouvé existe
|
||||
if ( $poste_comptable == '- ERROR -')
|
||||
$test=0;
|
||||
else
|
||||
{
|
||||
$sqltest = "select * from tmp_pcmn WHERE pcm_val='".$poste_comptable."'";
|
||||
// Vérification que le poste comptable trouvé existe
|
||||
if ( $poste_comptable == '- ERROR -')
|
||||
$test=0;
|
||||
else
|
||||
{
|
||||
$sqltest = "select * from tmp_pcmn WHERE pcm_val='".$poste_comptable."'";
|
||||
|
||||
$Restest=ExecSql($p_cn,$sqltest);
|
||||
$test=pg_NumRows($Restest);
|
||||
}
|
||||
$Restest=ExecSql($p_cn,$sqltest);
|
||||
$test=pg_NumRows($Restest);
|
||||
}
|
||||
|
||||
// Test it
|
||||
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<br/>";
|
||||
continue;
|
||||
}
|
||||
// Test it
|
||||
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<br/>";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Finances
|
||||
// Finances
|
||||
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
$p_user = $_SESSION['g_user'];
|
||||
$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);
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error 'import_inc.php' __LINE__");}
|
||||
|
||||
$r=InsertJrnx($p_cn,"c",$p_user,$jrn,$poste_comptable,$date_exec,$montant,$seq,$periode);
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error 'import_inc.php' __LINE__");}
|
||||
|
||||
//remove annoying double-quote
|
||||
$num_compte=str_replace('"','',$num_compte);
|
||||
$code=str_replace('\"','',$code);
|
||||
$r=InsertJrnx($p_cn,"d",$p_user,$jrn,$bq_account,$date_exec,$montant,$seq,$periode);
|
||||
|
||||
$jr_id=InsertJrn($p_cn,$date_exec,NULL,$jrn,$detail.$num_compte." ".$code,$seq,$periode);
|
||||
if ( $jr_id == false ) { Rollback($p_cn); exit(" Error 'import_inc.php' __LINE__");}
|
||||
|
||||
$r=InsertJrnx($p_cn,"c",$p_user,$jrn,$poste_comptable,$date_exec,$montant,$seq,$periode);
|
||||
|
||||
|
||||
//remove annoying double-quote
|
||||
$num_compte=str_replace('"','',$num_compte);
|
||||
$code=str_replace('\"','',$code);
|
||||
|
||||
$jr_id=InsertJrn($p_cn,$date_exec,NULL,$jrn,$detail.$num_compte." ".$code,$seq,$periode);
|
||||
}
|
||||
|
||||
if ( isNumber($jr_rapt) == 1)
|
||||
InsertRapt($p_cn,$jr_id,$jr_rapt);
|
||||
|
||||
SetInternalCode($p_cn,$seq,$jrn);
|
||||
|
||||
|
||||
echo "Tranfer de l'opération ".$code." effectué<br/>";
|
||||
$sql2 = "update import_tmp set status='t' where code='".$code."'";
|
||||
$Res2=ExecSql($p_cn,$sql2);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
Rollback($p_cn);
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans '.__FILE__.':'.__LINE__.
|
||||
' Message = '.$e->getMessage().
|
||||
'</span>';
|
||||
}
|
||||
|
||||
Commit($p_cn);
|
||||
|
||||
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ require_once("check_priv.php");
|
|||
// show sub menu
|
||||
|
||||
echo "<DIV class=\"u_subtmenu\">";
|
||||
|
||||
echo JS_AJAX_FICHE;
|
||||
|
||||
$p_array=array(array ("?p_action=impress&type=jrn","Journaux"),
|
||||
array("?p_action=impress&type=poste","Poste"),
|
||||
|
|
|
|||
|
|
@ -154,7 +154,14 @@ include("class_jrn.php");
|
|||
|
||||
} //else
|
||||
echo "</table>";
|
||||
|
||||
// show the saldo
|
||||
|
||||
$solde=$Jrn->get_solde( $_POST['from_periode'],
|
||||
$_POST['to_periode'],
|
||||
$p_cent);
|
||||
echo "solde débiteur:".$solde[0]."<br>";
|
||||
echo "solde créditeur:".$solde[1];
|
||||
|
||||
echo "</div>";
|
||||
exit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ if ( isset( $_POST['bt_html'] ) ) {
|
|||
{
|
||||
if ( isset ($_POST['poste_fille']) )
|
||||
{
|
||||
$parent=$_POST['poste_id'];
|
||||
$a_poste=getarray($cn,"select pcm_val from tmp_pcmn where pcm_val like '$parent%'");
|
||||
$parent=$_POST['poste_id'];
|
||||
$a_poste=getarray($cn,"select pcm_val from tmp_pcmn where pcm_val like '$parent%'");
|
||||
$go=3;
|
||||
}
|
||||
// Check if the post is numeric and exists
|
||||
|
|
|
|||
551
include/jrn.php
551
include/jrn.php
|
|
@ -24,8 +24,12 @@
|
|||
* \brief work with the ledger
|
||||
*/
|
||||
require_once('class_fiche.php');
|
||||
require_once ('class_gestion_sold.php');
|
||||
require_once ('class_gestion_purchase.php');
|
||||
require_once ('class_plananalytic.php');
|
||||
require_once ('class_operation.php');
|
||||
/*!
|
||||
* \brief Display the form to UPDATE account operation
|
||||
* \brief Display the form to UPDATE account operation in the expert view
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $jr_id pk of jrn
|
||||
|
|
@ -34,9 +38,11 @@ require_once('class_fiche.php');
|
|||
*
|
||||
*
|
||||
*/
|
||||
function UpdateJrn($p_cn,$p_jr_id)
|
||||
function ShowOperationExpert($p_cn,$p_jr_id)
|
||||
{
|
||||
echo_debug('jrn.php',__LINE__,"function UpdateJrn");
|
||||
// own
|
||||
$own=new own($p_cn);
|
||||
|
||||
$l_array=GetDataJrnJrId($p_cn,$p_jr_id);
|
||||
if ( $l_array == null ) {
|
||||
|
|
@ -54,38 +60,38 @@ require_once('class_fiche.php');
|
|||
|
||||
// for the first line
|
||||
if ( $i == 0 ) {
|
||||
$r.="<TABLE>";
|
||||
$r.="<TR>";
|
||||
// Date
|
||||
$r.="<TD>";
|
||||
$r.=$content['jr_date'];
|
||||
$r.="</TD>";
|
||||
// for upload document we need the grpt_id
|
||||
$r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
|
||||
|
||||
// comment can be changed
|
||||
$r.="<TD>";
|
||||
$r.='<INPUT TYPE="TEXT" name="comment" value="';
|
||||
$r.=$content['jr_comment'];
|
||||
$r.='" SIZE="25">';
|
||||
$r.="</TD>";
|
||||
|
||||
$r.="<TABLE>";
|
||||
$r.="<TR>";
|
||||
// Date
|
||||
$r.="<TD>";
|
||||
$r.=$content['jr_date'];
|
||||
$r.="</TD>";
|
||||
// for upload document we need the grpt_id
|
||||
$r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
|
||||
|
||||
// comment can be changed
|
||||
$r.="<TD>";
|
||||
$r.='<INPUT TYPE="TEXT" name="comment" value="';
|
||||
$r.=$content['jr_comment'];
|
||||
$r.='" SIZE="40">';
|
||||
$r.="</TD>";
|
||||
|
||||
// Internal
|
||||
$r.="<TD>";
|
||||
$r.=$content['jr_internal'];
|
||||
$r.="</TD>";
|
||||
$r.="<TD>";
|
||||
$r.=$content['jr_internal'];
|
||||
$r.="</TD>";
|
||||
|
||||
if ( $content['jrn_def_type'] == 'ACH' or
|
||||
$content['jrn_def_type'] == 'VEN' )
|
||||
{
|
||||
// Is Paid
|
||||
$r.="<TD>";
|
||||
$check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
|
||||
$r.='<TD>Payé <INPUT TYPE="CHECKBOX" name="is_paid" '.$check.'></TD>';
|
||||
}
|
||||
$r.="</TR>";
|
||||
$r.="</TABLE>";
|
||||
$r.="<TABLE>";
|
||||
if ( $content['jrn_def_type'] == 'ACH' or
|
||||
$content['jrn_def_type'] == 'VEN' )
|
||||
{
|
||||
// Is Paid
|
||||
$r.="<TD>";
|
||||
$check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
|
||||
$r.='<TD>Payé <INPUT TYPE="CHECKBOX" name="is_paid" '.$check.'></TD>';
|
||||
}
|
||||
$r.="</TR>";
|
||||
$r.="</TABLE>";
|
||||
$r.="<TABLE>";
|
||||
}
|
||||
$r.="<TR>";
|
||||
if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
|
||||
|
|
@ -96,6 +102,42 @@ require_once('class_fiche.php');
|
|||
$r.="<TD>".$content['vw_name']."</td>";
|
||||
if ( $content['j_debit'] == 'f' ) $r.=$col_vide;
|
||||
$r.="<TD>".$content['j_montant']."</td>";
|
||||
if ( $content['j_debit'] == 't' ) $r.=$col_vide;
|
||||
//-- add ca
|
||||
//
|
||||
if ( $own->MY_ANALYTIC != "un" && ereg("^[6,7]+",$content['j_poste']))
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__,"Content is ",$content);
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__,"CA Content is ",$array);
|
||||
$array=make_array($p_cn,
|
||||
"select po_id as value,".
|
||||
" po_name as label from poste_analytique ".
|
||||
" where pa_id = ".$r_plan['id'].
|
||||
" order by po_name",$null);
|
||||
$op=new operation($p_cn);
|
||||
$op_array=$op->get_operation_by_jid($content['j_id']);
|
||||
$select = new widget("select","","plan_".$r_plan['id']."_".$content['j_id'],$array);
|
||||
|
||||
if ( $op_array != null)
|
||||
foreach ($op_array as $row) {
|
||||
echo_debug(__FILE__.":".__LINE__,"row is ",$row);
|
||||
if ( $r_plan['id'] == $row->pa_id ) {
|
||||
$select->selected=$row->po_id;
|
||||
}
|
||||
}
|
||||
$select->table=1;
|
||||
echo_debug(__FILE__.":".__LINE__,"select ",$select);
|
||||
$r.=$select->IOValue();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$r.="</TR>";
|
||||
|
||||
// }// foreach ($l_array[$i] as $value=>$content)
|
||||
|
|
@ -123,24 +165,24 @@ require_once('class_fiche.php');
|
|||
if ( $a != null ) {
|
||||
$r.="<b>Operation concernée</b> <br>";
|
||||
if ( isset ($_GET["PHPSESSID"]) ) {
|
||||
$sessid=$_GET["PHPSESSID"];
|
||||
$sessid=$_GET["PHPSESSID"];
|
||||
}
|
||||
else {
|
||||
$sessid=$_POST["PHPSESSID"];
|
||||
$sessid=$_POST["PHPSESSID"];
|
||||
}
|
||||
|
||||
$r.= '<div style="margin-left:30px;">';
|
||||
foreach ($a as $key => $element) {
|
||||
$r.=sprintf ('%s <INPUT TYPE="BUTTON" VALUE="Détail" onClick="modifyOperation(\'%s\',\'%s\')">',
|
||||
GetInternal($p_cn,$element),
|
||||
$element,
|
||||
$sessid);
|
||||
$r.=sprintf('<INPUT TYPE="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',\'%s\')"><BR>',
|
||||
$content['jr_id'],$element,$sessid);
|
||||
}//for
|
||||
$r.= "</div>";
|
||||
|
||||
$r.= '<div style="margin-left:30px;">';
|
||||
foreach ($a as $key => $element) {
|
||||
$r.=sprintf ('%s <INPUT TYPE="BUTTON" VALUE="Détail" onClick="modifyOperation(\'%s\',\'%s\')">',
|
||||
GetInternal($p_cn,$element),
|
||||
$element,
|
||||
$sessid);
|
||||
$r.=sprintf('<INPUT TYPE="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',\'%s\')"><BR>',
|
||||
$content['jr_id'],$element,$sessid);
|
||||
}//for
|
||||
$r.= "</div>";
|
||||
}// if ( $a != null ) {
|
||||
|
||||
|
||||
if ( isset ($_GET["PHPSESSID"]) ) {
|
||||
$sessid=$_GET["PHPSESSID"];
|
||||
}
|
||||
|
|
@ -158,6 +200,324 @@ require_once('class_fiche.php');
|
|||
return $r;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Display the form to UPDATE account operation in the user view
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $jr_id pk of jrn
|
||||
*
|
||||
* \return none
|
||||
*
|
||||
*
|
||||
*/
|
||||
function ShowOperationUser($p_cn,$p_jr_id)
|
||||
{
|
||||
echo_debug('jrn.php',__LINE__,"function UpdateJrn");
|
||||
|
||||
$l_array=GetDataJrnJrIdUser($p_cn,$p_jr_id);
|
||||
|
||||
/* if the operation doesn't exist in the quant_xxx table then we
|
||||
* show the expert view
|
||||
*/
|
||||
|
||||
if ( $l_array == null ) {
|
||||
// If the operation is not in quant_sold or quant_purchase
|
||||
// because those tables comes later
|
||||
$r=ShowOperationExpert($p_cn,$p_jr_id);
|
||||
return $r;
|
||||
}
|
||||
// own
|
||||
$own=new own($p_cn);
|
||||
|
||||
echo_debug('jrn.php',__LINE__,$l_array);
|
||||
// Javascript
|
||||
$r=JS_VIEW_JRN_MODIFY;
|
||||
|
||||
// Build the form
|
||||
$col_vide="<TD></TD>";
|
||||
|
||||
|
||||
$content=$l_array[0] ;
|
||||
// for the first line
|
||||
$internal=$content['jr_internal'];
|
||||
|
||||
$r.='<TABLE>';
|
||||
$r.="<TR>";
|
||||
// Date
|
||||
$r.="<TD>";
|
||||
$r.=$content['jr_date'];
|
||||
|
||||
// for upload document we need the grpt_id
|
||||
$r.='<Input type="hidden" name="jr_grpt_id" value="'.$content['jr_grpt_id'].'">';
|
||||
|
||||
// comment can be changed
|
||||
|
||||
$r.='<INPUT TYPE="TEXT" name="comment" value="';
|
||||
$r.=$content['jr_comment'];
|
||||
$r.='" SIZE="40">';
|
||||
|
||||
|
||||
// Internal
|
||||
|
||||
$r.=$content['jr_internal'];
|
||||
$r.="</TD>";
|
||||
|
||||
// Is Paid
|
||||
$r.="<TD>";
|
||||
$check=( $content['jr_rapt'] != null )?"CHECKED":"UNCHECKED";
|
||||
$r.='<TD>Payé <INPUT TYPE="CHECKBOX" name="is_paid" '.$check.'></TD>';
|
||||
|
||||
$r.="</TR>";
|
||||
|
||||
echo_debug(__FILE__.":".__LINE__."jrn_Def_type = ".$content['jrn_def_type']);
|
||||
// for others lines
|
||||
|
||||
// for purchase ledger
|
||||
if ( $content['jrn_def_type'] == 'ACH' )
|
||||
{
|
||||
$r.='<tr><td><table>';
|
||||
echo_debug(__FILE__.":".__LINE__." content['qp_supplier'] ".$content['qp_supplier']);
|
||||
$client=new fiche($p_cn,$content['qp_supplier']);
|
||||
$r.="Client : ".$client->getName();
|
||||
echo_debug(__FILE__,__LINE__,$content);
|
||||
|
||||
/* now we get the different lines for this operation thanks */
|
||||
/* the qp_internal == jr_internal */
|
||||
$r.='<tr>';
|
||||
$r.='<th>Nom</th>';
|
||||
$r.='<th>Quantité</th>';
|
||||
$r.='<th>tva</th>';
|
||||
$r.='<th>code tva</th>';
|
||||
$r.='<th>Non Ded.</th>';
|
||||
$r.='<th>tva nd</th>';
|
||||
$r.='<th>tva d impot</th>';
|
||||
$r.='<th>prix</th>';
|
||||
$r.='</tr>';
|
||||
$object=new gestion_purchase($p_cn);
|
||||
$object->qp_internal=$internal;
|
||||
$array=$object->get_list();
|
||||
$tot_tva=0.0;
|
||||
$tot_amount=0.0;
|
||||
$tot_nd=0.0;
|
||||
$tot_tva_nd=0.0;
|
||||
$tot_tva_nd_recup=0.0;
|
||||
$i=0;
|
||||
foreach ($array as $row) {
|
||||
$fiche=new fiche($p_cn,$row->qp_fiche);
|
||||
// compute sum
|
||||
$tot_tva+=$row->qp_vat;
|
||||
$tot_nd+=$row->qp_nd_amount;
|
||||
$tot_tva_nd+=$row->qp_nd_tva;
|
||||
$tot_tva_nd_recup+=$row->qp_nd_tva_recup;
|
||||
$tot_amount+=$row->qp_price;
|
||||
|
||||
// $hid_jid=new widget("hidden","","p_jid_".$row->j_id,$row->j_id);
|
||||
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
|
||||
|
||||
$r.='<td> '.$fiche->strAttribut(ATTR_DEF_NAME).'</td>';
|
||||
$r.='<td align="right">'.$row->qp_quantite.'</td>';
|
||||
$r.='<td align="right">'.$row->qp_vat.'</td>';
|
||||
$r.='<td>'.$row->qp_vat_code.'</td>';
|
||||
$r.='<td>'.$row->qp_nd_amount.'</td>';
|
||||
$r.='<td>'.$row->qp_nd_tva.'</td>';
|
||||
$r.='<td>'.$row->qp_nd_tva_recup.'</td>';
|
||||
$r.='<td align="right">'.$row->qp_price.'</td>';
|
||||
//-- add ca
|
||||
//
|
||||
if ( $own->MY_ANALYTIC != "un" && ereg("^[6,7]+",$content['j_poste']))
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__,"Content is ",$content);
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__,"CA Content is ",$array);
|
||||
$array=make_array($p_cn,
|
||||
"select po_id as value,".
|
||||
" po_name as label from poste_analytique ".
|
||||
" where pa_id = ".$r_plan['id'].
|
||||
" order by po_name",$null);
|
||||
$op=new operation($p_cn);
|
||||
$op_array=$op->get_operation_by_jid($content['j_id']);
|
||||
$select = new widget("select","","plan_".$r_plan['id']."_".$row->j_id,$array);
|
||||
|
||||
if ( $op_array != null)
|
||||
foreach ($op_array as $row) {
|
||||
echo_debug(__FILE__.":".__LINE__,"row is ",$row);
|
||||
if ( $r_plan['id'] == $row->pa_id ) {
|
||||
$select->selected=$row->po_id;
|
||||
}
|
||||
}
|
||||
$select->table=1;
|
||||
echo_debug(__FILE__.":".__LINE__,"select ",$select);
|
||||
$r.=$select->IOValue();
|
||||
}
|
||||
}
|
||||
|
||||
$r.="</tr>";
|
||||
|
||||
}
|
||||
// display sum
|
||||
$r.='<tr><td colspan="8"><hr style="color:blue;"></td></tr>';
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total HTVA</td>'.
|
||||
'<td>'.sprintf('% 12.2f',$tot_amount)."</td>".
|
||||
"</tr>";
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total TVA</td>'.
|
||||
'<td>'.sprintf('%12.2f',$tot_tva)
|
||||
."</td>".
|
||||
"</tr>";
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total nd </td>'.
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_nd)."</td>".
|
||||
"</tr>";
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total tva nd</td>'.
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva_nd)."</td>".
|
||||
"</tr>";
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total tva nd recup. par impot</td>'.
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva_nd_recup)."</td>".
|
||||
"</tr>";
|
||||
$r.='<tr style="font-size:13px;color:green;">'.
|
||||
'<td colspan="7">Total </td>'.
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_amount+$tot_tva)."</td>".
|
||||
"</tr>";
|
||||
|
||||
echo '</table></td></tr>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
// for selling ledger
|
||||
if ( $content['jrn_def_type'] == 'VEN' )
|
||||
{
|
||||
echo_debug(__FILE__.":".__LINE__." content['qs_client'] ".$content['qs_client']);
|
||||
$client=new fiche($p_cn,$content['qs_client']);
|
||||
$r.="Client : ".$client->getName();
|
||||
echo_debug(__FILE__,__LINE__,$content);
|
||||
|
||||
/* now we get the different lines for this operation thanks */
|
||||
/* the qs_internal == jr_internal */
|
||||
$r.='<tr>';
|
||||
$r.='<th>Nom</th>';
|
||||
$r.='<th>Quantité</th>';
|
||||
$r.='<th>tva</th>';
|
||||
$r.='<th>code tva</th>';
|
||||
$r.='<th>prix</th>';
|
||||
$r.='</tr>';
|
||||
$object=new gestion_sold($p_cn);
|
||||
$object->qs_internal=$internal;
|
||||
$array=$object->get_list();
|
||||
$tot_tva=0.0;
|
||||
$tot_amount=0.0;
|
||||
$i=0;
|
||||
foreach ($array as $row) {
|
||||
$fiche=new fiche($p_cn,$row->qs_fiche);
|
||||
$tot_tva+=$row->qs_vat;
|
||||
$tot_amount+=$row->qs_price;
|
||||
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
|
||||
|
||||
/* $hid_jid=new widget("hidden","","p_jid_".$row->j_id,$row->j_id); */
|
||||
/* $r.=$hid_jid->IOValue(); */
|
||||
|
||||
$r.=($i%2==0)?"<tr class=\"odd\">":'<tr>'; $i++;
|
||||
$r.='<td> '.$fiche->strAttribut(ATTR_DEF_NAME).'</td>';
|
||||
$r.='<td align="right">'.$row->qs_quantite.'</td>';
|
||||
$r.='<td align="right">'.$row->qs_vat.'</td>';
|
||||
$r.='<td>'.$row->qs_vat_code.'</td>';
|
||||
$r.='<td align="right">'.$row->qs_price.'</td>';
|
||||
|
||||
$r.="</tr>";
|
||||
}
|
||||
$r.="<tr>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>Total HTVA</td>".
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('% 12.2f',$tot_amount)."</td>".
|
||||
"</tr>";
|
||||
$r.="<tr>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>Total TVA</td>".
|
||||
'<td style="text-justify:right;font-size:13px;color:green;">'.sprintf('%12.2f',$tot_tva)
|
||||
."</td>".
|
||||
"</tr>";
|
||||
$r.="<tr>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>"."</td>".
|
||||
"<td>Total </td>".
|
||||
'<td style="font-size:13px;color:green;">'.sprintf('%12.2f',$tot_amount+$tot_tva)."</td>".
|
||||
"</tr>";
|
||||
|
||||
}
|
||||
$r.="</TABLE>";
|
||||
|
||||
$file=new widget("file");
|
||||
$file->table=1;
|
||||
//document
|
||||
$r.='<tr><TD>A effacer <INPUT TYPE="CHECKBOX" name="to_remove" ></TD>';
|
||||
$r.="<TD>".sprintf('<A class="detail" HREF="show_pj.php?jrn=%s&jr_grpt_id=%s">%s</A>',
|
||||
$content['jr_id'],
|
||||
$content['jr_grpt_id'],
|
||||
$content['jr_pj_name'])."</TD>";
|
||||
$r.="</TR></TABLE>";
|
||||
$r.="<hr>";
|
||||
$r.= "<table>";
|
||||
$r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
|
||||
$r.="</table>";
|
||||
$r.="<hr>";
|
||||
|
||||
$r.="</table>";
|
||||
$r.="Total ".$content['jr_montant']."<br>";
|
||||
// show all the related operation
|
||||
$a=GetConcerned($p_cn,$content['jr_id']);
|
||||
|
||||
if ( $a != null ) {
|
||||
$r.="<b>Operation concernée</b> <br>";
|
||||
if ( isset ($_GET["PHPSESSID"]) ) {
|
||||
$sessid=$_GET["PHPSESSID"];
|
||||
}
|
||||
else {
|
||||
$sessid=$_POST["PHPSESSID"];
|
||||
}
|
||||
|
||||
$r.= '<div style="margin-left:30px;">';
|
||||
foreach ($a as $key => $element) {
|
||||
$r.=sprintf ('%s <INPUT TYPE="BUTTON" VALUE="Détail" onClick="modifyOperation(\'%s\',\'%s\')">',
|
||||
GetInternal($p_cn,$element),
|
||||
$element,
|
||||
$sessid);
|
||||
$r.=sprintf('<INPUT TYPE="button" value="Efface" onClick="dropLink(\'%s\',\'%s\',\'%s\')"><BR>',
|
||||
$content['jr_id'],$element,$sessid);
|
||||
}//for
|
||||
$r.= "</div>";
|
||||
}// if ( $a != null ) {
|
||||
|
||||
if ( isset ($_GET["PHPSESSID"]) ) {
|
||||
$sessid=$_GET["PHPSESSID"];
|
||||
}
|
||||
else {
|
||||
$sessid=$_POST["PHPSESSID"];
|
||||
}
|
||||
|
||||
$search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchJrn(\''.$sessid."','rapt','".$content['jr_montant']."')\">";
|
||||
|
||||
$r.= '<H2 class="info">rapprochement </H2>
|
||||
<INPUT TYPE="TEXT" name="rapt" value="">'.$search;
|
||||
$r.='<input type="hidden" name="jr_id" value="'.$content['jr_id'].'">';
|
||||
|
||||
// echo $r;
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Get the properties of a journal
|
||||
*
|
||||
|
|
@ -345,7 +705,7 @@ function GetData ($p_cn,$p_grpt) {
|
|||
jr_comment,
|
||||
to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
|
||||
to_char(jr_date,'DD.MM.YYYY') as jr_date,
|
||||
jr_id,jr_internal,jr_def_id
|
||||
jr_id,jr_internal,jr_def_id,jr_pj
|
||||
from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$p_grpt");
|
||||
$MaxLine=pg_NumRows($Res);
|
||||
if ( $MaxLine == 0 ) return null;
|
||||
|
|
@ -579,8 +939,6 @@ function SetInternalCode($p_cn,$p_grpt,$p_jrn)
|
|||
$atype=GetJrnProp($_SESSION['g_dossier'],$p_jrn);
|
||||
$type=$atype['jrn_def_code'];
|
||||
$internal_code=sprintf("%d%s-%s",$_SESSION['g_dossier'],$type,$num);
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal_code."' where ".
|
||||
" jr_grpt_id = ".$p_grpt);
|
||||
echo_debug ("jrn.php",__LINE__,"internal_code = $internal_code");
|
||||
return $internal_code;
|
||||
}
|
||||
|
|
@ -627,6 +985,86 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) {
|
|||
|
||||
for ( $i=0; $i < $MaxLine; $i++) {
|
||||
$line=pg_fetch_array($Res,$i);
|
||||
$array['j_debit']=$line['j_debit'];
|
||||
// is there a name from this j_qcode
|
||||
//
|
||||
if ( strlen( $line['j_qcode']) != 0 )
|
||||
{
|
||||
$fiche=new fiche($p_cn);
|
||||
$fiche->GetByQCode($line['j_qcode']);
|
||||
|
||||
$array['vw_name']=$fiche->getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
$array['vw_name']=$line['pcm_lib'];
|
||||
}
|
||||
|
||||
$array['jr_comment']=$line['jr_comment'];
|
||||
$array['j_montant']=$line['j_montant'];
|
||||
$array['jr_id']=$line['jr_id'];
|
||||
$array['j_id']=$line['j_id'];
|
||||
$array['jr_date']=$line['jr_date'];
|
||||
$array['jr_internal']=$line['jr_internal'];
|
||||
$array['j_poste']=$line['j_poste'];
|
||||
$array['jr_montant']=$line['jr_montant'];
|
||||
$array['jr_rapt']=$line['jr_rapt'];
|
||||
$array['jrn_def_type']=$line['jrn_def_type'];
|
||||
$array['jr_grpt_id']=$line['jr_grpt_id'];
|
||||
$array['jr_pj_name']=$line['jr_pj_name'];
|
||||
// $array['']=$line[''];
|
||||
|
||||
$ret_array[$i]=$array;
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
/*!
|
||||
* \brief Get data from quant_sold or quand_purchase for the user
|
||||
* view mode
|
||||
*
|
||||
*
|
||||
* \param connection
|
||||
* \param p_jr_id (jrn.jr_id)
|
||||
*
|
||||
*
|
||||
* \return array or null if there is no value
|
||||
*
|
||||
*/
|
||||
function GetDataJrnJrIdUser ($p_cn,$p_jr_id) {
|
||||
|
||||
echo_debug(__FILE__.":".__LINE__."GetDataJrnJrIdUser");
|
||||
|
||||
$Res=ExecSql($p_cn,"select ".
|
||||
"*".
|
||||
" from quant_sold join jrn on (qs_internal=jr_internal) ".
|
||||
" join jrn_def on (jr_def_id=jrn_def_id) ".
|
||||
" where jr_id=$p_jr_id");
|
||||
|
||||
|
||||
$MaxLine=pg_NumRows($Res);
|
||||
echo_debug('jrn.php',__LINE__,"Found $MaxLine lines");
|
||||
|
||||
|
||||
// if no info found in quant_sold try in quant_purchase
|
||||
if ( $MaxLine == 0 )
|
||||
{
|
||||
$Res=ExecSql($p_cn,"select ".
|
||||
"*".
|
||||
" from quant_purchase join jrn on (qp_internal=jr_internal)".
|
||||
" join jrn_def on (jr_def_id=jrn_def_id) ".
|
||||
" where jr_id=$p_jr_id");
|
||||
$MaxLine=pg_NumRows($Res);
|
||||
if ( $MaxLine == 0 ) return null;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
for ( $i=0; $i < $MaxLine; $i++) {
|
||||
$line=pg_fetch_array($Res,$i);
|
||||
|
||||
|
||||
$array['j_debit']=$line['j_debit'];
|
||||
// is there a name from this j_qcode
|
||||
//
|
||||
|
|
@ -641,7 +1079,19 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) {
|
|||
{
|
||||
$array['vw_name']=$line['pcm_lib'];
|
||||
}
|
||||
|
||||
|
||||
if ( isset ($line['qs_client']))
|
||||
{
|
||||
/* It is an invoice */
|
||||
$array['qs_client']=$line['qs_client'];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* it a purchase */
|
||||
$array['qp_supplier']=$line['qp_supplier'];
|
||||
|
||||
}
|
||||
|
||||
$array['jr_comment']=$line['jr_comment'];
|
||||
$array['j_montant']=$line['j_montant'];
|
||||
$array['jr_id']=$line['jr_id'];
|
||||
|
|
@ -659,4 +1109,5 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) {
|
|||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -52,12 +52,24 @@ echo JS_CONFIRM;
|
|||
}// if $mod_name != null
|
||||
|
||||
$cn_mod=dbconnect($l_id,'mod');
|
||||
|
||||
// Clean some tables
|
||||
$Res=ExecSql($cn_mod,"truncate table jrn");
|
||||
$Res=ExecSql($cn_mod,"select distinct jr_pj from jrn where jr_pj is not null ");
|
||||
if ( pg_NumRows($Res) != 0 )
|
||||
{
|
||||
$a_lob=pg_fetch_all($Res);
|
||||
foreach ($a_lob as $lob)
|
||||
pg_lo_unlink($cn_mod,$lob['loid']);
|
||||
}
|
||||
|
||||
$Res=ExecSql($cn_mod,"truncate table jrnx");
|
||||
$Res=ExecSql($cn_mod,"truncate table centralized");
|
||||
$Res=ExecSql($cn_mod,"truncate table stock_goods");
|
||||
// TODO
|
||||
// Nettoyage table quant_*
|
||||
$Res=ExecSql($cn_mod,"truncate table jrn_rapt");
|
||||
$Res=ExecSql($cn_mod,"truncate table import_tmp");
|
||||
// Reset the closed periode
|
||||
$Res=ExecSql($cn_mod,"update parm_periode set p_closed='f'");
|
||||
// Reset Sequence
|
||||
|
|
@ -73,7 +85,46 @@ echo JS_CONFIRM;
|
|||
$row=pg_fetch_array($Res,$seq);
|
||||
$sql=sprintf ("select setval('s_jrn_%d',1,false)",$row['jrn_def_id']);
|
||||
ExecSql($cn_mod,$sql);
|
||||
$sql=sprintf ("select setval('s_jrn_pj_%d',1,false)",$row['jrn_def_id']);
|
||||
ExecSql($cn_mod,$sql);
|
||||
|
||||
}
|
||||
//---
|
||||
// Cleaning Action
|
||||
//--
|
||||
if ( isset($_POST['DOC'] ))
|
||||
{
|
||||
$Res=ExecSql($cn_mod,"delete from action_gestion");
|
||||
$Res=ExecSql($cn_mod,"delete from document");
|
||||
// Remove lob file
|
||||
$Res=ExecSql($cn_mod,"select distinct loid from pg_largeobject");
|
||||
if ( pg_NumRows($Res) != 0 )
|
||||
{
|
||||
$a_lob=pg_fetch_all($Res);
|
||||
//var_dump($a_lob);
|
||||
foreach ($a_lob as $lob) {
|
||||
pg_lo_unlink($cn_mod,$lob['loid']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset($_POST['CARD']))
|
||||
{
|
||||
$Res=ExecSql($cn_mod,"delete from attr_value");
|
||||
$Res=ExecSql($cn_mod,"delete from jnt_fic_att_value");
|
||||
$Res=ExecSql($cn_mod,"delete from fiche");
|
||||
$Res=ExecSql($cn_mod,"delete from action_gestion");
|
||||
$Res=ExecSql($cn_mod,"delete from document");
|
||||
// Remove lob file
|
||||
$Res=ExecSql($cn_mod,"select distinct loid from pg_largeobject");
|
||||
if ( pg_NumRows($Res) != 0 )
|
||||
{
|
||||
$a_lob=pg_fetch_all($Res);
|
||||
foreach ($a_lob as $lob)
|
||||
pg_lo_unlink($cn_mod,$lob['loid']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -143,6 +194,11 @@ echo JS_CONFIRM;
|
|||
<TD> Basé sur </TD>
|
||||
<TD> <?php echo $available ?></TD>
|
||||
</TR>
|
||||
<TR><TD>Nettoyage des Documents et courriers (ce qui n'effacera pas les modèles de documents)</TD><TD> <input type="checkbox" name="DOC"></TD></TR>
|
||||
<TR><TD>Nettoyage de toutes les fiches (ce qui effacera client, fournisseurs et documents)</TD><TD> <input type="checkbox" name="CARD"></TD></TR>
|
||||
|
||||
|
||||
|
||||
<TR>
|
||||
<td colspan="2"> <INPUT TYPE="SUBMIT" VALUE="Add a template"></TD>
|
||||
</TR>
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ function DbConnect($p_db=-1,$p_type='dossier') {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$phpcompta_user=phpcompta_user;
|
||||
$password=phpcompta_password;
|
||||
$port=phpcompta_psql_port;
|
||||
ob_start();
|
||||
|
|
@ -104,9 +105,11 @@ password='$password' port=$port");
|
|||
if ( $a == false )
|
||||
{
|
||||
ob_clean();
|
||||
echo '<h2 class="error">Impossible de se connecter à postgreSql !</h2>';
|
||||
echo "Vos paramètres sont incorrectes : <br>";
|
||||
echo "<br>";
|
||||
echo "base de donnée : $l_dossier<br>";
|
||||
echo "Domaine : ".domaine."<br>";
|
||||
echo "Port $port <br>";
|
||||
echo "Utilisateur : $phpcompta_user <br>";
|
||||
|
||||
|
|
@ -125,15 +128,14 @@ de données");
|
|||
* \param $p_exit if true exits in case of error otherwise returns false
|
||||
* \return false if error otherwise true
|
||||
*/
|
||||
function ExecSql($p_connection, $p_string,$p_exit=true) {
|
||||
function ExecSql($p_connection, $p_string) {
|
||||
echo_debug('postgres.php',__LINE__,"SQL = $p_string");
|
||||
// probl. with Ubuntu & UTF8
|
||||
//----
|
||||
pg_set_client_encoding($p_connection,'latin1');
|
||||
$ret=pg_query($p_connection,$p_string);
|
||||
if ( $ret == false && $p_exit ) {
|
||||
echo_error ("SQL ERROR ::: $p_string");
|
||||
exit(" Operation cancelled due to error : $p_string");
|
||||
if ( $ret == false ) {
|
||||
throw new Exception ("SQL ERROR ::: $p_string",1);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
|
@ -401,11 +403,17 @@ function save_upload_document ($cn,$seq) {
|
|||
|
||||
$new_name=tempnam('/tmp','pj');
|
||||
echo_debug('postgres.php',__LINE__,"new name=".$new_name);
|
||||
echo_debug(__FILE__.":".__LINE__.$_FILES);
|
||||
if ($_FILES["pj"]["error"] > 0)
|
||||
{
|
||||
echo_error(__FILE__.":".__LINE__."Error: " . $_FILES["pj"]["error"] );
|
||||
}
|
||||
if ( strlen ($_FILES['pj']['tmp_name']) != 0 ) {
|
||||
echo_debug(__FILE__.":".__LINE__.'_FILE is'.$_FILES['pj']['tmp_name']);
|
||||
if (move_uploaded_file($_FILES['pj']['tmp_name'],
|
||||
$new_name)) {
|
||||
// echo "Image saved";
|
||||
|
||||
echo_debug(__FILE__.":".__LINE__."Doc saved");
|
||||
$oid= pg_lo_import($cn,$new_name);
|
||||
if ( $oid == false ) {
|
||||
echo_error('postgres.php',__LINE__,"cannot upload document");
|
||||
|
|
|
|||
|
|
@ -28,22 +28,28 @@ if ( isset ($_POST['spass']) ) {
|
|||
if ( $_POST['pass_1'] != $_POST['pass_2'] ) {
|
||||
?>
|
||||
<script>
|
||||
alert("Les mots de passe ne correspondent pas. Mot de passe inchangé");
|
||||
alert("Les mots de passe ne correspondent pas. Mot de passe inchangé");
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
$Rep=DbConnect();
|
||||
$l_pass=md5($_POST['pass_1']);
|
||||
$Res=ExecSql($Rep,"update ac_users set use_pass='$l_pass' where use_login='".$_SESSION['g_user']."'");
|
||||
$pass=$_POST['pass_1'];
|
||||
$_SESSION['g_pass']=$_POST['pass_1'];
|
||||
$g_pass=$_POST['pass_1'];
|
||||
echo "<i>Mot de passe est modifié</i>";
|
||||
}
|
||||
}
|
||||
$url=$_SERVER['REQUEST_URI'];
|
||||
if ( ! isset ($_SESSION['g_dossier']) )
|
||||
{
|
||||
echo '<A class="mtitle" href="user_login.php"><input type="button" value="Retour"></a>';
|
||||
}
|
||||
|
||||
?>
|
||||
<H2 CLASS="info"> Password</H2>
|
||||
<H2 CLASS="info"> Mot de passe</H2>
|
||||
|
||||
<FORM ACTION="<?php echo $url;?>" METHOD="POST">
|
||||
<TABLE ALIGN="CENTER">
|
||||
|
|
@ -54,7 +60,6 @@ $url=$_SERVER['REQUEST_URI'];
|
|||
</FORM>
|
||||
<?php
|
||||
$Rep=DbConnect();
|
||||
|
||||
// charge tous les styles
|
||||
$res=ExecSql($Rep,"select the_name from theme
|
||||
order by the_name");
|
||||
|
|
@ -73,7 +78,7 @@ foreach ($style as $st){
|
|||
}
|
||||
$disp_style.="</SELECT>";
|
||||
?>
|
||||
<H2 class="info">Thème</H2>
|
||||
<H2 class="info">Thème</H2>
|
||||
<FORM ACTION="<?php echo $url; ?>" METHOD="post">
|
||||
<TABLE ALIGN="center">
|
||||
<TR>
|
||||
|
|
@ -90,29 +95,35 @@ $disp_style.="</SELECT>";
|
|||
|
||||
// Si utilise un dossier alors propose de changer
|
||||
// la periode par defaut
|
||||
if ( isset ($_SESSION['g_dossier']) ) {
|
||||
|
||||
include_once("preference.php");
|
||||
$msg="";
|
||||
|
||||
if ( isset ($_POST["sub_periode"] ) ) {
|
||||
$periode=$_POST["periode"];
|
||||
$User->SetPeriode($periode);
|
||||
echo_debug('pref.inc',__LINE__,"Periode returns ".PeriodeClosed($cn,$periode));
|
||||
}
|
||||
|
||||
$l_user_per=$User->GetPeriode();
|
||||
// if periode is closed then warns the users
|
||||
if ( PeriodeClosed($cn,$l_user_per)=='t')
|
||||
if ( ! isset ($_SESSION['g_dossier']) )
|
||||
{
|
||||
$msg= '<h2 class="error">Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable</h2>';
|
||||
echo '<A href="user_login.php"><input type="button" value="Retour"></a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
include_once("preference.php");
|
||||
$msg="";
|
||||
$cn=DbConnect($_SESSION['g_dossier']);
|
||||
if ( isset ($_POST["sub_periode"] ) )
|
||||
{
|
||||
$periode=$_POST["periode"];
|
||||
$User->SetPeriode($periode);
|
||||
echo_debug('pref.inc',__LINE__,"Periode returns ".PeriodeClosed($cn,$periode));
|
||||
}
|
||||
|
||||
$l_form_per=FormPeriode($cn,$l_user_per,ALL);
|
||||
$l_user_per=$User->GetPeriode();
|
||||
// if periode is closed then warns the users
|
||||
if ( PeriodeClosed($cn,$l_user_per)=='t')
|
||||
{
|
||||
$msg= '<h2 class="error">Attention cette période est fermée, vous ne pourrez rien modifier dans le module comptable</h2>';
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<H2 CLASS="info"> Période</H2>
|
||||
$l_form_per=FormPeriode($cn,$l_user_per,ALL);
|
||||
|
||||
?>
|
||||
<H2 CLASS="info"> Période</H2>
|
||||
<?php echo $msg; ?>
|
||||
<FORM ACTION="<?php echo $url;?>" METHOD="POST">
|
||||
<TABLE ALIGN="CENTER">
|
||||
|
|
@ -134,9 +145,9 @@ if ( isset ($_SESSION['g_dossier']) ) {
|
|||
<option value="100">100
|
||||
<option value="150">150
|
||||
<option value="200">200
|
||||
<option value="-1">Illimité
|
||||
<option value="-1">Illimité
|
||||
<?php
|
||||
$label=($_SESSION['g_pagesize'] == -1)?'Illimité':$_SESSION['g_pagesize'];
|
||||
$label=($_SESSION['g_pagesize'] == -1)?'Illimité':$_SESSION['g_pagesize'];
|
||||
echo '<option value="'.$_SESSION['g_pagesize'].'" selected>'.$label;
|
||||
?>
|
||||
</SELECT>
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@ if ( $action == 'insert_vente' ) {
|
|||
if ( isset ($_POST["view_invoice"])) {
|
||||
$nb_number=$_POST["nb_item"];
|
||||
if ( form_verify_input($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$nb_number) == true)
|
||||
{
|
||||
$form=FormVenteView($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$nb_number);
|
||||
// Check failed : invalid date or quantity
|
||||
} else {
|
||||
echo_error("Cannot validate ");
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,false,$nb_number);
|
||||
}
|
||||
{
|
||||
$form=FormVenteView($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$nb_number);
|
||||
// Check failed : invalid date or quantity
|
||||
} else {
|
||||
echo_error("Cannot validate ");
|
||||
$form=FormVenInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,false,$nb_number);
|
||||
}
|
||||
echo '<div class="u_redcontent">';
|
||||
echo $form;
|
||||
echo '</div>';
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ function GetTvaRate($p_cn,$p_tva_id) {
|
|||
* \return: array
|
||||
* a[tva_id] = amount vat
|
||||
*/
|
||||
function ComputeTotalVat($p_cn, $a_fiche,$a_quant,$a_price,$ap_vat,$a_vat_amount=null,$all=false ) {
|
||||
function ComputeTotalVat($p_cn, $a_fiche,$a_quant,$a_price,$ap_vat,$a_vat_amount=null,$all=false )
|
||||
{
|
||||
echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_price");
|
||||
foreach ( $a_fiche as $t=>$el) {
|
||||
echo_debug('user_common.php',__LINE__,"t $t e $el");
|
||||
|
|
@ -115,7 +116,11 @@ echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_pric
|
|||
// if a vat amount is given
|
||||
if ( $a_vat_amount != null &&
|
||||
$a_vat_amount[$idx] != 0 )
|
||||
{
|
||||
$vat_amount= $a_vat_amount[$idx] ;
|
||||
echo_debug(__FILE__.':'.__LINE__.'- VAT_AMOUNT IS GIVEN '.$vat_amount);
|
||||
|
||||
}
|
||||
echo_debug('user_common',__LINE__,"vat amount = $vat_amount");
|
||||
// only the deductible vat
|
||||
if ( $all == false )
|
||||
|
|
@ -360,7 +365,9 @@ comment = $p_comment");
|
|||
*/
|
||||
function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null,$p_value=0,$p_paid=0)
|
||||
{
|
||||
|
||||
echo_debug(__FILE__,__LINE__,"Entering into function ListJrn($p_cn,$p_jrn,$p_where='',$p_array=null,$p_value=0,$p_paid=0)");
|
||||
$amount_paid=0.0;
|
||||
$amount_unpaid=0.0;
|
||||
include_once("central_inc.php");
|
||||
$limit=($_SESSION['g_pagesize']!=-1)?" LIMIT ".$_SESSION['g_pagesize']:"";
|
||||
$offset=($_SESSION['g_pagesize']!=-1)?" OFFSET ".$p_value:"";
|
||||
|
|
@ -599,9 +606,30 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
|
|||
//internal code
|
||||
// button modify
|
||||
$r.="<TD>";
|
||||
// If url contains
|
||||
$r.=sprintf('<A class="detail" HREF="javascript:modifyOperation(\'%s\',\'%s\',\'%s\')" >%s</A>',
|
||||
$row['jr_id'], $l_sessid, $p_jrn, $row['jr_internal']);
|
||||
// If url contains
|
||||
//
|
||||
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
echo_debug(__FILE__,__LINE__,"href = $href");
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$vue="E"; //Expert View
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$vue="S"; //Simple View
|
||||
break;
|
||||
case 'recherche.php':
|
||||
$vue=(isset($_GET['expert']))?'E':'S';
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
$r.=sprintf('<A class="detail" HREF="javascript:modifyOperation(\'%s\',\'%s\',\'%s\',\'%s\')" >%s</A>',
|
||||
$row['jr_id'], $l_sessid, $p_jrn,$vue, $row['jr_internal']);
|
||||
$r.="</TD>";
|
||||
// date
|
||||
$r.="<TD>";
|
||||
|
|
@ -640,14 +668,18 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
|
|||
// Show the paid column if p_paid is not null
|
||||
if ( $p_paid !=0 )
|
||||
{
|
||||
$w=new widget("checkbox");
|
||||
$w->name="rd_paid".$row['jr_id'];
|
||||
$w->selected=($row['jr_rapt']=='paid')?true:false;
|
||||
// if p_paid == 2 then readonly
|
||||
$w->readonly=( $p_paid == 2)?true:false;
|
||||
$h=new widget("hidden");
|
||||
$h->name="set_jr_id".$row['jr_id'];
|
||||
$r.='<TD>'.$w->IOValue().$h->IOValue().'</TD>';
|
||||
$w=new widget("checkbox");
|
||||
$w->name="rd_paid".$row['jr_id'];
|
||||
$w->selected=($row['jr_rapt']=='paid')?true:false;
|
||||
// if p_paid == 2 then readonly
|
||||
$w->readonly=( $p_paid == 2)?true:false;
|
||||
$h=new widget("hidden");
|
||||
$h->name="set_jr_id".$row['jr_id'];
|
||||
$r.='<TD>'.$w->IOValue().$h->IOValue().'</TD>';
|
||||
if ( $row['jr_rapt']=='paid')
|
||||
$amount_paid+=$row['jr_montant'];
|
||||
else
|
||||
$amount_unpaid+=$row['jr_montant'];
|
||||
}
|
||||
|
||||
// Rapprochement
|
||||
|
|
@ -658,7 +690,9 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
|
|||
|
||||
foreach ($a as $key => $element)
|
||||
{
|
||||
$r.= "<A class=\"detail\" HREF=\"javascript:modifyOperation('".$element."','".$l_sessid."')\" > ".GetInternal($p_cn,$element)."</A>";
|
||||
$l_amount=getDbValue($p_cn,"select jr_montant from jrn ".
|
||||
" where jr_id=$element");
|
||||
$r.= "<A class=\"detail\" HREF=\"javascript:modifyOperation('".$element."','".$l_sessid."')\" > ".GetInternal($p_cn,$element)." [ $l_amount € ]</A>";
|
||||
}//for
|
||||
}// if ( $a != null ) {
|
||||
$r.="</TD>";
|
||||
|
|
@ -694,9 +728,20 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech
|
|||
$r.="<TR>";
|
||||
$r.='<TD COLSPAN="4">Total</TD>';
|
||||
$r.='<TD ALIGN="RIGHT">'.$tot."</TD>";
|
||||
$r.="</tr>";
|
||||
if ( $p_paid != 0 ) {
|
||||
$r.="<TR>";
|
||||
$r.='<TD COLSPAN="4">Payé</TD>';
|
||||
$r.='<TD ALIGN="RIGHT">'.$amount_paid."</TD>";
|
||||
$r.="</tr>";
|
||||
$r.="<TR>";
|
||||
$r.='<TD COLSPAN="4">Non payé</TD>';
|
||||
$r.='<TD ALIGN="RIGHT">'.$amount_unpaid."</TD>";
|
||||
$r.="</tr>";
|
||||
}
|
||||
$r.="</table>";
|
||||
|
||||
return array ($count,$r);
|
||||
return array ($count,$r);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -876,7 +921,8 @@ function DeleteRapt($p_cn,$jr_id,$jr_id2) {
|
|||
* \return array if something is found or null
|
||||
*/
|
||||
function GetConcerned ($p_cn, $jr_id) {
|
||||
$sql=" select jr_id as cn from jrn_rapt where jra_concerned=$jr_id
|
||||
echo_debug(__FILE__.":".__LINE__."Get Concerned");
|
||||
$sql=" select jr_id as cn from jrn_rapt where jra_concerned=$jr_id
|
||||
union
|
||||
select jra_concerned as cn from jrn_rapt where jr_id=$jr_id";
|
||||
$Res=ExecSql($p_cn,$sql);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ require_once("preference.php");
|
|||
require_once("fiche_inc.php");
|
||||
require_once("user_common.php");
|
||||
require_once("class_parm_code.php");
|
||||
|
||||
require_once ('class_plananalytic.php');
|
||||
require_once ('class_own.php');
|
||||
require_once ('class_operation.php');
|
||||
/*!
|
||||
* \brief Display the form for a sell
|
||||
* Used to show detail, encode a new invoice
|
||||
|
|
@ -466,12 +468,13 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
|
|||
* \param $p_periode
|
||||
* \param $p_array array of value
|
||||
* \param $p_number nb of item
|
||||
*\param $piece == true we can upload a doc.
|
||||
*\param $p_piece == true we can upload a doc.
|
||||
*
|
||||
*/
|
||||
|
||||
function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_piece=true)
|
||||
{
|
||||
echo_debug(__FILE__.':'.__LINE__.'- FormAchView');
|
||||
$r="";
|
||||
$data="";
|
||||
// Keep all the data if hidden
|
||||
|
|
@ -481,7 +484,39 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
$data.=$hidden->IOValue($name,$content);
|
||||
${"$name"}=$content;
|
||||
}
|
||||
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=new&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=depense&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Compute the col head for CA
|
||||
$head_ca="";
|
||||
$own = new Own($p_cn);
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$head_ca.="<th>".$r_plan['name']."</th>";
|
||||
}
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
$r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
|
||||
// start table
|
||||
$r.='<TABLE>';
|
||||
// Show the Date
|
||||
|
|
@ -500,6 +535,7 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
// Show desc
|
||||
$r.="<tr>";
|
||||
$r.="<TD> Description : $e_comm</TD>";
|
||||
|
||||
$r.="</tr>";
|
||||
|
||||
$sum_with_vat=0.0;
|
||||
|
|
@ -513,14 +549,15 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
$r.="<TH>Montant HTVA</TH>";
|
||||
$r.="<TH>Montant TVA</TH>";
|
||||
$r.="<TH>Total</TH>";
|
||||
$r.=$head_ca;
|
||||
$r.="</TR>";
|
||||
for ($i=0;$i<$p_number;$i++)
|
||||
{
|
||||
if ( trim(${"e_march$i"}) == "" )
|
||||
{
|
||||
// no goods to sell
|
||||
continue;
|
||||
}
|
||||
{
|
||||
// no goods to sell
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the name
|
||||
$fiche_name=getFicheName($p_cn,${"e_march$i"});
|
||||
|
|
@ -533,14 +570,16 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
|
||||
|
||||
// If the price is not a number, retrieve the price from the database
|
||||
if ( isNumber(${"e_march$i"."_buy"}) == 0 ) {
|
||||
$fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE);
|
||||
} else {
|
||||
$fiche_price=${"e_march$i"."_buy"};
|
||||
}
|
||||
if ( isNumber(${"e_march$i"."_buy"}) == 0 )
|
||||
{
|
||||
$fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE);
|
||||
} else
|
||||
{
|
||||
$fiche_price=${"e_march$i"."_buy"};
|
||||
}
|
||||
// round it
|
||||
$fiche_price=round($fiche_price,2);
|
||||
|
||||
|
||||
// get TVA Amount
|
||||
$tva_amount=round(${"e_march".$i."_tva_amount"},2);
|
||||
|
||||
|
|
@ -551,15 +590,15 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
// vat rate
|
||||
$a_vat=GetTvaRate($p_cn,$vat);
|
||||
if ( $a_vat == null )
|
||||
{
|
||||
$vat_label="";
|
||||
$vat_rate=0.0;
|
||||
}
|
||||
{
|
||||
$vat_label="";
|
||||
$vat_rate=0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$vat_label=$a_vat['tva_label'];
|
||||
$vat_rate=$a_vat['tva_rate'];
|
||||
}
|
||||
{
|
||||
$vat_label=$a_vat['tva_label'];
|
||||
$vat_rate=$a_vat['tva_rate'];
|
||||
}
|
||||
|
||||
// Total card without vat
|
||||
$fiche_sum=$fiche_price*$fiche_quant;
|
||||
|
|
@ -567,20 +606,23 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
$sum_march+=$fiche_sum;
|
||||
// vat of the card
|
||||
if ( $tva_amount == 0)
|
||||
{
|
||||
$fiche_amount_vat=round($fiche_price*$fiche_quant*$vat_rate,2);
|
||||
// value card + vat
|
||||
$fiche_with_vat=round($fiche_price*$fiche_quant,2)+$fiche_amount_vat;
|
||||
}
|
||||
{
|
||||
$fiche_amount_vat=round($fiche_price*$fiche_quant*$vat_rate,2);
|
||||
echo_debug(__FILE__.':'.__LINE__.'- Tva Amount is computed '.$fiche_amount_vat);
|
||||
|
||||
// value card + vat
|
||||
$fiche_with_vat=round($fiche_price*$fiche_quant,2)+$fiche_amount_vat;
|
||||
}
|
||||
else
|
||||
{
|
||||
$fiche_amount_vat=$tva_amount;
|
||||
// value card + vat
|
||||
$fiche_with_vat=round($fiche_price*$fiche_quant,2)+$tva_amount_vat;
|
||||
}
|
||||
{
|
||||
echo_debug(__FILE__.':'.__LINE__.'- Tva Amount is given '.$tva_amount);
|
||||
$fiche_amount_vat=$tva_amount;
|
||||
// value card + vat
|
||||
$fiche_with_vat=round($fiche_price*$fiche_quant,2)+$tva_amount;
|
||||
}
|
||||
// Sum of invoice vat
|
||||
$sum_with_vat+=$fiche_with_vat;
|
||||
|
||||
echo_debug(__FILE__.':'.__LINE__.'- Sum_with_vat='.$fiche_with_vat);
|
||||
// Show the data
|
||||
$r.='<TR>';
|
||||
$r.='<TD>'.$fiche_name.'</TD>';
|
||||
|
|
@ -591,7 +633,44 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
$r.='<TD ALIGN="RIGHT">'.round($fiche_amount_vat,2).'</TD>';
|
||||
|
||||
$r.='<TD>'.round($fiche_with_vat,2).'</TD>';
|
||||
//----------------------------------------------------------------------
|
||||
// CA
|
||||
//----------------------------------------------------------------------
|
||||
// to show a select list for the analytic
|
||||
// if analytic is op (optionnel) there is a blank line
|
||||
|
||||
// encode the pa
|
||||
|
||||
if ( $own->MY_ANALYTIC!='un') // use of AA
|
||||
{
|
||||
// for each plan
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$array=make_array($p_cn,
|
||||
"select po_id as value,".
|
||||
" po_name as label from poste_analytique ".
|
||||
" where pa_id = ".$r_plan['id'].
|
||||
" order by po_name",$null);
|
||||
$select = new widget("select","","p_".$r_plan['id']."_".$i,$array);
|
||||
$select->table=1;
|
||||
|
||||
// view only or editable
|
||||
if ( $p_piece ) {
|
||||
$select->readonly=false;
|
||||
} else {
|
||||
$select->readonly=true;
|
||||
$select->selected=${"p_".$r_plan['id']."_".$i};
|
||||
}
|
||||
|
||||
$r.=$select->IOValue();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
$r.="</TR>";
|
||||
}
|
||||
|
||||
|
|
@ -603,24 +682,7 @@ function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_pi
|
|||
|
||||
|
||||
$r.="</DIV>";
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=new&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=depense&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
$r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
|
||||
|
||||
// check for upload piece
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$h=new widget('hidden');
|
||||
|
|
@ -687,6 +749,8 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
|
|||
$amount=0.0;
|
||||
$amount_jrn=0.0;
|
||||
$sum_tva_nd=0.0;
|
||||
// own
|
||||
$own=new own($p_cn);
|
||||
// Computing total customer
|
||||
for ($i=0;$i<$nb_item;$i++) {
|
||||
// store quantity & goods in array
|
||||
|
|
@ -698,16 +762,20 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
|
|||
|
||||
// check wether the price is set or no
|
||||
if ( isNumber(${"e_march$i"."_buy"}) == 0 ) {
|
||||
if ( $a_good[$i] !="" ) {
|
||||
// If the price is not set we have to find it from the database
|
||||
$a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE);
|
||||
}
|
||||
} else {
|
||||
// The price is valid
|
||||
$a_price[$i]=${"e_march$i"."_buy"};
|
||||
}
|
||||
$a_price[$i]=round($a_price[$i],2);
|
||||
if ( $a_good[$i] !="" )
|
||||
{
|
||||
// If the price is not set we have to find it from the database
|
||||
$a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The price is valid
|
||||
$a_price[$i]=${"e_march$i"."_buy"};
|
||||
}
|
||||
|
||||
$a_price[$i]=round($a_price[$i],2);
|
||||
|
||||
$cost=$a_price[$i]*$a_quant[$i];
|
||||
$amount+=$cost;
|
||||
$amount_jrn+=$cost;
|
||||
|
|
@ -719,143 +787,211 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn)
|
|||
// Compute vat with ded
|
||||
echo_debug('user_form_achat.php',__LINE__,"Call ComputeTotalVat");
|
||||
$a_vat=ComputeTotalVat($p_cn,$a_good,$a_quant,$a_price,$a_vat_good,$a_vat_amount,false);
|
||||
|
||||
StartSql($p_cn);
|
||||
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
|
||||
|
||||
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
|
||||
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
|
||||
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
$amount=$a_price[$i]*$a_quant[$i];
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
|
||||
echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
|
||||
{
|
||||
// if vat if given we use it to compute ND
|
||||
$nd_amount=($a_vat_amount[$i]==0)?round($a_quant[$i]*$a_price[$i]*$non_dedu,2):round($a_vat_amount*$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');
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode);
|
||||
if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
$amount=$amount-$nd_amount;
|
||||
}
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE);
|
||||
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
|
||||
{
|
||||
//We don't compute vat if it's given
|
||||
$lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn, $a_good[$i],$a_quant[$i],$a_price[$i],
|
||||
$a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i]
|
||||
;
|
||||
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
|
||||
$ded_vat=round($ded_vat,2);
|
||||
$sum_tva_nd+=$ded_vat;
|
||||
|
||||
// compute the NDA TVA
|
||||
$tva_dna=new 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);");
|
||||
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode);
|
||||
if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
}
|
||||
try {
|
||||
StartSql($p_cn);
|
||||
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
|
||||
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 )
|
||||
{
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
// Set Internal code and Comment
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
|
||||
|
||||
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
|
||||
// store not deductible and vat deductible via tax
|
||||
$aNd_amount[$i]=0.0;
|
||||
$aTva_ded_impot[$i]=0.0;
|
||||
$aTva_ded_impot_recup[$i]=0.0;
|
||||
|
||||
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
|
||||
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
$amount=$a_price[$i]*$a_quant[$i];
|
||||
//We don't compute vat if it's given
|
||||
$lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i];
|
||||
|
||||
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEPENSE_NON_DEDUCTIBLE);
|
||||
echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
|
||||
{
|
||||
// if vat if given we use it to compute ND
|
||||
$nd_amount=($a_vat_amount[$i]==0)?round($a_quant[$i]*$a_price[$i]*$non_dedu,2):round($a_vat_amount*$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');
|
||||
$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;
|
||||
|
||||
// save the ND in an array (for the easy view)
|
||||
$aNd_amount[$i]=$nd_amount;
|
||||
}
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE);
|
||||
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0)
|
||||
{
|
||||
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
|
||||
$ded_vat=round($ded_vat,2);
|
||||
$aTva_ded_impot[$i]=$ded_vat;
|
||||
$sum_tva_nd+=$ded_vat;
|
||||
|
||||
// compute the NDA TVA
|
||||
$tva_dna=new 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);");
|
||||
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode);
|
||||
}
|
||||
|
||||
$sum_tva_nd+=round($ded_vat,2);
|
||||
// Put the non deductible part into a special account
|
||||
$non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
|
||||
echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu");
|
||||
|
||||
// Save it
|
||||
$tva_ded_impot=new 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);");
|
||||
if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 )
|
||||
{
|
||||
|
||||
$ded_vat=($lvat != null )?$lvat*$non_dedu:0;
|
||||
|
||||
$sum_tva_nd+=round($ded_vat,2);
|
||||
$aTva_ded_impot_recup[$i]=round($ded_vat,2);
|
||||
|
||||
// Save it
|
||||
$tva_ded_impot=new 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);");
|
||||
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode);
|
||||
}
|
||||
|
||||
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode);
|
||||
if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
}
|
||||
|
||||
|
||||
// record into jrnx
|
||||
echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode);");
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]);
|
||||
|
||||
/* \brief if the quantity is < 0 then the stock increase (return of
|
||||
* material)
|
||||
*/
|
||||
$nNeg=($a_quant[$i]<0)?-1:1;
|
||||
|
||||
// always save quantity but in withStock we can find what card need a stock management
|
||||
InsertStockGoods($p_cn,$j_id,$a_good[$i],$nNeg*$a_quant[$i],'d');
|
||||
echo_debug('user_form_ach.php',__LINE__,"value non ded : ".$a_good[$i]."is");
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
// for each item, insert into operation_analytique
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
|
||||
if ( isset(${"p_".$r_plan['id']."_".$i})&& ${"p_".$r_plan['id']."_".$i} != -1)
|
||||
{
|
||||
|
||||
$op=new operation($p_cn);
|
||||
$op->po_id=${"p_".$r_plan['id']."_".$i};
|
||||
$op->oa_group=$group;
|
||||
$op->j_id=$j_id;
|
||||
$op->pa_id=$r_plan['id'];
|
||||
$op->oa_amount=round($a_price[$i]*$a_quant[$i],2);
|
||||
$op->oa_debit=($op->oa_amount < 0 )?'f':'t';
|
||||
$op->oa_date=$e_date;
|
||||
$op->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------
|
||||
// insert into quant_purchase
|
||||
//---------------------------------------------------------
|
||||
|
||||
echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat);
|
||||
echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]);
|
||||
//!\note
|
||||
// $a_vat_good[$i] contains the tva_id
|
||||
// $a_vat_amount[$i] contains the amount of vat
|
||||
$vat_code=$a_vat_good[$i];
|
||||
$computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i];
|
||||
|
||||
echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase");
|
||||
$r=ExecSql($p_cn,"select insert_quant_purchase ".
|
||||
"('".$internal."'".
|
||||
",".$j_id.
|
||||
",'".$a_good[$i]."'".
|
||||
",".$a_quant[$i].",".
|
||||
round($amount,2).
|
||||
",".$computed_vat.
|
||||
",".$vat_code.
|
||||
",".$aNd_amount[$i].
|
||||
",".$aTva_ded_impot[$i].
|
||||
",".$aTva_ded_impot_recup[$i].
|
||||
",'".$e_client."')");
|
||||
|
||||
|
||||
|
||||
} // end loop
|
||||
|
||||
// set up internal code for quant_purchase
|
||||
|
||||
// Insert Vat
|
||||
$sum_tva=0.0;
|
||||
if ( $a_vat != null ) // no vat
|
||||
{
|
||||
echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true));
|
||||
foreach ($a_vat as $tva_id => $e_tva_amount )
|
||||
{
|
||||
echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id");
|
||||
$poste=GetTvaPoste($p_cn,$tva_id,'d');
|
||||
if ($e_tva_amount == 0 ) continue;
|
||||
echo_debug('user_form_ach',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);");
|
||||
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);
|
||||
$sum_tva+=round($e_tva_amount,2);
|
||||
}
|
||||
}
|
||||
echo_debug('user_form_ach.php',__LINE__,"echeance = $e_ech");
|
||||
echo_debug('user_form_ach.php',__LINE__,"sum_tva = $sum_tva");
|
||||
echo_debug('user_form_ach.php',__LINE__,"amount_jrn = $amount_jrn");
|
||||
echo_debug('user_form_ach.php',__LINE__,"sum_tva_nd = $sum_tva_nd");
|
||||
|
||||
// Debit = client
|
||||
$poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
|
||||
echo_debug('user_form_achat.php',__LINE__,"get e_client $e_client poste $poste");
|
||||
echo_debug('user_form_achat.php',__LINE__,"insert client");
|
||||
|
||||
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($amount_jrn+$sum_tva+$sum_tva_nd,2),$seq,
|
||||
$periode,$e_client);
|
||||
|
||||
|
||||
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"--",$seq,$periode);
|
||||
|
||||
// Set Internal code and Comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
|
||||
$comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
|
||||
// record into jrnx
|
||||
echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode);");
|
||||
$j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]);
|
||||
if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
// always save quantity but in withStock we can find what card need a stock management
|
||||
if ( InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d') == false ) {
|
||||
$Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
echo_debug('user_form_ach.php',__LINE__,"value non ded : ".$a_good[$i]."is");
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
|
||||
if ( isset ($_FILES))
|
||||
save_upload_document($p_cn,$seq);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Insert Vat
|
||||
$sum_tva=0.0;
|
||||
if ( $a_vat != null ) // no vat
|
||||
{
|
||||
echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true));
|
||||
foreach ($a_vat as $tva_id => $e_tva_amount )
|
||||
{
|
||||
echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id");
|
||||
$poste=GetTvaPoste($p_cn,$tva_id,'d');
|
||||
if ($e_tva_amount == 0 ) continue;
|
||||
echo_debug('user_form_ach',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);");
|
||||
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);
|
||||
if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ach.php' __LINE__");}
|
||||
$sum_tva+=round($e_tva_amount,2);
|
||||
}
|
||||
}
|
||||
echo_debug('user_form_ach.php',__LINE__,"echeance = $e_ech");
|
||||
echo_debug('user_form_ach.php',__LINE__,"sum_tva = $sum_tva");
|
||||
echo_debug('user_form_ach.php',__LINE__,"amount_jrn = $amount_jrn");
|
||||
echo_debug('user_form_ach.php',__LINE__,"sum_tva_nd = $sum_tva_nd");
|
||||
|
||||
// Debit = client
|
||||
$poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
|
||||
echo_debug('user_form_achat.php',__LINE__,"get e_client $e_client poste $poste");
|
||||
echo_debug('user_form_achat.php',__LINE__,"insert client");
|
||||
|
||||
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($amount_jrn+$sum_tva+$sum_tva_nd,2),$seq,
|
||||
$periode,$e_client);
|
||||
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");}
|
||||
|
||||
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"--",$seq,$periode);
|
||||
if ( $r == false ) { Rollback($p_cn); exit;}
|
||||
// Set Internal code and Comment
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
$comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
if ( $Res == false ) { Rollback($p_cn); exit(" Error 'user_form_ach.php' __LINE__"); };
|
||||
|
||||
if ( isset ($_FILES))
|
||||
save_upload_document($p_cn,$seq);
|
||||
|
||||
|
||||
Commit($p_cn);
|
||||
|
||||
|
||||
return array($internal,$comment);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,6 +279,7 @@ function FormFin($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
$wConcerned->SetReadOnly($pview_only);
|
||||
$wConcerned->extra=0;
|
||||
$wConcerned->table=1;
|
||||
$wConcerned->extra2='paid';
|
||||
$r.=$wConcerned->IOValue("e_concerned".$i,${"e_concerned".$i});
|
||||
$r.='</TR>';
|
||||
// if not recorded the new amount must be recalculate
|
||||
|
|
@ -312,6 +313,9 @@ $r.="</FORM>";
|
|||
// if view_only is true
|
||||
//Put the new saldo here (old saldo - operation)
|
||||
if ( $pview_only==true) {
|
||||
$solde=round($solde,2);
|
||||
$new_solde=round($new_solde,2);
|
||||
|
||||
// if not recorded the new amount must be recalculate
|
||||
if ( $p_save == false) {
|
||||
$r.=" <b> Ancien Solde = ".$solde." </b><br>";
|
||||
|
|
@ -363,71 +367,85 @@ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
|||
|
||||
// Debit = banque
|
||||
$poste_bq=GetFicheAttribut($p_cn,$e_bank_account,ATTR_DEF_ACCOUNT);
|
||||
StartSql($p_cn);
|
||||
$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 ( ${"e_other$i"."_amount"} == 0 ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,${"e_other$i"},ATTR_DEF_ACCOUNT);
|
||||
try
|
||||
{
|
||||
StartSql($p_cn);
|
||||
$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 ( ${"e_other$i"."_amount"} == 0 ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,${"e_other$i"},ATTR_DEF_ACCOUNT);
|
||||
|
||||
// round it
|
||||
${"e_other$i"."_amount"}=round( ${"e_other$i"."_amount"},2);
|
||||
// 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($p_cn,'s_grpt');
|
||||
|
||||
if ( InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste_bq,$e_date,round(${"e_other$i"."_amount"},2),
|
||||
$seq,$periode,$e_bank_account) == false ) {
|
||||
$Rollback($p_cn);exit("error 'user_form_fin.php' __LINE__");
|
||||
}
|
||||
$amount+=${"e_other$i"."_amount"};
|
||||
// Record a line for the bank
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
// Set Internal code and Comment
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
|
||||
|
||||
// Record a line for the other account
|
||||
if ( ($j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round(${"e_other$i"."_amount"},2),$seq,$periode,${"e_other$i"})) == false )
|
||||
{ $Rollback($p_cn);exit("error 'user_form_fin.php' __LINE__");}
|
||||
InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste_bq,$e_date,round(${"e_other$i"."_amount"},2),
|
||||
$seq,$periode,$e_bank_account) ;
|
||||
|
||||
echo_debug('user_form_fin.php',__LINE__," $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,".${"e_other$i"}."_amount".",$seq,$periode);");
|
||||
|
||||
if ( ($jr_id=InsertJrn($p_cn,$e_date,'',$p_jrn,FormatString(${"e_other$i"."_comment"}),
|
||||
$seq,$periode))==false) {
|
||||
$Rollback($p_cn);exit("error 'user_form_fin.php' __LINE__");}
|
||||
// Record a line for the other account
|
||||
$j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,
|
||||
round(${"e_other$i"."_amount"},2),$seq,$periode,${"e_other$i"});
|
||||
|
||||
echo_debug('user_form_fin.php',__LINE__," $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,".${"e_other$i"}."_amount".",$seq,$periode);");
|
||||
|
||||
$jr_id=InsertJrn($p_cn,$e_date,'',$p_jrn,FormatString(${"e_other$i"."_comment"}),
|
||||
$seq,$periode);
|
||||
|
||||
if ( isNumber(${"e_concerned".$i}) == 1 ) {
|
||||
if ( isNumber(${"e_concerned".$i}) == 1 ) {
|
||||
|
||||
InsertRapt($p_cn,$jr_id,${"e_concerned$i"});
|
||||
}
|
||||
InsertRapt($p_cn,$jr_id,${"e_concerned$i"});
|
||||
}
|
||||
|
||||
|
||||
// Set Internal code and Comment
|
||||
$internal_code=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
$comment=$internal_code." compte : ".GetFicheName($p_cn,$e_bank_account);
|
||||
if ( FormatString(${"e_other$i"."_comment"}) == null ) {
|
||||
// Update comment if comment is blank
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
}
|
||||
// Set Internal code and Comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
|
||||
$comment=$internal_code." compte : ".GetFicheName($p_cn,$e_bank_account);
|
||||
if ( FormatString(${"e_other$i"."_comment"}) == null ) {
|
||||
// Update comment if comment is blank
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
}
|
||||
|
||||
|
||||
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($p_cn,$seq);
|
||||
|
||||
} else {
|
||||
if ( $oid != 0 )
|
||||
if ( $i == 0 )
|
||||
{
|
||||
ExecSql($p_cn,"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
|
||||
// first record we upload the files and
|
||||
// keep variable to update other row of jrn
|
||||
if ( isset ($_FILES))
|
||||
$oid=save_upload_document($p_cn,$seq);
|
||||
|
||||
} else {
|
||||
if ( $oid != 0 )
|
||||
{
|
||||
ExecSql($p_cn,"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 '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
|
||||
}
|
||||
Commit($p_cn);
|
||||
return $internal_code;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ require_once("class_widget.php");
|
|||
require_once("preference.php");
|
||||
require_once("fiche_inc.php");
|
||||
require_once("user_common.php");
|
||||
require_once ('class_plananalytic.php');
|
||||
require_once ('class_own.php');
|
||||
require_once ('class_operation.php');
|
||||
/*! \file
|
||||
* \brief Functions for the ledger of misc. operation
|
||||
*/
|
||||
|
|
@ -46,13 +49,14 @@ require_once("user_common.php");
|
|||
*/
|
||||
function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=true,$p_article=6,$p_saved=false)
|
||||
{
|
||||
include_once("poste.php");
|
||||
include_once("poste.php");
|
||||
if ( $p_array != null ) {
|
||||
// array contains old value
|
||||
foreach ( $p_array as $a=>$v) {
|
||||
${"$a"}=$v;
|
||||
}
|
||||
}
|
||||
|
||||
// The date
|
||||
list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode);
|
||||
$flag=(isset($e_date))?1:0;
|
||||
|
|
@ -70,9 +74,12 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
// Save old value and set a new one
|
||||
|
||||
$r="";
|
||||
|
||||
if ( $pview_only == false) {
|
||||
$r.=JS_SEARCH_POSTE;
|
||||
$r.=JS_COMPUTE_ODS;
|
||||
}
|
||||
|
||||
$r.="<FORM NAME=\"form_detail\" enctype=\"multipart/form-data\" ACTION=\"user_jrn.php?action=new&p_jrn=$p_jrn\" METHOD=\"POST\">";
|
||||
$r.='<TABLE>';
|
||||
// Date
|
||||
|
|
@ -93,20 +100,29 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
include_once("fiche_inc.php");
|
||||
|
||||
// Record the current number of article
|
||||
$r.='<INPUT TYPE="HIDDEN" name="nb_item" value="'.$p_article.'">';
|
||||
$r.='<INPUT TYPE="HIDDEN" ID="nb_item" name="nb_item" value="'.$p_article.'">';
|
||||
$e_comment=(isset($e_comment))?$e_comment:"";
|
||||
|
||||
|
||||
// Start the div for item to encode
|
||||
$r.="<DIV>";
|
||||
$r.='<H2 class="info">Opérations Diverses</H2>';
|
||||
$r.='<TABLE border="0">';
|
||||
$r.="<tr>";
|
||||
$r.="<th></th>";
|
||||
if ( $pview_only == false) $r.="<th></th>";
|
||||
$r.="<th>Compte</th>";
|
||||
$r.="<th>Poste</th>";
|
||||
$r.="<th>Montant</th>";
|
||||
$r.="<th>Crédit ou dédit</th>";
|
||||
$r.="<th>Crédit ou débit</th>";
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$r.="<th>".$r_plan['name']."</th>";
|
||||
}
|
||||
|
||||
}
|
||||
$r.="</tr>";
|
||||
$sum_deb=0.0;
|
||||
$sum_cred=0.0;
|
||||
|
|
@ -116,7 +132,7 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
|
||||
$account=(isset(${"e_account$i"}))?${"e_account$i"}:"";
|
||||
|
||||
$lib="";
|
||||
$lib='<span id="e_account'.$i.'_label"></span>';
|
||||
// If $account has a value
|
||||
if ( isNumber($account) == 1 ) {
|
||||
if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=$account") == 0 ) {
|
||||
|
|
@ -127,25 +143,25 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
if ( $pview_only == true ) return null;
|
||||
} else {
|
||||
// retrieve the tva label and name
|
||||
$lib=GetPosteLibelle($p_cn, $account,1);
|
||||
$lib='<span id="e_account'.$i.'_label">'.GetPosteLibelle($p_cn, $account,1).'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
${"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_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
$msg="Montant invalide !!! ";
|
||||
echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
${"e_account$i"."_amount"}=0;
|
||||
${"e_account$i"."_amount"}=0;
|
||||
}
|
||||
// code
|
||||
// Do we need a filter ?
|
||||
$l_line=GetJrnProp($_SESSION['g_dossier'],$p_jrn);
|
||||
if( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 or
|
||||
strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) {
|
||||
if( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ||
|
||||
strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) {
|
||||
$filter=1;
|
||||
}
|
||||
else
|
||||
|
|
@ -163,6 +179,8 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
$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"});
|
||||
|
||||
|
||||
|
|
@ -172,14 +190,45 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
$d_check=( ${"e_account$i"."_type"} == 'd' )?"CHECKED":"";
|
||||
$r.='<td>';
|
||||
if ( $pview_only == false ) {
|
||||
$r.=' <input type="radio" name="'."e_account"."$i"."_type".'" value="d" '.$d_check.'> Débit ou ';
|
||||
$r.=' <input type="radio" name="'."e_account"."$i"."_type".'" value="c" '.$c_check.'> Crédit ';
|
||||
$r.=' <input type="radio" id="'."e_account"."$i"."_type".'" name="'."e_account"."$i"."_type".'" value="d" '.$d_check.' onChange="checkTotal()">Débit ou ';
|
||||
$r.=' <input type="radio" id="'."e_account"."$i"."_type".'" name="'."e_account"."$i"."_type".'" value="c" '.$c_check.' onChange="checkTotal()"> Crédit ';
|
||||
}else {
|
||||
$r.=(${"e_account$i"."_type"} == 'c' )?"Crédit":"Dédit";
|
||||
$r.=(${"e_account$i"."_type"} == 'c' )?"Crédit":"Débit";
|
||||
$r.='<input type="hidden" name="e_account'.$i.'_type" value="'.${"e_account$i"."_type"}.'">';
|
||||
}
|
||||
$r.='</td>';
|
||||
$r.='</TR>';
|
||||
// Add CA
|
||||
//--------------------------------------------------
|
||||
if ( ereg("^7+",${"e_account$i"}) ||
|
||||
ereg("^6+",${"e_account$i"}))
|
||||
{
|
||||
|
||||
if ( $own->MY_ANALYTIC!='un') // use of AA
|
||||
{
|
||||
// for each plan
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$array=make_array($p_cn,
|
||||
"select po_id as value,".
|
||||
" po_name as label from poste_analytique ".
|
||||
" where pa_id = ".$r_plan['id'].
|
||||
" order by po_name",$null);
|
||||
$select = new widget("select","","p_".$r_plan['id']."_".$i,$array);
|
||||
$select->table=1;
|
||||
if ( $p_saved ) {
|
||||
$select->readonly=true;
|
||||
$select->selected= ${"p_".$r_plan['id']."_".$i};
|
||||
}
|
||||
$r.=$select->IOValue();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$r.='</td>';
|
||||
$r.='</TR>';
|
||||
$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
|
||||
|
|
@ -195,11 +244,18 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
$r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
|
||||
$r.="</table>";
|
||||
$r.="<hr>";
|
||||
} else {
|
||||
$r.= '<div class="info">
|
||||
Débit = <span id="totalDeb"></span>
|
||||
Crédit = <span id="totalCred"></span>
|
||||
Difference = <span id="totalDiff"></span>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
// Set correctly the REQUEST param for jrn_type
|
||||
$h=new widget('hidden');
|
||||
$h->name='jrn_type';
|
||||
$h->value='OD';
|
||||
$h->value='ODS';
|
||||
$r.=$h->IOValue();
|
||||
|
||||
$r.=$p_submit;
|
||||
|
|
@ -222,7 +278,14 @@ function FormODS($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
|
|||
echo "<script> alert('$msg'); </script>";
|
||||
return null;
|
||||
}
|
||||
|
||||
/* if not view only then a javascript will compute and check the
|
||||
total */
|
||||
if ( ! $pview_only ) {
|
||||
// Start compute
|
||||
$r.='<script language=javascript>'.
|
||||
'window.onload=checkTotal();'.
|
||||
'</script>';
|
||||
}
|
||||
return $r;
|
||||
|
||||
|
||||
|
|
@ -259,38 +322,80 @@ function RecordODS($p_cn,$p_array,$p_user,$p_jrn)
|
|||
|
||||
$sum_deb=0.0;
|
||||
$sum_cred=0.0;
|
||||
$own=new own($p_cn);
|
||||
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
|
||||
StartSql($p_cn);
|
||||
// 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);
|
||||
if ( ($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)) == false ) {
|
||||
$Rollback($p_cn);exit("error 'user_form_ods.php' __LINE__");}
|
||||
}
|
||||
|
||||
if ( InsertJrn($p_cn,$e_date,"",$p_jrn,$e_comm,$seq,$periode) == false ) {
|
||||
$Rollback($p_cn);exit("error 'user_form_ods.php' __LINE__");}
|
||||
|
||||
// Set Internal code and Comment
|
||||
$internal_code=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
if ( $e_comm=="" ) {
|
||||
// Update comment if comment is blank
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$internal_code."' where jr_grpt_id=".$seq);
|
||||
}
|
||||
if ( isset ($_FILES))
|
||||
save_upload_document($p_cn,$seq);
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
|
||||
try
|
||||
{
|
||||
StartSql($p_cn);
|
||||
// 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);
|
||||
// insert into ca
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
// for each item, insert into operation_analytique
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
|
||||
if ( isset(${"p_".$r_plan['id']."_".$i})&& ${"p_".$r_plan['id']."_".$i} != -1)
|
||||
{
|
||||
|
||||
$op=new operation($p_cn);
|
||||
$op->po_id=${"p_".$r_plan['id']."_".$i};
|
||||
$op->oa_group=$group;
|
||||
$op->j_id=$j_id;
|
||||
$op->pa_id=$r_plan['id'];
|
||||
$op->oa_amount=${"e_account$i"."_amount"};
|
||||
$op->oa_debit=($op->oa_amount < 0 )?'f':'t';
|
||||
$op->oa_date=$e_date;
|
||||
echo_debug(__FILE__.":".__LINE__,"saving ca ",$op);
|
||||
$op->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
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_code."' where jr_grpt_id=".$seq);
|
||||
}
|
||||
if ( isset ($_FILES))
|
||||
save_upload_document($p_cn,$seq);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
}
|
||||
Commit($p_cn);
|
||||
return $internal_code;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ require_once("class_widget.php");
|
|||
require_once("preference.php");
|
||||
require_once("fiche_inc.php");
|
||||
require_once("user_common.php");
|
||||
require_once ("class_own.php");
|
||||
require_once ("class_plananalytic.php");
|
||||
require_once ('class_operation.php');
|
||||
/*! FormVenInput
|
||||
* \brief Display the form for a sell
|
||||
* Used to show detail, encode a new invoice
|
||||
|
|
@ -41,6 +44,7 @@ require_once("user_common.php");
|
|||
*/
|
||||
function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_article=1)
|
||||
{
|
||||
|
||||
if ( $p_array != null ) {
|
||||
// array contains old value
|
||||
foreach ( $p_array as $a=>$v) {
|
||||
|
|
@ -221,7 +225,7 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_
|
|||
$Quantity->size=9;
|
||||
//$r.=InputType("","TEXT","e_quant".$i,$quant,$pview_only);
|
||||
$r.=$Quantity->IOValue("e_quant".$i,$quant);
|
||||
$r.='</TR>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -396,8 +400,10 @@ for ($o = 0;$o < $p_number; $o++) {
|
|||
|
||||
function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form',$p_comment='')
|
||||
{
|
||||
|
||||
$r="";
|
||||
$data="";
|
||||
$head_ca="";
|
||||
// Keep all the data if hidden
|
||||
// and store the array in variables
|
||||
$hidden=new widget("hidden");
|
||||
|
|
@ -405,7 +411,39 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
|
|||
$data.=$hidden->IOValue($name,$content);
|
||||
${"$name"}=$content;
|
||||
}
|
||||
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Compute the col head for CA
|
||||
$head_ca="";
|
||||
$own = new Own($p_cn);
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$head_ca.="<th>".$r_plan['name']."</th>";
|
||||
}
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
$r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
|
||||
// start table
|
||||
$r.='<TABLE>';
|
||||
// Show the Date
|
||||
|
|
@ -437,6 +475,7 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
|
|||
$r.="<TH>Montant HTVA</TH>";
|
||||
$r.="<TH>Montant TVA</TH>";
|
||||
$r.="<TH>Total</TH>";
|
||||
$r.=$head_ca;
|
||||
$r.="</TR>";
|
||||
for ($i=0;$i<$p_number;$i++) {
|
||||
if ( trim(${"e_march$i"}) == "" ) {
|
||||
|
|
@ -498,7 +537,40 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
|
|||
$r.='<TD ALIGN="RIGHT">'.round($fiche_amount_vat,2).'</TD>';
|
||||
|
||||
$r.='<TD>'.round($fiche_with_vat,2).'</TD>';
|
||||
|
||||
// to show a select list for the analytic
|
||||
// if analytic is op (optionnel) there is a blank line
|
||||
$own = new Own($p_cn);
|
||||
// encode the pa
|
||||
if ( $own->MY_ANALYTIC!='un') // use of AA
|
||||
{
|
||||
// for each plan
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
$null=($own->MY_ANALYTIC=='op')?1:0;
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
$array=make_array($p_cn,
|
||||
"select po_id as value,".
|
||||
" po_name as label from poste_analytique ".
|
||||
" where pa_id = ".$r_plan['id'].
|
||||
" order by po_name",$null);
|
||||
$select = new widget("select","","p_".$r_plan['id']."_".$i,$array);
|
||||
$select->table=1;
|
||||
// view only or editable
|
||||
if ( $p_doc=="form" ) {
|
||||
// editable
|
||||
$select->readonly=false;
|
||||
} else {
|
||||
// view only
|
||||
$select->readonly=true;
|
||||
$select->selected=${"p_".$r_plan['id']."_".$i};
|
||||
}
|
||||
$r.=$select->IOValue();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$r.="</TR>";
|
||||
}
|
||||
|
||||
|
|
@ -511,25 +583,9 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form'
|
|||
|
||||
$r.="</DIV>";
|
||||
if ( $p_doc == 'form' ) {
|
||||
// Compute href
|
||||
// $href=basename($_SERVER['PHP_SELF']);
|
||||
$href=basename($_SERVER['PHP_SELF']);
|
||||
switch ($href)
|
||||
{
|
||||
// user_jrn.php
|
||||
case 'user_jrn.php':
|
||||
$href="user_jrn.php?action=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
case 'commercial.php':
|
||||
$href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn";
|
||||
break;
|
||||
default:
|
||||
echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
|
||||
$r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
|
||||
|
||||
|
||||
// check for upload piece
|
||||
$file=new widget("file");
|
||||
|
|
@ -613,6 +669,8 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
|
|||
// Get the default period
|
||||
$periode=$p_user->GetPeriode();
|
||||
$amount=0.0;
|
||||
$own=new own($p_cn);
|
||||
$group=NextSequence($p_cn,"s_oa_group");
|
||||
|
||||
// Computing total customer
|
||||
//--
|
||||
|
|
@ -655,80 +713,125 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
|
|||
|
||||
// Compute the j_grpt
|
||||
$seq=NextSequence($p_cn,'s_grpt');
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
|
||||
|
||||
// Debit = client
|
||||
$poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
|
||||
StartSql($p_cn);
|
||||
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2)+round($sum_vat,2),$seq,$periode,$e_client);
|
||||
if ( $r == false) { $Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
|
||||
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
if ( $a_good[$i] == "" ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
|
||||
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
// record into jrnx
|
||||
$j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($a_price[$i]*$a_quant[$i],2),$seq,$periode,$a_good[$i]);
|
||||
if ( $j_id == false) { $Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
|
||||
// always save quantity but in withStock we can find what card need a stock management
|
||||
if ( InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c') == false ) {
|
||||
$Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
|
||||
} // end loop
|
||||
|
||||
// Insert Vat
|
||||
|
||||
if ( $a_vat_new != null ) // no vat
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($a_vat_new as $tva_id => $tva_amount ) {
|
||||
$poste=GetTvaPoste($p_cn,$tva_id,'c');
|
||||
if ($tva_amount == 0 ) continue;
|
||||
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($tva_amount,2),$seq,$periode);
|
||||
if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__");}
|
||||
|
||||
}
|
||||
}
|
||||
echo_debug('user_form_ven.php',__LINE__,"echeance = $e_ech");
|
||||
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",$seq,$periode);
|
||||
if ( $r == false ) { Rollback($p_cn); exit;}
|
||||
// Set Internal code and Comment
|
||||
$internal=SetInternalCode($p_cn,$seq,$p_jrn);
|
||||
$comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
StartSql($p_cn);
|
||||
$r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2)+round($sum_vat,2),$seq,$periode,$e_client);
|
||||
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
if ( $Res == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__"); };
|
||||
|
||||
if ( isset ($_FILES)) {
|
||||
if ( sizeof($_FILES) != 0 )
|
||||
save_upload_document($p_cn,$seq);
|
||||
}
|
||||
|
||||
// save the quantity, then we can make an invoice
|
||||
for ( $i=0;$i < $nb_item;$i++)
|
||||
{
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
// Credit = goods
|
||||
for ( $i = 0; $i < $nb_item;$i++) {
|
||||
if ( $a_good[$i] == "" ) continue;
|
||||
$poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
|
||||
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
// record into jrnx
|
||||
$j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($a_price[$i]*$a_quant[$i],2),$seq,$periode,$a_good[$i]);
|
||||
|
||||
// insert into the table quant_sold
|
||||
// Note that negative value are also saved but not the vat !
|
||||
if ( $a_vat[$i] == -1) {
|
||||
$computed_vat=0;
|
||||
$vat_code="null";
|
||||
} else {
|
||||
/* \brief if the quantity is < 0 then the stock increase (return of
|
||||
* material)
|
||||
*/
|
||||
$nNeg=($a_quant[$i]<0)?-1:1;
|
||||
|
||||
// always save quantity but in withStock we can find
|
||||
// what card need a stock management
|
||||
|
||||
InsertStockGoods($p_cn,$j_id,$a_good[$i],$nNeg*$a_quant[$i],'c') ;
|
||||
if ( $own->MY_ANALYTIC != "un" )
|
||||
{
|
||||
// for each item, insert into operation_analytique
|
||||
$plan=new PlanAnalytic($p_cn);
|
||||
$a_plan=$plan->get_list();
|
||||
foreach ($a_plan as $r_plan)
|
||||
{
|
||||
|
||||
if ( isset(${"p_".$r_plan['id']."_".$i})&& ${"p_".$r_plan['id']."_".$i} != -1)
|
||||
{
|
||||
|
||||
$op=new operation($p_cn);
|
||||
$op->po_id=${"p_".$r_plan['id']."_".$i};
|
||||
$op->oa_group=$group;
|
||||
$op->j_id=$j_id;
|
||||
$op->pa_id=$r_plan['id'];
|
||||
$op->oa_amount=round($a_price[$i]*$a_quant[$i],2);
|
||||
$op->oa_debit=($op->oa_amount < 0 )?'t':'f';
|
||||
$op->oa_date=$e_date;
|
||||
$op->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
$computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]);
|
||||
$vat_code=$a_vat[$i];
|
||||
}
|
||||
$r=ExecSql($p_cn,"select insert_quant_sold ".
|
||||
"('".$internal."','".$a_good[$i]."',".$a_quant[$i].",".$a_price[$i]*$a_quant[$i].
|
||||
",".$computed_vat.
|
||||
",".$vat_code.",'".$e_client."')");
|
||||
if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__"); };
|
||||
}
|
||||
|
||||
$r=ExecSql($p_cn,"select insert_quant_sold ".
|
||||
"('".$internal."',".$j_id.",'".$a_good[$i]
|
||||
."',".$a_quant[$i].",".$a_price[$i]*$a_quant[$i].
|
||||
",".$computed_vat.
|
||||
",".$a_vat[$i].",'".$e_client."')");
|
||||
|
||||
|
||||
} // end loop
|
||||
|
||||
// Insert Vat
|
||||
|
||||
if ( $a_vat_new != null ) // no vat
|
||||
|
||||
{
|
||||
foreach ($a_vat_new as $tva_id => $tva_amount ) {
|
||||
$poste=GetTvaPoste($p_cn,$tva_id,'c');
|
||||
if ($tva_amount == 0 ) continue;
|
||||
$r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($tva_amount,2),$seq,$periode);
|
||||
}
|
||||
}
|
||||
echo_debug('user_form_ven.php',__LINE__,"echeance = $e_ech");
|
||||
$r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",$seq,$periode);
|
||||
|
||||
// Set Internal code and Comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ".
|
||||
" jr_grpt_id = ".$seq);
|
||||
|
||||
$comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
|
||||
|
||||
// Update and set the invoice's comment
|
||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||
|
||||
if ( isset ($_FILES)) {
|
||||
if ( sizeof($_FILES) != 0 )
|
||||
save_upload_document($p_cn,$seq);
|
||||
}
|
||||
|
||||
// save the quantity, then we can make an invoice
|
||||
for ( $i=0;$i < $nb_item;$i++)
|
||||
{
|
||||
// don't record operation of 0
|
||||
if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
|
||||
|
||||
// insert into the table quant_sold
|
||||
// Note that negative value are also saved but not the vat !
|
||||
if ( $a_vat[$i] == -1) {
|
||||
$computed_vat=0;
|
||||
$vat_code="null";
|
||||
} else {
|
||||
$computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]);
|
||||
$vat_code=$a_vat[$i];
|
||||
}
|
||||
}
|
||||
}//try
|
||||
catch (Exception $e)
|
||||
{
|
||||
echo '<span class="error">'.
|
||||
'Erreur dans l\'enregistrement '.
|
||||
__FILE__.':'.__LINE__.' '.
|
||||
$e->getMessage();
|
||||
Rollback($p_cn);
|
||||
exit();
|
||||
}
|
||||
Commit($p_cn);
|
||||
return array($internal,$comment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ function u_ShowDossier($p_user,$p_admin)
|
|||
$result.="<TD class=\"mtitle\" ><A class=\"mtitle\" HREF=\"admin_repo.php\"> Administration </A></TD>";
|
||||
}
|
||||
$result.='<TD class="mtitle" ><A class="mtitle" HREF="manuel-fr.pdf" > Aide </a></TD>';
|
||||
$result.='<TD class="mtitle"><A class="mtitle" HREF="user_pref.php">Préférence</a></TD>';
|
||||
$result.='<TD class="mtitle" ><A class="mtitle" HREF="logout.php" > Sortir</a></TD>';
|
||||
$result.="</TR>";
|
||||
$result.="</table>";
|
||||
|
|
@ -74,6 +75,12 @@ function u_ShowDossier($p_user,$p_admin)
|
|||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"parametre.php?dos=$id\">Paramètres</A>";
|
||||
$result.="</TD>";
|
||||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"comptanalytic.php?dos=$id\">Comptabilité analytique</A>";
|
||||
$result.="</TD>";
|
||||
$result.="<TD class=\"mtitle\">";
|
||||
$result.="<A class=\"mtitle\" HREF=\"caisse.php?dos=$id\">Caisse Enregistreuse</A>";
|
||||
$result.="</TD>";
|
||||
|
||||
$result.="</TR>";
|
||||
}
|
||||
|
|
@ -154,15 +161,21 @@ function ShowMenuCompta($p_dossier,$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;
|
||||
}
|
||||
$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=FIN","Financier"),
|
||||
array("user_jrn.php?jrn_type=OD","Op. Diverses"),
|
||||
array("compta.php?p_action=impress","Impression","Impression"),
|
||||
array("compta.php?p_action=fiche","Fiche","Ajouter, modifier ou effacer des fiches"),
|
||||
array("user_jrn.php?jrn_type=ODS","Op. Diverses"),
|
||||
array("compta.php?p_action=impress","Impression","Impression",5),
|
||||
array("compta.php?p_action=fiche","Fiche","Ajouter, modifier ou effacer des fiches",6),
|
||||
array("user_advanced.php","Avancé","Opérations délicates"),
|
||||
);
|
||||
|
||||
|
|
@ -171,9 +184,11 @@ function ShowMenuCompta($p_dossier,$p_high="")
|
|||
$r="<H2 class=\"info\">Comptabilité ".$_SESSION['g_name'];
|
||||
|
||||
$r.='<div align="right">
|
||||
<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$_SESSION['g_dossier'].');">
|
||||
<input type="IMAGE" src="image/search.png" width="36" onclick="openRecherche(\''.$_REQUEST['PHPSESSID'].'\','.$_SESSION['g_dossier'].',\'E\');">
|
||||
<A HREF="user_pref.php" title="Préférence"><IMG SRC="image/preference.png" width="36" border="0" ></A>
|
||||
<A HREF="commercial.php?dos='.$_SESSION['g_dossier'].'" title="Gestion"><IMG SRC="image/compta.png" width="36" border="0" ></A>
|
||||
<A HREF="comptanalytic.php?dos='.$_SESSION['g_dossier'].'" title="CA"><IMG SRC="image/undefined.png" width="36" border="0" ></A>
|
||||
|
||||
<A HREF="parametre.php?dos='.$_SESSION['g_dossier'].'" title="Paramètre"><IMG SRC="image/param.png" width="36" border="0" ></A>
|
||||
<A HREF="login.php" title="Accueil"><IMG SRC="image/home.png" width="36" border="0" ></A>
|
||||
<A HREF="logout.php" title="Sortie"><IMG SRC="image/logout.png" title="Logout" width="36" border="0"></A>
|
||||
|
|
@ -481,6 +496,8 @@ function u_ShowMenuRecherche($p_cn,$p_jrn,$p_sessid,$p_array=null)
|
|||
$r.= "</TR>";
|
||||
$r.= "</TABLE>";
|
||||
$r.="</TR></TABLE>";
|
||||
if ( isset($p_expert))
|
||||
$r.='<input type="hidden" name="expert" value="on">';
|
||||
$r.= "</FORM>";
|
||||
|
||||
|
||||
|
|
@ -529,7 +546,7 @@ function ShowJrn($p_menu="")
|
|||
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=OD","Op. Diverses")
|
||||
array("user_jrn.php?jrn_type=ODS","Op. Diverses")
|
||||
);
|
||||
$result=ShowItem($p_array,'H',"cell","mtitle",$p_menu);
|
||||
return $result;
|
||||
|
|
@ -582,14 +599,30 @@ function ShowMenuFiche($p_dossier)
|
|||
|
||||
function MenuAdmin()
|
||||
{
|
||||
$item=array (array("admin_repo.php?action=user_mgt","Utilisateurs"),
|
||||
array("admin_repo.php?action=dossier_mgt","Dossiers"),
|
||||
array("admin_repo.php?action=modele_mgt","Modèles"),
|
||||
$def=-1;
|
||||
if (isset($_REQUEST['UID']))
|
||||
$def=0;
|
||||
if ( isset ($_REQUEST['action'])){
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'user_mgt':
|
||||
$def=0;
|
||||
break;
|
||||
case 'dossier_mgt':
|
||||
$def=1;
|
||||
break;
|
||||
case 'modele_mgt':
|
||||
$def=2;
|
||||
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("login.php","Accueil"),
|
||||
array("logout.php","Logout")
|
||||
);
|
||||
|
||||
$menu=ShowItem($item,'H');
|
||||
$menu=ShowItem($item,'H',"mtitle","mtitle",$def);
|
||||
return $menu;
|
||||
}
|
||||
/*!
|
||||
|
|
@ -693,6 +726,8 @@ function ShowMenuPcmn($p_start=1)
|
|||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=5">5 Actif</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=6">6 Charges</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=7">7 Produits</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=8">8 Hors Comptabilité</A></TD></TR>';
|
||||
echo '<TR><TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=9">9 Hors Comptabilité</A></TD></TR>';
|
||||
echo "</TABLE>";
|
||||
}
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
/* $Revision$ */
|
||||
/*! \file
|
||||
* \brief Check if still used
|
||||
* \todo this file should be removed, and also the include in user_form_xxx
|
||||
*/
|
||||
|
||||
if ( $action == 'update' ) {
|
||||
|
|
@ -51,4 +52,4 @@ if ( isset($_POST['update_record']) ) {
|
|||
echo '</div>';
|
||||
|
||||
} // if update_record
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# clean all phpcompta related DB.
|
||||
DOMAIN="v232_"
|
||||
DOMAIN="rel2331"
|
||||
dropdb -U phpcompta -h localhost ${DOMAIN}account_repository
|
||||
dropdb -U phpcompta -h localhost ${DOMAIN}dossier1
|
||||
dropdb -U phpcompta -h localhost ${DOMAIN}dossier3
|
||||
|
|
|
|||
362
sql/upgrade.sql
362
sql/upgrade.sql
|
|
@ -0,0 +1,362 @@
|
|||
begin ;
|
||||
|
||||
CREATE or replace FUNCTION insert_quant_sold(
|
||||
p_internal text,
|
||||
p_jid numeric,
|
||||
p_fiche character varying,
|
||||
p_quant numeric,
|
||||
p_price numeric,
|
||||
p_vat numeric,
|
||||
p_vat_code integer,
|
||||
p_client character varying)
|
||||
RETURNS void
|
||||
AS $$
|
||||
declare
|
||||
fid_client integer;
|
||||
fid_good integer;
|
||||
begin
|
||||
select f_id into fid_client from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
|
||||
select f_id into fid_good from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
|
||||
insert into quant_sold
|
||||
(qs_internal,j_id,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client,qs_valid)
|
||||
values
|
||||
(p_internal,p_jid,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client,'Y');
|
||||
return;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
CREATE or REPLACE FUNCTION account_update(p_f_id integer, p_account poste_comptable) RETURNS integer
|
||||
AS $$
|
||||
declare
|
||||
nMax fiche.f_id%type;
|
||||
nCount integer;
|
||||
nParent tmp_pcmn.pcm_val_parent%type;
|
||||
sName varchar;
|
||||
nJft_id attr_value.jft_id%type;
|
||||
begin
|
||||
|
||||
if length(trim(p_account)) != 0 then
|
||||
select count(*) into nCount from tmp_pcmn where pcm_val=p_account;
|
||||
if nCount = 0 then
|
||||
select av_text into sName from
|
||||
attr_value join jnt_fic_att_value using (jft_id)
|
||||
where
|
||||
ad_id=1 and f_id=p_f_id;
|
||||
nParent:=account_parent(p_account);
|
||||
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values (p_account,sName,nParent);
|
||||
end if;
|
||||
end if;
|
||||
select jft_id into njft_id from jnt_fic_att_value where f_id=p_f_id and ad_id=5;
|
||||
update attr_value set av_text=p_account where jft_id=njft_id;
|
||||
|
||||
return njft_id;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE quant_purchase (
|
||||
qp_id integer DEFAULT nextval(('s_quantity'::text)::regclass) NOT NULL,
|
||||
qp_internal text NOT NULL,
|
||||
j_id integer not null,
|
||||
qp_fiche integer NOT NULL,
|
||||
qp_quantite numeric(20,4) NOT NULL,
|
||||
qp_price numeric(20,4),
|
||||
qp_vat numeric(20,4) default 0.0,
|
||||
qp_vat_code integer,
|
||||
qp_nd_amount numeric(20,4) default 0.0,
|
||||
qp_nd_tva numeric(20,4) default 0.0,
|
||||
qp_nd_tva_recup numeric(20,4) default 0.0,
|
||||
qp_supplier integer NOT NULL,
|
||||
qp_valid char(1) default 'Y' not null
|
||||
);
|
||||
ALTER TABLE ONLY quant_purchase
|
||||
ADD CONSTRAINT qp_id_pk PRIMARY KEY (qp_id);
|
||||
|
||||
---
|
||||
truncate quant_sold;
|
||||
alter table quant_sold ADD qs_valid char(1) ;
|
||||
alter table quant_sold add j_id integer;
|
||||
alter table quant_sold alter j_id set not null;
|
||||
|
||||
update quant_sold set qs_valid='Y';
|
||||
alter table quant_sold alter qs_valid set default 'Y';
|
||||
alter table quant_sold alter qs_valid set not null;
|
||||
|
||||
|
||||
|
||||
CREATE or replace 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_client character varying) RETURNS void
|
||||
AS $$
|
||||
declare
|
||||
fid_client integer;
|
||||
fid_good integer;
|
||||
begin
|
||||
select f_id into fid_client from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client);
|
||||
select f_id into fid_good from
|
||||
attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche);
|
||||
insert into quant_purchase
|
||||
(qp_internal,
|
||||
j_id,
|
||||
qp_fiche,
|
||||
qp_quantite,
|
||||
qp_price,
|
||||
qp_vat,
|
||||
qp_vat_code,
|
||||
qp_nd_amount,
|
||||
qp_nd_tva,
|
||||
qp_nd_tva_recup,
|
||||
qp_supplier)
|
||||
values
|
||||
(p_internal,
|
||||
p_j_id,
|
||||
fid_good,
|
||||
p_quant,
|
||||
p_price,
|
||||
p_vat,
|
||||
p_vat_code,
|
||||
p_nd_amount,
|
||||
p_nd_tva,
|
||||
p_nd_tva_recup,
|
||||
fid_client);
|
||||
return;
|
||||
end;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values(8,'Comptes hors Compta',0);
|
||||
insert into tmp_pcmn(pcm_val,pcm_lib,pcm_val_parent) values(9,'Comptes hors Compta',0);
|
||||
|
||||
COMMENT ON TABLE parameter IS 'parameter of the company';
|
||||
|
||||
--
|
||||
-- Name: plan_analytique; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE plan_analytique (
|
||||
pa_id integer NOT NULL,
|
||||
pa_name text DEFAULT 'Sans Nom'::text NOT NULL,
|
||||
pa_description text
|
||||
);
|
||||
|
||||
--
|
||||
-- Name: TABLE plan_analytique; Type: COMMENT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
COMMENT ON TABLE plan_analytique IS 'Plan Analytique (max 5)';
|
||||
|
||||
|
||||
--
|
||||
-- Name: plan_analytique_pa_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
CREATE SEQUENCE plan_analytique_pa_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public.plan_analytique_pa_id_seq OWNER TO phpcompta;
|
||||
|
||||
--
|
||||
-- Name: plan_analytique_pa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER SEQUENCE plan_analytique_pa_id_seq OWNED BY plan_analytique.pa_id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: pa_id; Type: DEFAULT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE plan_analytique ALTER COLUMN pa_id SET DEFAULT nextval('plan_analytique_pa_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: plan_analytique_pa_name_key; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY plan_analytique
|
||||
ADD CONSTRAINT plan_analytique_pa_name_key UNIQUE (pa_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: plan_analytique_pkey; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY plan_analytique
|
||||
ADD CONSTRAINT plan_analytique_pkey PRIMARY KEY (pa_id);
|
||||
|
||||
|
||||
-- Ajout table operation_analytique
|
||||
|
||||
-- Ajout table poste_analytique
|
||||
--
|
||||
-- Name: poste_analytique; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
CREATE TABLE poste_analytique (
|
||||
po_id integer NOT NULL,
|
||||
po_name text NOT NULL,
|
||||
pa_id integer NOT NULL,
|
||||
po_amount numeric(20,4) DEFAULT 0.0 NOT NULL,
|
||||
po_description text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.poste_analytique OWNER TO phpcompta;
|
||||
|
||||
--
|
||||
-- Name: TABLE poste_analytique; Type: COMMENT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
COMMENT ON TABLE poste_analytique IS 'Poste Analytique';
|
||||
|
||||
|
||||
--
|
||||
-- Name: poste_analytique_po_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
CREATE SEQUENCE poste_analytique_po_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public.poste_analytique_po_id_seq OWNER TO phpcompta;
|
||||
|
||||
--
|
||||
-- Name: poste_analytique_po_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER SEQUENCE poste_analytique_po_id_seq OWNED BY poste_analytique.po_id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: po_id; Type: DEFAULT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE poste_analytique ALTER COLUMN po_id SET DEFAULT nextval('poste_analytique_po_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: poste_analytique_pkey; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY poste_analytique
|
||||
ADD CONSTRAINT poste_analytique_pkey PRIMARY KEY (po_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: poste_analytique_pa_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY poste_analytique
|
||||
ADD CONSTRAINT poste_analytique_pa_id_fkey FOREIGN KEY (pa_id) REFERENCES plan_analytique(pa_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: operation_analytique; Type: TABLE; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
create sequence s_oa_group;
|
||||
|
||||
CREATE TABLE operation_analytique (
|
||||
oa_id integer NOT NULL,
|
||||
po_id integer NOT NULL,
|
||||
oa_amount numeric(20,4) NOT NULL,
|
||||
oa_description text,
|
||||
oa_debit boolean DEFAULT true NOT NULL,
|
||||
j_id integer,
|
||||
oa_group integer DEFAULT nextval('s_oa_group'::regclass) NOT NULL,
|
||||
oa_date date NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.operation_analytique OWNER TO phpcompta;
|
||||
|
||||
--
|
||||
-- Name: TABLE operation_analytique; Type: COMMENT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
COMMENT ON TABLE operation_analytique IS 'History of the analytic account';
|
||||
|
||||
|
||||
--
|
||||
-- Name: historique_analytique_ha_id_seq; Type: SEQUENCE; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
CREATE SEQUENCE historique_analytique_ha_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER TABLE public.historique_analytique_ha_id_seq OWNER TO phpcompta;
|
||||
|
||||
--
|
||||
-- Name: historique_analytique_ha_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER SEQUENCE historique_analytique_ha_id_seq OWNED BY operation_analytique.oa_id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: oa_id; Type: DEFAULT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE operation_analytique ALTER COLUMN oa_id SET DEFAULT nextval('historique_analytique_ha_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: historique_analytique_pkey; Type: CONSTRAINT; Schema: public; Owner: phpcompta; Tablespace:
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY operation_analytique
|
||||
ADD CONSTRAINT historique_analytique_pkey PRIMARY KEY (oa_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: operation_analytique_j_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY operation_analytique
|
||||
ADD CONSTRAINT operation_analytique_j_id_fkey FOREIGN KEY (j_id) REFERENCES jrnx(j_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
--
|
||||
-- Name: operation_analytique_po_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: phpcompta
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY operation_analytique
|
||||
ADD CONSTRAINT operation_analytique_po_id_fkey FOREIGN KEY (po_id) REFERENCES poste_analytique(po_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
INSERT INTO parameter VALUES ('MY_ANALYTIC', null);
|
||||
|
||||
alter table jrn add constraint ux_internal unique (jr_internal);
|
||||
|
||||
alter table quant_sold add constraint fk_internal foreign key (qs_internal) references jrn (jr_internal) on delete cascade on update cascade;
|
||||
|
||||
alter table quant_purchase add constraint fk_internal foreign key (qp_internal) references jrn (jr_internal) on delete cascade on update cascade;
|
||||
commit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue