<?php 
session_start();
require_once '../../Server/connection.php';
if($_POST){	

  $client_id = $_POST['client_id'];
  $fowardedto_id = $_POST['fowardedto_id'];
  $fowardedby_id = $_SESSION['user_id'];
  $action = "fowarded";
  $status = 0;
  $perm_id = 67;
  $upl_status = $_POST['upl_status'];
  $remarks = addslashes($_POST['remarks']);
  
  
  
    $invItemSql = "INSERT INTO assignstatus (client_id,assigned_to,assigned_by,permission_id,status,action,remarks) 
				VALUES ('$client_id','$fowardedto_id','$fowardedby_id','$perm_id','$status','$action','$remarks')";

    $result11 = $conn->query($invItemSql);
  
    if($result11&&$upl_status=='Yes'){
  foreach ($_FILES["file"]["name"] as $key => $name){
		$newFilename = time() . "_" . $name;
		move_uploaded_file($_FILES["file"]["tmp_name"][$key],'../../files/'.$newFilename);
		$location = '../../files/' . $newFilename;
		
		$fSql12 = "INSERT INTO clientdocs (client_id,fileName) 
				VALUES ('$client_id','$location')";

		$resFSql12 = $conn->query($fSql12);
	          }
			
           if($resFSql12){			
		
					
				$_SESSION['success_message'] = "Customer Has Been Fowarded Successfully to DCO";
                       header("Location: ../existingCustomer.php");
                             exit();
					
					
				
                }				
			  
              }else{
				  
	
					
					$_SESSION['success_message'] = "Customer Has Been Fowarded Successfully to DCO";
                       header("Location: ../existingCustomer.php");
                             exit();
					
					
					
				  
				  
			  }
 
}