<?php

if ($this->is_id()) {
	//$delete_query = "DELETE FROM user_parent WHERE up_id = " . $this->get_id() . ";";
	//$sql->execute_query($delete_query);

	//kigayűjtük azokat a gyerek ID-kat (a törölteket is!), akiknél ez a szülő van beállítva  első vagy második helyen
	$parent_1_query = "SELECT uk_id FROM user_kid WHERE uk_parent_1 = " . $this->get_id();
	$parent1_assoc_array = $sql->assoc_array($parent_1_query);
	foreach ($parent1_assoc_array as $uk_id) {
		$sql->update_table('user_kid', array('uk_parent_1' => 'null'), array('uk_id' => $uk_id['uk_id']));
	}

	$parent_2_query = "SELECT uk_id FROM user_kid WHERE uk_parent_2 = " . $this->get_id();
	$parent2_assoc_array = $sql->assoc_array($parent_2_query);
	foreach ($parent2_assoc_array as $uk_id) {
		$sql->update_table('user_kid', array('uk_parent_2' => 'null'), array('uk_id' => $uk_id['uk_id']));
	}

	$sql->update_table('user_parent', array('up_deleted' => 1), array('up_id' => $this->get_id()));

	log::register('delete_parent', $this->get_id());
	header("Location: /admin/parents");
}


?>