Skip to content
Snippets Groups Projects
Commit ef55bf05 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #5604 fix js src

parent 1c6f55f0
No related branches found
No related tags found
No related merge requests found
<?php <?php
/**
/* * Copyright Maarch since 2008 under licence GPLv3.
* Copyright 2008-2015 Maarch * See LICENCE.txt file at the root folder for more details.
* * This file is part of Maarch software.
* This file is part of Maarch Framework.
* * @brief del_attachment
* Maarch Framework is free software: you can redistribute it and/or modify * @author dev <dev@maarch.org>
* it under the terms of the GNU General Public License as published by * @ingroup attachments
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Maarch Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/ */
require_once "core/class/class_security.php"; require_once "core/class/class_security.php";
...@@ -36,50 +26,50 @@ $db = new Database(); ...@@ -36,50 +26,50 @@ $db = new Database();
$info_doc = $ac->getAttachmentInfos($_REQUEST['id']); $info_doc = $ac->getAttachmentInfos($_REQUEST['id']);
if ($_REQUEST['relation'] == 1) { if ($_REQUEST['relation'] == 1) {
$stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($_REQUEST['id']) ); $stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($_REQUEST['id']));
$pdf_id = $ac->getCorrespondingPdf($_REQUEST['id']); $pdf_id = $ac->getCorrespondingPdf($_REQUEST['id']);
if (isset($pdf_id) && $pdf_id != 0) $stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($pdf_id)); if (isset($pdf_id) && $pdf_id != 0) $stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($pdf_id));
$document = $ac->getCorrespondingDocument($_REQUEST['id']); $document = $ac->getCorrespondingDocument($_REQUEST['id']);
$document_relation = $document->relation; $document_relation = $document->relation;
$attach_type = $_SESSION['attachment_types'][$document->attachment_type]; $attach_type = $_SESSION['attachment_types'][$document->attachment_type];
if($document_relation == 1){ if ($document_relation == 1) {
$target_table = "res_attachments"; $target_table = "res_attachments";
$document_id = $document->res_id; $document_id = $document->res_id;
$is_version = 0; $is_version = 0;
}else{ } else {
$target_table = "res_version_attachments"; $target_table = "res_version_attachments";
$document_id = $document->res_id_version; $document_id = $document->res_id_version;
$is_version = 1; $is_version = 1;
} }
if (isset($document_id) && $document_id != 0) $stmt = $db->query("UPDATE " . $target_table . " SET status = 'A_TRA' WHERE res_id = ?", array($document_id)); if (isset($document_id) && $document_id != 0) $stmt = $db->query("UPDATE " . $target_table . " SET status = 'A_TRA' WHERE res_id = ?", array($document_id));
} else { } else {
$stmt = $db->query("SELECT attachment_id_master FROM res_version_attachments WHERE res_id = ?", array($_REQUEST['id']) ); $stmt = $db->query("SELECT attachment_id_master FROM res_version_attachments WHERE res_id = ?", array($_REQUEST['id']));
$res=$stmt->fetchObject(); $res=$stmt->fetchObject();
$stmt = $db->query("UPDATE res_version_attachments SET status = 'DEL' WHERE attachment_id_master = ?", array($res->attachment_id_master) ); $stmt = $db->query("UPDATE res_version_attachments SET status = 'DEL' WHERE attachment_id_master = ?", array($res->attachment_id_master));
$stmt = $db->query("UPDATE res_attachments SET status = 'DEL' WHERE res_id = ?", array($res->attachment_id_master)); $stmt = $db->query("UPDATE res_attachments SET status = 'DEL' WHERE res_id = ?", array($res->attachment_id_master));
$pdf_id = $ac->getCorrespondingPdf($_REQUEST['id']); $pdf_id = $ac->getCorrespondingPdf($_REQUEST['id']);
if (isset($pdf_id) && $pdf_id != 0) $stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($pdf_id)); if (isset($pdf_id) && $pdf_id != 0) $stmt = $db->query("UPDATE " . RES_ATTACHMENTS_TABLE . " SET status = 'DEL' WHERE res_id = ?", array($pdf_id));
$document = $ac->getCorrespondingDocument($_REQUEST['id']); $document = $ac->getCorrespondingDocument($_REQUEST['id']);
$document_id = $document->res_id; $document_id = $document->res_id;
$document_relation = $document->relation; $document_relation = $document->relation;
$attach_type = $_SESSION['attachment_types'][$document->attachment_type]; $attach_type = $_SESSION['attachment_types'][$document->attachment_type];
if($document_relation == 1){ if ($document_relation == 1) {
$target_table = "res_attachments"; $target_table = "res_attachments";
$document_id = $document->res_id; $document_id = $document->res_id;
}else{ } else {
$target_table = "res_version_attachments"; $target_table = "res_version_attachments";
$document_id = $document->res_id_version; $document_id = $document->res_id_version;
} }
if (isset($document_id) && $document_id != 0){ if (isset($document_id) && $document_id != 0) {
$stmt = $db->query("UPDATE " . $target_table . " SET status = 'A_TRA' WHERE res_id = ?", array($document_id)); $stmt = $db->query("UPDATE " . $target_table . " SET status = 'A_TRA' WHERE res_id = ?", array($document_id));
} }
} }
if ($_SESSION['history']['attachdel'] == "true") { if ($_SESSION['history']['attachdel'] == "true") {
...@@ -110,13 +100,13 @@ if ($_SESSION['history']['attachdel'] == "true") { ...@@ -110,13 +100,13 @@ if ($_SESSION['history']['attachdel'] == "true") {
); );
} }
if(!empty($_REQUEST['rest'])) { if (!empty($_REQUEST['rest'])) {
echo '{"status" : "ok"}'; echo '{"status" : "ok"}';
exit; exit;
} }
if ($_REQUEST['relation'] == 1) { if ($_REQUEST['relation'] == 1) {
$stmt = $db->query("SELECT res_id_master FROM " . RES_ATTACHMENTS_TABLE . " WHERE res_id = ?",array($_REQUEST['id'])); $stmt = $db->query("SELECT res_id_master FROM " . RES_ATTACHMENTS_TABLE . " WHERE res_id = ?", array($_REQUEST['id']));
} else { } else {
$stmt = $db->query("SELECT res_id_master FROM res_version_attachments WHERE res_id = ?", array($_REQUEST['id'])); $stmt = $db->query("SELECT res_id_master FROM res_version_attachments WHERE res_id = ?", array($_REQUEST['id']));
} }
...@@ -124,14 +114,14 @@ if ($_REQUEST['relation'] == 1) { ...@@ -124,14 +114,14 @@ if ($_REQUEST['relation'] == 1) {
$res = $stmt->fetchObject(); $res = $stmt->fetchObject();
$resIdMaster = $res->res_id_master; $resIdMaster = $res->res_id_master;
$query = "SELECT title FROM res_view_attachments WHERE status NOT IN ('DEL','OBS','TMP') and res_id_master = ?"; $query = "SELECT title FROM res_view_attachments WHERE status NOT IN ('DEL','OBS','TMP') and res_id_master = ?";
if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') {
$query .= " and (attachment_type <> 'response_project' and attachment_type <> 'outgoing_mail_signed' and attachment_type <> 'signed_response' and attachment_type <> 'converted_pdf' and attachment_type <> 'outgoing_mail' and attachment_type <> 'print_folder' and attachment_type <> 'aihp')"; $query .= " and (attachment_type <> 'response_project' and attachment_type <> 'outgoing_mail_signed' and attachment_type <> 'signed_response' and attachment_type <> 'converted_pdf' and attachment_type <> 'outgoing_mail' and attachment_type <> 'print_folder' and attachment_type <> 'aihp')";
} else if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response'){ } else if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') {
$query .= " and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail_signed' or attachment_type = 'outgoing_mail' or attachment_type = 'signed_response' or attachment_type = 'aihp')"; $query .= " and (attachment_type = 'response_project' or attachment_type = 'outgoing_mail_signed' or attachment_type = 'outgoing_mail' or attachment_type = 'signed_response' or attachment_type = 'aihp')";
}
else{ } else {
$query .= " and attachment_type NOT IN ('converted_pdf','print_folder')"; $query .= " and attachment_type NOT IN ('converted_pdf','print_folder')";
} }
$stmt = $db->query($query, array($resIdMaster)); $stmt = $db->query($query, array($resIdMaster));
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
$new_nb_attach = $stmt->rowCount(); $new_nb_attach = $stmt->rowCount();
...@@ -140,49 +130,19 @@ if ($stmt->rowCount() > 0) { ...@@ -140,49 +130,19 @@ if ($stmt->rowCount() > 0) {
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
if (window.parent.top.document.getElementById('cur_resId')){
function get_num_rep(res_id){ var eleframe1 = parent.document.getElementsByName('list_attach');
trig_elements = window.parent.top.document.getElementsByClassName('trig'); if(eleframe1[0] === undefined){
for (i=0; i<trig_elements.length; i++){ eleframe1 = parent.document.getElementsByName('responses_iframe');
var id = trig_elements[i].id; }
var splitted_id = id.split("_"); console.log(eleframe1);
if (splitted_id.length == 3 && splitted_id[0] == 'ans' && splitted_id[2] == res_id) return splitted_id[1]; var nb_attach = '<?php functions::xecho($new_nb_attach);?>';
} <?php if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { ?>
return 0; eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type_exclude=response_project,signed_response,outgoing_mail_signed,converted_pdf,outgoing_mail,print_folder,aihp&fromDetail=attachments';?>";
} <?php } else if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response') { ?>
eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type=response_project,outgoing_mail_signed,signed_response,outgoing_mail,aihp&fromDetail=response';?>";
var res_id_doc = <?php functions::xecho($_REQUEST['id']); ?>; <?php } else { ?>
var num_rep = get_num_rep(res_id_doc); parent.document.getElementById('list_attach').src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&template_selected=documents_list_attachments_simple&page=frame_list_attachments&load&attach_type_exclude=converted_pdf,print_folder';?>";
var document_type = '<?php functions::xecho($info_doc['attachment_type']); ?>'; <?php } ?>
var is_version = '<?php functions::xecho($is_version); ?>';
if(window.parent.top.document.getElementById('content_'+num_rep+'_'+res_id_doc)) {
var tab = window.parent.top.document.getElementById('tabricatorRight');
if(document_type == 'signed_response'){
window.parent.top.document.getElementById('viewframevalidRep'+num_rep+'_'+res_id_doc).src = '<?php echo $_SESSION['config']['businessappurl']; ?>index.php?display=true&module=visa&page=view_pdf_attachement&res_id_master=<?php echo $resIdMaster; ?>&id=<?php echo $document_id; ?>';
window.parent.top.document.getElementById('content_'+num_rep+'_'+res_id_doc).id = 'content_'+num_rep+'_<?php echo $document_id; ?>';
window.parent.top.document.getElementById('viewframevalidRep'+num_rep+'_'+res_id_doc).id = 'viewframevalidRep'+num_rep+'_<?php echo $document_id; ?>';
}else{
tab.removeChild(window.parent.top.document.getElementById('content_'+num_rep+'_'+res_id_doc));
}
}
}
var eleframe1 = parent.document.getElementsByName('list_attach');
console.log(eleframe1);
var nb_attach = '<?php functions::xecho($new_nb_attach);?>';
<?php if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'attachments') { ?>
eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type_exclude=response_project,signed_response,outgoing_mail_signed,converted_pdf,outgoing_mail,print_folder,aihp&fromDetail=attachments';?>";
<?php } else if (isset($_REQUEST['fromDetail']) && $_REQUEST['fromDetail'] == 'response'){ ?>
eleframe1[0].src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&page=frame_list_attachments&load&attach_type=response_project,outgoing_mail_signed,signed_response,outgoing_mail,aihp&fromDetail=response';?>";
<?php } else { ?>
parent.document.getElementById('list_attach').src = "<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=attachments&template_selected=documents_list_attachments_simple&page=frame_list_attachments&load&attach_type_exclude=converted_pdf,print_folder';?>";
<?php } ?>
</script> </script>
...@@ -95,16 +95,6 @@ function endAttachmentFromTemplate() ...@@ -95,16 +95,6 @@ function endAttachmentFromTemplate()
function endAttachment() function endAttachment()
{ {
if (window.opener.$('cur_idAffich')) var num_rep = window.opener.$('cur_idAffich').value;
if (window.opener.$('cur_resId')) var res_id_master = window.opener.$('cur_resId').value;
if (window.opener.$('cur_rep')){
var oldRep = window.opener.$('cur_rep').value;
}
if(window.opener.$('viewframevalidRep'+num_rep+'_'+oldRep)) {
//window.opener.$('viewframevalidRep'+num_rep).src = "index.php?display=true&module=visa&page=view_doc&path=last";
window.opener.$('viewframevalidRep'+num_rep+'_'+oldRep).src = "index.php?display=true&module=visa&page=view_pdf_attachement&res_id_master="+res_id_master+"&id=last";
}
window.close(); window.close();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment