-
Notifications
You must be signed in to change notification settings - Fork 0
/
edt_comp.php
114 lines (110 loc) · 5.1 KB
/
edt_comp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php include_once 'config.php'; ?>
<?php include_once 'security.php'; ?>
<?php include_once 'operations/edt_comp_op.php'; ?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<?php include_once 'include/header.php'; ?>
</head>
<body id="body">
<!-- sidebar -->
<?php include_once 'include/slider.php'; ?>
<!-- end sidebar-->
<!-- navbar Start -->
<?php include_once 'include/navbar.php'; ?>
<!-- navbar End -->
<div class="page-wrapper">
<div class="page-content-tab">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-sm-6"></div>
<div class="col-md-6 col-sm-6">
<div class="card mt-5">
<h2 class="" style="text-align: center;">Update Company</h2>
<form class="p-4" action="" method="POST" enctype="multipart/form-data" name="update_company_form" onsubmit="return validateForm()">
<input type="hidden" name="old_image" value="<?php echo $comp_data['logo'] ?>">
<div class="row">
<div class="col-md-12">
<div class="mb-3">
<label for="company_name">Company Name</label>
<input class="form-control" type="text" name="company_name" value="<?php echo $comp_data['name'] ?>" id="company_name" disabled>
</div>
</div>
<div class="col-md-12">
<div class="mb-3">
<label for="company_email">Comapny Email</label>
<input class="form-control" type="email" name="company_email" value="<?php echo $comp_data['email'] ?>" id="company_email">
</div>
</div>
<div class="col-md-12">
<div class="mb-3">
<label for="company_logo">Company Logo</label>
<input class="form-control" type="file" name="company_logo" id="company_logo">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-end">
<button type="submit" name="add_company" class="btn btn-warning px-4">Update Company</button>
</div>
</div>
</form>
</div><!--end card-->
</div><!--end col-->
<div class="col-md-3 col-sm-6"></div>
</div><!--end row-->
</div><!-- container -->
</div> <!-- end page content -->
</div><!-- end page-wrapper -->
<!-- Scripting -->
<?php include_once 'include/footer.php'; ?>
<!-- end Scripting-->
</body>
<script>
function validateForm() {
var cemail = document.forms["update_company_form"]["company_email"].value;
var clogo = document.getElementById('company_logo');
if (cemail == "") {
Swal.fire({
position: 'top-end',
icon: 'warning',
title: 'Company Email must be filled out',
text: 'Please check the following',
timer: 2500
});
return false;
}
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(cemail)){
Swal.fire({
position: 'top-end',
icon: 'warning',
title: 'Invalid Email',
text: 'Please check the following',
timer: 2500
});
return false;
}
var file = clogo.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var image = new Image();
image.src = e.target.result;
image.onload = function() {
if (image.width < 100 || image.height < 100) {
Swal.fire({
position: 'top-end',
icon: 'warning',
title: 'Logo size must be at least 100x100 pixels',
text: 'Please check the following',
timer: 2500
});
return false;
}
document.forms["add_company_form"]['add_company'].submit();
};
};
reader.readAsDataURL(file);
}
</script>
</html>