feat: Enhance print functionality and add success modal for mass updates
This commit is contained in:
@@ -127,6 +127,27 @@ if ($update_allowed === 1){
|
||||
}
|
||||
}
|
||||
|
||||
// Create success modal if update was completed
|
||||
$success_modal = '';
|
||||
if ($update_allowed === 1 && isset($_POST['excel_data']) && $output_excel_display != ''){
|
||||
$success_modal = '
|
||||
<div id="successModal" class="modal" style="display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
||||
<div class="modal-content" style="background: white; border-radius: 12px; max-width: 500px; margin: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); position: relative;">
|
||||
<span class="close" onclick="closeSuccessModal()" style="position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; color: #999; cursor: pointer;">×</span>
|
||||
<div style="text-align: center; padding: 40px 30px;">
|
||||
<i class="fa-solid fa-check-circle" style="font-size: 64px; color: #28a745; margin-bottom: 20px;"></i>
|
||||
<h2 style="color: #155724; margin-bottom: 15px;">Update Completed!</h2>
|
||||
<p style="margin-bottom: 10px; color: #333;">Successfully updated '.$total_rowID.' items</p>
|
||||
<p style="font-size: 12px; color: #666; margin-bottom: 25px;">Order: '.htmlspecialchars($_POST['order_ref']).'</p>
|
||||
<div style="display: flex; gap: 10px; justify-content: center;">
|
||||
<button onclick="printDiv(\'excel_table\')" class="btn alt" style="padding: 12px 30px;"><i class="fa-solid fa-print"></i></button>
|
||||
<button onclick="closeSuccessModal()" class="btn" style="padding: 12px 30px;">✓</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
if ($_GET['success_msg'] == 1) {
|
||||
@@ -147,6 +168,12 @@ $view = '
|
||||
<a href="index.php?page=equipments" class="btn alt mar-right-2">←</a>
|
||||
';
|
||||
|
||||
if ($update_allowed === 1){
|
||||
$print_btn_class = ($output_excel_display != '') ? 'btn' : 'btn alt';
|
||||
$view .= '<button class="'.$print_btn_class.' mar-right-2" onclick="printDiv(\'excel_table\')"><i class="fa-solid fa-print"></i></button>';
|
||||
$view .= '<input type="submit" form="mass_update_form" id="mass_update_submit" value="💾+" onclick="return confirm(\'".$mass_update_confirm_message."\')" class="btn">';
|
||||
}
|
||||
|
||||
$view .= '</div>';
|
||||
|
||||
if (isset($success_msg)){
|
||||
@@ -157,7 +184,7 @@ if (isset($success_msg)){
|
||||
</div>';
|
||||
}
|
||||
|
||||
$view .= '<form action="" method="post">
|
||||
$view .= '<form action="" method="post" id="mass_update_form">
|
||||
<div class="content-block-wrapper">
|
||||
';
|
||||
|
||||
@@ -170,80 +197,72 @@ $soldto_dropdown = listPartner('soldto',$_SESSION['permission'],'','yes');
|
||||
$shipto_dropdown = listPartner('shipto',$_SESSION['permission'],'','');
|
||||
$location_dropdown = listPartner('location',$_SESSION['permission'],'','');
|
||||
|
||||
$view .='<div class="content-block order-details">
|
||||
$view .='<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-user fa-sm"></i>'.$mass_update_partners.'
|
||||
</div>';
|
||||
<i class="fa-solid fa-user fa-sm"></i>
|
||||
</div>
|
||||
<div class="form responsive-width-100" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px;">';
|
||||
|
||||
// SHOW SALESID and SOLDTO ONLY TO ADMIN
|
||||
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
|
||||
$view .='<div class="order-detail">
|
||||
<h3>'.$general_salesid.'</h3>
|
||||
<p>'.$salesid_dropdown.'</p>
|
||||
$view .='<div>
|
||||
<label for="salesid">'.$general_salesid.'</label>
|
||||
'.$salesid_dropdown.'
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$general_soldto.'</h3>
|
||||
<p>'.$soldto_dropdown.'</p>
|
||||
<div>
|
||||
<label for="soldto">'.$general_soldto.'</label>
|
||||
'.$soldto_dropdown.'
|
||||
</div>';
|
||||
}
|
||||
$view .=' <div class="order-detail">
|
||||
<h3>'.$general_shipto.'</h3>
|
||||
<p>'.$shipto_dropdown.'</p>
|
||||
$view .=' <div>
|
||||
<label for="shipto">'.$general_shipto.'</label>
|
||||
'.$shipto_dropdown.'
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$general_location.'</h3>
|
||||
<p>'.$location_dropdown.'</p>
|
||||
<div>
|
||||
<label for="location">'.$general_location.'</label>
|
||||
'.$location_dropdown.'
|
||||
</div>
|
||||
<input type="hidden" name="section" value="">
|
||||
</div>';
|
||||
<div>
|
||||
<label for="order_ref">'.$equipment_label11.'</label>
|
||||
<input id="order_ref" type="text" name="order_ref" required>
|
||||
</div>
|
||||
<div>
|
||||
<label for="status">'.$equipment_label3.'</label>
|
||||
<select id="status" name="status" required>';
|
||||
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
|
||||
$view .= '<option value="0">'.$status0_text .'</option>
|
||||
<option value="1">'.$status1_text .'</option>
|
||||
<option value="2">'.$status2_text .'</option>';
|
||||
}
|
||||
$view .= '
|
||||
<option value="3" selected>'.$status3_text .'</option>
|
||||
<option value="4">'.$status4_text .'</option>
|
||||
<option value="5">'.$status5_text .'</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-circle-info"></i>
|
||||
</div>
|
||||
<div class="form responsive-width-100" style="margin-top: 20px;">
|
||||
<label for="excel_data">'.$paste_excel_h3.' <span id="count" style="font-weight: normal; color: #666;"></span></label>
|
||||
<textarea id="excel_data" name="excel_data" onkeydown="countLines()" style="width:100%;height:200px; font-family: monospace;" placeholder="'.$paste_excel_1.' '.$paste_excel_2.'"></textarea>
|
||||
|
||||
$view .= ' <div class="content-block order-details">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-circle-info"></i></i>'.$mass_update_input.'
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3><label for="status">'.$equipment_label11.'</label></h3>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<input id="name" type="text" name="order_ref" required>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3><label for="status">'.$equipment_label3.'</label></h3>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<select id="status" name="status" required>';
|
||||
if ($_SESSION['permission'] == 3 || $_SESSION['permission'] == 4){
|
||||
$view .= '<option value="0">'.$status0_text .'</option>
|
||||
<option value="1">'.$status1_text .'</option>
|
||||
<option value="2">'.$status2_text .'</option>';
|
||||
}
|
||||
$view .= '
|
||||
<option value="3" selected>'.$status3_text .'</option>
|
||||
<option value="4">'.$status4_text .'</option>
|
||||
<option value="5">'.$status5_text .'</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<h3>'.$paste_excel_h3.'</h3><h3 id="count"><h3>
|
||||
</div>
|
||||
<div class="order-detail">
|
||||
<textarea id="excel_data" name="excel_data" onkeydown="countLines()" style="width:100%;height:150px;" placeholder="'.$paste_excel_1.' '.$paste_excel_2.'"></textarea>
|
||||
</div>
|
||||
<input type="submit" id="mass_update_submit" value="<i class="fas fa-level-down-alt fa-rotate-90"></i>" onclick="return confirm(\''.$mass_update_confirm_message.'\')" class="btn">
|
||||
';
|
||||
$view .='
|
||||
<input type="hidden" name="section" value="">
|
||||
</div>
|
||||
';
|
||||
</div>';
|
||||
|
||||
$view .= '</form>';
|
||||
|
||||
$view .= '</div></div>';
|
||||
if ($update_allowed === 1){
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header" style="margin-bottom: 40px;border-bottom: 0px;">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.$tab3.' '.$total_summary.'
|
||||
<button class="btn" style="float:inline-end;" onclick="printDiv(\'excel_table\')">Print</button>
|
||||
</div>
|
||||
$view .= '<div class="tabs">
|
||||
<a href="#"><i class="fa-solid fa-bars fa-sm"></i>'.$tab3.' '.$total_summary.'</a>
|
||||
</div>
|
||||
<div class="content-block tab-content" style="display: none;">
|
||||
<div class="table order-table" id="excel_table">
|
||||
'.($order_header ?? '' ).'
|
||||
'.$output_excel_display.'
|
||||
@@ -257,8 +276,26 @@ if ($update_allowed === 1){
|
||||
//OUTPUT
|
||||
echo $view;
|
||||
|
||||
// Output success modal if exists
|
||||
echo $success_modal;
|
||||
|
||||
echo '
|
||||
<script>
|
||||
function closeSuccessModal() {
|
||||
document.getElementById("successModal").style.display = "none";
|
||||
}
|
||||
|
||||
// Ensure log section starts closed
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const tabs = document.querySelectorAll(".tabs a");
|
||||
const tabContents = document.querySelectorAll(".tab-content");
|
||||
|
||||
tabs.forEach(tab => tab.classList.remove("active"));
|
||||
tabContents.forEach(content => {
|
||||
content.classList.remove("active");
|
||||
content.style.display = "none";
|
||||
});
|
||||
});
|
||||
|
||||
function countLines(){
|
||||
let button = document.getElementById("mass_update_submit");
|
||||
|
||||
Reference in New Issue
Block a user