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

fix remove signed file if unsign file

parent 88d76621
No related branches found
No related tags found
No related merge requests found
......@@ -54,10 +54,10 @@ if (empty($docserver)) {
$db = new Database();
$signatoryUser = \User\models\UserModel::getByUserId(['userId' => $_SESSION['user']['UserId'], 'select' => ['id']]);
if ($_SESSION['visa']['repSignRel'] > 1) {
//$target_table = 'res_version_attachments';
$target_table = 'res_version_attachments';
$db->query("UPDATE res_version_attachments set status = 'SIGN', signatory_user_serial_id = ? WHERE res_id = ?",[$signatoryUser['id'], $_SESSION['visa']['repSignId']]);
} else {
//$target_table = 'res_attachments';
$target_table = 'res_attachments';
$db->query("UPDATE res_attachments set status = 'SIGN', signatory_user_serial_id = ? WHERE res_id = ?",[$signatoryUser['id'], $_SESSION['visa']['repSignId']]);
}
unset($_SESSION['visa']['repSignRel']);
......@@ -196,9 +196,14 @@ if (empty($docserver)) {
'type' => 'string'
];
if (empty($_REQUEST['id'])) $id_origin = $objectId;
else $id_origin = $_REQUEST['id'];
if (empty($target_table)) $target_table = "res_attachments";
if (empty($_REQUEST['id'])) {
$id_origin = $objectId;
} else {
$id_origin = $_REQUEST['id'];
}
if (empty($target_table)) {
$target_table = "res_attachments";
}
array_push(
$_SESSION['data'],
array(
......
......@@ -58,21 +58,21 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) {
$tableName = 'res_view_attachments';
if (isset($_REQUEST['isOutgoing'])) {
if (isset($_REQUEST['isVersion'])) {
$stmt = $db->query("select res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
$stmt = $db->query("select relation, res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
. $tableName
. " where attachment_type = ? and res_id_version = ?", ['outgoing_mail', $objectId]);
} else {
$stmt = $db->query("select res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
$stmt = $db->query("select relation, res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
. $tableName
. " where attachment_type = ? and res_id = ?", ['outgoing_mail', $objectId]);
}
} else {
if (isset($_REQUEST['isVersion'])) {
$stmt = $db->query("select res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
$stmt = $db->query("select relation, res_id_version, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
. $tableName
. " where attachment_type NOT IN ('converted_pdf','print_folder') and res_id_version = ?", array($objectId));
} else {
$stmt = $db->query("select res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
$stmt = $db->query("select relation, res_id, format, res_id_master, title, identifier, type_id, attachment_type, dest_contact_id, dest_address_id, dest_user from "
. $tableName
. " where (attachment_type NOT IN ('converted_pdf','print_folder')) and res_id = ?", array($objectId));
}
......@@ -111,6 +111,8 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) {
exit;
}
$_SESSION['visa']['repSignRel'] = $line->relation;
$_SESSION['visa']['repSignId'] = $attachResId;
$docserver = \Docserver\models\DocserverModel::getByDocserverId(['docserverId' => $convertedAttachment["docserver_id"], 'select' => ['path_template']]);
$fileOnDs = $docserver["path_template"] . $convertedAttachment["path"] . $convertedAttachment["filename"];
......@@ -192,12 +194,6 @@ if (!empty($_REQUEST['id']) && !empty($_REQUEST['collId'])) {
include 'modules/visa/save_attach_res_from_cm.php';
$db->query('UPDATE listinstance set signatory = TRUE WHERE listinstance_id = (SELECT listinstance_id FROM listinstance WHERE res_id = ? AND item_id = ? AND difflist_type = ? AND process_date is null ORDER BY listinstance_id LIMIT 1)', [$objectResIdMaster, $_SESSION['user']['UserId'], 'VISA_CIRCUIT']);
if (isset($_REQUEST['isVersion'])) {
$db->query("UPDATE res_version_attachments set status = 'SIGN' WHERE res_id = ?", [$attachResId]);
} else {
$db->query("UPDATE res_attachments set status = 'SIGN' WHERE res_id = ?", [$attachResId]);
}
echo "{\"status\": 0, \"new_id\": $id}";
exit;
......
......@@ -166,7 +166,7 @@ abstract class AttachmentModelAbstract
]);
DatabaseModel::update([
'table' => $aArgs['table'],
'table' => 'res_attachments',
'set' => ['status' => 'DEL'],
'where' => ['origin = ?', 'status != ?'],
'data' => ["{$aArgs['resId']},{$aArgs['table']}", 'DEL']
......
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