<?php 
include('nf_config.php');
include('menu_side.php');

if(isset($_REQUEST['editId']) and $_REQUEST['editId']!=""){
	$row	=	$db->getAllRecords('ccprojects','*',' AND cid="'.$_REQUEST['editId'].'"');
}

if(isset($_REQUEST['submit']) and $_REQUEST['submit']!=""){
	extract($_REQUEST);
	if($desc_project==""){
		header('location:'.$_SERVER['PHP_SELF'].'?msg=un&editId='.$_REQUEST['editId']);
		exit;
	} 
	
	$data	=	array(
					'desc_project'=>$desc_project,
					'septh'=>$septh,										
					'sepdc'=>$sepdc,															
					'totdc'=>$totdc,															
					'totdcqty'=>$totdcqty,																				
					'umqtyuc'=>$umqtyuc,	
					'stockrep'=>$stockrep,
					'invoiceon'=>$invoiceon
					);
	$update	=	$db->update('ccprojects',$data,array('cid'=>$editId));
	if($update){
		header('location: nf_project.php?msg=rus&pid='.$pid.'&xuid='.$xuid.'&lang='.$lang);
		exit;
	}else{
		header('location: nf_project.php?msg=rnu&pid='.$pid.'&xuid='.$xuid.'&lang='.$lang);
		exit;
	}
}
?>
<!doctype html>
<html lang="en-US" class="no-js">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<title><?php echo $nprojectm ?></title>
	
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.css" >
    <link rel="stylesheet" href="./fontawesome/css/all.css" >

</head>

<body>
	
	<div class="container">
		<?php
		if(isset($_REQUEST['msg']) and $_REQUEST['msg']=="un"){
			echo	'<div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i> $field_mand field!</div>';
		}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="ue"){
			echo	'<div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i> $field_mand field!</div>';
		}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="ras"){
			echo	'<div class="alert alert-success"><i class="fa fa-thumbs-up"></i> $recadded</div>';
		}elseif(isset($_REQUEST['msg']) and $_REQUEST['msg']=="rna"){
			echo	'<div class="alert alert-danger"><i class="fa fa-exclamation-triangle"></i> $recaddedno <strong> $tryagain </strong></div>';
		}
		?>
		<div class="card">
			<div class="card-header"><i class="fa fa-fw fa-plus-circle"></i> <strong> <?php echo $nedit." ".$nproject;  ?> </strong> <a href="nf_project.php?pid=<?php echo $pid ?>&xuid=<?php echo $xuid ?>&lang=<?php echo $lang ?>" class="float-end btn btn-dark btn-sm"><i class="fa fa-fw fa-globe"></i> <?php echo $nproject;  ?></a></div>
			<div class="card-body">
				
				<div class="col-sm-6">
					<form method="post">
					
					<?php 
						$desc_project 	= $row[0]['desc_project']; 												
					?>
						<div class="mb-3">
							<label><?php echo $nproject ?><span class="text-danger">*</span></label>
							<input type="text" name="desc_project" id="desc_project" class="form-control" value="<?php echo $row[0]['desc_project']; ?>" required>
						</div>
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$nsepth) ?><span class="text-danger">*</span></label>
							<input type="text" name="septh" id="septh" class="form-control" value="<?php echo $row[0]['septh']; ?>" required>							
						</div>											
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$nsepdc) ?><span class="text-danger">*</span></label>
							<input type="text" name="sepdc" id="sepdc" class="form-control" value="<?php echo $row[0]['sepdc']; ?>" required>							
						</div>																	
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$ntotdc) ?><span class="text-danger">*</span></label>
							<input type="text" name="totdc" id="totdc" class="form-control" value="<?php echo $row[0]['totdc']; ?>" required>							
						</div>																							
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$ntotdcqty) ?><span class="text-danger">*</span></label>
							<input type="text" name="totdcqty" id="totdcqty" class="form-control" value="<?php echo $row[0]['totdcqty']; ?>" required>							
						</div>																													
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$numqtyuc) ?><span class="text-danger">*</span></label>
							<input type="text" name="umqtyuc" id="umqtyuc" class="form-control" value="<?php echo $row[0]['umqtyuc']; ?>" required>							
						</div>																																			
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$nstockrep) ?><span class="text-danger">*</span></label>
							<input type="text" name="stockrep" id="stockrep" class="form-control" value="<?php echo $row[0]['stockrep']; ?>" required>							
						</div>																																			
						<div class="mb-3">						
							<label><?php echo str_replace('<br>','',$ninvoiceon) ?><span class="text-danger">*</span></label>
							<input type="text" name="invoiceon" id="invoiceon" class="form-control" value="<?php echo $row[0]['invoiceon']; ?>" required>							
						</div>
				
						<div class="mb-3">
							<input type="hidden" name="editId" id="editId" value="<?php echo $_REQUEST['editId']?>">
							<button type="submit" name="submit" value="submit" id="submit" class="btn btn-primary"><i class="fa fa-fw fa-edit"></i> <?php echo $nupdate." ".$nproject;  ?></button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
    
    <script src="./jquery-3.4.1.js"></script>
    <script src="popper.min.js" ></script>
    <script src="./bootstrap/js/bootstrap.min.js" ></script>

</body>
</html>