GWM
This commit is contained in:
parent
b5cb4a5de1
commit
348d9ead06
@ -42,7 +42,6 @@ class BusinessController extends BaseController
|
||||
|
||||
|
||||
if ($business_id === '0') {
|
||||
|
||||
$data['business'] = [];
|
||||
$data['page_name']="Add Business";
|
||||
} else if ($business_id !== '0') {
|
||||
@ -86,39 +85,26 @@ class BusinessController extends BaseController
|
||||
{
|
||||
$BusinessModel = new BusinessModel();
|
||||
|
||||
$uploadFilePath = ROOTPATH . 'public/uploads/';
|
||||
|
||||
$data = [
|
||||
'business_name' => $this->request->getPost('businessname'),
|
||||
'letter_header' => $this->request->getPost('letter_header'),
|
||||
'isactive' => 1
|
||||
];
|
||||
// print_r($this->request->getFile('business_logo'));die;
|
||||
if($this->request->getFile('business_logo')){
|
||||
$file_name = $this->file_Upload($this->request->getFile('business_logo'), $uploadFilePath);
|
||||
if($file_name){
|
||||
$data['logo'] = $file_name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$business_id = $this->request->getPost('business_id');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
|
||||
if (!empty($business_id)) {
|
||||
if ($business_id != '') {
|
||||
|
||||
$BusinessModel->update($business_id, $data);
|
||||
return $this->response->setJSON(['success' => true ]);
|
||||
|
||||
} else {
|
||||
|
||||
$BusinessModel->insert($data);
|
||||
return $this->response->setJSON(['success' => true ]);
|
||||
}
|
||||
|
||||
if (session()->get('logged_user_role') == "Administrator") {
|
||||
return redirect()->to('new_business/'.session()->get("logged_user_business_id"));
|
||||
}else{
|
||||
return redirect()->to('business_list');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function delete_business($business_id)
|
||||
{
|
||||
$model = new BusinessModel();
|
||||
|
||||
@ -14,6 +14,7 @@ use App\Models\ServiceGroupModel;
|
||||
use App\Models\ClientBranchModel;
|
||||
use App\Models\DocsStatusModel;
|
||||
|
||||
|
||||
class MasterController extends BaseController
|
||||
{
|
||||
public $session;
|
||||
@ -29,6 +30,7 @@ class MasterController extends BaseController
|
||||
protected $DocsStatusModel;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
@ -42,6 +44,7 @@ class MasterController extends BaseController
|
||||
$this->ServiceGroupModel = new ServiceGroupModel();
|
||||
$this->ClientBranchModel = new ClientBranchModel();
|
||||
$this->DocsStatusModel = new DocsStatusModel();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -212,7 +215,7 @@ class MasterController extends BaseController
|
||||
|
||||
$id = $this->request->getVar('service_id');
|
||||
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||
//$data['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
|
||||
$data['AllBusinessData'] = $this->BusinessModel->findAll();
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
|
||||
@ -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','logo', 'business_name','isactive','letter_header'];
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','logo', 'business_name','isactive','letter_header','header_html','footer_html'];
|
||||
|
||||
public function getBusinessById($business_id) {
|
||||
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();
|
||||
|
||||
@ -7,7 +7,7 @@ class TemplateModel extends Model
|
||||
protected $table = 'template';
|
||||
protected $primaryKey = 'template_id';
|
||||
|
||||
protected $allowedFields = ['service_group_id','service_id','template_name','header_type','body_text','body_html', 'is_active' ,'created_by','updated_by'];
|
||||
protected $allowedFields = ['service_group_id','service_id','template_name','template_header_business','header_type','body_text','body_html', 'is_active' ,'created_by','updated_by'];
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,27 +24,44 @@
|
||||
<!-- end page title -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-8">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<form action="<?= base_url() . "add_business"; ?>" method="post">
|
||||
<form >
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="inputEmail4" class="col-form-label">Business Name</label>
|
||||
<input type="text" class="form-control" name="businessname" placeholder="Name" value="<?= isset($business['business_name']) ? $business['business_name'] : '' ?>" required>
|
||||
<input type="text" class="form-control" id="business_name" placeholder="Name" value="<?= isset($business['business_name']) ? $business['business_name'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="subject-input">Template Header</label>
|
||||
<!-- basic summernote-->
|
||||
<div id="summernote-header"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="subject-input">Template Footer</label>
|
||||
<!-- basic summernote-->
|
||||
<div id="summernote-footer"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
|
||||
<input type="hidden" id="header_html" value='<?= isset($business['business_id']) ? $business['header_html'] : '' ?>'>
|
||||
<input type="hidden" id="footer_html" value='<?= isset($business['business_id']) ? $business['footer_html'] : '' ?>'>
|
||||
<button type="submit" id="savedata" class="btn btn-primary">Submit</button>
|
||||
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div>
|
||||
<div class="col-lg-2"></div>
|
||||
<!-- end col -->
|
||||
|
||||
</div>
|
||||
@ -55,56 +72,83 @@
|
||||
</div> <!-- content -->
|
||||
|
||||
<script>
|
||||
function convertToUpperCase() {
|
||||
var inputField = document.getElementById("pan_no");
|
||||
inputField.value = inputField.value.toUpperCase();
|
||||
}
|
||||
|
||||
// Attach the function to the input field using an event listener
|
||||
document.getElementById("pan_no").addEventListener("input", convertToUpperCase);
|
||||
$(document).ready(function() {
|
||||
$('#summernote-header').summernote({
|
||||
height: 150, // set the height of the editor
|
||||
placeholder: 'Write the header content here...'
|
||||
});
|
||||
|
||||
function validatePanNumber() {
|
||||
var panNumber = document.getElementById("pan_no").value;
|
||||
var errorMessage = document.getElementById("error-message");
|
||||
$('#summernote-footer').summernote({
|
||||
height: 150, // set the height of the editor
|
||||
placeholder: 'Write the footer content here...'
|
||||
});
|
||||
|
||||
// Example regex: Adjust according to the format you need to validate
|
||||
var regex = /^[A-Za-z]{5}\d{4}[A-Za-z]$/;
|
||||
|
||||
setTimeout(() =>
|
||||
{
|
||||
$('#summernote-header').summernote('code', $('#header_html').val());
|
||||
$('#summernote-footer').summernote('code', $('#footer_html').val());
|
||||
|
||||
}, 1000);
|
||||
|
||||
if (regex.test(panNumber)) {
|
||||
errorMessage.style.display = "none";
|
||||
|
||||
} else {
|
||||
errorMessage.style.display = "inline";
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#savedata").on("click", function()
|
||||
{
|
||||
|
||||
var headerContent = $('#summernote-header').summernote('code');
|
||||
var footerContent = $('#summernote-footer').summernote('code');
|
||||
formData ={
|
||||
business_id : $('#business_id').val(),
|
||||
business_name : $('#business_name').val(),
|
||||
header_html : headerContent,
|
||||
footer_html : footerContent,
|
||||
};
|
||||
|
||||
console.log(formData);
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url()."add_business"; ?>',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
json: true,
|
||||
success: function(response) {
|
||||
|
||||
if(response.success){
|
||||
|
||||
toastr.success('Data saved successfully ', 'Success');
|
||||
window.location.href = '<?= base_url()."business_list"; ?>';
|
||||
|
||||
}else{
|
||||
toastr.warning('Something went wrong', 'Warning');
|
||||
}
|
||||
|
||||
// Function to allow only numbers in input field
|
||||
function isNumberKey(evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle errors here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
// Function to validate mobile number format
|
||||
function validateMobileNumber() {
|
||||
alert();
|
||||
var mobileNumber = document.getElementById("mobile_no").value;
|
||||
alert(mobileNumber);
|
||||
var errorMessage = document.getElementById("error-message2");
|
||||
// Regular expression to match a 10-digit Indian mobile number
|
||||
var mobileRegex = /^[6-9]\d{9}$/;
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
if (mobileRegex.test(mobileNumber)) {
|
||||
errorMessage.style.display = "none";
|
||||
|
||||
} else {
|
||||
errorMessage.style.display = "inline";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title">Business List</h4>
|
||||
<div class="page-title-right">
|
||||
<a href="#" id="add_branch_model_open" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
|
||||
<!-- <a href="#" id="add_branch_model_open" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect"> -->
|
||||
|
||||
<!-- <a href="<?= base_url('new_business/0'); ?>" class="btn btn-primary waves-effect waves-light"> -->
|
||||
<a href="<?= base_url('new_business/0'); ?>" class="btn btn-primary waves-effect waves-light">
|
||||
Create Business
|
||||
</a>
|
||||
</div>
|
||||
@ -53,10 +53,10 @@
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['business_id']; ?>" onclick="editbusiness(this)" class="edit-button dropdown-item"><i
|
||||
class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
|
||||
<!-- <a href="<?= "new_business/" . $value['business_id']; ?>" class="edit-button" style="margin-right: 5px;"><i
|
||||
class="ri-pencil-line"></i></a> -->
|
||||
|
||||
<a href="<?= "new_business/" . $value['business_id']; ?>" class="edit-button" >
|
||||
<i class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit
|
||||
</a>
|
||||
|
||||
<a href="<?= "delete_business/" . $value['business_id']; ?>"
|
||||
class="delete-button dropdown-item"><i style="margin-right: 16px !important;margin-left: 5px;" class="ri-delete-bin-line"></i>Delete</a>
|
||||
@ -85,59 +85,7 @@
|
||||
|
||||
|
||||
|
||||
<div id="bike_make_login-modal" aria-hidden="true" aria-modal="true" data-backdrop="static" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 id="business_type">Add Business</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="text-center mt-2 mb-4">
|
||||
|
||||
</div>
|
||||
<form id="model_form_data" action="<?= base_url() . "add_business"; ?>" method="post" class="px-4" enctype="multipart/form-data">
|
||||
|
||||
<input type="text" id="business_id" name="business_id" hidden>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="branchname">Business Name</label>
|
||||
<input type="text" class="form-control" id="business_name" name="businessname" placeholder="Name" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-group ">
|
||||
<label for="name">Change Logo</label>
|
||||
<div style="display: flex;">
|
||||
<input class="form-control" style="border: none;" type="file" id="business_logo" name="business_logo" accept="image/*" onchange="PreviewImage();">
|
||||
<img width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="form-group ">
|
||||
<label for="name">Letter Header</label>
|
||||
<textarea class="form-control" name="letter_header" id="letter_header"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right">
|
||||
<button class="btn btn-info waves-effect waves-light" type="submit" >Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
@ -147,13 +95,6 @@
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#datatable-buttonss').DataTable({
|
||||
|
||||
|
||||
"ordering": false
|
||||
});
|
||||
});
|
||||
|
||||
function statusChange(params) {
|
||||
console.log(params);
|
||||
@ -220,28 +161,6 @@
|
||||
$('#uploadPreview').attr('src', '<?= base_url() ?>public/assets/images/avatar_2x.png');
|
||||
})
|
||||
|
||||
function PreviewImage() {
|
||||
console.log('function called');
|
||||
var fileInput = document.getElementById("business_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>
|
||||
@ -38,7 +38,7 @@
|
||||
<form id="template-form">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="vs_category">Service Group<span class="text-danger">*</span></label>
|
||||
<select class="select2-dropdown form-control" id="service_group_id" required>
|
||||
<option value="">Select Service Group </option>
|
||||
@ -48,7 +48,7 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="vs_category">Service<span class="text-danger">*</span></label>
|
||||
<select class="select2-dropdown form-control" id="service_id" required>
|
||||
<option value="">Select Service </option>
|
||||
@ -58,12 +58,22 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="messageto-input">Template </label>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="messageto-input">Template Name<span class="text-danger">*</span> </label>
|
||||
<input type="text" class="form-control" id="template_name" value="<?= isset($templateData) ? $templateData->template_name : '' ?>" >
|
||||
<input type="hidden" id="template_id" value='<?= isset($templateData) ? $templateData->template_id : 'null' ?>'>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="vs_category">Template Header<span class="text-danger">*</span></label>
|
||||
<select class="select2-dropdown form-control" id="template_header_business" required>
|
||||
<option value="">Select Business </option>
|
||||
<?php if(isset($AllBusinessData)){ foreach ($AllBusinessData as $key => $value) { ?>
|
||||
<option value="<?php echo $value['business_id']; ?>" <?php if(isset($BusinessData)){ echo ($value['business_id'] == $BusinessData->business_id) ? 'selected' : ''; } ?> ><?php echo $value['business_name']; ?></option>
|
||||
<?php } } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@ -207,6 +217,7 @@ $("#savedata").on("click", function()
|
||||
service_group_id : $('#service_group_id').val(),
|
||||
service_id : $('#service_id').val(),
|
||||
template_id : $('#template_id').val(),
|
||||
template_header_business : $('#template_header_business').val(),
|
||||
template_name : $('#template_name').val(),
|
||||
body_text : $('.note-editable > p:first').text(),
|
||||
body_html : $('.note-codable').val(),
|
||||
@ -247,37 +258,35 @@ $("#savedata").on("click", function()
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
$('#summernote-basic').summernote({
|
||||
toolbar: [
|
||||
// [groupName, [list of button]]
|
||||
['style', ['style']],
|
||||
['font', ['bold', 'italic', 'underline', 'clear' ]],
|
||||
['fontname', ['fontname']],
|
||||
['color', ['color']],
|
||||
['para', ['ul', 'ol', 'paragraph' , 'height']],
|
||||
['table', ['table']],
|
||||
['insert', [ 'picture']],
|
||||
['view', ['fullscreen', 'codeview', 'help']],
|
||||
['mybutton', ['customButton']] // Custom button group
|
||||
],
|
||||
|
||||
|
||||
$('#summernote-basic').summernote({
|
||||
toolbar: [
|
||||
// [groupName, [list of button]]
|
||||
['style', ['style']],
|
||||
['font', ['bold', 'italic', 'underline', 'clear' ]],
|
||||
['fontname', ['fontname']],
|
||||
['color', ['color']],
|
||||
['para', ['ul', 'ol', 'paragraph' , 'height']],
|
||||
['table', ['table']],
|
||||
['insert', [ 'picture']],
|
||||
['view', ['fullscreen', 'codeview', 'help']],
|
||||
['mybutton', ['customButton']] // Custom button group
|
||||
],
|
||||
|
||||
buttons: {
|
||||
customButton: function() {
|
||||
var ui = $.summernote.ui;
|
||||
// create button
|
||||
var button = ui.button({
|
||||
contents: '<i class="fa fa-child"/> Place Holders',
|
||||
tooltip: 'Client Details Place Holders',
|
||||
click: function() {
|
||||
$('#customModal').modal('show');
|
||||
}
|
||||
});
|
||||
return button.render();
|
||||
buttons: {
|
||||
customButton: function() {
|
||||
var ui = $.summernote.ui;
|
||||
// create button
|
||||
var button = ui.button({
|
||||
contents: '<i class="fa fa-child"/> Place Holders',
|
||||
tooltip: 'Client Details Place Holders',
|
||||
click: function() {
|
||||
$('#customModal').modal('show');
|
||||
}
|
||||
});
|
||||
return button.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
setTimeout(() =>
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user