CHANGE_DOC_LIST : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-15 11:59:42 +05:30
parent 876646938f
commit 0b1ca98138
7 changed files with 157 additions and 163 deletions

View File

@ -46,6 +46,7 @@ use CodeIgniter\Router\RouteCollection;
$routes->get('get_client_branch/(:any)','ClientController::get_client_branch/$1');
$routes->post('status_client_branch','ClientController::status_client_branch');
$routes->post('client_upload','ClientController::client_upload');
$routes->get('check_gst','ClientController::check_gst');

View File

@ -473,6 +473,17 @@ class ClientController extends BaseController
echo "No file uploaded.";
}
}
public function check_gst(){
$gst_no = $this->request->getVar('gst_no');
$branch =$this->ClientBranchModel->where('gst_no',$gst_no)->first();
if($branch){
return json_encode(true);
}else{
return ;
}
}
}

View File

@ -170,6 +170,7 @@ class MasterController extends BaseController
echo view('layout/footer');
}
public function service_create()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
@ -319,49 +320,21 @@ class MasterController extends BaseController
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id ' , 'left')
// ->where('client.business_id', $business_id)
->where('client_docs.business_id', $business_id)
->where('client_docs.created_at >=', $financialYearStart)
->where('client_docs.created_at <=', $financialYearEnd)
// ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')")
->orderBy('client_docs.id', 'DESC')
->get()
->getResultArray();
$business_id_check = 0;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
$docStatusByClientId = [];
// $data['clientdata'] = $this->ClientModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id')
// ->join('client_branch', 'client.client_id = client_branch.client_id', 'left')
// ->findAll();
$data['clientdata'] = $this->ClientBranchModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
// foreach ($data['serviceGroupData'] as $key => $value) {
// $check_its_okay = 0;
// foreach (json_decode($value['business_id']) as $values) {
// if($values == $business_id){
// $check_its_okay =1;
// }
// }
// if($check_its_okay == 0){
// unset($data['serviceGroupData'][$key]);
// }
// $check_its_okay = 0;
// }
}else{
$business_id = $this->session->get('logged_in_staff_business_id');
@ -375,47 +348,20 @@ class MasterController extends BaseController
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id ' , 'left')
// ->where('client.business_id', $business_id)
->where('client_docs.business_id', $business_id)
->where('client_docs.created_at >=', $financialYearStart)
->where('client_docs.created_at <=', $financialYearEnd)
// ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')")
->orderBy('client_docs.id', 'DESC')
->get()
->getResultArray();
$business_id_check = 0;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
->getResultArray();
$docStatusByClientId = [];
// Fetch all doc_status entries and group them by client_docs_id
$data['clientdata'] = $this->ClientBranchModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
// foreach ($data['serviceGroupData'] as $key => $value) {
// $check_its_okay = 0;
// foreach (json_decode($value['business_id']) as $values) {
// if($values == $business_id){
// $check_its_okay =1;
// }
// }
// if($check_its_okay == 0){
// unset($data['serviceGroupData'][$key]);
// }
// $check_its_okay = 0;
// }
}
foreach ($data['doc_list'] as $doc) {
@ -442,24 +388,11 @@ class MasterController extends BaseController
}else{
$data['business_list'] = $this->BusinessModel->findAll();
}
// echo "<pre>";
// print_r($data);die;
echo view('layout/header', ['Data'=>$staffdata]);
echo view('share_docs',$data);
echo view('layout/footer');
}
public function set_include_archived_session($checked_or_not) {
if($checked_or_not == true){
// $includeArchived = $this->request->getGet('include_archived');
$this->session->set('include_archived', $checked_or_not);
}else{
$this->session->set('include_archived', $checked_or_not);
}
// print_r($this->session->get('include_archived'));die;
return $this->response->setJSON(['status' => 'success']);
}
public function shared_doc_non_financial_year_to(){
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$currentDate = new \DateTime();
@ -477,6 +410,8 @@ class MasterController extends BaseController
$financialYearStart = $financialYearStart->format('Y-m-d');
$financialYearEnd = $financialYearEnd->format('Y-m-d');
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
$business_id = $this->session->get('logged_in_staff_business_id');
if($this->session->get('logged_in_staff_role') == 'Admin'){
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.* , services.service_name ,
service_group.group_name , client_branch.name as client_branch_name ,
@ -486,9 +421,10 @@ class MasterController extends BaseController
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id', 'left')
->where('client_docs.business_id', $business_id)
->orderBy('client_docs.id','DESC')
->findAll();
$data['clientdata'] = $this->ClientBranchModel->select('client.name as client_name , client_branch.name as client_branch_name , client_branch.id as client_branch_id')
$data['clientdata'] = $this->ClientBranchModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
@ -524,17 +460,24 @@ class MasterController extends BaseController
$doc['doc_status'] = isset($docStatusByClientId[$doc['id']]) ? $docStatusByClientId[$doc['id']] : [];
}
$data['business_list'] = $this->BusinessModel->findAll();
// foreach (json_decode($staffdata->business_id) as $key => $value) {
// $business = $this->BusinessModel->where('business_id', $value)->first();
// if ($business) {
// $data['business_list'][] = $business;
// }
// }
echo view('layout/header', ['Data'=>$staffdata]);
echo view('share_docs',$data);
echo view('layout/footer');
}
public function set_include_archived_session($checked_or_not) {
if($checked_or_not == true){
// $includeArchived = $this->request->getGet('include_archived');
$this->session->set('include_archived', $checked_or_not);
}else{
$this->session->set('include_archived', $checked_or_not);
}
// print_r($this->session->get('include_archived'));die;
return $this->response->setJSON(['status' => 'success']);
}
public function shared_document_edit()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
@ -573,10 +516,10 @@ class MasterController extends BaseController
public function create_docs()
{
$docData = $this->request->getVar();
$docData['created_by'] = $this->session->has('is_staff_logged_in');
$docData['business_id'] = $this->session->has('logged_in_staff_business_id');
$docData['created_by'] = $this->session->get('is_staff_logged_in');
$docData['business_id'] = $this->session->get('logged_in_staff_business_id');
$docData['body_html'] = $this->TemplateModel->where('template_id',$this->request->getVar('template_id'))->get()->getRow()->body_html;
print_r($docData);die;
// print_r($docData);die;
$insert = $this->ClientDocsModel->insert($docData);
if($insert){
@ -729,7 +672,8 @@ class MasterController extends BaseController
public function change_doc_status()
{
try {
// try {
$doc_id = $this->request->getPost('doc_id');
$is_active = $this->request->getPost('is_active');
$data['is_active'] = $is_active;
@ -776,10 +720,10 @@ class MasterController extends BaseController
];
$MailHelper->send_url_email($clientData->email , '', $subject, $message, $mail_config);
$notificationHelper = new NotificationHelper();
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
$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);
// $notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
}
$statusData['client_docs_id'] = $doc_id;
@ -802,9 +746,9 @@ class MasterController extends BaseController
$result = "No Match's";
return $this->response->setJSON(['status' => 'failed','code' => 404,'data' => $result],404);
}
} catch (\Exception $exception) {
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
}
// } catch (\Exception $exception) {
// return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
// }
}
public function rememeber_notification()
@ -826,6 +770,7 @@ class MasterController extends BaseController
->join('client', 'client_branch.client_id = client.client_id', 'left')
->where('client_docs.id', $doc_id)->get()->getRow();
}
// print_r($clientData);die;
// 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 ')

View File

@ -7,8 +7,6 @@ class MailHelper
public static function send_otp_email($email_id, $otp)
{
$subject = 'BB-Sign Verify Document';
$message = "Hai,
<br>
@ -82,18 +80,10 @@ class MailHelper
]);
$email->setFrom($config['sender_email'], $config['sender_name']);
// $email->setMailType('html');
// $email->setFrom('bbone@venbait.in', 'BB-Sign');
$email->setTo($email_id);
$email->setSubject($subject);
$email->setMessage($message);
// $email->setMailType('html');
// $email->setFrom('bbone@venbait.in', 'BB-Sign');
// $email->setTo($email_id);
// $email->setSubject($subject);
// $email->setMessage($message);
// print_r($email);die;
if ($email->send()) {
return ['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $email_id];
} else {

View File

@ -55,6 +55,8 @@ class NotificationHelper
'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);

View File

@ -254,7 +254,7 @@
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" id="client_submit_button" onclick="submitBranch(this)">Submit</button>
<button class="btn btn-info waves-effect waves-light" type="submit" id="client_submit_button" onclick="submitClient(this, event)">Submit</button>
</div>
</form>
@ -269,7 +269,6 @@
<!-- End Page content -->
<!-- ============================================================== -->
<script>
$('#individual_client').click(function () {
@ -378,7 +377,20 @@
function submitBranch(params) {
function submitClient(params, event) {
event.preventDefault();
<?php
$session = \Config\Services::session(); ?>
var business_session = <?php echo $session->get('logged_in_staff_business_id') ?>;
if (business_session && business_session !== "") {
} else {
// toastr.waring('Select Business First');
return;
}
var formData = {
@ -399,12 +411,40 @@
formData.individual = 1;
// formData.whatsapp = $('#individual_client').prop('checked');
}else{
formData.individual = 0;
formData.gst_no = $('#gst_no').val();
formData.branch_email = $('#branch_email').val();
formData.contact = $('#contact').val();
formData.state_code = $('#state_code').val();
formData.branch_name = $('#branch_name').val();
formData.branch_mobile_no = $('#branch_mobile_no').val();
var formDatagst = {
gst_no: $('#gst_no').val(),
};
var queryString = $.param(formDatagst);
$.ajax({
type: 'GET',
url: '<?= base_url("check_gst"); ?>'+ '?' + queryString ,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
if(response == true){
$('#gst_no').val('');
$('#gst_no').focus();
// toastr.waring('GST Number Already Exists');
$('#client_submit_button').attr('disabled','false');
return ;
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
formData.sms = $('#sms').prop('checked');
formData.whatsapp = $('#whatsapp').prop('checked');
@ -436,7 +476,10 @@
success: function(response) {
console.log(response);
if(response == true){
$('#client_submit_button').attr('disabled','false');
$('#bike_model_login-modal').modal('hide');
window.location.reload();
}else{
$('#client_submit_button').attr('disabled','false');
@ -449,6 +492,8 @@
console.error(xhr.responseText);
}
});
$('#client_submit_button').attr('disabled','false');
}

View File

@ -182,75 +182,75 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="share-docs" enctype="multipart/form-data">
<div class="modal-body p-4">
<div class="row">
<div class="modal-body p-4">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="field-2" class="control-label">Select Client</label>
<select class="select2-dropdown form-control" name="client_branch_id" id="client_branch_id" required>
<option value="">Select Client</option>
<?php foreach ($clientdata as $key => $Value) { ?>
<option value="<?php echo $Value['client_branch_id']; ?>" ><?php echo $Value['name']; if(!empty($Value['client_branch_name'])){ ?> - <?php echo $Value['client_branch_name']; } ?></option>
<?php } ?>
</select>
<div class="col-md-12">
<div class="form-group">
<label for="field-2" class="control-label">Select Client</label>
<select class="select2-dropdown form-control" name="client_branch_id" id="client_branch_id" required>
<option value="">Select Client</option>
<?php foreach ($clientdata as $key => $Value) { ?>
<option value="<?php echo $Value['client_branch_id']; ?>" ><?php echo $Value['name']; if(!empty($Value['client_branch_name'])){ ?> - <?php echo $Value['client_branch_name']; } ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-2" class="control-label">Service Group</label>
<select class="select2-dropdown form-control" name="service_group_id" id="service_group_id" required>
<div class="col-md-6">
<div class="form-group">
<label for="field-2" class="control-label">Service Group</label>
<select class="select2-dropdown form-control" name="service_group_id" id="service_group_id" required>
<option value="">Select Service</option>
<?php foreach ($serviceGroupData as $key => $Value) { ?>
<option value="<?php echo $Value['service_group_id']; ?>" ><?php echo $Value['group_name']; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Service</label>
<select class="select2-dropdown form-control" name="service_id" id="service_id" required>
<option value="">Select Service</option>
<?php foreach ($serviceGroupData as $key => $Value) { ?>
<option value="<?php echo $Value['service_group_id']; ?>" ><?php echo $Value['group_name']; ?></option>
<?php } ?>
</select>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Service</label>
<select class="select2-dropdown form-control" name="service_id" id="service_id" required>
<option value="">Select Service</option>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Template</label>
<select class="select2-dropdown form-control" name="template_id" id="template_id" required>
<option value="">Select Template</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Document Name</label>
<input type="text" class=" form-control" name="document_name" id="document_name" required>
</select>
</div>
</div>
<input type="hidden" name="is_active" value="0">
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Template</label>
<select class="select2-dropdown form-control" name="template_id" id="template_id" required>
<option value="">Select Template</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="field-1" class="control-label">Document Name</label>
<input type="text" class=" form-control" name="document_name" id="document_name" required>
</div>
</div>
<input type="hidden" name="is_active" value="0">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" style="background-color:grey ; color:white;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Create</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" style="background-color:grey ; color:white;" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info waves-effect waves-light">Create</button>
</div>
</form>
</div>
</div>
@ -552,7 +552,7 @@
// Create a FormData object
var formData = new FormData(this);
console.log(formData);
// console.log(formData);
// Make an AJAX POST request
$.ajax({
url: '<?= base_url()."create_docs"; ?>',