Merge branch 'main' of bitbucket.org:venbainformationtechnology/bb_sign

This commit is contained in:
bitbucket 2024-06-11 14:34:25 +05:30
commit 09b6d1efce
10 changed files with 503 additions and 185 deletions

View File

@ -13,7 +13,7 @@ use CodeIgniter\Router\RouteCollection;
$routes->match(['get','post'],'/staff_profile','StaffController::staff_profile');
$routes->match(['get','post'],'/staff_create','StaffController::staff_create');
$routes->match(['get','post'],'/client_list','StaffController::client_list');
$routes->match(['get','post'],'/client_edit','StaffController::client_edit');
$routes->match(['get','post'],'/client_edit/(:any)','StaffController::client_edit/$1');
$routes->match(['get','post'],'/client_create','StaffController::client_create');
$routes->post("change_staff_password/(:any)", "StaffController::change_staff_password/$1");
$routes->match(['get','post'],'/forgot_password','StaffController::forgot_password');
@ -34,9 +34,12 @@ use CodeIgniter\Router\RouteCollection;
$routes->post('status_client','ClientController::status_client');
$routes->post('doc_rejection','ClientController::doc_rejection');
$routes->match(['get','post'],'/client_branch_list','ClientController::client_branch_list');
$routes->post('add_client_branch','ClientController::add_client_branch');
$routes->get('get_client_branch/(:any)','ClientController::get_client_branch/$1');
$routes->get('delete_client_branch/(:any)','ClientController::delete_client_branch/$1');
$routes->match(['get','post'],'/service_group_list','MasterController::service_group_list');
$routes->match(['get','post'],'/service_group_create','MasterController::service_group_create');
$routes->match(['get','post'],'/service_group_edit','MasterController::service_group_edit');
@ -68,16 +71,15 @@ use CodeIgniter\Router\RouteCollection;
$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->post('business_edit','BusinessController::business_edit');
$routes->get('branch_index/(:any)','BranchController::branch_index/$1');
$routes->get('branch_index','BranchController::branch_index');
$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('add_branch','BranchController::new_branch');
$routes->post('branch_edit','BranchController::branch_edit');

View File

@ -22,16 +22,14 @@ class BranchController extends BaseController
}
public function branch_index($business_id)
public function branch_index()
{
$BranchModel = new BranchModel();
$BusinessModel = new BusinessModel();
$business=$BusinessModel->where('business_id',$business_id)->first();
$branch=$BranchModel->where('business_id',$business_id)->findAll();
$data['branch']=$branch;
$data['business_name']=$business['business_name'];
$data['business_id']=$business['business_id'];
$data['branch'] = $BranchModel->select('branches.*, business.business_name')
->join('business', 'branches.business_id = business.business_id', 'left')
->findAll();
$data['business_list'] = $BusinessModel->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
@ -59,17 +57,15 @@ class BranchController extends BaseController
return view('business_form',$data);
}
public function new_branch($business_id)
public function new_branch()
{
if ($business_id) {
$data = $this->request->getPost();
$data['business_id'] = $business_id;
$BranchModel = new BranchModel();
$BranchModel->insert($data);
return;
}
}
@ -114,7 +110,7 @@ class BranchController extends BaseController
public function delete_branch($branch_id)
{
$model = new BranchModel();
$where = ['branch_id' => $branch_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
$where = ['branch_id' => $branch_id]; // Assuming 'isactive' is a column in your database
$existingBranch = $model->where($where)->first();
if ($existingBranch) {
@ -127,7 +123,7 @@ class BranchController extends BaseController
}
return redirect()->to('branch_index/' . $existingBranch['business_id']);
return redirect()->to('branch_index');
}
}

View File

@ -206,4 +206,9 @@ class BusinessController extends BaseController
}
public function business_branch_list()
{
}
}

View File

@ -257,12 +257,14 @@ class ClientController extends BaseController
// $data['clientBranchList'] = $this->ClientBranchModel->select('client.* , COUNT(client_docs.id) as docs_count')
$data['clientBranchList'] = $this->ClientBranchModel->select('*')
// ->join('client_docs', 'client.client_id = client_docs.client_id', 'left')
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name')
->join('client', 'client.client_id = client_branch.client_id', 'left')
// ->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
// ->groupBy('client.client_id')
// ->groupBy('client_branch.client_id')
->findAll();
$data['client_list'] = $this->ClientModel->select('client_id, name')->where('is_active', 1)->findAll();
// echo"<pre>";
// print_r($data);die;
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
// echo view('layout/header');
@ -270,4 +272,47 @@ class ClientController extends BaseController
echo view('layout/footer');
}
public function add_client_branch()
{
$data = $this->request->getPost();
$this->ClientBranchModel->insert($data);
return;
}
public function get_client_branch($branch_id)
{
if ($branch_id) {
$branch =$this->ClientBranchModel->where('id',$branch_id)->first();
return json_encode($branch);
}
}
public function delete_client_branch($branch_id)
{
$where = ['id' => $branch_id]; // Assuming 'isactive' is a column in your database
$existingBranch = $this->ClientBranchModel->where($where)->first();
if ($existingBranch) {
$data['is_active'] = 0;
if ($this->ClientBranchModel->update($branch_id, $data)) {
session()->setFlashdata('success', 'Deleted successfully.');
$this->logger->info("Branch: has been Inactivated successfully. Inactivated ID = ".$branch_id);
}
}
return redirect()->to('client_branch_list');
}
}

View File

@ -5,6 +5,7 @@ use App\Helpers\MailHelper;
use App\Models\StaffModel;
use App\Models\ClientModel;
use App\Models\ServiceModel;
use App\Models\BranchModel;
use App\Models\TemplateModel;
use CodeIgniter\API\ResponseTrait;
@ -16,6 +17,7 @@ class StaffController extends BaseController
protected $StaffModel;
protected $ClientModel;
protected $ServiceModel;
protected $BranchModel;
protected $TemplateModel;
use ResponseTrait;
@ -26,6 +28,7 @@ class StaffController extends BaseController
$this->StaffModel = new StaffModel();
$this->ClientModel = new ClientModel();
$this->ServiceModel = new ServiceModel();
$this->BranchModel = new BranchModel();
$this->TemplateModel = new TemplateModel();
}
@ -161,7 +164,7 @@ class StaffController extends BaseController
$data['clientList'] = $this->ClientModel->select('client.* , COUNT(client_docs.id) as docs_count')
->join('client_docs', 'client.client_id = client_docs.client_id', 'left')
->join('client_docs', 'client.client_id = client_docs.client_branch_id', 'left')
->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
->groupBy('client.client_id')
->findAll();
@ -171,7 +174,7 @@ class StaffController extends BaseController
echo view('client_list',$data);
echo view('layout/footer');
}
public function client_edit()
public function client_edit($client_id)
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
if($this->request->getmethod() == 'POST')
@ -179,18 +182,21 @@ class StaffController extends BaseController
//update staff details
$clientData = $this->request->getVar();
$clientData['updated_by'] = $this->session->get('is_staff_logged_in');
$client_id = $this->request->getVar('id');
$client_id = $this->request->getVar('client_id');
$this->ClientModel->where('client_id', $client_id )->set($clientData)->update();
return redirect()->to(base_url()."client_list");
}else{
$data['clientData'] = $this->ClientModel->where('md5(client.client_id)', $this->request->getVar('client_id') )->get()->getRow();
// $data['clientData'] = $this->ClientModel->where('md5(client.client_id)', $this->request->getVar('client_id') )->get()->getRow();
$data['clientData'] = $this->ClientModel->where('client_id', $client_id )->get()->getRow();
// print_r($data);die;
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('client_form',$data);
echo view('layout/footer');
return json_encode($data['clientData']);
// echo view('layout/header', ['Data'=>$staffdata]);
// echo view('client_form',$data);
// echo view('layout/footer');
}
@ -200,10 +206,15 @@ class StaffController extends BaseController
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
if($this->request->getmethod() == 'POST')
{
{
$clientData = $this->request->getVar();
$clientData['created_by'] = $this->session->get('is_staff_logged_in');
$clientData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
$business= $this->BranchModel->select('*')
->join('business' , 'branches.business_id = business.business_id', 'left')
->where('branches.branch_id ',$clientData['branch_id'])
->first();
$clientData['business_id'] = $business['business_id'];
$insert = $this->ClientModel->save($clientData);
if($insert)
{

View File

@ -10,7 +10,7 @@
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Branch List - <?php echo $business_name;?></h4>
<h4 class="page-title">Branch List</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class=""> <a href="#" id="add_branch_model_open" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
@ -59,6 +59,7 @@
<td><?= $value['state']; ?></td>
<td><?= $value['postal_code']; ?></td>
<td><?= $value['contact_1']; ?></td>
<td><?= $value['isactive'] ?></td>
<td>
<?php if ($value['isactive'] == 0): ?>
<span style="color: red;">Inactive</span>
@ -70,12 +71,16 @@
<a href="<?= base_url("user_list/" . $value['branch_id']) ?>" style="margin-left: 15px;">View</a>
</td> -->
<td>
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['branch_id']; ?>" onclick="editBranch(this)" class="edit-button"><i
class="ri-pencil-line" style="margin-right: 5px;"></i></a>
<a href="<?= base_url("delete_branch/".$value['branch_id']); ?>"
class="delete-button"><i class="ri-delete-bin-line"></i></a>
<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['branch_id']; ?>" onclick="editBranch(this)" class="edit-button dropdown-item"><i
class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<a href="<?= base_url("delete_branch/".$value['branch_id']); ?>"
class="delete-button dropdown-item"><i style="margin-right: 16px !important;margin-left: 5px;" class="ri-delete-bin-line"></i>Delete</a>
</div>
</div>
</td>
<?php endforeach; ?>
@ -98,18 +103,31 @@
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 id="branch_action_type">Add Branch</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">
<h4>Add Branch - <?php echo $business_name;?></h4>
</div>
<form id="model_form_data" class="px-4">
<input type="text" id="business_id" value="<?php echo $business_id; ?>" hidden>
<input type="text" id="business_id" value="" hidden>
<input type="text" id="branch_id" hidden>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="branchname">Branch Name</label>
<select name="business" id="business" class="form-control">
<option value="0">Select Business</option>
<?php foreach ($business_list as $key => $value) { ?>
<option value="<?php echo $value['business_id'] ?>"><?php echo $value['business_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="branchname">Branch Name</label>
@ -157,13 +175,13 @@
<div class="col-md-6">
<div class="form-group">
<label for="state">State</label>
<input class="form-control" name="state" type="text" id="state" required="" placeholder="State">
<input class="form-control" name="state" value="Tamil Nadu" type="text" id="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" required="" placeholder="Country">
<input class="form-control" name="country" value="India" type="text" id="country" required="" placeholder="Country">
</div>
</div>
<div class="col-md-6">
@ -172,16 +190,10 @@
<input class="form-control" name="postal_code" type="text" id="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" required="" placeholder="State Code">
</div>
</div>
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitBranch(this)">Submit</button>
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button>
</div>
</form>
@ -204,10 +216,11 @@
if ($('#branch_id').val()) {
var url = '<?= base_url("edit_branch/"); ?>'+$('#branch_id').val();
}else{
var url = '<?= base_url("add_branch/".$business_id); ?>';
var url = '<?= base_url("add_branch"); ?>';
}
var formData = {
business_id: $('#business').val(),
gstno: $('#gst_no').val(),
email: $('#email').val(),
contact_1: $('#contact_1').val(),
@ -255,35 +268,38 @@
});
}
function editBranch(params) {
$.ajax({
type: 'GET',
url: '<?= base_url("get_branch/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
// console.log(response);
$('#branch_name').val(response.branch_name);
$('#gst_no').val(response.gstno);
$('#email').val(response.email);
$('#contact_1').val(response.contact_1);
$('#contact_2').val(response.contact_2);
$('#address').val(response.address);
$('#branch_id').val(response.branch_id);
$('#city').val(response.city);
$('#postal_code').val(response.postal_code);
$('#state').val(response.state);
$('#country').val(response.country);
$('#state_code').val(response.state_code);
$('#branch_action_type').html('Edit Branch');
$.ajax({
type: 'GET',
url: '<?= base_url("get_branch/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
// console.log(response);
$('#business').val(response.business_id);
$('#branch_name').val(response.branch_name);
$('#gst_no').val(response.gstno);
$('#email').val(response.email);
$('#contact_1').val(response.contact_1);
$('#contact_2').val(response.contact_2);
$('#address').val(response.address);
$('#branch_id').val(response.branch_id);
$('#city').val(response.city);
$('#postal_code').val(response.postal_code);
$('#state').val(response.state);
$('#country').val(response.country);
$('#state_code').val(response.state_code);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$('#add_branch_model_open').click( function(){
$('#model_form_data')[0].reset();
})
$('#add_branch_model_open').click( function(){
$('#branch_action_type').html('Add Branch');
$('#model_form_data')[0].reset();
})
</script>

View File

@ -35,14 +35,6 @@
<tr>
<th>#</th>
<th>Business Name</th>
<!-- <th>Email</th> -->
<!-- <th>Mobile</th> -->
<!-- <th style="width:10% !important">Address</th> -->
<!-- <th>City</th> -->
<!-- <th>State</th> -->
<!-- <th>Postal Code</th> -->
<!-- <th>Country</th> -->
<th>Branch List</th>
<th>Action</th>
</tr>
</thead>
@ -57,16 +49,19 @@
<td><?= $value['business_name']; ?></td>
<!-- Call the model method -->
<td> <a href="<?= base_url("branch_index/" . $value['business_id']) ?>" style="margin-left: 20px;">View</a></td>
<td>
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['business_id']; ?>" onclick="editbusiness(this)" class="edit-button"><i
class="ri-pencil-line" style="margin-right: 5px;"></i></a>
<!-- <a href="<?= "new_business/" . $value['business_id']; ?>" class="edit-button" style="margin-right: 5px;"><i
class="ri-pencil-line"></i></a> -->
<a href="<?= "delete_business/" . $value['business_id']; ?>"
class="delete-button"><i class="ri-delete-bin-line"></i></a>
<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="<?= "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>
</div>
</div>
</td>
<?php endif?>
@ -90,19 +85,23 @@
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<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">
<h4>Add Business</h4>
</div>
<form id="model_form_data" action="<?= base_url() . "add_business"; ?>" method="post" class="px-4">
<input type="text" id="business_id" name="business_id" hidden>
<div class="row">
<div class="col-md-6">
<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>
@ -111,8 +110,8 @@
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" >Submit</button>
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" >Submit</button>
</div>
</form>
@ -172,25 +171,26 @@
function editbusiness(params) {
console.log(params.getAttribute('value'));
$.ajax({
type: 'GET',
url: '<?= base_url("get_business/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
console.log(response);
$('#business_name').val(response.business_name);
$('#business_id').val(response.business_id);
$('#business_type').html('Edit Business');
$.ajax({
type: 'GET',
url: '<?= base_url("get_business/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
$('#business_name').val(response.business_name);
$('#business_id').val(response.business_id);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$('#add_branch_model_open').click(function () {
$('#business_type').html('Add Business');
})

View File

@ -33,25 +33,49 @@
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100">
<thead>
<tr>
<th>Branch Name</th>
<th>GST</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Postal Code</th>
<th>Contact</th>
<th>Active</th>
<!-- <th>User List</th> -->
<th>Action</th>
<th>Client</th>
<th>Branch Name</th>
<th>GST No</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Postal Code</th>
<th>Mobile No</th>
<th>Active</th>
<th>Action</th>
</tr>
</thead>
<tr>
<td></td>
</tr>
</thead>
<tbody>
<?php foreach ($clientBranchList as $value) :?>
<tr>
<td><?= $value['client_name']; ?></td>
<td><?= $value['name']; ?></td>
<td><?= $value['gst_no']; ?></td>
<td><?= $value['address']; ?></td>
<td><?= $value['city']; ?></td>
<td><?= $value['state']; ?></td>
<td><?= $value['pin_code']; ?></td>
<td><?= $value['mobile_no']; ?></td>
<td>
<?php if ($value['is_active'] == 0): ?>
<span style="color: red;">Inactive</span>
<?php else: ?>
<span style="color: green;">Active</span>
<?php endif; ?>
</td>
<td>
<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['id']; ?>" onclick="editBranch(this)" class="edit-button dropdown-item"><i
class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<a href="<?= base_url("delete_client_branch/".$value['id']); ?>"
class="delete-button dropdown-item"><i style="margin-right: 16px !important;margin-left: 5px;" class="ri-delete-bin-line"></i>Delete</a>
</div>
</div>
</td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
@ -67,12 +91,13 @@
</div> <!-- content -->
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<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 modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="modal-header"> <h4>Add Branch </h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button></div>
<div class="modal-body" style="margin-top: -29px;">
<div class="text-center mt-2 mb-4">
<h4>Add Branch - </h4>
</div>
<form id="model_form_data" class="px-4">
@ -80,12 +105,25 @@
<input type="text" id="branch_id" hidden>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="client">Client</label>
<select name="client" id="client" class="form-control" style="width: auto;">
<option value="0">Select Client</option>
<?php foreach ($client_list as $key => $value) { ?>
<option value="<?php echo $value['client_id']; ?>"><?php echo $value['name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="branchname">Branch Name</label>
<input class="form-control" name="branch_name" type="text" id="branch_name" required="" placeholder="Branch Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="gstno">GST No</label>
@ -100,14 +138,8 @@
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact1">Contact 1</label>
<input class="form-control" name="contact_1" type="text" id="contact_1" required="" minlength="6" maxlength="16" placeholder="Contact 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact2">Contact 2</label>
<input class="form-control" name="contact_2" type="text" id="contact_2" required="" minlength="6" maxlength="16" placeholder="Contact 2">
<label for="mobile_no">Mobile No</label>
<input class="form-control" name="mobile_no" type="text" id="mobile_no" required="" minlength="6" maxlength="16" placeholder="Mobile No">
</div>
</div>
</div>
@ -127,13 +159,13 @@
<div class="col-md-6">
<div class="form-group">
<label for="state">State</label>
<input class="form-control" name="state" type="text" id="state" required="" placeholder="State">
<input class="form-control" name="state" type="text" id="state" value="Tamil Nadu" 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" required="" placeholder="Country">
<label for="country">Country</label>
<input class="form-control" name="country" type="text" value="India" id="country" required="" placeholder="Country">
</div>
</div>
<div class="col-md-6">
@ -142,16 +174,11 @@
<input class="form-control" name="postal_code" type="text" id="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" required="" placeholder="State Code">
</div>
</div>
</div>
<div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitBranch(this)">Submit</button>
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button>
</div>
</form>
@ -161,4 +188,91 @@
</div><!-- /.modal -->
<script>
function submitBranch(params) {
if ($('#branch_id').val()) {
var url = '<?= base_url("edit_client_branch/"); ?>'+$('#branch_id').val();
}else{
var url = '<?= base_url("add_client_branch"); ?>';
}
var formData = {
client_id: $('#client').val(),
gst_no: $('#gst_no').val(),
email: $('#email').val(),
contact: $('#contact').val(),
country: $('#country').val(),
state_code: $('#state_code').val(),
name: $('#branch_name').val(),
address: $('#address').val(),
city: $('#city').val(),
state: $('#state').val(),
postal_code: $('#postal_code').val(),
mobile_no: $('#mobile_no').val()
};
var form = $(params).parent().parent();
// console.log(form);
var isValid = true;
form[0].querySelectorAll('[required]').forEach(function(element) {
if (!element.value.trim()) {
isValid = false;
}
});
if (!isValid) {
return;
}
var business_id = $('#business_id').val();
$.ajax({
type: 'POST',
url: url,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
$('#bike_model_login-modal').modal('hide');
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function editBranch(params) {
$.ajax({
type: 'GET',
url: '<?= base_url("get_client_branch/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
console.log(response);
$('#client').val(response.client_id);
$('#branch_name').val(response.name);
$('#gst_no').val(response.gst_no);
$('#email').val(response.email);
$('#mobile_no').val(response.mobile_no);
$('#address').val(response.address);
$('#branch_id').val(response.branch_id);
$('#city').val(response.city);
$('#postal_code').val(response.pin_code);
$('#state').val(response.state);
$('#country').val(response.country);
$('#state_code').val(response.state_code);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -12,7 +12,7 @@
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Client List</h4>
<div class="page-title-right">
<a href="<?= base_url('client_create'); ?>" class="btn btn-primary waves-effect waves-light">
<a id="add_client_button" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect waves-light">
Create Client
</a>
</div>
@ -63,7 +63,7 @@
<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 class="dropdown-item" href="<?= base_url()."client_edit?client_id=".md5($value['client_id']); ?>" > <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<a class="dropdown-item" data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['client_id']; ?>" onclick="editBranch(this)"> <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['client_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="ri-shield-user-line"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
@ -96,7 +96,59 @@
</div> <!-- content -->
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 id="branch_action_type">Add Client</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form id="model_form_data" class="px-4">
<input type="text" id="business_id" value="" hidden>
<input type="text" id="client_id" value="" hidden>
<input type="text" id="branch_id" hidden>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input class="form-control" name="name" type="text" id="name" required="" placeholder="Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="panno">Pan No</label>
<input class="form-control" parsley-trigger="change" name="pan_no" type="text" id="pan_no" required="" placeholder="PAN No" pattern="[A-Z]{5}[0-9]{4}[A-Z]{1}" title="Please enter a valid PAN in the format ABCDE1234F">
<span id="error-message" style="color:red;display:none;">Invalid PAN Number.</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" name="email" type="email" id="email" required="" placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="mobile_no">Mobile No</label>
<input class="form-control" name="mobile_no" type="text" id="mobile_no" required placeholder="Mobile No" pattern="[0-9]{6,16}" minlength="6" maxlength="16" title="Please enter a valid mobile number between 6 and 16 digits">
</div>
</div>
</div>
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
@ -114,6 +166,58 @@
});
});
function submitBranch(params) {
var formData = {
pan_no: $('#pan_no').val(),
email: $('#email').val(),
name: $('#name').val(),
mobile_no: $('#mobile_no').val()
};
if ($('#client_id').val()) {
formData.client_id = $('#client_id').val();
var url = '<?= base_url("client_edit/"); ?>'+$('#client_id').val();
}else{
var url = '<?= base_url("client_create"); ?>';
}
var form = $(params).parent().parent();
// console.log(form);
var isValid = true;
form[0].querySelectorAll('[required]').forEach(function(element) {
if (!element.value.trim()) {
isValid = false;
}
});
if (!isValid) {
return;
}
$.ajax({
type: 'POST',
url: url,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
$('#bike_model_login-modal').modal('hide');
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function statusChange(params) {
console.log(params);
var status = params.getAttribute('data-isactive');
@ -148,4 +252,47 @@
}
function validatePanNumber() {
var panNumber = document.getElementById("pan_no").value;
var errorMessage = document.getElementById("error-message");
// Example regex: Adjust according to the format you need to validate
var regex = /^[A-Za-z]{5}\d{4}[A-Za-z]$/;
if (regex.test(panNumber)) {
errorMessage.style.display = "none";
} else {
errorMessage.style.display = "inline";
}
}
function editBranch(params) {
$('#branch_action_type').html('Edit Client');
$.ajax({
type: 'GET',
url: '<?= base_url("client_edit/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
console.log(response);
$('#client_id').val(response.client_id);
$('#name').val(response.name);
$('#pan_no').val(response.pan_no);
$('#email').val(response.email);
$('#mobile_no').val(response.mobile_no);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$('##bike_make_login-modal').click(function (params) {
$('#branch_action_type').html('Add Client');
})
</script>

View File

@ -290,28 +290,6 @@
<i class="ri-share-line"></i> Share Docs </a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-client" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-shield-user-line mr-1"></i> Client <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-client">
<a href="<?= base_url()."client_list"; ?>" class="dropdown-item">Client List</a>
<a href="<?= base_url()."client_branch_list"; ?>" class="dropdown-item">Client Branch</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-staff" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-user-line mr-1"></i> Staff <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-staff">
<a href="<?= base_url()."staff_list"; ?>" class="dropdown-item">Staff List</a>
<a href="<?= base_url()."staff_create"; ?>" class="dropdown-item">Create Staff</a>
</div>
</li>
<li class="nav-item dropdown">
@ -323,16 +301,20 @@
<a href="<?= base_url()."service_group_list"; ?>" class="dropdown-item">Service Group</a>
<a href="<?= base_url()."service_list"; ?>" class="dropdown-item">Services</a>
<a href="<?= base_url()."template_list"; ?>" class="dropdown-item">Template</a>
<a href="<?= base_url()."client_list"; ?>" class="dropdown-item">Client</a>
<a href="<?= base_url()."client_branch_list"; ?>" class="dropdown-item">Client Branch</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-my-visa" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-building"></i> Business <div class="arrow-down"></div>
<i class="fas fa-building"></i> Business Masters <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-my-visa">
<a href="<?= base_url()."business_list"; ?>" class="dropdown-item">Business</a>
<a href="<?= base_url()."branch_index"; ?>" class="dropdown-item">Business Branch</a>
<a href="<?= base_url()."staff_list"; ?>" class="dropdown-item">Staff</a>
</div>
</li>