FIX_ subscribe = 2 save as Approved displayed : ps
This commit is contained in:
parent
4bcad0de4b
commit
2e4119d077
@ -641,19 +641,12 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
|
||||
<input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id" value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
|
||||
<div class="form-group m-b-0">
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] == 'Approved') : ?>
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||
<!-- Show the "Save as Draft" button only if the status is not "Approved" -->
|
||||
<button type="submit" class="btn btn-white waves-effect waves-light" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="void" value="Void" id="voidButton">Void</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||
<!-- Show the "Save as Approved" button only if the status is not "Approved" -->
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($invoice_details['status'])) : ?>
|
||||
<button type="submit" class="btn btn-white waves-effect waves-light" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||
<button type="button" class="btn btn-primary waves-effect" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||
<button type="button" class="btn btn-white waves-effect waves-light" name="void" value="Void" id="voidButton">Void</button>
|
||||
<button type="button" class="btn btn-white waves-effect" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
||||
</div>
|
||||
</form>
|
||||
@ -1587,6 +1580,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||
var form = event.target;
|
||||
var status = document.getElementById('status').value;
|
||||
var invoice_type = document.getElementById('invoice_type').value;
|
||||
if (form.checkValidity() === false) {
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if it's not valid
|
||||
@ -1617,7 +1611,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
}
|
||||
if (status == "Approved") {
|
||||
$('#saveDraftButton').prop('disabled', true);
|
||||
$('#saveApprovedButton').prop('disabled', true);
|
||||
$('#saveApprovedButton').prop('disabled', false);
|
||||
$('#saveapproved').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
@ -1989,57 +1983,60 @@ function saveInvoiceCustomer() {
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var status = "<?php echo isset($invoice_details['status']) ? $invoice_details['status'] : ''; ?>";
|
||||
$(document).ready(function() {
|
||||
var status = "<?php echo isset($invoice_details['status']) ? $invoice_details['status'] : ''; ?>";
|
||||
var invoice_type = "<?php echo isset($invoice_details['invoice_type']) ? $invoice_details['invoice_type'] : ''; ?>";
|
||||
|
||||
// Function to hide all buttons
|
||||
function hideAllButtons() {
|
||||
$('#cancelButton, #saveDraftButton, #voidButton, #saveApprovedButton').hide();
|
||||
}
|
||||
console.log("Status: " + status);
|
||||
console.log("Invoice Type: " + invoice_type);
|
||||
|
||||
// Function to show buttons based on status
|
||||
function showButtonsBasedOnStatus(status) {
|
||||
hideAllButtons(); // Hide all buttons first
|
||||
|
||||
if (status === '') {
|
||||
// Case 1: When status is empty, show Draft and Approved buttons
|
||||
$('#saveDraftButton, #saveApprovedButton').show();
|
||||
} else if (status === 'Draft') {
|
||||
// Case 2: When status is Draft, show Void, Draft, and Approved buttons
|
||||
$('#voidButton, #saveDraftButton, #saveApprovedButton').show();
|
||||
} else if (status === 'Approved') {
|
||||
// Case 3: When status is Approved, show Cancel button only
|
||||
$('#cancelButton').show();
|
||||
} else if (status === 'Cancelled' || status === 'Void') {
|
||||
// Case 4 and 5: When status is Cancelled or Void, hide all buttons
|
||||
hideAllButtons();
|
||||
// Function to hide all buttons
|
||||
function hideAllButtons() {
|
||||
$('#cancelButton, #saveDraftButton, #voidButton, #saveApprovedButton').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to show buttons based on the initial status
|
||||
showButtonsBasedOnStatus(status);
|
||||
// Function to show buttons based on status
|
||||
function showButtonsBasedOnStatus(status) {
|
||||
hideAllButtons();
|
||||
if (invoice_type === '1' || invoice_type === '2') {
|
||||
if (status === '') {
|
||||
$('#saveDraftButton, #saveApprovedButton').show();
|
||||
} else if (status === 'Draft') {
|
||||
$('#voidButton, #saveDraftButton, #saveApprovedButton').show();
|
||||
} else if (status === 'Approved') {
|
||||
$('#cancelButton').show();
|
||||
if (invoice_type === '2') {
|
||||
$('#saveApprovedButton').show();
|
||||
}
|
||||
} else if (status === 'Cancelled' || status === 'Void') {
|
||||
hideAllButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handling button clicks can be done similarly as in the previous example
|
||||
// Handle click on the "Cancel" button
|
||||
$('#cancelButton').click(function() {
|
||||
console.log('Cancel button clicked');
|
||||
// Initial call to show buttons based on the initial status
|
||||
showButtonsBasedOnStatus(status);
|
||||
|
||||
// Handling button clicks
|
||||
$('#cancelButton').click(function() {
|
||||
console.log('Cancel button clicked');
|
||||
});
|
||||
|
||||
$('#saveDraftButton').click(function() {
|
||||
console.log('Save as Draft button clicked');
|
||||
});
|
||||
|
||||
$('#voidButton').click(function() {
|
||||
console.log('Void button clicked');
|
||||
});
|
||||
|
||||
$('#saveApprovedButton').click(function() {
|
||||
console.log('Save as Approved button clicked');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
// Handle click on the "Save as Draft" button
|
||||
$('#saveDraftButton').click(function() {
|
||||
console.log('Save as Draft button clicked');
|
||||
});
|
||||
|
||||
// Handle click on the "Void" button
|
||||
$('#voidButton').click(function() {
|
||||
console.log('Void button clicked');
|
||||
});
|
||||
|
||||
// Handle click on the "Save as Approved" button
|
||||
$('#saveApprovedButton').click(function() {
|
||||
console.log('Save as Approved button clicked');
|
||||
});
|
||||
});
|
||||
<script>
|
||||
$("#addressCopiedAsShipping").on("change", function() {
|
||||
if ($(this).is(":checked")) {
|
||||
var customerAddress1 = $("#baddress1").val();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user