<?php
session_start();
 include 'header.php' ?>

 

<!--<script type="text/javascript" src="../js/loader.js"></script>-->
<script src="../js/highcharts.src.js"></script>
<script src="../js/exporting.js"></script>
<script src="../js/export-data.js"></script>

<script type="text/javascript">
 
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>
<style>
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th { border:0px;
    
}
</style>
<div class="page-wrapper">
<?php
					$sql_ck="select * from registration where id in(select reg_id from system_login where id = '".$_SESSION['login_id']."' )";
							
							$res_ck=mysql_query($sql_ck);
							
						$row_ck=mysql_fetch_assoc($res_ck);
						
						
						$sql_pln="select * from tbl_user_status_and_plan  where user_id = '".$_SESSION['login_id']."' order by id desc limit 1";
							
							$res_pln=mysql_query($sql_pln);
							
						$row_pln=mysql_fetch_assoc($res_pln);
					?>
            <!-- Bread crumb -->
            <div class="row page-titles" style="height:50px;">
                <div class="col-md-12 align-self-center" >
                    <h3 class="text-primary">Profile </h3> </div>
               
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
            <div class="container-fluid" id="printableArea">
                <!-- Start Page Content -->
               
				<div class="row">
                    
                   
                    <div class="col-lg-7">
                         <div class="card" >
						<h3 align="center"><u>Profile</u></h3>
						<br />
						<form method="post" enctype="multipart/form-data">
						<table class="table">
						<tr>
						
						<td>Name</td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="name" value="<?php echo $row_ck['name'];?>" required  /></td>
						</tr>
						<tr>
						<td>Phone</td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="phone" value="<?php echo $row_ck['phone'];?>" required /></td>
						</tr>
						<tr>
						<td>Address </td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="address" value="<?php echo $row_ck['address'];?>"  required /></td>
						</tr>
						
						<tr>
						<td>Organisation Name </td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="org_name" value="<?php echo $row_ck['org_name'];?>" required /></td>
						</tr>
						
						<tr>
						<td>Gstin</td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="gstin" value="<?php echo $row_ck['gstin'];?>" required /></td>
						</tr>
						
						<tr>
						<td>State  </td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><select name="state" id="state"  class="select form-control" required="" >
				<option value="">-State-</option>
				<?php 
							$sqlc="select * from tbl_state";
							//echo $sqlc;
							$c=mysql_query($sqlc);
							if(mysql_num_rows($c)>0){
							while($cs=mysql_fetch_array($c))
							{?>
        <option value="<?=$cs["id"];?>" <?php if($row_ck['state']==$cs["id"]){?> selected="selected"<?php }?> >
        <?=$cs["name"];?>
        </option>
        <?php }}?>
				
				</select></td>
						</tr>
						
						<tr>
						<td>City </td>
						<td>:</td>
						<td>&nbsp;</td>
						<td><input type="text" class="form-control" name="city" value="<?php echo $row_ck['city'];?>" required /></td>
						</tr>
						
						<tr>
						<td>Pin </td>
						<td>:</td>
						<td>&nbsp;</td>
						<td ><input type="text" class="form-control" name="pin" value="<?php echo $row_ck['pin'];?>" required/></td>
						</tr>
						<tr>
						<td>Organisation Logo </td>
						<td>:</td>
						<td><img src="../uploads/<?php echo $row_ck['org_logo'];?>" style="height:60px; width:100px" /></td>
						<td><input type="hidden" name="img_nm" class="form-control"  value="<?php echo $row_ck['org_logo'];?>" /> <input type="file" name="img" class="form-control"  /></td>
						</tr>
						</table><br />
                          <p align="center">  <input type="submit" class="btn btn-success " name="update" value="Update" /></p>
							</form>
                       </div>
                    </div>
                  
				  <div class="col-lg-5">
                        <div class="card" >
						<h3><u>Plan Details :</u></h3>
						<p><b>Version : </b> <span style="color:#009933"><?php echo $row_pln['access_type'];?></span></p>
						<p><b>Plan Name : </b> <span style="color:#009933"><?php if($row_pln['plan_type']==0){ echo 'Trial';}else{
						
						$sql_pln_dt="select * from tbl_plan  where id = '".$row_pln['plan_type']."'";
							
							$res_pln_dt=mysql_query($sql_pln_dt);
							
						$row_pln_dt=mysql_fetch_assoc($res_pln_dt);
						echo $row_pln_dt['plan_name'];
						
						}
						?></span></p>
						<p><b>Plan Duration : </b> <span style="color:#009933"><?php if($row_pln['plan_type']==0){ echo '1 / month';}else{
						echo $row_pln_dt['duration'];
						
						}?></span></p>
						<p><b>Upgraded On : </b> <span style="color:#009933"><?php $upg_dt = date('d-m-Y', strtotime($row_pln['upgrade_date'])); if($upg_dt=='01-01-1970'){ echo 'none';}else{ echo $upg_dt;}?></span></p>
						<p><b>Expiring On : </b> <span style="color:#FF0000"><?php echo date('d-m-Y', strtotime($row_pln['expiry_date']));?></span></p>
                           
						   <p align="right"><button type="button" class="btn btn-success btn-sm" style="background:#009900">Plans</button></p>
                        </div>
						
                    </div>
                </div>
				
				
				
				
            
        </div>
		
		<?php
		
		if(isset($_POST['update'])){
		
		$file_name = $_FILES['img']['name'];
		if(!empty($file_name)){
		  $ext = pathinfo($file_name , PATHINFO_EXTENSION);
		    $renm = $_SESSION['uname'];
		   $file_name=$renm.".".$ext;
		$file_tmp =$_FILES['img']['tmp_name'];
		$file_type=$_FILES['img']['type'];	
	
	
	
        $desired_dir="../uploads/";
        if(empty($errors)==true){
            if(is_dir($desired_dir)==false){
                mkdir("$desired_dir", 0700);		// Create directory if it does not exist
            }
            if(is_dir("$desired_dir/".$file_name)==false){
                move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
            }else{									// rename the file if another one exist
                $new_dir="$desired_dir/".$file_name.time();
                 rename($file_tmp,$new_dir) ;				
            }
}
		
		}else{
		$file_name = $_REQUEST['img_nm'];
		
		}
		
		mysql_query("update  registration set name='".$_REQUEST['name']."' , phone='".$_REQUEST['phone']."' , address='".$_REQUEST['address']."' , org_name='".$_REQUEST['org_name']."' , org_logo='$file_name' , gstin='".$_REQUEST['gstin']."' , state='".$_REQUEST['state']."' , city='".$_REQUEST['city']."' , pin='".$_REQUEST['pin']."' where id= '".$_SESSION["reg_id"]."' ");
		
		?>
		
		<script>
		alert('Success');
		location ='';
		</script>
		<?php
		
		
		
		}
		
		?>
		
	
	
<?php include 'footer.php' ?>
<!--<script src="../js/loader.js"></script>-->