From 46d90549dc69af309f748508356a773f938717bf Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 6 Nov 2023 07:37:42 -0500 Subject: [PATCH] upload job oicture --- wrenchboard/src/include/wrenchboard_api.h | 1 + www-api/app/Models/UploadManager.php | 38 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index 893a30ca..8315e035 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -10,6 +10,7 @@ enum { PARTNER_STRIPE }; #define WRENCH_FILE_MYFILE 200 #define WRENCH_FILE_CONTRACTS 300 #define WRENCH_FILE_FAMILY 400 +#define WRENCH_FILE_JOB 500 #define PHP_API_OK 0 #define PHP_CREATED_OK 10 diff --git a/www-api/app/Models/UploadManager.php b/www-api/app/Models/UploadManager.php index 62467d6d..683e35fd 100644 --- a/www-api/app/Models/UploadManager.php +++ b/www-api/app/Models/UploadManager.php @@ -80,6 +80,44 @@ class UploadManager extends Model } break; + case WRENCHBOARD_PICTURE_JOB: + + if ( trim($in["uid"]) == ''){ + $out["error_msg"] = "invalid_upload_call"; + $out["call_backend"] = false; // something went bad + return -1; + } + // MAKE SURE FOLDER AS PER PROCESS IS AVAILABLE + $thisProfileFolder = $this->savePath.'PROFILE/'.$in["uid"]; + if (!file_exists($thisProfileFolder)) { + mkdir($thisProfileFolder, 0777, true); + } + if (!file_exists($thisProfileFolder."/JOBS")) { + mkdir($thisProfileFolder."/JOBS", 0777, true); + } + + $myFilesFolder = $thisProfileFolder."/JOBS"; + + if (file_exists($myFilesFolder)) { + //$tt_d = date('hisjmy'); + $out["message"] = "completed"; + $pieces = explode(".", $in['file_name']); + $in['profile'] = "profile.".$pieces[1]; + $myFilesFolderFileName = $myFilesFolder.'/'. $in['profile']; + $myfile = fopen($myFilesFolderFileName, "w") or die("Unable to open file!"); + $file_data = base64_decode($in["file_data"]); + fwrite($myfile, $file_data); + fclose($myfile); + $out["call_backend"] = false; // flag ready to save data entry + $data['uid'] =$in["uid"]; + $data['sessionid'] =$in["sessionid"]; + $data['profile'] = $in["profile"]; + $data['member_id'] = $in["member_id"]; + $data['file_section'] = WRENCH_FILE_JOB; + $out['upload_result'] = $this->specififBackendCall(WRENCHBOARD_SAVE_MEDIA,$data); + } + break; + case WRENCHBOARD_PICTURE_FAMMEMBER: if ( trim($in["uid"]) == '' && trim($in["family_uid"]) == ''){ $out["error_msg"] = "invalid_upload_call";