CHANGE_BUSINESS_BRANCH_ADD_IN_ALL : AADHAVAN
This commit is contained in:
parent
73af47e38c
commit
35b553f32d
@ -58,6 +58,20 @@ use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
|
||||
|
||||
$routes->get('business_list','BusinessController::business_list');
|
||||
$routes->get('new_business/(:any)','BusinessController::new_business/$1');
|
||||
$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('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');
|
||||
|
||||
|
||||
|
||||
|
||||
118
app/Controllers/BranchController.php
Normal file
118
app/Controllers/BranchController.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BranchModel;
|
||||
// use App\Models\RoleModel;
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\StaffModel;
|
||||
|
||||
|
||||
class BranchController extends BaseController
|
||||
{
|
||||
|
||||
public $session;
|
||||
protected $StaffModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
$this->StaffModel = new StaffModel();
|
||||
|
||||
}
|
||||
|
||||
public function branch_index($business_id)
|
||||
{
|
||||
$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'];
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('branch_list',$data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
|
||||
public function new_business($business_id)
|
||||
{
|
||||
|
||||
|
||||
if ($business_id === '0') {
|
||||
|
||||
$data['business'] = [];
|
||||
$data['page_name']="Add Business";
|
||||
} else if ($business_id !== '0') {
|
||||
|
||||
$BusinessModel = new BusinessModel();
|
||||
$business=$BusinessModel->getBusinessById($business_id);
|
||||
$data['business']=$business;
|
||||
$data['page_name']="Edit Business" ;
|
||||
}
|
||||
$data['business_id'] = $business_id;
|
||||
|
||||
return view('business_form',$data);
|
||||
}
|
||||
public function new_branch($business_id)
|
||||
{
|
||||
if ($business_id) {
|
||||
$data = $this->request->getPost();
|
||||
$data['business_id'] = $business_id;
|
||||
$BranchModel = new BranchModel();
|
||||
|
||||
$BranchModel->insert($data);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get_branch($branch_id)
|
||||
{
|
||||
if ($branch_id) {
|
||||
$BranchModel = new BranchModel();
|
||||
$branch =$BranchModel->where('branch_id',$branch_id)->first();
|
||||
|
||||
return json_encode($branch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function edit_branch($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();
|
||||
$where = ['branch_id' => $branch_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
|
||||
$existingBranch = $model->where($where)->first();
|
||||
|
||||
if ($existingBranch) {
|
||||
$data['isactive'] = 0;
|
||||
|
||||
if ($model->update($branch_id, $data)) {
|
||||
session()->setFlashdata('success', 'Deleted successfully.');
|
||||
$this->logger->info("Branch: has been Inactivated successfully. Inactivated ID = ".$branch_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return redirect()->to('branch_index/' . $existingBranch['business_id']);
|
||||
}
|
||||
|
||||
}
|
||||
144
app/Controllers/BusinessController.php
Normal file
144
app/Controllers/BusinessController.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\StaffModel;
|
||||
|
||||
|
||||
|
||||
class BusinessController extends BaseController
|
||||
{
|
||||
public $session;
|
||||
protected $BusinessModel;
|
||||
protected $StaffModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->StaffModel = new StaffModel();
|
||||
|
||||
}
|
||||
|
||||
public function business_list()
|
||||
{
|
||||
$data['business'] = $this->BusinessModel->findAll();
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('business_list',$data);
|
||||
echo view('layout/footer');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function new_business($business_id)
|
||||
{
|
||||
|
||||
|
||||
if ($business_id === '0') {
|
||||
|
||||
$data['business'] = [];
|
||||
$data['page_name']="Add Business";
|
||||
} else if ($business_id !== '0') {
|
||||
|
||||
$BusinessModel = new BusinessModel();
|
||||
$business=$BusinessModel->getBusinessById($business_id);
|
||||
$data['business']=$business;
|
||||
$data['page_name']="Edit Business" ;
|
||||
}
|
||||
$data['business_id'] = $business_id;
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('business_form',$data);
|
||||
echo view('layout/footer');
|
||||
|
||||
}
|
||||
public function new_branch($business_id)
|
||||
{
|
||||
|
||||
|
||||
if ($business_id === '0') {
|
||||
|
||||
$data['business'] = [];
|
||||
$data['page_name']="Add Branch";
|
||||
} else if ($business_id !== '0') {
|
||||
|
||||
$BusinessModel = new BusinessModel();
|
||||
$business=$BusinessModel->getBusinessById($business_id);
|
||||
$data['business']=$business;
|
||||
$data['page_name']="Edit Branch" ;
|
||||
}
|
||||
$data['business_id'] = $business_id;
|
||||
|
||||
return view('branch_form',$data);
|
||||
}
|
||||
|
||||
|
||||
public function add_business()
|
||||
{
|
||||
// print_r("hello");die;
|
||||
$BusinessModel = new BusinessModel();
|
||||
|
||||
|
||||
$data = [
|
||||
'business_name' => $this->request->getPost('businessname'),
|
||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||
];
|
||||
|
||||
$business_id = $this->request->getPost('business_id');
|
||||
|
||||
|
||||
if (!empty($business_id)) {
|
||||
|
||||
$BusinessModel->update($business_id, $data);
|
||||
} else {
|
||||
|
||||
$BusinessModel->insert($data);
|
||||
}
|
||||
|
||||
// echo"<pre>";
|
||||
// print_r(session()->get("logged_user_business_id"));die;
|
||||
|
||||
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();
|
||||
$where = ['business_id' => $business_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
|
||||
$existingBusiness = $model->where($where)->first();
|
||||
|
||||
if ($existingBusiness) {
|
||||
$data['isactive'] = 0;
|
||||
|
||||
if ($model->update($business_id, $data)) {
|
||||
session()->setFlashdata('success', 'Deleted successfully.');
|
||||
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$business_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return redirect()->to('business_list');
|
||||
}
|
||||
|
||||
public function get_business($business_id)
|
||||
{
|
||||
if ($business_id) {
|
||||
$BusinessModel = new BusinessModel();
|
||||
$business =$BusinessModel->where('business_id',$business_id)->first();
|
||||
|
||||
return json_encode($business);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -49,6 +49,8 @@ class MasterController extends BaseController
|
||||
// $data['serviceList'] = $this->ServiceModel->findAll();
|
||||
$data['serviceList'] = $this->ServiceModel->select('services.* , COUNT(template.template_id) as template_count')
|
||||
->join('template', 'services.service_id = template.service_id', 'left')
|
||||
->where('services.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
||||
->groupBy('services.service_id')
|
||||
->findAll();
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
@ -65,6 +67,8 @@ class MasterController extends BaseController
|
||||
if($this->request->getmethod() == 'POST')
|
||||
{
|
||||
$serviceData = $this->request->getVar();
|
||||
$serviceData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||
|
||||
$this->ServiceModel->insert($serviceData);
|
||||
return redirect()->to(base_url()."service_list");
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ class StaffController extends BaseController
|
||||
$this->session->set('is_staff_logged_in',$staffdata['staff_id']);
|
||||
$this->session->set('logged_in_staff_role',$staffdata['role']);
|
||||
$this->session->set('logged_in_staff_name',$staffdata['name']);
|
||||
$this->session->set('logged_in_staff_branch_id',$staffdata['branch_id']);
|
||||
|
||||
return redirect()->to(base_url().'staff_list');
|
||||
}
|
||||
@ -78,6 +79,7 @@ class StaffController extends BaseController
|
||||
public function staff_logout()
|
||||
{
|
||||
session()->remove('is_staff_logged_in');
|
||||
session()->remove('logged_in_staff_branch_id');
|
||||
session()->destroy();
|
||||
return redirect()->to(base_url()."staff");
|
||||
}
|
||||
@ -94,7 +96,7 @@ class StaffController extends BaseController
|
||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||
|
||||
|
||||
$data['staffList'] = $this->StaffModel->where('staff.staff_id != ',session()->get('is_staff_logged_in') )->findAll();
|
||||
$data['staffList'] = $this->StaffModel->where('staff.staff_id != ',session()->get('is_staff_logged_in') )->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
@ -109,6 +111,7 @@ class StaffController extends BaseController
|
||||
{
|
||||
$staffData = $this->request->getVar();
|
||||
$staffData['created_by'] = $this->session->get('is_staff_logged_in');
|
||||
$staffData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||
$insert = $this->StaffModel->save($staffData);
|
||||
if($insert)
|
||||
{
|
||||
@ -158,6 +161,8 @@ 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')
|
||||
->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
||||
->groupBy('client.client_id')
|
||||
->findAll();
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
@ -197,6 +202,7 @@ class StaffController extends BaseController
|
||||
{
|
||||
$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');
|
||||
$insert = $this->ClientModel->save($clientData);
|
||||
if($insert)
|
||||
{
|
||||
|
||||
15
app/Models/BranchModel.php
Normal file
15
app/Models/BranchModel.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class BranchModel extends Model
|
||||
{
|
||||
protected $table = 'branches';
|
||||
protected $primaryKey = 'branch_id';
|
||||
protected $allowedFields = ['business_id','branch_id','branch_name','gstno','email','contact_1','contact_2','address','city','state','country','postal_code','state_code','isactive'];
|
||||
|
||||
public function getBranchesByBusinessId($business_id)
|
||||
{
|
||||
// Query the database to retrieve branches associated with the provided business ID
|
||||
return $this->where('business_id', $business_id)->findAll();
|
||||
}
|
||||
}
|
||||
13
app/Models/BusinessModel.php
Normal file
13
app/Models/BusinessModel.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class BusinessModel extends Model
|
||||
{
|
||||
protected $table = 'business';
|
||||
protected $primaryKey = 'business_id';
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','isactive'];
|
||||
|
||||
public function getBusinessById($business_id) {
|
||||
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ class ClientModel extends Model
|
||||
protected $table = 'client';
|
||||
protected $primaryKey = 'client_id';
|
||||
|
||||
protected $allowedFields = [ 'name','pan_no', 'mobile_no' , 'email' , 'otp', 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
|
||||
protected $allowedFields = [ 'branch_id', 'name','pan_no', 'mobile_no' , 'email' , 'otp', 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
|
||||
|
||||
protected $beforeInsert = ['beforeInsert'];
|
||||
protected $beforeUpdate = ['beforeUpdate'];
|
||||
|
||||
@ -7,7 +7,7 @@ class ServiceModel extends Model
|
||||
protected $table = 'services';
|
||||
protected $primaryKey = 'service_id';
|
||||
|
||||
protected $allowedFields = ['service_name', 'notes' ,'is_active' ,'created_by','updated_by'];
|
||||
protected $allowedFields = ['branch_id','service_name', 'notes' ,'is_active' ,'created_by','updated_by'];
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ class StaffModel extends Model
|
||||
protected $table = 'staff';
|
||||
protected $primaryKey = 'staff_id';
|
||||
|
||||
protected $allowedFields = [ 'role' , 'name', 'mobile_no' , 'email', 'password' , 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
|
||||
protected $allowedFields = [ 'branch_id','role' , 'name', 'mobile_no' , 'email', 'password' , 'address' , 'city' , 'state' , 'country' , 'pin_code' , 'is_active' ,'created_by','updated_by'];
|
||||
|
||||
protected $beforeInsert = ['beforeInsert'];
|
||||
protected $beforeUpdate = ['beforeUpdate'];
|
||||
@ -32,7 +32,7 @@ class StaffModel extends Model
|
||||
{
|
||||
|
||||
$builder = $this->db->table('staff');
|
||||
$builder -> select("staff_id,name,email,password,is_active,role");
|
||||
$builder -> select("staff_id,name,email,password,is_active,role,branch_id");
|
||||
$builder -> where('email',$email);
|
||||
$result = $builder->get();
|
||||
if(count($result->getResultArray()) ==1)
|
||||
|
||||
289
app/Views/branch_list.php
Normal file
289
app/Views/branch_list.php
Normal file
@ -0,0 +1,289 @@
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
<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>
|
||||
<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">
|
||||
Add Branch
|
||||
</a>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($branch as $value) :
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $value['branch_name']; ?></td>
|
||||
<td><?= $value['gstno']; ?></td>
|
||||
<td><?= $value['address']; ?></td>
|
||||
<td><?= $value['city']; ?></td>
|
||||
<td><?= $value['state']; ?></td>
|
||||
<td><?= $value['postal_code']; ?></td>
|
||||
<td><?= $value['contact_1']; ?></td>
|
||||
<td>
|
||||
<?php if ($value['isactive'] == 0): ?>
|
||||
<span style="color: red;">Inactive</span>
|
||||
<?php else: ?>
|
||||
<span style="color: green;">Active</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<!-- <td>
|
||||
<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>
|
||||
</td>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div> <!-- container -->
|
||||
|
||||
</div> <!-- content -->
|
||||
|
||||
|
||||
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<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="branch_id" hidden>
|
||||
|
||||
<div class="row">
|
||||
<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>
|
||||
<input class="form-control" name="gst_no" type="text" id="gst_no" required="" placeholder="GST No" pattern="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}[Z]{1}[0-9A-Z]{1}">
|
||||
</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="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">
|
||||
</div>
|
||||
</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" 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" 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" 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">
|
||||
</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" 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>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
function submitBranch(params) {
|
||||
|
||||
if ($('#branch_id').val()) {
|
||||
var url = '<?= base_url("edit_branch/"); ?>'+$('#branch_id').val();
|
||||
}else{
|
||||
var url = '<?= base_url("add_branch/".$business_id); ?>';
|
||||
}
|
||||
|
||||
var formData = {
|
||||
gstno: $('#gst_no').val(),
|
||||
email: $('#email').val(),
|
||||
contact_1: $('#contact_1').val(),
|
||||
contact_2: $('#contact_2').val(),
|
||||
country: $('#country').val(),
|
||||
state_code: $('#state_code').val(),
|
||||
branch_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();
|
||||
// console.log(formData);
|
||||
|
||||
$.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_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);
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#add_branch_model_open').click( function(){
|
||||
$('#model_form_data')[0].reset();
|
||||
})
|
||||
|
||||
</script>
|
||||
115
app/Views/business_form.php
Normal file
115
app/Views/business_form.php
Normal file
@ -0,0 +1,115 @@
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title">Create Business</h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Minton</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Pages</a></li>
|
||||
<li class="breadcrumb-item active">Starter</li> -->
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<form action="<?= base_url() . "add_business"; ?>" method="post">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<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>
|
||||
</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>
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div>
|
||||
<!-- end col -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div> <!-- container -->
|
||||
|
||||
</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);
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
// 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>
|
||||
|
||||
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
197
app/Views/business_list.php
Normal file
197
app/Views/business_list.php
Normal file
@ -0,0 +1,197 @@
|
||||
<!-- ============================================================== -->
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<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="<?= base_url('new_business/0'); ?>" class="btn btn-primary waves-effect waves-light"> -->
|
||||
Create Business
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<table id="datatable-buttonss" class="table table-striped dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<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>
|
||||
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($business as $value) :
|
||||
if ($value['isactive'] == 1) : ?>
|
||||
<tr>
|
||||
<td><?= $value['business_id']; ?></td>
|
||||
<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>
|
||||
</td>
|
||||
|
||||
<?php endif?>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div> <!-- container -->
|
||||
|
||||
</div> <!-- content -->
|
||||
|
||||
|
||||
|
||||
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<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="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>
|
||||
|
||||
<div class="form-group text-center">
|
||||
<button class="btn btn-rounded btn-primary" type="submit" >Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
<!-- ============================================================== -->
|
||||
<!-- End Page content -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#datatable-buttonss').DataTable({
|
||||
|
||||
|
||||
"ordering": false
|
||||
});
|
||||
});
|
||||
|
||||
function statusChange(params) {
|
||||
console.log(params);
|
||||
var status = params.getAttribute('data-isactive');
|
||||
var client_id = params.getAttribute('data-id');
|
||||
if(status == 1){
|
||||
var is_active= 0;
|
||||
}else{
|
||||
var is_active= 1;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
client_id: client_id,
|
||||
is_active: is_active
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo base_url()."status_client"?>',
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.data) {
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@ -28,7 +28,7 @@
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100">
|
||||
<table id="datatable-buttonss" class="table table-striped dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -107,7 +107,7 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#datatable-buttons').DataTable({
|
||||
$('#datatable-buttonss').DataTable({
|
||||
|
||||
|
||||
"ordering": false
|
||||
|
||||
@ -314,9 +314,18 @@
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php if($_SESSION['logged_in_staff_role'] == 'Super Admin') { ?>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="topnav-my-visa">
|
||||
<a href="<?= base_url()."business_list"; ?>" class="dropdown-item">Business</a>
|
||||
</div>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
</ul> <!-- end navbar-->
|
||||
</div> <!-- end .collapsed-->
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100">
|
||||
<table id="datatable-buttonss" class="table table-striped dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -100,7 +100,7 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#datatable-buttons').DataTable({
|
||||
$('#datatable-buttonss').DataTable({
|
||||
|
||||
|
||||
"ordering": false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user