<style>
.control-label {  
  padding-top: 0 !important;
}
</style>
<div class="page-content-wrapper">
                <div class="page-content">
                    <div class="page-bar">
                        <div class="page-title-breadcrumb">
                            <div class=" pull-left">
                                <div class="page-title">View Project</div>                                
                            </div>
                            <ol class="breadcrumb page-breadcrumb pull-right">
                                <li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i>
                                </li>
                                <li><a class="parent-item" href="index.php?page=manage_projects">Projects</a>&nbsp;<i class="fa fa-angle-right"></i></li><li class="active">View Project</li>
                            </ol>
                        </div>
                    </div>
<div class="row">
                        <div class="col-md-12 col-sm-12">
                            <div class="card card-box">
                                <div class="card-head">
                                    <header>View Project</header>  
                                    <div style="margin-left:20px;">
	                                	<a class="btn btn-info" href="index.php?page=manage_projects&p=<?php echo $p;?>">Back</a>&nbsp;
	                                	<a class="btn btn-info" href="index.php?page=add_project&id=<?php echo $editId; ?>">Edit</a>&nbsp;
	                                	<a target="_blank" class="btn btn-info" href="index.php?page=project_expenses&id=<?php echo $editId; ?>">Expenses</a>&nbsp;
	                                	<a target="_blank" class="btn btn-info" href="index.php?page=project_incomes&id=<?php echo $editId; ?>">Payments</a>&nbsp;
	                                	<a target="_blank" class="btn btn-info" href="index.php?page=add_sub_task&project_id=<?php echo $editId; ?>">Sub Tasks</a>
	                                	<a target="_blank" class="btn btn-info" href="index.php?page=project_profit_loss&id=<?php echo $editId; ?>">Profit/Loss</a>
	                                </div>                                  
                                </div>
                                <div class="card-body" id="bar-parent1">
                                	
                                	<?php if(isset($error) && $error!='') { ?> 
                                	<div class="alert alert-danger"><?php echo $error; ?></div>
                                	<?php } else if(isset($success) && $success!='') { ?> 
                                	<div class="alert alert-success"><?php echo $success; ?></div>
                                	<?php } ?>                                		
                                		                                      	                          	                                	
                                    <form action="" id="form_staff_add" class="form-horizontal" method="post" enctype="multipart/form-data">                                    	
                                        <div class="form-body div-left">     
                                        	<?php if($resEdit['type']>0){ ?>                                   	                                        	 
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Project Type</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getProjectType($resEdit['type']);?>
                                                </div>
                                            </div>
                                            <?php } ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Name</label>
                                                <div class="col-md-4">                                                                                                                                                                   
                                                    <?php echo $resEdit['name'];?>
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Total Amount</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo money_format('%!i', $resEdit['total_amount']);?>
                                                </div>
                                            </div>                                            
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Project Details</label>
                                                <div class="col-md-4">        
                                                	<?php echo $resEdit['description'];?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Client Details</label>
                                                <div class="col-md-4">        
                                                	<?php echo $resEdit['client_details'];?>
                                                	                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Start Date</label>
                                                <div class="col-md-4">        
                                                	<?php echo getFormattedDate($resEdit['start_date']);?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">End Date</label>
                                                <div class="col-md-4">        
                                                	<?php echo getFormattedDate($resEdit['end_date']);?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Date</label>
                                                <div class="col-md-4">        
                                                	<?php echo $resEdit['date'];?>                                            
                                                </div>
                                            </div>        
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Total Payments</label>
                                                <div class="col-md-4">        
                                                	<b><?php if(!empty($totalPayments)){ echo money_format('%!i', $totalPayments);} else { echo 'No payments added';}?></b>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Total Expense</label>
                                                <div class="col-md-4">        
                                                	<b><?php if(!empty($totalExpense)){ echo money_format('%!i', $totalExpense);} else { echo 'No expenses added';}?></b>                                       
                                                </div>
                                            </div>    
                                            <?php if($resEdit['status']=='completed'){
                                            	$profitLoss = $totalPayments-$totalExpense;
												$profitLoss = number_format((float)abs($profitLoss), 2, '.', '');
                                            	if($profitLoss>0){	?>  
	                                            	<div class="form-group row">
		                                                <label class="control-label col-md-3">Profit</label>
		                                                <div class="col-md-4">        
		                                                	<b><span style="color: green;"><?php echo money_format('%!i', $profitLoss); ?></span></b>                                       
		                                                </div>
		                                            </div>
		                                         <?php } else if($profitLoss<0){ ?>
		                                         	<div class="form-group row">
		                                                <label class="control-label col-md-3">Loss</label>
		                                                <div class="col-md-4">        
		                                                	<b><span style="color: red;"><?php echo money_format('%!i', $profitLoss); ?></span></b>                                   
		                                                </div>
		                                            </div>
		                                         <?php } else { ?>
		                                         	<div class="form-group row">
		                                                <label class="control-label col-md-3">Loss</label>
		                                                <div class="col-md-4">        
		                                                	<b><span style="color: orange;">No Profit</span></b>                                   
		                                                </div>
		                                            </div>
		                                         <?php } ?>      
                                            <?php } ?>                              
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Status</label>
                                                <div class="col-md-4">        
                                                	<b><?php if($resEdit['status']=='in_progress'){ echo 'In Progress'; } else { echo ucfirst($resEdit['status']); }?></b>                                            
                                                </div>
                                            </div>                                            
                                            <?php if($resEdit['added_by']>0){ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Added By</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getAdminUserName($resEdit['added_by']);?>   
                                                </div>
                                            </div>  
                                            <?php } ?> 
                                            <?php if($resEdit['updated_by']>0){ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Updated By</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getAdminUserName($resEdit['updated_by']);?>   
                                                </div>
                                            </div>  
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Updated On</label>
                                                <div class="col-md-4">                                                    
                                                    <?php echo getFormattedDate($resEdit['updated_on']);?>   
                                                </div>
                                            </div>
                                            <?php } ?>  
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Upload Quotation (PDF)</label>
                                                <div class="col-md-4">                                                    
                                                    <input type="file" name="quotation" id="quotation">
                                                </div>
                                                <?php if(isset($resEdit['quotation']) && $resEdit['quotation']!=''){ ?>
                                                	<a target="_blank" href="<?php echo BASE_URL.'lcontrol/quotations/'.$resEdit['quotation']; ?>"><img style="width:50px;" src="images/pdf.png"></a>
                                                <?php } ?>
                                            </div>         
                                            <div class="form-group">
	                                            <div class="offset-md-3 col-md-9">                                            	
	                                            		<button type="submit" name="upload" class="btn btn-info">Upload</button> 
	                                            </div>
	                                        </div>                                                                           
                                            
                                        </div>  
                                                                              
                                      	
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
	</div>
</div>
