<?php require_once('../Connections/conn_ama.php'); 
	include("../../../../../../functions/functions.php");    
	    
	if (!isset($_SESSION)) {
	  session_start();
	}

if ((isset($_POST['MM_update'])) && ($_POST['MM_update'] == "update-dept-details")) {
	
	
        $insertSQL = sprintf("UPDATE departments d
                              /* LEFT JOIN  departments d ON d.deptID = dd.deptID */
                              LEFT JOIN deptsubdetails dd ON d.deptID = dd.deptID
                              LEFT JOIN deptcontact dc ON dd.subdeptdetailsID = dc.subdeptdetailsID
                              SET d.deptname=%s, d.rank=%s, dd.subdeptname=%s, dd.deptfunctions=%s, 
                              dc.location=%s, dc.digitaladdress=%s, dc.address=%s, dc.phone=%s, dc.email=%s 
                              WHERE d.deptID = %s",

            GetSQLValueString($_POST['deptname'], "text"),
            GetSQLValueString($_POST['rank'], "int"),
            GetSQLValueString($_POST['subdeptname'], "text"),
            GetSQLValueString($_POST['deptfunctions'], "text"),
            GetSQLValueString($_POST['location'], "text"),
            GetSQLValueString($_POST['digitaladdress'], "text"),
            GetSQLValueString($_POST['address'], "text"),
            GetSQLValueString($_POST['phone'], "text"),
            GetSQLValueString($_POST['email'], "text"),
            GetSQLValueString($_POST['MM_deptID'], "int"));

    $Result1 = mysqli_query($conn_ama, $insertSQL) or die(mysqli_error($conn_ama));
    //$lawyerID = mysqli_insert_id($conn_ama);
    
    if($Result1){

        $result = "datasent";
        echo $result;
    }
    else{
      echo "notsent";
    }

}
		
		
?>