CIM69 - Pictures
This commit is contained in:
@@ -1716,38 +1716,23 @@ if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpe
|
|||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
// UPLOAD PICTURE for PRODUCTS
|
// UPLOAD PICTURE for PRODUCTS
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
function uploadrequest($requestid, $request_line_id, $name){
|
function uploadrequest($key){
|
||||||
|
$target_dir = dirname(__FILE__)."/images/cartests/";
|
||||||
$identifier = date('YmdHis');
|
$input_file = $target_dir . basename($_FILES["fileToUpload"]["name"][$key]);
|
||||||
$target_dir = dirname(__FILE__)."/images/requests/";
|
|
||||||
$input_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
|
||||||
$imageFileType = strtolower(pathinfo($input_file,PATHINFO_EXTENSION));
|
$imageFileType = strtolower(pathinfo($input_file,PATHINFO_EXTENSION));
|
||||||
$target_file = $target_dir . $name.'-'.$identifier .'.jpg';
|
$file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"][$key]);
|
||||||
$file_input_check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
$location = "./assets/images/cartests/".basename($_FILES["fileToUpload"]["name"][$key]);
|
||||||
$image_name = $name.'-'.$identifier .'.jpg';
|
|
||||||
//Do when JPG or PNG or JPEG or GIF and smaller than 5MB
|
//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) {
|
if(($imageFileType == "jpg" || $imageFileType == "png" || $imageFileType == "jpeg" || $imageFileType == "gif" || $imageFileType == "png") && $_FILES["fileToUpload"]["size"][$key] < 5000000 && $file_input_check !== false) {
|
||||||
//Upload picture
|
//Upload picture
|
||||||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"][$key], $input_file)) {
|
||||||
storeImage($requestid,$request_line_id,$image_name);
|
//ADD FILELOCATION TO POST VARIABLE
|
||||||
|
$_POST['questions'][$key] = $location;
|
||||||
} else {
|
} 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
|
// displayImages
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|||||||
@@ -182,6 +182,10 @@ $view .= '<div class="content-block">
|
|||||||
case 'textarea':
|
case 'textarea':
|
||||||
$view .= '<p>'.((!empty($value) || $value !="")?$value:$not_specified).'</p>';
|
$view .= '<p>'.((!empty($value) || $value !="")?$value:$not_specified).'</p>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'file':
|
||||||
|
$view .= '<p><img src="'.$value.'" width="150px"/></p>';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,14 @@ if (isset($_GET['rowID'])) {
|
|||||||
|
|
||||||
if ($update_allowed === 1){
|
if ($update_allowed === 1){
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
//ARRAY convert to JSON
|
//UPLOAD ALL PICTURES
|
||||||
|
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
|
||||||
|
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
|
||||||
|
if($value !='' || !empty($value)){
|
||||||
|
uploadrequest($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ARRAY convert to JSON
|
||||||
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
||||||
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
@@ -113,6 +120,13 @@ if (isset($_GET['rowID'])) {
|
|||||||
} else {
|
} else {
|
||||||
// Create a new equipment
|
// Create a new equipment
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
|
//UPLOAD ALL PICTURES
|
||||||
|
foreach ($_FILES["fileToUpload"]["name"] as $key => $value){
|
||||||
|
//ONLY UPDATE PICTURES IF SOMETHING IS RETURNED
|
||||||
|
if($value !='' || !empty($value)){
|
||||||
|
uploadrequest($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
//ARRAY convert to JSON
|
//ARRAY convert to JSON
|
||||||
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
$_POST['header'] = json_encode($_POST['header'], JSON_UNESCAPED_UNICODE);
|
||||||
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
$_POST['questions'] = json_encode($_POST['questions'], JSON_UNESCAPED_UNICODE);
|
||||||
@@ -152,7 +166,7 @@ $carbrands_input .= '</datalist>';
|
|||||||
template_header('Cartesttool', 'cartesttool','manage');
|
template_header('Cartesttool', 'cartesttool','manage');
|
||||||
|
|
||||||
$view ='
|
$view ='
|
||||||
<form action="" method="post">
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||||
<h2 class="responsive-width-100"><?=$page?>'.$cartest_h2.'</h2>
|
<h2 class="responsive-width-100"><?=$page?>'.$cartest_h2.'</h2>
|
||||||
<a href="'.$url .'" class="btn alt mar-right-2">'.$button_cancel.'</a>
|
<a href="'.$url .'" class="btn alt mar-right-2">'.$button_cancel.'</a>
|
||||||
@@ -253,9 +267,21 @@ foreach($arrayQuestions_cartest as $group){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
$view .= '<label for="" id="'.$question['QuestionID'].']">'.$question['Question'].'</label>';
|
$view .= '<label for="" id="'.$question['QuestionID'].'">'.$question['Question'].'</label>';
|
||||||
$view .= '<textarea id="QuestionID" name="questions['.$question['QuestionID'].']" placeholder="">'.(isset($cartest['questions'][$question['QuestionID']])?$cartest['questions'][$question['QuestionID']]:'').'</textarea>';
|
$view .= '<textarea id="QuestionID" name="questions['.$question['QuestionID'].']" placeholder="">'.(isset($cartest['questions'][$question['QuestionID']])?$cartest['questions'][$question['QuestionID']]:'').'</textarea>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'file';
|
||||||
|
$view .= '<label for="" id="">'.$question['Question'].'</label>';
|
||||||
|
|
||||||
|
if ($question['QuestionID'] !=''){
|
||||||
|
$view .= '<input type="hidden" name="questions['.$question['QuestionID'].']" value="'.$cartest['questions'][$question['QuestionID']].'" />
|
||||||
|
<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;"><img id="'.$question['QuestionID'].'" src="'.$cartest['questions'][$question['QuestionID']].'" width="150px"/>';
|
||||||
|
} else {
|
||||||
|
$view .= '<input type="file" name="fileToUpload['.$question['QuestionID'].']" onchange="preview('.$question['QuestionID'].')" style="width: 30%;padding: 50px 0 0 0;height: 10px;" required><img id="'.$question['QuestionID'].'" src="" width="150px"/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$view .= ' </div>
|
$view .= ' </div>
|
||||||
@@ -334,6 +360,11 @@ echo '
|
|||||||
display = document.querySelector(\'#time\');
|
display = document.querySelector(\'#time\');
|
||||||
startTimer(startMinute, display);
|
startTimer(startMinute, display);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function preview(id) {
|
||||||
|
id.src=URL.createObjectURL(event.target.files[0]);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ $arrayQuestions_cartest = array(
|
|||||||
"Group_sequence" => '5',
|
"Group_sequence" => '5',
|
||||||
"Questions_in_group" => array(
|
"Questions_in_group" => array(
|
||||||
array("Question_sequence" => '1',"QuestionID" => "cartest_18","Question" => $cartest_18, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
array("Question_sequence" => '1',"QuestionID" => "cartest_18","Question" => $cartest_18, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||||
array("Question_sequence" => '2',"QuestionID" => "cartest_19","Question" => $cartest_19, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
array("Question_sequence" => '2',"QuestionID" => "cartest_19","Question" => $cartest_19, "Type" => 'file', "Response" => $allowedResponse_1),
|
||||||
array("Question_sequence" => '3',"QuestionID" => "cartest_20","Question" => $cartest_20, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
array("Question_sequence" => '3',"QuestionID" => "cartest_20","Question" => $cartest_20, "Type" => 'file', "Response" => $allowedResponse_1),
|
||||||
array("Question_sequence" => '4',"QuestionID" => "cartest_21","Question" => $cartest_21, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
array("Question_sequence" => '4',"QuestionID" => "cartest_21","Question" => $cartest_21, "Type" => 'dropdown', "Response" => $allowedResponse_1),
|
||||||
array("Question_sequence" => '5',"QuestionID" => "cartest_22","Question" => $cartest_22, "Type" => 'dropdown', "Response" => $allowedResponse_1)
|
array("Question_sequence" => '5',"QuestionID" => "cartest_22","Question" => $cartest_22, "Type" => 'file', "Response" => $allowedResponse_1)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array("Group" => $cartest_header_6,
|
array("Group" => $cartest_header_6,
|
||||||
|
|||||||
Reference in New Issue
Block a user