Bug fixes : ps
This commit is contained in:
parent
81d22eef40
commit
9348f0ee3f
@ -99,7 +99,7 @@ class Invoice extends BaseController
|
||||
public function load_details1()
|
||||
{
|
||||
$id = $this->request->getPost('selectedValue');
|
||||
$where = ['isactive' => 1, 'customer_id' => (int)$id];
|
||||
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$id];
|
||||
$where['address_type'] = 1;
|
||||
$data['customer_billing'] = $this->get_customer_address($where, []);
|
||||
$select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"];
|
||||
@ -114,7 +114,7 @@ class Invoice extends BaseController
|
||||
{
|
||||
$customer_id = $this->request->getPost('customerValue');
|
||||
$address_id = $this->request->getPost('selectedValue');
|
||||
$where = ['isactive' => 1, 'customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
|
||||
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
|
||||
$data['customer_shipping'] = $this->get_customer_address($where, []);
|
||||
return $this->response->setJSON(['data' => $data]);
|
||||
}
|
||||
@ -124,11 +124,10 @@ class Invoice extends BaseController
|
||||
{
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_addresses');
|
||||
if (!empty($select)) {
|
||||
$address_details = $model->select($select)->where($where)->findAll();
|
||||
} else {
|
||||
$address_details = $model->where($where)->findAll();
|
||||
if (empty($select)) {
|
||||
$select = ["customer_addresses.customer_id","customer_addresses.customer_address_id","customer_addresses.first_name","customer_addresses.last_name ","customer_addresses.company","customer_addresses.email","customer_addresses.mobile_no","customer_addresses.address_type","customer_addresses.address_1","customer_addresses.address_2","customer_addresses.city","customer_addresses.state","customer_addresses.postal_code","customer_addresses.country","states.state_name","countries.country_name"];
|
||||
}
|
||||
$address_details = $model->select($select)->join('states', 'states.state_short_name = customer_addresses.state AND customer_addresses.country = "IN"', 'left')->join('countries', 'countries.country_short_name = customer_addresses.country', 'left')->where($where)->findAll();
|
||||
return $address_details;
|
||||
}
|
||||
|
||||
|
||||
@ -3,32 +3,26 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
|
||||
<ul class="nav nav-tabs" id="customerTabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
|
||||
</li>
|
||||
<?php if ($page_name === 'Edit Customer Details') : ?>
|
||||
<?php if ($page_name === 'Edit Customer Details') : ?>
|
||||
<ul class="nav nav-tabs" id="customerTabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
|
||||
<a class="nav-link active" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="invoiceDetails-tab" data-toggle="tab" href="#invoiceDetails" role="tab" aria-controls="invoiceDetails" aria-selected="false">Invoice Details</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<div class="tab-content">
|
||||
<!-- <?php print_r($customer); ?> -->
|
||||
|
||||
<!-- Customer Details Tab -->
|
||||
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
|
||||
<!-- Customer details form fields -->
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm" >
|
||||
<!-- <img src="<?= base_url()."public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
|
||||
<div class="form-group">
|
||||
|
||||
</div>
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm">
|
||||
<!-- <img src="<?= base_url() . "public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cfname" class="col-form-label">First Name<span class="text-danger"> *</span></label>
|
||||
@ -42,7 +36,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cmail" class="col-form-label">Email</label>
|
||||
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)"/>
|
||||
<input type="text" class="form-control" id="cmail" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" onkeyup="validateEmail(this.value)" />
|
||||
<span id="emailValidationMessage"></span>
|
||||
</div>
|
||||
</div>
|
||||
@ -72,7 +66,6 @@
|
||||
<div class="col-md-6 text-left">
|
||||
<h5> Billing Address </h5>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="after-add-more">
|
||||
@ -134,24 +127,24 @@
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<div id="billinput" style="display: block">
|
||||
<label for="bistate" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State"/>
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
<div id="billdropdown" style="display: none">
|
||||
<label for="bdstate" class="col-form-label">State</label>
|
||||
<select class="form-control" id="bdstate" name="bdstate[]">
|
||||
<option value="">Choose your State</option>
|
||||
<?php foreach ($state_details as $value) { ?>
|
||||
<option value="<?php echo $value['state_short_name']; ?>">
|
||||
<?php echo $value['state_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
|
||||
<div id="billinput" style="display: block">
|
||||
<label for="bistate" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" id="bistate" name="bistate[]" placeholder="State" />
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
<div id="billdropdown" style="display: none">
|
||||
<label for="bdstate" class="col-form-label">State</label>
|
||||
<select class="form-control" id="bdstate" name="bdstate[]">
|
||||
<option value="">Choose your State</option>
|
||||
<?php foreach ($state_details as $value) { ?>
|
||||
<option value="<?php echo $value['state_short_name']; ?>">
|
||||
<?php echo $value['state_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<!-- <div class="invalid-feedback"> Please provide. </div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bcity" class="col-form-label">City<span class="text-danger"> *</span></label>
|
||||
@ -206,9 +199,9 @@
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" id="sistate0" name="sistate[]" placeholder="State" style="display: block" />
|
||||
<select class="form-control" id="sdstate0" name="sdstate[]" style="display: none">
|
||||
<label for="" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" id="sistate0" name="sistate[]" placeholder="State" style="display: block" />
|
||||
<select class="form-control" id="sdstate0" name="sdstate[]" style="display: none">
|
||||
<option value="">Choose your State</option>
|
||||
<?php foreach ($state_details as $value) { ?>
|
||||
<option value="<?php echo $value['state_short_name']; ?>">
|
||||
@ -250,27 +243,18 @@
|
||||
<br>
|
||||
<?php } ?>
|
||||
<div class="form-group text-right m-b-0">
|
||||
|
||||
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" id="submitBtn" type="submit">Submit</button>
|
||||
<!-- <button type="reset" class="btn btn-primary waves-effect mr-1">Reset</button> -->
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
|
||||
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
<!-- Display Subscription Details -->
|
||||
|
||||
|
||||
<!-- Add subscription details content here -->
|
||||
<!-- You can fetch and display subscription details here -->
|
||||
|
||||
|
||||
|
||||
<!-- <div class="loader" style="display: none;">
|
||||
<img src="<?= base_url()."public/assets/images/plugins/loading.gif" ?>" alt="Loading...">
|
||||
</div> -->
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body-->
|
||||
|
||||
</div><!-- end customer Details Tab -->
|
||||
|
||||
<!-- Subscription Details Tab -->
|
||||
<div class="tab-pane fade show " id="subscriptionDetails" role="tabpanel" aria-labelledby="subscriptionDetails-tab">
|
||||
<?php if (!empty($subscriptionData)) : ?>
|
||||
<table class="table table-bordered">
|
||||
@ -294,7 +278,9 @@
|
||||
<?php else : ?>
|
||||
<p>No subscriptions found for this customer.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div><!-- end subscription Details Tab -->
|
||||
|
||||
<!-- Invoice Details Tab -->
|
||||
<div class="tab-pane fade" id="invoiceDetails" role="tabpanel" aria-labelledby="invoiceDetails-tab">
|
||||
<?php if (!empty($invoices)) : ?>
|
||||
<table class="table table-bordered">
|
||||
@ -317,15 +303,16 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else : ?>
|
||||
<p>No subscriptions found for this customer.</p>
|
||||
<p>No invoice found for this customer.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end invoice Details Tab -->
|
||||
|
||||
</div><!-- end tab-content-->
|
||||
</div><!-- end card-body-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#addressCopiedAsShipping").on("change", function() {
|
||||
if ($(this).is(":checked")) {
|
||||
@ -336,14 +323,14 @@
|
||||
var customerInputState = $("#bistate").val();
|
||||
var customerCity = $("#bcity").val();
|
||||
var customerPostalCode = $("#bzip").val();
|
||||
|
||||
|
||||
$("#saddress1").val(customerAddress1).prop("readonly", false);
|
||||
$("#saddress2").val(customerAddress2).prop("readonly", false);
|
||||
$("#scountry0").val(customerCountry).prop("readonly", false);
|
||||
if(customerCountry == 'IN'){
|
||||
if (customerCountry == 'IN') {
|
||||
$("#sistate0").val(customerInputState).css("display", "none").prop("readonly", false);
|
||||
$("#sdstate0").val(customerDropdownState).css("display", "block").prop("readonly", false);
|
||||
}else{
|
||||
} else {
|
||||
$("#sistate0").val(customerInputState).css("display", "block").prop("readonly", false);
|
||||
$("#sdstate0").val(customerDropdownState).css("display", "none").prop("readonly", false);
|
||||
}
|
||||
@ -362,7 +349,7 @@
|
||||
}
|
||||
});
|
||||
$("#bcountry").on("change", function() {
|
||||
var country = $("#bcountry").val();
|
||||
var country = $("#bcountry").val();
|
||||
var dropdownField = $("#billdropdown");
|
||||
var textField = $("#billinput");
|
||||
if (country === 'IN') {
|
||||
@ -375,25 +362,25 @@
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
var barray = <?php echo json_encode($customer_billing); ?>;
|
||||
if (barray.length > 0) {
|
||||
for (var i = 0; i < barray.length; i++) {
|
||||
$("#baddress1").val(barray[i]['address_1']);
|
||||
$("#baddress2").val(barray[i]['address_2']);
|
||||
$("#bcountry").val(barray[i]['country']);
|
||||
$("#bcity").val(barray[i]['city']);
|
||||
if(barray[i]['country'] == 'IN'){
|
||||
$("#bdstate").val(barray[i]['state']);
|
||||
$("#billdropdown").show();
|
||||
$("#billinput").hide();
|
||||
} else {
|
||||
$("#bistate").val(barray[i]['state']);
|
||||
$("#billdropdown").hide();
|
||||
$("#billinput").show();
|
||||
|
||||
}
|
||||
$("#bzip").val(barray[i]['postal_code']);
|
||||
$("#baddress1").val(barray[i]['address_1']);
|
||||
$("#baddress2").val(barray[i]['address_2']);
|
||||
$("#bcountry").val(barray[i]['country']);
|
||||
$("#bcity").val(barray[i]['city']);
|
||||
if (barray[i]['country'] == 'IN') {
|
||||
$("#bdstate").val(barray[i]['state']);
|
||||
$("#billdropdown").show();
|
||||
$("#billinput").hide();
|
||||
} else {
|
||||
$("#bistate").val(barray[i]['state']);
|
||||
$("#billdropdown").hide();
|
||||
$("#billinput").show();
|
||||
|
||||
}
|
||||
$("#bzip").val(barray[i]['postal_code']);
|
||||
$('#bcustomer_address_id').val(barray[i]['customer_address_id']);
|
||||
}
|
||||
}
|
||||
@ -402,35 +389,35 @@
|
||||
|
||||
var sarray = <?php echo json_encode($customer_shipping); ?>;
|
||||
if (sarray.length > 0) {
|
||||
j=0;
|
||||
j = 0;
|
||||
for (var i = 0; i < sarray.length; i++) {
|
||||
if (i == 0) {
|
||||
var html = $(".after-shipping-addr-add-more").first();
|
||||
} else {
|
||||
var html = $(".after-shipping-addr-add-more").first().clone();
|
||||
}
|
||||
if((barray[0]['address_1'] == sarray[i]['address_1']) &&
|
||||
(barray[0]['city'] == sarray[i]['city']) &&
|
||||
(barray[0]['state'] == sarray[i]['state']) &&
|
||||
(barray[0]['country'] == sarray[i]['country']) &&
|
||||
(barray[0]['postal_code']== sarray[i]['postal_code'])){
|
||||
$("#addressCopiedAsShipping").prop("checked",true);
|
||||
if ((barray[0]['address_1'] == sarray[i]['address_1']) &&
|
||||
(barray[0]['city'] == sarray[i]['city']) &&
|
||||
(barray[0]['state'] == sarray[i]['state']) &&
|
||||
(barray[0]['country'] == sarray[i]['country']) &&
|
||||
(barray[0]['postal_code'] == sarray[i]['postal_code'])) {
|
||||
$("#addressCopiedAsShipping").prop("checked", true);
|
||||
}
|
||||
html.find('input#scustomer_address_id').val(sarray[i]['customer_address_id']);
|
||||
html.find('input#saddress1').val(sarray[i]['address_1']);
|
||||
html.find('input#saddress2').val(sarray[i]['address_2']);
|
||||
html.find('input#scity').val(sarray[i]['city']);
|
||||
html.find('select#scountry0').val(sarray[i]['country']);
|
||||
html.find('select#scountry0').attr('id','scountry'+j);
|
||||
if(sarray[i]['country'] === 'IN'){
|
||||
html.find('select#scountry0').attr('id', 'scountry' + j);
|
||||
if (sarray[i]['country'] === 'IN') {
|
||||
// html.find('select#sdstate0').attr('id','sdstate'+$j).val(sarray[i]['state']);
|
||||
html.find('select#sdstate0').attr('id','sdstate'+j).css("display", "block").val(sarray[i]['state']);
|
||||
html.find('input#sistate0').attr('id','sistate'+j).css("display", "none").val('');
|
||||
}else{
|
||||
html.find('input#sistate0').attr('id','sistate'+j).css("display", "block").val(sarray[i]['state']);
|
||||
html.find('select#sdstate0').attr('id','sdstate'+j).css("display", "none").val('');
|
||||
html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "block").val(sarray[i]['state']);
|
||||
html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "none").val('');
|
||||
} else {
|
||||
html.find('input#sistate0').attr('id', 'sistate' + j).css("display", "block").val(sarray[i]['state']);
|
||||
html.find('select#sdstate0').attr('id', 'sdstate' + j).css("display", "none").val('');
|
||||
}
|
||||
|
||||
|
||||
html.find('input#szip').val(sarray[i]['postal_code']);
|
||||
if (i !== 0) {
|
||||
html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
|
||||
@ -446,9 +433,9 @@
|
||||
$("body").on("click", ".shipping-addr-add-more", function() {
|
||||
var html = $(".after-shipping-addr-add-more").first().clone();
|
||||
var count = $(".after-shipping-addr-add-more").length;
|
||||
html.find('select#scountry0').attr('id','scountry'+count).val('')
|
||||
html.find('select#sdstate0').attr('id','sdstate'+count).css("display", "none").val('');
|
||||
html.find('input#sistate0').attr('id','sistate'+count).css("display", "block").val('');
|
||||
html.find('select#scountry0').attr('id', 'scountry' + count).val('')
|
||||
html.find('select#sdstate0').attr('id', 'sdstate' + count).css("display", "none").val('');
|
||||
html.find('input#sistate0').attr('id', 'sistate' + count).css("display", "block").val('');
|
||||
html.find('input').val(''); // Clear input values in the cloned element
|
||||
html.find(".shipping-addr-div-change").html("<a class='btn btn-success waves-effect waves-light mr-1 shipping-addr-add-more'>+ Add More Shipping Address </a><a class='btn btn-danger waves-effect waves-light mr-1 shipping-addr-remove'>- Remove </a>");
|
||||
html.insertAfter(".after-shipping-addr-add-more:last");
|
||||
@ -467,24 +454,24 @@
|
||||
|
||||
function toggleButtons() {
|
||||
var elementCount = $(".after-shipping-addr-add-more").length;
|
||||
console.log('elementCount == '+elementCount);
|
||||
console.log('elementCount == ' + elementCount);
|
||||
if (elementCount > 1) {
|
||||
$(".shipping-addr-remove").show(); // Show the "shipping-addr-remove" buttons
|
||||
$(".shipping-addr-remove").show(); // Show the "shipping-addr-remove" buttons
|
||||
} else {
|
||||
$(".shipping-addr-remove").hide(); // Hide the "shipping-addr-remove" buttons
|
||||
$(".shipping-addr-remove").hide(); // Hide the "shipping-addr-remove" buttons
|
||||
}
|
||||
$(".after-shipping-addr-add-more .shipping-addr-add-more").hide();
|
||||
$(".after-shipping-addr-add-more:last .shipping-addr-add-more").show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#submit-button').click(function() {
|
||||
// Disable the button
|
||||
$(this).prop('disabled', true);
|
||||
|
||||
// Change the button content to a spinner
|
||||
$(this).html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Loading...');
|
||||
|
||||
|
||||
// Simulate a delay to demonstrate loading (you can replace this with your actual loading logic)
|
||||
setTimeout(function() {
|
||||
// Re-enable the button and restore the original text
|
||||
@ -494,66 +481,66 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function changeFields(element) {
|
||||
var selectedValue = $(element).val();
|
||||
var elementId = $(element).attr('id');
|
||||
var match = elementId.match(/\d+/);
|
||||
if (match) {
|
||||
var idnumber = parseInt(match[0], 10);
|
||||
if(selectedValue == 'IN'){
|
||||
$("#sdstate"+idnumber).show();
|
||||
$("#sistate"+idnumber).hide();
|
||||
if (selectedValue == 'IN') {
|
||||
$("#sdstate" + idnumber).show();
|
||||
$("#sistate" + idnumber).hide();
|
||||
} else {
|
||||
$("#sdstate"+idnumber).hide();
|
||||
$("#sistate"+idnumber).show();
|
||||
$("#sdstate" + idnumber).hide();
|
||||
$("#sistate" + idnumber).show();
|
||||
}
|
||||
} else {
|
||||
// alert("No number found in the ID");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||
var form = event.target;
|
||||
|
||||
|
||||
if (form.checkValidity() === false) {
|
||||
|
||||
|
||||
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 validateEmail(email) {
|
||||
// Regular expression for a basic email validation
|
||||
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
|
||||
function validateEmail(email) {
|
||||
// Regular expression for a basic email validation
|
||||
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
|
||||
|
||||
var emailInput = document.getElementById("cmail");
|
||||
var validationMessage = document.getElementById("emailValidationMessage");
|
||||
var emailInput = document.getElementById("cmail");
|
||||
var validationMessage = document.getElementById("emailValidationMessage");
|
||||
|
||||
if (emailPattern.test(email)) {
|
||||
validationMessage.textContent = "";
|
||||
}else if(email == ""){
|
||||
validationMessage.textContent = "";
|
||||
if (emailPattern.test(email)) {
|
||||
validationMessage.textContent = "";
|
||||
} else if (email == "") {
|
||||
validationMessage.textContent = "";
|
||||
} else {
|
||||
validationMessage.textContent = "Invalid email address";
|
||||
validationMessage.style.color = "red";
|
||||
}
|
||||
}
|
||||
else {
|
||||
validationMessage.textContent = "Invalid email address";
|
||||
validationMessage.style.color = "red";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function restriction(event) {
|
||||
var charCode = event.which || event.keyCode;
|
||||
if((charCode >= 48 && charCode <= 57)){
|
||||
return true;
|
||||
}else {
|
||||
event.preventDefault(); // Prevent the character from being entered
|
||||
return false;
|
||||
function restriction(event) {
|
||||
var charCode = event.which || event.keyCode;
|
||||
if ((charCode >= 48 && charCode <= 57)) {
|
||||
return true;
|
||||
} else {
|
||||
event.preventDefault(); // Prevent the character from being entered
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1,3 +1,9 @@
|
||||
<!-- <style>
|
||||
/* Target the Select2 container and set the width */
|
||||
.select2-container .select2-dropdown {
|
||||
width: 249px !important;
|
||||
}
|
||||
</style> -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
@ -17,7 +23,9 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please select customer. </div>
|
||||
<div class="subscribedetails" style="display: none"><div id="schemeName"></div></div>
|
||||
<div class="subscribedetails" style="display: none">
|
||||
<div id="schemeName"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
@ -28,7 +36,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="storeBillingAddress"> Billing Address  ( <input type="checkbox" id="editAddressesCheckbox" /> Do you want to edit/change addresses?)</label>
|
||||
@ -71,12 +79,12 @@
|
||||
</div>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="fromsubcription">From Subcription</label>
|
||||
<input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>">
|
||||
<label for="fromsubcription">From Subcription</label>
|
||||
<input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="tosubcription">To Subcription</label>
|
||||
<input type="date" class="form-control" id="to_subcription" name="to_subscription" value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>">
|
||||
<label for="tosubcription">To Subcription</label>
|
||||
<input type="date" class="form-control" id="to_subcription" name="to_subscription" value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -101,16 +109,16 @@
|
||||
<?php if (!empty($invoice_item_details)) {
|
||||
foreach ($invoice_item_details as $inx => $ii_details) : ?>
|
||||
<tr>
|
||||
<td><select class="form-control" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2">
|
||||
<td><select class="form-control book-select" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
|
||||
<?= $book->title ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" />
|
||||
<td style="width:10%;"><input type="number" class="form-control item-quantity" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" readonly />
|
||||
<td style="width:10%;"><input type="text" class="form-control item-rate" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" readonly />
|
||||
</td>
|
||||
<td style="width:8%;"><input type="text" class="form-control item-tax" id="<?= "tax" . $inx; ?>" name="tax[]" value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" readonly />
|
||||
</td>
|
||||
@ -136,16 +144,16 @@
|
||||
<?php endforeach;
|
||||
} else { ?>
|
||||
<tr>
|
||||
<td style="width:30%;"><select class="form-control" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2">
|
||||
<td style="width:30% !important;"><select class="form-control book-select" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2" style="width: 249px !important;">
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
|
||||
<td style="width:10%;"><input type="number" class="form-control item-quantity" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:10%;"><input type="text" class="form-control item-rate" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:8%;"><input type="text" class="form-control item-tax" id="tax0" name="tax[]" /></td>
|
||||
<td style="width:12%;"><input type="text" class="form-control item-amount" id="amount0" name="amount[]" />
|
||||
</td>
|
||||
@ -312,41 +320,20 @@
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>`;
|
||||
|
||||
// cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">';
|
||||
cell2.innerHTML = '<input type="number" class="form-control" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell2.innerHTML = '<input type="number" class="form-control item-quantity" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control item-rate" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax' + counter + '" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount' + counter + '" name="amount[]">';
|
||||
cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]">';
|
||||
cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell7.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
|
||||
cell8.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
|
||||
|
||||
// Attach the calculateInvoice function to new input fields' change events
|
||||
// cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
newRow.querySelector('.book-select').addEventListener("change", function() {
|
||||
displayBookTag(this, counter);
|
||||
});
|
||||
$(newRow.querySelector('.book-select')).select2();
|
||||
newRow.querySelector('.quantity-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.rate-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-amount-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-type-select').addEventListener("change", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
// cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
|
||||
|
||||
|
||||
function displayBookTag(inputElement, counter) {
|
||||
var row = inputElement.parentElement.parentElement;
|
||||
var bookId = inputElement.value;
|
||||
@ -453,9 +440,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Define a function to calculate the grand total
|
||||
// Define a function to calculate the grand total
|
||||
function calculateGrandTotal() {
|
||||
var invoiceItems = []; // Create an empty array to store item details
|
||||
@ -499,68 +483,7 @@
|
||||
var grandTotalElement = grandTotal.toFixed(2);
|
||||
document.getElementById("grandtotal").value = grandTotalElement;
|
||||
}
|
||||
|
||||
// the calculateOverallTotals function whenever you need to recalculate the totals, such as when a new item is added or an item is edited.
|
||||
|
||||
|
||||
|
||||
// function calculateSubTotal() {
|
||||
// var amountInputs = document.querySelectorAll('.amount-input');
|
||||
// var subTotal = 0;
|
||||
// var taxInputs = document.querySelectorAll('.tax-input');
|
||||
// var taxTotal = 0;
|
||||
// var discountAmountInputs = document.querySelectorAll('.discount-amount-input');
|
||||
// var discountTypeSelects = document.querySelectorAll('.discount-type-select');
|
||||
// var overallDiscount = 0;
|
||||
|
||||
// amountInputs.forEach(function (input, index) {
|
||||
// var amount = parseFloat(input.value) || 0;
|
||||
// subTotal += amount;
|
||||
|
||||
|
||||
// var tax = parseFloat(taxInputs[index].value) || 0;
|
||||
// taxTotal += tax;
|
||||
|
||||
// var discountType = discountTypeSelects[index].value;
|
||||
// var discountAmount = parseFloat(discountAmountInputs[index].value) || 0;
|
||||
|
||||
// if (discountType === '₹') {
|
||||
// // Calculate discount based on ₹
|
||||
// var discountedAmount = amount - discountAmount;
|
||||
// overallDiscount += discountAmount;
|
||||
// } else if (discountType === '%') {
|
||||
// // Calculate discount based on %
|
||||
// var discountPercentage = discountAmount;
|
||||
// var discountValue = (amount * discountPercentage) / 100;
|
||||
// var discountedAmount = amount - discountValue;
|
||||
// overallDiscount += discountValue;
|
||||
// }
|
||||
// });
|
||||
|
||||
// var subTotalElement = subTotal.toFixed(2);
|
||||
// $("#subtotal").val(subTotalElement);
|
||||
|
||||
// var taxElement = taxTotal.toFixed(2);
|
||||
// $("#invoicetax").val(taxElement);
|
||||
|
||||
// var overallDiscountElement = overallDiscount.toFixed(2);
|
||||
// $("#discount").val(overallDiscountElement);
|
||||
|
||||
// calculateGrandTotal(subTotal, taxTotal, overallDiscount);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// function calculateGrandTotal(subTotal, invoiceTax, discount) {
|
||||
// var grandTotal = 0;
|
||||
|
||||
// if (!isNaN(subTotal) && !isNaN(invoiceTax) && !isNaN(discount)) {
|
||||
// grandTotal = subTotal + invoiceTax - discount;
|
||||
// }
|
||||
|
||||
// var grandElement = grandTotal.toFixed(2);
|
||||
// $("#grandtotal").val(grandElement);
|
||||
// }
|
||||
|
||||
</script>
|
||||
|
||||
<!-- JavaScript for removing a row from the table -->
|
||||
@ -569,7 +492,7 @@
|
||||
function removeItem(row) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
table.removeChild(row);
|
||||
calculateSubTotal(); // Call the calculation function to update the totals
|
||||
calculateOverallTotals(); // Call the calculation function to update the totals
|
||||
}
|
||||
|
||||
// Attach the removeItem function to the Remove buttons using event delegation
|
||||
@ -588,18 +511,17 @@
|
||||
var cust_id = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
||||
var ship_addr_id = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
|
||||
if (cust_id != '') {
|
||||
|
||||
load_details1(ship_addr_id, cust_id);
|
||||
load_details2(ship_addr_id, cust_id);
|
||||
}
|
||||
var ship_addr = "";
|
||||
|
||||
var bill_addr = "";
|
||||
// $("#customerName").val(customer_id).change();
|
||||
|
||||
|
||||
$("#customerName").change(function() {
|
||||
var cust_id = $(this).val();
|
||||
var ship_addr_id = "";
|
||||
load_details1(ship_addr_id, cust_id);
|
||||
$('#storeShippingAddress').val('');
|
||||
});
|
||||
|
||||
$("#loadShippingDropdown").change(function() {
|
||||
@ -644,12 +566,17 @@
|
||||
cm = response['data']['customer_membership'];
|
||||
$('#hiddenBillingAddressId').val('');
|
||||
customer_billing = "";
|
||||
var customer_billing_addressDetails = [];
|
||||
if (cb.length > 0) {
|
||||
$.each(cb, function(k, v) {
|
||||
customer_billing = v.address_1 + " " + v.address_2 + ",\n" + v
|
||||
.city + ",\n" + v.state + " - " + v.postal_code + ",\n" + v
|
||||
.country + "."
|
||||
customer_billing_id = v.customer_address_id
|
||||
$.each(cb, function(k, v) {
|
||||
var state = v.state_name ? v.state_name : v.state;
|
||||
state = v.postal_code ? state+"-"+v.postal_code : state;
|
||||
v.address_1 ? customer_billing_addressDetails.push(v.address_1 + " " + v.address_2):"";
|
||||
v.city ? customer_billing_addressDetails.push(v.city):"";
|
||||
state ? customer_billing_addressDetails.push(state):"";
|
||||
v.country_name ? customer_billing_addressDetails.push(v.country_name) :"";
|
||||
customer_billing_id = v.customer_address_id;
|
||||
|
||||
});
|
||||
}
|
||||
if (cm.length > 0) {
|
||||
@ -660,25 +587,17 @@
|
||||
$("#schemeName").text("No Earlier Membership found");
|
||||
}
|
||||
|
||||
|
||||
// var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr
|
||||
//
|
||||
if ((bill_addr != "") && (bill_addr != customer_billing)) {
|
||||
$("#storeBillingAddress").val(bill_addr).prop("readonly", false);
|
||||
$('#editAddressesCheckbox').prop('checked', true);
|
||||
} else {
|
||||
$("#storeBillingAddress").val(customer_billing).prop("readonly", true);
|
||||
$("#storeBillingAddress").val(customer_billing_addressDetails.join(', \n')+".").prop("readonly", true);
|
||||
$('#editAddressesCheckbox').prop('checked', false);
|
||||
}
|
||||
|
||||
$('#hiddenBillingAddressId').val(customer_billing_id);
|
||||
if (cs.length > 0) {
|
||||
$('#loadShippingDropdown').empty();
|
||||
if (ship_addr != '') {
|
||||
$("#storeShippingAddress").val(ship_addr);
|
||||
} else {
|
||||
$('#storeShippingAddress').val('');
|
||||
}
|
||||
$('#loadShippingDropdown').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select an address"
|
||||
@ -691,9 +610,8 @@
|
||||
ship_addr_id) ?
|
||||
true : false
|
||||
}));
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
@ -714,15 +632,19 @@
|
||||
success: function(response) {
|
||||
cs = response['data']['customer_shipping'];
|
||||
customer_shipping = "";
|
||||
customer_shipping_addressDetails = [];
|
||||
if (cs.length > 0) {
|
||||
$.each(cs, function(k, v) {
|
||||
customer_shipping = v.address_1 + " " + v.address_2 + ",\n" + v
|
||||
.city + ",\n" + v.state + " - " + v.postal_code + ",\n" + v
|
||||
.country + "."
|
||||
var state = v.state_name ? v.state_name : v.state;
|
||||
state = v.postal_code ? state+"-"+v.postal_code : state;
|
||||
v.address_1 ? customer_shipping_addressDetails.push(v.address_1 + " " + v.address_2) : "";
|
||||
v.city ? customer_shipping_addressDetails.push(v.city) : "";
|
||||
state ? customer_shipping_addressDetails.push(state) :"";
|
||||
v.country_name ? customer_shipping_addressDetails.push(v.country_name):"";
|
||||
customer_shipping_id = v.customer_address_id;
|
||||
});
|
||||
}
|
||||
|
||||
$("#storeShippingAddress").val(customer_shipping);
|
||||
$("#storeShippingAddress").val(customer_shipping_addressDetails.join(', \n')+".");
|
||||
},
|
||||
error: function() {
|
||||
alert("Error fetching address.");
|
||||
@ -748,6 +670,9 @@
|
||||
return serial_number;
|
||||
}
|
||||
|
||||
bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>";
|
||||
if (bill_addr != '') { $("#storeBillingAddress").val(bill_addr);}
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
@ -822,11 +747,19 @@
|
||||
if (form.checkValidity() === false) {
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if it's not valid
|
||||
if (status == "Draft" ){$('#saveDraftButton').prop('disabled', false);}
|
||||
if (status == "Approved" ){$('#saveapproved').prop('disabled', false);}
|
||||
if (status == "Draft") {
|
||||
$('#saveDraftButton').prop('disabled', false);
|
||||
}
|
||||
if (status == "Approved") {
|
||||
$('#saveapproved').prop('disabled', false);
|
||||
}
|
||||
} else {
|
||||
if (status == "Draft" ){$('#saveDraftButton').prop('disabled', true);}
|
||||
if (status == "Approved" ){$('#saveapproved').prop('disabled', true);}
|
||||
if (status == "Draft") {
|
||||
$('#saveDraftButton').prop('disabled', true);
|
||||
}
|
||||
if (status == "Approved") {
|
||||
$('#saveapproved').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
});
|
||||
</script>
|
||||
@ -6,20 +6,18 @@
|
||||
<!-- <?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
|
||||
<?php endif; ?> -->
|
||||
<form class="parsley-examples" action="<?= base_url() . "insert_users"; ?>" method="post" enctype="multipart/form-data">
|
||||
<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">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="email" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" name="email" placeholder="Email" value="<?= isset($details['email']) ? $details['email'] : '' ?>" required />
|
||||
|
||||
</div>
|
||||
|
||||
<?php if (empty($details)) { ?>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="password" class="col-form-label">Password<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="password" name="password" placeholder="Password" value="<?= isset($details['password']) ? $details['password'] : '' ?>" required />
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@ -30,77 +28,70 @@
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="last_name" class="col-form-label">Last Name<span class="text-danger"></span></label>
|
||||
<input data-parsley-type="alphanum" type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name" value="<?= isset($details['last_name']) ? $details['last_name'] : '' ?>" />
|
||||
<input data-parsley-type="alphanum" type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name" value="<?= isset($details['last_name']) ? $details['last_name'] : '' ?>" />
|
||||
</div>
|
||||
<!-- <div class="form-group col-md-4">
|
||||
<label for="date_of_birth" class="col-form-label">Date Of Birth<span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" placeholder="Date Of birth (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" required />
|
||||
</div> -->
|
||||
<label for="date_of_birth" class="col-form-label">Date Of Birth<span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" placeholder="Date Of birth (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" required />
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="mobile_no" class="col-form-label">Mobile Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile_no" name="mobile_no" placeholder="Mobile Number (Enter only numbers)" data-toggle="input-mask" data-mask-format="0000000000" value="<?= isset($details['mobile_no']) ? $details['mobile_no'] : '' ?>" autofocus required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
|
||||
<select id="role" name="role" class="form-control" required>
|
||||
<option value="">Select Role</option>
|
||||
<option value="admin" <?= isset($details['role']) && $details['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
|
||||
<option value="manager" <?= isset($details['role']) && $details['role'] === 'manager' ? 'selected' : '' ?>>Manager</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gender" class="col-form-label">Gender<span class="text-danger"></span></label>
|
||||
<select id="gender" name="gender" class="form-control">
|
||||
<option value="">Select Gender</option>
|
||||
<option value="male" <?= isset($details['gender']) && $details['gender'] === 'male' ? 'selected' : '' ?>>Male</option>
|
||||
<option value="female" <?= isset($details['gender']) && $details['gender'] === 'female' ? 'selected' : '' ?>>Female</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="mobile_no" class="col-form-label">Mobile Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile_no" name="mobile_no" placeholder="Mobile Number (Enter only numbers)" data-toggle="input-mask" data-mask-format="0000000000" value="<?= isset($details['mobile_no']) ? $details['mobile_no'] : '' ?>" autofocus required>
|
||||
</div>
|
||||
|
||||
<!-- ... (other form elements) ... -->
|
||||
<div class="form-group col-md-4">
|
||||
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
|
||||
<select id="role" name="role" class="form-control" required>
|
||||
<option value="">Select Role</option>
|
||||
<option value="admin" <?= isset($details['role']) && $details['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
|
||||
<option value="manager" <?= isset($details['role']) && $details['role'] === 'manager' ? 'selected' : '' ?>>Manager</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gender" class="col-form-label">Gender<span class="text-danger"></span></label>
|
||||
<select id="gender" name="gender" class="form-control" >
|
||||
<option value="">Select Gender</option>
|
||||
<option value="male" <?= isset($details['gender']) && $details['gender'] === 'male' ? 'selected' : '' ?>>Male</option>
|
||||
<option value="female" <?= isset($details['gender']) && $details['gender'] === 'female' ? 'selected' : '' ?>>Female</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ... (rest of the form) ... -->
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="address" class="col-form-label">Address<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="address" name="address" placeholder="Address (eg : 1234 Main St)" value="<?= isset($details['address']) ? $details['address'] : '' ?>" />
|
||||
<input type="text" class="form-control" id="address" name="address" placeholder="Address (eg : 1234 Main St)" value="<?= isset($details['address']) ? $details['address'] : '' ?>" />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="city" class="col-form-label">City<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="city" name="city" placeholder="City" value="<?= isset($details['city']) ? $details['city'] : '' ?>" />
|
||||
</div>
|
||||
<input type="text" class="form-control" id="city" name="city" placeholder="City" value="<?= isset($details['city']) ? $details['city'] : '' ?>" />
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="state" class="col-form-label">State<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="state" name="state" placeholder="State" value="<?= isset($details['state']) ? $details['state'] : '' ?>" />
|
||||
<input type="text" class="form-control" id="state" name="state" placeholder="State" value="<?= isset($details['state']) ? $details['state'] : '' ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="postal_code" class="col-form-label">Postal Code<span class="text-danger"></span></label>
|
||||
<input data-parsley-type="number" type="text" class="form-control" id="postal_code" name="postal_code" placeholder="Postal Code (PIN)" value="<?= isset($details['postal_code']) ? $details['postal_code'] : '' ?>" pattern="[0-9]{6}" maxlength="6" />
|
||||
</div>
|
||||
<?php if (!empty($details['profile_picture'])) { ?>
|
||||
<div class="form-group col-md-4 mt-3">
|
||||
<div class="media">
|
||||
<img src="<?= base_url('public/uploads/' . $details['profile_picture']) ?>" alt="Business Logo" height="50" class="preview-image d-flex align-self-start rounded mr-2">
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0">Existing Profile Picture</h5>
|
||||
<p class="mb-1"><?= $details['profile_picture']; ?></p>
|
||||
<input type="hidden" id="existing_profile_picture_name" name="existing_profile_picture_name" placeholder="hidden Field for profile picture name" readonly value="<?= $details['profile_picture']; ?>" />
|
||||
</div>
|
||||
<input data-parsley-type="number" type="text" class="form-control" id="postal_code" name="postal_code" placeholder="Postal Code (PIN)" value="<?= isset($details['postal_code']) ? $details['postal_code'] : '' ?>" pattern="[0-9]{6}" maxlength="6" />
|
||||
</div>
|
||||
<?php if (!empty($details['profile_picture'])) { ?>
|
||||
<div class="form-group col-md-4 mt-3">
|
||||
<div class="media">
|
||||
<img src="<?= base_url('public/uploads/' . $details['profile_picture']) ?>" alt="Business Logo" height="50" class="preview-image d-flex align-self-start rounded mr-2">
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0">Existing Profile Picture</h5>
|
||||
<p class="mb-1"><?= $details['profile_picture']; ?></p>
|
||||
<input type="hidden" id="existing_profile_picture_name" name="existing_profile_picture_name" placeholder="hidden Field for profile picture name" readonly value="<?= $details['profile_picture']; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="profile_picture" class="col-form-label">Profile Picture</label>
|
||||
<input type="file" name="profile_picture" value="<?= isset($details['profile_picture']) ? $details['profile_picture'] : '' ?>" accept="image/*" onchange="validateFile(this)" />
|
||||
@ -108,20 +99,20 @@
|
||||
</div>
|
||||
|
||||
<?php if ($loggedin_person_role === 'sadmin') { ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="business_id" class="col-form-label">Buiness<span class="text-danger"></span></label>
|
||||
<select id="business_id" name="business_id" class="form-control" required>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="business_id" class="col-form-label">Buiness<span class="text-danger"></span></label>
|
||||
<select id="business_id" name="business_id" class="form-control" required>
|
||||
<option value="">Choose your Buiness</option>
|
||||
<?php foreach ($business_details as $value) { ?>
|
||||
<option value="<?php echo $value['business_id']; ?>" <?php if (isset($details['business_id']) && ($details['business_id'] === $value['business_id'])) echo "selected"; ?>>
|
||||
<?php echo $value['title']; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="user_id" name="user_id" placeholder="hidden for user id" value="<?= isset($details['user_id']) ? $details['user_id'] : '' ?>" />
|
||||
|
||||
|
||||
<?php if (!empty($details) && $loggedin_person_role !== 'manager') { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($details) && $details['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
@ -137,9 +128,9 @@
|
||||
Reset
|
||||
</button>
|
||||
<?php if ($loggedin_person_role !== 'manager') : ?>
|
||||
<a href="<?= base_url() . "user_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
<a href="<?= base_url() . "user_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- end card-body-->
|
||||
@ -171,21 +162,22 @@
|
||||
|
||||
// Set the min attribute of the date input field to "1965-01-01"
|
||||
document.getElementById('date_of_birth').setAttribute('min', '1965-01-01');
|
||||
|
||||
function validateFile(input) {
|
||||
const file = input.files[0];
|
||||
const errorMessage = document.getElementById("error_message");
|
||||
|
||||
if (file) {
|
||||
if (file.type.startsWith("image/")) {
|
||||
// It's an image file, no error
|
||||
errorMessage.textContent = "";
|
||||
// It's an image file, no error
|
||||
errorMessage.textContent = "";
|
||||
} else {
|
||||
// Invalid file type
|
||||
errorMessage.textContent = "Invalid file type. Please select an image.";
|
||||
input.value = ""; // Clear the input field
|
||||
// Invalid file type
|
||||
errorMessage.textContent = "Invalid file type. Please select an image.";
|
||||
input.value = ""; // Clear the input field
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||
@ -197,5 +189,5 @@
|
||||
} else {
|
||||
$('#submitBtn').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user