Latest Changes: Venkateshwaran

This commit is contained in:
venkathraman786 2023-05-13 00:50:13 -05:00
parent 9ac354318c
commit ebe1f95426
86 changed files with 719 additions and 884 deletions

51
.gitignore vendored
View File

@ -1,50 +1 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
dist/
# Compiled Java class files
*.class
# Compiled Python bytecode
*.py[cod]
# Log files
*.log
# Package files
*.jar
# Maven
target/
dist/
# JetBrains IDE
.idea/
# Unit test reports
TEST*.xml
# Generated by MacOS
.DS_Store
# Generated by Windows
Thumbs.db
# Applications
*.app
*.exe
*.war
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
/vendor

View File

@ -28,11 +28,9 @@ class CompanyController extends CI_Controller{
public function addcompany(){
if($this->input->post('submit')){
print_r($this->input->post());die();
$config = array(
'file_name'=>time(),
@ -77,6 +75,7 @@ class CompanyController extends CI_Controller{
$branch['comp_id'] = $id;
$branch['branch_name']= $this->input->post('branch_name')[$i];
$branch['branch_address'] = $this->input->post('address')[$i];
$branch['maplink'] = $this->input->post('maplink')[$i];
// echo '<pre>'; print_r($branch); die();
@ -171,7 +170,6 @@ class CompanyController extends CI_Controller{
// print_r($this->input->post('new_branch_name'));die();
for($i=0;$i<$count;$i++)
{
// echo $this->input->post('branch_id')[$i];die();
$id = $this->input->post('branch_id')[$i];
$branch['branch_name']= $this->input->post('branch_name')[$i];
$branch['branch_address'] = $this->input->post('address')[$i];
@ -180,9 +178,10 @@ class CompanyController extends CI_Controller{
// echo '<pre>'; echo $id; print_r($branch); die();
$this->CompanyModel->updatebranches($branch, $id);
}
// $count1 = count($this->input->post('new_branch_name'));
if ($this->input->post('new_branch_name')) {
$count1 = count($this->input->post('new_branch_name'));
for($i=0;$i<$count1;$i++) {
@ -196,7 +195,7 @@ class CompanyController extends CI_Controller{
$result=$this->CompanyModel->branches($branch);
}
}
}
$this->session->set_flashdata('status', '"'. $company['comp_name'] .'" -Company Updated Sucessfully');
redirect('CompanyController/companylist');

View File

@ -55,7 +55,7 @@ public function addemp()
/* 'max_width'=>'300',
'max_height'=>'300', */
'max_size'=>'2048',
'allowed_types' => "jpg|png",
'allowed_types' => "jpg|png|jpeg",
'upload_path'=>'./uploads/'
);
@ -147,7 +147,7 @@ public function addemp()
'overwrite'=>TRUE,
/* 'max_width'=>'300',
'max_height'=>'300', */
'max_size'=>'2048',
/* 'max_size'=>'2048', */
'allowed_types' => "jpg|png|jpeg",
'upload_path'=>'./uploads/'
@ -214,13 +214,15 @@ public function addemp()
$result['view'] = $this->EmployeeModel->viewEmployee($id);
if ($result['view'] == '') {
echo '<center><h2>User information not avaiable<h2><center>';
// echo '<center><h2>User information not avaiable<h2><center>';
$this->load->view('nouserinfo');
} else {
$this->load->view('EmpPreview', $result);
}
}
else {
echo '<center><h2>User information not avaiable<h2><center>';
// echo '<center><h2>User information not avaiable<h2><center>';
$this->load->view('nouserinfo');
}
@ -232,7 +234,8 @@ public function addemp()
{
$result['view'] = $this->EmployeeModel->viewEmployee($id);
if ($result['view'] == '') {
echo '<center><h2>User information not avaiable<h2><center>';
// echo '<center><h2>User information not avaiable<h2><center>';
$this->load->view('nouserinfo');
} else {
$this->load->view('EmpIDCard', $result);
}
@ -362,30 +365,5 @@ public function deleteEmp()
$this->db->update('employees');
redirect( 'EmployeeController/DisableEmployeeList' );
}
public function check_emp_code()
{
if($this->input->post('emp_code'))
{
$data = $this->EmployeeModel->check_code_exist($this->input->post('emp_code'));
if ($data)
{
echo true;
}
else
{
echo false;
}
}
}
}
?>

View File

@ -74,14 +74,14 @@ class LoginController extends CI_Controller
else{
if ($user && $password == $user->password)
if ($user && password_verify($password, $user->password))
{
$this->session->set_userdata('user_id', $user->email);
redirect('Dashboard');
}
else
{
$this->session->set_userdata('user_id', $user->email);
$this->session->set_flashdata('username', $this->input->post('email'));
$this->session->set_flashdata('password', $this->input->post('password'));
$this->session->set_flashdata('pass',"Invalid Password");
$this->load->view('login');

View File

@ -69,17 +69,6 @@ return $query->result();
}
public function check_code_exist($id)
{
$this->db->select();
$this->db->from('employees');
$this->db->where('emp_code', $id);
$this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result_array();
return $query;
}
public function updateemp($employee, $id){

View File

@ -81,7 +81,7 @@ $('#empidErr').hide();
data:{ empid:empid},
success:function(response)
{
alert(response)
// alert(response)
if (response == true)
{
$('#empidErr').show();
@ -392,7 +392,7 @@ $(document).ready(function() {
$('#empid').on('change', function() {
if ($('#empid').val().length == 0) {
alert($('#empid').val().length)
// alert($('#empid').val().length)
$('#empidErr').html('Please Enter a Employee Code.');
} else {
$('#empidErr').html();

View File

@ -37,8 +37,7 @@
<thead>
<tr>
<th class="disableSort">Emp ID</th>
<th class="disableSort">Name</th>
<th class="disableSort">Email</th>
<th class="disableSort">Name</th>
<th class="disableSort">Mobile</th>
<th class="disableSort">Company</th>
<th class="disableSort">Branch</th>
@ -55,8 +54,7 @@
?>
<tr>
<td><?php echo $row['emp_code']; ?></td>
<td><?php echo $row['emp_name']; ?></td>
<td><?php echo $row['emp_email']; ?></td>
<td><?php echo $row['emp_name']; ?></td>
<td><?php echo $row['emp_mobile']; ?></td>
<td><?php echo $row['comp_name']; ?></td>
<td><?php echo $row['branch_name']; ?></td>

View File

@ -52,7 +52,7 @@
<div class="col-sm-6">
<label>Company Name<span class="error">*</span></label>
<select name='comp_id' class="ct" required >
<option value="<?php echo $row->comp_id; ?>" ><?php echo $row->comp_name; ?></option>
<option id="name_" value="<?php echo $row->comp_id; ?>" style="display: none;"><?php echo $row->comp_name; ?></option>
<?php foreach($get_comp as $comp_name)
{
?>
@ -145,6 +145,36 @@ $('#empidErr').hide();
});
}
$(document).ready(function() {
var comp_id = $('#name_').val();
if (comp_id != '') {
$.ajax({
url: '<?php echo base_url('EmployeeController/get_branch'); ?>',
type: 'post',
data: {comp_id: comp_id},
dataType: 'json',
success: function(response) {
console.log(response)
var len = response.length;
// $('.st').empty();
var arr = [];
for (var i = 0; i < len; i++) {
var branch_name = response[i]['branch_name'];
var branch_id = response[i]['branch_id'];
data = "<option value='"+branch_id+"'>"+branch_name+"</option>";
arr.push(data);
}
$('.st').html(arr);
$(".st").val(<?php echo $row->branch_id; ?>);
}
});
} else {
$('.ct').empty();
$('.ct').append("<option value=''> Select city </option>");
}""
});
$(document).ready(function() {
$('.ct').change(function() {
@ -169,6 +199,7 @@ $(document).ready(function() {
arr.push(data);
}
$('.st').html(arr);
// $('.st').html('arr');
}
});
} else {

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2, user-scalable=yes">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?php echo base_url('assets/style.css'); ?>">
</head>
<body>
@ -33,7 +33,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Whatsapp-icon.png">
</div>
<div class="details">
<a href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank"><?php echo $view->emp_mobile; ?></a>
<a href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank"><?php echo $view->emp_mobile; ?></a>
</div>
</div>
<div class="employee-email">
@ -41,7 +41,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Email-icon.png">
</div>
<div class="details">
<a href="mailto:<?php echo $view->emp_email; ?>" target="_blank"><?php echo $view->emp_email; ?></a>
<a href="mailto:<?php echo $view->emp_email; ?>" target="_top"><?php echo $view->emp_email; ?></a>
</div>
</div>
<div class="employee-website">
@ -49,7 +49,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Website-Icon.png">
</div>
<div class="details">
<a href="<?php echo $view->comp_web; ?>" target="_blank"><?php echo $view->comp_web; ?></a>
<a href="<?php echo $view->comp_web; ?>" target="_blank"><?php echo preg_replace('~^https?://~', '', $view->comp_web); ?></a>
</div>
</div>
<div class="employee-address">
@ -57,7 +57,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Location-Icon.png">
</div>
<div class="details">
<?php echo $view->branch_address; ?>
<a href="<?php echo $view->maplink; ?>" target="_blank"><?php echo $view->branch_address; ?></a>
</div>
</div>
<div class="emp-btn">
@ -84,8 +84,6 @@ function siteURL() {
$domainName = $_SERVER['HTTP_HOST'];
return $protocol;
}
document.querySelector('#shareBtn')
.addEventListener('click', event => {
@ -94,7 +92,6 @@ function siteURL() {
// available
if (navigator.share) {
navigator.share({
// Title that occurs over
// web share dialog
title: 'GeeksForGeeks',
@ -134,10 +131,5 @@ function siteURL() {
}
})
</script>
</body>
</html>

View File

@ -17,7 +17,7 @@
<body>
<!-- Header -->
<?php include 'includes/header.php' ?>
<section class="p-4">
<section class="p-4 emppreview">
<div class="container">
<div class="row mb-4">
<div class="col-sm-6">
@ -53,7 +53,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Whatsapp-icon.png">
</div>
<div class="details">
<?php echo $view->emp_mobile; ?>
<a href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank"><?php echo $view->emp_mobile; ?></a>
</div>
</div>
<div class="employee-email">
@ -61,7 +61,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Email-icon.png">
</div>
<div class="details">
<?php echo $view->emp_email; ?>
<a href="mailto:<?php echo $view->emp_email; ?>" target="_top"><?php echo $view->emp_email; ?></a>
</div>
</div>
<div class="employee-website">
@ -69,7 +69,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Website-Icon.png">
</div>
<div class="details">
<?php echo preg_replace('~^https?://~', '', $view->comp_web); ?>
<a href="<?php echo $view->comp_web; ?>" target="_blank"><?php echo preg_replace('~^https?://~', '', $view->comp_web); ?></a>
</div>
</div>
<div class="employee-address">
@ -77,7 +77,7 @@
<img src="<?php echo base_url(); ?>/assets/images/Location-Icon.png">
</div>
<div class="details">
<?php echo $view->branch_address; ?>
<a href="<?php echo $view->maplink; ?>" target="_blank"><?php echo $view->branch_address; ?></a>
</div>
</div>
<!-- <div class="emp-btn">
@ -102,7 +102,7 @@
use chillerlan\QRCode\QROptions;
$qrcode = new QRCode;
$data = base_url().'empvcard/'.md5($view->emp_id);
$data = base_url().'empvcard/'.$view->emp_code;
?>

View File

@ -17,7 +17,7 @@
<?php include 'includes/header.php' ?>
<!-- Employee List Section -->
<section>
<section class="deactivated-employees-list">
<div class="container">
<div class="box">
<br>
@ -101,6 +101,7 @@
disable: ["last"],
appendFilterby: true,
debug: true,
stateSave: true,
vocabulary: {
voc_filter_by: 'Filter By',
voc_type_here_filter: 'Filter...',

View File

@ -56,10 +56,12 @@
<div class="col-sm-6">
<label>Company Logo<span id="logoErr" class="error">*</span></label>
<label>Company Logo<span id="" class="error">*</span></label>
<input type="file" accept="image/png, image/jpg" name="comp_logo" id="uploadImage" onchange="PreviewImage();" class="text-center center-block file-upload" required>
<input type="file" accept="image/png, image/jpg" name="comp_logo" id="uploadImage" onchange="PreviewImage();" class="text-center center-block file-upload" required>
<div class="mt-2" style="color:#c73200;">(UploadSize: Below 1MB/ Type: PNG Only)</div>
<span id="logoErr" class="error"></span>
</div>
@ -82,7 +84,7 @@
<label>Company Website<span class="error">*</span></label>
<input type="url" id="companyWebsite" name="comp_web" required/>
<input type="url" id="companyWebsite" name="comp_web" placeholder="eg: https://google.com" required/>
<span id="companyWebsiteError" class="error"></span>
@ -111,18 +113,13 @@
<label>Google Map Link<span class="error">*</span></label>
<input type="url" id="maplink" name="maplink[]" required/>
<input type="url" id="maplink" name="maplink[]" placeholder="Enter Google Map Share Link" required/>
<span id="maplinkError" class="error"></span>
</div>
<div class="col-sm-1">
<button type="button" id="add-button" class="border-0"><i class="fa fa-plus-square"></i></button>
</div>
</div>
@ -130,6 +127,12 @@
<!-- division for add text fields -->
<div id="fields-container"><div class="field-pair"></div></div>
<div class="col-sm-1">
<button type="button" id="add-button" class="border-0"><i class="fa fa-plus-square"></i></button>
</div>
<div class="row text-center">
<input type="submit" id="submitButton" name=submit value="Submit" class="blue-btn submit-btn m-auto">
</div>
@ -182,7 +185,9 @@
input3.type = "url";
input3.name = "maplink[]";
input3.name = "maplink[]";
input3.placeholder = "Enter Google Map Share Link";
input3.required = true;
@ -251,13 +256,21 @@ function PreviewImage() {
<script>
$('#submitButton').on('click', function() {
var uploadImage = $('#uploadImage').val();
if (uploadImage == '') {
$('#logoErr').text('Upload Image');
} else {
$('#logoErr').text('');
}
})
$(document).ready(function() {
$('#uploadImage').on('keyup', function() {
$('#uploadImage').on('change', function() {
var uploadImage = $('#uploadImage').val();
if (uploadImage == '') {
@ -351,7 +364,7 @@ function PreviewImage() {
if (maplink == '') {
$('#maplinkError').text('Enter Google Map Link');
$('#maplinkError').text('Enter Google Map Share Link');
} else {

View File

@ -1,69 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Change Password</title>
<style type="text/css">
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
text-align: center;
margin-top: 50px;
}
form {
max-width: 500px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
input[type="email"],
input[type="password"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-size: 16px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<form method="post" action="<?php echo base_url('LoginController/updatepass'); ?>">
<div>
<label for="old_password">Old Password:</label>
<input type="password" id="old_password" name="old_password" required>
</div>
<div>
<label for="new_password">New Password:</label>
<input type="password" id="new_password" maxlength="10" name="new_password" required>
</div>
<div>
<label for="confirm_password">Confirm New Password:</label>
<input type="password" id="confirm_password" maxlength="10" name="confirm_password" required>
</div>
<input type="submit" value="Change Password">
</form>
</body>
</html>

View File

@ -1,93 +1,58 @@
<!DOCTYPE html>
<html>
<html lang="en-US">
<head>
<title>Change Password</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Change Password</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<style type="text/css">
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
text-align: center;
margin-top: 50px;
}
form {
max-width: 500px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
input[type="email"],
input[type="text"],
input[type="password"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-size: 16px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
.field-icon {
float: right;
margin-left: -25px;
margin-top: -45px;
margin-right: 10px;
position: relative;
z-index: 3;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap" rel="stylesheet">
<link href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/fontawesome/css/all.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/style.css'); ?>" rel="stylesheet">
<script src="<?php echo base_url('assets/bootstrap/js/bootstrap.bundle.min.js'); ?>"></script>
</head>
<body>
<form method="post" action="<?php echo base_url('LoginController/updatepass'); ?>">
<div>
<label for="old_password">Old Password:</label>
<input class="form-control" type="password" id="old_password" name="old_password" required>
<span id='message1' style="color:red"><?php echo $this->session->flashdata('error'); ?></span>
<span toggle="#old_password" id="toggle-password" class="fa fa-fw fa-eye field-icon toggle-password"></span>
<!-- <span id='message1'></span> -->
</div>
<div>
<label for="new_password">New Password:</label>
<input class="form-control" type="password" id="new_password" maxlength="10" name="new_password" required>
<span toggle="#new_password" id="toggle-password1" class="fa fa-fw fa-eye field-icon toggle-password"></span>
</div>
<div>
<label for="confirm_password">Confirm New Password:</label>
<input class="form-control" type="password" id="confirm_password" maxlength="10" name="confirm_password" required>
<span toggle="#confirm_password" id="toggle-password2" class="fa fa-fw fa-eye field-icon toggle-password"></span>
<span id='message'></span>
</div>
<!-- <input type="submit" value="Change Password"><br> -->
<button type="submit" id="submit" class="btn btn-success">Submit</button>
<!-- Header -->
<?php include 'includes/header.php' ?>
<section class="p-4">
<div class="container">
<div class="row">
<div class="col-sm-6">
<h1 class="heading-style h2">Change Password</h1>
</div>
<div class="col-sm-6 text-end">
<a href="<?php echo base_url('EmployeeController/EmployeeList') ?>" class="blue-btn">Back</a>
</div>
</div>
<form method="post" action="<?php echo base_url('LoginController/updatepass'); ?>" class="form-design" style="max-width:450px;">
<div class="row">
<div class="col-sm-12 show-hide">
<label for="old_password">Old Password<span class="error">*</span></label>
<input class="form-control" type="password" id="old_password" maxlength="18" name="old_password" required>
<span toggle="#old_password" id="toggle-password" class="fa fa-fw fa-eye field-icon toggle-password"></span>
<span id='message1' style="color:red"><?php echo $this->session->flashdata('error'); ?></span>
</div>
<div class="col-sm-12 show-hide">
<label for="new_password">New Password<span class="error">*</span></label>
<input class="form-control" type="password" id="new_password" maxlength="18" name="new_password" required>
<span toggle="#new_password" id="toggle-password1" class="fa fa-fw fa-eye field-icon toggle-password"></span>
</div>
<div class="col-sm-12 show-hide">
<label for="confirm_password">Confirm New Password<span class="error">*</span></label>
<input class="form-control" type="password" id="confirm_password" maxlength="18" name="confirm_password" required>
<span toggle="#confirm_password" id="toggle-password2" class="fa fa-fw fa-eye field-icon toggle-password"></span>
<span id='message'></span>
</div>
<div class="col-sm-12 text-center mt-3">
<button type="submit" id="submit" class="blue-btn submit-btn m-auto">Submit</button>
</div>
</div>
</form>
<button><a href="<?php echo base_url('EmployeeController/EmployeeList') ?>" class="blue-btn">Back</a></button>
</div>
</section>
<script>
$("#toggle-password").click(function() {
// alert("sdvs")
$(this).toggleClass("fa-eye fa-eye-slash");
@ -143,7 +108,7 @@ $('#new_password, #confirm_password').on('keyup', function () {
$('#message').html('Not Matching').css('color', 'red');
});
</script>
<!-- Footer -->
<?php include 'includes/footer.php' ?>
</body>
</html>

View File

@ -16,7 +16,7 @@
<body>
<!-- Header -->
<?php include 'includes/header.php' ?>
<section>
<section class="deactivated-employees-list">
<div class="container">
<div class="box"><br>
<?php if($this->session->flashdata('status'));?>
@ -80,6 +80,7 @@
firstSort: false,
appendFilterby: true,
debug: true,
stateSave: true,
vocabulary: {
voc_filter_by: 'Filter By',
voc_type_here_filter: 'Filter...',

View File

@ -43,17 +43,20 @@
<div class="col-sm-6">
<label>Upload Photo<span class="error">*</span></label>
<input type="file" accept="image/png" name="comp_logo" value="Company Logo" id="uploadImage" onchange="PreviewImage();" class="text-center center-block file-upload" ><div class="mt-2" style="color:#c73200;">(UploadSize: Below 1MB/ Type: PNG Only)</div>
<span id="comp_logo_err" class="error"></span>
</div>
<div class="col-sm-6">
<img src="<?php echo base_url(); ?>/uploads/<?php echo $row->comp_logo; ?>" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"><br><br>
</div>
<div class="col-sm-6">
<label>Company Name<span class="error">*</span></label>
<input type="text" name="comp_name" placeholder="Company Name" value="<?php echo $row->comp_name; ?>" required>
<input type="text" id="comp_name" name="comp_name" placeholder="Company Name" value="<?php echo $row->comp_name; ?>" required>
<span id="comp_name_err" class="error"></span>
</div>
<div class="col-sm-6">
<label>Company Website<span class="error">*</span></label>
<input type="url" name="comp_web" placeholder="Company Website" value="<?php echo $row->comp_web; ?>" required >
<input type="url" id="comp_web" name="comp_web" placeholder="eg: https://google.com" value="<?php echo $row->comp_web; ?>" required />
<span id="comp_web_err" class="error"></span>
</div>
</div>
@ -67,29 +70,35 @@
<div class="row align-items-center">
<div class="col-sm-11">
<label>Branch Name<span class="error">*</span></label>
<input type="text" name="branch_name[]" placeholder="Branch Name" value="<?php echo $row->branch_name; ?>" required>
<input type="text" id="<?= $key ?>" name="branch_name[]" placeholder="Branch Name" value="<?php echo $row->branch_name; ?>" required>
<span id="<?= $key.'name' ?>" class="error"></span>
<label>Branch Address<span class="error">*</span></label>
<input type="text" name="address[]" placeholder="Address" value="<?php echo $row->branch_address; ?>" required>
<input type="text" id="<?= $key ?>" name="address[]" placeholder="Address" value="<?php echo $row->branch_address; ?>" required>
<span id="<?= $key.'add' ?>" class="error"></span>
<label>Google Map Link<span class="error">*</span></label>
<input type="text" name="maplink[]" placeholder="Google Map Link" value="<?php echo $row->maplink; ?>" required>
<input type="text" id="<?= $key ?>" name="maplink[]" placeholder="Enter Google Map Share Link" value="<?php echo $row->maplink; ?>" required>
<span id="<?= $key.'link' ?>" class="error"></span>
</div>
<div class="col-sm-1">
<!-- <div class="col-sm-1">
<button type="button" id="add-button" class="border-0"><i class="fa fa-plus-square"></i></button>
</div>
</div> -->
</div>
<!-- division for add text fields -->
<div id="fields-container"> <div class="field-pair"></div></div>
<?php
}
} ?>
<div class="col-sm-1">
<button type="button" id="add-button" class="border-0"><i class="fa fa-plus-square"></i></button>
</div>
<?php
}
?>
<div class="row text-center">
<input type="submit" name="update" value="Update" class="blue-btn submit-btn m-auto">
<input type="submit" id="submit" name="update" value="Update" class="blue-btn submit-btn m-auto">
</div>
</form>
@ -104,6 +113,58 @@
</div>
</section>
<script>
$('#submit').click(function() {
if ($('#uploadImage').val() == '') {
$("#comp_logo_err").html('*Input required')
}
else{
$(`#${this.id}name`).html('')
}
if ($('#comp_name').val() == '') {
$("#comp_name_err").html('*Input required')
}
else{
$("#comp_name_err").html('')
}
if ($('#comp_web').val() == '') {
$("#comp_web_err").html('*Input required')
}
else{
$("#comp_web_err").html('')
}
if ($('#branch_name').val() == '') {
$("#branch_name_err").html('*Input required')
}
else{
$("#branch_name_err").html('')
}
$("input[name^='branch_name']").each(function () {
if ($(this).val() == '') {
$(`#${this.id}name`).html('*Input required')
}
else{
$(`#${this.id}name`).html('')
}
})
$("input[name^='address']").each(function () {
if ($(this).val() == '') {
$(`#${this.id}add`).html('*Input required')
}
else{
$(`#${this.id}add`).html('')
}
})
$("input[name^='maplink']").each(function () {
if ($(this).val() == '') {
$(`#${this.id}link`).html('*Input required')
}
else{
$(`#${this.id}link`).html('')
}
})
});
// add event listener to "Add" button
document.getElementById("add-button").addEventListener("click", function() {
// create new field pair element
@ -133,7 +194,8 @@
var input3 = document.createElement("input");
input3.type = "url";
input3.name = "new_maplink[]";
input3.name = "new_maplink[]";
input3.placeholder = "Enter Google Map Share Link";
input3.required = true;
var removeButton = document.createElement("button");

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Employee ID-Card</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2, user-scalable=yes">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500&display=swap" rel="stylesheet">
<link href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css'); ?>" rel="stylesheet">
<link rel="stylesheet" href="<?php echo base_url('assets/style.css'); ?>">
</head>
<body>
<section class="d-flex align-items-center justify-content-center vh-100">
<div class="container">
<h2 class="text-center">User information not available</h2>
</div>
</section>
</body>
</html>

View File

@ -89,7 +89,7 @@ img{
}
.custom-table tbody {
display:block;
max-height:405px;
height:405px;
overflow-y:auto;
}
.custom-table thead, .custom-table tbody tr {
@ -172,7 +172,7 @@ background-color: #f5f5f5;
.error{
color:red;
}
input[type="text"], input[type="tel"], input[type="email"], input[type="password"], select{
input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="url"], select{
background:#e3e3e3;
color:#000;
padding:5px 10px;
@ -212,14 +212,18 @@ input[type="text"], input[type="tel"], input[type="email"], input[type="password
/*Employee Preview*/
.idcard-section{
max-width:500px;
max-width:450px;
margin:0 auto;
padding:10px;
position: relative;
}
.idcard-section .employee-name, .idcard-section .designation, .idcard-section .company-name, .employee-details .details, .emp-btn button{
font-family:'Monserrat',sans-serif;
font-weight:600;
.idcard-section .employee-name, .idcard-section .designation, .idcard-section .company-name{
font-family:'Montserrat',sans-serif;
font-weight:700;
}
.employee-details .details, .emp-btn button{
font-family:'Montserrat',sans-serif;
font-weight:500;
}
.emp-btn button a{
color:#ffffff;
@ -250,8 +254,9 @@ input[type="text"], input[type="tel"], input[type="email"], input[type="password
max-width:150px;
height:150px;
margin:30px auto 0 auto;
padding:5px 5px 0;
padding:3px 3px 0;
background: linear-gradient(to right, #2d7baa,#80bc42,#e5692f);
overflow: hidden;
}
.profile-photo img{
border-radius:50%;
@ -260,22 +265,22 @@ input[type="text"], input[type="tel"], input[type="email"], input[type="password
text-align:center;
}
.company-logo img{
width:140px;
height:50px;
}
.employee-name, .designation, .company-name{
text-align:center;
text-transform:capitalize;
}
.employee-name{
font-size:31px;
margin:20px 0 10px;
font-size:26px;
margin:15px 0 0;
}
.designation{
font-size:21px;
margin-bottom:10px;
font-size:20px;
margin:5px 0;
}
.company-name{
font-size:21px;
font-size:19px;
}
.employee-details{
margin:30px auto 0 auto;
@ -285,26 +290,30 @@ input[type="text"], input[type="tel"], input[type="email"], input[type="password
.employee-details>div{
display:flex;
align-items:center;
margin-bottom:15px;
margin-bottom:13px;
}
.employee-details .icon{
width:50px;
width:35px;
line-height:10px;
}
.employee-details .details{
flex-basis:90%;
max-width:90%;
font-size:16px;
line-height:27px;
font-size:14px;
line-height:20px;
}
.employee-details .employee-address img{
width:34px;
.employee-details .details a{
text-decoration:none;
color:#858585;
}
.employee-details .details a:hover{
color:#e5692f;
}
.employee-details img{
width:28px;
width:22px;
}
.employee-details .employee-website img{
width:30px;
.employee-details .icon img {
width:17px;
}
.emp-btn{
justify-content: space-between;
@ -392,6 +401,21 @@ input[type="text"], input[type="tel"], input[type="email"], input[type="password
.deactivated-employees-list .blue-btn{
margin:0;
}
.emplive-view .profile-photo{
height: 155px!important;;
.show-hide{
position: relative;
}
.show-hide #toggle-password, .show-hide #toggle-password1, .show-hide #toggle-password2{
right: 25px;
position: absolute;
top: 55px;
}
.deactivate-btn a:hover{
color: #60bf00!important;
}
.deactivate-btn a.delete:hover{
color: #bf0d00!important;
}
.emppreview .idcard-section .designation{
margin:0!important;
}

View File

@ -32,6 +32,7 @@
]
},
"require-dev": {
"mikey179/vfsstream": "1.6.*",
"phpunit/phpunit": "4.* || 5.* || 9.*"
}
}

98
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3c175b4011b89c5642f16dcbb77cd40d",
"content-hash": "b4d3c065bf64f549bccd1940068aa75c",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -303,26 +303,29 @@
},
{
"name": "endroid/qr-code",
"version": "4.6.1",
"version": "4.8.2",
"source": {
"type": "git",
"url": "https://github.com/endroid/qr-code.git",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/2436c2333a3931c95e2b96eb82f16f53143d6bba",
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba",
"shasum": ""
},
"require": {
"bacon/bacon-qr-code": "^2.0.5",
"php": "^7.4||^8.0"
"php": "^8.0"
},
"conflict": {
"khanamiryan/qrcode-detector-decoder": "^1.0.6"
},
"require-dev": {
"endroid/quality": "dev-master",
"ext-gd": "*",
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
"setasign/fpdf": "^1.8.2"
},
"suggest": {
@ -363,7 +366,7 @@
],
"support": {
"issues": "https://github.com/endroid/qr-code/issues",
"source": "https://github.com/endroid/qr-code/tree/4.6.1"
"source": "https://github.com/endroid/qr-code/tree/4.8.2"
},
"funding": [
{
@ -371,7 +374,7 @@
"type": "github"
}
],
"time": "2022-10-26T08:48:17+00:00"
"time": "2023-03-30T18:46:02+00:00"
},
{
"name": "jeroendesloovere/vcard",
@ -430,30 +433,30 @@
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.5.0",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b"
"reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
"php": "^8.1"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^11",
"doctrine/coding-standard": "^11",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.30 || ^5.4"
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.5.27",
"vimeo/psalm": "^5.4"
},
"type": "library",
"autoload": {
@ -480,7 +483,7 @@
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.5.0"
"source": "https://github.com/doctrine/instantiator/tree/2.0.0"
},
"funding": [
{
@ -496,7 +499,58 @@
"type": "tidelift"
}
],
"time": "2022-12-30T00:15:36+00:00"
"time": "2022-12-30T00:23:10+00:00"
},
{
"name": "mikey179/vfsstream",
"version": "v1.6.11",
"source": {
"type": "git",
"url": "https://github.com/bovigo/vfsStream.git",
"reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bovigo/vfsStream/zipball/17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f",
"reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"autoload": {
"psr-0": {
"org\\bovigo\\vfs\\": "src/main/php"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Frank Kleine",
"homepage": "http://frankkleine.de/",
"role": "Developer"
}
],
"description": "Virtual file system to mock the real file system in unit tests.",
"homepage": "http://vfs.bovigo.org/",
"support": {
"issues": "https://github.com/bovigo/vfsStream/issues",
"source": "https://github.com/bovigo/vfsStream/tree/master",
"wiki": "https://github.com/bovigo/vfsStream/wiki"
},
"time": "2022-02-23T02:02:42+00:00"
},
{
"name": "myclabs/deep-copy",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

BIN
uploads/1683263065.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
uploads/1683613859.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
uploads/1683614792.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
uploads/1683615045.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
uploads/1683615200.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
uploads/1683616017.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
uploads/1683617325.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -42,6 +42,9 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var ?string */
private $vendorDir;
@ -106,6 +109,7 @@ class ClassLoader
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
@ -425,7 +429,8 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
@ -555,18 +560,26 @@ class ClassLoader
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
include $file;
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@ -98,7 +98,7 @@ class InstalledVersions
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
@ -119,7 +119,7 @@ class InstalledVersions
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
@ -328,7 +328,9 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
@ -340,12 +342,17 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}

View File

@ -6,4 +6,5 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'org\\bovigo\\vfs\\' => array($vendorDir . '/mikey179/vfsstream/src/main/php'),
);

View File

@ -33,25 +33,18 @@ class ComposerAutoloaderInit7e4b8f8e605735eb395daae535cbcd83
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire7e4b8f8e605735eb395daae535cbcd83($fileIdentifier, $file);
$filesToLoad = \Composer\Autoload\ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}
/**
* @param string $fileIdentifier
* @param string $file
* @return void
*/
function composerRequire7e4b8f8e605735eb395daae535cbcd83($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}

View File

@ -85,6 +85,16 @@ class ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83
),
);
public static $prefixesPsr0 = array (
'o' =>
array (
'org\\bovigo\\vfs\\' =>
array (
0 => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php',
),
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'PHPUnit\\Exception' => __DIR__ . '/..' . '/phpunit/phpunit/src/Exception.php',
@ -721,6 +731,7 @@ class ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$prefixesPsr0;
$loader->classMap = ComposerStaticInit7e4b8f8e605735eb395daae535cbcd83::$classMap;
}, null, ClassLoader::class);

View File

@ -312,33 +312,33 @@
},
{
"name": "doctrine/instantiator",
"version": "1.5.0",
"version_normalized": "1.5.0.0",
"version": "2.0.0",
"version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b"
"reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b",
"reference": "0a0fa9780f5d4e507415a065172d26a98d02047b",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
"php": "^8.1"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^11",
"doctrine/coding-standard": "^11",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.30 || ^5.4"
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.5.27",
"vimeo/psalm": "^5.4"
},
"time": "2022-12-30T00:15:36+00:00",
"time": "2022-12-30T00:23:10+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -365,7 +365,7 @@
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.5.0"
"source": "https://github.com/doctrine/instantiator/tree/2.0.0"
},
"funding": [
{
@ -385,27 +385,30 @@
},
{
"name": "endroid/qr-code",
"version": "4.6.1",
"version_normalized": "4.6.1.0",
"version": "4.8.2",
"version_normalized": "4.8.2.0",
"source": {
"type": "git",
"url": "https://github.com/endroid/qr-code.git",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184"
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/2436c2333a3931c95e2b96eb82f16f53143d6bba",
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba",
"shasum": ""
},
"require": {
"bacon/bacon-qr-code": "^2.0.5",
"php": "^7.4||^8.0"
"php": "^8.0"
},
"conflict": {
"khanamiryan/qrcode-detector-decoder": "^1.0.6"
},
"require-dev": {
"endroid/quality": "dev-master",
"ext-gd": "*",
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
"setasign/fpdf": "^1.8.2"
},
"suggest": {
@ -414,7 +417,7 @@
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
"setasign/fpdf": "Enables you to use the PDF writer"
},
"time": "2022-10-26T08:48:17+00:00",
"time": "2023-03-30T18:46:02+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -448,7 +451,7 @@
],
"support": {
"issues": "https://github.com/endroid/qr-code/issues",
"source": "https://github.com/endroid/qr-code/tree/4.6.1"
"source": "https://github.com/endroid/qr-code/tree/4.8.2"
},
"funding": [
{
@ -514,6 +517,60 @@
},
"install-path": "../jeroendesloovere/vcard"
},
{
"name": "mikey179/vfsstream",
"version": "v1.6.11",
"version_normalized": "1.6.11.0",
"source": {
"type": "git",
"url": "https://github.com/bovigo/vfsStream.git",
"reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bovigo/vfsStream/zipball/17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f",
"reference": "17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5|^5.0"
},
"time": "2022-02-23T02:02:42+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"org\\bovigo\\vfs\\": "src/main/php"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Frank Kleine",
"homepage": "http://frankkleine.de/",
"role": "Developer"
}
],
"description": "Virtual file system to mock the real file system in unit tests.",
"homepage": "http://vfs.bovigo.org/",
"support": {
"issues": "https://github.com/bovigo/vfsStream/issues",
"source": "https://github.com/bovigo/vfsStream/tree/master",
"wiki": "https://github.com/bovigo/vfsStream/wiki"
},
"install-path": "../mikey179/vfsstream"
},
{
"name": "myclabs/deep-copy",
"version": "1.11.1",
@ -2260,6 +2317,7 @@
"dev": true,
"dev-package-names": [
"doctrine/instantiator",
"mikey179/vfsstream",
"myclabs/deep-copy",
"nikic/php-parser",
"phar-io/manifest",

View File

@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'codeigniter/framework',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'd96cab760b54311d8d842bc021a0d730cf0af37d',
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => NULL,
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -47,9 +47,9 @@
'dev_requirement' => false,
),
'codeigniter/framework' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'd96cab760b54311d8d842bc021a0d730cf0af37d',
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => NULL,
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -65,18 +65,18 @@
'dev_requirement' => false,
),
'doctrine/instantiator' => array(
'pretty_version' => '1.5.0',
'version' => '1.5.0.0',
'reference' => '0a0fa9780f5d4e507415a065172d26a98d02047b',
'pretty_version' => '2.0.0',
'version' => '2.0.0.0',
'reference' => 'c6222283fa3f4ac679f8b9ced9a4e23f163e80d0',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/instantiator',
'aliases' => array(),
'dev_requirement' => true,
),
'endroid/qr-code' => array(
'pretty_version' => '4.6.1',
'version' => '4.6.1.0',
'reference' => 'a75c913b0e4d6ad275e49a2c1de1cacffc6c2184',
'pretty_version' => '4.8.2',
'version' => '4.8.2.0',
'reference' => '2436c2333a3931c95e2b96eb82f16f53143d6bba',
'type' => 'library',
'install_path' => __DIR__ . '/../endroid/qr-code',
'aliases' => array(),
@ -91,6 +91,15 @@
'aliases' => array(),
'dev_requirement' => false,
),
'mikey179/vfsstream' => array(
'pretty_version' => 'v1.6.11',
'version' => '1.6.11.0',
'reference' => '17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f',
'type' => 'library',
'install_path' => __DIR__ . '/../mikey179/vfsstream',
'aliases' => array(),
'dev_requirement' => true,
),
'myclabs/deep-copy' => array(
'pretty_version' => '1.11.1',
'version' => '1.11.1.0',

View File

@ -4,8 +4,8 @@
$issues = array();
if (!(PHP_VERSION_ID >= 70400)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {

View File

@ -16,17 +16,17 @@
}
],
"require": {
"php": "^7.1 || ^8.0"
"php": "^8.1"
},
"require-dev": {
"ext-phar": "*",
"ext-pdo": "*",
"doctrine/coding-standard": "^9 || ^11",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.30 || ^5.4"
"doctrine/coding-standard": "^11",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.5.27",
"vimeo/psalm": "^5.4"
},
"autoload": {
"psr-4": {

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Doctrine\Instantiator\Exception;
use Throwable;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Doctrine\Instantiator\Exception;
use InvalidArgumentException as BaseInvalidArgumentException;
@ -36,7 +38,7 @@ class InvalidArgumentException extends BaseInvalidArgumentException implements E
{
return new self(sprintf(
'The provided class "%s" is abstract, and cannot be instantiated',
$reflectionClass->getName()
$reflectionClass->getName(),
));
}
@ -44,7 +46,7 @@ class InvalidArgumentException extends BaseInvalidArgumentException implements E
{
return new self(sprintf(
'The provided class "%s" is an enum, and cannot be instantiated',
$className
$className,
));
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Doctrine\Instantiator\Exception;
use Exception;
@ -20,15 +22,15 @@ class UnexpectedValueException extends BaseUnexpectedValueException implements E
*/
public static function fromSerializationTriggeredException(
ReflectionClass $reflectionClass,
Exception $exception
Exception $exception,
): self {
return new self(
sprintf(
'An exception was raised while trying to instantiate an instance of "%s" via un-serialization',
$reflectionClass->getName()
$reflectionClass->getName(),
),
0,
$exception
$exception,
);
}
@ -42,7 +44,7 @@ class UnexpectedValueException extends BaseUnexpectedValueException implements E
string $errorString,
int $errorCode,
string $errorFile,
int $errorLine
int $errorLine,
): self {
return new self(
sprintf(
@ -50,10 +52,10 @@ class UnexpectedValueException extends BaseUnexpectedValueException implements E
. 'in file "%s" at line "%d"',
$reflectionClass->getName(),
$errorFile,
$errorLine
$errorLine,
),
0,
new Exception($errorString, $errorCode)
new Exception($errorString, $errorCode),
);
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Doctrine\Instantiator;
use ArrayIterator;
@ -20,8 +22,6 @@ use function sprintf;
use function strlen;
use function unserialize;
use const PHP_VERSION_ID;
final class Instantiator implements InstantiatorInterface
{
/**
@ -31,37 +31,33 @@ final class Instantiator implements InstantiatorInterface
*
* @deprecated This constant will be private in 2.0
*/
public const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C';
/** @deprecated This constant will be private in 2.0 */
public const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O';
private const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C';
private const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O';
/**
* Used to instantiate specific classes, indexed by class name.
*
* @var callable[]
*/
private static $cachedInstantiators = [];
private static array $cachedInstantiators = [];
/**
* Array of objects that can directly be cloned, indexed by class name.
*
* @var object[]
*/
private static $cachedCloneables = [];
private static array $cachedCloneables = [];
/**
* @param string $className
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @throws ExceptionInterface
*
* @template T of object
*/
public function instantiate($className)
public function instantiate(string $className): object
{
if (isset(self::$cachedCloneables[$className])) {
/** @phpstan-var T */
@ -84,12 +80,11 @@ final class Instantiator implements InstantiatorInterface
*
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @template T of object
*/
private function buildAndCacheFromFactory(string $className)
private function buildAndCacheFromFactory(string $className): object
{
$factory = self::$cachedInstantiators[$className] = $this->buildFactory($className);
$instance = $factory();
@ -127,14 +122,12 @@ final class Instantiator implements InstantiatorInterface
'%s:%d:"%s":0:{}',
is_subclass_of($className, Serializable::class) ? self::SERIALIZATION_FORMAT_USE_UNSERIALIZER : self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER,
strlen($className),
$className
$className,
);
$this->checkIfUnSerializationIsSupported($reflectionClass, $serializedString);
return static function () use ($serializedString) {
return unserialize($serializedString);
};
return static fn () => unserialize($serializedString);
}
/**
@ -153,7 +146,7 @@ final class Instantiator implements InstantiatorInterface
throw InvalidArgumentException::fromNonExistingClass($className);
}
if (PHP_VERSION_ID >= 80100 && enum_exists($className, false)) {
if (enum_exists($className, false)) {
throw InvalidArgumentException::fromEnum($className);
}
@ -181,7 +174,7 @@ final class Instantiator implements InstantiatorInterface
$message,
$code,
$file,
$line
$line,
);
return true;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Doctrine\Instantiator;
use Doctrine\Instantiator\Exception\ExceptionInterface;
@ -10,15 +12,13 @@ use Doctrine\Instantiator\Exception\ExceptionInterface;
interface InstantiatorInterface
{
/**
* @param string $className
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @throws ExceptionInterface
*
* @template T of object
*/
public function instantiate($className);
public function instantiate(string $className): object;
}

View File

@ -24,7 +24,7 @@ Use [Composer](https://getcomposer.org/) to install the library. Also make sure
[GD extension](https://www.php.net/manual/en/book.image.php) if you want to generate images.
``` bash
$ composer require endroid/qr-code
composer require endroid/qr-code
```
## Usage: using the builder
@ -113,10 +113,32 @@ $dataUri = $result->getDataUri();
### Writer options
Some writers provide writer options. Each available writer option is can be
found as a constant prefixed with WRITER_OPTION_ in the writer class.
* `PdfWriter`
* `unit`: unit of measurement (default: mm)
* `fpdf`: PDF to place the image in (default: new PDF)
* `x`: image offset (default: 0)
* `y`: image offset (default: 0)
* `PngWriter`
* `compression_level`: compression level (0-9, default: -1 = zlib default)
* `SvgWriter`
* `block_id`: id of the block element for external reference (default: block)
* `exclude_xml_declaration`: exclude XML declaration (default: false)
* `exclude_svg_width_and_height`: exclude width and height (default: false)
* `force_xlink_href`: forces xlink namespace in case of compatibility issues (default: false)
* `WebPWriter`
* `quality`: image quality (0-100, default: 80)
You can provide any writer options like this.
```php
use Endroid\QrCode\Writer\SvgWriter;
$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
$builder->setWriterOptions([
SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true
]);
```
### Encoding

View File

@ -12,15 +12,18 @@
}
],
"require": {
"php": "^7.4||^8.0",
"php": "^8.0",
"bacon/bacon-qr-code": "^2.0.5"
},
"require-dev": {
"ext-gd": "*",
"endroid/quality": "dev-master",
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
"setasign/fpdf": "^1.8.2"
},
"conflict": {
"khanamiryan/qrcode-detector-decoder": "^1.0.6"
},
"suggest": {
"ext-gd": "Enables you to write PNG images",
"khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator",
@ -41,6 +44,9 @@
"sort-packages": true,
"preferred-install": {
"endroid/*": "source"
},
"allow-plugins": {
"endroid/installer": true
}
},
"extra": {

View File

@ -25,7 +25,7 @@ use Endroid\QrCode\Writer\WriterInterface;
class Builder implements BuilderInterface
{
/**
* @var array<mixed>{
* @var array<string, mixed>{
* data: string,
* writer: WriterInterface,
* writerOptions: array,
@ -78,7 +78,7 @@ class Builder implements BuilderInterface
return $this;
}
/** @param array<mixed> $writerOptions */
/** @param array<string, mixed> $writerOptions */
public function writerOptions(array $writerOptions): BuilderInterface
{
$this->options['writerOptions'] = $writerOptions;
@ -243,7 +243,7 @@ class Builder implements BuilderInterface
*
* @return mixed
*/
private function buildObject(string $class, string $optionsPrefix = null)
private function buildObject(string $class, string|null $optionsPrefix = null)
{
/** @var \ReflectionClass<object> $reflectionClass */
$reflectionClass = new \ReflectionClass($class);

View File

@ -20,7 +20,7 @@ interface BuilderInterface
public function writer(WriterInterface $writer): BuilderInterface;
/** @param array<mixed> $writerOptions */
/** @param array<string, mixed> $writerOptions */
public function writerOptions(array $writerOptions): BuilderInterface;
public function data(string $data): BuilderInterface;

View File

@ -6,17 +6,12 @@ namespace Endroid\QrCode\Color;
final class Color implements ColorInterface
{
private int $red;
private int $green;
private int $blue;
private int $alpha;
public function __construct(int $red, int $green, int $blue, int $alpha = 0)
{
$this->red = $red;
$this->green = $green;
$this->blue = $blue;
$this->alpha = $alpha;
public function __construct(
private int $red,
private int $green,
private int $blue,
private int $alpha = 0
) {
}
public function getRed(): int

View File

@ -6,15 +6,12 @@ namespace Endroid\QrCode\Encoding;
final class Encoding implements EncodingInterface
{
private string $value;
public function __construct(string $value)
{
public function __construct(
private string $value
) {
if (!in_array($value, mb_list_encodings())) {
throw new \Exception(sprintf('Invalid encoding "%s"', $value));
}
$this->value = $value;
}
public function __toString(): string

View File

@ -16,11 +16,6 @@ final class ValidationException extends \Exception
return new self(sprintf('Please install "%s" or disable image validation', $packageName));
}
public static function createForIncompatiblePhpVersion(): self
{
return new self('The validator is not compatible with PHP 8 yet, see https://github.com/khanamiryan/php-qrcode-detector-decoder/pull/103');
}
public static function createForInvalidData(string $expectedData, string $actualData): self
{
return new self('The validation reader read "'.$actualData.'" instead of "'.$expectedData.'". Adjust your parameters to increase readability or disable validation.');

View File

@ -8,13 +8,10 @@ use Endroid\QrCode\Label\LabelInterface;
class LabelImageData
{
private int $width;
private int $height;
private function __construct(int $width, int $height)
{
$this->width = $width;
$this->height = $height;
private function __construct(
private int $width,
private int $height
) {
}
public static function createForLabel(LabelInterface $label): self

View File

@ -8,31 +8,14 @@ use Endroid\QrCode\Logo\LogoInterface;
class LogoImageData
{
private string $data;
/** @var mixed */
private $image;
private string $mimeType;
private int $width;
private int $height;
private bool $punchoutBackground;
/** @param mixed $image */
private function __construct(
string $data,
$image,
string $mimeType,
int $width,
int $height,
bool $punchoutBackground
private string $data,
private \GdImage|null $image,
private string $mimeType,
private int $width,
private int $height,
private bool $punchoutBackground
) {
$this->data = $data;
$this->image = $image;
$this->mimeType = $mimeType;
$this->width = $width;
$this->height = $height;
$this->punchoutBackground = $punchoutBackground;
}
public static function createForLogo(LogoInterface $logo): self
@ -89,10 +72,9 @@ class LogoImageData
return $this->data;
}
/** @return mixed */
public function getImage()
public function getImage(): \GdImage
{
if (null === $this->image) {
if (!$this->image instanceof \GdImage) {
throw new \Exception('SVG Images have no image resource');
}
@ -126,10 +108,7 @@ class LogoImageData
private static function detectMimeTypeFromUrl(string $url): string
{
/** @var mixed $format */
$format = PHP_VERSION_ID >= 80000 ? true : 1;
$headers = get_headers($url, $format);
$headers = get_headers($url, true);
if (!is_array($headers) || !isset($headers['Content-Type'])) {
throw new \Exception(sprintf('Content type could not be determined for logo URL "%s"', $url));

View File

@ -6,18 +6,14 @@ namespace Endroid\QrCode\Label\Font;
final class Font implements FontInterface
{
private string $path;
private int $size;
public function __construct(string $path, int $size = 16)
{
$this->validatePath($path);
$this->path = $path;
$this->size = $size;
public function __construct(
private string $path,
private int $size = 16
) {
$this->assertValidPath($path);
}
private function validatePath(string $path): void
private function assertValidPath(string $path): void
{
if (!file_exists($path)) {
throw new \Exception(sprintf('Invalid font path "%s"', $path));

View File

@ -6,11 +6,9 @@ namespace Endroid\QrCode\Label\Font;
final class NotoSans implements FontInterface
{
private int $size;
public function __construct(int $size = 16)
{
$this->size = $size;
public function __construct(
private int $size = 16
) {
}
public function getPath(): string

View File

@ -6,11 +6,9 @@ namespace Endroid\QrCode\Label\Font;
final class OpenSans implements FontInterface
{
private int $size;
public function __construct(int $size = 16)
{
$this->size = $size;
public function __construct(
private int $size = 16
) {
}
public function getPath(): string

View File

@ -15,20 +15,18 @@ use Endroid\QrCode\Label\Margin\MarginInterface;
final class Label implements LabelInterface
{
private string $text;
private FontInterface $font;
private LabelAlignmentInterface $alignment;
private MarginInterface $margin;
private ColorInterface $textColor;
public function __construct(
string $text,
FontInterface $font = null,
LabelAlignmentInterface $alignment = null,
MarginInterface $margin = null,
ColorInterface $textColor = null
private string $text,
FontInterface|null $font = null,
LabelAlignmentInterface|null $alignment = null,
MarginInterface|null $margin = null,
ColorInterface|null $textColor = null
) {
$this->text = $text;
$this->font = $font ?? new Font(__DIR__.'/../../assets/noto_sans.otf', 16);
$this->alignment = $alignment ?? new LabelAlignmentCenter();
$this->margin = $margin ?? new Margin(0, 10, 10, 10);

View File

@ -6,17 +6,12 @@ namespace Endroid\QrCode\Label\Margin;
final class Margin implements MarginInterface
{
private int $top;
private int $right;
private int $bottom;
private int $left;
public function __construct(int $top, int $right, int $bottom, int $left)
{
$this->top = $top;
$this->right = $right;
$this->bottom = $bottom;
$this->left = $left;
public function __construct(
private int $top,
private int $right,
private int $bottom,
private int $left
) {
}
public function getTop(): int

View File

@ -6,17 +6,12 @@ namespace Endroid\QrCode\Logo;
final class Logo implements LogoInterface
{
private string $path;
private ?int $resizeToWidth;
private ?int $resizeToHeight;
private bool $punchoutBackground;
public function __construct(string $path, ?int $resizeToWidth = null, ?int $resizeToHeight = null, bool $punchoutBackground = false)
{
$this->path = $path;
$this->resizeToWidth = $resizeToWidth;
$this->resizeToHeight = $resizeToHeight;
$this->punchoutBackground = $punchoutBackground;
public function __construct(
private string $path,
private int|null $resizeToWidth = null,
private int|null $resizeToHeight = null,
private bool $punchoutBackground = false
) {
}
public static function create(string $path): self
@ -36,24 +31,24 @@ final class Logo implements LogoInterface
return $this;
}
public function getResizeToWidth(): ?int
public function getResizeToWidth(): int|null
{
return $this->resizeToWidth;
}
public function setResizeToWidth(?int $resizeToWidth): self
public function setResizeToWidth(int|null $resizeToWidth): self
{
$this->resizeToWidth = $resizeToWidth;
return $this;
}
public function getResizeToHeight(): ?int
public function getResizeToHeight(): int|null
{
return $this->resizeToHeight;
}
public function setResizeToHeight(?int $resizeToHeight): self
public function setResizeToHeight(int|null $resizeToHeight): self
{
$this->resizeToHeight = $resizeToHeight;

View File

@ -8,9 +8,9 @@ interface LogoInterface
{
public function getPath(): string;
public function getResizeToWidth(): ?int;
public function getResizeToWidth(): int|null;
public function getResizeToHeight(): ?int;
public function getResizeToHeight(): int|null;
public function getPunchoutBackground(): bool;
}

View File

@ -11,9 +11,6 @@ use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeShrink;
final class Matrix implements MatrixInterface
{
/** @var array<int, array<int, int>> */
private array $blockValues = [];
private float $blockSize;
private int $innerSize;
private int $outerSize;
@ -21,10 +18,12 @@ final class Matrix implements MatrixInterface
private int $marginRight;
/** @param array<array<int>> $blockValues */
public function __construct(array $blockValues, int $size, int $margin, RoundBlockSizeModeInterface $roundBlockSizeMode)
{
$this->blockValues = $blockValues;
public function __construct(
private array $blockValues,
int $size,
int $margin,
RoundBlockSizeModeInterface $roundBlockSizeMode
) {
$this->blockSize = $size / $this->getBlockCount();
$this->innerSize = $size;
$this->outerSize = $size + 2 * $margin;

View File

@ -15,30 +15,24 @@ use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
final class QrCode implements QrCodeInterface
{
private string $data;
private EncodingInterface $encoding;
private ErrorCorrectionLevelInterface $errorCorrectionLevel;
private int $size;
private int $margin;
private RoundBlockSizeModeInterface $roundBlockSizeMode;
private ColorInterface $foregroundColor;
private ColorInterface $backgroundColor;
public function __construct(
string $data,
EncodingInterface $encoding = null,
ErrorCorrectionLevelInterface $errorCorrectionLevel = null,
int $size = 300,
int $margin = 10,
RoundBlockSizeModeInterface $roundBlockSizeMode = null,
ColorInterface $foregroundColor = null,
ColorInterface $backgroundColor = null
private string $data,
EncodingInterface|null $encoding = null,
ErrorCorrectionLevelInterface|null $errorCorrectionLevel = null,
private int $size = 300,
private int $margin = 10,
RoundBlockSizeModeInterface|null $roundBlockSizeMode = null,
ColorInterface|null $foregroundColor = null,
ColorInterface|null $backgroundColor = null
) {
$this->data = $data;
$this->encoding = $encoding ?? new Encoding('UTF-8');
$this->errorCorrectionLevel = $errorCorrectionLevel ?? new ErrorCorrectionLevelLow();
$this->size = $size;
$this->margin = $margin;
$this->roundBlockSizeMode = $roundBlockSizeMode ?? new RoundBlockSizeModeMargin();
$this->foregroundColor = $foregroundColor ?? new Color(0, 0, 0);
$this->backgroundColor = $backgroundColor ?? new Color(255, 255, 255);

View File

@ -1,7 +0,0 @@
<?php
declare(strict_types=1);
interface WritableInterface
{
}

View File

@ -13,7 +13,7 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
final class BinaryWriter implements WriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);

View File

@ -11,15 +11,9 @@ use Endroid\QrCode\QrCodeInterface;
use Endroid\QrCode\Writer\Result\ConsoleResult;
use Endroid\QrCode\Writer\Result\ResultInterface;
/**
* Writer of QR Code for CLI.
*/
class ConsoleWriter implements WriterInterface
final class ConsoleWriter implements WriterInterface
{
/**
* {@inheritDoc}
*/
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);

View File

@ -13,7 +13,7 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
final class DebugWriter implements WriterInterface, ValidatingWriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);

View File

@ -15,7 +15,7 @@ final class EpsWriter implements WriterInterface
{
public const DECIMAL_PRECISION = 10;
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);

View File

@ -17,8 +17,9 @@ final class PdfWriter implements WriterInterface
public const WRITER_OPTION_PDF = 'fpdf';
public const WRITER_OPTION_X = 'x';
public const WRITER_OPTION_Y = 'y';
public const WRITER_OPTION_LINK = 'link';
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
@ -99,6 +100,11 @@ final class PdfWriter implements WriterInterface
$fpdf->Cell($matrix->getOuterSize(), 0, $label->getText(), 0, 0, 'C');
}
if (isset($options[self::WRITER_OPTION_LINK])) {
$link = $options[self::WRITER_OPTION_LINK];
$fpdf->Link($x, $y, $x + $matrix->getOuterSize(), $y + $matrix->getOuterSize(), $link);
}
return new PdfResult($matrix, $fpdf);
}

View File

@ -4,214 +4,26 @@ declare(strict_types=1);
namespace Endroid\QrCode\Writer;
use Endroid\QrCode\Bacon\MatrixFactory;
use Endroid\QrCode\Exception\ValidationException;
use Endroid\QrCode\ImageData\LabelImageData;
use Endroid\QrCode\ImageData\LogoImageData;
use Endroid\QrCode\Label\Alignment\LabelAlignmentLeft;
use Endroid\QrCode\Label\Alignment\LabelAlignmentRight;
use Endroid\QrCode\Label\LabelInterface;
use Endroid\QrCode\Logo\LogoInterface;
use Endroid\QrCode\QrCodeInterface;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeNone;
use Endroid\QrCode\Writer\Result\GdResult;
use Endroid\QrCode\Writer\Result\PngResult;
use Endroid\QrCode\Writer\Result\ResultInterface;
use Zxing\QrReader;
final class PngWriter implements WriterInterface, ValidatingWriterInterface
final class PngWriter extends AbstractGdWriter
{
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public const WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
if (!extension_loaded('gd')) {
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
if (!isset($options[self::WRITER_OPTION_COMPRESSION_LEVEL])) {
$options[self::WRITER_OPTION_COMPRESSION_LEVEL] = -1;
}
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
/** @var GdResult $gdResult */
$gdResult = parent::write($qrCode, $logo, $label, $options);
$baseBlockSize = $qrCode->getRoundBlockSizeMode() instanceof RoundBlockSizeModeNone ? 10 : intval($matrix->getBlockSize());
$baseImage = imagecreatetruecolor($matrix->getBlockCount() * $baseBlockSize, $matrix->getBlockCount() * $baseBlockSize);
if (!$baseImage) {
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
}
/** @var int $foregroundColor */
$foregroundColor = imagecolorallocatealpha(
$baseImage,
$qrCode->getForegroundColor()->getRed(),
$qrCode->getForegroundColor()->getGreen(),
$qrCode->getForegroundColor()->getBlue(),
$qrCode->getForegroundColor()->getAlpha()
);
/** @var int $transparentColor */
$transparentColor = imagecolorallocatealpha($baseImage, 255, 255, 255, 127);
imagefill($baseImage, 0, 0, $transparentColor);
for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) {
for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) {
if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) {
imagefilledrectangle(
$baseImage,
$columnIndex * $baseBlockSize,
$rowIndex * $baseBlockSize,
($columnIndex + 1) * $baseBlockSize - 1,
($rowIndex + 1) * $baseBlockSize - 1,
$foregroundColor
);
}
}
}
$targetWidth = $matrix->getOuterSize();
$targetHeight = $matrix->getOuterSize();
if ($label instanceof LabelInterface) {
$labelImageData = LabelImageData::createForLabel($label);
$targetHeight += $labelImageData->getHeight() + $label->getMargin()->getTop() + $label->getMargin()->getBottom();
}
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
if (!$targetImage) {
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
}
/** @var int $backgroundColor */
$backgroundColor = imagecolorallocatealpha(
$targetImage,
$qrCode->getBackgroundColor()->getRed(),
$qrCode->getBackgroundColor()->getGreen(),
$qrCode->getBackgroundColor()->getBlue(),
$qrCode->getBackgroundColor()->getAlpha()
);
imagefill($targetImage, 0, 0, $backgroundColor);
imagecopyresampled(
$targetImage,
$baseImage,
$matrix->getMarginLeft(),
$matrix->getMarginLeft(),
0,
0,
$matrix->getInnerSize(),
$matrix->getInnerSize(),
imagesx($baseImage),
imagesy($baseImage)
);
if (PHP_VERSION_ID < 80000) {
imagedestroy($baseImage);
}
if ($qrCode->getBackgroundColor()->getAlpha() > 0) {
imagesavealpha($targetImage, true);
}
$result = new PngResult($matrix, $targetImage);
if ($logo instanceof LogoInterface) {
$result = $this->addLogo($logo, $result);
}
if ($label instanceof LabelInterface) {
$result = $this->addLabel($label, $result);
}
return $result;
}
private function addLogo(LogoInterface $logo, PngResult $result): PngResult
{
$logoImageData = LogoImageData::createForLogo($logo);
if ('image/svg+xml' === $logoImageData->getMimeType()) {
throw new \Exception('PNG Writer does not support SVG logo');
}
$targetImage = $result->getImage();
$matrix = $result->getMatrix();
if ($logoImageData->getPunchoutBackground()) {
/** @var int $transparent */
$transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127);
imagealphablending($targetImage, false);
$xOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2);
$yOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2);
for ($xOffset = $xOffsetStart; $xOffset < $xOffsetStart + $logoImageData->getWidth(); ++$xOffset) {
for ($yOffset = $yOffsetStart; $yOffset < $yOffsetStart + $logoImageData->getHeight(); ++$yOffset) {
imagesetpixel($targetImage, $xOffset, $yOffset, $transparent);
}
}
}
imagecopyresampled(
$targetImage,
$logoImageData->getImage(),
intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2),
intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2),
0,
0,
$logoImageData->getWidth(),
$logoImageData->getHeight(),
imagesx($logoImageData->getImage()),
imagesy($logoImageData->getImage())
);
if (PHP_VERSION_ID < 80000) {
imagedestroy($logoImageData->getImage());
}
return new PngResult($matrix, $targetImage);
}
private function addLabel(LabelInterface $label, PngResult $result): PngResult
{
$targetImage = $result->getImage();
$labelImageData = LabelImageData::createForLabel($label);
/** @var int $textColor */
$textColor = imagecolorallocatealpha(
$targetImage,
$label->getTextColor()->getRed(),
$label->getTextColor()->getGreen(),
$label->getTextColor()->getBlue(),
$label->getTextColor()->getAlpha()
);
$x = intval(imagesx($targetImage) / 2 - $labelImageData->getWidth() / 2);
$y = imagesy($targetImage) - $label->getMargin()->getBottom();
if ($label->getAlignment() instanceof LabelAlignmentLeft) {
$x = $label->getMargin()->getLeft();
} elseif ($label->getAlignment() instanceof LabelAlignmentRight) {
$x = imagesx($targetImage) - $labelImageData->getWidth() - $label->getMargin()->getRight();
}
imagettftext($targetImage, $label->getFont()->getSize(), 0, $x, $y, $textColor, $label->getFont()->getPath(), $label->getText());
return new PngResult($result->getMatrix(), $targetImage);
}
public function validateResult(ResultInterface $result, string $expectedData): void
{
$string = $result->getString();
if (!class_exists(QrReader::class)) {
throw ValidationException::createForMissingPackage('khanamiryan/qrcode-detector-decoder');
}
if (PHP_VERSION_ID >= 80000) {
throw ValidationException::createForIncompatiblePhpVersion();
}
$reader = new QrReader($string, QrReader::SOURCE_TYPE_BLOB);
if ($reader->text() !== $expectedData) {
throw ValidationException::createForInvalidData($expectedData, strval($reader->text()));
}
return new PngResult($gdResult->getMatrix(), $gdResult->getImage(), $options[self::WRITER_OPTION_COMPRESSION_LEVEL]);
}
}

View File

@ -8,11 +8,9 @@ use Endroid\QrCode\Matrix\MatrixInterface;
abstract class AbstractResult implements ResultInterface
{
private MatrixInterface $matrix;
public function __construct(MatrixInterface $matrix)
{
$this->matrix = $matrix;
public function __construct(
private MatrixInterface $matrix
) {
}
public function getMatrix(): MatrixInterface

View File

@ -11,29 +11,17 @@ use Endroid\QrCode\QrCodeInterface;
final class DebugResult extends AbstractResult
{
private QrCodeInterface $qrCode;
private ?LogoInterface $logo;
private ?LabelInterface $label;
/** @var array<mixed> */
private array $options;
private bool $validateResult = false;
/** @param array<mixed> $options */
public function __construct(
MatrixInterface $matrix,
QrCodeInterface $qrCode,
LogoInterface $logo = null,
LabelInterface $label = null,
array $options = []
private QrCodeInterface $qrCode,
private LogoInterface|null $logo = null,
private LabelInterface|null $label = null,
/** @var array<string, mixed> $options */
private array $options = []
) {
parent::__construct($matrix);
$this->qrCode = $qrCode;
$this->logo = $logo;
$this->label = $label;
$this->options = $options;
}
public function setValidateResult(bool $validateResult): void

View File

@ -8,15 +8,12 @@ use Endroid\QrCode\Matrix\MatrixInterface;
final class EpsResult extends AbstractResult
{
/** @var array<string> */
private array $lines;
/** @param array<string> $lines */
public function __construct(MatrixInterface $matrix, array $lines)
{
public function __construct(
MatrixInterface $matrix,
/** @var array<string> $lines */
private array $lines
) {
parent::__construct($matrix);
$this->lines = $lines;
}
public function getString(): string

View File

@ -8,13 +8,11 @@ use Endroid\QrCode\Matrix\MatrixInterface;
final class PdfResult extends AbstractResult
{
private \FPDF $fpdf;
public function __construct(MatrixInterface $matrix, \FPDF $fpdf)
{
public function __construct(
MatrixInterface $matrix,
private \FPDF $fpdf
) {
parent::__construct($matrix);
$this->fpdf = $fpdf;
}
public function getPdf(): \FPDF

View File

@ -6,29 +6,20 @@ namespace Endroid\QrCode\Writer\Result;
use Endroid\QrCode\Matrix\MatrixInterface;
final class PngResult extends AbstractResult
final class PngResult extends GdResult
{
/** @var mixed */
private $image;
private int $quality;
/** @param mixed $image */
public function __construct(MatrixInterface $matrix, $image)
public function __construct(MatrixInterface $matrix, \GdImage $image, int $quality = -1)
{
parent::__construct($matrix);
$this->image = $image;
}
/** @return mixed */
public function getImage()
{
return $this->image;
parent::__construct($matrix, $image);
$this->quality = $quality;
}
public function getString(): string
{
ob_start();
imagepng($this->image);
imagepng($this->image, quality: $this->quality);
return strval(ob_get_clean());
}

View File

@ -8,18 +8,12 @@ use Endroid\QrCode\Matrix\MatrixInterface;
final class SvgResult extends AbstractResult
{
private \SimpleXMLElement $xml;
private bool $excludeXmlDeclaration;
public function __construct(
MatrixInterface $matrix,
\SimpleXMLElement $xml,
bool $excludeXmlDeclaration = false
private \SimpleXMLElement $xml,
private bool $excludeXmlDeclaration = false
) {
parent::__construct($matrix);
$this->xml = $xml;
$this->excludeXmlDeclaration = $excludeXmlDeclaration;
}
public function getXml(): \SimpleXMLElement

View File

@ -20,7 +20,7 @@ final class SvgWriter implements WriterInterface
public const WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT = 'exclude_svg_width_and_height';
public const WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_BLOCK_ID])) {
$options[self::WRITER_OPTION_BLOCK_ID] = 'block';
@ -81,7 +81,7 @@ final class SvgWriter implements WriterInterface
return $result;
}
/** @param array<mixed> $options */
/** @param array<string, mixed> $options */
private function addLogo(LogoInterface $logo, SvgResult $result, array $options): void
{
$logoImageData = LogoImageData::createForLogo($logo);

View File

@ -11,6 +11,6 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
interface WriterInterface
{
/** @param array<mixed> $options */
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface;
/** @param array<string, mixed> $options */
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface;
}