From 0234bd615e10a3b84ebbb0f5125e32f2ac7da262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Wed, 19 Jun 2024 10:53:30 +0200 Subject: [PATCH] CIM69 - Update carbrand dropdown and small improvements --- assets/functions.php | 85 ++++++++++++++++++++++++++++++++++++-- cartest.php | 3 +- cartest_manage.php | 19 ++++++++- settings/systemcartest.php | 73 +++++++++++++++++++++++++++++++- 4 files changed, 173 insertions(+), 7 deletions(-) diff --git a/assets/functions.php b/assets/functions.php index be48e54..ac8ea0e 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -1712,6 +1712,82 @@ if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpe //} } } + +//------------------------------------------ +// UPLOAD PICTURE for PRODUCTS +//------------------------------------------ +function uploadrequest($requestid, $request_line_id, $name){ + + $identifier = date('YmdHis'); + $target_dir = dirname(__FILE__)."/images/requests/"; + $input_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); + $imageFileType = strtolower(pathinfo($input_file,PATHINFO_EXTENSION)); + $target_file = $target_dir . $name.'-'.$identifier .'.jpg'; + $file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); + $image_name = $name.'-'.$identifier .'.jpg'; + //Do when JPG or PNG or JPEG or GIF and smaller than 5MB + if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg" || $imageFileType == "gif" || $imageFileType == "png") && $_FILES["fileToUpload"]["size"] < 5000000 && $file_input_check !== false) { + //Upload picture + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { + storeImage($requestid,$request_line_id,$image_name); + } else { + + } + //} + } + } + + function storeImage($requestid, $request_line_id,$image_name){ + + include dirname(__FILE__,2).'/settings/settings.php'; + + $pdo = dbConnect($dbname); + + $sql = 'INSERT INTO images (requestid, request_line_id, image_name) VALUES (?,?,?)'; + $stmt = $pdo->prepare($sql); + $stmt->execute([$requestid, $request_line_id,$image_name]); + } + + //------------------------------------------ + // displayImages + //------------------------------------------ + function displayImages($requestid,$request_type){ + + include dirname(__FILE__,2).'/settings/settings.php'; + + $pdo = dbConnect($dbname); + + switch ($request_type) { + case 'request': + $whereclause = 'requestid = "'.$requestid.'"'; + break; + case 'request_line': + $whereclause = 'request_line_id = "'.$requestid.'"'; + break; + + default: + # code... + break; + } + $sql = 'SELECT * FROM images WHERE '.$whereclause; + $stmt = $pdo->prepare($sql); + $stmt->execute(); + $images = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $output = ''; + + if($images){ + $output .= '
STATE: 0 = DISCONNECTED, 3 = REACTIVATE, 5 = FULL_CONNECT