CHANGE_ADMIN_BUSINESS_AND_BRANCH : AADHAVAN
This commit is contained in:
parent
de9ab1cb46
commit
a62ca6451f
@ -63,15 +63,18 @@ use CodeIgniter\Router\RouteCollection;
|
||||
$routes->post('add_business','BusinessController::add_business');
|
||||
$routes->get('delete_business/(:any)','BusinessController::delete_business/$1');
|
||||
$routes->get('get_business/(:any)','BusinessController::get_business/$1');
|
||||
$routes->get('business','BusinessController::business');
|
||||
$routes->post('business_edit','BusinessController::business_edit');
|
||||
|
||||
|
||||
|
||||
$routes->get('branch_index/(:any)','BranchController::branch_index/$1');
|
||||
$routes->get('new_business/(:any)','BranchController::new_business/$1');
|
||||
$routes->get('delete_branch/(:any)','BranchController::delete_branch/$1');
|
||||
$routes->get('get_branch/(:any)','BranchController::get_branch/$1');
|
||||
$routes->post('edit_branch/(:any)','BranchController::edit_branch/$1');
|
||||
$routes->post('add_branch/(:any)','BranchController::new_branch/$1');
|
||||
$routes->post('branch_edit','BranchController::branch_edit');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -96,6 +96,21 @@ class BranchController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function branch_edit()
|
||||
{
|
||||
$branch_id = $this->request->getPost('branch_id');
|
||||
if ($branch_id) {
|
||||
$data = $this->request->getPost();
|
||||
$BranchModel = new BranchModel();
|
||||
|
||||
$BranchModel->update($branch_id,$data);
|
||||
return json_encode(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function delete_branch($branch_id)
|
||||
{
|
||||
$model = new BranchModel();
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\BranchModel;
|
||||
use App\Models\StaffModel;
|
||||
|
||||
|
||||
@ -11,13 +12,15 @@ class BusinessController extends BaseController
|
||||
{
|
||||
public $session;
|
||||
protected $BusinessModel;
|
||||
protected $BranchModel;
|
||||
protected $StaffModel;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->BranchModel = new BranchModel();
|
||||
$this->StaffModel = new StaffModel();
|
||||
|
||||
}
|
||||
@ -141,4 +144,66 @@ class BusinessController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function business()
|
||||
{
|
||||
$branch_id =session()->get("logged_in_staff_branch_id");
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
if ($branch_id) {
|
||||
// $BusinessModel = new BusinessModel();
|
||||
$BranchModel = new BranchModel();
|
||||
$data['branch'] =$BranchModel->select('branches.*, business.*')
|
||||
->join('business', 'business.business_id = branches.business_id')
|
||||
->where('branches.branch_id',$branch_id)
|
||||
->first();
|
||||
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('business',$data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function business_edit()
|
||||
{
|
||||
$uploadFilePath = ROOTPATH . 'public/uploads/';
|
||||
|
||||
$file_name = $this->file_Upload($this->request->getFile('business_logo'), $uploadFilePath);
|
||||
$data = $this->request->getPost();
|
||||
$data['logo'] = $file_name;
|
||||
|
||||
$business_id = $this->request->getPost('business_id');
|
||||
|
||||
if($business_id){
|
||||
$update = $this->BusinessModel->update($business_id, $data);
|
||||
}else{
|
||||
$insert = $this->BusinessModel->insert($data);
|
||||
}
|
||||
|
||||
return json_encode(true);
|
||||
|
||||
// if($insert){
|
||||
// $client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
|
||||
// return $this->respond(['status' => true,'code' => 200,'data' => $client_data], 200);
|
||||
|
||||
// }else{
|
||||
// return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200);
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function file_Upload($fileToUpload, $filepath)
|
||||
{
|
||||
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
|
||||
$fileName = $fileToUpload->getName();
|
||||
$fileToUpload->move($filepath, $fileName);
|
||||
return $fileName;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ class BusinessModel extends Model
|
||||
{
|
||||
protected $table = 'business';
|
||||
protected $primaryKey = 'business_id';
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','isactive'];
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','logo', 'business_name','isactive'];
|
||||
|
||||
public function getBusinessById($business_id) {
|
||||
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();
|
||||
|
||||
296
app/Views/business.php
Normal file
296
app/Views/business.php
Normal file
@ -0,0 +1,296 @@
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-1 col-xl-1">
|
||||
</div>
|
||||
<div class="col-lg-10 col-xl-10">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="tab-pane show active" id="settings">
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Business Info</h5>
|
||||
|
||||
<form id="business_edit_form" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<input type="hidden" id="business_id" name="business_id" value="<?php echo $branch['business_id'] ?>">
|
||||
<label for="name">Business Name</label>
|
||||
<?php if($branch){ $business_name = $branch['business_name']; ?>
|
||||
<?php }else{ $business_name = ''; } ?>
|
||||
<input type="text" class="form-control" id="business_name" name="business_name" value="<?= $business_name ?>">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="name">Change Logo</label>
|
||||
<input type="file" id="business_logo" name="business_logo" accept="image/*" onchange="PreviewImage();">
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-6 float-right" style="position: relative;top: 20px;">
|
||||
<img src="<?= isset($branch['logo']) && !empty($branch['logo']) ? base_url() . "public/uploads/" . $branch['logo'] : base_url()."public/assets/images/avatar_2x.png" ?>" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-12" style="margin-top: 27px;">
|
||||
<button type="button" class="btn btn-primary" id="submit_business" style="float: inline-end;">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- end settings content-->
|
||||
|
||||
|
||||
<div class="text-left mt-3">
|
||||
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Branch Info</h5>
|
||||
<form id="branch_edit_form" enctype="multipart/form-data">
|
||||
<input type="hidden" id="branch_id" name="branch_id" value="<?php echo $branch['branch_id']; ?>">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<label for="old_password">Branch Name</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name" value="<?php echo $branch['branch_name']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<label for="old_password">Email</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="email" name="email" value="<?php echo $branch['branch_name']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<label for="old_password">Contact 1</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="contact_1" name="contact_1" value="<?php echo $branch['contact_1']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<div class="form-group">
|
||||
<label for="old_password">Contact 2</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="contact_2" name="contact_2" value="<?php echo $branch['contact_2']; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6" style="margin-top: 27px;">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="address">Address</label>
|
||||
<input class="form-control" name="address" type="text" id="address" value="<?php echo $branch['address']; ?>" required="" placeholder="Address">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="city">City</label>
|
||||
<input class="form-control" name="city" type="text" id="city" value="<?php echo $branch['city']; ?>" required="" placeholder="City">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="state">State</label>
|
||||
<input class="form-control" name="state" type="text" id="state" value="<?php echo $branch['state']; ?>" required="" placeholder="State">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="pincode">Country</label>
|
||||
<input class="form-control" name="country" type="text" id="country" value="<?php echo $branch['country']; ?>" required="" placeholder="Country">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="pincode">Pin Code</label>
|
||||
<input class="form-control" name="postal_code" type="text" id="postal_code" value="<?php echo $branch['postal_code']; ?>" required="" placeholder="Postal Code">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="statecode">State Code</label>
|
||||
<input class="form-control" name="state_code" type="text" id="state_code" value="<?php echo $branch['state_code']; ?>" required="" placeholder="State Code">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12" style="margin-top: 27px;">
|
||||
<button type="button" class="btn btn-primary" id="submit_password" style="float: inline-end;" onclick="changePassword(this)">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-lg-1 col-xl-1">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#submit_business').click(function(e) {
|
||||
e.preventDefault(); // Prevent the form from submitting normally
|
||||
|
||||
var form = document.getElementById('business_edit_form');
|
||||
var formData = new FormData(form);
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url() ?>business_edit',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false, // Prevent jQuery from automatically processing the data
|
||||
contentType: false, // Prevent jQuery from automatically setting the content type
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Handle the case where the response indicates failure
|
||||
alert('Update failed.');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle errors here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function changePassword(params) {
|
||||
|
||||
|
||||
var form = document.getElementById('branch_edit_form');
|
||||
var formData = new FormData(form);
|
||||
$.ajax({
|
||||
url: '<?= base_url() ?>branch_edit',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response) {
|
||||
toastr.success( 'Success');
|
||||
|
||||
window.location.reload();
|
||||
}else{
|
||||
toastr.warning( 'Warning');
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var oldPasswordField = document.getElementById("old_password");
|
||||
var toggleOldPassword = document.getElementById("toggleOldPassword");
|
||||
|
||||
var newPasswordField = document.getElementById("new_password");
|
||||
var toggleNewPassword = document.getElementById("toggleNewPassword");
|
||||
|
||||
var confirmField = document.getElementById("confirm_password");
|
||||
var toggleConfirmPassword = document.getElementById("toggleConfirmPassword");
|
||||
|
||||
toggleOldPassword.addEventListener("click", function() {
|
||||
togglePasswordVisibility(oldPasswordField, toggleOldPassword);
|
||||
});
|
||||
|
||||
toggleNewPassword.addEventListener("click", function() {
|
||||
togglePasswordVisibility(newPasswordField, toggleNewPassword);
|
||||
});
|
||||
|
||||
toggleConfirmPassword.addEventListener("click", function() {
|
||||
togglePasswordVisibility(confirmField, toggleConfirmPassword);
|
||||
});
|
||||
|
||||
function togglePasswordVisibility(field, toggle) {
|
||||
if (field.type === "password") {
|
||||
field.type = "text";
|
||||
toggle.className = "fa fa-eye-slash";
|
||||
} else {
|
||||
field.type = "password";
|
||||
toggle.className = "fa fa-eye";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var newPasswordField = document.getElementById('new_password');
|
||||
var confirmPasswordField = document.getElementById('confirm_password');
|
||||
var submitButton = document.getElementById('submit_password');
|
||||
|
||||
// Add an event listener to the "Confirm Password" field
|
||||
confirmPasswordField.addEventListener('input', function() {
|
||||
// Check if the passwords match
|
||||
if (newPasswordField.value === confirmPasswordField.value) {
|
||||
// Enable the submit button
|
||||
submitButton.disabled = false;
|
||||
} else {
|
||||
// Disable the submit button
|
||||
submitButton.disabled = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
function PreviewImage() {
|
||||
console.log('function called');
|
||||
var fileInput = document.getElementById("client_logo");
|
||||
var file = fileInput.files[0];
|
||||
|
||||
if (file) {
|
||||
var allowedExtensions = ["jpg", "jpeg", "png"];
|
||||
var fileExtension = file.name.split('.').pop().toLowerCase();
|
||||
|
||||
if (!allowedExtensions.includes(fileExtension) || file.size > 200 * 1024) {
|
||||
toastr.warning('Maximum file size allowed is 200KB.', 'File size exceeds limit.');
|
||||
fileInput.value = ""; // Clear the file input
|
||||
document.getElementById("uploadPreview").src = "http://ssl.gstatic.com/accounts/ui/avatar_2x.png"; // Remove the preview image
|
||||
} else {
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
reader.onload = function (event) {
|
||||
document.getElementById("uploadPreview").src = event.target.result;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -8,6 +8,9 @@
|
||||
letter-spacing: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
@ -17,7 +20,11 @@
|
||||
<div class="col-2"> </div>
|
||||
<div class="col-8">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title"><?php echo $docData->service_name; ?></h4>
|
||||
<h4 class="page-title"><?php echo $docData->service_name; ?>
|
||||
<a class="btn btn-primary download-btn">
|
||||
<i class="fas fa-download"></i>
|
||||
</a>
|
||||
</h4>
|
||||
<div class="page-title-right">
|
||||
<a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light"> Close </a>
|
||||
<a href="#" class="btn btn-danger waves-effect waves-light" data-toggle="modal" data-target="#reject-modal"> Reject </a>
|
||||
@ -39,6 +46,7 @@
|
||||
<div class="card-body">
|
||||
|
||||
<div class="template-header">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-body">
|
||||
@ -285,6 +293,36 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.querySelector(".download-btn").addEventListener("click", async function() {
|
||||
const { jsPDF } = window.jspdf;
|
||||
|
||||
var element = document.querySelector(".card-body");
|
||||
const canvas = await html2canvas(element);
|
||||
var imgData = canvas.toDataURL('image/png');
|
||||
var pdf = new jsPDF('p', 'mm', 'a4');
|
||||
var imgWidth = 210;
|
||||
var pageHeight = 297;
|
||||
var imgHeight = canvas.height * imgWidth / canvas.width;
|
||||
var heightLeft = imgHeight;
|
||||
var position = 0;
|
||||
|
||||
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
heightLeft -= pageHeight;
|
||||
|
||||
while (heightLeft >= 0) {
|
||||
position = heightLeft - imgHeight;
|
||||
pdf.addPage();
|
||||
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
||||
heightLeft -= pageHeight;
|
||||
}
|
||||
|
||||
pdf.save('download.pdf');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
|
||||
@ -163,11 +163,17 @@
|
||||
<i class="ri-account-circle-line"></i>
|
||||
<span>My Profile</span>
|
||||
</a>
|
||||
<?php }else if(isset($_SESSION['is_client_logged_in']) && $_SESSION['is_client_logged_in']){ ?>
|
||||
<a href="<?= base_url('client_profile'); ?>" class="dropdown-item notify-item">
|
||||
<i class="ri-account-circle-line"></i>
|
||||
<span>My Profile</span>
|
||||
<?php if($_SESSION['logged_in_staff_role'] == 'Admin' ) { ?>
|
||||
<a href="<?= base_url('business'); ?>" class="dropdown-item notify-item">
|
||||
<i class="ri-briefcase-line"></i>
|
||||
<span>Business</span>
|
||||
</a>
|
||||
|
||||
<?php } }else if(isset($_SESSION['is_client_logged_in']) && $_SESSION['is_client_logged_in']){ ?>
|
||||
<!-- <a href="<?= base_url('client_profile'); ?>" class="dropdown-item notify-item"> -->
|
||||
<!-- <i class="ri-account-circle-line"></i> -->
|
||||
<!-- <span>My Profile</span> -->
|
||||
<!-- </a> -->
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -289,15 +295,12 @@
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-master" role="button"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="ri-database-2-line mr-1"></i> Master <div class="arrow-down"></div>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?= base_url()."service_list"; ?>">
|
||||
<i class="ri-service-line"></i> Services
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="topnav-master">
|
||||
<a href="<?= base_url()."service_list"; ?>" class="dropdown-item">Services</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
<?php }else if(isset($_SESSION['is_client_logged_in']) && $_SESSION['is_client_logged_in']) { ?>
|
||||
|
||||
@ -313,7 +316,8 @@
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if(isset($_SESSION['is_staff_logged_in']) && $_SESSION['is_staff_logged_in']) { ?>
|
||||
|
||||
<?php if($_SESSION['logged_in_staff_role'] == 'Super Admin') { ?>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
@ -325,7 +329,7 @@
|
||||
<a href="<?= base_url()."business_list"; ?>" class="dropdown-item">Business</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php }} ?>
|
||||
|
||||
</ul> <!-- end navbar-->
|
||||
</div> <!-- end .collapsed-->
|
||||
|
||||
BIN
public/uploads/downArrow.png
Normal file
BIN
public/uploads/downArrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 362 B |
BIN
public/uploads/ia.jpg
Normal file
BIN
public/uploads/ia.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 469 KiB |
Loading…
Reference in New Issue
Block a user