function st_save_shipment() { global $wpdb; $table = $wpdb->prefix . 'shipments'; $log_table = $wpdb->prefix . 'shipment_updates_log'; $flight_num = sanitize_text_field($_POST['flight_num'] ?? ''); $shipment_num = sanitize_text_field($_POST['shipment_num'] ?? ''); $sender_name = sanitize_text_field($_POST['sender_name'] ?? ''); $sender_phone = sanitize_text_field($_POST['sender_phone'] ?? ''); $receiver_name = sanitize_text_field($_POST['receiver_name'] ?? ''); $receiver_phone = sanitize_text_field($_POST['receiver_phone'] ?? ''); $destination = sanitize_text_field($_POST['destination'] ?? ''); $status = sanitize_text_field($_POST['status'] ?? ''); $notes = sanitize_textarea_field($_POST['notes'] ?? ''); $contents = sanitize_text_field($_POST['contents'] ?? ''); $amount_due = floatval($_POST['amount_due'] ?? 0); $amount_paid = floatval($_POST['amount_paid'] ?? 0); $amount_balance = floatval($_POST['amount_balance'] ?? 0); if (empty($flight_num) || empty($shipment_num)) { st_json_exit(array('success' => false, 'message' => 'الرجاء إدخال رقم الرحلة ورقم الشحنة')); } // ✅ تحقق من التكرار قبل الإدخال $exists = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM $table WHERE flight_num = %s AND shipment_num = %s", $flight_num, $shipment_num )); if ($exists > 0) { st_json_exit(array('success' => false, 'message' => 'هذه الشحنة موجودة مسبقًا في نفس الرحلة')); } // ✅ إدخال الشحنة $inserted = $wpdb->insert($table, array( 'flight_num' => $flight_num, 'shipment_num' => $shipment_num, 'sender_name' => $sender_name, 'sender_phone' => $sender_phone, 'receiver_name' => $receiver_name, 'receiver_phone' => $receiver_phone, 'destination' => $destination, 'status' => $status, 'notes' => $notes, 'contents' => $contents, 'amount_due' => $amount_due, 'amount_paid' => $amount_paid, 'amount_balance' => $amount_balance, 'created_at' => current_time('mysql') )); if ($inserted === false) { st_json_exit(array('success' => false, 'message' => 'حدث خطأ أثناء إضافة الشحنة: ' . $wpdb->last_error)); } // ✅ حفظ في جدول التحديثات لتسجيل أول حالة $wpdb->insert($log_table, array( 'flight_num' => $flight_num, 'shipment_num' => $shipment_num, 'sender_name' => $sender_name, 'sender_phone' => $sender_phone, 'receiver_name' => $receiver_name, 'receiver_phone' => $receiver_phone, 'status' => $status, 'notes' => $notes, 'destination' => $destination, 'created_at' => current_time('mysql') )); st_json_exit(array('success' => true, 'message' => 'تمت إضافة الشحنة بنجاح.')); } Elementor #25 – salah.soog-sdn.com

Elementor #25

إدارة الشحنات - واجهة

إدارة الشحنات

رقم الشحنةالمستلمالوجهة
جارٍ التحميل...
1- تعديل الحالة عبر رقم الرحلة
2- تعديل الحالة عبر رقم الشحنة
3- تعديل حالة مجموعة شحنات