diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/shortcodes.php b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/shortcodes.php index 127d270..f27a35a 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/shortcodes.php +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/shortcodes.php @@ -1238,6 +1238,38 @@ jQuery(document).ready(function($) { success: function(r) { if (r.success) { alert('سفارش لغو شد.'); location.reload(); } else { alert('خطا: ' + r.data); btn.prop('disabled', false).text('❌ لغو'); } }, error: function() { alert('خطا در ارتباط با سرور.'); btn.prop('disabled', false).text('❌ لغو'); } }); + + // بارگذاری تعهدنامه‌ها + $.ajax({ + url: ifnex_ajax.ajax_url, + method: 'POST', + data: { action: 'ifnex_get_commitment_forms', order_id: , nonce: ifnex_ajax.nonce }, + success: function(res) { + if (res.success && res.data && res.data.length > 0) { + var html = ''; + res.data.forEach(function(form) { + var badge = form.upload_status === 'uploaded' ? '✅ آپلود شده' + : form.upload_status === 'verified' ? '✅ تأیید شده' + : '⏳ آپلود نشده'; + html += '
'; + html += '
'; + html += '
' + form.title + '
' + (form.description || '') + '
'; + html += badge; + html += '
'; + if (form.file_url) html += '📥 دانلود فرم'; + if (form.uploaded_file_url) html += '📎 فایل آپلودشده'; + html += ''; + html += '
'; + }); + $('#ifnex-commitment-forms').html(html); + } else { + $('#ifnex-commitment-forms').html('

تعهدنامه‌ای برای این سفارش موجود نیست.

'); + } + }, + error: function() { + $('#ifnex-commitment-forms').html('

خطا در بارگذاری تعهدنامه‌ها.

'); + } + }); }); }); function uploadCommitmentForm(orderId, formId, input) { diff --git a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/user-bridge.php b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/user-bridge.php index 2ab0c2b..62903a5 100644 --- a/03_WordPress/wp-content/plugins/ifnex-bridge/includes/user-bridge.php +++ b/03_WordPress/wp-content/plugins/ifnex-bridge/includes/user-bridge.php @@ -855,7 +855,7 @@ function ifnex_download_order_pdf_ajax() { $download_url = rtrim($api_url, '/') . "/customer/orders/{$order_id}/pdf/{$download_type}"; // ارسال درخواست به لاراول با توکن احراز هویت - $token = get_user_meta($user_id, 'ifnex_api_token', true); + $token = get_user_meta($user_id, 'ifnex_laravel_token', true); if (!$token) wp_send_json_error('توکن احراز هویت یافت نشد.'); $response = wp_remote_get($download_url, array( @@ -908,7 +908,7 @@ function ifnex_get_commitment_forms_ajax() { $api_url = get_option('ifnex_api_url', 'http://localhost:8000/api/v1'); $url = rtrim($api_url, '/') . "/customer/orders/{$order_id}/commitment-forms"; - $token = get_user_meta($user_id, 'ifnex_api_token', true); + $token = get_user_meta($user_id, 'ifnex_laravel_token', true); if (!$token) wp_send_json_error('توکن احراز هویت یافت نشد.'); $response = wp_remote_get($url, array( @@ -973,7 +973,7 @@ function ifnex_upload_commitment_form_ajax() { $api_url = get_option('ifnex_api_url', 'http://localhost:8000/api/v1'); $url = rtrim($api_url, '/') . "/customer/orders/{$order_id}/commitment-forms/{$form_id}/upload"; - $token = get_user_meta($user_id, 'ifnex_api_token', true); + $token = get_user_meta($user_id, 'ifnex_laravel_token', true); if (!$token) wp_send_json_error('توکن احراز هویت یافت نشد.'); $multipart = new CURLFile($upload['file'], $file['type'], $file['name']); diff --git a/04_Laravel/database/migrations/2026_10_03_000001_make_file_fields_nullable_in_commitment_forms.php b/04_Laravel/database/migrations/2026_10_03_000001_make_file_fields_nullable_in_commitment_forms.php new file mode 100644 index 0000000..a9bbeee --- /dev/null +++ b/04_Laravel/database/migrations/2026_10_03_000001_make_file_fields_nullable_in_commitment_forms.php @@ -0,0 +1,34 @@ +getDriverName() === 'sqlite') { + return; + } + + DB::statement("ALTER TABLE `commitment_forms` MODIFY COLUMN `file_type` VARCHAR(255) NULL"); + DB::statement("ALTER TABLE `commitment_forms` MODIFY COLUMN `file_size` BIGINT UNSIGNED NULL"); + } + + public function down(): void + { + if (DB::connection()->getDriverName() === 'sqlite') { + return; + } + + DB::table('commitment_forms')->whereNull('file_type')->update(['file_type' => 'pdf']); + DB::table('commitment_forms')->whereNull('file_size')->update(['file_size' => 0]); + + DB::statement("ALTER TABLE `commitment_forms` MODIFY COLUMN `file_type` VARCHAR(255) NOT NULL"); + DB::statement("ALTER TABLE `commitment_forms` MODIFY COLUMN `file_size` BIGINT UNSIGNED NOT NULL"); + } +}; \ No newline at end of file