require_once "functions.php"; session_start(); security::redirect_if_not_loggedin(); $Guid = costant::desktop_guid(); if (isset($_GET["DeleteAttach"])) { attachments::delete_attachment_by_name($_GET["DeleteAttach"]); } if (isset($_FILES['UploadedAttachments']) && isset($_POST["Attachment_TrId"])) { $TrNumber = (int) $_POST['Attachment_TrId']; $FileName = $_FILES['UploadedAttachments']['name']; $FileExtension = substr($FileName, strpos($FileName, ".") + 1, strlen($FileName)); $NewFileName = "Transaction_" . $TrNumber . "_Attach" . (attachments::get_number_of_attachments($TrNumber) + 1) . "." . $FileExtension; move_uploaded_file($_FILES['UploadedAttachments']['tmp_name'], "attachments/" . $NewFileName); echo $NewFileName; } if (isset($_GET["AttachmentsTable"])) { $TrId = $_GET["AttachmentsTable"]; $Attachments = attachments::get_attachments_filename_array($TrId, true); echo "<table class = 'table'>"; echo "<tbody>"; for ($i = 0; $i < sizeof($Attachments); $i++) { echo "<tr>"; $File = $Attachments[$i]; design::table_cell(substr($File, strpos($File, "Attach"), strlen($File)), ""); design::table_cell("<a href='services.php?guid={$Guid}&download_attachment={$File}'>\n <span class='glyphicon glyphicon-download-alt'> </span> Open</a>", "text_align_right"); design::table_cell("<a href='#' onclick='attachment_delete(\"{$File}\",{$TrId});return false;'>\n <span class='glyphicon glyphicon-remove'> </span> Delete</a>", "text_align_right"); echo "</tr>"; } echo "</tbody>"; echo "</table>"; }
#Delete Category if (isset($_GET["delete_category"])) { db_function::category_delete_all(); echo $operation_succeded; } #Import Category if (isset($_GET["import_category"])) { db_function::category_insert_json($_POST["MMEX_Post"]); echo $operation_succeded; } #Download New Transactions if (isset($_GET["download_transaction"])) { $TransactionsArr = db_function::transaction_select_all_order_by_date(); if (!empty($TransactionsArr)) { for ($i = 0; $i < sizeof($TransactionsArr); $i++) { $TransactionsArr[$i]['Attachments'] = implode(";", attachments::get_attachments_filename_array((int) $TransactionsArr[$i]['ID'])); } echo json_encode($TransactionsArr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); } } #Download Attachments by name if (isset($_GET["download_attachment"])) { $AttachmentFileName = $_GET["download_attachment"]; if (!empty($AttachmentFileName)) { $FullPath = costant::attachments_folder() . "/" . $AttachmentFileName; header("Content-Type:"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename= " . $AttachmentFileName); header("Content-Transfer-Encoding: binary"); readfile($FullPath);