FIX_bug Fixes : ps
This commit is contained in:
parent
bf680a0d7c
commit
c46ff81926
@ -3,6 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BusinessModel;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
|
||||
class Business extends BaseController
|
||||
{
|
||||
@ -100,86 +101,99 @@ class Business extends BaseController
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_role = get_user_role();
|
||||
|
||||
## logo
|
||||
$img = $this->request->getFile('business_logo');
|
||||
$filePath = 'public/uploads/' . $this->request->getPost('business_logo');
|
||||
$fileName = $img->getName();
|
||||
if ($fileName !== "") {
|
||||
if ($img->isValid() && !$img->hasMoved()) {
|
||||
$img->move(ROOTPATH . 'public/uploads', $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
## favicon
|
||||
$favicon = $this->request->getFile('favicon');
|
||||
$faviconFileName = $favicon->getName();
|
||||
if ($faviconFileName !== "") {
|
||||
if ($favicon->isValid() && !$favicon->hasMoved()) {
|
||||
$favicon->move(ROOTPATH . 'public/uploads', $faviconFileName);
|
||||
}
|
||||
}
|
||||
|
||||
## signature
|
||||
$sign = $this->request->getFile('signature');
|
||||
$signFileName = $sign->getName();
|
||||
if ($signFileName !== "") {
|
||||
if ($sign->isValid() && !$sign->hasMoved()) {
|
||||
$sign->move(ROOTPATH . 'public/uploads', $signFileName);
|
||||
}
|
||||
}
|
||||
|
||||
## Business Data
|
||||
$panNo = $this->request->getPost('pan_no');
|
||||
$BusinessModel = new BusinessModel();
|
||||
// print_r( $this->request->getPost('currency'));
|
||||
$businessId = $this->request->getPost('business_id');
|
||||
|
||||
$data = [
|
||||
'title' => $this->request->getPost('bname'),
|
||||
'email' => $this->request->getPost('bmail'),
|
||||
'mobile_no' => $this->request->getPost('bmobile'),
|
||||
'address' => $this->request->getPost('baddress'),
|
||||
'city' => $this->request->getPost('bcity'),
|
||||
'state' => $this->request->getPost('bstate'),
|
||||
'postal_code' => $this->request->getPost('bzip'),
|
||||
'pan_no' => $this->request->getPost('pan_no'),
|
||||
'org_reg_no' => $this->request->getPost('org_reg_no'),
|
||||
'terms' => $this->request->getPost('bterms'),
|
||||
'80G' => $this->request->getPost('80G'),
|
||||
'12AA' => $this->request->getPost('12AA'),
|
||||
'80G_vaildupto' => $this->request->getPost('80G_vaildupto'),
|
||||
'12AA_vaildupto' => $this->request->getPost('12AA_vaildupto'),
|
||||
'site_name' => $this->request->getPost('site_name'),
|
||||
'site_title' => $this->request->getPost('site_title'),
|
||||
'admin_email' => $this->request->getPost('admin_email'),
|
||||
'site_mobile'=> $this->request->getPost('site_mobile'),
|
||||
'copyright'=> $this->request->getPost('copyright'),
|
||||
'currency'=> serialize($this->request->getPost('currency')),
|
||||
'country'=> $this->request->getPost('country'),
|
||||
'start_no'=> $this->request->getPost('start_no'),
|
||||
'left_pad'=> $this->request->getPost('left_pad'),
|
||||
'prefix_format'=> $this->request->getPost('prefix_format'),
|
||||
];
|
||||
if ($fileName !== "") {
|
||||
$data['business_logo'] = $fileName;
|
||||
}
|
||||
if ($faviconFileName !== "") {
|
||||
$data['favicon'] = $faviconFileName;
|
||||
}
|
||||
if ($signFileName !== "") {
|
||||
$data['signature'] = $signFileName;
|
||||
$existingBusiness = $BusinessModel->where('pan_no', $panNo)->first();
|
||||
|
||||
if ($existingBusiness && $existingBusiness['business_id'] != $businessId) {
|
||||
// If it exists and it's not the same record being updated, show an error message
|
||||
session()->setFlashdata('error', 'The PAN number already exists.');
|
||||
return redirect()->back()->withInput(); // Redirect back with input data
|
||||
}
|
||||
|
||||
try {
|
||||
## logo
|
||||
$img = $this->request->getFile('business_logo');
|
||||
$filePath = 'public/uploads/' . $this->request->getPost('business_logo');
|
||||
$fileName = $img->getName();
|
||||
if ($fileName !== "") {
|
||||
if ($img->isValid() && !$img->hasMoved()) {
|
||||
$img->move(ROOTPATH . 'public/uploads', $fileName);
|
||||
}
|
||||
}
|
||||
|
||||
## favicon
|
||||
$favicon = $this->request->getFile('favicon');
|
||||
$faviconFileName = $favicon->getName();
|
||||
if ($faviconFileName !== "") {
|
||||
if ($favicon->isValid() && !$favicon->hasMoved()) {
|
||||
$favicon->move(ROOTPATH . 'public/uploads', $faviconFileName);
|
||||
}
|
||||
}
|
||||
|
||||
## signature
|
||||
$sign = $this->request->getFile('signature');
|
||||
$signFileName = $sign->getName();
|
||||
if ($signFileName !== "") {
|
||||
if ($sign->isValid() && !$sign->hasMoved()) {
|
||||
$sign->move(ROOTPATH . 'public/uploads', $signFileName);
|
||||
}
|
||||
}
|
||||
|
||||
## Business Data
|
||||
// print_r( $this->request->getPost('currency'));
|
||||
|
||||
$data = [
|
||||
'title' => $this->request->getPost('bname'),
|
||||
'email' => $this->request->getPost('bmail'),
|
||||
'mobile_no' => $this->request->getPost('bmobile'),
|
||||
'address' => $this->request->getPost('baddress'),
|
||||
'city' => $this->request->getPost('bcity'),
|
||||
'state' => $this->request->getPost('bstate'),
|
||||
'postal_code' => $this->request->getPost('bzip'),
|
||||
'pan_no' => $this->request->getPost('pan_no'),
|
||||
'org_reg_no' => $this->request->getPost('org_reg_no'),
|
||||
'terms' => $this->request->getPost('bterms'),
|
||||
'80G' => $this->request->getPost('80G'),
|
||||
'12AA' => $this->request->getPost('12AA'),
|
||||
'80G_vaildupto' => $this->request->getPost('80G_vaildupto'),
|
||||
'12AA_vaildupto' => $this->request->getPost('12AA_vaildupto'),
|
||||
'site_name' => $this->request->getPost('site_name'),
|
||||
'site_title' => $this->request->getPost('site_title'),
|
||||
'admin_email' => $this->request->getPost('admin_email'),
|
||||
'site_mobile'=> $this->request->getPost('site_mobile'),
|
||||
'copyright'=> $this->request->getPost('copyright'),
|
||||
'currency'=> serialize($this->request->getPost('currency')),
|
||||
'country'=> $this->request->getPost('country'),
|
||||
'start_no'=> $this->request->getPost('start_no'),
|
||||
'left_pad'=> $this->request->getPost('left_pad'),
|
||||
'prefix_format'=> $this->request->getPost('prefix_format'),
|
||||
];
|
||||
if ($fileName !== "") {
|
||||
$data['business_logo'] = $fileName;
|
||||
}
|
||||
if ($faviconFileName !== "") {
|
||||
$data['favicon'] = $faviconFileName;
|
||||
}
|
||||
if ($signFileName !== "") {
|
||||
$data['signature'] = $signFileName;
|
||||
}
|
||||
|
||||
$business_id = $this->request->getPost('business_id'); // Get the business ID for update
|
||||
// print_r($data);die;
|
||||
// print_r($data);die;
|
||||
if (empty($business_id)) {
|
||||
// It's an insert operation
|
||||
$data['created_by'] = $session_uid;
|
||||
$businessId = $BusinessModel->insert($data);
|
||||
session()->setFlashdata('success', 'Organization details have been updated successfully.');
|
||||
} else {
|
||||
// It's an update operation
|
||||
$businessId = $business_id;
|
||||
$data['updated_by'] = $session_uid;
|
||||
$BusinessModel->update($business_id, $data);
|
||||
session()->setFlashdata('success', 'Organization details have been updated successfully.');
|
||||
}
|
||||
|
||||
## Donation Business Data (Note: not a super-admin means just updated only)
|
||||
@ -198,12 +212,14 @@ class Business extends BaseController
|
||||
}
|
||||
|
||||
if ($session_role === 'sadmin') {
|
||||
session()->setFlashdata('success', 'organization details has been updated successfully.');
|
||||
return redirect()->route('org_list');
|
||||
}else{
|
||||
session()->setFlashdata('success', 'organization details has been updated successfully.');
|
||||
} else {
|
||||
return redirect()->to(base_url("new_org/{$business_id}"));
|
||||
}
|
||||
} catch (DatabaseException $e) {
|
||||
session()->setFlashdata('error', $e->getMessage());
|
||||
return redirect()->back()->withInput(); // Redirect back with input data
|
||||
}
|
||||
}
|
||||
|
||||
public function save_business_branch($requestData, $bid)
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Reader\Csv as ReaderCsv;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as ReaderXlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
|
||||
class Customer extends BaseController
|
||||
{
|
||||
@ -92,7 +93,14 @@ class Customer extends BaseController
|
||||
$session_bid = get_business_id();
|
||||
|
||||
$pan = ($this->request->getPost('pan_no') == '') ? $this->request->getPost('o_pan_no') : $this->request->getPost('pan_no');
|
||||
|
||||
|
||||
$existingDonor = $model->where('pan_no', $pan)->first();
|
||||
|
||||
if ($existingDonor) {
|
||||
$results = ['status' => false, 'message' => 'The PAN number already exists.','donor_id' => ''];
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
}
|
||||
try {
|
||||
$data = [
|
||||
'first_name' => $this->request->getPost('cfname'),
|
||||
'mobile_no' => $this->request->getPost('mobile'),
|
||||
@ -114,7 +122,11 @@ class Customer extends BaseController
|
||||
|
||||
$donor_where = ['business_id' => (int)get_business_id() , 'isactive' => 1, 'donor_type'=>$this->request->getPost('DonorType')];
|
||||
$results['donor'] = $model->getData('donor', $donor_where);
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
} catch (DatabaseException $e) {
|
||||
$results = ['status' => false, 'message' => 'could not be added DB Error Occur','donor_id' => '','error'=>$e->getMessage()];
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
}
|
||||
}
|
||||
public function insert_donor()
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\BusinessModel;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
|
||||
class Users extends BaseController
|
||||
{
|
||||
@ -145,6 +146,7 @@ class Users extends BaseController
|
||||
{
|
||||
$model = new BusinessModel();
|
||||
$model->setTable('business');
|
||||
|
||||
$organzation_details = $model->orderBy('business_id', 'DESC')->findAll();
|
||||
|
||||
// Fetch branches for all organizations
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
@ -43,6 +44,15 @@
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_org"; ?>" id="myForm">
|
||||
<hr />
|
||||
<h4 class="header-title" id="org-settings-title">
|
||||
|
||||
@ -187,7 +187,35 @@
|
||||
// Call function to set required fields based on donor type
|
||||
checkValidityAndSetRequired();
|
||||
|
||||
// Get invalid fields
|
||||
var type = document.getElementById('DonorType').value;
|
||||
var aadharValue = document.getElementById('adhar_no').value.trim();
|
||||
var panValue = document.getElementById('pan_no').value.trim();
|
||||
var passportValue = document.getElementById('passport_no').value.trim();
|
||||
|
||||
if (type === 'organization') {
|
||||
if (panValue !== '' && !validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission if PAN is not valid
|
||||
return;
|
||||
}
|
||||
}else if (type === 'individual' && (panValue === '' && passportValue === '')) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
alert('Please enter either PAN Number or Passport Number.');
|
||||
return ;
|
||||
}
|
||||
else if (type === 'individual') {
|
||||
if (aadharValue !== '' && !validateAdharNumber(aadharValue)) {
|
||||
event.preventDefault(); // Prevent form submission if Aadhaar is not valid
|
||||
return;
|
||||
}else{ document.getElementById('pan_no').removeAttribute('required'); }
|
||||
if (panValue !== '' && !validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission if PAN is not valid
|
||||
return;
|
||||
}else{ document.getElementById('adhar_no').removeAttribute('required'); }
|
||||
if (passportValue !== '' && !validatePassport(passportValue)) {
|
||||
event.preventDefault(); // Prevent form submission if Passport is not valid
|
||||
return;
|
||||
}else{ document.getElementById('passport_no').removeAttribute('required'); }
|
||||
}
|
||||
var invalidFields = form.querySelectorAll('.is-invalid');
|
||||
console.log("*** Invalid Fields ***");
|
||||
invalidFields.forEach(function(field) {
|
||||
@ -200,32 +228,6 @@
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
var type = document.getElementById('DonorType').value;
|
||||
var aadharValue = document.getElementById('adhar_no').value.trim();
|
||||
var panValue = document.getElementById('pan_no').value.trim();
|
||||
var passportValue = document.getElementById('passport_no').value.trim();
|
||||
|
||||
if (type === 'organization') {
|
||||
if (panValue !== '' && !validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission if PAN is not valid
|
||||
return;
|
||||
}
|
||||
} else if (type === 'individual') {
|
||||
if (aadharValue !== '' && !validateAdharNumber(aadharValue)) {
|
||||
event.preventDefault(); // Prevent form submission if Aadhaar is not valid
|
||||
return;
|
||||
}
|
||||
if (panValue !== '' && !validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission if PAN is not valid
|
||||
return;
|
||||
}
|
||||
if (passportValue !== '' && !validatePassport(passportValue)) {
|
||||
event.preventDefault(); // Prevent form submission if Passport is not valid
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if form is not valid
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<br>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
<h3 style="text-align: right;text-decoration: underline"><strong><?= $data->title ?></strong></h3>
|
||||
<p class="sub-add" style="padding-left: 80px; text-align: right;"><?= $data->org_address ?> <?= $data->org_city ? ",".$data->org_city :""; ?> <?= $data->org_state ? ",".$data->org_state :""; ?> <?= $data->org_zip ? ",".$data->org_zip.".":""; ?><br>
|
||||
<?= $data->org_mobile ? "Mobile No: ".$data->org_mobile.", ":""; ?> <?= $data->org_email ? "Email: ".$data->org_email.", <br>":""; ?>
|
||||
<?= $data->org_pan ? "PAN No: ".$data->org_pan.", ":""; ?> <?= $data->org_reg_no ? "Register No: ".$data->org_reg_no:""; ?></p>
|
||||
<?= $data->org_pan ? "PAN No: ".$data->org_pan.", ":""; ?> <?= $data->org_reg_no ? "Registered No: ".$data->org_reg_no:""; ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height: 18px;">
|
||||
@ -97,7 +97,7 @@
|
||||
<td style="width: 49% !important; height: 18px; text-align: right;border: none;"><strong>Date:</strong> <?=date("d-m-Y", strtotime($data->receipt_date));?></td>
|
||||
</tr>
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 100%; height: 18px; text-align: justify;border: none;padding:30px;" colspan="2"><p>Received with thanks from <b><?= $data->customer_name . ($data->cust_org_name ? ' (' . $data->cust_org_name . ')' : '') ?></b><?php if($data->cust_pan_no) { echo ', PAN <b>'.$data->cust_pan_no.'</b>'; } ?>,<br> a sum of <b><?= $currency ?> <?= $currency_in_words ? $currency_in_words.' Only' :'' ?></b> (<?= $currency ?>.<?= $data->amount ?>), <br> towards <b><?= $data->cause_name ?></b>.</td>
|
||||
<td style="width: 100%; height: 18px; text-align: justify;border: none;padding:30px;" colspan="2"><p>Received with thanks from <b><?= $data->customer_name . ($data->cust_org_name ? ' (' . $data->cust_org_name . ')' : '') ?></b><?php if($data->cust_pan_no) { echo ', PAN <b>'.$data->cust_pan_no.'</b>'; } ?>, a sum of <b><?= $currency ?> <?= $currency_in_words ? $currency_in_words.' Only' :'' ?></b> (<?= $currency ?>.<?= $data->amount ?>), towards <b><?= $data->cause_name ?></b>.</td>
|
||||
</tr>
|
||||
<tr style="height: 18px;">
|
||||
<td style="width: 30.5118%; height: 18px;border: none;"><strong>Collected by:</strong> <?= $staff_name ?></td>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
@ -10,7 +11,16 @@
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; // print_r($details); ?>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<form class="parsley-examples" action="<?= base_url() . "insert_users"; ?>" method="post" enctype="multipart/form-data" id="myForm">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
@ -46,11 +56,19 @@
|
||||
<div class="form-group col-md-6">
|
||||
<label for="business_id" class="col-form-label">Organization <span class="text-danger">*</span></label>
|
||||
<select id="business_id" name="business_id" class="form-control" required>
|
||||
<?php foreach ($organzation_details as $business) { ?>
|
||||
<!-- <?php foreach ($organzation_details as $business) { ?>
|
||||
<option value="<?= $business['business_id']; ?>" <?= isset($details['business_id']) && ($details['business_id'] == $business['business_id']) ? 'selected' : '' ?>>
|
||||
<?= $business['title']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?> -->
|
||||
<option value="">--Select--</option>
|
||||
<?php foreach ($organzation_details as $business): ?>
|
||||
<option value="<?= $business['business_id']; ?>"
|
||||
<?= isset($details['business_id']) && ($details['business_id'] == $business['business_id']) ? 'selected' : '' ?>
|
||||
<?= $business['isactive'] != 1 ? 'disabled' : '' ?>>
|
||||
<?= $business['title'].($business['isactive'] != 1 ? ' (disabled)' : ''); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user