session_start(); $ses_user_id = $_SESSION['ses_user_id']; if ($ses_user_id == "") { header("Location: ../../index.php?error=3"); } ?> <html> <meta charset="utf-8"> <script src="../../helper/jquery-latest.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="../../css/sweetalert/sweetalert.css"> <link href="../../css/menu.css" rel="stylesheet" type="text/css"/> <script> $(document).onload(function() { // alert('กำลังประมวลผล \\n\\ กรุณารอซักครู่'); }); </script> </html> <?php include '../../helper/db_connect.php'; connect_database(); $id = $_GET['id']; $check = $_GET['type']; $parent_id = $_GET['p_id']; add_parent_id($id, $parent_id); echo "<script type='text/javascript'>"; //echo "alert('เพิ่มข้อมูลบิดาสำเร็จ');"; echo "\$(document).ready(function() {"; echo "sweetAlert('เพิ่มข้อมูลบิดาสำเร็จ','', 'success');"; echo "});"; echo "window.location.assign('checkparent.php?id={$id}&type={$check}')"; echo "</script>";
function check_chinahouse($person) { if ($person['CHINAHOUSE_ID'] != 0) { return $person['CHINAHOUSE_ID']; } else { if ($person['PARENT_ID'] == 0 && $person['BROTHER_LIST'] == '') { return 0; } else { if ($person['PARENT_ID'] != 0) { $parent_id = $person['PARENT_ID']; $parents = get_person_detial($parent_id); $parent = mysql_fetch_assoc($parents); if ($parent['CHINAHOUSE_ID'] == 0) { $brothers = get_person_brother($person['PARENT_ID'], $person['BROTHER_LIST'], $person['ID']); while ($brother = mysql_fetch_assoc($brothers)) { if ($brother['CHINAHOUSE_ID'] != 0) { return $brother['CHINAHOUSE_ID']; } } if ($parent['PARENT_ID'] == 0 && $parent['BROTHER_LIST'] == '') { return 0; } else { return 1; } } else { return $parent['CHINAHOUSE_ID']; } } else { $has_parent = false; $brothers = get_person_brother($person['PARENT_ID'], $person['BROTHER_LIST'], $person['ID']); while ($brother = mysql_fetch_assoc($brothers)) { if ($brother['PARENT_ID'] != 0) { $has_parent = true; add_parent_id($person['ID'], $brother['PARENT_ID']); } if ($brother['CHINAHOUSE_ID'] != 0) { return $brother['CHINAHOUSE_ID']; } } if ($has_parent) { return 1; } else { return 0; } } } } }
echo "</script>"; } else { add_chinahouse($id, $parent['CHINAHOUSE_ID']); echo "<script type='text/javascript'>"; echo "window.location.assign('../view/chinaaddr.php?id={$id}')"; echo "</script>"; } } else { $has_parent = false; // $parent_id = 0; $brothers = get_person_brother($person['PARENT_ID'], $person['BROTHER_LIST'], $id); while ($brother = mysql_fetch_assoc($brothers)) { if ($brother['PARENT_ID'] != 0) { $has_parent = true; // $parent_id = $brother['PARENT_ID']; add_parent_id($id, $brother['PARENT_ID']); } if ($brother['CHINAHOUSE_ID'] != 0) { add_chinahouse($id, $brother['CHINAHOUSE_ID']); echo "<script type='text/javascript'>"; echo "window.location.assign('../view/chinaaddr.php?id={$id}')"; echo "</script>"; } } if ($has_parent) { header("Location:'checkparent.php?id={$id}&type={$check}'"); } else { echo "<script type='text/javascript'>"; echo '$(document).ready(function() {' . 'swal({title: "ข้อมูลไม่เพียงพอ บิดาไม่ได้ระบุที่อยู่บรรพบุรุษที่ประเทศจีน",' . 'type: "warning",' . 'showCancelButton: true,' . 'confirmButtonColor: "#DD6B55",' . 'confirmButtonText: "เพื่มข้อมูลที่อยู่บรรพบุรุษที่ประเทศจีนด้วยมือ",' . 'closeOnConfirm: false, closeOnCancel: false},' . 'function(isConfirm) {' . 'if (isConfirm) {' . 'window.location.assign("../view/add_chinahouse.php?id=' . $id . '&gen_id=");' . '}else {window.location.assign("../view/ancestorsaddr.php");}' . '});});'; echo "</script>"; }