CHANGE_Bug Fix : ps
This commit is contained in:
parent
e9d1abc26f
commit
ec8574993b
@ -610,14 +610,13 @@ class Customer extends BaseController
|
||||
|
||||
public function import_donor()
|
||||
{
|
||||
|
||||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||||
helper('session');
|
||||
$session_uid = get_logged_user_id();
|
||||
$session_bid = get_business_id();
|
||||
|
||||
$json = []; // Arr - Json For Message FrontEnd
|
||||
$response = []; // Arr - response For Message FrontEnd
|
||||
$list = []; // Arr - Store on DB
|
||||
$path = ROOTPATH . 'public/import/donor/';
|
||||
$fileNewName = "";
|
||||
@ -627,7 +626,6 @@ class Customer extends BaseController
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0777, true);
|
||||
}
|
||||
|
||||
$fileName = $file->getName();
|
||||
if ($fileName !== "") {
|
||||
if ($file->isValid() && !$file->hasMoved()) {
|
||||
@ -636,10 +634,9 @@ class Customer extends BaseController
|
||||
$fileNewName = $newName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileNewName) {
|
||||
$json = ['error_message' => "Failed to upload file"];
|
||||
return $this->response->setJSON($json);
|
||||
$response = ['error_message' => "Failed to upload file"];
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
$arr_file = explode('.', $fileName);
|
||||
@ -649,59 +646,100 @@ class Customer extends BaseController
|
||||
} else if ('xlsx' == $extension) {
|
||||
$reader = new ReaderXlsx();
|
||||
} else {
|
||||
$json = ['error_message' => "Unsupported file type"];
|
||||
return $this->response->setJSON($json);
|
||||
$response = ['error_message' => "Unsupported file type"];
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
if (!$reader) {
|
||||
$json = ['error_message' => "Failed to initialize reader"];
|
||||
return $this->response->setJSON($json);
|
||||
$response = ['error_message' => "Failed to initialize reader"];
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
$spreadsheet = $reader->load($path.$fileNewName);
|
||||
$sheet_data = $spreadsheet->getActiveSheet()->toArray();
|
||||
|
||||
if(!empty($sheet_data)){
|
||||
foreach ($sheet_data as $key => $val) {
|
||||
if ($key != 0) { // key zero - header
|
||||
$list[] = [
|
||||
'business_id' => $session_bid,
|
||||
'first_name' => $val[0],
|
||||
'donor_type' => $val[1],
|
||||
'org_name' => $val[2] ? $val[2] : null ,
|
||||
'org_reg_details' => $val[3] ? $val[3] : null,
|
||||
'mobile_no' => $val[4] ? $val[4] : null,
|
||||
'email' => $val[5],
|
||||
'pan_no' => $val[6],
|
||||
'adhar_no' => $val[7],
|
||||
'passport_no' => $val[8] ? $val[8] : null ,
|
||||
'address' => $val[9],
|
||||
'country' => $val[10],
|
||||
'state' => $val[11],
|
||||
'city' => $val[12],
|
||||
'postal_code' => $val[13],
|
||||
'created_by' => $session_uid,
|
||||
'XL_file_name' => $fileNewName,
|
||||
'ip_address' => $ip_address
|
||||
];
|
||||
$sheet_data = $spreadsheet->getActiveSheet()->toArray();
|
||||
if (!empty($sheet_data)) {
|
||||
$flag = 0;
|
||||
$final_notes = [];
|
||||
$list = [];
|
||||
foreach ($sheet_data as $key => $val) {
|
||||
|
||||
if ($key != 0 && trim($val[0]) && trim($val[1])) { // key zero - header
|
||||
$flag = 0;
|
||||
$notes = [];
|
||||
if ($val[4]) {
|
||||
$validate = $this->check_existing($val[4], 'donor', 'mobile_no');
|
||||
if ($validate) { $notes[] = $validate; $flag++;}
|
||||
}
|
||||
if ($val[5]) {
|
||||
$validate = $this->check_existing($val[5], 'donor', 'email');
|
||||
if ($validate) { $notes[] = $validate; $flag++;}
|
||||
}
|
||||
if ($val[6]) {
|
||||
$validate = $this->check_existing($val[6], 'donor', 'pan_no');
|
||||
if ($validate) { $notes[] = $validate; $flag++;}
|
||||
}
|
||||
if ($val[7]) {
|
||||
$validate = $this->check_existing($val[7], 'donor', 'adhar_no');
|
||||
if ($validate) { $notes[] = $validate; $flag++;}
|
||||
}
|
||||
if ($val[8]) {
|
||||
$validate = $this->check_existing($val[8], 'donor', 'passport_no');
|
||||
if ($validate) { $notes[] = $validate; $flag++;}
|
||||
}
|
||||
if ($flag > 0) {
|
||||
$final_notes[] = $val[0] . ' has duplicate entries: ' . implode(',', $notes);
|
||||
} else {
|
||||
$list[] = [
|
||||
'business_id' => $session_bid,
|
||||
'first_name' => $val[0],
|
||||
'donor_type' => ucfirst(strtolower($val[1])),
|
||||
'org_name' => $val[2] ? $val[2] : null,
|
||||
'org_reg_details' => $val[3] ? $val[3] : null,
|
||||
'mobile_no' => $val[4] ? $val[4] : null,
|
||||
'email' => $val[5],
|
||||
'pan_no' => $val[6],
|
||||
'adhar_no' => $val[7] ? $val[7] : null,
|
||||
'passport_no' => $val[8] ? $val[8] : null,
|
||||
'address' => $val[9] ? $val[9] : null,
|
||||
'country' => $val[10] ? $val[10] : null,
|
||||
'state' => $val[11] ? $val[11] : null,
|
||||
'city' => $val[12] ? $val[12] : null,
|
||||
'postal_code' => $val[13] ? $val[13] : null,
|
||||
'created_by' => $session_uid,
|
||||
'XL_file_name' => $fileNewName,
|
||||
'ip_address' => $ip_address
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count($list) > 0) {
|
||||
$CustomerModel = new CustomerModel();
|
||||
$result = $CustomerModel->bulkInsert($list);
|
||||
$response = $result ? [
|
||||
'success_message' => count($list) . " Contributors imported successfully. " . implode("\n", $final_notes)
|
||||
] : ['error_message' => "Something went wrong. Please try again."];
|
||||
} else {
|
||||
$response = ['error_message' => "No new record is found." . implode("\n", $final_notes)];
|
||||
}
|
||||
} else {
|
||||
$response = ['error_message' => "There is no record to import"];
|
||||
}
|
||||
}else{
|
||||
$json = ['error_message' => "There is no record to import"];
|
||||
return $this->response->setJSON($json);
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
if (count($list) > 0) {
|
||||
$CustomerModel = new CustomerModel();
|
||||
|
||||
$result = $CustomerModel->bulkInsert($list);
|
||||
($result) ? ['success_message' => "All Entries are imported successfully."]
|
||||
: ['error_message' => "Something went wrong. Please try again."];
|
||||
} else {
|
||||
$json = ['error_message' => "No new record is found."];
|
||||
|
||||
public function check_existing($value, $table, $field) {
|
||||
$model = new CustomerModel();
|
||||
$model->setTable($table);
|
||||
$where = [$field => $value];
|
||||
$check_existing = $model->where($where)->findAll();
|
||||
|
||||
$statement_string = ucfirst(str_replace('_', ' ', $field));
|
||||
$notes = '';
|
||||
if (!empty($check_existing)) {
|
||||
$notes = $statement_string . " already exists";
|
||||
}
|
||||
return $notes;
|
||||
}
|
||||
return $this->response->setJSON($json);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Csv as ReaderCsv;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as ReaderXlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
|
||||
class Invoice extends BaseController
|
||||
{
|
||||
@ -148,6 +151,7 @@ class Invoice extends BaseController
|
||||
|
||||
$data['causes'] = $bmodel->select('*')->where('business_id', (int)get_business_id())->where('isactive',1)->get()->getResult();
|
||||
$data['campaign'] = $model->getData('campaign', $where);
|
||||
|
||||
$data['invoice_number_formatting'] = $model->getData('business', $where);
|
||||
$data['receipt_type'] = "individual";
|
||||
if ($id === '0') {
|
||||
@ -798,13 +802,18 @@ class Invoice extends BaseController
|
||||
$sheet->getStyle($cell)->getFont()->setSize($cell == 'B3' ? 14 : 12);
|
||||
$sheet->getStyle($cell)->getFont()->setBold(true);
|
||||
}
|
||||
|
||||
|
||||
if($export){
|
||||
$row = 6; // Start from row 6
|
||||
foreach ($export as $d) {
|
||||
$col = 'A'; // Start from column A
|
||||
foreach ($d as $value) {
|
||||
if (is_numeric($value)) {
|
||||
$sheet->setCellValueExplicit($col . $row, $value, DataType::TYPE_STRING);
|
||||
$sheet->getStyle($col . $row)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_NUMBER);
|
||||
} else {
|
||||
$sheet->setCellValue($col . $row, $value);
|
||||
}
|
||||
$sheet->setCellValue($col . $row, $value);
|
||||
$col++;
|
||||
}
|
||||
|
||||
@ -195,9 +195,10 @@ class Notifications extends BaseController
|
||||
|
||||
public function template_creation()
|
||||
{
|
||||
$session_bid = get_business_id();
|
||||
$data['page_name'] = 'Template Details';
|
||||
$model = new NotificationModel();
|
||||
$data['template'] = $model->getTemplateDetails();
|
||||
$data['template'] = $model->getTemplateDetails($session_bid);
|
||||
$this->render_page('template_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
@ -330,10 +331,10 @@ class Notifications extends BaseController
|
||||
//Campaign Creation
|
||||
|
||||
public function campaign_creation()
|
||||
{
|
||||
{ $session_bid = get_business_id();
|
||||
$data['page_name'] = 'Campaign Details';
|
||||
$model = new NotificationModel();
|
||||
$data['campaign'] = $model->getCampaignDetails();
|
||||
$data['campaign'] = $model->getCampaignDetails($session_bid);
|
||||
$this->render_page('campaign_creation', $data);
|
||||
// echo "templates";die;
|
||||
}
|
||||
|
||||
@ -41,12 +41,13 @@ class NotificationModel extends Model
|
||||
->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getTemplateDetails(){
|
||||
public function getTemplateDetails($session_bid){
|
||||
return $this->db->table('templates as T' )
|
||||
->join('users as U1', 'U1.user_id = T.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = T.updated_by', 'left')
|
||||
->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,T.isactive')
|
||||
->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP'))
|
||||
->where('U1.business_id =',$session_bid)
|
||||
->get()->getResultArray();
|
||||
}
|
||||
|
||||
@ -82,13 +83,14 @@ class NotificationModel extends Model
|
||||
return $statement;
|
||||
}
|
||||
|
||||
public function getCampaignDetails(){
|
||||
public function getCampaignDetails($session_bid){
|
||||
$result = $this->db->table('notification_campaign as NC' )
|
||||
->join('users as U1', 'U1.user_id = NC.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = NC.updated_by', 'left')
|
||||
->join('templates as T', 'T.template_id = NC.template_id', 'left')
|
||||
->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,if(NC.scheduled_time IS NULL ,"",NC.scheduled_time) as scheduled_time')
|
||||
->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP'))
|
||||
->where('U1.business_id =',$session_bid)
|
||||
->get()->getResultArray();
|
||||
|
||||
if (!empty($result)) {
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
<th>Action</th>
|
||||
<th>Module</th>
|
||||
<th>Key</th>
|
||||
<th>Old Value</th>
|
||||
<th>New Value</th>
|
||||
<th>Old Value</th>
|
||||
<th>Updated By</th>
|
||||
<th>Updated On</th>
|
||||
</tr>
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($loged_user === 'sadmin'){ ?>
|
||||
<?php if($loged_user === 'sadmin' || $loged_user === 'admin'){ ?>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="80G" class="col-form-label">80G</label>
|
||||
@ -160,11 +160,12 @@
|
||||
<div class="form-group col-md-6">
|
||||
<label for="site_name" class="col-form-label">Site Name</label>
|
||||
<input type="text" class="form-control" id="site_name" name="site_name" value="<?= isset($organzations['site_name']) ? $organzations['site_name'] : '' ?>" placeholder="Site Name" />
|
||||
<?php if ($loged_user === 'sadmin') : ?> <span class="help-block"><small>Auto-Text Copied from Buiness title field (First time only)</small></span> <?php endif; ?>
|
||||
<?php if ($loged_user === 'sadmin') : ?> <span class="help-block"><small>Auto-text copied from Organization Name field (First time only. If you want to change it means please edit.)</small></span> <?php endif; ?>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="site_title" class="col-form-label">Site Title</label>
|
||||
<input type="text" class="form-control" id="site_title" name="site_title" placeholder="Site Title" value="<?= isset($organzations['site_title']) ? $organzations['site_title'] : '' ?>" />
|
||||
<?php if ($loged_user === 'sadmin') : ?> <span class="help-block"><small>Auto-text copied from Organization Name field (First time only. If you want to change it means please edit.)</small></span> <?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@ -241,24 +242,24 @@
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branchname" class="col-form-label">Branch Name<span class="text-danger"> </span></label>
|
||||
<label for="branchname" class="col-form-label">Branch Name<span class="text-danger">* </span></label>
|
||||
<input type="text" class="form-control" id="branchname" name="branch_name[]" placeholder="Branch Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branchaddress" class="col-form-label">Branch Address<span class="text-danger"></span></label>
|
||||
<label for="branchaddress" class="col-form-label">Branch Address<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branchaddress" name="branchaddress[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="mobile_no" class="col-form-label">Contact Person Mobile <span class="text-danger"></span></label>
|
||||
<label for="mobile_no" class="col-form-label">Contact Person Mobile <span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="mobile_no" name="mobile_no[]" placeholder="Contact Person Mobile " required data-parsley-type="number" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="email" class="col-form-label">Email<span class="text-danger"></span></label>
|
||||
<label for="email" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="email" name="email[]" placeholder="Email" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
@ -556,20 +557,32 @@
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
var Role = <?php echo json_encode($loged_user); ?>;
|
||||
$('#bname').on('input', function() {
|
||||
if($('#site_name').val() != "" && $('#site_title').val() != "" && Role === 'sadmin'){
|
||||
$('#bname').change(function(){
|
||||
// alert($(this).val());
|
||||
if($('#site_name').val() === "" && $('#site_title').val() === "" && Role === 'sadmin'){
|
||||
var bname = $(this).val();
|
||||
$('#site_name').val(bname);
|
||||
$('#site_title').val(bname);
|
||||
if (bname === '' ) {
|
||||
$('#site_name').val('');
|
||||
$('#site_title').val('');
|
||||
}
|
||||
$('#site_name').val(bname);
|
||||
$('#site_title').val(bname);
|
||||
if (bname === '' ) {
|
||||
$('#site_name').val('');
|
||||
$('#site_title').val('');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Role === 'sadmin') {
|
||||
$('#branchaddress').removeAttr('required');
|
||||
$('#branchaddress').siblings('span.text-danger').remove();
|
||||
$('#branchname').removeAttr('required');
|
||||
$('#branchname').siblings('span.text-danger').remove();
|
||||
$('#mobile_no').removeAttr('required');
|
||||
$('#mobile_no').siblings('span.text-danger').remove();
|
||||
$('#email').removeAttr('required');
|
||||
$('#email').siblings('span.text-danger').remove();
|
||||
}
|
||||
});
|
||||
$(document).ready(function() {
|
||||
var Role = <?php echo json_encode($loged_user); ?>;
|
||||
var busiBranchArray = <?php echo json_encode($branches); ?>;
|
||||
|
||||
if (busiBranchArray.length > 0) {
|
||||
|
||||
@ -93,8 +93,7 @@
|
||||
<div class="form-group col-md-4" id="passport_no_individual">
|
||||
<label for="csname" class="col-form-label"><span class="contactPerson"> </span>Passport Number <i class="text-danger contactPerson"> *</i> </label>
|
||||
<input type="text" class="form-control" id="passport_no"name="passport_no" value="<?= isset($customer['passport_no']) ? $customer['passport_no'] : '' ?>" placeholder="Passport Number" onchange="checkExisting(this,'passport_no','passport_no')"/>
|
||||
<span id="passportValidationMessage"></span>
|
||||
<span id="errorMessage2" style="color: red;"></span>
|
||||
<span id="passportValidationMessage" style="color: red;"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -172,104 +171,100 @@
|
||||
|
||||
<script>
|
||||
function checkValidityAndSetRequired() {
|
||||
var type = document.getElementById('DonorType').value;
|
||||
var panInput = document.getElementById('pan_no');
|
||||
var passportInput = document.getElementById('passport_no');
|
||||
var errorMessage = document.getElementById('errorMessage');
|
||||
var errorMessage = document.getElementById('passportValidationMessage');
|
||||
if (type === 'organization') {
|
||||
panInput.setAttribute('required', 'required');
|
||||
passportInput.removeAttribute('required');
|
||||
errorMessage.textContent = ""; // Clear any existing error message
|
||||
var type = document.getElementById('DonorType').value;
|
||||
var panInput = document.getElementById('pan_no');
|
||||
var passportInput = document.getElementById('passport_no');
|
||||
var errorMessage = document.getElementById('errorMessage');
|
||||
var passportValidationMessage = document.getElementById('passportValidationMessage');
|
||||
|
||||
// Clear previous error messages
|
||||
errorMessage.textContent = "";
|
||||
passportValidationMessage.textContent = "";
|
||||
} else if (type === 'individual') {
|
||||
if (panInput.value === "" && passportInput.value === "") {
|
||||
// If both PAN and Passport are empty, require either one
|
||||
|
||||
if (type === 'organization') {
|
||||
panInput.setAttribute('required', 'required');
|
||||
passportInput.setAttribute('required', 'required');
|
||||
errorMessage.textContent = "Either PAN or Passport is required.";
|
||||
passportValidationMessage.textContent = "Either PAN or Passport is required.";
|
||||
passportInput.removeAttribute('required');
|
||||
} else if (type === 'individual') {
|
||||
if (panInput.value === "" && passportInput.value === "") {
|
||||
panInput.setAttribute('required', 'required');
|
||||
passportInput.setAttribute('required', 'required');
|
||||
errorMessage.textContent = "Either PAN or Passport is required.";
|
||||
passportValidationMessage.textContent = "Either PAN or Passport is required.";
|
||||
} else {
|
||||
panInput.removeAttribute('required');
|
||||
passportInput.removeAttribute('required');
|
||||
}
|
||||
} else {
|
||||
// If either PAN or Passport is filled, reset requirements
|
||||
panInput.removeAttribute('required');
|
||||
passportInput.removeAttribute('required');
|
||||
errorMessage.textContent = ""; // Clear error message
|
||||
passportValidationMessage.textContent = "";
|
||||
}
|
||||
} else {
|
||||
// For other type, set PAN or Passport as required based on the default logic
|
||||
panInput.removeAttribute('required');
|
||||
passportInput.removeAttribute('required');
|
||||
errorMessage.textContent = ""; // Clear any existing error message
|
||||
passportValidationMessage.textContent = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||
var form = event.target;
|
||||
|
||||
// Call function to set required fields based on donor type
|
||||
checkValidityAndSetRequired();
|
||||
|
||||
// Get invalid fields
|
||||
var invalidFields = form.querySelectorAll('.is-invalid');
|
||||
console.log("*** Invalid Fields ***");
|
||||
invalidFields.forEach(function(field) {
|
||||
console.log(field);
|
||||
});
|
||||
if (invalidFields.length > 0) {
|
||||
invalidFields[0].focus();
|
||||
console.log("**"+invalidFields[0]);
|
||||
}
|
||||
|
||||
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 !== '') {
|
||||
if (!validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission if it's not valid
|
||||
$('#submitBtn').prop('disabled', false);
|
||||
|
||||
}
|
||||
invalidFields.forEach(function(field) {
|
||||
console.log(field);
|
||||
});
|
||||
|
||||
if (invalidFields.length > 0) {
|
||||
invalidFields[0].focus();
|
||||
console.log("**" + invalidFields[0]);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
if (type === 'individual') {
|
||||
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 (aadharValue !== '') {
|
||||
if (!validateAdharNumber(aadharValue)) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (panValue === '' && passportValue === '') {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
return;
|
||||
}else{
|
||||
if (panValue !== '') {
|
||||
if (!validatePANNumber(panValue)) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
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 === '' && passportValue === '') {
|
||||
event.preventDefault(); // Prevent form submission if both PAN and Passport are empty
|
||||
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 (passportValue !== '') {
|
||||
if (!validatePassport(passportValue)) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form.checkValidity()) {
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if form is not valid
|
||||
}
|
||||
}
|
||||
}
|
||||
if (form.checkValidity() === true) {
|
||||
});
|
||||
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if it's not valid
|
||||
$('#submitBtn').prop('disabled', false);
|
||||
} else {
|
||||
// if (form.checkValidity() === true) {
|
||||
|
||||
$('#submitBtn').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
// form.reportValidity(); // Display validation error messages
|
||||
// event.preventDefault(); // Prevent form submission if it's not valid
|
||||
// $('#submitBtn').prop('disabled', false);
|
||||
// } else {
|
||||
|
||||
// $('#submitBtn').prop('disabled', true);
|
||||
// }
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function onlyNumbers(event){
|
||||
@ -452,12 +447,13 @@ invalidFields.forEach(function(field) {
|
||||
case 'passport_no':
|
||||
spanid = "passportValidationMessage"; break;
|
||||
}
|
||||
var validationMessage = document.getElementById(spanid);
|
||||
var validationMessage = document.getElementById(spanid);
|
||||
resetValidationMessage(spanid);
|
||||
var value = input.value.trim();
|
||||
if (value === "") {
|
||||
validationMessage.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?= base_url() . 'check_existing' ?>",
|
||||
@ -479,5 +475,11 @@ invalidFields.forEach(function(field) {
|
||||
console.error("check existing " + elementid + " -- " + status + ": " + error);
|
||||
}
|
||||
});
|
||||
}}
|
||||
function resetValidationMessage(spanid) {
|
||||
var validationMessage = document.getElementById(spanid);
|
||||
validationMessage.style.display = 'none';
|
||||
validationMessage.innerText = '';
|
||||
validationMessage.style.color = '';
|
||||
}
|
||||
</script>
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user