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="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'] : '' ?>" />
|
<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">
|
<div class="form-group m-b-0">
|
||||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] == 'Approved') : ?>
|
<?php if (isset($invoice_details['status'])) : ?>
|
||||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
<button type="submit" class="btn btn-white waves-effect waves-light" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||||
<?php endif; ?>
|
<button type="button" class="btn btn-primary waves-effect" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
<button type="button" class="btn btn-white waves-effect waves-light" name="void" value="Void" id="voidButton">Void</button>
|
||||||
<!-- Show the "Save as Draft" button only if the status is not "Approved" -->
|
<button type="button" class="btn btn-white waves-effect" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
||||||
<button type="submit" class="btn btn-white waves-effect waves-light" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
<?php endif; ?>
|
||||||
<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; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -1587,6 +1580,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
|||||||
document.getElementById('myForm').addEventListener('submit', function(event) {
|
document.getElementById('myForm').addEventListener('submit', function(event) {
|
||||||
var form = event.target;
|
var form = event.target;
|
||||||
var status = document.getElementById('status').value;
|
var status = document.getElementById('status').value;
|
||||||
|
var invoice_type = document.getElementById('invoice_type').value;
|
||||||
if (form.checkValidity() === false) {
|
if (form.checkValidity() === false) {
|
||||||
form.reportValidity(); // Display validation error messages
|
form.reportValidity(); // Display validation error messages
|
||||||
event.preventDefault(); // Prevent form submission if it's not valid
|
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") {
|
if (status == "Approved") {
|
||||||
$('#saveDraftButton').prop('disabled', true);
|
$('#saveDraftButton').prop('disabled', true);
|
||||||
$('#saveApprovedButton').prop('disabled', true);
|
$('#saveApprovedButton').prop('disabled', false);
|
||||||
$('#saveapproved').prop('disabled', true);
|
$('#saveapproved').prop('disabled', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1989,57 +1983,60 @@ function saveInvoiceCustomer() {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var status = "<?php echo isset($invoice_details['status']) ? $invoice_details['status'] : ''; ?>";
|
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
|
console.log("Status: " + status);
|
||||||
function hideAllButtons() {
|
console.log("Invoice Type: " + invoice_type);
|
||||||
$('#cancelButton, #saveDraftButton, #voidButton, #saveApprovedButton').hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to show buttons based on status
|
// Function to hide all buttons
|
||||||
function showButtonsBasedOnStatus(status) {
|
function hideAllButtons() {
|
||||||
hideAllButtons(); // Hide all buttons first
|
$('#cancelButton, #saveDraftButton, #voidButton, #saveApprovedButton').hide();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Initial call to show buttons based on the initial status
|
// Function to show buttons based on status
|
||||||
showButtonsBasedOnStatus(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
|
// Initial call to show buttons based on the initial status
|
||||||
// Handle click on the "Cancel" button
|
showButtonsBasedOnStatus(status);
|
||||||
$('#cancelButton').click(function() {
|
|
||||||
console.log('Cancel button clicked');
|
// 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
|
<script>
|
||||||
$('#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');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$("#addressCopiedAsShipping").on("change", function() {
|
$("#addressCopiedAsShipping").on("change", function() {
|
||||||
if ($(this).is(":checked")) {
|
if ($(this).is(":checked")) {
|
||||||
var customerAddress1 = $("#baddress1").val();
|
var customerAddress1 = $("#baddress1").val();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user