Compare commits

..

10 Commits

Author SHA1 Message Date
bitbucket
9e68ef8f83 WhatsApp template message : GWM 2024-07-24 14:37:20 +05:30
aadhavan valli
24c4d964eb CHANGE_CLIENT_BRANCH_EDIT_VIEW : AADHAVAN 2024-07-20 09:48:51 +05:30
bitbucket
d49338397f GWM 2024-07-19 16:27:34 +05:30
bitbucket
2ba925f1c6 GWM 2024-07-19 16:24:40 +05:30
bitbucket
3b8783eff3 Merge : GWM 2024-07-18 16:12:30 +05:30
bitbucket
b452f4e885 CHANGE_ test changes : GWM 2024-07-18 15:36:12 +05:30
bitbucket
0a14de4d73 CHANGE_ internal test , mail template , client feedback : GWM 2024-07-18 14:42:14 +05:30
aadhavan valli
466975dbce Merge branch 'main' of bitbucket.org:venbainformationtechnology/bb_sign 2024-07-17 16:14:53 +05:30
aadhavan valli
ebb6e7840c CHANGE_ADD_DELETE_BUTTON_DOC_NOT_SHARED_ADD_NEW_IN_HISTROY : AADHAVAN 2024-07-17 16:14:36 +05:30
bitbucket
90bea122ea CHANGE_ in docs link expire time: GWM 2024-07-16 11:10:42 +05:30
18 changed files with 802 additions and 357 deletions

3
.env
View File

@ -73,8 +73,7 @@ database.default.port = 3306
WAAI_INSTANCE = '66712908EB75A' whatsAppToken = 'EAARGyzEtu2kBO1mK3ILZAvZCd8D3QNpHo2uU5SWZBXbZC3eNL9hFpZA5WebolazilZA0RfU0zdu6gNZAW1yGCYiXFgZBC1YQfZBErv0QKAYQAT9wMOTy2f0C3m4ZAK8ZCwt3mGlURfa6m2uUCyNK4qEUy2Evx7scd8aanXLFr8MJUbVNJP8BPPSpUJW4A0dZAaci56lrPGnw0hV7jV9ISGmDLNYZD';
WAAI_TOKEN = '667128c844c48'
API_KEY = 'HgvlULWCIrs'; // Your API key API_KEY = 'HgvlULWCIrs'; // Your API key

View File

@ -76,6 +76,8 @@ use CodeIgniter\Router\RouteCollection;
$routes->get('client_docs_histroy/(:any)','MasterController::client_docs_histroy/$1'); $routes->get('client_docs_histroy/(:any)','MasterController::client_docs_histroy/$1');
$routes->match(['get','post'],'/change_doc_status','MasterController::change_doc_status'); $routes->match(['get','post'],'/change_doc_status','MasterController::change_doc_status');
$routes->match(['get','post'],'/rememeber_notification','MasterController::rememeber_notification'); $routes->match(['get','post'],'/rememeber_notification','MasterController::rememeber_notification');
$routes->match(['get','post'],'/createSharedLink','MasterController::createSharedLink');
$routes->match(['get','post'],'/delete_doc','MasterController::delete_doc');
$routes->match(['get','post'],'/test','MasterController::test'); $routes->match(['get','post'],'/test','MasterController::test');
$routes->post('doc_generate_otp','MasterController::doc_generate_otp'); $routes->post('doc_generate_otp','MasterController::doc_generate_otp');
$routes->post('doc_verify_otp','MasterController::doc_verify_otp'); $routes->post('doc_verify_otp','MasterController::doc_verify_otp');

View File

@ -176,8 +176,9 @@ class BusinessController extends BaseController
$mail_config = $this->request->getPost(); $mail_config = $this->request->getPost();
$r_mail = $this->request->getPost('r_email'); $r_mail = $this->request->getPost('r_email');
$MailHelper = new MailHelper(); $MailHelper = new MailHelper();
print_r($MailHelper->check_mail_config($r_mail, $mail_config));die; $mail_check_status = $MailHelper->check_mail_config($r_mail, $mail_config);
return $mail_check_status;
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
} }

View File

@ -161,8 +161,7 @@ class ClientController extends BaseController
$message = 'Login OTP is: ' . $otp; $message = 'Login OTP is: ' . $otp;
if($client_branch_data['whatsapp'] == 1){ if($client_branch_data['whatsapp'] == 1){
try { try {
$notificationHelper->sendWhatsAppMessage($number, $message);
// return $this->respond(['success' => true, 'otp' => $otp]);
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->respond(['Error' => $e->getMessage()]); return $this->respond(['Error' => $e->getMessage()]);
} }
@ -262,7 +261,7 @@ class ClientController extends BaseController
public function client_branch_list() public function client_branch_list()
{ {
// if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); } // if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name, client.mobile_no as client_mobile_no') $data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name, client.mobile_no as client_mobile_no,client.email as client_email')
->join('client', 'client.client_id = client_branch.client_id', 'left') ->join('client', 'client.client_id = client_branch.client_id', 'left')
->findAll(); ->findAll();

View File

@ -529,14 +529,14 @@ class MasterController extends BaseController
}else if($this->session->has('is_client_logged_in')){ }else if($this->session->has('is_client_logged_in')){
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow(); $userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
} }
// dd();
$doc_id = $this->request->getVar('doc_id'); $doc_id = $this->request->getVar('doc_id');
if(!empty($this->request->getVar('view_from')) && $this->request->getVar('view_from') == 'client'){ if(!empty($this->request->getVar('view_from')) && $this->request->getVar('view_from') == 'client'){
$data['docData'] = $this->ClientDocsModel->clientDocPreview($doc_id); $data['docData'] = $this->ClientDocsModel->clientDocPreview($doc_id);
}else{ }else{
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id); $data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
} }
// dd($data['docData']);
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no , $data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no ,
client_branch.gst_no , client_branch.mobile_no , client_branch.gst_no , client_branch.mobile_no ,
client_branch.email , client_branch.address , client_branch.email , client_branch.address ,
@ -546,13 +546,15 @@ class MasterController extends BaseController
->where('client_branch.id',$data['docData']->client_branch_id) ->where('client_branch.id',$data['docData']->client_branch_id)
->get()->getRow(); ->get()->getRow();
if($data['clientData']->individual == 1){ if($data['clientData']->individual == 1){
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no , $clientData = $this->ClientBranchModel->select('client.email , client.mobile_no')
client.mobile_no ,
client.email , client.individual')
->join('client', 'client_branch.client_id = client.client_id', 'left') ->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_branch.id',$data['docData']->client_branch_id) ->where('client_branch.id',$data['docData']->client_branch_id)
->get()->getRow(); ->get()->getRow();
$data['clientData']->email = $clientData->email;
$data['clientData']->mobile_no = $clientData->mobile_no;
} }
$data['header_html'] = $data['docData']->header_html; $data['header_html'] = $data['docData']->header_html;
$data['footer_html'] = $data['docData']->footer_html; $data['footer_html'] = $data['docData']->footer_html;
$data['body_html'] = $data['docData']->body_html; $data['body_html'] = $data['docData']->body_html;
@ -571,6 +573,8 @@ class MasterController extends BaseController
$placeHolder = '%'.$key.'%'; $placeHolder = '%'.$key.'%';
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']); $data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
} }
$data['business_list'] = $this->BusinessModel->findAll();
echo view('layout/header', ['Data'=>$userData]); echo view('layout/header', ['Data'=>$userData]);
echo view('client_docs_preview',$data); echo view('client_docs_preview',$data);
echo view('layout/footer'); echo view('layout/footer');
@ -661,64 +665,96 @@ class MasterController extends BaseController
public function change_doc_status() public function change_doc_status()
{ {
// try { try {
$doc_id = $this->request->getPost('doc_id'); $doc_id = $this->request->getPost('doc_id');
$is_active = $this->request->getPost('is_active'); $is_active = $this->request->getPost('is_active');
$data['is_active'] = $is_active; $data['is_active'] = $is_active;
$MailHelper = new MailHelper();
$notificationHelper = new NotificationHelper();
if($is_active == 1){ if($is_active == 1){
$DateAndYears = $this->dateAndYearPlaceholder(); $DateAndYears = $this->dateAndYearPlaceholder();
$data['place_holder_object'] = $DateAndYears; $data['place_holder_object'] = $DateAndYears;
$MailHelper = new MailHelper();
$clientData = $this->ClientDocsModel->select('client.name as client_name, client_branch.email, client_branch.*')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
if($clientData->individual == 1){
$clientData = $this->ClientDocsModel->select('client.name as client_name, client.*, client_branch.sms, client_branch.whatsapp')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
}
$documentUrl = base_url();
// helper('url');
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=> md5((string)$doc_id)], 36000) . '">Preview and Approve Document</a>';
// $businessData = $this->BranchModel->select('branches.* , business.business_name ') //get Client Data
// ->join('business', 'branches.business_id = business.business_id', 'left') $clientData = $this->ClientDocsModel->select('client.name as client_name,
// ->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id')) client.email as client_email,
// ->get()->getRow(); client_branch.email as client_branch_email,
$businessData = $this->BusinessModel->select('branches.* , business.business_name ,business.smtp_host, business.smtp_user, business.smtp_pass, business.smtp_port, business.email as business_mail') client.mobile_no as client_mobile_no,
client_branch.mobile_no as client_branch_mobile_no,
client.individual as individual,
client_branch.whatsapp as whatsapp,
client_branch.sms as sms,')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
if($clientData->individual == 1){
$client_mail_id = $clientData->client_email;
$client_mobile_no = $clientData->client_mobile_no;
}else{
$client_mail_id = $clientData->client_branch_email;
$client_mobile_no = $clientData->client_branch_mobile_no;
}
//get Business and mail confic data
$businessData = $this->BusinessModel->select('branches.* , business.business_name ,business.smtp_host, business.smtp_user, business.smtp_pass, business.smtp_port, business.email as business_mail')
->join('branches', 'business.business_id = branches.business_id', 'left') ->join('branches', 'business.business_id = branches.business_id', 'left')
->where('business.business_id',$this->session->get('logged_in_staff_business_id')) ->where('business.business_id',$this->session->get('logged_in_staff_business_id'))
->get()->getRow(); ->get()->getRow();
$subject = 'BB-Sign Verify Document';
// print_r($businessData);die;
$message = "Dear " . $clientData->client_name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
// print_r($clientData->email);die;
$mail_config = [ $mail_config = [
'SMTPHost' => $businessData->smtp_host, 'protocol' => 'smtp',
'SMTPUser' => $businessData->smtp_user, 'mailType' => 'html',
'SMTPPass' => $businessData->smtp_pass, 'SMTPHost' => $businessData->smtp_host,
'SMTPPort' => $businessData->smtp_port, 'SMTPUser' => $businessData->smtp_user,
'sender_email' => $businessData->business_mail, 'SMTPPass' => $businessData->smtp_pass,
'sender_name' => $businessData->business_name 'SMTPPort' => $businessData->smtp_port,
]; 'sender_email' => $businessData->business_mail,
$MailHelper->send_url_email($clientData->email , '', $subject, $message, $mail_config); 'sender_name' => $businessData->business_name
$notificationHelper = new NotificationHelper(); ];
$number ='91'. $clientData->mobile_no; // Replace with dynamic recipient number
if($clientData->whatsapp == 1){
$whatsApp_message = "Dear " . substr($clientData->client_name, 0, 20) . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
// $notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
// send mail
$subject = 'Verify Document';
$url = generate_signed_url('preview', ['doc_id'=> md5((string)$doc_id)], 259200);
$message = "Dear " . $clientData->client_name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the button below to preview and approve.<br><br>";
$html = view('email_templates',['message'=>$message,'url'=>$url]);
$mail_status = $MailHelper->send_url_email($client_mail_id , '', $subject, $html, $mail_config);
//send whatsapp message
$number ='91'. $client_mobile_no;
if($clientData->whatsapp == 1){
$result = $notificationHelper->send_whatsapp_message($number, $clientData->client_name , $businessData->business_name , $url);
if ($result['status_code'] == 200) {
//echo 'Message sent successfully';
} else {
// echo 'Failed to send message. Status Code: ' . $result['status_code'];
// print_r($result['response']);
}
} }
//create history data for documet sharing
$statusData['client_docs_id'] = $doc_id; $statusData['client_docs_id'] = $doc_id;
$statusData['is_staff'] = 1; $statusData['is_staff'] = 1;
$statusData['created_by'] = $this->session->get('is_staff_logged_in'); $statusData['created_by'] = $this->session->get('is_staff_logged_in');
$statusData['status'] = 'Shared'; $statusData['status'] = 'Shared';
$this->DocsStatusModel->insert($statusData); $this->DocsStatusModel->insert($statusData);
//create history data for mail sending status
$statusData['note'] = $client_mail_id;
if($mail_status['status'] == 'success'){ $statusData['status'] = 'Mail Success';
}else{ $statusData['status'] = 'Mail Failed'; }
$this->DocsStatusModel->insert($statusData);
}else{ }else{
$statusData['client_docs_id'] = $doc_id; $statusData['client_docs_id'] = $doc_id;
$statusData['is_staff'] = 1; $statusData['is_staff'] = 1;
@ -729,14 +765,18 @@ class MasterController extends BaseController
$updated = $this->ClientDocsModel->update($doc_id, $data); $updated = $this->ClientDocsModel->update($doc_id, $data);
if ($updated) { if ($updated) {
return $this->response->setJSON(['status' => 'success','code' => 200,'data' => true],200); if($is_active == 1){
return $this->response->setJSON(['status' => 'success','code' => 200,'data' => "Document Shared",'mail_status'=>$mail_status['status'],'mail'=>$client_mail_id ],200);
}else{
return $this->response->setJSON(['status' => 'success','code' => 200,'data' => "Document Reverted"],200);
}
} else { } else {
$result = "No Match's"; $result = "No Match's";
return $this->response->setJSON(['status' => 'failed','code' => 404,'data' => $result],404); return $this->response->setJSON(['status' => 'failed','code' => 404,'data' => $result],404);
} }
// } catch (\Exception $exception) { } catch (\Exception $exception) {
// return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500); return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
// } }
} }
public function rememeber_notification() public function rememeber_notification()
@ -745,31 +785,36 @@ class MasterController extends BaseController
$doc_id = $this->request->getPost('doc_id'); $doc_id = $this->request->getPost('doc_id');
$MailHelper = new MailHelper(); $MailHelper = new MailHelper();
$clientData = $this->ClientDocsModel->select('client.name as client_name, client_branch.email, client_branch.mobile_no, client_branch.whatsapp, client.individual, client_docs.business_id') //get Client Data
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left') $clientData = $this->ClientDocsModel->select('client.name as client_name,
->join('client', 'client_branch.client_id = client.client_id', 'left') client.email as client_email,
->where('client_docs.id', $doc_id)->get()->getRow(); client_branch.email as client_branch_email,
client.mobile_no as client_mobile_no,
client_branch.mobile_no as client_branch_mobile_no,
client.individual as individual,
client_branch.whatsapp as whatsapp,
client_branch.sms as sms,
client_docs.business_id')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
if($clientData->individual == 1){ if($clientData->individual == 1){
$clientData = $this->ClientDocsModel->select('client.name as client_name, client.email, client.mobile_no, client_branch.whatsapp, client.individual, client_docs.business_id') $client_mail_id = $clientData->client_email;
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left') $client_mobile_no = $clientData->client_mobile_no;
->join('client', 'client_branch.client_id = client.client_id', 'left') }else{
->where('client_docs.id', $doc_id)->get()->getRow(); $client_mail_id = $clientData->client_branch_email;
$client_mobile_no = $clientData->client_branch_mobile_no;
} }
// helper('url');
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=>md5((string)$doc_id)], 36000) . '">Preview and Approve Document</a>';
// $businessData = $this->BranchModel->select('branches.* , business.business_name ') //get Business and mail confic data
// ->join('business', 'branches.business_id = business.business_id', 'left')
// ->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
// ->get()->getRow();
$businessData = $this->BusinessModel->select('business.*') $businessData = $this->BusinessModel->select('business.*')
// ->where('business.business_id',$this->session->get('logged_in_staff_business_id')) // ->where('business.business_id',$this->session->get('logged_in_staff_business_id'))
->where('business_id', $clientData->business_id) ->where('business_id', $clientData->business_id)
->get()->getRow(); ->get()->getRow();
// print_r($businessData);die;
$subject = 'BB-Sign Verify Document';
$message = "Dear " . $clientData->client_name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
$mail_config = [ $mail_config = [
'protocol' => 'smtp',
'mailType' => 'html',
'SMTPHost' => $businessData->smtp_host, 'SMTPHost' => $businessData->smtp_host,
'SMTPUser' => $businessData->smtp_user, 'SMTPUser' => $businessData->smtp_user,
'SMTPPass' => $businessData->smtp_pass, 'SMTPPass' => $businessData->smtp_pass,
@ -777,34 +822,82 @@ class MasterController extends BaseController
'sender_email' => $businessData->email, 'sender_email' => $businessData->email,
'sender_name' => $businessData->business_name 'sender_name' => $businessData->business_name
]; ];
// print_r($mail_config);die;
// send mail
$subject = 'Verify Document';
$url = generate_signed_url('preview', ['doc_id'=> md5((string)$doc_id)], 259200);
$message = "Dear " . $clientData->client_name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the button below to preview and approve.<br><br>";
$html = view('email_templates',['message'=>$message,'url'=>$url]);
$mail_status = $MailHelper->send_url_email($client_mail_id , '', $subject, $html, $mail_config);
$mail_send = $MailHelper->send_url_email($clientData->email , '', $subject, $message, $mail_config); //send whatsapp message
if (!$mail_send) { $number ='91'. $client_mobile_no;
throw new \Exception('Email sending failed.');
}
$notificationHelper = new NotificationHelper();
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
if($clientData->whatsapp == 1){ if($clientData->whatsapp == 1){
$whatsApp_message = "Dear " . substr($clientData->client_name, 0, 20) . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
//$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
} }
return $this->respond(['success' => true, 'data' => 'Remember Send Successfully']);
return $this->response->setJSON(['status' => 'success','code' => 200,'mail_status'=>$mail_status['status'],'mail'=>$client_mail_id ],200);
} catch (\Exception $exception) { } catch (\Exception $exception) {
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500); return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
} }
} }
public function createSharedLink()
{
$doc_id = $this->request->getPost('doc_id');
$link = generate_signed_url('preview', ['doc_id'=> md5((string)$doc_id)], 259200);
return $this->response->setJSON(['status' => 'success','code' => 200,'link'=>$link ],200);
}
public function delete_doc()
{
try {
$doc_id = $this->request->getPost('doc_id');
$delete_doc = $this->ClientDocsModel->where('id', $doc_id)->delete();
$delete_history = $this->DocsStatusModel->where('client_docs_id', $doc_id)->delete();
return $this->respond(['success' => true, 'data' => 'Doc Deleted SuccessFully']);
} catch (\Exception $exception) {
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
}
}
public function doc_generate_otp() public function doc_generate_otp()
{ {
try { try {
$mobile_no = $this->request->getPost('mobile_no'); $mobile_no = $this->request->getPost('mobile_no');
$client_data = $this->ClientBranchModel->where('mobile_no', $mobile_no )->first(); $doc_id = $this->request->getPost('doc_id');
if($client_data){ $clientData = $this->ClientDocsModel->select('client.name as client_name,
client.email as client_email,
client_branch.email as client_branch_email,
client.mobile_no as client_mobile_no,
client_branch.mobile_no as client_branch_mobile_no,
client.individual as individual,
client_branch.whatsapp as whatsapp,
client_branch.sms as sms,
client_docs.business_id')
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
if($clientData->individual == 1){
$client_mail_id = $clientData->client_email;
$client_mobile_no = $clientData->client_mobile_no;
}else{
$client_mail_id = $clientData->client_branch_email;
$client_mobile_no = $clientData->client_branch_mobile_no;
}
if ($clientData) {
$id = $this->request->getPost('doc_id'); $id = $this->request->getPost('doc_id');
$otp = mt_rand(100000, 999999); $otp = mt_rand(100000, 999999);
$data = ['otp' => $otp]; $data = ['otp' => $otp];
$clint_full_data = $this->ClientDocsModel->select('client_docs.* , services.service_name , service_group.group_name , client_branch.name as client_branch_name , client.name as client_name') $client_full_data = $this->ClientDocsModel->select('client_docs.* , services.service_name , service_group.group_name , client_branch.name as client_branch_name , client.name as client_name')
->join('template', 'template.template_id = client_docs.template_id', 'left') ->join('template', 'template.template_id = client_docs.template_id', 'left')
->join('services', 'services.service_id = template.service_id', 'left') ->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left') ->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
@ -817,11 +910,11 @@ class MasterController extends BaseController
$notificationHelper = new NotificationHelper(); $notificationHelper = new NotificationHelper();
$number = '91'.$mobile_no; // Replace with dynamic recipient number $number = '91'.$mobile_no; // Replace with dynamic recipient number
$message = 'Document Verification OTP : ' . $otp; $message = 'Document Verification OTP : ' . $otp;
if($client_data['whatsapp'] == 1){ if($clientData->whatsapp == 1){
// $notificationHelper->sendWhatsAppMessage($number, $message);
} }
if($client_data['sms'] == 1){ if($clientData->sms == 1){
$data = $notificationHelper->sendSms($number, $client_data['name'] , $otp, '', 'doc_verify',$clint_full_data); $data = $notificationHelper->sendSms($number, $clientData->client_name , $otp, '', 'doc_verify',$client_full_data);
} }
return $this->respond(['success' => true]); return $this->respond(['success' => true]);
} }
@ -922,4 +1015,15 @@ class MasterController extends BaseController
return $this->fail('Invalid request method', 405); return $this->fail('Invalid request method', 405);
} }
} }
public function test(){
$notificationHelper = new NotificationHelper();
$result = $notificationHelper->send_whatsapp_message('919884002190','','','');
if ($result['status_code'] == 200) {
echo 'Message sent successfully';
} else {
echo 'Failed to send message. Status Code: ' . $result['status_code'];
print_r($result['response']);
}
}
} }

View File

@ -98,10 +98,12 @@ class TestController extends Controller
->get()->getRow(); ->get()->getRow();
if($data['clientData']->individual == 1){ if($data['clientData']->individual == 1){
$data['clientData'] = $this->ClientBranchModel->select('client.name ,client.individual, client.pan_no, client.mobile_no , client.email ') $clientData = $this->ClientBranchModel->select('client.email , client.mobile_no')
->join('client', 'client_branch.client_id = client.client_id', 'left') ->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_branch.id',$data['docData']->client_branch_id) ->where('client_branch.id',$data['docData']->client_branch_id)
->get()->getRow(); ->get()->getRow();
$data['clientData']->email = $clientData->email;
$data['clientData']->mobile_no = $clientData->mobile_no;
} }

View File

@ -15,14 +15,14 @@ class MailHelper
try { try {
$email = \Config\Services::email(); $email = \Config\Services::email();
$email->initialize([ // $email->initialize([
'protocol' => $config['protocol'], // 'protocol' => $config['protocol'],
'SMTPHost' => $config['SMTPHost'], // 'SMTPHost' => $config['SMTPHost'],
'SMTPUser' => $config['SMTPUser'], // 'SMTPUser' => $config['SMTPUser'],
'SMTPPass' => $config['SMTPPass'], // 'SMTPPass' => $config['SMTPPass'],
'SMTPPort' => $config['SMTPPort'], // 'SMTPPort' => $config['SMTPPort'],
// 'mailType' => $config['mailType'] // // 'mailType' => $config['mailType']
]); // ]);
// $email->setFrom($config['sender_email'], $config['sender_name']);/ // $email->setFrom($config['sender_email'], $config['sender_name']);/
$email->setMailType('html'); $email->setMailType('html');
@ -48,41 +48,27 @@ class MailHelper
} }
} }
public static function send_url_email($email_id, $branch_email, $subject, $message, $mail_config = []) public static function send_url_email($email_id, $branch_email, $subject, $html, $mail_config = [])
{ {
// print_r("helllo");die;
// try { // try {
$default_config = [
'protocol' => 'smtp',
'SMTPHost' => 'mail.venbait.in',
'SMTPUser' => 'bbone@venbait.in',
'SMTPPass' => 'xk!L(N_-R#};',
'SMTPPort' => 465,
'mailType' => 'html',
'sender_email' => 'bbone@venbait.in',
'sender_name' => 'BB-Sign'
];
// Merge default config with provided config // Merge default config with provided config
$config = array_merge($default_config, $mail_config);
$email = \Config\Services::email(); $email = \Config\Services::email();
$email->initialize([ $email->initialize([
'protocol' => $config['protocol'], 'protocol' => $mail_config['protocol'],
'SMTPHost' => $config['SMTPHost'], 'SMTPHost' => $mail_config['SMTPHost'],
'SMTPUser' => $config['SMTPUser'], 'SMTPUser' => $mail_config['SMTPUser'],
'SMTPPass' => $config['SMTPPass'], 'SMTPPass' => $mail_config['SMTPPass'],
'SMTPPort' => (int)$config['SMTPPort'], 'SMTPPort' => (int)$mail_config['SMTPPort'],
'mailType' => $config['mailType'] 'mailType' => $mail_config['mailType']
]); ]);
$email->setFrom($config['sender_email'], $config['sender_name']); $email->setFrom($mail_config['sender_email'], $mail_config['sender_name']);
$email->setTo($email_id); $email->setTo($email_id);
$email->setSubject($subject); $email->setSubject($subject);
$email->setMessage($message); $email->setMessage($html);
if ($email->send()) { if ($email->send()) {
return ['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $email_id]; return ['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $email_id];
@ -99,42 +85,36 @@ class MailHelper
public static function check_mail_config($r_email, $mail_config = []) public static function check_mail_config($r_email, $mail_config = [])
{ {
$default_config = [ if (empty($mail_config['protocol']) || empty($mail_config['SMTPHost']) ||
'protocol' => 'smtp', empty($mail_config['SMTPUser']) || empty($mail_config['SMTPPass']) ||
'SMTPHost' => 'mail.venbait.in', empty($mail_config['SMTPPort']) || empty($mail_config['mailType']) ||
'SMTPUser' => 'bbone@venbait.in', empty($mail_config['sender_email']) ) {
'SMTPPass' => 'xk!L(N_-R#};', return json_encode(['status' => 'failed', 'code' => 400, 'message' => 'Incomplete Mail Configuration', 'data' => $r_email]);
'SMTPPort' => 465, }
'mailType' => 'html',
'sender_email' => 'bbone@venbait.in',
'sender_name' => 'BB-Sign'
];
// Merge default config with provided config
$config = array_merge($default_config, $mail_config);
$email = \Config\Services::email(); $email = \Config\Services::email();
$email->initialize([ $email->initialize([
'protocol' => $config['protocol'], 'protocol' => $mail_config['protocol'],
'SMTPHost' => $config['SMTPHost'], 'SMTPHost' => $mail_config['SMTPHost'],
'SMTPUser' => $config['SMTPUser'], 'SMTPUser' => $mail_config['SMTPUser'],
'SMTPPass' => $config['SMTPPass'], 'SMTPPass' => $mail_config['SMTPPass'],
'SMTPPort' => (int)$config['SMTPPort'], 'SMTPPort' => (int)$mail_config['SMTPPort'],
'mailType' => $config['mailType'] 'mailType' => $mail_config['mailType']
]); ]);
$email->setFrom($config['sender_email'], "Sender Name"); $email->setFrom($mail_config['sender_email'], '');
$email->setTo($r_email); $email->setTo($r_email);
$email->setSubject("Test Mail Configuration"); $email->setSubject("Test Mail Configuration");
$email->setMessage("Test Mail Configuration"); $email->setMessage("Test Mail Configuration");
if ($email->send()) { if ($email->send()) {
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $r_email]); return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $r_email]);
} else { } else {
log_message('error', 'Email sending failed: ' . $email->printDebugger(['headers'])); log_message('error', 'Email sending failed: ' . $email->printDebugger(['headers']));
return ['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $r_email]; return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $r_email]);
} }
} }
} }

View File

@ -4,7 +4,7 @@
namespace App\Helpers; namespace App\Helpers;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
use CodeIgniter\HTTP\ClientInterface;
class NotificationHelper class NotificationHelper
{ {
protected $email; protected $email;
@ -18,70 +18,7 @@ class NotificationHelper
} }
public function sendWhatsAppMessage($number, $message, $client_login_url = '')
{
// Extract plain text message
$plainTextMessage = strip_tags($message);
// Extract URL from message
preg_match('/<a\s+(?:[^>]*?\s+)?href="([^"]*)"/i', $client_login_url, $match);
$client_login_url = isset($match[1]) ? $match[1] : '';
// Prepare the data to send
$instance_id = $_ENV['WAAI_INSTANCE'];
$access_token = $_ENV['WAAI_TOKEN'];
$url = 'https://waai.in/api/send';
// Prepare the text for WhatsApp
if($client_login_url){
$whatsappMessage = $plainTextMessage . "\n\nClick here - " . $client_login_url;
}else{
$whatsappMessage = $plainTextMessage ;
}
// Prepare JSON payload
$postdata = json_encode([
'number' => $number,
'type' => 'text',
'message' => $whatsappMessage,
'instance_id' => $instance_id,
'access_token' => $access_token
]);
// Initialize cURL session
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($postdata)
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// Execute cURL session
$response = curl_exec($ch);
// Check for cURL errors
if ($response === false) {
$this->logger->error('Failed to communicate with WhatsApp API: ' . curl_error($ch));
curl_close($ch);
throw new \Exception('Failed to communicate with WhatsApp API');
}
// Get HTTP response code
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Check HTTP response code for success
if ($httpCode !== 200) {
$this->logger->error('Failed to send WhatsApp message. HTTP Code: ' . $httpCode);
throw new \Exception('Failed to send WhatsApp message. HTTP Code: ' . $httpCode);
}
// Log success or handle further
$this->logger->info('WhatsApp message sent successfully to ' . $number);
return true;
}
public function sendSms($number, $name= '', $otp='', $url ='', $message_type_name, $client_full_data='') public function sendSms($number, $name= '', $otp='', $url ='', $message_type_name, $client_full_data='')
{ {
@ -119,6 +56,76 @@ class NotificationHelper
return json_encode(['response' => $output]); return json_encode(['response' => $output]);
} }
public function send_whatsapp_message($to, $client_name , $business_name , $doc_url)
{
$url = 'https://graph.facebook.com/v20.0/355752820961010/messages';
$headers = [
'Authorization: Bearer '.$_ENV['whatsAppToken'],
'Content-Type: application/json'
];
$templateName = 'bbsigndoc';
$languageCode = 'en';
$parsedUrl = parse_url($doc_url, PHP_URL_QUERY);
$data = [
'messaging_product' => 'whatsapp',
'to' => $to,
'type' => 'template',
'template' => [
'name' => $templateName,
'language' => [
'code' => $languageCode
],
'components' => [
[
'type' => 'body',
'parameters' => [
[
'type' => 'text',
'text' => $client_name
],
[
'type' => 'text',
'text' => $business_name
]
]
],
[
'type' => 'button',
'sub_type' => 'url',
'index' => 0,
'parameters' => [
[
'type' => 'text',
'text' => $parsedUrl
]
]
]
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'status_code' => $statusCode,
'response' => json_decode($response, true)
];
}
} }
?> ?>

View File

@ -3,7 +3,7 @@
use Config\Services; use Config\Services;
if (!function_exists('generate_signed_url')) { if (!function_exists('generate_signed_url')) {
function generate_signed_url($route, $params = [], $expiresIn = 3600) function generate_signed_url($route, $params = [], $expiresIn = 259200)
{ {
$secretKey = 'your-secret-key'; // Change this to your secret key $secretKey = 'your-secret-key'; // Change this to your secret key
$expiresAt = time() + $expiresIn; $expiresAt = time() + $expiresIn;

View File

@ -32,13 +32,10 @@
<table id="business_branch_table" class="table table-striped dt-responsive nowrap w-100"> <table id="business_branch_table" class="table table-striped dt-responsive nowrap w-100">
<thead> <thead>
<tr> <tr>
<th>Branch Name</th> <th>Branch Name</th>
<th>GST</th> <th>GST</th>
<th>Address</th> <th>Address</th>
<th>City</th>
<th>State</th>
<th>PIN Code</th>
<th>Contact</th> <th>Contact</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <th>Action</th>
@ -52,10 +49,12 @@
<tr> <tr>
<td><?= $value['branch_name']; ?></td> <td><?= $value['branch_name']; ?></td>
<td><?= $value['gstno']; ?></td> <td><?= $value['gstno']; ?></td>
<td><?= $value['address']; ?></td> <td>
<td><?= $value['city']; ?></td> <?= $value['address']; ?></br>
<td><?= $value['state']; ?></td> <?= $value['city']; ?>
<td><?= $value['pin_code']; ?></td> <?php if (!empty($value['state'])): ?>, <?= $value['state']; ?><?php endif; ?>
<?php if (!empty($value['pin_code'])): ?> - <?= $value['pin_code']; ?><?php endif; ?>
</td>
<td><?= $value['contact']; ?></td> <td><?= $value['contact']; ?></td>
<td> <td>
<?php if ($value['isactive'] == 0): ?> <?php if ($value['isactive'] == 0): ?>

View File

@ -57,9 +57,12 @@
<h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-envelope mr-1"></i> Mail Settings</h5> <h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-envelope mr-1"></i> Mail Settings</h5>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="subject-input">Email</label> <label for="subject-input">Sender Email</label>
<input type="mail" id="email" class="form-control" value="<?= isset($business['email']) ? $business['email'] : '' ?>"> <input type="mail" id="email" class="form-control" value="<?= isset($business['email']) ? $business['email'] : '' ?>">
</div> </div>
<div class="form-group col-md-6">
</div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="subject-input">User Name</label> <label for="subject-input">User Name</label>
<input type="text" id="user_name" class="form-control" value="<?= isset($business['smtp_user']) ? $business['smtp_user'] : '' ?>"> <input type="text" id="user_name" class="form-control" value="<?= isset($business['smtp_user']) ? $business['smtp_user'] : '' ?>">
@ -77,33 +80,32 @@
<input type="text" id="port" class="form-control" value="<?= isset($business['smtp_port']) ? $business['smtp_port'] : '' ?>"> <input type="text" id="port" class="form-control" value="<?= isset($business['smtp_port']) ? $business['smtp_port'] : '' ?>">
</div> </div>
</div> </div>
<?php if(!isset($business['business_id'])){ ?>
<h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-bell mr-1"></i>Test Mail</h5> <h5 class="mb-3 text-uppercase bg-light p-2 client_notification_area"><i class="fas fa-envelope-open-text mr-1"></i>Test Mail</h5>
<div class="form-row" id="test_mail_config_div"> <div class="form-row" id="test_mail_config_div">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="">Test Config Mail</label> <label for="">Enter Your Mail-Id</label>
<input type="mail" class="form-control" id="r_email"> <input type="mail" class="form-control" id="r_email">
</div> </div>
<?php }else{ ?> <div class="form-group col-md-6">
<div class="form-row"> <label for=""></label>
<div class="form-group col-md-6">
<!-- <label for="">Test Config Mail</label> --> <button class="btn btn-primary" id="test-email-btn" type="button" style="margin-top: 29px;">Test Email</button>
<!-- <input type="mail" class="form-control" id="r_email"> --> <img src="<?= base_url()."public"; ?>/assets/images/submit-spin.svg" width="29px" height="29px" class="ml-2" id="submit-spin" style="display:none; margin-top: 2.1rem !important;"></img>
</div> </div>
<?php } ?>
</div> </div>
</form> </form>
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>"> <input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
<input type="hidden" id="header_html" value='<?= isset($business['business_id']) ? $business['header_html'] : '' ?>'> <input type="hidden" id="header_html" value='<?= isset($business['business_id']) ? $business['header_html'] : '' ?>'>
<input type="hidden" id="footer_html" value='<?= isset($business['business_id']) ? $business['footer_html'] : '' ?>'> <input type="hidden" id="footer_html" value='<?= isset($business['business_id']) ? $business['footer_html'] : '' ?>'>
<?php if(isset($business['business_id'])){?> <?php if(isset($business['business_id']) > 0){ ?>
<button type="submit" id="savedata" class="btn btn-primary">Submit</button> <button type="submit" id="savedata" class="btn btn-primary" style="float: right;">Submit</button>
<?php }else{ ?> <?php }else{ ?>
<button class="btn btn-primary" id="test-email-btn" type="button">Test Email</button> <button type="submit" id="savedata" class="btn btn-primary" style="float: right;" disabled>Submit</button>
<button type="submit" id="savedata" class="btn btn-primary" style="display:none;">Submit</button> <?php } ?>
<?php } ?>
</div> </div>
</div> <!-- end card --> </div> <!-- end card -->
</div> </div>
@ -119,62 +121,67 @@
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#summernote-header').summernote({ $('#summernote-header').summernote({
height: 150, // set the height of the editor height: 150, // set the height of the editor
toolbar: [ toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear' ]],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph' , 'height']],
['table', ['table']],
['insert', [ 'picture']],
['view', ['fullscreen', 'codeview', 'help']],
['mybutton', ['customButton','Years']] // Custom button group
],
});
$('#summernote-footer').summernote({
height: 150, // set the height of the editor
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear' ]],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph' , 'height']],
['table', ['table']],
['insert', [ 'picture']],
['view', ['fullscreen', 'codeview', 'help']],
['mybutton', ['customButton','Years']] // Custom button group
],
});
setTimeout(() =>
{
$('#summernote-header').summernote('code', $('#header_html').val());
$('#summernote-footer').summernote('code', $('#footer_html').val());
['style', ['style']], }, 500);
['font', ['bold', 'italic', 'underline', 'clear' ]],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph' , 'height']],
['table', ['table']],
['insert', [ 'picture']],
['view', ['fullscreen', 'codeview', 'help']],
['mybutton', ['customButton','Years']] // Custom button group
],
}); });
$('#summernote-footer').summernote({
height: 150, // set the height of the editor
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear' ]],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph' , 'height']],
['table', ['table']],
['insert', [ 'picture']],
['view', ['fullscreen', 'codeview', 'help']],
['mybutton', ['customButton','Years']] // Custom button group
],
});
setTimeout(() =>
{
$('#summernote-header').summernote('code', $('#header_html').val());
$('#summernote-footer').summernote('code', $('#footer_html').val());
}, 500);
});
$("#test-email-btn").on("click", function() $("#test-email-btn").on("click", function()
{ {
$('#submit-spin').show();
$(this).hide();
formData ={ formData ={
sender_email : $('#email').val(), sender_email : $('#email').val(),
r_email : $('#r_email').val(), r_email : $('#r_email').val(),
smtp_host : $('#host').val(), SMTPHost : $('#host').val(),
smtp_user : $('#user_name').val(), SMTPUser : $('#user_name').val(),
smtp_pass : $('#password').val(), SMTPPass : $('#password').val(),
smtp_port : $('#port').val(), SMTPPort : $('#port').val(),
mailType : 'html',
protocol : 'smtp',
}; };
// console.log(formData); // console.log(formData);
$.ajax({ $.ajax({
@ -183,17 +190,17 @@ $(document).ready(function() {
data: formData, data: formData,
json: true, json: true,
success: function(response) { success: function(response) {
console.log(response);
console.log(JSON.parse(response));
if(JSON.parse(response).status == 'success'){ if(JSON.parse(response).status == 'success'){
$('#savedata').css('display',''); $('#savedata').prop('disabled', false);
$('#test-email-btn').css('display','none'); toastr.success('Mail Sent successfully ', 'Success');
toastr.success('Data saved successfully ', 'Success'); // window.location.href = '<?= base_url()."business_list"; ?>';
// window.location.href = '<?= base_url()."business_list"; ?>';
}else{
}else{ $('#savedata').prop('disabled', true);
toastr.warning('Something went wrong', 'Warning'); toastr.warning('Mail sending failed. Please check your mail configuration.', 'Warning');
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
@ -201,24 +208,58 @@ $(document).ready(function() {
console.error(xhr.responseText); console.error(xhr.responseText);
} }
}); });
setTimeout(() => {
$('#submit-spin').hide();
$(this).show();
}, 2000);
}) })
$("#savedata").on("click", function() $("#savedata").on("click", function()
{ {
var isValid = true;
var headerContent = $('#summernote-header').summernote('code'); var firstEmptyField = null;
var footerContent = $('#summernote-footer').summernote('code');
formData ={ // Find all elements with 'required' attribute
business_id : $('#business_id').val(), $('form [required]').each(function() {
business_name : $('#business_name').val(), var field = $(this);
header_html : headerContent,
footer_html : footerContent, // Check if the field is empty
email : $('#email').val(), if (field.val().trim() === '') {
smtp_host : $('#host').val(), isValid = false;
smtp_user : $('#user_name').val(), if (!firstEmptyField) {
smtp_pass : $('#password').val(), firstEmptyField = field;
smtp_port : $('#port').val(), }
};
// Highlight the empty field
field.addClass('error');
} else {
// Remove error class if the field is not empty
field.removeClass('error');
}
});
if (!isValid) {
// Focus on the first empty field and show an error message
toastr.warning('Please fill in all required fields.', 'Warning');
firstEmptyField.focus();
return; // Prevent the AJAX call
}
var headerContent = $('#summernote-header').summernote('code');
var footerContent = $('#summernote-footer').summernote('code');
formData ={
business_id : $('#business_id').val(),
business_name : $('#business_name').val(),
header_html : headerContent,
footer_html : footerContent,
email : $('#email').val(),
smtp_host : $('#host').val(),
smtp_user : $('#user_name').val(),
smtp_pass : $('#password').val(),
smtp_port : $('#port').val(),
};
$.ajax({ $.ajax({
url: '<?= base_url()."add_business"; ?>', url: '<?= base_url()."add_business"; ?>',

View File

@ -35,12 +35,10 @@
<tr> <tr>
<th>Client</th> <th>Client</th>
<th>Branch Name</th> <th>Branch Name</th>
<th>GST No</th> <th>GST</th>
<th>Mobile</th>
<th>Email</th>
<th>Address</th> <th>Address</th>
<th>City</th>
<th>State</th>
<th>Pin Code</th>
<th>Mobile No</th>
<th>Active</th> <th>Active</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
@ -49,21 +47,19 @@
<?php foreach ($clientBranchList as $value) :?> <?php foreach ($clientBranchList as $value) :?>
<tr> <tr>
<td><?= $value['client_name']; ?></td> <td><?= $value['client_name']; ?></td>
<?php if($value['individual'] == 1) { ?> <td> <?php if($value['individual'] == 1) { ?><?= 'Individual' ?><?php }else{ ?> <?= $value['name']; ?><?php } ?></td>
<td><?= $value['client_name']; ?></td>
<?php }else{ ?>
<td><?= $value['name']; ?></td>
<?php } ?>
<td><?= $value['gst_no']; ?></td> <td><?= $value['gst_no']; ?></td>
<td><?= $value['address']; ?></td> <td> <?php if($value['individual'] == 1) { ?><?= $value['client_mobile_no']; ?><?php }else{ ?> <?= $value['mobile_no']; ?><?php } ?></td>
<td><?= $value['city']; ?></td> <td><?php if($value['individual'] == 1) { ?><?= $value['client_email']; ?><?php }else{ ?> <?= $value['email']; ?><?php } ?></td>
<td><?= $value['state']; ?></td>
<td><?= $value['pin_code']; ?></td> <td>
<?php if($value['individual'] == 1) { ?> <?= $value['address']; ?></br>
<td><?= $value['client_mobile_no']; ?></td> <?= $value['city']; ?>
<?php }else{ ?> <?php if (!empty($value['state'])): ?>, <?= $value['state']; ?><?php endif; ?>
<td><?= $value['mobile_no']; ?></td> <?php if (!empty($value['pin_code'])): ?> - <?= $value['pin_code']; ?><?php endif; ?>
<?php } ?> </td>
<td> <td>
<?php if ($value['is_active'] == 0): ?> <?php if ($value['is_active'] == 0): ?>
<span style="color: red;">Inactive</span> <span style="color: red;">Inactive</span>
@ -414,6 +410,8 @@
$('#email').prop('required', false); $('#email').prop('required', false);
$('#mobile_no').prop('required', false); $('#mobile_no').prop('required', false);
}else{ }else{
$('.branch_hide_edit').show();
$('#individual').val('');
$('#branch_name').val(response.name); $('#branch_name').val(response.name);
$('#gst_no').val(response.gst_no); $('#gst_no').val(response.gst_no);
$('#email').val(response.email); $('#email').val(response.email);

View File

@ -54,9 +54,14 @@
<div class="col-8"> <div class="col-8">
<div class="page-title-box page-title-box-alt"> <div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $docData->service_name; ?> <h4 class="page-title"><?php echo $docData->service_name; ?>
<a class="download-btnn" style="color:#000;"> <a class="download-btnn" style="color:#000;" title="Download">
<i class="fas fa-download"></i> <i class="fas fa-download"></i>
</a> </a>
<?php if(isset($_SESSION['is_staff_logged_in']) && $_SESSION['is_staff_logged_in']) { ?>
<i class="mdi mdi-link-variant-plus" title="Create Share Link" data-id="<?php echo $docData->doc_id; ?>" onclick="createSharedLink(this)"></i>
<?php } ?>
</h4> </h4>
<div class="page-title-right"> <div class="page-title-right">
<!-- <a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light" > Close </a> --> <!-- <a onclick="window.history.back()" class="btn btn-secondary waves-effect waves-light" > Close </a> -->
@ -190,6 +195,22 @@
</div><!-- /.modal --> </div><!-- /.modal -->
<div id="linkModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<p id="generatedLink" style="display:none;"></p>
Copy the document link by clicking the below button
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="copyLinkButton">Copy Link</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script> <script>
@ -432,10 +453,30 @@
data: formData, data: formData,
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
$('.loader').fadeOut(); setTimeout(function() {
$('.loader-mask').fadeOut('slow'); $('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
}, 1000);
console.log(response);
if (response.data) { if (response.data) {
window.location.reload(); if (response.hasOwnProperty('mail_status')) {
if (response.mail_status == 'success')
{
toastr.success(response.data, 'Success');
toastr.success('Mail Send To '+response.mail, 'Success');
} else {
toastr.success(response.data, 'Success');
toastr.warning('Failed to send mail to '+response.mail, 'Warning');
}
} else {
toastr.success(response.data, 'Success');
}
setTimeout(function() { window.location.reload(); }, 2000);
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
@ -448,6 +489,56 @@
} }
function createSharedLink(params){
var doc_id = params.getAttribute('data-id');
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = {
doc_id: doc_id,
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."createSharedLink"?>',
data: formData,
dataType: 'json',
success: function(response) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
}, 1000);
if (response.status == 'success')
{
$('#generatedLink').text(response.link);
$('#linkModal').modal('show');
} else {
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$(document).on('click', '#copyLinkButton', function() {
const textToCopy = $('#generatedLink').text();
// Use the Clipboard API to copy the text
navigator.clipboard.writeText(textToCopy).then(() => {
// Success callback
console.log('Text copied to clipboard');
}).catch(err => {
// Error callback
console.error('Failed to copy text: ', err);
});
});
</script> </script>

View File

@ -0,0 +1,75 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<head>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Minton - Responsive Bootstrap 4 Admin Dashboard</title>
</head>
<body itemscope itemtype="http://schema.org/EmailMessage"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;"
bgcolor="#f6f6f6">
<table class="body-wrap"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;"
bgcolor="#f6f6f6">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
valign="top"></td>
<td class="container" width="600"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;"
valign="top">
<div class="content"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
<table class="main" width="100%" cellpadding="0" cellspacing="0"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;"
bgcolor="#fff">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class=""
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #fff; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #38414a; margin: 0; padding: 20px;"
align="center" bgcolor="#71b6f9" valign="top">
<span style="margin-top: 10px;display: block;">Verify Document</span>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-wrap"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;"
valign="top">
<table width="100%" cellpadding="0" cellspacing="0"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
valign="top">
<?= $message; ?>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
valign="top">
<a href=" <?= $url; ?>" class="btn-primary"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #f1556c; margin: 0; border-color: #f1556c; border-style: solid; border-width: 8px 16px;">
Preview and Approve Document
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
valign="top"></td>
</tr>
</table>
</body>
</html>

View File

@ -160,22 +160,34 @@
</style> </style>
<style> <style>
.dropdown-menu-right { .dropdown-menu-right {
right: auto !important; right: auto !important;
top: auto !important; top: auto !important;
/* left: auto !important; */ /* left: auto !important; */
} }
.modal-xg { .modal-xg {
max-width: 70%; /* Adjust the percentage as needed */ max-width: 70%; /* Adjust the percentage as needed */
} }
</style> </style>
</head> </head>
<script>
$(window).on('load', function() {
// setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
// }, 500);
});
</script>
<body class="loading" data-layout-mode="horizontal" data-layout='{"mode": "light", "width": "fluid", "menuPosition": "fixed", "topbar": {"color": "dark"}, "showRightSidebarOnPageLoad": true}'> <body class="loading" data-layout-mode="horizontal" data-layout='{"mode": "light", "width": "fluid", "menuPosition": "fixed", "topbar": {"color": "dark"}, "showRightSidebarOnPageLoad": true}'>
<!-- <div class="loader-mask">
<div class="loader">
<img src="<?= base_url() . "public" ?>/assets/images/submit-spin.svg" height="40" width="40" alt="Loading...">
</div>
</div> -->
<!-- Begin page --> <!-- Begin page -->
<div id="wrapper"> <div id="wrapper">

View File

@ -77,13 +77,12 @@
</tr> </tr>
<tr> <tr>
<th style="width:10px">Client Name</th> <th style="width:10px">Client</th>
<th>Client Branch Name</th>
<th>Service Group</th> <th>Service Group</th>
<th>Service Name</th> <th>Service</th>
<th>Document Name</th> <th>Document</th>
<th>Doc Status</th> <th>Doc Status</th>
<th>Approve Date</th> <th>Approval Date</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
@ -94,8 +93,7 @@
<?php foreach ($doc_list as $key => $value) { ?> <?php foreach ($doc_list as $key => $value) { ?>
<tr> <tr>
<td style="width:10px"> <?php echo $value['client_name']; ?></td> <td style="width:10px"> <?= $value['client_name']; ?> <?php if (!empty($value['client_branch_name'])): ?>- <?= $value['client_branch_name']; ?><?php endif; ?> </td>
<td> <?php echo $value['client_branch_name']; ?></td>
<td> <?php echo $value['group_name']; ?></td> <td> <?php echo $value['group_name']; ?></td>
<td> <?php echo $value['service_name']; ?></td> <td> <?php echo $value['service_name']; ?></td>
<td> <?php echo $value['document_name']; ?></td> <td> <?php echo $value['document_name']; ?></td>
@ -133,7 +131,7 @@
</a> </a>
<?php } ?> <?php } ?>
<a id="doc_history_button" data-id="<?php echo $value['id']; ?>" class="dropdown-item" data-toggle="modal" data-target="#bike_make_login-modal" data-title="Share"> <a id="doc_history_button" data-id="<?php echo $value['id']; ?>" class="dropdown-item" data-toggle="modal" data-target="#bike_make_login-modal" data-title="History">
<i class="mdi mdi-history" style="margin-right: 16px !important;"></i>History <i class="mdi mdi-history" style="margin-right: 16px !important;"></i>History
</a> </a>
@ -146,7 +144,16 @@
<a class="dropdown-item" data-id="<?php echo $value['id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Remember" onclick="rememberNotification(this)"> <a class="dropdown-item" data-id="<?php echo $value['id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Remember" onclick="rememberNotification(this)">
<i class="mdi mdi-email-send" style="margin-right: 16px !important; margin-left: 5px;"></i>Reminder <i class="mdi mdi-email-send" style="margin-right: 16px !important; margin-left: 5px;"></i>Reminder
</a> </a>
<?php } ?>
<?php if($value['is_active'] == 1 && $value['is_approved'] == 0){ ?>
<a class="dropdown-item" data-id="<?php echo $value['id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Create Link" onclick="createSharedLink(this)">
<i class="mdi mdi-link-variant-plus" style="margin-right: 16px !important; margin-left: 5px;"></i>Create Link
</a>
<?php } ?>
<?php if($value['is_active'] == 0 ) { ?>
<a class="dropdown-item" data-id="<?php echo $value['id']; ?>" title="Delete" onclick="DeleteDoc(this)">
<i class="mdi mdi-delete" style="margin-right: 16px !important; margin-left: 5px;"></i>Delete
</a>
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
@ -297,6 +304,21 @@
</div><!-- /.modal-dialog --> </div><!-- /.modal-dialog -->
</div><!-- /.modal --> </div><!-- /.modal -->
<div id="linkModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<p id="generatedLink" style="display:none;"></p>
Copy the document link by clicking the below button
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="copyLinkButton">Copy Link</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- ============================================================== --> <!-- ============================================================== -->
@ -593,6 +615,8 @@
if(status == 1){ if(status == 1){
var is_active= 0; var is_active= 0;
}else{ }else{
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var is_active= 1; var is_active= 1;
} }
@ -606,9 +630,30 @@
data: formData, data: formData,
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
}, 1000);
console.log(response); console.log(response);
if (response.data) { if (response.data) {
window.location.reload(); if (response.hasOwnProperty('mail_status')) {
if (response.mail_status == 'success')
{
toastr.success(response.data, 'Success');
toastr.success('Mail Sent To '+response.mail, 'Success');
} else {
toastr.success(response.data, 'Success');
toastr.warning('Failed to sent mail to '+response.mail, 'Warning');
}
} else {
toastr.success(response.data, 'Success');
}
setTimeout(function() { window.location.reload(); }, 2000);
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
@ -622,7 +667,8 @@
function rememberNotification(params) { function rememberNotification(params) {
var doc_id = params.getAttribute('data-id'); var doc_id = params.getAttribute('data-id');
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = { var formData = {
doc_id: doc_id, doc_id: doc_id,
}; };
@ -631,6 +677,93 @@
url: '<?php echo base_url()."rememeber_notification"?>', url: '<?php echo base_url()."rememeber_notification"?>',
data: formData, data: formData,
dataType: 'json', dataType: 'json',
success: function(response) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
}, 1000);
if (response.mail_status == 'success')
{
toastr.success('Mail Send To '+response.mail, 'Success');
} else {
toastr.warning('Failed to send mail to '+response.mail, 'Warning');
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function createSharedLink(params){
var doc_id = params.getAttribute('data-id');
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = {
doc_id: doc_id,
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."createSharedLink"?>',
data: formData,
dataType: 'json',
success: function(response) {
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').fadeOut('slow');
}, 1000);
if (response.status == 'success')
{
$('#generatedLink').text(response.link);
$('#linkModal').modal('show');
} else {
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$(document).on('click', '#copyLinkButton', function() {
const textToCopy = $('#generatedLink').text();
// Use the Clipboard API to copy the text
navigator.clipboard.writeText(textToCopy).then(() => {
// Success callback
console.log('Text copied to clipboard');
}).catch(err => {
// Error callback
console.error('Failed to copy text: ', err);
});
});
function DeleteDoc(params) {
var doc_id = params.getAttribute('data-id');
var formData = {
doc_id: doc_id,
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."delete_doc"?>',
data: formData,
dataType: 'json',
success: function(response) { success: function(response) {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
@ -646,7 +779,6 @@
} }
</script> </script>
@ -680,6 +812,9 @@
}else if(item.status == "Rejected"){ }else if(item.status == "Rejected"){
reason_or_ip = ' - Reason('; reason_or_ip = ' - Reason(';
reason_or_ip_end = ')'; reason_or_ip_end = ')';
}else if(item.status == "Mail Success" || item.status == "Mail Failed"){
reason_or_ip = ' - Email-Id(';
reason_or_ip_end = ')';
}else{ }else{
reason_or_ip = ''; reason_or_ip = '';
reason_or_ip_end = ''; reason_or_ip_end = '';

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB