From 0d2971db938e425d896ee6cbb5b0bd628697dd26 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Mon, 18 May 2015 18:41:39 +0200 Subject: [PATCH] =?UTF-8?q?Task=20#1120=20-=20Ajouter=20option=20s=C3=A9cu?= =?UTF-8?q?rit=C3=A9=20:=20effacement=20op=C3=A9ration=20comptable=20#1120?= =?UTF-8?q?=20:=20new=20privilege=20=20->=20remove=20accountancy=20writing?= =?UTF-8?q?=20privilege=20write=20,=20override=20ledger=20acces=20=20->=20?= =?UTF-8?q?remove=20receipt=20(document)override=20ledger=20acces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/ajax_ledger.php | 95 ++++++++++------------- include/constant.security.php | 2 + include/template/ledger_detail_bottom.php | 3 +- include/template/security_list_action.php | 22 ++++-- sql/upgrade.sql | 26 ++++++- 5 files changed, 88 insertions(+), 60 deletions(-) diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php index b9a84f92b..8468a5f6e 100644 --- a/html/ajax_ledger.php +++ b/html/ajax_ledger.php @@ -160,7 +160,7 @@ switch ($action) // remove op /////////////////////////////////////////////////////////////////////////// case 'rmop': - if ( $access=='W') + if ( $access=='W' && $g_user->check_action(RMOPER) == 1) { ob_start(); /* get the ledger */ @@ -181,6 +181,10 @@ case 'rmop': $html=ob_get_contents(); ob_end_clean(); } + else + { + $html= _("Effacement refusé"); + } break; ////////////////////////////////////////////////////////////////////// // DE Detail @@ -227,22 +231,21 @@ case 'de': case 'file': $op->get(); $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ + + $repo = new Database(); + $theme = $repo->get_value("select the_filestyle from theme where the_name=$1", array($_SESSION['g_theme'])); + html_min_page_start($theme); + // if there is a receipt document if ( $obj->det->jr_pj_name=='') { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo ""; - if ( ! isset($_REQUEST['ajax']) ) { - echo ""; - echo '
'; - }else { - echo ""; - echo "
"; + if ( ! isset($_REQUEST['ajax']) ) { + echo '
'; + }else { + echo "
"; - } - echo "

Document

"; + } + echo "

Document

"; if ( $access=='W') { echo '
'; @@ -261,50 +264,37 @@ case 'file': } else { - echo ""; - if (!isset($_REQUEST['ajax'])) - { - echo ""; - echo '
'; - } - else - { - echo ""; - echo "
"; - } - $repo = new Database(); - $theme = $repo->get_value("select the_filestyle from theme where the_name=$1", array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; + if (!isset($_REQUEST['ajax'])) + { + echo '
'; + } + else + { + echo "
"; + } + - echo _('Aucun fichier'); - } - echo '
'; - echo ''; - exit(); + echo _('Aucun fichier'); + } + echo '
'; + exit(); } else { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - if ( ! isset($_REQUEST['ajax']) ) { - echo ""; - echo '
'; - }else { - echo ""; - echo "
"; + // There is no document attached to this writing + // + if ( ! isset($_REQUEST['ajax']) ) { + echo '
'; + }else { + echo "
"; - } + } echo '
'; $x=''; - if ($access=='W' && $g_user->check_action (RMDOC) == 1) - $x=sprintf(''._('enlever').'', + if ($access=='W' && $g_user->check_action (RMRECEIPT) == 1) + $x=sprintf('', $gDossier,$div,$jr_id); - echo $x; + $filename= $obj->det->jr_pj_name; if ( strlen($obj->det->jr_pj_name) > 20 ) { @@ -313,6 +303,7 @@ case 'file': $h=sprintf('%s', $gDossier,$ledger,$obj->det->jr_grpt_id,h( $filename)); echo $h; + echo $x; echo '
'; echo ''; exit(); @@ -342,8 +333,8 @@ case 'loadfile': echo '
'; // check if the user can remove a document - if ($g_user->check_action (RMDOC) == 1) { - $x=sprintf(''._('enlever').'', + if ($g_user->check_action (RMRECEIPT) == 1) { + $x=sprintf(''."ⵝ".'', $gDossier,$div,$jr_id); echo $x; } @@ -359,7 +350,7 @@ case 'loadfile': // remove a file ///////////////////////////////////////////////////////////////////////////// case 'rmf': - if ( $access == 'W' && $g_user->check_action (RMDOC) == 1) + if ( $access == 'W' && $g_user->check_action (RMRECEIPT) == 1) { echo ""; $repo=new Database(); diff --git a/include/constant.security.php b/include/constant.security.php index bcd579797..15426d89c 100644 --- a/include/constant.security.php +++ b/include/constant.security.php @@ -24,5 +24,7 @@ define ("FICCAT",910); //création, modification et effacement de catégorie de define ('RMDOC',1020); // Effacement de document pour follow up & comptabilité define ('VIEWDOC',1010); // Voir document pour follow up define ('PARCATDOC',1050); // modifier type document pour follow up +define ('RMRECEIPT',1110); // Effacer un document d'une pièce comptable +define ('RMOPER',1120); // Effacer une opération comptable global $audit; $audit=false; ?> diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index bfaeafe41..8fe7c781d 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -285,7 +285,8 @@ if ( $div != 'popup' ) { } $per=new Periode($cn,$obj->det->jr_tech_per); - if ( $per->is_closed() == 0 && $owner->MY_STRICT=='N'){ + if ( $per->is_closed() == 0 && $owner->MY_STRICT=='N' && $g_user->check_action(RMOPER)==1) + { $remove=new IButton('Effacer'); $remove->label=_('Effacer'); $remove->javascript="if ( confirm('Vous confirmez effacement ?')) {removeOperation('".$obj->det->jr_id."',".dossier::id().",'".$div."')}"; diff --git a/include/template/security_list_action.php b/include/template/security_list_action.php index 19512b47a..1c1c54d1a 100644 --- a/include/template/security_list_action.php +++ b/include/template/security_list_action.php @@ -49,9 +49,19 @@ }// end function ?> - get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", - array(800,1000)); - display_security_fieldset(_('Fiche'),$array,$sec_User); ?> - get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", - array(1001,1100)); - display_security_fieldset(_('Suivi & Comptabilité'),$array,$sec_User); ?> +get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", + array(800,1000)); + display_security_fieldset(_('Fiche'),$array,$sec_User); ?> +get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", + array(1001,1100)); + display_security_fieldset(_('Suivi'),$array,$sec_User); ?> + +get_array("select ac_id, ac_description from action where ac_id >=$1 and ac_id <=$2 order by ac_id ", + array(1101,1200)); + display_security_fieldset(_('Comptabilité'),$array,$sec_User); ?> diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 0203ef86f..e438d64dc 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,4 +1,9 @@ -update action set ac_description = 'Effacer un document de la comptabilité ou du suivi' where ac_id=1020; +INSERT INTO action( + ac_id, ac_description, ac_module, ac_code) + VALUES (1110, 'Enlever une pièce justificative', 'compta', 'RMRECEIPT'); +INSERT INTO action( + ac_id, ac_description, ac_module, ac_code) + VALUES (1120, 'Effacer une opération ', 'compta', 'RMOPER'); CREATE TABLE todo_list_shared (id serial primary key, todo_list_id int4 NOT NULL, use_login int4 NOT NULL, CONSTRAINT unique_todo_list_id_login @@ -11,3 +16,22 @@ comment on column todo_list_shared.todo_list_id is 'fk to todo_list'; comment on column todo_list_shared.use_login is 'user login'; +/** +Arbre dépendance + with recursive t (ag_id,ag_ref_ag_id,ag_title,depth) as ( + select + ag_id , ag_ref_ag_id, ag_title , 1 + from + action_gestion + where ag_id=55 + union all + select + p2.ag_id,p2.ag_ref_ag_id,p2.ag_title,depth + 1 + from + t as p1, action_gestion as p2 + where + p1.ag_ref_ag_id is not null and + p1.ag_id = p2.ag_ref_ag_id +) select * from t; + +*/ \ No newline at end of file