<?php
if(isset($_SESSION['tmp_doc_pop'])) unset($_SESSION['tmp_doc_pop']);
/*
if($_GET['action'] == "edit" && $_GET['m_id'] != ""){
	$m_id = mysql_real_escape_string(stripslashes($_GET['m_id']));
	$user_id = $_SESSION['sys_id']; 
	$orgunitid = mysql_real_escape_string(stripslashes($_GET['orgunitid']));
	$status = mysql_real_escape_string(stripslashes($_GET['status']));
	$start = (int)$_GET['start'];
	$type_io = (int)$_GET['type_io'];
	$bool = mysql_query("UPDATE tbl_manage_doc SET receive_status = 2, sysuserid = '$user_id' WHERE m_id = $m_id AND orgunitid = $orgunitid ");
	if($bool){
		header("Location: ?d=document/list_docin/head_doc&orgunitid=$orgunitid&status=$status&type_io=$type_io&start=$start");
	}else{
		$err = "<script>document.getElementById('msgwar').innerHTML = \"<span class = 'error'>ຢືນຢັນການຮັບ ລົ້ມເຫຼວ, ກະລຸນາລອງໃໝ່....!</span>\"</script>";
	} 
	
}
*/
if (isset($_POST['type'])) {
	for ($i = 0; $i < count($_POST['type']); $i++) {	
				
		$doc_id = mysql_real_escape_string(stripslashes($_POST['id'][$i]));
		$orgunitid = mysql_real_escape_string(stripslashes($_POST['orgunitid'][$i]));
		$doc_comment = mysql_real_escape_string(stripslashes($_POST['doc_comment'][$i]));
		$remark = mysql_real_escape_string(stripslashes($_POST['remark'][$i]));
		$send = mysql_real_escape_string(stripslashes($_POST['send_'][0]));
		if ($_POST['id'][$i] != "") {
			//echo $_POST['type'][$i];
			
			switch ($_POST['type'][$i]) {				
				case "added" :	
					
					
				break;
				
				case "edited":	
						$bool = mysql_query("UPDATE tbl_in_out_document SET remark='$remark' WHERE doc_id='$doc_id' ");
						mysql_query("UPDATE tbl_manage_doc SET receive_status=2 WHERE doc_id='$doc_id' AND orgunitid='$orgunitid' AND remark!='' ");
					
					if($bool){
						$err = "<script>document.getElementById('msgwar').innerHTML = \"<span>ແກ້ໄຂຂໍ້ມູນສໍາເລັດ....! </span>\"</script>";
					}else{
						$err = "<script>document.getElementById('msgwar').innerHTML = \"<span class='error'>ແກ້ໄຂຂໍ້ມູນລົ້ມເຫຼວ,​ ກະລຸນາລອງໃໝ່.....! </span>\"</script>";
					}
				break;
				
			}
			//if($bool) header("Location: ?d=document/docin/docin&start=".$_GET['start']);
		}
	}
}