{"id":20,"date":"2026-05-22T16:54:56","date_gmt":"2026-05-22T13:24:56","guid":{"rendered":"https:\/\/mpakat.ir\/?page_id=20"},"modified":"2026-05-27T14:21:37","modified_gmt":"2026-05-27T10:51:37","slug":"20-2","status":"publish","type":"page","link":"https:\/\/mpakat.ir\/","title":{"rendered":"\u0635\u0641\u062d\u0647 \u0627\u0635\u0644\u06cc="},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/chart.js\"><\/script>\n\n    <script>\n        \/\/ \ud83c\udf1f \u0641\u0631\u0627\u0631 \u0627\u0632 \u0642\u0627\u0644\u0628 \u0648\u0631\u062f\u067e\u0631\u0633 \ud83c\udf1f\n        document.addEventListener('DOMContentLoaded', function() {\n            const appEnv = document.querySelector('.ios-app-env');\n            if (appEnv && document.body) {\n                document.body.appendChild(appEnv);\n                document.body.style.margin = '0';\n                document.body.style.overflow = 'hidden';\n                document.documentElement.style.overflow = 'hidden';\n            }\n        });\n\n        const manifestObj = {\n            \"name\": \"\u0633\u06cc\u0633\u062a\u0645 \u0645\u062f\u06cc\u0631\u06cc\u062a \u0627\u0646\u0628\u0627\u0631\",\n            \"short_name\": \"\u0627\u0646\u0628\u0627\u0631\",\n            \"start_url\": window.location.pathname,\n            \"display\": \"standalone\",\n            \"background_color\": \"#F2F2F7\",\n            \"theme_color\": \"#007AFF\",\n            \"icons\": [{\n                \"src\": \"https:\/\/mpakat.ir\/wp-content\/uploads\/2026\/06\/cropped-1780345157811.png\",\n                \"sizes\": \"512x512\",\n                \"type\": \"image\/png\",\n                \"purpose\": \"any maskable\"\n            }]\n        };\n        const manifestString = JSON.stringify(manifestObj);\n        const manifestUrl = 'data:application\/manifest+json;charset=utf-8,' + encodeURIComponent(manifestString);\n        const linkTag = document.createElement('link');\n        linkTag.rel = 'manifest';\n        linkTag.href = manifestUrl;\n        document.head.appendChild(linkTag);\n\n        if ('serviceWorker' in navigator) {\n            window.addEventListener('load', function() {\n                const swCode = \"self.addEventListener('install', (e) => { self.skipWaiting(); }); self.addEventListener('activate', (e) => { e.waitUntil(clients.claim()); }); self.addEventListener('fetch', (e) => { });\";\n                const blob = new Blob([swCode], {type: 'application\/javascript'});\n                const swUrl = URL.createObjectURL(blob);\n                navigator.serviceWorker.register(swUrl).catch(function(err) {});\n            });\n        }\n    <\/script>\n\n    <div class=\"ios-app-env\" dir=\"rtl\">\n        <div class=\"ios-container\" id=\"pm-main-app-container\">\n            <div class=\"ios-header\">\n                <div class=\"header-titles\">\n                    <h1 class=\"ios-large-title\">\u0627\u0646\u0628\u0627\u0631 \u0645\u062d\u0635\u0648\u0644\u0627\u062a<\/h1>\n                    <p class=\"ios-subtitle\">\u0633\u06cc\u0633\u062a\u0645 \u0645\u062f\u06cc\u0631\u06cc\u062a \u0645\u0648\u062c\u0648\u062f\u06cc \u0647\u0648\u0634\u0645\u0646\u062f<\/p>\n                <\/div>\n                <div class=\"header-actions\">\n                                            <a href=\"https:\/\/mpakat.ir\/wp-login.php?redirect_to=https%3A%2F%2Fmpakat.ir%2F\" class=\"ios-btn-login\">\u0648\u0631\u0648\u062f \u0628\u0647 \u0633\u06cc\u0633\u062a\u0645<\/a>\n                                    <\/div>\n            <\/div>\n\n            <div class=\"ios-toolbar\" id=\"pm-sys-toolbar\">\n                <div class=\"ios-search-bar\" id=\"pm-sys-search-box\">\n                    <span class=\"search-icon\">\ud83d\udd0d<\/span>\n                    <input type=\"text\" id=\"pm-search\" placeholder=\"\u062c\u0633\u062a\u062c\u0648 \u0645\u062d\u0635\u0648\u0644 \u06cc\u0627 \u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc...\">\n                <\/div>\n                \n                <button class=\"ios-btn-print\" onclick=\"refreshApp()\" title=\"\u0628\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc \u062f\u0627\u062f\u0647\u200c\u0647\u0627\">\n                    <span>\ud83d\udd04<\/span> \u0628\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc\n                <\/button>\n\n                <button id=\"pm-btn-add-front\" class=\"ios-btn-admin-add\" style=\"display:none;\" onclick=\"openFrontAdd()\">\n                    <span>\u2795<\/span> \u0627\u0641\u0632\u0648\u062f\u0646 \u06a9\u0627\u0644\u0627\n                <\/button>\n                <button id=\"pm-btn-reports-front\" class=\"ios-btn-admin-report\" style=\"display:none;\" onclick=\"loadAndOpenReports()\">\n                    <span>\ud83d\udccb<\/span> \u06af\u0632\u0627\u0631\u0634\u0627\u062a\n                <\/button>\n                \n                <button id=\"pm-btn-print\" class=\"ios-btn-print\" onclick=\"window.print()\">\n                    <span>\ud83d\udda8\ufe0f<\/span> \u0686\u0627\u067e \/ PDF\n                <\/button>\n            <\/div>\n\n            <div id=\"pm-category-pills\" class=\"ios-cat-pills\"><\/div>\n            <div id=\"pm-loader\" class=\"ios-loader\"><div class=\"ios-spinner\"><\/div><\/div>\n            <div id=\"pm-grouped-container\" style=\"display:none; width: 100%;\"><\/div>\n\n            <div id=\"pm-chart-section\" class=\"ios-chart-section\">\n                <div class=\"chart-header-row\">\n                    <h3 class=\"ios-section-title\">\u0622\u0645\u0627\u0631 \u06a9\u0644\u06cc \u0627\u0646\u0628\u0627\u0631<\/h3>\n                    <div class=\"ios-segmented-control\">\n                        <button class=\"seg-btn active\" data-period=\"daily\">\u0631\u0648\u0632\u0627\u0646\u0647<\/button>\n                        <button class=\"seg-btn\" data-period=\"monthly\">\u0645\u0627\u0647\u0627\u0646\u0647<\/button>\n                        <button class=\"seg-btn\" data-period=\"yearly\">\u0633\u0627\u0644\u0627\u0646\u0647<\/button>\n                    <\/div>\n                <\/div>\n                <div class=\"chart-canvas-wrap\"><canvas id=\"pm-chart-canvas\"><\/canvas><\/div>\n                <div id=\"pm-chart-details\" class=\"ios-chart-details\">\u0628\u0631\u0627\u06cc \u0645\u0634\u0627\u0647\u062f\u0647 \u0644\u06cc\u0633\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0648\u0627\u0631\u062f\/\u062e\u0627\u0631\u062c \u0634\u062f\u0647\u060c \u06cc\u06a9 \u0646\u0642\u0637\u0647 \u0627\u0632 \u0646\u0645\u0648\u062f\u0627\u0631 \u0631\u0627 \u0644\u0645\u0633 \u06a9\u0646\u06cc\u062f.<\/div>\n            <\/div>\n        <\/div>\n        \n        <div id=\"pm-access-denied\" style=\"display:none; text-align:center; padding: 100px 20px;\">\n            <div style=\"font-size: 80px; margin-bottom: 20px;\">\ud83d\udd12<\/div>\n            <h2 style=\"font-size: 28px; font-weight: 800; color: #1C1C1E;\">\u062f\u0633\u062a\u0631\u0633\u06cc \u0645\u062d\u062f\u0648\u062f<\/h2>\n            <p style=\"color: #8E8E93; font-size: 16px;\">\u0646\u0645\u0627\u06cc\u0634 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0627\u0646\u0628\u0627\u0631 \u0628\u0631\u0627\u06cc \u0627\u0641\u0631\u0627\u062f \u063a\u06cc\u0631\u0645\u062c\u0627\u0632 \u0645\u0633\u062f\u0648\u062f \u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>\n            <br><a href=\"https:\/\/mpakat.ir\/wp-login.php?redirect_to=https%3A%2F%2Fmpakat.ir%2F\" class=\"ios-btn-login\" style=\"padding: 15px 30px; font-size:18px;\">\u0648\u0631\u0648\u062f \u0628\u0647 \u0633\u06cc\u0633\u062a\u0645<\/a>\n        <\/div>\n\n        <div id=\"pm-print-table\"><\/div>\n        <div id=\"pm-toast-container\"><\/div>\n\n        <!-- PWA Install Prompt -->\n        <div id=\"pwa-install-prompt\" class=\"ios-install-prompt\" style=\"display:none;\">\n            <div class=\"ios-install-content\">\n                <img decoding=\"async\" src=\"https:\/\/mpakat.ir\/wp-content\/uploads\/2026\/06\/cropped-1780345157811.png\" class=\"ios-install-icon\" alt=\"App Icon\">\n                <div class=\"ios-install-text\">\n                    <h4>\u0646\u0635\u0628 \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646 \u0627\u0646\u0628\u0627\u0631<\/h4>\n                    <p>\u0628\u0631\u0627\u06cc \u062f\u0633\u062a\u0631\u0633\u06cc \u0633\u0631\u06cc\u0639\u200c\u062a\u0631\u060c \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646 \u0627\u0646\u0628\u0627\u0631 \u0631\u0627 \u0628\u0647 \u0635\u0641\u062d\u0647 \u0627\u0635\u0644\u06cc \u062e\u0648\u062f \u0627\u0636\u0627\u0641\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n                <\/div>\n                <button id=\"pwa-install-btn\" class=\"ios-btn-install\">\u0646\u0635\u0628<\/button>\n                <button id=\"pwa-close-btn\" class=\"ios-btn-close\">\u2715<\/button>\n            <\/div>\n        <\/div>\n\n        <!-- \u0641\u0631\u0627\u0646\u062a\u200c\u0627\u0646\u062f Modal: \u0627\u0641\u0632\u0648\u062f\u0646 \u0648 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u067e\u0627\u06a9\u062a -->\n        <div id=\"modal-add-packet\" class=\"ios-front-modal-overlay\">\n            <div class=\"ios-front-modal-box\">\n                <div style=\"display:flex; justify-content:space-between; margin-bottom:20px;\">\n                    <h3 id=\"fm_modal_title\" style=\"margin:0; font-size:20px; font-weight:800;\">\u0627\u0641\u0632\u0648\u062f\u0646 \u06a9\u0627\u0644\u0627\u06cc \u062c\u062f\u06cc\u062f<\/h3>\n                    <button class=\"ios-btn-close\" onclick=\"closeFrontModal('modal-add-packet')\">\u2715<\/button>\n                <\/div>\n                <input type=\"hidden\" id=\"fm_edit_id\" value=\"0\">\n                <div class=\"ios-form-group\">\n                    <input type=\"text\" id=\"fm_add_name\" class=\"ios-front-input\" placeholder=\"\u0646\u0627\u0645 \u0645\u062d\u0635\u0648\u0644 (\u0645\u062b\u0627\u0644: \u067e\u0627\u06a9\u062a \u0622\u0628\u06cc)\">\n                <\/div>\n                <div class=\"ios-form-group\">\n                    <input type=\"text\" id=\"fm_add_cat\" class=\"ios-front-input\" placeholder=\"\u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc (\u0645\u062b\u0627\u0644: \u067e\u0627\u06a9\u062a\u200c\u0647\u0627)\">\n                <\/div>\n                <div style=\"display:flex; gap:10px;\">\n                    <select id=\"fm_add_color\" class=\"ios-front-input\" style=\"flex:1;\">\n                        <option value=\"\u0622\u0628\u06cc\">\u0622\u0628\u06cc<\/option><option value=\"\u0642\u0631\u0645\u0632\">\u0642\u0631\u0645\u0632<\/option><option value=\"\u0645\u0634\u06a9\u06cc\">\u0645\u0634\u06a9\u06cc<\/option>\n                        <option value=\"\u0637\u0644\u0627\u06a9\u0648\u0628\">\u0637\u0644\u0627\u06a9\u0648\u0628<\/option><option value=\"\u0633\u0628\u0632\u06a9\u0648\u0628\">\u0633\u0628\u0632\u06a9\u0648\u0628<\/option><option value=\"\u0633\u0627\u062f\u0647\" selected>\u0628\u062f\u0648\u0646 \u0631\u0646\u06af<\/option>\n                    <\/select>\n                    <select id=\"fm_add_barcode\" class=\"ios-front-input\" style=\"flex:1;\">\n                        <option value=\"0\" selected>\u0628\u062f\u0648\u0646 \u0628\u0627\u0631\u06a9\u062f<\/option><option value=\"1\">\u0628\u0627\u0631\u06a9\u062f \u062f\u0627\u0631\u062f<\/option>\n                    <\/select>\n                <\/div>\n                <div class=\"ios-form-group\">\n                    <textarea id=\"fm_add_desc\" class=\"ios-front-input\" rows=\"2\" placeholder=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u06a9\u0648\u062a\u0627\u0647 (\u0627\u062e\u062a\u06cc\u0627\u0631\u06cc)\"><\/textarea>\n                <\/div>\n                <div style=\"display:flex; gap:10px;\">\n                    <input type=\"number\" id=\"fm_add_qty\" class=\"ios-front-input\" placeholder=\"\u0645\u0648\u062c\u0648\u062f\u06cc \u0627\u0648\u0644\u06cc\u0647\" style=\"flex:1;\">\n                    <input type=\"number\" id=\"fm_add_min\" class=\"ios-front-input\" placeholder=\"\u062d\u062f \u0636\u0631\u0631 (\u0645\u062b\u0627\u0644: 5)\" style=\"flex:1;\">\n                <\/div>\n                <div style=\"display:flex; gap:10px; margin-top:10px;\">\n                    <button id=\"fm_submit_btn\" onclick=\"submitFrontPacket()\" style=\"flex:2; background:#007AFF; color:#fff; border:none; padding:15px; border-radius:14px; font-size:16px; font-weight:700; cursor:pointer;\">\u0630\u062e\u06cc\u0631\u0647 \u06a9\u0627\u0644\u0627<\/button>\n                    <button id=\"fm_delete_btn\" onclick=\"deleteFrontPacket()\" style=\"display:none; flex:1; background:#FF3B30; color:#fff; border:none; padding:15px; border-radius:14px; font-size:16px; font-weight:700; cursor:pointer;\">\u062d\u0630\u0641 \u06a9\u0627\u0644\u0627<\/button>\n                <\/div>\n            <\/div>\n        <\/div>\n\n        <!-- \u0641\u0631\u0627\u0646\u062a\u200c\u0627\u0646\u062f Modal: \u06af\u0632\u0627\u0631\u0634\u0627\u062a -->\n        <div id=\"modal-reports\" class=\"ios-front-modal-overlay\">\n            <div class=\"ios-front-modal-box\" id=\"modal-reports-inner-box\">\n                <div style=\"display:flex; justify-content:space-between; margin-bottom:15px; align-items:center;\">\n                    <h3 style=\"margin:0; font-size:20px; font-weight:800;\">\u06af\u0632\u0627\u0631\u0634\u0627\u062a \u0632\u0646\u062f\u0647 \u0627\u0646\u0628\u0627\u0631<\/h3>\n                    <div style=\"display:flex; gap:10px;\">\n                        <button id=\"fm_clear_all_logs_btn\" onclick=\"clearAllLogsFront()\" style=\"display:none; background:#FF3B30; color:#fff; border:none; padding:6px 12px; border-radius:8px; font-size:12px; font-weight:bold; cursor:pointer;\">\ud83d\uddd1\ufe0f \u067e\u0627\u06a9 \u06a9\u0631\u062f\u0646 \u06a9\u0644 \u0622\u0645\u0627\u0631<\/button>\n                        <button class=\"ios-btn-close\" onclick=\"closeFrontModal('modal-reports')\">\u2715<\/button>\n                    <\/div>\n                <\/div>\n                <div id=\"front-reports-content\" style=\"overflow-x:auto; max-height: 60vh;\">\n                    <div class=\"ios-loader\"><div class=\"ios-spinner\"><\/div><\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <style>\n        body, html { overflow: hidden !important; width: 100%; height: 100%; margin: 0; padding: 0; }\n        \n        \/* \ud83c\udf1f \u0631\u06cc\u0633\u067e\u0627\u0646\u0633\u06cc\u0648 \u0641\u0648\u0644\u200c\u0627\u0633\u06a9\u0631\u06cc\u0646 \u0645\u0637\u0644\u0642 - \u0641\u0631\u0627\u0631 \u06a9\u0627\u0645\u0644 \u0627\u0632 \u0642\u0627\u0644\u0628 \u0648\u0631\u062f\u067e\u0631\u0633 \ud83c\udf1f *\/\n        .ios-app-env {\n            position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;\n            width: 100vw !important; height: 100vh !important; height: 100dvh !important;\n            max-width: 100% !important; margin: 0 !important;\n            z-index: 2147483647 !important; \/* \u0628\u0627\u0644\u0627\u062a\u0631\u06cc\u0646 \u0633\u0637\u062d \u0645\u0645\u06a9\u0646 *\/\n            overflow-y: auto !important; overflow-x: hidden !important;\n            font-family: -apple-system, BlinkMacSystemFont, \"SF Pro Text\", \"Segoe UI\", Roboto, sans-serif;\n            background-color: #F2F2F7 !important; \n            padding: 40px 5vw 80px 5vw !important; \n            box-sizing: border-box !important; color: #1C1C1E;\n            display: block !important;\n        }\n\n        .ios-container { \n            width: 100% !important; \n            max-width: 1800px !important; \n            margin: 0 auto !important; \n            box-sizing: border-box !important; \n            display: flex; flex-direction: column;\n        }\n        \n        .ios-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; width: 100%; }\n        .ios-large-title { font-size: 38px; font-weight: 800; margin: 0; letter-spacing: -1px; }\n        .ios-subtitle { font-size: 15px; color: #8E8E93; margin: 4px 0 0 0; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;}\n\n        .ios-btn-login {\n            background: #007AFF; color: #FFF; padding: 12px 24px; border-radius: 20px;\n            text-decoration: none; font-weight: 600; font-size: 15px; box-shadow: 0 4px 14px rgba(0, 122, 255, 0.3); transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); display:inline-block;\n        }\n        .ios-btn-login:active { transform: scale(0.92); }\n        .ios-badge { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 20px; font-size: 14px; font-weight: 600; background: rgba(0, 122, 255, 0.1); color: #007AFF; }\n\n        .ios-toolbar { display: flex; gap: 12px; margin-bottom: 15px; flex-wrap: wrap; width: 100%;}\n        .ios-search-bar { flex: 1; min-width: 250px; position: relative; background: rgba(227, 227, 232, 0.8); border-radius: 16px; display: flex; align-items: center; padding: 0 16px; backdrop-filter: blur(10px);}\n        .ios-search-bar input { width: 100%; background: transparent; border: none; padding: 14px 10px 14px 30px; font-size: 17px; outline: none; font-family: inherit; font-weight: 500; color:#1C1C1E;}\n        .search-icon { position: absolute; left: 16px; color: #8E8E93; font-size: 16px; }\n        \n        .ios-btn-print {\n            background: #FFF; border: none; padding: 12px 20px; border-radius: 16px; font-size: 15px; font-weight: 600; color: #007AFF; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.04); transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 6px; white-space: nowrap;\n        }\n        .ios-btn-print:active { background: #E5E5EA; transform: scale(0.92); }\n\n        .ios-btn-admin-add {\n            background: #34C759; color: #FFF; border: none; padding: 12px 20px; border-radius: 16px; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 10px rgba(52,199,89,0.3); transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 6px; white-space: nowrap;\n        }\n        .ios-btn-admin-add:active { transform: scale(0.92); }\n\n        .ios-btn-admin-report {\n            background: #FF9500; color: #FFF; border: none; padding: 12px 20px; border-radius: 16px; font-size: 15px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 10px rgba(255,149,0,0.3); transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 6px; white-space: nowrap;\n        }\n        .ios-btn-admin-report:active { transform: scale(0.92); }\n\n\n        .ios-cat-pills { display: flex; overflow-x: auto; gap: 8px; margin-bottom: 30px; padding-bottom: 5px; -ms-overflow-style: none; scrollbar-width: none; width: 100%;}\n        .ios-cat-pills::-webkit-scrollbar { display: none; }\n        .ios-pill { padding: 10px 20px; background: #E5E5EA; border-radius: 20px; border: none; white-space: nowrap; font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s; color: #1C1C1E; font-family: inherit;}\n        .ios-pill.active { background: #007AFF; color: #FFF; box-shadow: 0 4px 12px rgba(0,122,255,0.3); }\n\n        .ios-loader { text-align: center; padding: 60px; width: 100%;}\n        .ios-spinner { width: 30px; height: 30px; border: 3px solid #D1D1D6; border-top-color: #007AFF; border-radius: 50%; animation: ios-spin 1s linear infinite; margin: 0 auto; }\n        @keyframes ios-spin { 100% { transform: rotate(360deg); } }\n\n        \/* \ud83c\udf1f \u0627\u0633\u062a\u0627\u06cc\u0644 \u06af\u0631\u06cc\u062f \u062f\u0627\u06cc\u0646\u0627\u0645\u06cc\u06a9 \u06f5.\u06f9.\u06f0 \ud83c\udf1f *\/\n        .ios-category-group { margin-bottom: 40px; width: 100%; }\n        .ios-section-title { font-size: 20px; font-weight: 700; margin: 0 0 16px 5px; color: #1C1C1E; text-align: right;}\n        \n        .ios-grid { \n            display: grid !important; \n            grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)) !important; \n            gap: 24px !important; \n            justify-content: start !important; \n            width: 100% !important;\n        }\n        \n        .ios-card {\n            background: rgba(255, 255, 255, 0.7); border-radius: 24px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); display: flex; flex-direction: column; align-items: center; justify-content: center; backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 1); transition: transform 0.2s, box-shadow 0.2s; box-sizing: border-box; width: 100%;\n        }\n        \n        .ios-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-direction: row-reverse; width: 100%;}\n        .ios-card-title { font-size: 18px; font-weight: 700; color: #1C1C1E; line-height: 1.3; text-align: right; flex: 1; display:flex; align-items:center; gap:5px;}\n        \n        .ios-color-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; flex-shrink: 0; }\n        .color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }\n        \n        .theme-blue { background: rgba(0, 122, 255, 0.1); color: #0056b3; }\n        .theme-blue .color-dot { background: linear-gradient(135deg, #007AFF, #0056b3); }\n        .theme-red { background: rgba(255, 59, 48, 0.1); color: #c81e14; }\n        .theme-red .color-dot { background: linear-gradient(135deg, #FF3B30, #c81e14); }\n        .theme-black { background: rgba(28, 28, 30, 0.1); color: #000; }\n        .theme-black .color-dot { background: linear-gradient(135deg, #1C1C1E, #000000); }\n        .theme-gold { background: rgba(255, 215, 0, 0.2); color: #a67c00; }\n        .theme-gold .color-dot { background: linear-gradient(135deg, #FFD700, #DAA520); }\n        .theme-green { background: rgba(52, 199, 89, 0.1); color: #248A3D; }\n        .theme-green .color-dot { background: linear-gradient(135deg, #34C759, #248A3D); }\n        .theme-none { background: #E5E5EA; color: #666; }\n        .theme-none .color-dot { background: #A1A1A6; }\n\n        .ios-qty-label { text-align: center; font-size: 13px; color: #8E8E93; font-weight: 600; margin-bottom: 2px;}\n        .qty-highlight { \n            font-size: 42px; font-weight: 900; background: linear-gradient(135deg, #007AFF, #34AADC); \n            -webkit-background-clip: text; -webkit-text-fill-color: transparent; \n            display: block; text-align: center; margin-bottom: 15px; line-height: 1; letter-spacing: -1px;\n        }\n        \n        .ios-controls { \n            display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; \n            background: #F2F2F7; border-radius: 24px; padding: 4px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);\n            width: 100%; box-sizing: border-box; gap: 5px;\n        }\n        .ios-btn-circle { width: 44px; height: 44px; border-radius: 20px; border: none; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 400; cursor: pointer; background: #FFF; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: 0.2s; flex-shrink: 0;}\n        .ios-btn-circle.minus { color: #FF3B30; }\n        .ios-btn-circle.plus { color: #34C759; }\n        .ios-btn-circle:active { transform: scale(0.88); background: #E5E5EA;}\n        .ios-step-input { flex: 1; width: 100%; min-width: 50px; height: 44px; border: none; background: transparent; text-align: center; font-size: 18px; font-weight: 700; color: #1C1C1E; outline: none; transition: 0.2s;}\n        .ios-step-input:focus { color: #007AFF;}\n        \n        .ios-qty-display { \n            text-align: center; font-size: 44px; font-weight: 900; width: 100%; margin-top: auto;\n            background: linear-gradient(135deg, #007AFF, #34AADC); \n            -webkit-background-clip: text; -webkit-text-fill-color: transparent; \n            display: block; line-height: 1; letter-spacing: -1px;\n        }\n\n        .ios-chart-section { background: #FFF; border-radius: 28px; padding: 25px; margin-top: 30px; box-shadow: 0 8px 24px rgba(0,0,0,0.03); width:100%; box-sizing:border-box;}\n        .chart-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px;}\n        .ios-segmented-control { display: flex; background: #E3E3E8; border-radius: 8px; padding: 2px; }\n        .seg-btn { background: transparent; border: none; padding: 6px 16px; font-size: 13px; font-weight: 600; border-radius: 6px; cursor: pointer; color: #3A3A3C; }\n        .seg-btn.active { background: #FFF; box-shadow: 0 2px 6px rgba(0,0,0,0.1); color: #000; }\n        .chart-canvas-wrap { height: 350px; width: 100%; position: relative; }\n        \n        .ios-chart-details { margin-top: 15px; padding: 15px; background: #F2F2F7; border-radius: 16px; font-size: 14px; color: #666; text-align: right; line-height: 1.6; border: 1px solid #E5E5EA; transition: 0.3s; }\n        .ios-chart-details h4 { margin: 0 0 10px 0; color: #1C1C1E; font-size: 16px; }\n        .ios-chart-details p { margin: 6px 0; }\n\n        #pm-toast-container { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); z-index: 9999999; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }\n        .ios-toast { background: rgba(28,28,30,0.85); backdrop-filter: blur(20px); color: #FFF; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 600; opacity: 0; transform: translateY(-20px) scale(0.9); transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: 0 10px 30px rgba(0,0,0,0.2); }\n        .ios-toast.show { opacity: 1; transform: translateY(0) scale(1); }\n\n        \/* PWA Prompt Styles *\/\n        .ios-install-prompt { position: fixed; bottom: 20px; left: 20px; right: 20px; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 20px; padding: 15px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 15px; z-index: 9999999; border: 1px solid rgba(255,255,255,0.5); animation: pwaSlideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }\n        @keyframes pwaSlideUp { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }\n        .ios-install-content { display: flex; width: 100%; align-items: center; gap: 15px; }\n        .ios-install-icon { width: 45px; height: 45px; border-radius: 12px; object-fit: cover; }\n        .ios-install-text { flex: 1; }\n        .ios-install-text h4 { margin: 0 0 5px 0; font-size: 15px; color: #000; font-weight: 700; }\n        .ios-install-text p { margin: 0; font-size: 12px; color: #666; line-height: 1.4; }\n        .ios-btn-install { background: #007AFF; color: #FFF; border: none; padding: 8px 16px; border-radius: 16px; font-weight: 600; font-size: 14px; cursor: pointer; }\n        .ios-btn-close { background: transparent; border: none; color: #999; font-size: 20px; cursor: pointer; padding: 0 5px; }\n\n        \/* \u0627\u0633\u062a\u0627\u06cc\u0644\u200c\u0647\u0627\u06cc \u0645\u0631\u0628\u0648\u0637 \u0628\u0647 Modal \u0641\u0631\u0627\u0646\u062a\u200c\u0627\u0646\u062f (\u0627\u0641\u0632\u0648\u062f\u0646 \u0648 \u0648\u06cc\u0631\u0627\u06cc\u0634) *\/\n        .ios-front-modal-overlay {\n            position: fixed !important; top:0 !important; left:0 !important; width:100vw !important; height:100vh !important;\n            background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);\n            z-index: 99999999 !important; display: flex; align-items: center; justify-content: center;\n            opacity: 0; visibility: hidden; transition: 0.3s;\n        }\n        .ios-front-modal-overlay.active { opacity: 1; visibility: visible; }\n        .ios-front-modal-box {\n            background: #FFF; padding: 25px; border-radius: 28px; width: 90%; max-width: 450px;\n            box-shadow: 0 20px 40px rgba(0,0,0,0.25); transform: translateY(50px) scale(0.95); transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);\n            max-height: 85vh; overflow-y: auto; text-align:right;\n        }\n        .ios-front-modal-overlay.active .ios-front-modal-box { transform: translateY(0) scale(1); }\n        #modal-reports-inner-box { max-width: 800px; }\n        .ios-front-input {\n            width: 100%; box-sizing:border-box; padding: 14px 15px; border-radius: 14px;\n            border: 1px solid #E5E5EA; background: #F2F2F7; font-family: inherit; font-size:15px; margin-bottom: 12px; outline:none; transition:0.2s;\n        }\n        .ios-front-input:focus { border-color: #007AFF; background: #FFF; box-shadow: 0 0 0 4px rgba(0,122,255,0.1); }\n        .front-reports-table { width: 100%; border-collapse: collapse; text-align: right; font-size:13px; }\n        .front-reports-table th, .front-reports-table td { padding: 12px; border-bottom: 1px solid #E5E5EA; white-space:nowrap;}\n\n        @media (min-width: 768px) {\n            .ios-install-prompt { left: auto; right: 30px; width: 350px; bottom: 30px; border-radius: 24px;}\n        }\n\n        \/* \u0645\u0648\u0628\u0627\u06cc\u0644 *\/\n        @media (max-width: 768px) {\n            .ios-app-env { padding: 20px 10px 60px 10px !important; }\n            .ios-header { flex-direction: column !important; align-items: center !important; text-align: center !important; gap: 15px !important; }\n            .header-titles, .header-actions { width: 100% !important; display: flex !important; flex-direction: column !important; align-items: center !important; }\n            .ios-toolbar { flex-direction: column !important; }\n            .ios-search-bar { width: 100% !important; box-sizing: border-box !important; }\n            .ios-btn-print, .ios-btn-admin-add, .ios-btn-admin-report { width: 100% !important; justify-content: center !important; padding: 14px !important; }\n            .ios-container { width: 100% !important; }\n            \n            .ios-grid { grid-template-columns: 1fr !important; justify-items: center !important; width: 100% !important;}\n            .ios-card { width: 100% !important; max-width: 400px !important; }\n            .ios-card-header { flex-direction: column !important; align-items: center !important; gap: 8px !important; justify-content: center !important;}\n            .ios-card-title { text-align: center !important; justify-content: center !important;}\n            .ios-section-title { text-align: center !important; width: 100% !important; margin-left: 0 !important; }\n            .chart-header-row { justify-content: center !important; }\n            .chart-canvas-wrap { height: 250px !important; }\n        }\n\n        #pm-print-table { display: none; }\n        @media print {\n            body * { visibility: hidden; }\n            #pm-print-table, #pm-print-table * { visibility: visible; }\n            #pm-print-table { position: absolute; left: 0; top: 0; width: 100%; display: block !important; direction: rtl; font-family: Tahoma, Arial, sans-serif !important; }\n            .ios-app-env { position: static !important; background: transparent !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; border: none !important; overflow: visible !important; height: auto !important;}\n            .ios-app-env > .ios-container { display: none !important; }\n        }\n    <\/style>\n\n    <script>\n    function openFrontModal(id) { document.getElementById(id).classList.add('active'); }\n    function closeFrontModal(id) { document.getElementById(id).classList.remove('active'); }\n\n    document.addEventListener('DOMContentLoaded', function() {\n        const ajaxUrl = 'https:\/\/mpakat.ir\/wp-admin\/admin-ajax.php';\n        let allPackets = [];\n        let canEdit = false;\n        let canManagePackets = false;\n        let canEditPackets = false;\n        let chartData = {};\n        let catOrder = {};\n        let sysSettings = {};\n        let activeChartTab = 'daily';\n        let theChart = null;\n        let currentFilter = 'all';\n        let isAdmin = false;\n\n        let deferredPrompt;\n        window.addEventListener('beforeinstallprompt', (e) => {\n            e.preventDefault();\n            let cooldownDays = parseInt(sysSettings.pwa_cooldown || 7);\n            let lastDismissed = localStorage.getItem('pm_pwa_dismissed');\n            if (lastDismissed) {\n                let daysPassed = (Date.now() - parseInt(lastDismissed)) \/ (1000 * 60 * 60 * 24);\n                if (daysPassed < cooldownDays) return;\n            }\n            deferredPrompt = e;\n            document.getElementById('pwa-install-prompt').style.display = 'flex';\n        });\n\n        document.getElementById('pwa-install-btn').addEventListener('click', async () => {\n            document.getElementById('pwa-install-prompt').style.display = 'none';\n            localStorage.setItem('pm_pwa_dismissed', Date.now());\n            if (deferredPrompt) {\n                deferredPrompt.prompt();\n                const { outcome } = await deferredPrompt.userChoice;\n                deferredPrompt = null;\n            }\n        });\n\n        document.getElementById('pwa-close-btn').addEventListener('click', () => {\n            document.getElementById('pwa-install-prompt').style.display = 'none';\n            localStorage.setItem('pm_pwa_dismissed', Date.now());\n        });\n\n        window.showToast = function(msg) {\n            const wrap = document.getElementById('pm-toast-container');\n            const el = document.createElement('div');\n            el.className = 'ios-toast'; el.innerText = msg;\n            wrap.appendChild(el);\n            setTimeout(() => el.classList.add('show'), 10);\n            setTimeout(() => { el.classList.remove('show'); setTimeout(() => el.remove(), 400); }, 3000);\n        }\n\n        function getThemeClass(colorName) {\n            if(colorName.includes('\u0622\u0628\u06cc')) return 'theme-blue';\n            if(colorName.includes('\u0642\u0631\u0645\u0632')) return 'theme-red';\n            if(colorName.includes('\u0645\u0634\u06a9\u06cc')) return 'theme-black';\n            if(colorName.includes('\u0637\u0644\u0627')) return 'theme-gold';\n            if(colorName.includes('\u0633\u0628\u0632')) return 'theme-green';\n            return 'theme-none';\n        }\n\n        window.refreshApp = function() {\n            document.getElementById('pm-grouped-container').style.display = 'none';\n            document.getElementById('pm-chart-section').style.display = 'none';\n            document.getElementById('pm-loader').style.display = 'block';\n            initApp(true);\n        };\n\n        window.initApp = function(isRefresh = false) {\n            const fd = new FormData(); fd.append('action', 'pm_get_data');\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r => r.json()).then(res => {\n                if(res.success) {\n                    if (res.data.access_denied) {\n                        document.getElementById('pm-main-app-container').style.display = 'none';\n                        document.getElementById('pm-access-denied').style.display = 'block';\n                        return;\n                    }\n\n                    allPackets = res.data.packets; \n                    canEdit = res.data.can_edit;\n                    canManagePackets = res.data.can_manage_packets;\n                    canEditPackets = res.data.can_edit_packets; \/\/ \u062f\u0633\u062a\u0631\u0633\u06cc \u0648\u06cc\u0631\u0627\u06cc\u0634 \u0648 \u062d\u0630\u0641\n                    chartData = res.data.chart; \n                    catOrder = res.data.cat_order || {};\n                    sysSettings = res.data.sys_settings || {};\n                    isAdmin = res.data.is_admin || false;\n                    \n                    const badgeContainer = document.getElementById('pm-auth-badge');\n                    if (badgeContainer) badgeContainer.innerHTML = canEdit ? '<span class=\"ios-badge\">\u2713 \u0645\u062f\u06cc\u0631 \u0627\u0646\u0628\u0627\u0631<\/span>' : '<span class=\"ios-badge\" style=\"background:rgba(255, 59, 48, 0.1);color:#FF3B30;\">\ud83d\udc41\ufe0f \u0641\u0642\u0637 \u0645\u0634\u0627\u0647\u062f\u0647<\/span>';\n                    \n                    \/\/ \u062f\u06a9\u0645\u0647 \u0648\u0631\u0648\u062f \u0628\u0647 \u0645\u06cc\u0632\u06a9\u0627\u0631 \u0628\u0627 \u06a9\u0646\u062a\u0631\u0644 \u062f\u0633\u062a\u0631\u0633\u06cc\n                    if (res.data.has_backend_access) {\n                        document.getElementById('pm-admin-btn').style.display = 'inline-block';\n                    }\n\n                    if(sysSettings.show_search === '0') {\n                        document.getElementById('pm-sys-search-box').style.display = 'none';\n                        document.getElementById('pm-category-pills').style.display = 'none';\n                    }\n                    if(sysSettings.show_print === '0') document.getElementById('pm-btn-print').style.display = 'none';\n                    \n                    if(sysSettings.show_chart === '0') {\n                        document.getElementById('pm-chart-section').style.display = 'none';\n                    } else {\n                        document.getElementById('pm-chart-section').style.display = 'block';\n                    }\n                    \n                    if(canManagePackets) document.getElementById('pm-btn-add-front').style.display = 'flex';\n                    if(res.data.can_view_reports) document.getElementById('pm-btn-reports-front').style.display = 'flex';\n\n                    \/\/ \u0646\u0645\u0627\u06cc\u0634 \u062f\u06a9\u0645\u0647 \u062d\u0630\u0641 \u06a9\u0644\u06cc \u06af\u0632\u0627\u0631\u0634\u0627\u062a \u0628\u0631\u0627\u06cc \u0627\u062f\u0645\u06cc\u0646\n                    if(isAdmin) {\n                        document.getElementById('fm_clear_all_logs_btn').style.display = 'inline-block';\n                    }\n\n                    renderCategoryPills(); \n                    renderGroupedGrid(); \n                    if(sysSettings.show_chart === '1') renderChart();\n                    \n                    document.getElementById('pm-loader').style.display = 'none';\n                    document.getElementById('pm-grouped-container').style.display = 'block';\n\n                    if (isRefresh) showToast('\ud83d\udd04 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u0628\u0631\u0648\u0632 \u0634\u062f');\n                }\n            });\n        }\n\n        document.getElementById('pm-search').addEventListener('input', renderGroupedGrid);\n\n        function renderCategoryPills() {\n            const pillsContainer = document.getElementById('pm-category-pills');\n            const uniqueCats = [...new Set(allPackets.map(p => p.category))];\n            uniqueCats.sort((a, b) => {\n                let orderA = catOrder[a] !== undefined ? parseInt(catOrder[a]) : 99;\n                let orderB = catOrder[b] !== undefined ? parseInt(catOrder[b]) : 99;\n                return (orderA !== orderB) ? orderA - orderB : a.localeCompare(b);\n            });\n            let pillsHtml = `<button class=\"ios-pill ${currentFilter === 'all' ? 'active' : ''}\" data-cat=\"all\">\u0647\u0645\u0647<\/button>`;\n            uniqueCats.forEach(cat => { pillsHtml += `<button class=\"ios-pill ${currentFilter === cat ? 'active' : ''}\" data-cat=\"${cat}\">${cat}<\/button>`; });\n            pillsContainer.innerHTML = pillsHtml;\n            pillsContainer.querySelectorAll('.ios-pill').forEach(btn => {\n                btn.addEventListener('click', (e) => {\n                    pillsContainer.querySelectorAll('.ios-pill').forEach(b => b.classList.remove('active'));\n                    e.target.classList.add('active'); currentFilter = e.target.dataset.cat; renderGroupedGrid();\n                });\n            });\n        }\n\n        function renderGroupedGrid() {\n            const term = document.getElementById('pm-search').value.toLowerCase();\n            const container = document.getElementById('pm-grouped-container');\n            container.innerHTML = '';\n            let filtered = allPackets.filter(p => (p.name.toLowerCase().includes(term) || p.category.toLowerCase().includes(term)) && (currentFilter === 'all' || p.category === currentFilter));\n\n            if(filtered.length === 0) {\n                container.innerHTML = '<p style=\"text-align:center; color:#8E8E93; font-weight:600;\">\u0645\u062d\u0635\u0648\u0644\u06cc \u06cc\u0627\u0641\u062a \u0646\u0634\u062f.<\/p>';\n                updatePrintTable([], {}, []); return;\n            }\n\n            const grouped = {};\n            filtered.forEach(p => { if(!grouped[p.category]) grouped[p.category] = []; grouped[p.category].push(p); });\n            const sortedCategories = Object.keys(grouped).sort((a, b) => {\n                let orderA = catOrder[a] !== undefined ? parseInt(catOrder[a]) : 99;\n                let orderB = catOrder[b] !== undefined ? parseInt(catOrder[b]) : 99;\n                return (orderA !== orderB) ? orderA - orderB : a.localeCompare(b);\n            });\n\n            sortedCategories.forEach(category => {\n                const groupDiv = document.createElement('div'); groupDiv.className = 'ios-category-group';\n                let cardsHtml = '';\n                grouped[category].forEach(p => {\n                    let controls = '';\n                    if(canEdit) {\n                        controls = `\n                            <div class=\"ios-qty-label\">\u0645\u0648\u062c\u0648\u062f\u06cc \u0641\u0639\u0644\u06cc<\/div>\n                            <span class=\"qty-highlight\" id=\"qty-lbl-${p.id}\">${p.quantity}<\/span>\n                            <div class=\"ios-controls\">\n                                <button class=\"ios-btn-circle plus\" onclick=\"doAction(${p.id}, 1)\">+<\/button>\n                                <input type=\"number\" class=\"ios-step-input\" id=\"step-${p.id}\" value=\"250\" onfocus=\"this.select()\">\n                                <button class=\"ios-btn-circle minus\" onclick=\"doAction(${p.id}, -1)\">\u2212<\/button>\n                            <\/div>`;\n                    } else { \n                        controls = `<div class=\"ios-qty-label\" style=\"margin-top:auto;\">\u0645\u0648\u062c\u0648\u062f\u06cc \u0641\u0639\u0644\u06cc<\/div><div class=\"ios-qty-display\" id=\"qty-lbl-${p.id}\">${p.quantity}<\/div>`; \n                    }\n                    \n                    let themeClass = getThemeClass(p.color_type);\n                    let colorBadge = `<div class=\"ios-color-badge ${themeClass}\" title=\"${p.color_type}\"><span class=\"color-dot\"><\/span>${p.color_type}<\/div>`;\n                    let barcodeBadge = p.has_barcode == '1' ? '<span title=\"\u0628\u0627\u0631\u06a9\u062f \u062f\u0627\u0631\u062f\" style=\"background:rgba(0,0,0,0.05); padding:2px 6px; border-radius:8px; font-size:11px; color:#555;\">\ud83c\udff7\ufe0f \u0628\u0627\u0631\u06a9\u062f<\/span>' : '';\n                    let descHtml = p.description ? `<div style=\"font-size:12px; color:#8E8E93; text-align:right; width:100%; margin-bottom:12px; line-height:1.4;\">${p.description}<\/div>` : '';\n                    \n                    \/\/ \u0646\u0645\u0627\u06cc\u0634 \u062f\u06a9\u0645\u0647 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u0641\u0642\u0637 \u0628\u0631\u0627\u06cc \u06a9\u0633\u06cc \u06a9\u0647 \u062f\u0633\u062a\u0631\u0633\u06cc \u0648\u06cc\u0631\u0627\u06cc\u0634 \u062f\u0627\u0631\u062f\n                    let editBtnHtml = canEditPackets ? `<button style=\"background:none; border:none; padding:0 0 0 10px; font-size:18px; cursor:pointer; color:#8E8E93;\" onclick=\"openFrontEdit(${p.id})\">\u2699\ufe0f<\/button>` : '';\n\n                    cardsHtml += `<div class=\"ios-card\"><div class=\"ios-card-header\"><div style=\"display:flex; align-items:center;\">${editBtnHtml}${colorBadge}<\/div><div class=\"ios-card-title\">${p.name} ${barcodeBadge}<\/div><\/div>${descHtml}${controls}<\/div>`;\n                });\n                groupDiv.innerHTML = `<h3 class=\"ios-section-title\">${category}<\/h3><div class=\"ios-grid\">${cardsHtml}<\/div>`;\n                container.appendChild(groupDiv);\n            });\n            \n            \/\/ \u062a\u0648\u0644\u06cc\u062f \u062a\u0627\u0631\u06cc\u062e \u0634\u0645\u0633\u06cc \u0628\u0631\u0627\u06cc PDF\n            const today = new Date();\n            const options = { year: 'numeric', month: '2-digit', day: '2-digit', calendar: 'persian' };\n            const todayJalali = today.toLocaleDateString('fa-IR', options);\n            updatePrintTable(filtered, grouped, sortedCategories, todayJalali);\n        }\n\n        function updatePrintTable(filtered, grouped, sortedCategories, todayJalali) {\n            let trs = '';\n            if(filtered.length === 0) { trs = '<tr><td colspan=\"7\" style=\"text-align:center; padding:20px;\">\u062e\u0627\u0644\u06cc<\/td><\/tr>'; } \n            else {\n                let rowIdx = 1;\n                sortedCategories.forEach(category => {\n                    grouped[category].forEach(p => {\n                        let has_bc = p.has_barcode == '1' ? '\u062f\u0627\u0631\u062f' : '\u0646\u062f\u0627\u0631\u062f';\n                        let desc = p.description ? p.description : '-';\n                        trs += `<tr>\n                            <td style=\"padding:10px; border:1px solid #CCC; text-align:center;\">${rowIdx}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC;\">${p.name}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC; text-align:center;\">${has_bc}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC; font-size:12px;\">${desc}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC; text-align:center;\">${p.color_type}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC;\">${p.category}<\/td>\n                            <td style=\"padding:10px; border:1px solid #CCC; text-align:center; font-weight:bold; font-size:16px;\">${p.quantity}<\/td>\n                        <\/tr>`;\n                        rowIdx++;\n                    });\n                });\n            }\n            document.getElementById('pm-print-table').innerHTML = `<div style=\"text-align:center; margin-bottom:20px;\"><h2 style=\"margin:0;\">\u06af\u0632\u0627\u0631\u0634 \u062c\u0627\u0645\u0639 \u0627\u0646\u0628\u0627\u0631<\/h2><p style=\"color:#666;\">\u062a\u0627\u0631\u06cc\u062e: ${todayJalali}<\/p><\/div><table style=\"width:100%; border-collapse:collapse; text-align:right; font-size:14px;\"><thead style=\"background:#E5E5EA;\"><tr><th style=\"padding:12px; border:1px solid #CCC; width:40px; text-align:center;\">\u0631\u062f\u06cc\u0641<\/th><th style=\"padding:12px; border:1px solid #CCC;\">\u0646\u0627\u0645 \u0645\u062d\u0635\u0648\u0644<\/th><th style=\"padding:12px; border:1px solid #CCC; text-align:center;\">\u0628\u0627\u0631\u06a9\u062f<\/th><th style=\"padding:12px; border:1px solid #CCC;\">\u062a\u0648\u0636\u06cc\u062d\u0627\u062a<\/th><th style=\"padding:12px; border:1px solid #CCC; text-align:center;\">\u0646\u0648\u0639 \/ \u0686\u0627\u067e<\/th><th style=\"padding:12px; border:1px solid #CCC;\">\u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc<\/th><th style=\"padding:12px; border:1px solid #CCC; text-align:center;\">\u0645\u0648\u062c\u0648\u062f\u06cc<\/th><\/tr><\/thead><tbody>${trs}<\/tbody><\/table>`;\n        }\n\n        window.doAction = function(id, sign) {\n            const stepInput = document.getElementById('step-' + id);\n            const qtyLabel = document.getElementById('qty-lbl-' + id);\n            let stepVal = parseInt(stepInput.value);\n            \n            if(isNaN(stepVal) || stepVal <= 0) { showToast('\u0645\u0642\u062f\u0627\u0631 \u0646\u0627\u0645\u0639\u062a\u0628\u0631 \u0627\u0633\u062a!'); return; }\n            \n            let changeAmount = stepVal * sign;\n            let currentQty = parseInt(qtyLabel.innerText);\n            \n            if(currentQty + changeAmount < 0) { \n                showToast('\u274c \u0645\u0648\u062c\u0648\u062f\u06cc \u06a9\u0627\u0641\u06cc \u0646\u06cc\u0633\u062a! (\u062d\u062f\u0627\u06a9\u062b\u0631 \u0642\u0627\u0628\u0644 \u06a9\u0633\u0631: ' + currentQty + ')');\n                return;\n            }\n\n            qtyLabel.style.opacity = '0.3';\n            const fd = new FormData(); fd.append('action', 'pm_update_qty'); fd.append('packet_id', id); fd.append('change', changeAmount);\n\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r => r.json()).then(res => {\n                qtyLabel.style.opacity = '1';\n                if(res.success) {\n                    qtyLabel.innerText = res.data.new_qty;\n                    const pIdx = allPackets.findIndex(x => x.id == id); if(pIdx > -1) allPackets[pIdx].quantity = res.data.new_qty;\n                    \n                    let actedAmount = Math.abs(changeAmount);\n                    showToast(`\u2713 \u0628\u0627 \u0645\u0648\u0641\u0642\u06cc\u062a ${actedAmount} \u0639\u062f\u062f ${sign > 0 ? '\u0627\u0636\u0627\u0641\u0647' : '\u06a9\u0645'} \u0634\u062f`);\n                    if(res.data.sms_triggered) showToast(res.data.sms_sent ? '\u26a0\ufe0f \u067e\u06cc\u0627\u0645 \u0628\u0644\u0647 \u0627\u0631\u0633\u0627\u0644 \u0634\u062f.' : '\u26a0\ufe0f \u062d\u062f \u0636\u0631\u0631 \u0631\u0633\u06cc\u062f.');\n                    \n                    const term = document.getElementById('pm-search').value.toLowerCase();\n                    const filtered = allPackets.filter(p => (p.name.toLowerCase().includes(term) || p.category.toLowerCase().includes(term)) && (currentFilter === 'all' || p.category === currentFilter));\n                    const grouped = {}; filtered.forEach(p => { if(!grouped[p.category]) grouped[p.category] = []; grouped[p.category].push(p); });\n                    const sortedCategories = Object.keys(grouped).sort((a,b) => { let oA = catOrder[a]!==undefined?parseInt(catOrder[a]):99; let oB = catOrder[b]!==undefined?parseInt(catOrder[b]):99; return (oA!==oB)?oA-oB:a.localeCompare(b); });\n                    \n                    const todayJalali = new Date().toLocaleDateString('fa-IR', { year: 'numeric', month: '2-digit', day: '2-digit', calendar: 'persian' });\n                    updatePrintTable(filtered, grouped, sortedCategories, todayJalali);\n\n                    if(sysSettings.show_chart === '1') {\n                        const fdChart = new FormData();\n                        fdChart.append('action', 'pm_get_data');\n                        fetch(ajaxUrl, { method: 'POST', body: fdChart }).then(r=>r.json()).then(r2 => { if(r2.success) { chartData = r2.data.chart; updateChart(); } });\n                    }\n                } else { showToast('\u062e\u0637\u0627: ' + res.data); }\n            }).catch(() => { qtyLabel.style.opacity = '1'; showToast('\u062e\u0637\u0627\u06cc \u0634\u0628\u06a9\u0647'); });\n        };\n\n        window.openFrontAdd = function() {\n            document.getElementById('fm_modal_title').innerText = '\u0627\u0641\u0632\u0648\u062f\u0646 \u06a9\u0627\u0644\u0627\u06cc \u062c\u062f\u06cc\u062f';\n            document.getElementById('fm_edit_id').value = '0';\n            document.getElementById('fm_add_name').value = '';\n            document.getElementById('fm_add_cat').value = '';\n            document.getElementById('fm_add_color').value = '\u0633\u0627\u062f\u0647';\n            document.getElementById('fm_add_barcode').value = '0';\n            document.getElementById('fm_add_desc').value = '';\n            document.getElementById('fm_add_qty').value = '';\n            document.getElementById('fm_add_min').value = '5';\n            document.getElementById('fm_delete_btn').style.display = 'none';\n            document.getElementById('fm_submit_btn').innerText = '\u0630\u062e\u06cc\u0631\u0647 \u06a9\u0627\u0644\u0627 \u062f\u0631 \u0627\u0646\u0628\u0627\u0631';\n            openFrontModal('modal-add-packet');\n        };\n\n        window.openFrontEdit = function(id) {\n            const p = allPackets.find(x => x.id == id);\n            if(!p) return;\n            document.getElementById('fm_modal_title').innerText = '\u0648\u06cc\u0631\u0627\u06cc\u0634: ' + p.name;\n            document.getElementById('fm_edit_id').value = p.id;\n            document.getElementById('fm_add_name').value = p.name;\n            document.getElementById('fm_add_cat').value = p.category;\n            document.getElementById('fm_add_color').value = p.color_type;\n            document.getElementById('fm_add_barcode').value = p.has_barcode;\n            document.getElementById('fm_add_desc').value = p.description;\n            document.getElementById('fm_add_qty').value = p.quantity;\n            document.getElementById('fm_add_min').value = p.min_qty;\n            document.getElementById('fm_delete_btn').style.display = 'block';\n            document.getElementById('fm_submit_btn').innerText = '\u0630\u062e\u06cc\u0631\u0647 \u062a\u063a\u06cc\u06cc\u0631\u0627\u062a';\n            openFrontModal('modal-add-packet');\n        };\n\n        window.submitFrontPacket = function() {\n            const editId = parseInt(document.getElementById('fm_edit_id').value || 0);\n            const name = document.getElementById('fm_add_name').value;\n            const cat = document.getElementById('fm_add_cat').value;\n            if(!name || !cat) { showToast('\u0646\u0627\u0645 \u0648 \u062f\u0633\u062a\u0647 \u0627\u0644\u0632\u0627\u0645\u06cc \u0627\u0633\u062a!'); return; }\n            \n            const fd = new FormData();\n            const action = editId > 0 ? 'pm_edit_packet_frontend' : 'pm_add_packet_frontend';\n            fd.append('action', action);\n            if(editId > 0) fd.append('edit_id', editId);\n            \n            fd.append('name', name);\n            fd.append('category', cat);\n            fd.append('color_type', document.getElementById('fm_add_color').value);\n            fd.append('has_barcode', document.getElementById('fm_add_barcode').value);\n            fd.append('description', document.getElementById('fm_add_desc').value);\n            fd.append('quantity', document.getElementById('fm_add_qty').value || 0);\n            fd.append('min_qty', document.getElementById('fm_add_min').value || 5);\n\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r => r.json()).then(res => {\n                if(res.success) {\n                    showToast(editId > 0 ? '\u2705 \u062a\u063a\u06cc\u06cc\u0631\u0627\u062a \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f' : '\u2705 \u06a9\u0627\u0644\u0627 \u0627\u0636\u0627\u0641\u0647 \u0634\u062f!');\n                    closeFrontModal('modal-add-packet');\n                    initApp(false); \n                } else { showToast('\u062e\u0637\u0627: ' + res.data); }\n            });\n        };\n\n        window.deleteFrontPacket = function() {\n            if(!confirm('\u0622\u06cc\u0627 \u0627\u0632 \u062d\u0630\u0641 \u0627\u06cc\u0646 \u06a9\u0627\u0644\u0627 \u0645\u0637\u0645\u0626\u0646 \u0647\u0633\u062a\u06cc\u062f\u061f (\u063a\u06cc\u0631\u0642\u0627\u0628\u0644 \u0628\u0627\u0632\u06af\u0634\u062a)')) return;\n            const editId = document.getElementById('fm_edit_id').value;\n            const fd = new FormData();\n            fd.append('action', 'pm_delete_packet_frontend');\n            fd.append('delete_id', editId);\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r => r.json()).then(res => {\n                if(res.success) {\n                    showToast('\ud83d\uddd1\ufe0f \u06a9\u0627\u0644\u0627 \u062d\u0630\u0641 \u0634\u062f!');\n                    closeFrontModal('modal-add-packet');\n                    initApp(false);\n                } else { showToast('\u062e\u0637\u0627: ' + res.data); }\n            });\n        };\n\n        window.loadAndOpenReports = function() {\n            openFrontModal('modal-reports');\n            const content = document.getElementById('front-reports-content');\n            content.innerHTML = '<div class=\"ios-loader\"><div class=\"ios-spinner\"><\/div><\/div>';\n            \n            const fd = new FormData(); fd.append('action', 'pm_get_reports_frontend');\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r => r.json()).then(res => {\n                if(res.success) {\n                    let trs = '';\n                    res.data.forEach(r => {\n                        trs += `<tr>\n                            <td>${r.date}<\/td>\n                            <td><strong>${r.packet}<\/strong><\/td>\n                            <td>${r.user}<\/td>\n                            <td>${r.action}<\/td>\n                            <td style=\"direction:ltr;\">${r.val}<\/td>\n                            <td style=\"text-align:center;\">\n                                <button onclick=\"deleteLogFront(${r.id})\" style=\"background:none;border:none;color:#FF3B30;font-size:16px;cursor:pointer;\" title=\"\u062d\u0630\u0641 \u0627\u06cc\u0646 \u06af\u0632\u0627\u0631\u0634\">\ud83d\uddd1\ufe0f<\/button>\n                            <\/td>\n                        <\/tr>`;\n                    });\n                    if(trs === '') trs = '<tr><td colspan=\"6\" style=\"text-align:center;\">\u06af\u0632\u0627\u0631\u0634\u06cc \u06cc\u0627\u0641\u062a \u0646\u0634\u062f.<\/td><\/tr>';\n                    content.innerHTML = `<table class=\"front-reports-table\"><thead><tr><th>\u062a\u0627\u0631\u06cc\u062e<\/th><th>\u0645\u062d\u0635\u0648\u0644<\/th><th>\u06a9\u0627\u0631\u0628\u0631<\/th><th>\u0639\u0645\u0644\u06cc\u0627\u062a<\/th><th>\u0645\u0642\u062f\u0627\u0631<\/th><th style=\"width:40px;\">\u062d\u0630\u0641<\/th><\/tr><\/thead><tbody>${trs}<\/tbody><\/table>`;\n                } else {\n                    content.innerHTML = `<p style=\"color:red; text-align:center;\">${res.data}<\/p>`;\n                }\n            });\n        };\n\n        window.deleteLogFront = function(logId) {\n            if(!confirm('\u0622\u06cc\u0627 \u0627\u0632 \u062d\u0630\u0641 \u0627\u06cc\u0646 \u06af\u0632\u0627\u0631\u0634 \u0645\u0637\u0645\u0626\u0646 \u0647\u0633\u062a\u06cc\u062f\u061f \u0646\u0645\u0648\u062f\u0627\u0631 \u0641\u0648\u0631\u0627\u064b \u0622\u067e\u062f\u06cc\u062a \u062e\u0648\u0627\u0647\u062f \u0634\u062f.')) return;\n            const fd = new FormData(); \n            fd.append('action', 'pm_delete_log'); \n            fd.append('log_id', logId);\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r=>r.json()).then(res=>{\n                if(res.success) { \n                    showToast('\u2705 \u06af\u0632\u0627\u0631\u0634 \u062d\u0630\u0641 \u0634\u062f'); \n                    loadAndOpenReports(); \/\/ \u0631\u0641\u0631\u0634 \u062c\u062f\u0648\u0644 \u06af\u0632\u0627\u0631\u0634\u0627\u062a\n                    initApp(false); \/\/ \u0631\u0641\u0631\u0634 \u0646\u0645\u0648\u062f\u0627\u0631\n                } else { \n                    showToast('\u062e\u0637\u0627: ' + res.data); \n                }\n            });\n        };\n\n        window.clearAllLogsFront = function() {\n            if(!confirm('\u0647\u0634\u062f\u0627\u0631: \u0622\u06cc\u0627 \u0627\u0632 \u062d\u0630\u0641 \u062a\u0645\u0627\u0645 \u06af\u0632\u0627\u0631\u0634\u0627\u062a \u0633\u06cc\u0633\u062a\u0645 \u0645\u0637\u0645\u0626\u0646 \u0647\u0633\u062a\u06cc\u062f\u061f \u0627\u06cc\u0646 \u0639\u0645\u0644\u06cc\u0627\u062a \u06a9\u0627\u0645\u0644\u0627\u064b \u063a\u06cc\u0631\u0642\u0627\u0628\u0644 \u0628\u0627\u0632\u06af\u0634\u062a \u0627\u0633\u062a.')) return;\n            const fd = new FormData(); \n            fd.append('action', 'pm_clear_all_logs');\n            fetch(ajaxUrl, { method: 'POST', body: fd }).then(r=>r.json()).then(res=>{\n                if(res.success) { \n                    showToast('\u2705 \u06a9\u0644 \u0622\u0645\u0627\u0631 \u067e\u0627\u06a9 \u0634\u062f'); \n                    loadAndOpenReports(); \n                    initApp(false); \n                } else { \n                    showToast('\u062e\u0637\u0627: ' + res.data); \n                }\n            });\n        };\n\n        function renderChart() {\n            const ctx = document.getElementById('pm-chart-canvas').getContext('2d');\n            const d = chartData[activeChartTab] || [];\n            \n            if (theChart) {\n                theChart.destroy(); \n            }\n\n            theChart = new Chart(ctx, {\n                type: 'line',\n                data: { \n                    labels: d.map(x => x.label), \n                    datasets: [\n                        { \n                            label: '\u0648\u0631\u0648\u062f (\u0627\u0641\u0632\u0627\u06cc\u0634)',\n                            data: d.map(x => x.total_in), \n                            borderColor: '#34C759', backgroundColor: 'rgba(52, 199, 89, 0.1)', \n                            borderWidth: 3, pointBackgroundColor: '#FFF', pointBorderColor: '#34C759', pointRadius: 4, fill: true, tension: 0.4 \n                        },\n                        { \n                            label: '\u062e\u0631\u0648\u062c (\u06a9\u0627\u0647\u0634)',\n                            data: d.map(x => x.total_out), \n                            borderColor: '#FF3B30', backgroundColor: 'rgba(255, 59, 48, 0.1)', \n                            borderWidth: 3, pointBackgroundColor: '#FFF', pointBorderColor: '#FF3B30', pointRadius: 4, fill: true, tension: 0.4 \n                        }\n                    ] \n                },\n                options: { \n                    responsive: true, maintainAspectRatio: false, \n                    onClick: (e, elements) => {\n                        if (elements.length > 0) {\n                            const dataIndex = elements[0].index;\n                            const rawData = chartData[activeChartTab][dataIndex];\n                            let html = `<h4>\ud83d\udcc5 \u062c\u0632\u0626\u06cc\u0627\u062a \u062a\u0627\u0631\u06cc\u062e: ${rawData.label}<\/h4>`;\n                            if (rawData.items_in && rawData.items_in.trim() !== '') html += `<p style=\"color:#248A3D\"><b>\ud83d\udce5 \u0648\u0627\u0631\u062f \u0634\u062f\u0647:<\/b> ${rawData.items_in}<\/p>`;\n                            if (rawData.items_out && rawData.items_out.trim() !== '') html += `<p style=\"color:#c81e14\"><b>\ud83d\udce4 \u062e\u0627\u0631\u062c \u0634\u062f\u0647:<\/b> ${rawData.items_out}<\/p>`;\n                            if (!rawData.items_in && !rawData.items_out) html += `<p>\u0647\u06cc\u0686 \u06a9\u0627\u0644\u0627\u06cc\u06cc \u062f\u0631 \u0627\u06cc\u0646 \u062a\u0627\u0631\u06cc\u062e \u062c\u0627\u0628\u062c\u0627 \u0646\u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>`;\n                            document.getElementById('pm-chart-details').innerHTML = html;\n                        }\n                    },\n                    plugins: { \n                        legend: { display: true, position: 'top', labels: { font: { family: 'inherit' } } },\n                        tooltip: { enabled: false } \n                    }, \n                    scales: { y: { beginAtZero: true, grid: { color: 'rgba(0,0,0,0.04)', drawBorder: false } }, x: { grid: { display: false } } } \n                }\n            });\n        }\n\n        function updateChart() {\n            if(!theChart) return;\n            const d = chartData[activeChartTab] || [];\n            theChart.data.labels = d.map(x => x.label);\n            theChart.data.datasets[0].data = d.map(x => x.total_in);\n            theChart.data.datasets[1].data = d.map(x => x.total_out);\n            theChart.update();\n            document.getElementById('pm-chart-details').innerHTML = '\u0628\u0631\u0627\u06cc \u0645\u0634\u0627\u0647\u062f\u0647 \u0644\u06cc\u0633\u062a \u0645\u062d\u0635\u0648\u0644\u0627\u062a \u0648\u0627\u0631\u062f\/\u062e\u0627\u0631\u062c \u0634\u062f\u0647\u060c \u06cc\u06a9 \u0646\u0642\u0637\u0647 \u0627\u0632 \u0646\u0645\u0648\u062f\u0627\u0631 \u0631\u0627 \u0644\u0645\u0633 \u06a9\u0646\u06cc\u062f.';\n        }\n\n        document.querySelectorAll('.seg-btn').forEach(t => {\n            t.addEventListener('click', (e) => {\n                document.querySelectorAll('.seg-btn').forEach(b => b.classList.remove('active')); e.target.classList.add('active');\n                activeChartTab = e.target.dataset.period; updateChart();\n            });\n        });\n\n        initApp(); \/\/ \u0634\u0631\u0648\u0639 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc \u0627\u067e\u0644\u06cc\u06a9\u06cc\u0634\u0646\n    });\n    <\/script>\n    <\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-20","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/pages\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":6,"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/pages\/20\/revisions"}],"predecessor-version":[{"id":38,"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/pages\/20\/revisions\/38"}],"wp:attachment":[{"href":"https:\/\/mpakat.ir\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}