diff --git a/contrib/document_test/facture.odt b/contrib/document_test/facture.odt index fc80858bf..64496bdd8 100644 Binary files a/contrib/document_test/facture.odt and b/contrib/document_test/facture.odt differ diff --git a/doc/developper/Doxyfile b/doc/developper/Doxyfile index c2613509c..c37cf5240 100644 --- a/doc/developper/Doxyfile +++ b/doc/developper/Doxyfile @@ -30,9 +30,9 @@ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO +DETAILS_AT_TOP = YES INHERIT_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO +DISTRIBUTE_GROUP_DOC = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = @@ -43,8 +43,8 @@ SUBGROUPING = YES # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = YES HIDE_UNDOC_MEMBERS = YES @@ -57,8 +57,8 @@ HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO +SORT_BRIEF_DOCS = YES +SORT_BY_SCOPE_NAME = YES GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES @@ -77,7 +77,7 @@ WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = +WARN_LOGFILE = doxygen-warn.log #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- @@ -147,7 +147,7 @@ VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt index a126baa1a..7ad15b707 100644 Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ diff --git a/html/access.php b/html/access.php index a24713b49..3dde43316 100644 --- a/html/access.php +++ b/html/access.php @@ -33,11 +33,12 @@ require_once ('class_dossier.php'); require_once('class_todo_list.php'); +$user=new User(DbConnect()); +$user->check_dossier(dossier::id()); + $cn=DbConnect(dossier::id()); -$user=new User($cn); -if ($user->AccessJrn($cn,dossier::id()) == false ){ - exit('

Permission refusee

'); -} +$user->db=$cn; +$user->Check(); if ( DBVERSION!=dossier::get_version($cn)) { echo '

Votre base de données n\'est pas à jour, '; @@ -48,7 +49,7 @@ if ( DBVERSION!=dossier::get_version($cn)) { html_page_start($_SESSION['g_theme']); echo '
'; -echo menu_tool('access'); +echo menu_tool('access.php'); echo '
'; echo '
'; /* diff --git a/html/admin/setup.php b/html/admin/setup.php index ab9419e03..2b9570c85 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -387,7 +387,7 @@ echo '
'; echo "

Mise à jour Repository

"; $cn=DbConnect(); if ( DEBUG == 'false') ob_start(); - $MaxVersion=8; + $MaxVersion=9; for ($i=4;$i<= $MaxVersion;$i++) { if ( get_version($cn) <= $i ) { diff --git a/html/admin/sql/patch/ac-upgrade9.sql b/html/admin/sql/patch/ac-upgrade9.sql new file mode 100644 index 000000000..5e4519080 --- /dev/null +++ b/html/admin/sql/patch/ac-upgrade9.sql @@ -0,0 +1,10 @@ +begin; +--- on account_repository +update priv_user set priv_priv='X' where priv_priv='NO'; +update priv_user set priv_priv='R' where priv_priv='W'; +update user_global_pref set parameter_value='TEXT' where parameter_type='TOPMENU'; + + +update version set val=10; +commit; + diff --git a/html/admin/sql/patch/upgrade56.sql b/html/admin/sql/patch/upgrade56.sql new file mode 100644 index 000000000..044c41ce3 --- /dev/null +++ b/html/admin/sql/patch/upgrade56.sql @@ -0,0 +1,168 @@ +begin; +CREATE OR REPLACE FUNCTION create_missing_sequence() + RETURNS integer AS +$BODY$ +declare +p_sequence text; +nSeq integer; +c1 cursor for select jrn_def_id from jrn_def; +begin + open c1; + loop + fetch c1 into nSeq; + if not FOUND THEN + close c1; + return 0; + end if; + p_sequence:='s_jrn_pj'||nSeq::text; + execute 'create sequence '||p_sequence; + end loop; +close c1; +return 0; + +end; +$BODY$ +LANGUAGE 'plpgsql'; + +select create_missing_sequence(); + + +CREATE OR REPLACE FUNCTION drop_index(p_constraint character varying) + RETURNS void AS +$BODY$ +declare + nCount integer; +begin + select count(*) into nCount from pg_indexes where indexname=p_constraint; + if nCount = 1 then + execute 'drop index '||p_constraint ; + end if; +end; +$BODY$ +LANGUAGE 'plpgsql'; +-- on dossier + +insert into parameter (pr_id,pr_value) values ('MY_TVA_USE','Y'); +insert into parameter (pr_id,pr_value) values ('MY_PJ_SUGGEST','Y'); + +-- new security +alter table action add ac_module text; +alter table action add ac_code varchar(9); +create unique index uj_login_uj_jrn_id on user_sec_jrn(uj_login,uj_jrn_id); + +-- PostgreSQL database dump +-- +delete from user_Sec_act; +delete from action; + +COMMENT ON TABLE action IS 'The different privileges'; +select drop_index('x_act'); + +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (100, 'Accès en lecture', 'budget', 'BUDLEC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (110, 'Création hypothèse', 'budget', 'BUDHYP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (120, 'Création de fiche', 'budget', 'BUDFIC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (130, 'Impression', 'budget', 'BUDIMP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (210, 'Ajout de plan analytique', 'compta_anal', 'CAPA'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (220, 'Ajout de poste analytique', 'compta_anal', 'CAPO'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (230, 'Ajout de groupe analytique', 'compta_anal', 'CAGA'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (235, 'Ajout d''operation diverses', 'compta_anal', 'CAOD'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (240, 'Impression', 'compta_anal', 'CAIMP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (300, 'Gestion', 'gestion', 'GESTION'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (305, 'Import en Banque', 'gestion', 'GEBQ'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (307, 'Effacement d''opération', 'gestion', 'GEOP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (310, 'Courrier (lecture & écriture)', 'gestion', 'GECOUR'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (311, 'Fournisseur', 'gestion', 'GESUPPL'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (312, 'Client', 'gestion', 'GECUST'); +-- INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (320, 'gestion de stock', 'gestion', 'GESTOCK'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (700, 'Rapport', 'impression', 'IMPRAP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (710, 'Journaux', 'impression', 'IMPJRN'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (720, 'Fiche', 'impression', 'IMPFIC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (730, 'Poste', 'impression', 'IMPPOSTE'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (740, 'Bilan', 'impression', 'IMPBIL'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (750, 'Balance', 'impression', 'IMPBAL'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (800, 'Ajout de fiche', 'fiche', 'FICADD'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (805, 'Création, modification et effacement de fiche', 'fiche', 'FIC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (910, 'création, modification et effacement de catégorie de fiche', 'fiche', 'FICCAT'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1100, 'Mode comptabilité analytique', 'parametre', 'PARCA'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1110, 'Ajout de période', 'parametre', 'PARPER'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1120, 'Catégorie des fiches', 'parametre', 'PARFIC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1130, 'Document', 'parametre', 'PARDOC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1140, 'Modification journaux', 'parametre', 'PARJRN'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1150, 'TVA', 'parametre', 'PARTVA'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1160, 'Moyen de paiement', 'parametre', 'PARMP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1180, 'Clôture ', 'parametre', 'PARCLO'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1185, 'Changement du plan comptable ', 'parametre', 'PARPCMN'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1170, 'Poste Comptable de base', 'parametre', 'PARPOS'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1190, 'Centralisation', 'parametre', 'PARCENT'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1200, 'Écriture d''ouverture', 'parametre', 'PAREO'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1210, 'Mode strict', 'parametre', 'PARSTR'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1220, 'Coordonnées société', 'parametre', 'PARCOORD'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1230, 'Création de rapport', 'parametre', 'PARRAP'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1240, 'Effacement et création d''opération prédéfinie', 'parametre', 'PARPREDE'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1245, 'Sécurité du dossier', 'parametre', 'PARSEC'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1500, 'Stock (lecture)', 'stock', 'STOLE'); +INSERT INTO action (ac_id, ac_description, ac_module, ac_code) VALUES (1510, 'Stock (changement)', 'stock', 'STOWRITE'); + +ALTER TABLE jrn ADD COLUMN jr_pj_number text; +ALTER TABLE del_jrn ADD COLUMN jr_pj_number text; +ALTER TABLE jrn_def ADD COLUMN jrn_def_pj_pref text; + +update jrn_def set jrn_def_pj_pref=jrn_def_type ; + +CREATE OR REPLACE FUNCTION jrn_del() + RETURNS trigger AS +$BODY$ +declare +row jrn%ROWTYPE; +begin +row:=OLD; +insert into del_jrn ( jr_id, + jr_def_id, + jr_montant, + jr_comment, + jr_date, + jr_grpt_id, + jr_internal, + jr_tech_date, + jr_tech_per, + jrn_ech, + jr_ech, + jr_rapt, + jr_valid, + jr_opid, + jr_c_opid, + jr_pj, + jr_pj_name, + jr_pj_type, + jr_pj_number, + del_jrn_date) + select jr_id, + jr_def_id, + jr_montant, + jr_comment, + jr_date, + jr_grpt_id, + jr_internal, + jr_tech_date, + jr_tech_per, + jrn_ech, + jr_ech, + jr_rapt, + jr_valid, + jr_opid, + jr_c_opid, + jr_pj, + jr_pj_name, + jr_pj_type, + jr_pj_number + ,now() from jrn where jr_id=row.jr_id; +return row; +end; +$BODY$ +LANGUAGE 'plpgsql' ; + + + +update version set val=57; + +commit; diff --git a/html/admin_repo.php b/html/admin_repo.php index a467b2712..dcd5fd81a 100644 --- a/html/admin_repo.php +++ b/html/admin_repo.php @@ -43,7 +43,9 @@ if ($User->admin != 1) { } echo '

Administration Globale

'; -echo "
".MenuAdmin()."
"; +echo '
'; + +echo MenuAdmin()."
"; diff --git a/html/ajax_import.php b/html/ajax_import.php index 3cb9aff35..196708b60 100644 --- a/html/ajax_import.php +++ b/html/ajax_import.php @@ -29,7 +29,7 @@ */ include_once ("constant.php"); include_once ("postgres.php"); -include ('class_user.php'); +require_once ('class_user.php'); require_once ('class_dossier.php'); @@ -37,6 +37,8 @@ require_once ('class_dossier.php'); $cn=DbConnect(dossier::id()); $User=new User($cn); +$User->check_dossier(dossier::id()); +$User->can_request('GEBQ'); $User->Check(); if ( isset ($_GET['action']) && $_GET['action']=='update' diff --git a/html/ajax_report.php b/html/ajax_report.php index f55124b47..c4f993fee 100644 --- a/html/ajax_report.php +++ b/html/ajax_report.php @@ -31,6 +31,7 @@ require_once ("user_common.php"); require_once ("debug.php"); require_once('class_dossier.php'); require_once('class_acc_report.php'); +require_once('class_user.php'); if ( ! isset($_GET['gDossier']) || ! isset($_GET['f']) ) { @@ -39,6 +40,13 @@ if ( ! isset($_GET['gDossier']) || print $a; exit(); } +$cn=DbConnect(dossier::id()); + +$User=new User($cn); +$User->Check(); +$User->check_dossier(dossier::id()); +$User->can_request('PARRAP',0); + $gDossier=dossier::id(); diff --git a/html/annulation.php b/html/annulation.php index ec3111a9b..e6b1b26bb 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -33,6 +33,8 @@ require_once("class_widget.php"); require_once("class_acc_ledger.php"); require_once("class_acc_operation.php"); require_once ('class_periode.php'); +require_once('class_acc_reconciliation.php'); + /* Admin. Dossier */ include_once ("class_user.php"); @@ -42,6 +44,8 @@ $gDossier=dossier::id(); $cn=DbConnect($gDossier); $User=new User($cn); $User->Check(); +$User->check_dossier(dossier::id()); +$User->can_request(GEOP,0); html_page_start($User->theme,"onLoad='window.focus();'"); echo JS_VIEW_JRN_MODIFY; @@ -50,12 +54,10 @@ if ( isset( $_REQUEST['p_jrn'] )) { } // Check privilege - // CheckJrn verify that the user is not an admin - // an admin has all right - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } +if ( $User->check_jrn($_GET['p_jrn']) != 'W') { + NoAccess(); + exit -1; +} @@ -223,7 +225,10 @@ if ($p_id != -1 ) { // A // Add a "concerned operation to bound these op.together // - $Res=InsertRapt($cn,$seq,$l_array['jr_id']); + $rec=new Acc_Reconciliation ($cn); + $rec->set_jr_id($seq); + $rec->insert($l_array['jr_id']); + // Check return code if ( $Res == false ) { throw (new Exception(__FILE__.__LINE__."sql a echoue [ $sql ]"));} @@ -404,8 +409,10 @@ for ( $i = 0; $i < $max_cred;$i++) { echo ${"e_class_cred$i"}." $lib "."".${"e_mont_cred$i"}.""; echo '
'; } - -$a=GetConcerned($cn,$e_jr_id); +/* concerned operation */ +$rec=new Acc_Reconciliation($cn); +$rec->set_jr_id($e_jr_id); +$a=$rec->get(); if ( $a != null ) { diff --git a/html/bal_csv.php b/html/bal_csv.php index f6bd2eed0..20162306d 100644 --- a/html/bal_csv.php +++ b/html/bal_csv.php @@ -36,11 +36,13 @@ $cn=DbConnect($gDossier); require_once ('class_user.php'); $User=new User(DbConnect()); $User->Check(); -if ( $User->check_action($cn,BALANCE) == 0) +if ( $User->check_action(IMPBAL) == 0) { NoAccess(); exit; } +echo 'poste;libelle;deb;cred;solde deb;solde cred'; +printf("\n"); $bal=new Acc_Balance($cn); $t_cent=""; diff --git a/html/bilan.php b/html/bilan.php index 6a1bee0d9..e6c7a6fae 100644 --- a/html/bilan.php +++ b/html/bilan.php @@ -40,16 +40,8 @@ $User->Check(); // TODO a specific level of security for the "bilan" ??? // Change must be done here -if ( $User->admin == 0 ) { - if ($User->check_action($cn,IMP) - ==0 - ) - { - /* Cannot Access */ - NoAccess(); - } +$User->can_request(IMPBIL); -} $bilan=new Acc_Bilan($cn); $bilan->get_request_get(); diff --git a/html/bud_ajax.php b/html/bud_ajax.php index afe5d214b..0de652ddf 100644 --- a/html/bud_ajax.php +++ b/html/bud_ajax.php @@ -29,11 +29,16 @@ extract ($_POST); require_once ('class_dossier.php'); require_once ('class_bud_data.php'); require_once ('debug.php'); +require_once('class_user.php'); echo_debug(__FILE__.':'.__LINE__,' $POST ',$_POST); - - $cn=DbConnect(dossier::id()); +$User=new User($cn); +$User->Check(); +$User->check_dossier(dossier::id()); +$User->can_request('BUDLEC',1); + + if ( $_POST['action'] == 'delete') { if ( $bd_id != 0 ) { diff --git a/html/budget.php b/html/budget.php index dabf08c95..29a8eb3c8 100644 --- a/html/budget.php +++ b/html/budget.php @@ -48,7 +48,7 @@ $User=new User($rep); $User->Check(); echo '
'; -echo menu_tool("budget"); +echo menu_tool("budget.php"); echo '
'; /* security */ @@ -86,7 +86,7 @@ echo ShowItem(array( echo '
'; echo '
'; echo ''; -$User->can_request($rep,BUDGET); +$User->can_request(BUDLEC,1); $cn=DbConnect($gDossier); $obj=new Bud_Hypo($cn); @@ -96,6 +96,7 @@ $obj=new Bud_Hypo($cn); //----------------------------------------------------- if ( $p_action == "hypo" ) { + $User->can_request(BUDHYP,1); require_once("bud_hypo.inc.php"); } @@ -104,6 +105,7 @@ if ( $p_action == "hypo" ) //----------------------------------------------------- if ( $p_action == "fiche" ) { + $User->can_request(BUDFIC,1); if ( $obj->size()==0 ) { echo '

Desole pas d\'hypothese definie

'; exit(); @@ -130,6 +132,7 @@ if ( $p_action == "detail" ) //----------------------------------------------------- if ( $p_action == "synthese" ) { + $User->can_request(BUDIMP,1); if ( $obj->size()==0 ) { echo '

Desole pas d\'hypothese definie

'; exit(); diff --git a/html/commercial.php b/html/commercial.php index f77cc44a6..15182558f 100644 --- a/html/commercial.php +++ b/html/commercial.php @@ -43,6 +43,7 @@ $rep=DbConnect($gDossier); require_once ("class_user.php"); $User=new User($rep); $User->Check(); +$User->check_dossier($gDossier); //----------------------------------------------------- // update preference @@ -70,13 +71,16 @@ require_once('class_widget.php'); include_once("preference.php"); include_once("user_menu.php"); $str_dossier=dossier::get(); -echo '
'; -echo menu_tool('gestion'); -echo '
'; + $p_action=(isset ($_REQUEST['p_action']))?$_REQUEST['p_action']:""; // TODO Menu with all the customer //echo '
'; -echo '
'; +///echo '
'; +echo '
'; +echo menu_tool('commercial.php'); + +echo '
'; + echo ShowItem(array( array('?p_action=client&'.$str_dossier,'Client'), array('?p_action=ven&'.$str_dossier,'Vente/Facture'), @@ -95,13 +99,11 @@ echo ShowItem(array( ), 'H',"mtitle","mtitle","?p_action=$p_action&".$str_dossier,' width="100%"'); - - // +echo '
'; echo '
'; - $cn=DbConnect($gDossier); -$User->can_request($cn,SEC_GESTION); + echo JS_VIEW_JRN_MODIFY; echo JS_AJAX_FICHE; @@ -118,12 +120,14 @@ if ( $p_action == "pref" ) //----------------------------------------------------- if ( $p_action == "client" ) { + $User->can_request(GECUST,1); require_once("client.inc.php"); }// $p_action == fournisseur //----------------------------------------------------- // Fournisseur if ( $p_action == 'fournisseur') { + $User->can_request(GESUPPL,1); require_once("supplier.inc.php"); } @@ -131,6 +135,7 @@ if ( $p_action == 'fournisseur') // action if ( $p_action == 'suivi_courrier') { + $User->can_request(GECOUR,1); require_once("action.inc.php"); } //----------------------------------------------------- @@ -167,13 +172,14 @@ if ( $p_action=='quick_writing') { // Impression if ( $p_action == 'impress') { - if ( $User->check_action($cn,IMP) == 0) - { - NoAccess(); - exit; - } - - require_once("impress.inc.php"); + if ( $User->check_action(IMPRAP)==1 || + $User->check_action(IMPJRN)==1 || + $User->check_action(IMPFIC)==1 || + $User->check_action(IMPPOSTE)==1 || + $User->check_action(IMPBIL)==1 ) + require_once("impress.inc.php"); + else + $User->can_request(9999,1); } if ( $p_action == 'fiche') { require_once('fiche.inc.php'); @@ -182,14 +188,20 @@ if ( $p_action == 'stock') { require_once('stock.inc.php'); } if ( $p_action=='periode') { - require_once ('periode.inc.php'); + if ( $User->check_action(PARPER)==1 || + $User->check_action(PARCLO)==1) + require_once ('periode.inc.php'); + else + $User->can_request(9999,1); } if ( $p_action=='central') { + $User->can_request(PARCENT,1); require_once ('central.inc.php'); } //----------------------------------------------------- // Expense if ( $p_action == 'defreport') { + $User->can_request(PARPREDE,1); require_once("report.inc.php"); } diff --git a/html/compta.php b/html/compta.php index 9dd59e5b8..6060fd762 100644 --- a/html/compta.php +++ b/html/compta.php @@ -28,6 +28,7 @@ $gDossier=dossier::id(); include_once ("ac_common.php"); $action=(isset($_REQUEST['p_action']))?$_REQUEST['p_action']:''; $use_html=1; + //---------------------------------------------------------------------- /*!\todo find a way to improve performance : the calendar must not * always be loaded and takes at least 50KB @@ -71,8 +72,6 @@ echo '
'; // call impress sub-menu if ( $action == 'impress' ) { - $User->can_request($cn,IMP) ; - require_once('impress.inc.php'); } diff --git a/html/comptanalytic.php b/html/comptanalytic.php index e0290719b..3c7c33871 100644 --- a/html/comptanalytic.php +++ b/html/comptanalytic.php @@ -38,7 +38,7 @@ require_once ("class_user.php"); require_once ('user_menu.php'); $User=new User($cn); $User->Check(); - +$User->check_dossier($gDossier); html_page_start($_SESSION['g_theme']); @@ -47,30 +47,27 @@ html_page_start($_SESSION['g_theme']); //Header echo '
'; //----------------------------------------------------------------- -echo menu_tool('analytic'); +echo menu_tool('comptanalytic.php'); $def=-1; if ( isset ($_REQUEST['p_action'])) { - switch ($_REQUEST['p_action']) - { - case 'ca_pa': - $User->can_request($cn,CA_ACCESS); - $def=0; - break; - case 'ca_od': - $User->can_request($cn,CA_ODS); - $def=1; - break; - case 'ca_imp': - $User->can_request($cn,CA_IMPRESSION); - $def=2; - break; - case 'ca_groupe': - $def=3; - break; - } + switch ($_REQUEST['p_action']) + { + case 'ca_pa': + $def=0; + break; + case 'ca_od': + $def=1; + break; + case 'ca_imp': + $def=2; + break; + case 'ca_groupe': + $def=3; + break; + } } -echo '
'; +echo '
'; echo ShowItem(array( array('?p_action=ca_pa&'.$str_dossier,'Plan Analytique',"Plan Analytique",0), array('?p_action=ca_od&'.$str_dossier,'Opérations Diverses',"Permet d'enregistrer des operations sur la compta analytique",1), @@ -81,6 +78,29 @@ echo ShowItem(array( echo '
'; echo '
'; echo '
'; +if ( isset ($_REQUEST['p_action'])) + { + switch ($_REQUEST['p_action']) + { + case 'ca_pa': + $User->can_request(CAPA,1); + $def=0; + break; + case 'ca_od': + $User->can_request(CAOD,1); + $def=1; + break; + case 'ca_imp': + $User->can_request(CAIMP,1); + $def=2; + break; + case 'ca_groupe': + $User->can_request(CAGA,1); + $def=3; + break; + } + } + if ( !isset($_REQUEST['p_action'])) exit(); diff --git a/html/compute.php b/html/compute.php index 3fb6c93b2..ec1c652b4 100644 --- a/html/compute.php +++ b/html/compute.php @@ -24,7 +24,7 @@ * \brief respond ajax request, the get contains * the value : * - c for qcode - * - t for tva_id + * - t for tva_id -1 if there is no TVA to compute * - p for price * - q for quantity * - n for number of the ctrl @@ -48,20 +48,27 @@ foreach (array('t','c','p','q','n','gDossier') as $a) { } $cn=DbConnect(dossier::id()); -// Retrieve the rate of vat - -$tva_rate=new Acc_Tva($cn); -$tva_rate->set_parameter('id',$t); -$tva_rate->load(); +// Retrieve the rate of vat, it $t == -1 it means no VAT +if ( $t != -1 ){ + $tva_rate=new Acc_Tva($cn); + $tva_rate->set_parameter('id',$t); + $tva_rate->load(); +} $total=new Acc_Compute(); bcscale(4); $amount=round(bcmul($p,$q),2); $total->set_parameter('amount',$amount); -$total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); -$total->compute_vat(); -$tvac=bcadd($total->get_parameter('amount_vat'),$amount); -header("Content-type: text/html; charset: utf8",true); -echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; +if ( $t != -1 ) { + $total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate')); + $total->compute_vat(); + $tvac=bcadd($total->get_parameter('amount_vat'),$amount); + header("Content-type: text/html; charset: utf8",true); + echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}'; +} else { +/* there is no vat to compute */ + header("Content-type: text/html; charset: utf8",true); + echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"NA","tvac":"'.$amount.'"}'; +} ?> diff --git a/html/control.php b/html/control.php deleted file mode 100644 index 131c4907b..000000000 --- a/html/control.php +++ /dev/null @@ -1,73 +0,0 @@ - -

ERREUR MAUVAIS APPEL

- -Check(); -include ("check_priv.php"); -echo '
'; - -echo ShowMenuCompta($_SESSION['g_dossier']); -echo '
'; -echo JS_SEARCH_POSTE; - -if ( !isset($sessid)) -{ - $sessid=$_REQUEST["PHPSESSID"]; -} -$search='"; - - -include_once("fiche_inc.php"); - -$cn=DbConnect($_SESSION['g_dossier']); - -// Security check -$read=$User->check_action($cn,FICHE_READ); -$write=$User->check_action($cn,FICHE_WRITE); -if ($read+$write == 0 ){ - /* Cannot Access */ - NoAccess(); -} -function ShowFicheDefInput($p_fiche_def) -{ - $r=""; - // Save the label - - $p_fiche_def->SaveLabel($_REQUEST['label']); - $p_fiche_def->Get(); - $p_fiche_def->GetAttribut(); - $r.= '

'.$p_fiche_def->label.'

'; - - $r.= '
'; - $r.= ''; - - $r.= $p_fiche_def->DisplayAttribut(); - $r.= ' '; - $r.= "
"; - return $r; -} -// Creation of a new model of card -// in the database -if ( isset($_POST['add_modele']) and $write != 0) { - // insert the model of card in database - $fiche_def=new fiche_def($cn); - $fiche_def->Add($_POST); -} -$r=""; -// Add a line in the card model -if ( isset ($_POST["add_line"]) ) { - $r= '
'; - if ( $write ==0) - $r.= "

Pas d'accès

"; - else - { - $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); - // Insert Line - $fiche_def->InsertAttribut($_REQUEST['ad_id']); - - $r.=ShowFicheDefInput($fiche_def); - - } - $r.= '
'; -} -// Change the name of the card model -if ( isset ($_POST["change_name"] ) ) { - $r= '
'; - if ( $write ==0) - $r.= "

Pas d'accès

"; - else - { - $fiche_def=new fiche_def($cn,$_REQUEST['fd_id']); - $r.=ShowFicheDefInput($fiche_def); - } - $r.= '
'; -} - -//var_dump($_GET); -ShowMenuFiche($_SESSION['g_dossier']); -echo $r; - -//------------------------------------------------------------------------------ -// Get action -if ( isset ( $_GET["action"]) ) { - $action=$_GET["action"]; - // View the details of the selected cat. of cards - if ( isset ($_GET["fiche"]) && $action=="vue" - && ! isset ($_POST['add_fiche']) - && ! isset ($_POST['update_fiche']) - && ! isset ($_POST['delete'])) { - echo '
'; - $fiche_def=new fiche_def($cn,$_GET['fiche']); - $fiche_def->myList(); - - echo '
'; - - } - //_________________________________________________________________________ -// Display the detail of a card - if ($action== "detail" ) { - echo '
'; - $t=false; - if ( $write == 0) - { - echo '

Vos changements ne seront pas sauvés

'; - $t=true; - } - $str=""; - $fiche=new fiche($cn,$_GET["fiche_id"]); - if ( $_SESSION['g_pagesize'] != -1 ){ - // retrieve value - // with offet &offset=15&step=15&page=2&size=15 - if ( isset($_GET['offset']) && $_SESSION['g_pagesize'] != -1) { - $str=sprintf("&offset=%s&step=%s&page=%s&size=%s", - $_GET['offset'], - $_GET['step'], - $_GET['page'], - $_GET['size']); - } - - - } - if ( $write != 0 ) - echo '
'; - echo $fiche->Display($t); - echo ''; - if ( $write != 0 ) { - echo ''; - echo ''; - } - $str=""; - - echo ''; - if ( $write != 0 ) echo '
'; - echo '
'; - } - //_________________________________________________________________________ - // Display the form where you can enter - // the property of the card model - if ($action == "add_modele" and $write !=0) { - echo '
'; - CreateCategory($cn,$search); - echo '
'; - } - //_________________________________________________________________________ - // Modify a card Model - if ($action == "modifier" ) { - echo '
'; - if ( $write ==0) - echo "

Pas d'accès

"; - else - { - - - $fiche_def=new fiche_def($cn,$_GET['fiche']); - $fiche_def->Get(); - $fiche_def->GetAttribut(); - echo '

'.$fiche_def->label.'

'; - - echo '
'; - echo ''; - - echo $fiche_def->DisplayAttribut(); - echo ' '; - echo "
"; - } - echo '
'; - } - //_________________________________________________________________________ - // Search a card - if ( $action == "search" ) - { - $sql="select distinct f_id,fd_id,av_text from fiche join jnt_fic_att_value using (f_id) - join attr_value using (jft_id) where - upper(av_text) like upper('%".FormatString($_GET["search_text"])."%') order by av_text,f_id"; - $all=get_array($cn,$sql); - // test on the size - // - if ( sizeof($all) != 0 ) - { - echo '
'; - echo "Nombre de résultat : ".sizeof($all).'
'; - foreach ($all as $f_id){ - $fiche=new fiche($cn,$f_id['f_id']); - echo ''. - $fiche->getName().'
'; - } - echo '
'; - } - else - { - echo '
'; - echo '
'; - $w=new widget('text'); - $search_text=(isset($_REQUEST['search_text']))?$_REQUEST['search_text']:""; - $h=new widget('hidden'); - echo $h->IOValue('action','search'); - echo "Recherche :".$w->IOValue('search_text',$search_text); - echo widget::submit('submit','Rechercher'); - echo '
'; - echo "Aucun résultat trouvé"; - - echo '
'; - - } - } -} -// Display a blank card from the selected category -if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) ) { - echo '
'; - if ( $write ==0) - echo "

Pas d'accès

"; - else - { - $url=$_SERVER['REQUEST_URI']; - $fiche=new fiche($cn,0); - - echo '
'; - echo $fiche->blank($_POST['fiche']); - echo ''; - echo ''. - ''; - - - echo '
'; - } - echo '
'; - exit(); -} -//------------------------------------------------------------------------------ -// delete a card -if (isset($_POST['delete']) ) { - echo '
'; - if ( $write ==0) - echo "

Pas d'accès

"; - else - { - $fiche=new fiche($cn,$_POST["f_id"]); - $fiche->remove(); - } - $fiche_def=new fiche_def($cn,$_GET['fiche']); - $fiche_def->myList(); - - echo "
"; - exit(); - } -//------------------------------------------------------------------------------ -// Add the data (attribute) of the card -if ( isset ($_POST["add_fiche"]) ) { - echo '
'; - - if ( $write ==0) - echo "

Pas d'accès

"; - else - { - $fiche=new fiche($cn); - $fiche->Save($_REQUEST['fiche']); - $fiche_def=new fiche_def($cn,$_GET['fiche']); - $fiche_def->myList(); - - - } - echo '
'; - exit(); -} -//------------------------------------------------------------------------------ -// Update a card -if ( isset ($_POST["update_fiche"]) ) { - echo '
'; - if ( $write ==0) - echo "

Pas d'accès

"; - else - { - $fiche=new fiche($cn,$_POST['f_id']); - $fiche->Save(); - - } - $fiche_def=new fiche_def($cn,$_GET['fiche']); - $fiche_def->myList(); - - - - - - echo '
'; -} -//--Search menu -if ( ! isset($_REQUEST['action']) ){ - echo '
'; - echo '
'; - $w=new widget('text'); - $search_text=(isset($_REQUEST['search_text']))?$_REQUEST['search_text']:""; - $h=new widget('hidden'); - echo $h->IOValue('action','search'); - echo "Recherche :".$w->IOValue('search_text',$search_text); - echo widget::submit('submit','Rechercher'); - echo '
'; - echo '
'; -} - html_page_stop(); -?> diff --git a/html/fiche_csv.php b/html/fiche_csv.php index 9ca0980dd..a9a0f22de 100644 --- a/html/fiche_csv.php +++ b/html/fiche_csv.php @@ -34,12 +34,11 @@ $gDossier=dossier::id(); if ( isset ($_REQUEST['with_amount'])) include_once("class_acc_account_ledger.php"); $cn=DbConnect($gDossier); -$rep=DbConnect(); require_once ('class_user.php'); -$User=new User($rep); +$User=new User($cn); $User->Check(); - -$User->can_request($cn,FICHE_READ); +$User->check_dossier($gDossier); +$User->can_request(IMPFIC,0); if ( isset ($_POST['fd_id'])) { diff --git a/html/fiche_new.php b/html/fiche_new.php index e23dff71f..667005d0d 100644 --- a/html/fiche_new.php +++ b/html/fiche_new.php @@ -33,19 +33,19 @@ require_once("class_fiche_def.php"); /* $Revision$ */ /* Admin. Dossier */ -$rep=DbConnect(); -include_once ("class_user.php"); -$User=new User($rep); -$User->Check(); +$gDossier=dossier::id(); +$cn=DbConnect($gDossier); +include_once ("class_user.php"); +$User=new User($cn); +$User->Check(); +$User->check_dossier($gDossier); html_min_page_start($User->theme,"onLoad='window.focus();'"); require_once('class_dossier.php'); -$gDossier=dossier::id(); -$cn=DbConnect($gDossier); // TODO add security here // Get The priv on the selected folder -if ( $User->check_action($cn,FICHE_WRITE)== 0) { +if ( $User->check_action(FICADD)== 0) { /* Cannot Access */ echo '

Vous ne pouvez pas ajouter de fiche

'; return; diff --git a/html/fiche_search.php b/html/fiche_search.php index 05722099a..2f48e7b25 100644 --- a/html/fiche_search.php +++ b/html/fiche_search.php @@ -20,17 +20,43 @@ /* $Revision$ */ /*! \file * \brief Search a card in a popup window + * + * This parameter given to this file via the javascript popup windows are + * caller = searchcard + * - first when is the first call it doesn't lookup directly + * - search + * - p_jrn the ledger id + * - PHPSESSID + * - type deb only the deb card from the ledger, cred means credit only, all the card, filter all the card of the ledger + * - name of the control + * - gDossier the dossier id + * -the caller (what jascript function triggers this window) + * caller = searchcardCtrl + * - first + * - searh + * - p_jrn the ledger id + * - PHPSESSID + * - type deb only the deb card from the ledger, cred means credit only, all the card, filter all the card of the ledger + * - name of the control + * - ctrl the second control to set up + * - gDossier the dossier id + * -the caller (what jascript function triggers this window) */ include_once ("ac_common.php"); include_once ("poste.php"); include_once ("postgres.php"); include_once("jrn.php"); -/* Admin. Dossier */ -$rep=DbConnect(); +require_once('class_dossier.php'); include_once ("class_user.php"); -$User=new User($rep); +// include_once ("check_priv.php"); +$gDossier=dossier::id(); +$cn=DbConnect($gDossier); + +$User=new User($cn); $User->Check(); +$User->check_dossier($gDossier); + echo JS_SEARCH_CARD; echo JS_MINTOOLKIT; //determine focus: @@ -44,18 +70,6 @@ if ( isset ( $_GET['search']) ) -require_once('class_dossier.php'); -$gDossier=dossier::id(); - -include_once ("check_priv.php"); -$cn=DbConnect($gDossier); -// Get The priv on the selected folder -if ( $User->check_action($cn,FICHE_READ) == 0 ){ - /* Cannot Access */ - echo '

Vous n\' avez pas accès

'; - return; -} - function get_list_fiche($p_cn,$get,$p_jrn) { $sql="select $get as fiche from jrn_def where jrn_def_id=$p_jrn"; @@ -82,23 +96,29 @@ function SetData (name_ctl,value,value_2,value_3,value_4,value_5,value_6) { self.opener.SetData(name_ctl,value,value_2,value_3,value_4,value_5,value_6); window.close(); } +function setCtrl(name_ctl,value,name_ctl2,value_3) { + self.opener.setCtrl(name_ctl,value,name_ctl2,value_3); + window.close(); + } javascript=sprintf("NewCard('%s','%s','%s')", - $_REQUEST['PHPSESSID'], - $_GET['type'], - "fic_search"); - $add_card->label="Ajout d'une fiche"; + if ( $User->check_action(FICADD)==1) { + $add_card=new widget('button'); + $add_card->javascript=sprintf("NewCard('%s','%s','%s')", + $_REQUEST['PHPSESSID'], + $_GET['type'], + "fic_search"); + $add_card->label="Ajout d'une fiche"; + } } foreach ($_GET as $key=>$element) { // The value are e_name e_type e_PHPSESSID ${"e_$key"}=$element; - echo_debug('fiche_search.php',__LINE__,"e_$key =$element
"); } $e_fic_search=(isset ($_REQUEST['fic_search']))?$_REQUEST['fic_search']:""; @@ -202,7 +222,7 @@ if ( $text=FormatString($row['vw_name']); $r.=""; $qcode= $row['quick_code'] ; - +if ( $e_caller=='searchcard') { $r.=sprintf ('', "select" . $i, $e_name, @@ -214,6 +234,16 @@ if ( $row['tva_label'] , $qcode ); + } else { + $r.=sprintf ('', + "select" . $i, + $e_name, + $row['quick_code'] , + $e_extra, + $text, + $row['quick_code'] + ); + } $r.=" ".h($row['vw_name']); if ( $row['vw_addr'] !="") $r.="
Adresse: ".h($row['vw_addr'])." ".h($row['vw_cp']).""; @@ -227,6 +257,6 @@ echo $r; ?> IOValue(); +if ( $_GET['p_jrn'] != 0 && $User->check_action(FICADD)==1)echo $add_card->IOValue(); html_page_stop(); ?> diff --git a/html/fid.php b/html/fid.php index 41c553b8f..e78d504e7 100644 --- a/html/fid.php +++ b/html/fid.php @@ -22,15 +22,26 @@ /*!\file * \brief Fid for the ajax request for cards + * + * Valid parameter GET are + * - d type = cred, deb, all or filter (see fiche_search.php') + * - j is the legdger + * - PHPSESSID + * - caller give you what is the caller + * - caller=searchcardCtrl : p_extra contains the control to update + * - caller =searchcard p_extra is not used + * - extra extra data, its meaning depends of the caller */ - +require_once('class_own.php'); require_once ("constant.php"); require_once ("postgres.php"); require_once ("user_common.php"); require_once ("debug.php"); require_once('class_dossier.php'); $gDossier=dossier::id(); +$caller=$_GET['caller']; +$extra=$_GET['extra']; echo_debug('fid.php',__LINE__,"Recherche fid.php".$_GET["FID"]); $cn=DbConnect($gDossier); @@ -71,7 +82,12 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) $array=get_array($cn,$sql, array($_GET['FID'])); echo_debug("fid",__LINE__,$array); + /* Different behaviour depending of the caller */ + if ( strcmp($caller,'searchcardCtrl') === 0 ){ + $name=$array[0]['vw_name']; + } else $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']; @@ -82,7 +98,9 @@ if ( isset($_SESSION['isValid']) && $_SESSION['isValid'] == 1) $buy=($buy==null)?" ":str_replace('"','',$buy); $tva_id=($tva_id==null)?" ":str_replace('"','',$tva_id); - $a='{"answer":"ok","name":"'.$name.'","sell":"'.$sell.'","buy":"'.$buy.'","tva_id":"'.$tva_id.'","ctl":"'.$_GET['ctl'].'"}'; + + + $a='{"answer":"ok","name":"'.$name.'","sell":"'.$sell.'","buy":"'.$buy.'","tva_id":"'.$tva_id.'","ctl":"'.$_GET['ctl'].'","caller":"'.$caller.'","extra":"'.$extra.'"}'; } else diff --git a/html/get_pj.php b/html/get_pj.php new file mode 100644 index 000000000..09aa5d226 --- /dev/null +++ b/html/get_pj.php @@ -0,0 +1,57 @@ +get_propertie(); +$pj_pref=$prop["jrn_def_pj_pref"]; +$pj_seq=$Ledger->get_last_pj(); +$string='{"pj":"'.$pj_pref.$pj_seq.'"}'; + +header("Content-type: text/json; charset: utf8",true); +echo $string; + + +?> + diff --git a/html/import.php b/html/import.php index d898b8248..bb349456e 100644 --- a/html/import.php +++ b/html/import.php @@ -1,27 +1,27 @@ Check(); +$User->check_dossier(dossier::id()); html_page_start($User->theme); echo JS_PROTOTYPE; @@ -53,24 +54,24 @@ echo '
'; echo ShowMenuAdvanced(7); -$User->can_request($cn,IMP_BQE); +$User->can_request(GEBQ,1); echo JS_AJAX_FICHE; echo ''; if ( isset( $_REQUEST['PHPSESSID'])) { - $sessid = $_REQUEST['PHPSESSID']; + $sessid = $_REQUEST['PHPSESSID']; } // if action is set proceed to it if ( isset ($_GET["action"]) ) { $action=$_GET["action"]; -// menu = import cvs + // menu = import cvs if ($action == "import" ) { if(isset($_FILES['fupload'])) { - // load the table with the cvs' content + // load the table with the cvs' content echo '
'; ImportCSV($cn,$_FILES['fupload']['tmp_name'],$_POST['import_bq'],$_POST['format_csv'],$_POST['import_jrn']); echo "
"; diff --git a/html/index.php b/html/index.php index aa9256a1d..45cad9f8d 100644 --- a/html/index.php +++ b/html/index.php @@ -19,7 +19,10 @@ *
  • Documenter avec les tags doxygen votre nouveau code,
  • *
  • Dans le répertoire include: Les noms de fichiers sont *.inc.php pour les fichiers à éxécuter
  • *
  • Dans le répertoire include: Les noms de fichiers sont *.php pour les fichiers contenant des fonctions uniquement
  • - *
  • Dans le répertoire include: Les noms de fichier sont class_*.php pour les fichiers contenant des classes.
  • + *
  • Dans le répertoire include: Les noms de fichier sont + * class_*.php pour les fichiers contenant des classes.
  • + *
  • Dans le répertoire include/template: les fichiers de + * présentation HTML
  • *
  • Utiliser sql/upgrade.sql comme fichier temporaire pour modifier la base de données, en général * ce fichier deviendra l'un des patch
  • *
  • Faire de la doc
  • diff --git a/html/jrn_csv.php b/html/jrn_csv.php index aed02bc4d..9c690a9e8 100644 --- a/html/jrn_csv.php +++ b/html/jrn_csv.php @@ -25,6 +25,7 @@ header('Content-type: application/csv'); header('Content-Disposition: attachment;filename="jrn.csv"',FALSE); include_once ("ac_common.php"); +require_once('class_own.php'); require_once('class_dossier.php'); $gDossier=dossier::id(); @@ -33,24 +34,24 @@ include_once ("postgres.php"); include_once("check_priv.php"); require_once("class_acc_ledger.php"); $cn=DbConnect($gDossier); -$rep=DbConnect(); + require_once ('class_user.php'); -$User=new User($rep); +$User=new User($cn); $User->Check(); -if ( $User->check_action($cn,IMP) == 0 || - $User->AccessJrn($cn,$_GET['jrn_id']) == false){ - /* Cannot Access */ - NoAccess(); - } +$User->can_request(IMPJRN,0); +$User->check_dossier($gDossier); +if ($_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) =='X') { + NoAccess(); exit();} - $p_cent=( isset ( $_GET['central']) )?$_GET['central']:'off'; +$p_cent=( isset ( $_GET['central']) )?$_GET['central']:'off'; $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); $Jrn->get_name(); $jrn_type=$Jrn->get_type(); + // Detailled printing //--- if ( $_GET['p_simple'] == 0 ) @@ -140,12 +141,16 @@ if ( $_GET['p_simple'] == 0 ) //----------------------------------------------------- if ( $jrn_type=='ACH' || $jrn_type=='VEN') { - $a_Tva=get_array($cn,"select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate"); + $own=new Own($cn); $col_tva=""; - foreach($a_Tva as $line_tva) - { - $col_tva.='"Tva '.$line_tva['tva_label'].'";'; - } + + if ( $own->MY_TVA_USE=='Y') { + $a_Tva=get_array($cn,"select tva_id,tva_label from tva_rate where tva_rate != 0.0000 order by tva_rate"); + foreach($a_Tva as $line_tva) + { + $col_tva.='"Tva '.$line_tva['tva_label'].'";'; + } + } echo '"Date";"operation";"Client/Fourn.";"Commentaire";"inter.";"HTVA";'.$col_tva.'"TVAC"'."\n\r"; foreach ($Row as $line) { @@ -169,16 +174,16 @@ if ( $_GET['p_simple'] == 0 ) } } } - - foreach ($a_Tva as $line_tva) - { - $a=$line_tva['tva_id']; - if ( isset($a_tva_amount[$a])) - printf("% 8.2f;",$a_tva_amount[$a]); - else - printf("0;"); - } - + if ($own->MY_TVA_USE == 'Y' ) { + foreach ($a_Tva as $line_tva) + { + $a=$line_tva['tva_id']; + if ( isset($a_tva_amount[$a])) + printf("% 8.2f;",$a_tva_amount[$a]); + else + printf("0;"); + } + } printf("% 9.2f\r\n",$line['TVAC']); } } diff --git a/html/jrn_pdf.php b/html/jrn_pdf.php index 9fa9ea40f..89b643006 100644 --- a/html/jrn_pdf.php +++ b/html/jrn_pdf.php @@ -41,12 +41,16 @@ include_once("preference.php"); include_once("class_acc_ledger.php"); include_once("check_priv.php"); require_once ('header_print.php'); +require_once('class_own.php'); + echo_debug('jrn_pdf.php',__LINE__,"imp pdf journaux"); $cn=DbConnect($gDossier); $l_type="JRN"; $centr=" Non centralisé"; $l_centr=0; +$own=new Own($cn); + if ($_GET['central'] == 'on' ) { $centr=utf8_decode(" centralisé "); $l_centr=1; @@ -54,12 +58,13 @@ if ($_GET['central'] == 'on' ) { $Jrn=new Acc_Ledger($cn,$_GET['jrn_id']); $Jrn->get_name(); -$User=new User(DbConnect()); +$User=new User($cn); $User->Check(); +$User->check_dossier($gDossier); +$User->can_request(IMPJRN,0); // Security -if ($User->check_action($cn,IMP) == 0 || - $User->AccessJrn($cn,$_GET['jrn_id']) == false){ +if ( $_GET['jrn_id']!=0 && $User->check_jrn($_GET['jrn_id']) == 'X' ){ /* Cannot Access */ NoAccess(); } @@ -180,131 +185,201 @@ if ( $Jrn->id==0 || $jrn_type=='FIN' || $jrn_type=='ODS' || $_REQUEST['p_simple //--------------------------------------------------------------------- if ( ($jrn_type=='ACH' || $jrn_type=='VEN' ) && $_REQUEST['p_simple']== 1 ) { + /* simple printing with vat */ + if ( $own->MY_TVA_USE=='Y') { + echo_debug ('jrn_pdf',__LINE__,'here'); + echo_debug('jrn_pdf',__LINE__,$Jrn); + $pdf= new Cezpdf("A4",'landscape'); + // $pdf->selectFont('./addon/fonts/Helvetica.afm'); + $pdf->selectFont('./addon/fonts/Courier.afm'); + header_pdf($cn,$pdf); - echo_debug ('jrn_pdf',__LINE__,'here'); - echo_debug('jrn_pdf',__LINE__,$Jrn); - $pdf= new Cezpdf("A4",'landscape'); - // $pdf->selectFont('./addon/fonts/Helvetica.afm'); - $pdf->selectFont('./addon/fonts/Courier.afm'); - header_pdf($cn,$pdf); - - $offset=0;$limit=30;$step=30; - $a_Tva=get_array($cn,"select tva_id,tva_label,tva_poste from tva_rate where tva_rate != 0.0000 order by tva_id"); - $col_tva="TVA "; - $space=0; - $total_HTVA=0.0; - $total_TVAC=0.0; - foreach($a_Tva as $line_tva) - { - //initialize Amount TVA - $tmp1=$line_tva['tva_label']; - $rap_tva[$tmp1]=0.0; - if ( $space == 0 ) - $col_tva=str_repeat(" ",6).utf8_decode($line_tva['tva_label']); - else { - $ecart=$space-strlen($line_tva['tva_label']); - $ecart=($ecart<0)?0:$ecart; - $col_tva.=str_repeat(" ",$ecart).utf8_decode($line_tva['tva_label']); - } - $space=9; - } - - // if the period is centralized get the first amounts - if ( $l_centr==1) - list($total_TVAC,$total_HTVA)=get_rappel_simple($cn,$Jrn->id,$jrn_type,$_GET['from_periode'],$rap_tva); - - - - while (1) { - - $a=0; - $a_jrn=$Jrn->get_rowSimple($_GET['from_periode'], - $_GET['to_periode'], - $_GET['central'], - 1, - $limit, - $offset); - if ( $a_jrn == null ) break; - - // page Header - $t=sprintf("Rappel TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA); - foreach($rap_tva as $idx=>$am) { - $t.=utf8_decode(sprintf('[ %s = % .2f]',$idx,$am)); - } - $pdf->ezText($t,9,array('justification'=>'left')); - - $offset+=$step; - //total page - $total_htva_page=0.0;$total_tvac_page=0.0; + $offset=0;$limit=30;$step=30; + $a_Tva=get_array($cn,"select tva_id,tva_label,tva_poste from tva_rate where tva_rate != 0.0000 order by tva_id"); + $col_tva="TVA "; + $space=0; + $total_HTVA=0.0; + $total_TVAC=0.0; foreach($a_Tva as $line_tva) { //initialize Amount TVA $tmp1=$line_tva['tva_label']; - $page_tva[$tmp1]=0.0; + $rap_tva[$tmp1]=0.0; + if ( $space == 0 ) + $col_tva=str_repeat(" ",6).utf8_decode($line_tva['tva_label']); + else { + $ecart=$space-strlen($line_tva['tva_label']); + $ecart=($ecart<0)?0:$ecart; + $col_tva.=str_repeat(" ",$ecart).utf8_decode($line_tva['tva_label']); + } + $space=9; + } + + // if the period is centralized get the first amounts + if ( $l_centr==1) + list($total_TVAC,$total_HTVA)=get_rappel_simple($cn,$Jrn->id,$jrn_type,$_GET['from_periode'],$rap_tva); + + + + while (1) { + + $a=0; + $a_jrn=$Jrn->get_rowSimple($_GET['from_periode'], + $_GET['to_periode'], + $_GET['central'], + 1, + $limit, + $offset); + if ( $a_jrn == null ) break; + + // page Header + $t=sprintf("Rappel TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA); + foreach($rap_tva as $idx=>$am) { + $t.=utf8_decode(sprintf('[ %s = % .2f]',$idx,$am)); } - $str_tva=""; + $pdf->ezText($t,9,array('justification'=>'left')); + + $offset+=$step; + //total page + $total_htva_page=0.0;$total_tvac_page=0.0; + foreach($a_Tva as $line_tva) + { + //initialize Amount TVA + $tmp1=$line_tva['tva_label']; + $page_tva[$tmp1]=0.0; + } + $str_tva=""; - $pdf->ezTable($a_jrn, - array('num'=>utf8_decode('Numéro'), - 'date'=>'Date', - 'client'=>'Client', - 'jr_internal'=>'Int.', - 'comment'=>'Description', - 'HTVA'=>'HTVA', - 'TVA_INLINE'=>$col_tva, - 'TVAC'=>'TVAC'), - utf8_decode($Jrn->name), - array('shaded'=>0,'showHeadings'=>1,'fontSize'=>8,'width'=>750,'Maxwidth'=>750), - true + $pdf->ezTable($a_jrn, + array('num'=>utf8_decode('Numéro'), + 'date'=>'Date', + 'jr_internal'=>'Int.', + 'client'=>'Client', + 'comment'=>'Description', + 'HTVA'=>'HTVA', + 'TVA_INLINE'=>$col_tva, + 'TVAC'=>'TVAC'), + utf8_decode($Jrn->name), + array('shaded'=>0,'showHeadings'=>1,'fontSize'=>8,'width'=>750,'Maxwidth'=>750), + true - ); - //-------------------------------------------------------------------------------- - // Foot - // Set total foot page - // amount VAT - foreach ($a_jrn as $row) - { - $total_TVAC+=$row['TVAC']; - $total_HTVA+=$row['HTVA']; - $total_tvac_page+=$row['TVAC']; - $total_htva_page+=$row['HTVA']; + ); + //-------------------------------------------------------------------------------- + // Foot + // Set total foot page + // amount VAT + foreach ($a_jrn as $row) + { + $total_TVAC+=$row['TVAC']; + $total_HTVA+=$row['HTVA']; + $total_tvac_page+=$row['TVAC']; + $total_htva_page+=$row['HTVA']; - foreach ($row['TVA'] as $line) - { - $tva_id=$line[1][1]; - $rap_tva[$tva_id]+=$line[1][2]; - $page_tva[$tva_id]+=$line[1][2]; - } + foreach ($row['TVA'] as $line) + { + $tva_id=$line[1][1]; + $rap_tva[$tva_id]+=$line[1][2]; + $page_tva[$tva_id]+=$line[1][2]; + } + } + //total page + $t=sprintf("total page TVAC = %.2f HTVA= %.2f",$total_tvac_page,$total_htva_page); + foreach($page_tva as $idx=>$am) { + $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); } - //total page - $t=sprintf("total page TVAC = %.2f HTVA= %.2f",$total_tvac_page,$total_htva_page); - foreach($page_tva as $idx=>$am) { - $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); + $pdf->ezText($t,9,array('justification'=>'left')); + + $t=utf8_decode(sprintf("total à reporter TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA)); + foreach($rap_tva as $idx=>$am) { + $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); + } + $pdf->ezText($t,9,array('justification'=>'left')); + + // New Page + $pdf->ezNewPage(); + header_pdf($cn,$pdf); + echo_debug('jrn_pdf',__LINE__,$a_jrn); } - $pdf->ezText($t,9,array('justification'=>'left')); + } else { /* we do not use any vat */ - $t=utf8_decode(sprintf("total à reporter TVAC = %.2f HTVA= %.2f",$total_TVAC,$total_HTVA)); - foreach($rap_tva as $idx=>$am) { - $t.=utf8_decode(sprintf('[ %s = % .2f ]',$idx,$am)); + $pdf= new Cezpdf("A4",'landscape'); + // $pdf->selectFont('./addon/fonts/Helvetica.afm'); + $pdf->selectFont('./addon/fonts/Courier.afm'); + header_pdf($cn,$pdf); + + $offset=0;$limit=30;$step=30; + $space=0; + $total_HTVA=0.0; + $total_TVAC=0.0; + + if ( $l_centr==1) + list($total_TVAC,$total_HTVA)=get_rappel_simple($cn,$Jrn->id,$jrn_type,$_GET['from_periode'],$rap_tva); + + + while (1) { + + $a=0; + $a_jrn=$Jrn->get_rowSimple($_GET['from_periode'], + $_GET['to_periode'], + $_GET['central'], + 1, + $limit, + $offset); + if ( $a_jrn == null ) break; + // page Header + $t=sprintf("Rappel Total = %.2f ",$total_TVAC); + + $pdf->ezText($t,9,array('justification'=>'left')); + + $offset+=$step; + //total page + $total_htva_page=0.0;$total_tvac_page=0.0; + + + $pdf->ezTable($a_jrn, + array('num'=>utf8_decode('Numéro'), + 'date'=>'Date', + 'client'=>'Client', + 'jr_internal'=>'Int.', + 'comment'=>'Description', + 'TVAC'=>'Total'), + utf8_decode($Jrn->name), + array('shaded'=>0,'showHeadings'=>1,'fontSize'=>8,'width'=>750,'Maxwidth'=>750), + true + + + + ); + //-------------------------------------------------------------------------------- + // Foot + // Set total foot page + // amount VAT + foreach ($a_jrn as $row) + { + $total_TVAC+=$row['TVAC']; + $total_tvac_page+=$row['TVAC']; + + } + //total page + $t=sprintf("total page = %.2f ",$total_tvac_page); + + $pdf->ezText($t,9,array('justification'=>'left')); + + $t=utf8_decode(sprintf("total à reporter = %.2f ",$total_TVAC)); + + $pdf->ezText($t,9,array('justification'=>'left')); + + // New Page + $pdf->ezNewPage(); + header_pdf($cn,$pdf); + echo_debug('jrn_pdf',__LINE__,$a_jrn); } - $pdf->ezText($t,9,array('justification'=>'left')); - // New Page - $pdf->ezNewPage(); - header_pdf($cn,$pdf); - - - - - - - - echo_debug('jrn_pdf',__LINE__,$a_jrn); - } - echo_debug('jrn_pdf',__LINE__,'Envoie PDF'); + } /* else */ + $pdf->ezStream(); exit(0); diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index 077754635..871b39eb1 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -44,6 +44,7 @@ function clean_Fid(p_ctl) if ( $(nSell) ) { $(nSell).value=""; } if ( $(nBuy) ) { $(nBuy).value="";} if ( $(nTva_id) ) { $(nTva_id).value="-1"; } + if ( $("first_sold")) { $("first_sold").value=""; } } function errorFid(request,json) { @@ -54,8 +55,10 @@ function errorFid(request,json) { * \param p_deb if debit of credit * \param p_jrn the ledger * \param phpsessid + *\param p_caller id of the caller + *\param p_extra extra parameter, change depends of the caller */ -function ajaxFid(p_ctl,p_deb,phpsessid) +function ajaxFid(p_ctl,p_deb,phpsessid,p_caller,p_extra) { var gDossier=$('gDossier').value; var ctl_value=trim($(p_ctl).value); @@ -63,7 +66,7 @@ function ajaxFid(p_ctl,p_deb,phpsessid) var p_jrn=$('p_jrn').value; if ( trim(ctl_value)==0 ) { nLabel=p_ctl+"_label"; - $(nLabel).value=""; + if ($(nLabel) ){$(nLabel).value="";} $(nLabel).innerHTML=" "; clean_Fid(p_ctl); return; @@ -71,6 +74,7 @@ function ajaxFid(p_ctl,p_deb,phpsessid) queryString="?FID="+ctl_value; queryString=queryString+"&d="+p_deb+"&j="+p_jrn+'&gDossier='+gDossier; queryString=queryString+'&ctl='+p_ctl+'&PHPSESSID='+phpsessid; + queryString=queryString+'&caller='+p_caller+'&extra='+p_extra; /* alert(queryString); */ var action=new Ajax.Request ( "fid.php", @@ -95,12 +99,20 @@ function successFid(request,json) { var buy=answer.buy; var tva_id=answer.tva_id; var ctl=answer.ctl; + var extra=answer.extra; + var caller=answer.caller; + if ( caller == 'searchcardControl') { + if ( trim (data)== "") { $(ctl).style.color="red";} + else { $(ctl).style.color="black"; $(extra).value=data;} + } var toSet=ctl+'_label'; if (trim(data) == "" ) { $(toSet).innerHTML="Fiche Inconnue"; $(toSet).style.color="red"; clean_Fid(ctl); + $(ctl).style.color="red"; } else { + $(ctl).style.color="black"; var nSell=ctl+"_price"; var nBuy=ctl+"_price"; var nTva_id=ctl+"_tva_id"; @@ -109,11 +121,48 @@ function successFid(request,json) { if ( $(nTva_id) ) { $(nTva_id).value=tva_id; } - if ( $(nSell ) ) { + if ( $(nSell ) && trim(sell)!="" ) { $(nSell).value=sell; } - if ( $(nBuy) ) $(nBuy).value=buy; + if ( $(nBuy) && trim(buy)!="") { $(nBuy).value=buy; } } + +} +function ajax_error_saldo(request,json) { + alert('erreur : ajax fiche'); +} +/*!\brief this function get the saldo + * \param p_ctl the ctrl where we take the quick_code + * \param phpsessid + */ +function ajax_saldo(phpsessid,p_ctl) +{ + var gDossier=$('gDossier').value; + var ctl_value=trim($(p_ctl).value); + var jrn=$('p_jrn').value; + queryString="?FID="+ctl_value; + queryString=queryString+'&gDossier='+gDossier+'&j='+jrn; + queryString=queryString+'&ctl='+ctl_value+'&PHPSESSID='+phpsessid; + /* alert(queryString); */ + var action=new Ajax.Request ( + "get_saldo.php", + { + method:'get', + parameters:queryString, + onFailure:ajax_error_saldo, + onSuccess:ajax_success_saldo + } + + ); + +} +/*!\brief callback function for ajax + * \param request : object request + * \param json : json answer */ +function ajax_success_saldo(request,json) { + var answer=request.responseText.evalJSON(true); + $('first_sold').value=answer.saldo; + } //--> diff --git a/html/js/scripts.js b/html/js/scripts.js index b9a226d28..89d0e9a6f 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -415,7 +415,9 @@ function compute_sold(p_ctl_nb) { refresh_sold(); return; } - var tva_id=$('e_march'+p_ctl_nb+'_tva_id').value; + var tva_id=-1; + if ($('e_march'+p_ctl_nb+'_tva_id')) tva_id=$('e_march'+p_ctl_nb+'_tva_id').value; + $('e_march'+p_ctl_nb+'_price').value=trim($('e_march'+p_ctl_nb+'_price').value); var price=$('e_march'+p_ctl_nb+'_price').value; @@ -438,32 +440,31 @@ function refresh_sold () { var tva=0; var htva=0;var tvac=0; for (var i=0;i<$("nb_item").value;i++) { - tva+=$('tva_march'+i).value*1; - htva+=$('htva_march'+i).value*1; - tvac+=$('tvac_march'+i).value*1; - $('tva_march'+i+'_show').value=$('tva_march'+i).value; + if ( $('tva_march'+i) ) tva+=$('tva_march'+i).value*1; + if ($('htva_march'+i)) htva+=$('htva_march'+i).value*1; + if ($('tvac_march'+i)) tvac+=$('tvac_march'+i).value*1; + if ($('tva_march'+i+'_show')) $('tva_march'+i+'_show').value=$('tva_march'+i).value; } - $('tva').innerHTML=Math.round(tva*100)/100; - $('htva').innerHTML=Math.round(htva*100)/100; - $('tvac').innerHTML=Math.round(tvac*100)/100; + if ( $('tva')) $('tva').innerHTML=Math.round(tva*100)/100; + if ( $('htva')) $('htva').innerHTML=Math.round(htva*100)/100; + if ($('tvac')) $('tvac').innerHTML=Math.round(tvac*100)/100; } /** * @brief update the field htva, tva_id and tvac, callback function for compute_sold */ function success_compute_sold(request,json) { - - var answer=request.responseText.evalJSON(true); - var rtva=answer.tva*1; - var rhtva=answer.htva*1; - var rtvac=answer.tvac*1; - var ctl=answer.ctl; - $('sum').show(); - $('tva_march'+ctl).value=rtva; - $('htva_march'+ctl).value=rhtva; - $('tvac_march'+ctl).value=rtvac; - refresh_sold(); + var answer=request.responseText.evalJSON(true); + var rtva=answer.tva*1; + var rhtva=answer.htva*1; + var rtvac=answer.tvac*1; + var ctl=answer.ctl; + $('sum').show(); + if($('tva_march'+ctl)) $('tva_march'+ctl).value=rtva; + if($('htva_march'+ctl)) $('htva_march'+ctl).value=rhtva; + if ($('tvac_march'+ctl)) $('tvac_march'+ctl).value=rtvac; + refresh_sold(); } /** @@ -515,6 +516,43 @@ function error_get_predef(request,json) { alert ("Erreur mise à jour champs non possible"); } +/** +* @brief update the list of available predefined operation when we change the ledger. +*/ +function update_pj() { + var jrn=$("p_jrn").value; + var phpsessid=$("phpsessid").value; + var dossier=$("gDossier").value; + var querystring='?PHPSESSID='+phpsessid+'&gDossier='+dossier+'&l='+jrn; + var action=new Ajax.Request( + "get_pj.php", + { + method:'get', + parameters:querystring, + onFailure:error_get_pj, + onSuccess:success_get_pj + } + ); +} +/** + * @brief update the field predef + */ +function success_get_pj(request,json) { + + var answer=request.responseText.evalJSON(true); + obj=$("e_pj"); + obj.value=''; + if ( answer.count == 0 ) return; + obj.value=answer.pj; + $("e_pj_suggest").value=answer.pj; +} +/** + * @brief update the field predef + */ +function error_get_pj(request,json) { + alert("Ajax a echoue"); +} + /** * @brief add a line in the form for the ledger fin */ @@ -545,24 +583,24 @@ function ledger_fin_add_row(){ * @brief add a line in the form for the purchase ledger */ function ledger_purchase_add_row(){ - style='class="input_text"'; - var mytable=$("sold_item").tBodies[0]; - var line=mytable.rows.length; - var row=mytable.insertRow(line); - var phpsessid=$("phpsessid"); - var nb=$("nb_item"); - var newNode = mytable.rows[1].cloneNode(true); - var tt=newNode.innerHTML; - mytable.appendChild(newNode); - new_tt=tt.replace(/march0/g,"march"+nb.value); - new_tt=new_tt.replace(/quant0/g,"quant"+nb.value); - new_tt=new_tt.replace(/sold\(0\)/g,"sold("+nb.value+")"); - newNode.innerHTML=new_tt; - $("e_march"+nb.value+"_label").innerHTML=' '; - $("e_march"+nb.value+"_price").value='0'; - $("e_march"+nb.value).value=""; - $("e_quant"+nb.value).value="1"; - nb.value++; + style='class="input_text"'; + var mytable=$("sold_item").tBodies[0]; + var line=mytable.rows.length; + var row=mytable.insertRow(line); + var phpsessid=$("phpsessid"); + var nb=$("nb_item"); + var newNode = mytable.rows[1].cloneNode(true); + var tt=newNode.innerHTML; + mytable.appendChild(newNode); + new_tt=tt.replace(/march0/g,"march"+nb.value); + new_tt=new_tt.replace(/quant0/g,"quant"+nb.value); + new_tt=new_tt.replace(/sold\(0\)/g,"sold("+nb.value+")"); + newNode.innerHTML=new_tt; + $("e_march"+nb.value+"_label").innerHTML=' '; + $("e_march"+nb.value+"_price").value='0'; + $("e_march"+nb.value).value=""; + $("e_quant"+nb.value).value="1"; + nb.value++; } /** @@ -573,15 +611,19 @@ function ledger_purchase_add_row(){ function compute_purchase(p_ctl_nb) { var phpsessid=$("phpsessid").value; var dossier=$("gDossier").value; - var a=trim($("e_march"+p_ctl_nb+'_tva_amount').value); - $("e_march"+p_ctl_nb+'_tva_amount').value=a; - + var a=-1; + if ( document.getElementById("e_march"+p_ctl_nb+'_tva_amount')) { + a=trim($("e_march"+p_ctl_nb+'_tva_amount').value); + $("e_march"+p_ctl_nb+'_tva_amount').value=a; + } $("e_march"+p_ctl_nb).value=trim($("e_march"+p_ctl_nb).value); var qcode=$("e_march"+p_ctl_nb).value; if ( qcode.length == 0 ) { clean_purchase(p_ctl_nb);refresh_purchase();return;} - - var tva_id=$('e_march'+p_ctl_nb+'_tva_id').value; + var tva_id=-1; + if ( $('e_march'+p_ctl_nb+'_tva_id') ) { + tva_id=$('e_march'+p_ctl_nb+'_tva_id').value; + } $('e_march'+p_ctl_nb+'_price').value=trim($('e_march'+p_ctl_nb+'_price').value); var price=$('e_march'+p_ctl_nb+'_price').value; @@ -604,36 +646,52 @@ function refresh_purchase() { var tva=0; var htva=0;var tvac=0; for (var i=0;i<$("nb_item").value;i++) { - tva+=$('tva_march'+i).value*1; + if( $('tva_march'+i)) tva+=$('tva_march'+i).value*1; htva+=$('htva_march'+i).value*1; tvac+=$('tvac_march'+i).value*1; } - $('tva').innerHTML=Math.round(tva*100)/100; + if ( $('tva') ) $('tva').innerHTML=Math.round(tva*100)/100; $('htva').innerHTML=Math.round(htva*100)/100; - $('tvac').innerHTML=Math.round(tvac*100)/100; + if ($('tvac')) $('tvac').innerHTML=Math.round(tvac*100)/100; } /** * @brief update the field htva, tva_id and tvac, callback function for compute_sold + * it the field TVA in the answer contains NA it means that VAT is appliable and then do not + * update the VAT field except htva_martc */ function success_compute_purchase(request,json) { var answer=request.responseText.evalJSON(true); - var rtva=answer.tva*1; + var ctl=answer.ctl; + var rtva=answer.tva; var rhtva=answer.htva*1; var rtvac=answer.tvac*1; - var ctl=answer.ctl; - $('sum').show(); - if ( $('e_march'+ctl+'_tva_amount').value=="" || $('e_march'+ctl+'_tva_amount').value==0 ){ - $('tva_march'+ctl).value=rtva; - $('e_march'+ctl+'_tva_amount').value=rtva; - } - else { - $('tva_march'+ctl).value=$('e_march'+ctl+'_tva_amount').value; - } - $('htva_march'+ctl).value=rhtva; - $('tvac_march'+ctl).value=parseFloat($('htva_march'+ctl).value)+parseFloat($('tva_march'+ctl).value); + if ( rtva == 'NA' ) { + var rhtva=answer.htva*1; + $('htva_march'+ctl).value=rhtva; + $('tvac_march'+ctl).value=rtvac; + $('sum').show(); + refresh_purchase(); + + return; + } + rtva=answer.tva*1; + + + + $('sum').show(); + if ( $('e_march'+ctl+'_tva_amount').value=="" || $('e_march'+ctl+'_tva_amount').value==0 ){ + $('tva_march'+ctl).value=rtva; + $('e_march'+ctl+'_tva_amount').value=rtva; + } + else { + $('tva_march'+ctl).value=$('e_march'+ctl+'_tva_amount').value; + } + $('htva_march'+ctl).value=rhtva; + $('tvac_march'+ctl).value=parseFloat($('htva_march'+ctl).value)+parseFloat($('tva_march'+ctl).value); + refresh_purchase(); } @@ -651,20 +709,20 @@ function compute_all_purchase() { var tva=0; var htva=0;var tvac=0; for (var i=0;i<$("nb_item").value;i++) { - tva+=$('tva_march'+i).value*1; + if ( $('tva_march') ) tva+=$('tva_march'+i).value*1; htva+=$('htva_march'+i).value*1; tvac+=$('tvac_march'+i).value*1; } - $('tva').innerHTML=Math.round(tva*100)/100; + if ( $('tva') ) $('tva').innerHTML=Math.round(tva*100)/100; $('htva').innerHTML=Math.round(htva*100)/100; - $('tvac').innerHTML=Math.round(tvac*100)/100; + if ($('tvac'))$('tvac').innerHTML=Math.round(tvac*100)/100; } function clean_tva(p_ctl) { -$('e_march'+p_ctl+'_tva_amount').value=0; +if ( $('e_march'+p_ctl+'_tva_amount') )$('e_march'+p_ctl+'_tva_amount').value=0; } function clean_sold( p_ctl_nb) @@ -682,10 +740,10 @@ function clean_purchase(p_ctl_nb) { var qcode=$("e_march"+p_ctl_nb).value; $('e_march'+p_ctl_nb+'_price').value=''; $('e_quant'+p_ctl_nb).value='1'; - $('e_march'+p_ctl_nb+'_tva_amount').value='0'; - $('tva_march'+p_ctl_nb).value=0; - $('htva_march'+p_ctl_nb).value=0; - $('tvac_march'+p_ctl_nb).value=0; + if ( $('e_march'+p_ctl_nb+'_tva_amount') )$('e_march'+p_ctl_nb+'_tva_amount').value='0'; + if ( $('tva_march'+p_ctl_nb)) $('tva_march'+p_ctl_nb).value=0; + if ($('htva_march'+p_ctl_nb)) $('htva_march'+p_ctl_nb).value=0; + if( $('tvac_march'+p_ctl_nb)) $('tvac_march'+p_ctl_nb).value=0; } /** * @brief add a line in the form for the quick_writing @@ -715,9 +773,14 @@ function quick_writing_add_row(){ $("amount"+nb.value).value=''; $("poste"+nb.value).value=''; $("ld"+nb.value).value=''; - $('qc_'+nb.value+'_label').innerHTML=''; - $('poste'+nb.value+'_label').innerHTML=''; - + nb.value++; } +function my_clear(p_ctrl) { + if ( document.getElementById(p_ctrl)){ + document.getElementById(p_ctrl).value=""; + } +} + + diff --git a/html/js/search_card.js b/html/js/search_card.js index 8ed75596c..11796f52b 100644 --- a/html/js/search_card.js +++ b/html/js/search_card.js @@ -21,32 +21,51 @@ /*! \file * \brief - * open a windows for searching a card + * + */ +/*!\brief open a windows for showing a card +* \param p_sessid must be given +* \param the qcode +*\todo is obsolete ?? */ - function showfiche(p_sessid,p_qcode) { p_dossier=document.getElementById("gDossier").value; var a=window.open('show_fiche.php?PHPSESSID='+p_sessid+'&gDossier='+p_dossier+'&q='+p_qcode,'','toolbar=no,width=350,height=450,scrollbar=yes,statusbar=no'); a.focus(); } - -/* type must be cred or deb and name is - * the control's name +/*!\brief Open a window for searching a card +* +* Remark The ledger (jrn_id) must be in the calling form as a hidden field named p_jrn +*\param p_sessid is the PHPSESSID +*\param type must be deb or cred +*\param name is the name of the control, it is used for computing the name of the VAT, Price field +* \see SetData() */ function SearchCard(p_sessid,type,name) { - var search=document.getElementById(name).value; var gDossier=document.getElementById('gDossier').value; var jrn=0; if ( document.getElementById("p_jrn") ) { jrn=document.getElementById("p_jrn").value; } - var a=window.open('fiche_search.php?first&search&fic_search='+search+'&p_jrn='+jrn+'&PHPSESSID='+p_sessid+'&type='+type+'&name='+name+'&gDossier='+gDossier,'item','toolbar=no,width=350,height=450,scrollbars=yes,statusbar=no'); + var file='fiche_search.php'; +var +query='?first&search&fic_search='+search+'&p_jrn='+jrn+'&PHPSESSID='+p_sessid ++'&type='+type+'&name='+name+'&gDossier='+gDossier; + query+="&caller=searchcard"; + var a=window.open(file+query,'item','toolbar=no,width=350,height=450,scrollbars=yes,statusbar=no'); a.focus(); return false; } +/*!\brief Open a window for adding a card +* +* Remark The ledger (jrn_id) must be in the calling form as a hidden field named p_jrn +*\param p_sessid is the PHPSESSID +*\param type must be deb or cred +*\param name is the name of the control, it is used for computing the name of the VAT, Price field +*/ function NewCard(p_sessid,type,name) { var search=document.getElementById(name).value; @@ -56,9 +75,9 @@ function NewCard(p_sessid,type,name) return false; } -/* SetValue( p_ctl,p_value ) -/* p_ctl is the name of the control -/* p_value is the value to set in +/*!brief set the value of a ctrl + *\param p_ctl control to change + *\param p_value value to set (only) */ function SetValue(p_ctl,p_value) { @@ -70,14 +89,17 @@ function SetValue(p_ctl,p_value) } -/* Parameters - * i = ctl _name - * p_id = code id (fiche.f_id) - *¨p_label = label - * p_price vw_fiche_attr.vw_price - * p_price vw_fiche_attr.vw_price - * p_tva_id vw_fiche_attr.tva_id - * p_tva_label vw_fiche_attr.tva_label +/*!\brief Set the data from the child window to the parent one +* +* Set the data found during the search (tva_id, price, tva_label) to the form, the name are based on i. +* The url contains the caller (searchcard).This function is called if the caller is searchcard + * \param i ctl _name + * \param p_id code id (quickcode + * \param p_label = label + * \param p_price vw_fiche_attr.vw_price + * \param p_price vw_fiche_attr.vw_price + * \param p_tva_id vw_fiche_attr.tva_id + * \param p_tva_label vw_fiche_attr.tva_label */ function SetData(i,p_id,p_label,p_price,p_price,p_tva_id, p_tva_label) { @@ -121,5 +143,44 @@ function SetValue(p_ctl,p_value) document.getElementById(a).innerHTML=p_tva_label; } } +/*!\brief Set the value of 2 input fields +* +* Set the quick code in the first ctrl and the label of the quickcode in the second one. This function is a variant of SetData for +* some specific need. This function is called if the caller is searchcardCtrl +* +*\param p_ctrl the input with the name of the quick code +*\param p_quickcode the found quick_code +*\param p_ctrlname the name of the input field with the label +*\param p_label the label of the quickcode +*/ +function setCtrl(p_ctrl,p_quickcode,p_ctrlname,p_label){ + var ctrl=document.getElementById(p_ctrl); + if ( ctrl ) { ctrl.value=p_quickcode; } + var ctrl_name=document.getElementById(p_ctrlname); + if ( ctrl_name ) { ctrl_name.value=p_label; } +} - +/*!\brief Open a window for searching a card +* +* Remark The ledger (jrn_id) must be in the calling form as a hidden field named p_jrn, this function is derived from searchCard because +* the returns value are also handled differently (so a paramter caller is added to the url +*\param p_sessid is the PHPSESSID +*\param name is the name of the control, it is used for computing the name of the VAT, Price field +* \see SetData() +*/ +function searchCardCtrl(p_sessid,type,name,ctrl) +{ + var search=document.getElementById(name).value; + var gDossier=document.getElementById('gDossier').value; + var jrn=0; + if ( document.getElementById("p_jrn") ) { + jrn=document.getElementById("p_jrn").value; + } + var file='fiche_search.php'; + var query='?first&search&fic_search='+search+'&p_jrn='+jrn+'&PHPSESSID='+p_sessid+'&type='+type+'&name='+name+'&gDossier='+gDossier; + query+="&extra="+ctrl; + query+="&caller=searchcardCtrl"; + var a=window.open(file+query,'item','toolbar=no,width=350,height=450,scrollbars=yes,statusbar=no'); + a.focus(); + return false; +} diff --git a/html/js/search_poste.js b/html/js/search_poste.js index 9aca4b0ce..c9a523f8e 100644 --- a/html/js/search_poste.js +++ b/html/js/search_poste.js @@ -30,17 +30,23 @@ *\param p_jrn the concerned ledger id *\param p_return update with the pcm_val or pcm_lib (value=label or poste) *\param p_search take the value of the ctl and make a search + *\param p_ctrl the control (input) to update (default value = none ) + *\note the script will to see if it founds a hidden value in the document.form + * to know if the return must update or replace *\see poste_search.php */ -function SearchPoste(p_sessid,p_dossier,p_ctl,p_jrn,p_return,p_search) +function SearchPoste(p_sessid,p_dossier,p_ctl,p_jrn,p_return,p_search,p_ctrl) { var comment=""; if ( document.getElementById(p_ctl) && p_search=='Y') { comment=document.getElementById(p_ctl).value; } - - var win=window.open('poste_search.php?gDossier='+p_dossier+'&p_jrn='+p_jrn+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+"&p_comment="+comment+"&search"+"&ret="+p_return,'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes'); + var +win=window.open('poste_search.php?gDossier='+p_dossier+'&p_jrn='+p_jrn+'&p_ctl=' ++p_ctl+'&PHPSESSID='+p_sessid+"&p_comment="+comment+"&search"+"&ret="+p_return+ +'&ctrl='+p_ctrl, +'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes'); } /*!\brief open a window for searching a account *\param p_sessid PHPSESSID @@ -49,32 +55,34 @@ function SearchPoste(p_sessid,p_dossier,p_ctl,p_jrn,p_return,p_search) *\param p_jrn the concerned ledger id *\param p_return update with the pcm_val or pcm_lib (value=label or poste) *\param p_search take the value of the ctl and make a search +*\param p_ctrl the control to update (default value = none ) *\see poste_search.php */ -function SearchPosteFilter(p_sessid,p_dossier,p_ctl,p_filter,jrn) +function SearchPosteFilter(p_sessid,p_dossier,p_ctl,p_filter,jrn,p_ctrl) { var comment=""; if ( document.getElementById(p_ctl) ) { comment=document.getElementById(p_ctl).value; } - var win=window.open('poste_search.php?gDossier='+p_dossier+'&p_jrn='+jrn+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+'&filter='+p_filter+'&p_comment='+comment+"&search&ret=label",'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes'); + var win=window.open('poste_search.php?gDossier='+p_dossier+'&p_jrn='+jrn+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+'&filter='+p_filter+'&p_comment='+comment+"&search&ret=label"+'&ctrl='+p_ctrl,'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes'); } function GetIt() { window.close(); } -function SetItChild(p_ctl,p_value,p_label) { +function SetItChild(p_ctl,p_value,p_label,p_ctrl) { - self.opener.SetItParent(p_ctl,p_value,p_label); + self.opener.SetItParent(p_ctl,p_value,p_label,p_ctrl); window.close(); } -function SetItParent(p_ctl,p_value,p_label) { +function SetItParent(p_ctl,p_value,p_label,p_ctrl) { var f=document.getElementById(p_ctl); f.value=p_value; var f1=document.getElementById(p_ctl+"_label"); if ( f1) f1.innerHTML=p_label; + if ( document.getElementById(p_ctrl)) document.getElementById(p_ctrl).value=p_label; } @@ -90,7 +98,18 @@ function set_poste_parent(p_ctl,p_value) { } +function set_jrn_child(p_ctl,p_value) { + self.opener.set_jrn_parent(p_ctl,p_value); + window.close(); +} +function set_jrn_parent(p_ctl,p_value) { + var f=document.getElementById(p_ctl); + if ( f ) { + if ( trim(f.value)!="") f.value+=' '; + f.value+=p_value; + } +} /* SetValue( p_ctl,p_value ) /* p_ctl is the name of the control /* p_value is the value to set in @@ -105,3 +124,7 @@ function SetValue(p_ctl,p_value) } + +function clear(p_ctrl) { + if ( document.getElementById(p_ctrl)) document.getElementById(p_ctrl)=''; +} diff --git a/html/line_update.php b/html/line_update.php index 1c79f2b2a..17fb93c0c 100644 --- a/html/line_update.php +++ b/html/line_update.php @@ -34,7 +34,7 @@ $User=new User($rep); $User->Check(); html_page_start($User->theme,"onLoad='window.focus();'"); $cn=DbConnect($gDossier); -$User->can_request($cn,MPCMN); +$User->can_request(PARPCMN); include ("user_menu.php"); @@ -111,7 +111,7 @@ echo $acc->form(true); -',$acc->get_parameter('value')); ?> + ',h($acc->get_parameter('value'))); ?> diff --git a/html/login.php b/html/login.php index e4e08784c..6360c9a3b 100644 --- a/html/login.php +++ b/html/login.php @@ -39,7 +39,7 @@ if ( isset ($_POST["p_user"] ) ) { $rep=DbConnect(); include_once ("class_user.php"); $User=new User($rep); - $User->Check(); + $User->Check(); echo ""; diff --git a/html/modify_op.php b/html/modify_op.php index 4370c9649..62eff1488 100644 --- a/html/modify_op.php +++ b/html/modify_op.php @@ -33,19 +33,28 @@ include_once ("postgres.php"); include_once("jrn.php"); include_once("class_widget.php"); require_once ("constant.php"); +require_once('class_acc_reconciliation.php'); +require_once('class_acc_operation.php'); /* Admin. Dossier */ -$rep=DbConnect(); +$gDossier=dossier::id(); +$cn=DbConnect($gDossier); + include_once ("class_user.php"); -$User=new User($rep); +$User=new User($cn); $User->Check(); +$User->check_dossier(dossier::id()); html_page_start($User->theme,"onLoad='window.focus();'"); require_once('class_dossier.php'); -$gDossier=dossier::id(); +// $p_jrn=(isset($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:0; +$acc=new Acc_Operation($cn); +if (isset($_REQUEST['line'])) + $acc->jr_id=$_REQUEST ['line']; +else + $acc->jr_id=$_REQUEST ['jr_ir']; -$cn=DbConnect($gDossier); -$p_jrn=(isset($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:0; +$p_jrn=$acc->get_ledger(); if ( isset ( $_GET['action'] ) ) { $action=$_GET['action']; @@ -86,7 +95,9 @@ function hide_div (p_div) { echo_debug(__FILE__,__LINE__,"action is $action"); //----------------------------------------------------- if ( $action == 'update' ) { - if ( ($priv=CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn'],true)) < 1 ) { + if ( $User->check_jrn($p_jrn) =='X' ) { + echo ' '; + NoAccess(); exit -1; @@ -120,7 +131,8 @@ if ( $action == 'update' ) { $view.="
    "; $view.="
    "; $view.="
    "; - $view.=($p_view == 'S')?'':""; + if ( $User->check_jrn($p_jrn) == 'W') + $view.=($p_view == 'S')?'':""; $view.="      "; $view.=''; $view.=''; @@ -142,7 +154,8 @@ if ( $action == 'update' ) { $view.="
    "; $view.="
    "; $view.="
    "; - $view.=($p_view == 'E') ?'':""; + if ( $User->check_jrn($p_jrn) == 'W') + $view.=($p_view == 'E') ?'':""; $view.="      "; $view.=''; $view.='
    '; @@ -187,34 +200,49 @@ if ( $action=="view_ca") { // update the record and upload files //---------------------------------------------------------------------- if ( isset($_POST['update_record']) ) { - if ( ($priv=CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn,true)) !=2 ) { + /* in what ledger are we working */ + $acc=new Acc_Operation($cn); + $acc->jr_id=$_POST['jr_id']; + $l=$acc->get_ledger(); + if ( $User->check_jrn($l) != 'W' ) { + echo ' '; NoAccess(); exit -1; - } try { - // NO UPDATE except rapt & comment && upload pj + // NO UPDATE except rapt & comment && upload pj && PJ Number StartSql($cn); - - UpdateComment($cn,$_POST['jr_id'],$_POST['comment']); + $acc=new Acc_Operation($cn); + $acc->jr_id=$_POST['jr_id']; + /* set the pj */ + $acc->pj=$_POST['pj']; $acc->set_pj(); + $acc->operation_update_comment($_POST['comment']); + /* insert now the grouping */ if ( trim($_POST['rapt']) != "" ) { if ( strpos($_POST['rapt'],',') !== 0 ) { $aRapt=split(',',$_POST['rapt']); + /* reconcialition */ + $rec=new Acc_Reconciliation ($cn); + $rec->set_jr_id($_POST['jr_id']); + foreach ($aRapt as $rRapt) { + + if ( isNumber($rRapt) == 1 ) { - InsertRapt($cn,$_POST['jr_id'],$rRapt); + // Add a "concerned operation to bound these op.together + // + $rec->insert($rRapt); } } } else if ( isNumber($_POST['rapt']) == 1 ) { - InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']); + $rec->insert($_POST['rapt']); } } - // 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']); @@ -320,8 +348,9 @@ if ( isset($_POST['update_record']) ) { } // if update_record //----------------------------------------------------- if ( $action == 'delete' ) { - echo_debug('modify_op.php',__LINE__," Call DeleteRapt($cn,".$_GET['line'].",".$_GET['line2'].")"); - DeleteRapt($cn,$_GET['line'],$_GET['line2']); + $rec=new Acc_Reconciliation ($cn); + $rec->set_jr_id($_GET ['line']); + $rec->remove($_GET['line2']); echo '