From: Agnibho Mondal Date: Thu, 10 Jun 2021 22:29:16 +0000 (+0530) Subject: Deletable attachments X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=74de6b7cec2b4eaf6df7ab8a4aba9f6074dbd82c;p=simpleipd.git Deletable attachments --- diff --git a/www/attachments.php b/www/attachments.php index 581e549..4df1e58 100644 --- a/www/attachments.php +++ b/www/attachments.php @@ -14,7 +14,7 @@ if(!empty($_GET["pid"])){ $name=""; } $fname=str_replace("/", "", $pid)."-".$name.time()."-".rand(1000,9999).".".pathinfo($_FILES["upload"]["name"], PATHINFO_EXTENSION); - move_uploaded_file($_FILES["upload"]["tmp_name"], "data/attachments/".$fname); + move_uploaded_file($_FILES["upload"]["tmp_name"], CONFIG_WWW."data/attachments/".$fname); if(!empty($_GET["req"])){ $db->omitRequisition($_GET["req"]); } @@ -23,14 +23,25 @@ if(!empty($_GET["pid"])){ $error=$error."Only jpg, png, gif, pdf files are supported."; } } + elseif(!empty($_POST["delete"])){ + $file=str_replace("/","",$_POST["delete"]); + rename(CONFIG_WWW."data/attachments/".$file, CONFIG_WWW."data/attachments/.trash/".$file); + } + + if(checkAccess("attachments")=="all" && $db->getStatus($pid)->fetchArray()["status"]=="admitted"){ + $hideEdit=""; + } + else{ + $hideEdit="style='display:none'"; + } foreach(glob("data/attachments/".str_replace("/", "", $pid)."-*") as $attach){ if(pathinfo($attach, PATHINFO_EXTENSION)=="pdf"){ - $pdfs=$pdfs."".pathinfo($attach, PATHINFO_BASENAME).""; + $pdfs=$pdfs."

".pathinfo($attach, PATHINFO_BASENAME)."


"; } else{ preg_match("/-([0-9]+)-/", pathinfo($attach, PATHINFO_FILENAME), $orig); - $imgs=$imgs."
Uploaded on: ".date("M d, Y h:i a", $orig[1])."
"; + $imgs=$imgs."
Uploaded on: ".date("M d, Y h:i a", $orig[1])."
"; } } } @@ -46,9 +57,10 @@ $error=$error."

";
+
-
> + > diff --git a/www/treatment.php b/www/treatment.php index 20b6489..46820a3 100644 --- a/www/treatment.php +++ b/www/treatment.php @@ -31,6 +31,12 @@ if(!empty($_GET["pid"])){ } $list=$db->getDrugs($pid); $view=""; + if(checkAccess("treatment")=="all" && $db->getStatus($pid)->fetchArray()["status"]=="admitted"){ + $hideEdit=""; + } + else{ + $hideEdit="style='display:none'"; + } while($drug=$list->fetchArray()){ if($drug["omit"]){ $omit="omit"; @@ -60,16 +66,10 @@ if(!empty($_GET["pid"])){ if(filter_var($drug["duration"], FILTER_VALIDATE_INT)){ $drug["duration"]=$drug["duration"]. " days"; } - $view=$view."".$drug["drug"]."".$drug["dose"]."".$drug["route"]."".$drug["frequency"]."".date("M j", $drug["start"]).$end."".$drug["duration"]."".$drug["addl"]."".$last.""; + $view=$view."".$drug["drug"]."".$drug["dose"]."".$drug["route"]."".$drug["frequency"]."".date("M j", $drug["start"]).$end."".$drug["duration"]."".$drug["addl"]."".$last.""; } $form=schema2form("forms/drugs.schema.json"); $form2=schema2form("forms/advice.schema.json", null, null, null, json_decode($advice)); - if(checkAccess("treatment")=="all" && $db->getStatus($pid)->fetchArray()["status"]=="admitted"){ - $hideForm=""; - } - else{ - $hideForm="style='display:none'"; - } } ?> @@ -86,13 +86,13 @@ if(!empty($_GET["pid"])){

Medicine List

- Add New Drug + >Add New Drug @@ -111,7 +111,7 @@ if(!empty($_GET["pid"])){
-
> +
>