FEAT_CLIENT_ONBOARDING : RV

This commit is contained in:
VENKATESHWARAN 2024-02-14 12:27:08 +05:30
parent 0c20d4ddd6
commit 89b2fe681d
26 changed files with 1562 additions and 490 deletions

View File

@ -31,30 +31,37 @@ $routes->group("/client", ["filter" => "authMVC"], function($routes){
$routes->get("list", "ClientController::index");
$routes->get("create", "ClientController::clientOnboarding");
$routes->get("list/(:any)", "ClientController::editClientOnboarding/$1");
$routes->group("general", ["filter" => "authMVC"], function($routes){
$routes->get("create", "ClientController::clientGeneralInfoData");
$routes->post("create", "ClientController::createClientGeneralInfo");
$routes->post("create", "ClientController::createClientGeneralInfo");
$routes->post("edit", "ClientController::editClientGeneralInfo");
});
$routes->group("relation", ["filter" => "authMVC"], function($routes){
$routes->get("list", "ClientController::index");
$routes->get("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::clientCreate");
});
$routes->group("branch", ["filter" => "authMVC"], function($routes){
$routes->get("list", "ClientController::index");
$routes->get("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::clientCreate");
});
$routes->post("create", "ClientController::createClientBranch");
$routes->post("edit", "ClientController::editClientBranch");
$routes->get("list/(:any)", "ClientController::getSingleBranchDataById/$1");
});
$routes->group("relation", ["filter" => "authMVC"], function($routes){
$routes->post("create", "ClientController::createClientRelation");
$routes->post("edit", "ClientController::editClientRelation");
});
$routes->group("policy", ["filter" => "authMVC"], function($routes){
$routes->get("list", "ClientController::index");
$routes->get("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::createClientPolicy");
$routes->post("edit", "ClientController::editClientPolicy");
$routes->get("list/(:any)", "ClientController::getClientPolicyById/$1");
});
$routes->group("kyc", ["filter" => "authMVC"], function($routes){
$routes->get("list", "ClientController::index");
$routes->get("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::clientCreate");
$routes->post("create", "ClientController::createClientKYCInfo");
$routes->post("edit", "ClientController::editClientKYCInfo");
$routes->get("list/(:any)", "ClientController::getKycDocsById/$1");
$routes->get("delete/(:any)", "ClientController::deleteClientKycDocs/$1");
});
});
$routes->group("/util", ["filter" => "authMVC"], function($routes){
$routes->get("clients-with-policies", "EmployeeController::getClientWithPolicies");
$routes->get("police-by-insurer/(:any)", "ClientController::getPolicesByInsurerId/$1");
});

View File

@ -71,7 +71,7 @@ class Security extends BaseConfig
*
* Regenerate CSRF Token on every submission.
*/
public bool $regenerate = true;
public bool $regenerate = false;
/**
* --------------------------------------------------------------------------

View File

@ -6,6 +6,7 @@ use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use CodeIgniter\API\ResponseTrait;
use App\Models\UserModel;
use App\Models\ClientModel;
@ -21,10 +22,14 @@ use App\Models\LevelContactModel;
use App\Models\PolicesModel;
use App\Models\TPABranchModel;
use App\Models\TPAModel;
use App\Models\StateModel;
class ClientController extends AdminController
{
{
use ResponseTrait;
protected $myLogger;
protected $clientModel;
protected $userModel;
protected $clientBranchModel;
@ -39,12 +44,14 @@ class ClientController extends AdminController
protected $policesModel;
protected $tpaBranchModel;
protected $tpaModel;
protected $stateModel;
public function __construct()
{
parent::__construct();
set_session_context('Client');
$this->myLogger = \Config\Services::mylogger();
$this->clientModel = new ClientModel();
$this->userModel = new UserModel();
$this->clientBranchModel = new ClientBranchModel();
@ -59,31 +66,425 @@ class ClientController extends AdminController
$this->policesModel = new PolicesModel();
$this->tpaBranchModel = new TPABranchModel();
$this->tpaModel = new TPAModel();
$this->stateModel = new StateModel();
}
public function index()
{
echo view('layout/header');
echo view('client_list');
$this->myLogger->logme('error','Client list function called');
$headerData['page_name'] = 'Client List';
$data['clientList'] = $this->clientModel->findAll();
echo view('layout/header', $headerData);
echo view('client_list', $data);
echo view('layout/footer');
}
public function clientOnboarding(){
public function clientOnboarding()
{
$this->myLogger->logme('error','Client Onboarding function called');
$headerData['page_name'] = 'Client Onboarding';
$data['contact_level'] = ['1'=>'level 1', '2'=>'level 2', '3'=>'level 3'];
$data['entity'] = $this->kycEntityTypeModel->findAll();
$data['kyc_docs'] = $this->kycDocsModel->findAll();
$data['police'] = $this->policesModel->findAll();
$data['insurer'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
$data['state'] = $this->stateModel->getAllStates();
$data['RM'] = $this->userModel->findAll();
echo view('layout/header');
// echo "<pre>";
// print_r($data); die;
echo view('layout/header', $headerData);
echo view('client_onboarding', $data);
echo view('layout/footer');
}
public function createClientGeneralInfo(){
}
public function editClientOnboarding($id = null)
{
$this->myLogger->logme('error','Edit Client Onboarding function called');
$headerData['page_name'] = 'Edit Client Onboarding';
$editData['RM'] = $this->userModel->findAll();
$editData['tpa'] = $this->tpaBranchModel ->getTpaBranchesWithTpaNames();
$editData['state'] = $this->stateModel->getAllStates();
$editData['police'] = $this->policesModel->findAll();
$editData['entity'] = $this->kycEntityTypeModel->findAll();
$editData['insurer'] = $this->insurerBranchModel ->getInsurerBranchesWithInsurerNames();
$editData['kyc_docs'] = $this->kycDocsModel->findAll();
$editData['client'] = $this->clientModel->where(['id' => $id, 'is_active' => 1])->first();
$editData['client_kyc'] = $this->clientKYCDocsModel->getKycDocsName($id);
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_policy'] = $this->clientPolicyModel->getClientPolicyByClientId($id);
// echo "<pre>";
// print_r($editData); die;
echo view('layout/header', $headerData);
echo view('client_onboarding', $editData);
echo view('layout/footer');
}
public function createClientGeneralInfo()
{
$this->myLogger->logme('error','Client general info function called');
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
$insert = $this->clientModel->insert($data);
if($insert){
$client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
echo json_encode(array("status" => true , 'data' => $client_data));
}else{
echo json_encode(array("status" => false));
}
}
public function editClientGeneralInfo()
{
$this->myLogger->logme('error','edit client general info function called');
$id = $this->request->getPost('PrimaryKey');
$data = $this->request->getPost();
$data['updated_by'] = get_session_userid();
$update = $this->clientModel->update($id,$data);
if($update){
echo json_encode(array("status" => true , 'data' => $data));
}else{
echo json_encode(array("status" => false));
}
}
public function createClientKYCInfo()
{
$this->myLogger->logme('error','create Client kyc function called');
$File = file_Upload($this->request->getFile('file_name'));
if(!empty($File)){
$data['file_name'] = $File;
}
$data['client_id'] = $this->request->getPost('client_id');
$data['kyc_doc_type_id'] = $this->request->getPost('kyc_doc_id');
$data['created_by'] = get_session_userid();
$insert = $this->clientKYCDocsModel->insert($data);
if($insert){
$kycDocs = $this->clientKYCDocsModel->getKycDocsName($this->request->getPost('client_id'));
echo json_encode(array("status" => true , 'data' => $kycDocs));
}else{
echo json_encode(array("status" => false));
}
}
public function editClientKYCInfo()
{
$this->myLogger->logme('error','edit client kyc function called');
$File = file_Upload($this->request->getFile('file_name'));
if(!empty($File)){
$data['file_name'] = $File;
}
$id = $this->request->getPost('PrimaryKey');
$data['client_id'] = $id;
$data['kyc_doc_type_id'] = $this->request->getPost('kyc_doc_id');
$data['updated_by'] = get_session_userid();
$insert = $this->clientKYCDocsModel->insert($data);
if($insert){
$kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
echo json_encode(array("status" => true , 'data' => $kycDocs));
}else{
echo json_encode(array());
}
}
public function deleteClientKycDocs($id=null)
{
$delete = $this->clientKYCDocsModel->where('id', $id)->delete();
if($delete){
echo json_encode(array("status" => true ));
}else{
echo json_encode(array("status" => false));
}
}
public function createClientRelation()
{
$this->myLogger->logme('error','Client relation function called');
$data['client_id'] = $this->request->getPost('client_id');
$data['created_by'] = get_session_userid();
$inserted = false;
if ($this->request->getPost('head')) {
$data['level'] = "1";
$data['user_id'] = $this->request->getPost('head');
$inserted = $this->clientRMModel->insert($data);
}
if ($this->request->getPost('manager')) {
$data['level'] = "2";
$data['user_id'] = $this->request->getPost('manager');
$inserted = $this->clientRMModel->insert($data);
}
if ($this->request->getPost('account_manager')) {
$data['level'] = "3";
foreach ($this->request->getPost('account_manager') as $value) {
$data['user_id'] = $value;
$inserted = $this->clientRMModel->insert($data);
}
}
if ($inserted) {
echo json_encode(array("status" => true, 'data' => $this->request->getPost()));
} else {
echo json_encode(array("status" => false));
}
}
public function editClientRelation()
{
$this->myLogger->logme('error','Client relation function called');
$id = $this->request->getPost('PrimaryKey');
$data['client_id'] = $this->request->getPost('client_id');
$data['updated_by'] = get_session_userid();
$inserted = false;
if ($this->request->getPost('head')) {
$data['user_id'] = $this->request->getPost('head');
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1);
if($checkHead){
$inserted = $this->clientRMModel->where('client_id', $id )->where('level', 1)->set($data)->update();
}else{
$data['level'] = "1";
$data['user_id'] = $this->request->getPost('head');
$inserted = $this->clientRMModel->insert($data);
}
}
if ($this->request->getPost('manager')) {
$data['user_id'] = $this->request->getPost('manager');
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2);
if($checkHead){
$inserted = $this->clientRMModel->where('client_id', $id )->where('level', 2)->set($data)->update();
}else{
$data['level'] = "2";
$data['user_id'] = $this->request->getPost('manager');
$inserted = $this->clientRMModel->insert($data);
}
}
if ($this->request->getPost('account_manager')) {
$this->clientRMModel->where('client_id', $id)->where('level', 3)->delete();
$data['level'] = "3";
foreach ($this->request->getPost('account_manager') as $value) {
$data['user_id'] = $value;
$inserted = $this->clientRMModel->insert($data);
}
}
$lastQuery = $this->clientRMModel->getLastQuery();
if ($inserted) {
echo json_encode(array("status" => true, 'data' => $this->request->getPost(), "place" => 'edit'));
} else {
echo json_encode(array("status" => false, "place" => 'edit'));
}
}
public function createClientBranch()
{
$this->myLogger->logme('error','Client branch CREATE function called');
$data = $this->request->getPost();
$data['created_by'] = get_session_userid();
$insert = $this->clientBranchModel->insert($data);
if($insert){
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
// Prepare data to insert
$data = [
'contact_type' => 'client',
'ref_id' => $insert,
'created_by' => get_session_userid(),
'name' => $this->request->getPost('name')[$i],
'email' => $this->request->getPost('email')[$i],
'mobile' => $this->request->getPost('mobile')[$i],
'designation' => $this->request->getPost('designation')[$i]
];
$contacts = $this->levelContactModel->insert($data);
}
}
if($insert){
$branchData = $this->clientBranchModel->where('client_id', $this->request->getPost('client_id'))->findAll();
echo json_encode(array("status" => true , 'data' => $branchData));
}else{
echo json_encode(array("status" => false));
}
}
public function editClientBranch()
{
$this->myLogger->logme('error','Client branch EDIT function called');
$id = $this->request->getPost('PrimaryKey');
$client_id = $this->request->getPost('client_id');
$data = $this->request->getPost();
$data['updated_by'] = get_session_userid();
$insert = $this->clientBranchModel->update($id, $data);
$this->myLogger->logme('error','Client branch EDITED by {data}', ['data' => get_session_userid()]);
if($insert){
$this->levelContactModel->where('ref_id', $id)->where('contact_type', 'client')->delete();
for ($i = 0; $i < count($this->request->getPost('name')); $i++) {
$data = [
'contact_type' => 'client',
'ref_id' => $id,
'updated_by' => get_session_userid(),
'name' => $this->request->getPost('name')[$i],
'email' => $this->request->getPost('email')[$i],
'mobile' => $this->request->getPost('mobile')[$i],
'designation' => $this->request->getPost('designation')[$i]
];
$contacts = $this->levelContactModel->insert($data);
}
}
if($insert){
$branchData = $this->clientBranchModel->where('client_id', $client_id)->findAll();
echo json_encode(array("status" => true , 'data' => $branchData));
}else{
echo json_encode(array("status" => false));
}
}
public function createClientPolicy()
{
$this->myLogger->logme('error','Client policy CREATE function called');
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$data['insurer_branch_id'] = $insurerBranchId;
$data['insurer_id'] = $insurerId;
$tpaValue = (string) $this->request->getPost('tpa');
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
$data['tpa_branch_id'] = $tpaBranchId;
$data['tpa_id'] = $tpaId;
$data['policy_id'] = $this->request->getPost('policy_id');
$data['client_id'] = $this->request->getPost('client_id');
$data['created_by'] = get_session_userid();
$insert = $this->clientPolicyModel->insert($data);
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($this->request->getPost('client_id'));
echo json_encode(array("status" => true , 'data' => $clientPoliceData));
}else{
echo json_encode(array("status" => false));
}
}
public function editClientPolicy()
{
$this->myLogger->logme('error','Client policy function called');
$id = $this->request->getPost('PrimaryKey');
$client_id = $this->request->getPost('client_id');
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
$data['insurer_branch_id'] = $insurerBranchId;
$data['insurer_id'] = $insurerId;
$tpaValue = (string) $this->request->getPost('tpa');
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
$data['tpa_branch_id'] = $tpaBranchId;
$data['tpa_id'] = $tpaId;
$data['policy_id'] = $this->request->getPost('policy_id');
$data['updated_by'] = get_session_userid();
$insert = $this->clientPolicyModel->update($id,$data);
$lastQuery = $this->clientPolicyModel->getLastQuery();
if($insert){
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
echo json_encode(array("status" => true , 'data' => $clientPoliceData));
}else{
echo json_encode(array("status" => false));
}
}
public function getKycDocsById($id=null)
{
$this->myLogger->logme('error','getKycDocsById function called');
if($id){
$kyc_docs_data = $this->kycDocsModel->where(['kyc_type_id' => $id, 'is_active' => 1])->findAll();
echo json_encode(array("status" => true , 'data' => $kyc_docs_data));
$this->myLogger->logme('error','getKycDocs status TRUE');
}else{
echo json_encode(array("status" => false));
$this->myLogger->logme('error','getKycDocs status FALSE');
}
}
public function getPolicesByInsurerId($id = null)
{
$this->myLogger->logme('error','getPolicesByInsurerId function called');
if($id){
$police_data = $this->policesModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll();
echo json_encode(array("status" => true , 'data' => $police_data));
}else{
echo json_encode(array("status" => false));
}
}
public function getSingleBranchDataById($id=null)
{
$this->myLogger->logme('error','getSingleBranchDataById function called');
if($id){
$branch_data = $this->clientBranchModel->where(['id' => $id, 'is_active' => 1])->first();
$branch_contact_data = $this->levelContactModel->where(['ref_id' => $id, 'contact_type'=>'client', 'is_active' => 1])->findAll();
echo json_encode(array("status" => true , 'data' => $branch_data, 'contact' => $branch_contact_data));
}else{
echo json_encode(array("status" => false));
}
}
public function getClientPolicyById($id=null)
{
$this->myLogger->logme('error','getClientPolicyById function called');
if($id){
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
$insurer_id = $client_policy_data['insurer_id'];
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
echo json_encode(array("status" => true , 'data' => $client_policy_data, 'policy' => $polices));
}else{
echo json_encode(array("status" => false));
}
}
}

View File

@ -16,21 +16,30 @@ use App\Models\UserTeamsModel;
class UserController extends AdminController
{
protected $myLogger;
protected $userModel;
protected $roleModel;
protected $teamModel;
protected $userTeamsModel;
public function __construct()
{
// helper('utility');
set_session_context('User');
$this->myLogger = \Config\Services::mylogger();
$this->userModel = new UserModel();
$this->roleModel = new RoleModel();
$this->teamModel = new TeamModel();
$this->userTeamsModel = new UserTeamsModel();
}
public function list()
{
{
$headerData['page_name'] = 'User List';
$model = new UserModel();
$this->myLogger->logme('error','list {data} called',['data' => '9638527410']);
$this->myLogger->logme('error','User list function called');
$data['UserList'] = $model->where('is_active', 1)->orderBy('id', 'DESC')->findAll();
echo view('layout/header');
echo view('layout/header', $headerData);
echo view('AddUser');
echo view('UserList', $data);
echo view('layout/footer');
@ -39,6 +48,7 @@ class UserController extends AdminController
public function create()
{
$this->myLogger->logme('error','User create function called');
$teams = $this->request->getPost('team');
//if this is get method return to user creation page
if(!$this->request->getPost()){
@ -46,8 +56,7 @@ class UserController extends AdminController
}else{
//else do user insert operation
$userModel = new UserModel();
$File = fileUpload($this->request->getFile('profile'));
$File = file_Upload($this->request->getFile('profile'));
$userData = $this->request->getPost();
if(!empty($File)){
$userData['profile'] = $File;
@ -56,51 +65,41 @@ class UserController extends AdminController
// Inserting data into the 'users' table
$userData['created_by'] = get_session_userid();
unset($userData['team']);
$insert = $userModel->insert($userData);
$insert = $this->userModel->insert($userData);
if($insert){
$teamData['user_id'] = $insert ;
$UserTeamsModel = new UserTeamsModel();
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$UserTeamsModel->insert($teamData);
$this->userTeamsModel->insert($teamData);
}
}
}
return redirect()->to(base_url('/user/list'));
}
public function getuser($id = null){
$model = new UserModel();
$RoleModel = new RoleModel();
$TeamModal = new TeamModel();
$UserTeamsModel = new UserTeamsModel();
$roleData = $RoleModel->select('id, role')->findAll();
$teamData = $TeamModal->select('id, name')->findAll();
$userTeamData = $UserTeamsModel->where('user_id', $id)->findAll();
$data = $model->getUserById($id);
public function getuser($id = null)
{
$roleData = $this->roleModel->select('id, role')->findAll();
$teamData = $this->teamModel->select('id, name')->findAll();
$userTeamData = $this->userTeamsModel->where('user_id', $id)->findAll();
$data = $this->userModel->getUserById($id);
if($data){
echo json_encode(array("status" => true , 'data' => $data, 'roleData' => $roleData, 'teamData' => $teamData, 'userTeamData' => $userTeamData));
}else{
echo json_encode(array("status" => false));
}
}
public function edit()
{
$teams = $this->request->getPost('team');
// echo '<pre>';
// print_r($this->request->getPost()); die;
if(!$this->request->getPost()){
return redirect()->to(base_url('/user/list'));
}else{
$userModel = new UserModel();
$id = $this->request->getPost('PrimaryKey');
$imageDetails = $userModel->find($id);
$File = fileUpload($this->request->getFile('profile'), (isset($imageDetails['profile']) ? $imageDetails['profile'] : null));
$imageDetails = $this->userModel->find($id);
$File = file_Upload($this->request->getFile('profile'), (isset($imageDetails['profile']) ? $imageDetails['profile'] : null));
$userData = $this->request->getPost();
if(!empty($File)){
$userData['profile'] = $File;
@ -108,17 +107,18 @@ class UserController extends AdminController
// Update data in the 'users' table based on the $id
$userData['updated_by'] = get_session_userid();
unset($userData['PrimaryKey']);
$update = $userModel->update($id, $userData);
$update = $this->userModel->update($id, $userData);
if($update){
$UserTeamsModel = new UserTeamsModel();
$UserTeamsModel->where('user_id', $id)->delete();
$teamData['user_id'] = $id ;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$UserTeamsModel->insert($teamData);
}
$this->userTeamsModel->where('user_id', $id)->delete();
if($teams){
$teamData['user_id'] = $id ;
foreach ($teams as $value) {
$teamData['team_id'] = $value;
$teamData['created_by'] = get_session_userid();
$this->userTeamsModel->insert($teamData);
}
}
}
return redirect()->to(base_url('/user/list'));
}
@ -137,14 +137,10 @@ class UserController extends AdminController
}
}
public function getRolesAndTeams(){
$RoleModel = new RoleModel();
$TeamModal = new TeamModel();
$roleData = $RoleModel->select('id, role')->findAll();
$teamData = $TeamModal->select('id, name')->findAll();
public function getRolesAndTeams()
{
$roleData = $this->roleModel->select('id, role')->findAll();
$teamData = $this->teamModel->select('id, name')->findAll();
echo json_encode(array("status" => true , 'roleData' => $roleData, 'teamData' => $teamData,));
}
}

View File

@ -43,9 +43,9 @@ if (!function_exists('change_date_format')) {
}
}
if (!function_exists('fileUpload')) {
if (!function_exists('file_Upload')) {
function fileUpload($fileToUpload, $imageDetails = null)
function file_Upload($fileToUpload, $imageDetails = null)
{
$fileName = $fileToUpload->getClientName();
if ($fileToUpload !== NULL && $fileName !== "") {

View File

@ -13,9 +13,24 @@ class ClientBranchModel extends Model
"client_id",
"branch_name",
"branch_code",
"city",
"district",
"state",
"created_by",
"updated_by",
"is_active",
];
public function getBranchAndContactByBranchId($branch_id){
return $this->db->table('client_branch')
->select('client_branch.*')
->select('level_contacts.name, level_contacts.email, level_contacts.mobile, level_contacts.designation,')
->join('level_contacts', 'level_contacts.ref_id = client_branch.id')
->where('level_contacts.contact_type', 'client')
->where('client_branch.id', $branch_id)
->get()
->getResult();
}
}

View File

@ -8,6 +8,22 @@ class ClientKYCDocsModel extends Model
{
protected $table = 'client_kyc_documents';
protected $primaryKey = 'id';
protected $allowedFields = ['id','client_id','entity_type_id','file_name','is_active',"created_by","updated_by",];
protected $allowedFields = [
'id',
'client_id',
'kyc_doc_type_id',
'file_name',
'is_active',
"created_by",
"updated_by",
];
public function getKycDocsName($client_id){
$query = $this->select('client_kyc_documents.*, kyc_docs.file_name as client_file_name')
->join('kyc_docs', 'kyc_docs.id = client_kyc_documents.kyc_doc_type_id')
->where(['client_id' => $client_id, 'client_kyc_documents.is_active' => 1])
->findAll();
return $query;
}
}

View File

@ -20,4 +20,43 @@ class ClientPolicyModel extends Model
"updated_by",
"Is_active",
];
public function getClientPolicyById($id){
return $this->db->table('client_policy')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
->select('policies.name as policy_name')
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.id', $id)
->get()
->getResult();
}
public function getClientPolicyByClientId($client_id){
return $this->db->table('client_policy')
->select('client_policy.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
->select('policies.name as policy_name')
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.client_id', $client_id)
->get()
->getResult();
}
}

View File

@ -18,4 +18,13 @@ class ClientRMModel extends Model
"is_active",
];
public function checkExistenceOfClientRelation($id, $user_id, $level)
{
$query = $this->where('client_id', $id)
->where('user_id', $user_id)
->where('level', $level)
->countAllResults();
return ($query > 0) ? true : false;
}
}

View File

@ -17,6 +17,7 @@ class LevelContactModel extends Model
"email",
"city",
"mobile",
"designation",
"created_by",
"updated_by",
"is_active",

20
app/Models/StateModel.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class StateModel extends Model
{
protected $table = 'states';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"state"
];
public function getAllStates()
{
return $this->select('id, state')->findAll();
}
}

View File

@ -23,4 +23,12 @@ class TPABranchModel extends Model
"updated_by",
"is_active",
];
public function getTpaBranchesWithTpaNames()
{
$query = $this->select('tpa_branch.*, T.short_name as tpa_short_name, T.name as tpa_name')
->join('tpa T', 'tpa_branch.tpa_id = T.id', 'left')
->find();
return $query;
}
}

View File

@ -90,13 +90,12 @@ class UserModel extends Model
public function getUserById($id){
$userData = $this->where('id', $id)->get();
if ($userData->getNumRows() > 0) {
return $userData->getRow();
} else {
return false;
}
}
}
?>

View File

@ -2,46 +2,54 @@
<div class="row">
<div class="col-12">
<div class="card-body">
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="UserId" />
<form role="form" class="parsley-examples" method="post" id="general_form" enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="general_PrimaryKey" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" name="client_id" id="client_id" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="emp_code">Entity Type <span
<label for="entity_type_id">Entity Type <span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role" required>
<select class="form-control" id="entity_type" name="entity_type_id" required>
<option value="">Select Entity</option>
<?php foreach($entity as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
<?php if(isset($client['entity_type_id'])){ ?>
<?php if($value['id'] == $client['entity_type_id']) { ?>
<option value="<?= $value['id'] ?>" selected><?= $value['name'] ?></option>
<?php } else { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
<?php } ?>
<?php } else { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="first_name">Client Name<span
<label for="client_name">Client Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Client Name" name="first_name" required>
<input type="text" class="form-control" id="client_name"
placeholder="Enter Client Name" value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>" name="client_name" required>
</div>
<div class="form-group col-md-4">
<label for="last_name">Client Short Name<span
<label for="short_name">Client Short Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Short Name" name="last_name" required>
<input type="text" class="form-control" id="short_name"
placeholder="Enter Short Name" value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>" name="short_name" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="email">PAN<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="email"
placeholder="Enter PAN Number" name="email" required>
<div class="form-group col-md-6">
<label for="pan">PAN<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="pan"
placeholder="Enter PAN Number" value="<?= isset($client['pan']) ? $client['pan'] : '' ?>" name="pan" required>
</div>
<div class="form-group col-md-4">
<label for="mobile">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile"
placeholder="Enter GST Number" name="mobile" required>
<div class="form-group col-md-6">
<label for="gst">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="gst"
placeholder="Enter GST Number" value="<?= isset($client['gst']) ? $client['gst'] : '' ?>" name="gst" required>
</div>
</div>
@ -49,37 +57,49 @@
<div class="form-row">
<div class="form-group col-md-6">
<label for="email">Address 1<span
<label for="address1">Address 1<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="email"
placeholder="Enter Address 1" name="email" required>
<input type="text" class="form-control" id="address1"
placeholder="Enter Address 1" value="<?= isset($client['address1']) ? $client['address1'] : '' ?>" name="address1" required>
</div>
<div class="form-group col-md-6">
<label for="mobile">Address 2<span
<label for="address2">Address 2<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile"
placeholder="Enter Address 2" name="mobile" required>
<input type="text" class="form-control" id="address2"
placeholder="Enter Address 2" value="<?= isset($client['address2']) ? $client['address2'] : '' ?>" name="address2" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="first_name">City<span
<label for="city">City<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter City" name="first_name" required>
<input type="text" class="form-control" id="city"
placeholder="Enter City" value="<?= isset($client['city']) ? $client['city'] : '' ?>" name="city" required>
</div>
<div class="form-group col-md-4">
<label for="last_name">State<span
<label for="state">State<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter State" name="last_name" required>
<select class="form-control" id="state" name="state" required>
<option value="">Select State</option>
<?php foreach($state as $value) { ?>
<?php if(isset($client['state'])){ ?>
<?php if($value['id'] == $client['state']) { ?>
<option value="<?= $value['id'] ?>" selected><?= $value['state'] ?></option>
<?php } else { ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
<?php } else { ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="last_name">Pincode<span
<label for="pincode">Pincode<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Pincode" name="last_name" required>
<input type="text" class="form-control" id="pincode"
placeholder="Enter Pincode" value="<?= isset($client['pincode']) ? $client['pincode'] : '' ?>" name="pincode" maxlength="6" required>
</div>
</div>
</div>
@ -101,6 +121,105 @@
$(document).ready(function () {
$("#general_form").submit(function(event) {
event.preventDefault();
var isValid = validateForm();
var PrimaryKey = $('#general_PrimaryKey').val();
var form_action = '';
if (isValid) {
if(PrimaryKey === ''){
form_action = '<?= base_url("client/general/create"); ?>';
}else{
form_action = '<?= base_url("client/general/edit"); ?>';
}
var formData = new FormData($('#general_form')[0]);
var OptionsHTML1 = ''
$.ajax({
data: formData,
url: form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$('#client_id').val(res.data.id);
$('#client_id_relation').val(res.data.id);
$('#client_id_branch').val(res.data.id);
$('#client_id_police').val(res.data.id);
$('#client_id_kyc').val(res.data.id);
$('#kyc_tab').click();
$.toast({
text: 'Client General Info',
heading: "Submitted Sucessfully",
position: 'top-right',
icon: 'success',
bgColor: !1,
});
$.ajax({
url: '<?= base_url("client/kyc/list/"); ?>'+res.data.entity_type_id,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$.each(res.data, function(index, item) {
OptionsHTML1 += '<option value="' + item.id + '">' + item.file_name + '</option>';
});
$('#kyc_docs').html(OptionsHTML1);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
});
function validateForm() {
var isValid = true;
// Perform validation for each field
$('#general_form input, #general_form select').each(function() {
// Check for empty text inputs and selects
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
alert('Please fill in all fields');
isValid = false;
return false; // Exit the loop early
}
}
// Check for file inputs (assuming image files)
if ($(this).is('input[type="file"]')) {
var fileInput = $(this)[0];
if (fileInput.files.length === 0) {
alert('Please select an image file');
isValid = false;
return false; // Exit the loop early
}
}
});
return isValid;
}
});
</script>

View File

@ -2,7 +2,7 @@
<div class="row float-right" style="padding-bottom: 10px;">
<div class="col-6">
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light">Add</button>
<button type="button" id="btnBranchAdd" class="btn btn-primary waves-effect waves-light">Add</button>
</div>
</div>
@ -11,22 +11,12 @@
<table class="table table-borderless table-nowrap mb-0">
<thead class="thead-light">
<tr>
<th>#</th>
<th>Branch Name</th>
<th>Branch Code</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>App design and development</td>
<td>01/01/2015</td>
</tr>
<tr>
<td>2</td>
<td>Coffee detail page - Main Page</td>
<td>21/07/2016</td>
</tr>
<tbody id="branch_list">
</tbody>
</table>
</div>
@ -36,29 +26,54 @@
<div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px;">
<div class="col-6">
<button type="button" class="btn btn-primary waves-effect waves-light btnBack">Back</button>
<button type="button" class="btn btn-primary waves-effect waves-light btnBack">List</button>
</div>
</div>
<hr>
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
<form role="form" class="parsley-examples" method="post" id="branch_form"
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="UserId" />
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="branch_PrimaryKey" />
<input type="hidden" name="client_id" id="client_id_branch" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="first_name">Branch Name<span
<label for="branch_name">Branch Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Branch Name" name="first_name" required>
<input type="text" class="form-control" id="branch_name"
placeholder="Enter Branch Name" name="branch_name" required>
</div>
<div class="form-group col-md-6">
<label for="last_name">Branch Code<span
<label for="branch_code">Branch Code<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Branch Code" name="last_name" required>
<input type="text" class="form-control" id="branch_code"
placeholder="Enter Branch Code" name="branch_code" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="state">State<span
class="text-danger">*</span></label>
<select class="form-control" id="state" name="state" required>
<option value="">Select State</option>
<?php foreach($state as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['state'] ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="district">District<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="district"
placeholder="Enter District" name="district" required>
</div>
<div class="form-group col-md-4">
<label for="city">City</label>
<input type="text" class="form-control" id="branch_city"
placeholder="Enter City" name="city" required>
</div>
</div>
@ -67,47 +82,31 @@
<br>
<div class="form-row">
<div class="form-group col-md-4">
<label for="first_name">Contact Level<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select Contact Level</option>
<?php foreach($contact_level as $key => $value) { ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-6">
<label for="first_name">Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact Name" name="first_name" required>
<input type="text" class="form-control" id="name0"
placeholder="Enter Contact Name" name="name[]" >
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-6">
<label for="last_name">Email<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Email" name="last_name" required>
<input type="text" class="form-control" id="email0"
placeholder="Enter Contact Email" name="email[]" >
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="last_name">Mobile<span
<div class="form-group col-md-6">
<label for="mobile">Mobile<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Mobile" name="last_name" required>
<input type="text" class="form-control" id="mobile0"
placeholder="Enter Contact Mobile" name="mobile[]" >
</div>
<div class="form-group col-md-4">
<label for="first_name">City<span
<div class="form-group col-md-6">
<label for="designation">Designation<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact City" name="first_name" required>
</div>
<div class="form-group col-md-4">
<label for="first_name">Level Name</label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Level Name" name="first_name" >
<input type="text" class="form-control" id="designation0"
placeholder="Enter Designation Name" name="designation[]" >
</div>
</div>
@ -116,47 +115,28 @@
<br>
<div class="form-row">
<div class="form-group col-md-4">
<label for="first_name">Contact Level<span
<div class="form-group col-md-6">
<label for="name">Name<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select Contact Level</option>
<?php foreach($contact_level as $key => $value) { ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php } ?>
</select>
<input type="text" class="form-control" id="name1"
placeholder="Enter Contact Name" name="name[]" >
</div>
<div class="form-group col-md-4">
<label for="first_name">Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact Name" name="first_name" required>
</div>
<div class="form-group col-md-4">
<label for="last_name">Email<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Email" name="last_name" required>
<div class="form-group col-md-6">
<label for="email">Email</label>
<input type="text" class="form-control" id="email1"
placeholder="Enter Contact Email" name="email[]" >
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="last_name">Mobile<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Mobile" name="last_name" required>
<div class="form-group col-md-6">
<label for="mobile">Mobile</label>
<input type="text" class="form-control" id="mobile1"
placeholder="Enter Contact Mobile" name="mobile[]" >
</div>
<div class="form-group col-md-4">
<label for="first_name">City<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact City" name="first_name" required>
</div>
<div class="form-group col-md-4">
<label for="first_name">Level Name</label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Level Name" name="first_name" >
<div class="form-group col-md-6">
<label for="designation">Designation</label>
<input type="text" class="form-control" id="designation1"
placeholder="Enter Designation Name" name="designation[]">
</div>
</div>
@ -165,52 +145,30 @@
<br>
<div class="form-row">
<div class="form-group col-md-4">
<label for="first_name">Contact Level<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select Contact Level</option>
<?php foreach($contact_level as $key => $value) { ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php } ?>
</select>
<div class="form-group col-md-6">
<label for="name">Name</label>
<input type="text" class="form-control" id="name2"
placeholder="Enter Contact Name" name="name[]" >
</div>
<div class="form-group col-md-4">
<label for="first_name">Level Name</label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Level Name" name="first_name" >
</div>
<div class="form-group col-md-4">
<label for="first_name">Name<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact Name" name="first_name" required>
<div class="form-group col-md-6">
<label for="email">Email</label>
<input type="text" class="form-control" id="email2"
placeholder="Enter Contact Email" name="email[]" >
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="last_name">Email<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Email" name="last_name" required>
<div class="form-group col-md-6">
<label for="mobile">Mobile</label>
<input type="text" class="form-control" id="mobile2"
placeholder="Enter Contact Mobile" name="mobile[]" >
</div>
<div class="form-group col-md-4">
<label for="last_name">Mobile<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="last_name"
placeholder="Enter Contact Mobile" name="last_name" required>
<div class="form-group col-md-6">
<label for="designation">Designation</label>
<input type="text" class="form-control" id="designation2"
placeholder="Enter Designation Name" name="designation[]" >
</div>
<div class="form-group col-md-4">
<label for="first_name">City<span
class="text-danger">*</span></label>
<input type="text" class="form-control" id="first_name"
placeholder="Enter Contact City" name="first_name" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
@ -228,16 +186,45 @@
<script>
$(document).ready(function () {
var branch_PrimaryKey = $('#client_id_branch').val();
var branch_form_action = '';
$('#add_branch').hide();
$('.btnBack').hide();
$('#btnBranchAdd').click(function(){
branch_form_action = '<?= base_url("client/branch/create"); ?>';
$('#btnAdd').click(function(){
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnAdd').hide();
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
$('#btnBranchAdd').hide();
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#name0').val('');
$('#email0').val('');
$('#mobile0').val('');
$('#designation0').val('');
$('#name1').val('');
$('#email1').val('');
$('#mobile1').val('');
$('#designation1').val('');
$('#name2').val('');
$('#email2').val('');
$('#mobile2').val('');
$('#designation2').val('');
})
$('.btnBack').click(function(){
@ -245,66 +232,123 @@ $(document).ready(function () {
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnAdd').show();
$('#btnBranchAdd').show();
$('#branch_name').val('');
$('#branch_code').val('');
$('#state').val('');
$('#district').val('');
$('#branch_city').val('');
$('#name0').val('');
$('#email0').val('');
$('#mobile0').val('');
$('#designation0').val('');
$('#name1').val('');
$('#email1').val('');
$('#mobile1').val('');
$('#designation1').val('');
$('#name2').val('');
$('#email2').val('');
$('#mobile2').val('');
$('#designation2').val('');
})
$('body').on('click', '.btnEdit', function () {
var student_id = $(this).attr('data-id');
if(branch_PrimaryKey !== ''){
var branchTable = '';
var data = <?= isset($client_branch) ? json_encode($client_branch) : '[]' ?>;
$.each(data, function(index, item) {
branchTable += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td><a class="btnBranchEdit" data-id="${item.id}" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnBranchEdit" style="font-size:18px;"></i></a></td>
</tr>
`;
});
$('#branch_list').append(branchTable);
}
$("#branch_form").submit(function(event) {
event.preventDefault();
// Perform validation
var isValid = true; // Assuming you have a function for form validation
if (isValid) {
var formData = new FormData($('#branch_form')[0]);
$.ajax({
data: formData,
url: branch_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$('#branch_list tr').remove();
var branchTableInsert = ''
$.each(res.data, function(index, item) {
branchTableInsert += `
<tr>
<td>${item.branch_name}</td>
<td>${item.branch_code}</td>
<td><a class="btnBranchEdit" data-id="${item.id}" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnBranchEdit" style="font-size:18px;"></i></a></td>
</tr>
`;
});
$('#branch_list').append(branchTableInsert);
$('#add_branch').hide();
$('#branch_table').show();
$('.btnBack').hide();
$('#btnBranchAdd').show();
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
});
$('body').on('click', '.btnBranchEdit', function () {
var branch_id = $(this).attr('data-id');
branch_form_action = '<?= base_url("client/branch/edit"); ?>';
$.ajax({
url: '<?php echo base_url('user/getuser/');?>'+student_id,
url: '<?php echo base_url('client/branch/list/');?>'+branch_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#role').val('')
$('#Add-Edit-Page').show();
$('.header-title').html('Edit User');
$('#List-page').hide();
console.log(res)
$('#add_branch').show();
$('#branch_table').hide();
$('.btnBack').show();
$('#btnAdd').hide();
$('#UserForm').attr('action', '<?php echo base_url('user/edit');?>');
$('#UserId').val(res.data.id);
$('#first_name').val(res.data.first_name);
$('#last_name').val(res.data.last_name);
$('#email').val(res.data.email);
$('#mobile').val(res.data.mobile);
$('#emp_code').val(res.data.emp_code);
$('#btnSubmit').html('Update');
$.each(res.roleData, function(index, item) {
var isSelected = res.userTeamData.some(function(userTeamItem) {
return res.data.role === item.id;
});
$('#role').append($('<option>', {
value: item.id,
text : item.role,
selected: isSelected
}));
$('#btnBranchAdd').hide();
$('#branch_name').val(res.data.branch_name);
$('#branch_code').val(res.data.branch_code);
$('#state option[value="' + res.data.state + '"]').prop('selected', true);
$('#district').val(res.data.district);
$('#branch_city').val(res.data.city);
$('#branch_PrimaryKey').val(res.data.id);
$.each(res.contact, function(index, contact) {
if (contact !== undefined) {
$('#name' + index).val(contact.name !== undefined ? contact.name : '');
$('#email' + index).val(contact.email !== undefined ? contact.email : '');
$('#mobile' + index).val(contact.mobile !== undefined ? contact.mobile : '');
$('#designation' + index).val(contact.designation !== undefined ? contact.designation : '');
}
});
$.each(res.teamData, function(index, item) {
var isSelected = res.userTeamData.some(function(userTeamItem) {
return userTeamItem.team_id === item.id;
});
$('#team').append($('<option>', {
value: item.id,
text : item.name,
selected: isSelected
}));
});
$('#team').multiselect({
nonSelectedText: 'Select Team',
enableFiltering: false,
enableCaseInsensitiveFiltering: false,
includeSelectAllOption : false,
buttonWidth:'100%'
});
if(res.data.profile){
$('#ajaxImgUpload').attr('src', '<?php echo base_url();?>public/uploads/'+res.data.profile).width(100);
}else{
$('#ajaxImgUpload').attr('src', 'https://via.placeholder.com/300').width(100);
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
@ -313,6 +357,7 @@ $(document).ready(function () {
});
});
});
</script>

View File

@ -3,23 +3,25 @@
<div class="row">
<div class="col-12">
<div class="card-body">
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
<form role="form" class="parsley-examples" method="post" id="kyc_form"
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="UserId" />
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="kyc_PrimaryKey" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" name="client_id" id="client_id_kyc" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" name="entity_type" id="entity_type" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="emp_code">Document Type</label>
<select class="form-control" id="role" name="role">
<option value="">Select Document</option>
<select class="form-control" id="kyc_docs" name="kyc_doc_id" required>
<option value="">Select Kyc Docs</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="profile">File</label>
<input class="form-control" type="file" name="profile"
multiple="true" id="profile">
<label for="kyc_docs">File</label>
<input class="form-control" type="file" name="file_name"
multiple="true" id="kyc_docs_file" required>
</div>
<div class="form-group col-md-4 align-self-end">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"id="btnSubmit">Submit</button>
@ -31,6 +33,199 @@
</div>
</div> <!-- end col-->
</div>
<div class="col-lg-8">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table id="kyc_table" class="table table-sm mb-0">
<thead>
<tr>
<th>Document Name</th>
<th>File Name</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div> <!-- end table-responsive-->
</div>
</div> <!-- end card -->
</div> <!-- end col -->
<!-- end row -->
</div>
<!-- end -->
<!-- end -->
<script>
var kycPrimaryKey = $('#kyc_PrimaryKey').val();
$(document).ready(function(){
// $('#kyc_docs').change(function(){
// var selectedValue = $(this).val()
// console.log(selectedValue);
// })
if(kycPrimaryKey !== ''){
var OptionsHTML3 =""
$.ajax({
url: '<?= base_url("client/kyc/list/"); ?>'+'<?= isset($client['entity_type_id']) ? $client['entity_type_id'] : '' ?>',
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$.each(res.data, function(index, item) {
OptionsHTML3 += '<option value="' + item.id + '">' + item.file_name + '</option>';
});
$('#kyc_docs').html(OptionsHTML3);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
var table = '';
var data = <?= isset($client_kyc) ? json_encode($client_kyc) : '[]' ?>;
$('#tbody tr').remove();
$.each(data, function(index, item) {
table += `
<tr id="kyc-${item.id}">
<td>${item.client_file_name}</td>
<td>${item.file_name}</td>
<td><i data-id="${item.id}" class="mdi mdi-delete btnKycDelete" style="font-size:18px;"></i></td>
</tr>
`;
});
$('#tbody').append(table);
}
})
$("#kyc_form").submit(function(event) {
event.preventDefault();
// Perform validation
var isValid = validateForm(); // Assuming you have a function for form validation
var rowHtml = '';
var form_action = '';
if (isValid) {
if(kycPrimaryKey === ''){
form_action = '<?= base_url("client/kyc/create"); ?>';
}else{
form_action = '<?= base_url("client/kyc/edit"); ?>';
}
var formData = new FormData($('#kyc_form')[0]);
$.ajax({
data: formData,
url: form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
if(kycPrimaryKey === ''){
$.toast({
text: 'Client Relation Info',
heading: "Submitted Sucessfully",
position: 'top-right',
icon: 'success',
});
}else{
$.toast({
text: 'Client Relation Info',
heading: "Updated Sucessfully",
position: 'top-right',
icon: 'success',
});
}
$('#tbody tr').remove();
$.each(res.data, function(index, item) {
rowHtml += `
<tr id="kyc-${item.id}">
<td>${item.client_file_name}</td>
<td>${item.file_name}</td>
<td><i data-id="${item.id}" class="mdi mdi-delete btnKycDelete" style="font-size:18px;"></i></td>
</tr>
`;
});
$('#tbody').append(rowHtml);
$('#kyc_docs_file').val('');
$('#kyc_docs').val('');
$('#kyc_docs').val('Select Document Type');
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
});
$('body').on('click', '.btnKycDelete', function () {
Swal.fire({
title: "Are you sure?",
text: "You won't be able to revert this!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, delete it!"
}).then((result) => {
if (result.isConfirmed) {
var kyc_id = $(this).attr('data-id');
$.get('<?php echo base_url('client/kyc/delete/');?>'+kyc_id, function (data) {
console.log('kyc-'+ kyc_id)
if(data){
$('#kyc-'+ kyc_id).remove();
}
})
}
});
});
function validateForm() {
var isValid = true;
// Perform validation for each field
$('#kyc_form input, #kyc_form select').each(function() {
// Check for empty text inputs and selects
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
alert('Please fill in all fields');
isValid = false;
return false; // Exit the loop early
}
}
// Check for file inputs (assuming image files)
if ($(this).is('input[type="file"]')) {
var fileInput = $(this)[0];
if (fileInput.files.length === 0) {
console.log('Please select an image file');
isValid = false;
return false; // Exit the loop early
}
}
});
return isValid;
}
</script>

View File

@ -7,8 +7,8 @@
</div>
</div>
</div>
</div>
<!-- end page title -->
</div>
<!-- end page title -->
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
@ -18,124 +18,48 @@
<h4 class="header-title" style="position: relative;">Client List</h4>
</div>
<div class="col-6" style="text-align: right;">
<a href="<?= base_url("client/create"); ?>" class="btn btn-primary waves-effect waves-light">Add</a>
<a href="<?= base_url("client/create"); ?>"
class="btn btn-primary waves-effect waves-light">Add</a>
</div>
</div>
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">ID</th>
<th class="font-weight-medium">Requested By</th>
<th class="font-weight-medium">Subject</th>
<th class="font-weight-medium">Assignee</th>
<th class="font-weight-medium">Priority</th>
<th class="font-weight-medium">Status</th>
<th class="font-weight-medium">Created Date</th>
<th class="font-weight-medium">Due Date</th>
<th class="font-weight-medium">Action</th>
</tr>
<tr>
<th class="font-weight-medium">#</th>
<th class="font-weight-medium">Client Code</th>
<th class="font-weight-medium">Client Name</th>
<th class="font-weight-medium">Created By</th>
<th class="font-weight-medium">Created At</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody class="font-14">
<?php foreach($clientList as $row){ ?>
<tr>
<td><b>#1256</b></td>
<td>
<a href="javascript: void(0);" class="text-dark">
<img src="../assets/images/users/avatar-2.jpg" alt="contact-img" title="contact-img" class="avatar-sm rounded-circle img-thumbnail" />
<span class="ml-2">George A. Lianes</span>
</a>
</td>
<td>
Support for theme
</td>
<td>
<a href="javascript: void(0);">
<img src="../assets/images/users/avatar-10.jpg" alt="contact-img" title="contact-img" class="avatar-sm rounded-circle img-thumbnail" />
</a>
</td>
<td>
<span class="badge badge-secondary">Low</span>
</td>
<td>
<span class="badge badge-success">Open</span>
</td>
<td>
2017/04/28
</td>
<td>
2017/04/28
</td>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['short_name']; ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['created_by']; ?></td>
<td><?php echo $row['created_at']; ?></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>
<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="#"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit Ticket</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-check-all mr-2 text-muted font-18 vertical-middle"></i>Close</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Remove</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>Mark as Unread</a>
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row['id'];?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>EditTicket</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Deactivate</a>
</div>
</div>
</td>
</tr>
<tr>
<td><b>#2542</b></td>
<td>
<a href="javascript: void(0);" class="text-dark">
<img src="../assets/images/users/avatar-3.jpg" alt="contact-img" title="contact-img" class="avatar-sm rounded-circle img-thumbnail" />
<span class="ml-2">Jose D. Delacruz</span>
</a>
</td>
<td>
New submission on your website
</td>
<td>
<a href="javascript: void(0);">
<img src="../assets/images/users/avatar-9.jpg" alt="contact-img" title="contact-img" class="avatar-sm rounded-circle img-thumbnail" />
</a>
</td>
<td>
<span class="badge badge-warning">Medium</span>
</td>
<td>
<span class="badge badge-secondary">Closed</span>
</td>
<td>
2008/04/25
</td>
<td>
2008/04/25
</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 class="dropdown-item" href="#"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit Ticket</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-check-all mr-2 text-muted font-18 vertical-middle"></i>Close</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Remove</a>
<a class="dropdown-item" href="#"><i class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>Mark as Unread</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<!-- end row -->

View File

@ -1,3 +1,36 @@
<style>
body {
.multiselect-native-select {
position: relative;
/* bottom: 32px; */
select {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px -1px -1px -3px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
left: 50%;
top: 30px;
}
}
.multiselect-container{
width: 100% !important;
}
.multiselect-selected-text{
float: left !important;
}
}
</style>
<div class="row mt-4" id="client_add">
<div class="col-12">
@ -20,7 +53,7 @@
</a>
</li>
<li class="nav-item">
<a href="#KYC-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2">
<a href="#KYC-DOC-tab" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
<span class="mr-1"><i class="fa fa-file"></i></span>
<span class="d-none d-sm-inline-block">KYC Docs</span>
</a>

View File

@ -13,22 +13,13 @@
<table class="table table-borderless table-nowrap mb-0">
<thead class="thead-light">
<tr>
<th>#</th>
<th>Branch Name</th>
<th>Branch Code</th>
<th>Insurer</th>
<th>policy</th>
<th>TPA</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>App design and development</td>
<td>01/01/2015</td>
</tr>
<tr>
<td>2</td>
<td>Coffee detail page - Main Page</td>
<td>21/07/2016</td>
</tr>
<tbody id="policy_table">
</tbody>
</table>
</div>
@ -39,37 +30,44 @@
<div class="row float-right" style="position: relative; bottom: 20px;">
<div class="col-6">
<button type="button" class="btn btn-primary waves-effect waves-light btnBack">Back</button>
<button type="button" class="btn btn-primary waves-effect waves-light btnBack">List</button>
</div>
</div>
<hr>
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
<form role="form" class="parsley-examples" method="post" id="policy_form"
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="UserId" />
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="policy_PrimaryKey" />
<input type="hidden" name="client_id" id="client_id_police" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="email">Insurer<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select Insurer Branch</option>
<select class="form-control" id="insurer" name="insurer">
<option value="">Select Insurer</option>
<?php foreach($insurer as $value) { ?>
<option value="<?= $value['id'] . '-' . $value['insurer_id']?>"><?= $value['insurer_name'] . '-' . $value['branch_code'] ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="first_name">Polices<span
<label for="policy">Polices<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select Policy</option>
<select class="form-control" id="policy" name="policy_id">
<option value="">Select Policy</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="mobile">TPA<span
class="text-danger">*</span></label>
<select class="form-control" id="role" name="role">
<option value="">Select TPA Branch</option>
<select class="form-control" id="tpa" name="tpa">
<option value="">Select TPA</option>
<?php foreach($tpa as $value) { ?>
<option value="<?= $value['id']. '-' . $value['tpa_id'] ?>"><?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?></option>
<?php } ?>
</select>
</div>
</div>
@ -91,7 +89,9 @@
<script>
$(document).ready(function () {
var policy_PrimaryKey = $('#client_id_police').val();
var policy_form_action = '';
$('#add_form').hide();
$('.btnBack').hide();
@ -100,9 +100,13 @@ $(document).ready(function () {
$('#table_list').hide();
$('.btnBack').show();
$('.btnAdd').hide();
$('#UserForm').attr('action', '<?php echo base_url('/user/create');?>');
policy_form_action = '<?= base_url("client/policy/create"); ?>';
})
$('.btnBack').click(function(){
$('#add_form').hide();
@ -110,7 +114,165 @@ $(document).ready(function () {
$('.btnBack').hide();
$('.btnAdd').show();
})
if(policy_PrimaryKey !== ''){
var policyTable = '';
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
console.log(data)
$.each(data, function(index, item) {
policyTable += `
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name}</td>
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
<td><a data-id="${item.id}" class="btnPolicyEdit" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnPolicyEdit" style="font-size:18px;"></i></a></td>
</tr>
`;
});
$('#policy_table').append(policyTable);
}
$("#policy_form").submit(function(event) {
event.preventDefault();
// Perform validation
var isValid = true; // Assuming you have a function for form validation
if (isValid) {
var formData = new FormData($('#policy_form')[0]);
$.ajax({
data: formData,
url: policy_form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
if(policy_PrimaryKey === ''){
$.toast({
text: 'Client Policy Info',
heading: "Submitted Sucessfully",
position: 'top-right',
icon: 'success',
});
}else{
$.toast({
text: 'Client Policy Info',
heading: "Updated Sucessfully",
position: 'top-right',
icon: 'success',
});
}
$('#policy_table tr').remove();
var policyTable = '';
$.each(res.data, function(index, item) {
policyTable += `
<tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${item.policy_name}</td>
<td>${item.tpa_short} - ${item.tpa_branch_code}</td>
<td><a data-id="${item.id}" class="btnPolicyEdit" href="#"><i data-id="${item.id}" class="mdi mdi-lead-pencil btnPolicyEdit" style="font-size:18px;"></i></a></td>
</tr>
`;
});
$('#policy_table').append(policyTable);
$('#add_form').hide();
$('#table_list').show();
$('.btnBack').hide();
$('.btnAdd').show();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
});
$('#insurer').change(function() {
var id = $(this).val();
var OptionsHTML2 = '';
var OptionsHTML = '';
console.log(id)
var url = "<?= base_url("util/police-by-insurer/"); ?>" + id;
$.ajax({
url: url,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
$.each(res.data, function(index, item) {
OptionsHTML2 += '<option value="' + item.id + '">' + item.name + '</option>';
});
$('#policy').html(OptionsHTML2);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
});
$('body').on('click', '.btnPolicyEdit', function () {
policy_form_action = '<?= base_url("client/policy/edit"); ?>';
var policy_id = $(this).attr('data-id');
console.log(policy_id);
$.ajax({
url: '<?php echo base_url('client/policy/list/');?>'+policy_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#add_form').show();
$('#table_list').hide();
$('.btnBack').show();
$('.btnAdd').hide();
$('#insurer option[value="' + res.data.insurer_branch_id + '-' + res.data.insurer_id + '"]').prop('selected', true);
$('#tpa option[value="' + res.data.tpa_branch_id + '-' + res.data.tpa_id + '"]').prop('selected', true);
$('#policy option[value="' + res.data.policy_id + '"]').prop('selected', true);
$('#policy_PrimaryKey').val(res.data.id)
var policeOptionHTML = '';
$.each(res.policy, function(index, item) {
if(res.data.policy_id === item.id){
isSelected = true;
}else{
isSelected = false;
}
policeOptionHTML += '<option value="' + item.id + '" ' + (isSelected ? 'selected="selected"' : '') + '>' + item.name + '</option>';
});
$('#policy').html(policeOptionHTML);
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
});
});
</script>

View File

@ -1,64 +1,43 @@
<style>
body {
.multiselect-native-select {
position: relative;
/* bottom: 32px; */
select {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px -1px -1px -3px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
left: 50%;
top: 30px;
}
}
.multiselect-container{
width: 100% !important;
}
.multiselect-selected-text{
float: left !important;
}
}
</style>
<div class="tab-pane fade" id="RM-tab">
<div class="row">
<div class="col-12">
<div class="card-body">
<form role="form" class="parsley-examples" method="post" id="UserForm" action=""
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="UserId" />
<form role="form" class="parsley-examples" method="post" id="relation_form" enctype="multipart/form-data">
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="relation_PrimaryKey" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<input type="hidden" name="client_id" id="client_id_relation" value="<?= isset($client['id']) ? $client['id'] : '' ?>"/>
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-4">
<label for="emp_code">Account Manager</label>
<select class="form-control" id="account_manager" name="role">
<!-- <option value="">Select Account Manager</option> -->
<select class="form-control" id="account_manager" name="account_manager[]" multiple>
<?php foreach($RM as $value) { ?>
<?php if($value['role'] === '3') { ?>
<option value="<?= $value['id'] ?>"><?= $value['first_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="profile">Manager</label>
<select class="form-control" id="role" name="role">
<select class="form-control" id="manager" name="manager">user_id
<option value="">Select Manager</option>
<?php foreach($RM as $value) { ?>
<?php if($value['role'] === '2') { ?>
<option value="<?= $value['id'] ?>"><?= $value['first_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="profile">Head</label>
<select class="form-control" id="role" name="role">
<select class="form-control" id="head" name="head">
<option value="">Select Head</option>
<?php foreach($RM as $value) { ?>
<?php if($value['role'] === '5') { ?>
<option value="<?= $value['id'] ?>"><?= $value['first_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
@ -80,6 +59,9 @@ body {
<script>
$(document).ready(function(){
var relation_PrimaryKey = $('#relation_PrimaryKey').val()
$('#account_manager').multiselect({
nonSelectedText: 'Select Account Manager',
enableFiltering: false,
@ -87,5 +69,94 @@ body {
includeSelectAllOption : false,
buttonWidth:'100%'
});
var data = <?= isset($client_relation) ? json_encode($client_relation) : '[]' ?>;
if (relation_PrimaryKey !== '') {
$.each(data, function(index, item) {
$('#head option[value="' + item.user_id + '"]').prop('selected', true);
$('#manager option[value="' + item.user_id + '"]').prop('selected', true);
var $option = $('#account_manager option[value="' + item.user_id + '"]');
if ($option.length > 0) {
$option.prop('selected', true);
}
$('#account_manager').multiselect('refresh');
});
}
$("#relation_form").submit(function(event) {
event.preventDefault();
// Perform validation
var isValid = validateForm(); // Assuming you have a function for form validation
var form_action = '';
if (isValid) {
if(relation_PrimaryKey === ''){
form_action = '<?= base_url("client/relation/create"); ?>';
}else{
form_action = '<?= base_url("client/relation/edit"); ?>';
}
var formData = new FormData($('#relation_form')[0]);
$.ajax({
data: formData,
url: form_action,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
console.log(res);
if(relation_PrimaryKey === ''){
$.toast({
text: 'Client Relation Info',
heading: "Submitted Sucessfully",
position: 'top-right',
icon: 'success',
});
}else{
$.toast({
text: 'Client Relation Info',
heading: "Updated Sucessfully",
position: 'top-right',
icon: 'success',
});
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
});
function validateForm() {
var isValid = true;
// Perform validation for each field
$('#relation_form input, #relation_form select').each(function() {
// Check for empty text inputs and selects
if ($(this).is('input[type="text"]') || $(this).is('select')) {
if ($.trim($(this).val()) == '') {
alert('Please fill in all fields');
isValid = false;
return false; // Exit the loop early
}
}
});
return isValid;
}
});
</script>

View File

@ -10,6 +10,7 @@ CLI::write($message);
CLI::newLine();
CLI::write('at ' . CLI::color(clean_path($exception->getFile()) . ':' . $exception->getLine(), 'green'));
CLI::newLine();
CLI::error('ERROR: ' . $code);
// The backtrace
if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE) {

View File

@ -465,8 +465,16 @@
<!-- App js -->
<script src="<?= base_url()."public"; ?>/assets/js/app.min.js"></script>
<!-- Tost-->
<script src="<?= base_url()."public"; ?>/assets/libs/jquery-toast-plugin/jquery.toast.min.js"></script>
<!-- toastr init js-->
<script src="<?= base_url()."public"; ?>/assets/js/pages/toastr.init.js"></script>
<!-- Sweet Alert CDN -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-multiselect@1.1.0/dist/js/bootstrap-multiselect.min.js"></script>
<!-- Multiselect CDN -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<title>User List</title>
<title><?= isset($page_name) ? $page_name : 'nHance'; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
<meta content="Coderthemes" name="author" />
@ -23,11 +23,14 @@
<!-- third party css end -->
<!-- App css -->
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-material.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/app-material.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-creative.min.css" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/app-creative.min.css" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-material-dark.min.css" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/app-material-dark.min.css" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/bootstrap-creative-dark.min.css" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url()."public"; ?>/assets/css/app-creative-dark.min.css" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- Jquery Toast css -->
<link href="<?= base_url()."public"; ?>/assets/libs/jquery-toast-plugin/jquery.toast.min.css" rel="stylesheet" type="text/css" />
<!-- icons -->
<link href="<?= base_url()."public"; ?>/assets/css/icons.min.css" rel="stylesheet" type="text/css" />
@ -289,7 +292,7 @@
<!-- <span class="logo-lg-text-light">Minton</span> -->
</span>
<span class="logo-lg">
<img src="<?= base_url()."public"; ?>/assets/images/logo-dark.png" alt="" height="20">
<img src="<?= base_url()."public"; ?>/assets/images/image.png" alt="" height="50">
<!-- <span class="logo-lg-text-light">M</span> -->
</span>
</a>

View File

@ -69,7 +69,7 @@
</div>
<div class="form-group mb-0 text-center">
<a href="<?= base_url('/LoginController/receiveGoogleOAuthResponse'); ?>"><img
<a href="<?= base_url('oauth2callback'); ?>"><img
src="<?= base_url()."public"; ?>/assets/images/googleButton.svg" width="300"></a>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

File diff suppressed because one or more lines are too long