Restructure files , move show_document.php to export_document.php

This commit is contained in:
Dany De Bontridder 2015-10-17 16:37:31 +02:00
parent c59cca605b
commit 9da5661d42
5 changed files with 81 additions and 41 deletions

View file

@ -33,9 +33,14 @@
*/
function remove_document(p_dossier,p_id)
{
var queryString="gDossier="+p_dossier+"&a=rm&d_id="+p_id;
var queryString={
"gDossier":p_dossier,
"a":"rm",
"d_id":p_id,
'act':'RAW:document'
};
var action=new Ajax.Request (
"show_document.php",
"export.php",
{
method:'get',
parameters:queryString,
@ -53,10 +58,15 @@ function remove_document(p_dossier,p_id)
*/
function update_document(p_dossier,p_id)
{
var queryString="gDossier="+p_dossier+"&a=upd_doc&d_id="+p_id;
queryString+="&value="+$('input_desc_txt'+p_id).value;
var queryString={
"gDossier":p_dossier,
"a":"upd_doc",
"d_id":p_id,
'act':'RAW:document',
'value':$('input_desc_txt'+p_id).value
};
var action=new Ajax.Request (
"show_document.php",
"export.php",
{
method:'get',
parameters:queryString,
@ -79,9 +89,14 @@ function update_document(p_dossier,p_id)
*/
function remove_operation(p_dossier,p_id)
{
var queryString="gDossier="+p_dossier+"&a=rmop&id="+p_id;
var queryString={
"gDossier":p_dossier,
"a":"rmop",
"id":p_id,
'act':'RAW:document'
};
var action=new Ajax.Request (
"show_document.php",
"export.php",
{
method:'get',
parameters:queryString,
@ -115,9 +130,15 @@ function successRemoveOp(request,json)
*/
function remove_action(p_dossier,p_id,ag_id)
{
queryString="gDossier="+p_dossier+"&a=rmaction&id="+p_id+"&ag_id="+ag_id;
var queryString={
"gDossier":p_dossier,
"a":"rmaction",
"id":p_id,
"ag_id":ag_id,
'act':'RAW:document'
};
var action=new Ajax.Request (
"show_document.php",
"export.php",
{
method:'get',
parameters:queryString,
@ -146,9 +167,14 @@ function remove_action(p_dossier,p_id,ag_id)
*/
function remove_comment(p_dossier,p_id)
{
queryString="gDossier="+p_dossier+"&a=rmcomment&id="+p_id;
var queryString={
"gDossier":p_dossier,
"a":"rmcomment",
"id":p_id,
'act':'RAW:document'
};
var action=new Ajax.Request (
"show_document.php",
"export.php",
{
method:'get',
parameters:queryString,

View file

@ -162,7 +162,8 @@ class Document
}
$this->SaveGenerated($dirname.DIRECTORY_SEPARATOR.$file_to_parse);
// Invoice
$ret='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'&'.dossier::get().'">Document g&eacute;n&eacute;r&eacute;</A>';
$href=http_build_query(array('gDossier'=>Dossier::id(),"d_id"=>$this->d_id,'act'=>'RAW:document'));
$ret='<A class="mtitle" HREF="export.php?'.$href.'">Document g&eacute;n&eacute;r&eacute;</A>';
@rmdir($dirname);
return $ret;
}
@ -409,7 +410,9 @@ class Document
return '';
$image='<IMG SRC="image/insert_table.gif" title="'.$this->d_filename.'" border="0">';
$r="";
$r='<A class="mtitle" HREF="show_document.php?d_id='.$this->d_id.'&'.dossier::get().'">'.$image.'</A>';
$href=http_build_query(array('gDossier'=>Dossier::id(),"d_id"=>$this->d_id,'act'=>'RAW:document'));
$r='<A class="mtitle" HREF="export.php?'.$href.'">'.$image.'</A>';
return $r;
}
/** Get

View file

@ -404,7 +404,7 @@ class Follow_Up
$upload->readOnly=$readonly;
$upload->value="";
$aAttachedFile=$this->db->get_array('select d_id,d_filename,d_description,d_mimetype,'.
'\'show_document.php?'.
'\'export.php?act=RAW:document&'.
Dossier::get().'&d_id=\'||d_id as link'.
' from document where ag_id=$1', array($this->ag_id));
/* create the select for document */

View file

@ -19,31 +19,36 @@
*/
// Copyright Author Dany De Bontridder danydb@aevalys.eu
// Verify parameters
/** \file
/**
* \file
* \brief retrieve a document
*/
require_once '../include/constant.php';
require_once NOALYSS_INCLUDE.'/lib/class_database.php';
if ( ! defined ('ALLOWED')) die (_('Non autorisé'));
require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
require_once NOALYSS_INCLUDE.'/class/class_document.php';
require_once NOALYSS_INCLUDE.'/class/class_dossier.php';
$gDossier = dossier::id();
$cn = Dossier::connect();
$action = (isset($_REQUEST['a'])) ? $_REQUEST['a'] : 'sh';
require_once NOALYSS_INCLUDE.'/class/class_user.php';
global $g_user;
$g_user = new User($cn);
$g_user->Check();
$g_user->check_dossier($gDossier);
set_language();
$d_id=HtmlInput::default_value_request('d_id',0);
$id=HtmlInput::default_value_request('id',0);
$ag_id=HtmlInput::default_value_request('ag_id',0);
$value=HtmlInput::default_value_request('value', null);
if ( isNumber($id) == 0 ||
isNumber($ag_id) == 0 ||
isNumber($d_id) == 0
)
{
die (_('Données invalides'));
}
/* Show the document */
if ($action == 'sh')
{
if ($g_user->check_action(VIEWDOC) == 1)
{
// retrieve the document
$doc = new Document($cn, $_REQUEST['d_id']);
$doc = new Document($cn, $d_id);
$doc->Send();
}
}
@ -53,9 +58,9 @@ if ($action == 'rm')
$json='{"d_id":"-1"}';
if ($g_user->check_action(RMDOC) == 1)
{
$doc = new Document($cn, $_REQUEST['d_id']);
$doc = new Document($cn, $d_id);
$doc->remove();
$json = sprintf('{"d_id":"%s"}', $_REQUEST['d_id']);
$json = sprintf('{"d_id":"%s"}', $d_id);
}
header("Content-type: text/html; charset: utf8", true);
print $json;
@ -65,11 +70,11 @@ if ( $action == "upd_doc")
{
if ($g_user->check_action(VIEWDOC) == 1)
{
$doc = new Document($cn, $_REQUEST['d_id']);
$doc = new Document($cn, $d_id);
$doc->get();
if ( $g_user->can_write_action($doc->ag_id))
// retrieve the document
$doc->update_description(strip_tags ($_REQUEST['value']));
$doc->update_description(strip_tags ($value));
}
}
@ -77,11 +82,11 @@ if ( $action == "upd_doc")
if ($action == 'rmop')
{
$json = '{"ago_id":"-1"}';
$dt_id = $cn->get_value("select ag_id from action_gestion_operation where ago_id=$1",array( $_REQUEST['id']));
$dt_id = $cn->get_value("select ag_id from action_gestion_operation where ago_id=$1",array( $id));
if ($g_user->check_action(RMDOC) == 1 && $g_user->can_write_action($dt_id) == true)
{
$cn->exec_sql("delete from action_gestion_operation where ago_id=$1", array($_REQUEST['id']));
$json = sprintf('{"ago_id":"%s"}', $_REQUEST['id']);
$cn->exec_sql("delete from action_gestion_operation where ago_id=$1", array($id));
$json = sprintf('{"ago_id":"%s"}', $id);
}
header("Content-type: text/html; charset: utf8", true);
print $json;
@ -90,11 +95,11 @@ if ($action == 'rmop')
if ($action == 'rmcomment')
{
$json = '{"agc_id":"-1"}';
$dt_id = $cn->get_value("select ag_id from action_gestion_comment where agc_id=$1", array($_REQUEST['id']));
$dt_id = $cn->get_value("select ag_id from action_gestion_comment where agc_id=$1", array($id));
if ($g_user->check_action(RMDOC) == 1 && $g_user->can_write_action($dt_id) == true)
{
$cn->exec_sql("delete from action_gestion_comment where agc_id=$1", array($_REQUEST['id']));
$json = sprintf('{"agc_id":"%s"}', $_REQUEST['id']);
$cn->exec_sql("delete from action_gestion_comment where agc_id=$1", array($id));
$json = sprintf('{"agc_id":"%s"}', $id);
}
header("Content-type: text/html; charset: utf8", true);
print $json;
@ -103,11 +108,11 @@ if ($action == 'rmcomment')
if ($action == 'rmaction')
{
$json = '{"act_id":"-1"}';
if ($g_user->check_action(RMDOC) == 1 && $g_user->can_write_action($_REQUEST['id']) == true && $g_user->can_write_action($_REQUEST['ag_id']) == true)
if ($g_user->check_action(RMDOC) == 1 && $g_user->can_write_action($id) == true && $g_user->can_write_action($ag_id) == true)
{
$cn->exec_sql("delete from action_gestion_related where aga_least=$1 and aga_greatest=$2", array($_REQUEST['id'], $_REQUEST['ag_id']));
$cn->exec_sql("delete from action_gestion_related where aga_least=$2 and aga_greatest=$1", array($_REQUEST['id'], $_REQUEST['ag_id']));
$json = sprintf('{"act_id":"%s"}', $_REQUEST['id']);
$cn->exec_sql("delete from action_gestion_related where aga_least=$1 and aga_greatest=$2", array($id, $ag_id));
$cn->exec_sql("delete from action_gestion_related where aga_least=$2 and aga_greatest=$1", array($id, $ag_id));
$json = sprintf('{"act_id":"%s"}', $id);
}
header("Content-type: text/html; charset: utf8", true);
print $json;

View file

@ -9,4 +9,10 @@ CREATE TRIGGER fiche_detail_upd_trg
insert into menu_ref(me_code,me_file,me_menu,me_description,me_type)
values ('RAW:receipt','export_receipt.php','Export la pièce','export la pièce justificative d''une opération','PR');
insert into profile_menu (me_code,p_id,p_type_display) select 'RAW:receipt',p_id,'P' from profile where p_id > 0;
insert into profile_menu (me_code,p_id,p_type_display) select 'RAW:receipt',p_id,'P' from profile where p_id > 0;
insert into menu_ref(me_code,me_file,me_menu,me_description,me_type)
values ('RAW:document','export_document.php','Export le document','export le document d''une événement','PR');
insert into profile_menu (me_code,p_id,p_type_display) select 'RAW:document',p_id,'P' from profile where p_id > 0;