<?php include 'inc_classes.php'; 
include "admin_authentication.php";
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>AdminLTE 2 | User Profile</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="bower_components/bootstrap-daterangepicker/daterangepicker.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
	<?php include "include/header-main.php"; ?>
    <!-- Left side column. contains the logo and sidebar -->
    <?php include "include/menu_left.php"; ?>
    <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        User Profile
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Examples</a></li>
        <li class="active">User profile</li>
      </ol>
    </section>
	<?php
	$sel_staff="select * from site_setting where 1 and admin_id='".$_SESSION['admin_id']."'";
	$ptr_staff=mysql_query($sel_staff);
	$data_staff=mysql_fetch_array($ptr_staff);
	?>
    <!-- Main content -->
    <section class="content">

      <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->
          <div class="box box-primary">
            <div class="box-body box-profile">
              <img class="profile-user-img img-responsive img-circle" src="../faculty_login/staff_photo/<?php echo $data_staff['photo']; ?>" alt="<?php echo $data_staff['name']; ?>">

              <h3 class="profile-username text-center"><?php echo $data_staff['name']; ?></h3>

              <p class="text-muted text-center"><?php echo $data_staff['designation1']; ?></p>

              <!--<ul class="list-group list-group-unbordered">
                <li class="list-group-item">
                  <b>Followers</b> <a class="pull-right">1,322</a>
                </li>
                <li class="list-group-item">
                  <b>Following</b> <a class="pull-right">543</a>
                </li>
                <li class="list-group-item">
                  <b>Friends</b> <a class="pull-right">13,287</a>
                </li>
              </ul>

              <a href="#" class="btn btn-primary btn-block"><b>Follow</b></a>-->
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->

          <!-- About Me Box -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">About Me</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <strong><i class="fa fa-book margin-r-5"></i> Education</strong>

              <p class="text-muted">
                <?php echo $data_staff['qualification']; ?>
              </p>

              <hr>

              <strong><i class="fa fa-map-marker margin-r-5"></i> Location</strong>

              <p class="text-muted"><?php echo $data_staff['current_address']; ?></p>

              <hr>

              <strong><i class="fa fa-pencil margin-r-5"></i> Skills</strong>

              <p>
                <span class="label label-danger">UI Design</span>
                <span class="label label-success">Coding</span>
                <span class="label label-info">Javascript</span>
                <span class="label label-warning">PHP</span>
                <span class="label label-primary">Node.js</span>
              </p>

              <hr>

              <!--<strong><i class="fa fa-file-text-o margin-r-5"></i> Notes</strong>

              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam fermentum enim neque.</p>-->
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <!--<li class="active"><a href="#activity" data-toggle="tab">Activity</a></li>
              <li><a href="#timeline" data-toggle="tab">Timeline</a></li>-->
              <li><a href="#settings" data-toggle="tab">Settings</a></li>
            </ul>
            <div class="tab-content">
              <!--<div class="active tab-pane" id="activity">
                <div class="post">
                  <div class="user-block">
                    <img class="img-circle img-bordered-sm" src="dist/img/user1-128x128.jpg" alt="user image">
                        <span class="username">
                          <a href="#">Jonathan Burke Jr.</a>
                          <a href="#" class="pull-right btn-box-tool"><i class="fa fa-times"></i></a>
                        </span>
                    <span class="description">Shared publicly - 7:30 PM today</span>
                  </div>
                  <p>
                    Lorem ipsum represents a long-held tradition for designers,
                    typographers and the like. Some people hate it and argue for
                    its demise, but others ignore the hate as they create awesome
                    tools to help create filler text for everyone from bacon lovers
                    to Charlie Sheen fans.
                  </p>
                  <ul class="list-inline">
                    <li><a href="#" class="link-black text-sm"><i class="fa fa-share margin-r-5"></i> Share</a></li>
                    <li><a href="#" class="link-black text-sm"><i class="fa fa-thumbs-o-up margin-r-5"></i> Like</a>
                    </li>
                    <li class="pull-right">
                      <a href="#" class="link-black text-sm"><i class="fa fa-comments-o margin-r-5"></i> Comments
                        (5)</a></li>
                  </ul>

                  <input class="form-control input-sm" type="text" placeholder="Type a comment">
                </div>

                <div class="post clearfix">
                  <div class="user-block">
                    <img class="img-circle img-bordered-sm" src="dist/img/user7-128x128.jpg" alt="User Image">
                        <span class="username">
                          <a href="#">Sarah Ross</a>
                          <a href="#" class="pull-right btn-box-tool"><i class="fa fa-times"></i></a>
                        </span>
                    <span class="description">Sent you a message - 3 days ago</span>
                  </div>
                  <p>
                    Lorem ipsum represents a long-held tradition for designers,
                    typographers and the like. Some people hate it and argue for
                    its demise, but others ignore the hate as they create awesome
                    tools to help create filler text for everyone from bacon lovers
                    to Charlie Sheen fans.
                  </p>

                  <form class="form-horizontal">
                    <div class="form-group margin-bottom-none">
                      <div class="col-sm-9">
                        <input class="form-control input-sm" placeholder="Response">
                      </div>
                      <div class="col-sm-3">
                        <button type="submit" class="btn btn-danger pull-right btn-block btn-sm">Send</button>
                      </div>
                    </div>
                  </form>
                </div>

                <div class="post">
                  <div class="user-block">
                    <img class="img-circle img-bordered-sm" src="dist/img/user6-128x128.jpg" alt="User Image">
                        <span class="username">
                          <a href="#">Adam Jones</a>
                          <a href="#" class="pull-right btn-box-tool"><i class="fa fa-times"></i></a>
                        </span>
                    <span class="description">Posted 5 photos - 5 days ago</span>
                  </div>

                  <div class="row margin-bottom">
                    <div class="col-sm-6">
                      <img class="img-responsive" src="dist/img/photo1.png" alt="Photo">
                    </div>

                    <div class="col-sm-6">
                      <div class="row">
                        <div class="col-sm-6">
                          <img class="img-responsive" src="dist/img/photo2.png" alt="Photo">
                          <br>
                          <img class="img-responsive" src="dist/img/photo3.jpg" alt="Photo">
                        </div>

                        <div class="col-sm-6">
                          <img class="img-responsive" src="dist/img/photo4.jpg" alt="Photo">
                          <br>
                          <img class="img-responsive" src="dist/img/photo1.png" alt="Photo">
                        </div>

                      </div>

                    </div>

                  </div>


                  <ul class="list-inline">
                    <li><a href="#" class="link-black text-sm"><i class="fa fa-share margin-r-5"></i> Share</a></li>
                    <li><a href="#" class="link-black text-sm"><i class="fa fa-thumbs-o-up margin-r-5"></i> Like</a>
                    </li>
                    <li class="pull-right">
                      <a href="#" class="link-black text-sm"><i class="fa fa-comments-o margin-r-5"></i> Comments
                        (5)</a></li>
                  </ul>

                  <input class="form-control input-sm" type="text" placeholder="Type a comment">
                </div>

              </div>-->
              <!-- /.tab-pane -->
              <!--<div class="tab-pane" id="timeline">

                <ul class="timeline timeline-inverse">

                  <li class="time-label">
                        <span class="bg-red">
                          10 Feb. 2014
                        </span>
                  </li>

                  <li>
                    <i class="fa fa-envelope bg-blue"></i>

                    <div class="timeline-item">
                      <span class="time"><i class="fa fa-clock-o"></i> 12:05</span>

                      <h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3>

                      <div class="timeline-body">
                        Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles,
                        weebly ning heekya handango imeem plugg dopplr jibjab, movity
                        jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle
                        quora plaxo ideeli hulu weebly balihoo...
                      </div>
                      <div class="timeline-footer">
                        <a class="btn btn-primary btn-xs">Read more</a>
                        <a class="btn btn-danger btn-xs">Delete</a>
                      </div>
                    </div>
                  </li>
                  <li>
                    <i class="fa fa-user bg-aqua"></i>

                    <div class="timeline-item">
                      <span class="time"><i class="fa fa-clock-o"></i> 5 mins ago</span>

                      <h3 class="timeline-header no-border"><a href="#">Sarah Young</a> accepted your friend request
                      </h3>
                    </div>
                  </li>
                  <li>
                    <i class="fa fa-comments bg-yellow"></i>

                    <div class="timeline-item">
                      <span class="time"><i class="fa fa-clock-o"></i> 27 mins ago</span>

                      <h3 class="timeline-header"><a href="#">Jay White</a> commented on your post</h3>

                      <div class="timeline-body">
                        Take me to your leader!
                        Switzerland is small and neutral!
                        We are more like Germany, ambitious and misunderstood!
                      </div>
                      <div class="timeline-footer">
                        <a class="btn btn-warning btn-flat btn-xs">View comment</a>
                      </div>
                    </div>
                  </li>
                  <li class="time-label">
                        <span class="bg-green">
                          3 Jan. 2014
                        </span>
                  </li>
                  <li>
                    <i class="fa fa-camera bg-purple"></i>

                    <div class="timeline-item">
                      <span class="time"><i class="fa fa-clock-o"></i> 2 days ago</span>

                      <h3 class="timeline-header"><a href="#">Mina Lee</a> uploaded new photos</h3>

                      <div class="timeline-body">
                        <img src="http://placehold.it/150x100" alt="..." class="margin">
                        <img src="http://placehold.it/150x100" alt="..." class="margin">
                        <img src="http://placehold.it/150x100" alt="..." class="margin">
                        <img src="http://placehold.it/150x100" alt="..." class="margin">
                      </div>
                    </div>
                  </li>
                  <li>
                    <i class="fa fa-clock-o bg-gray"></i>
                  </li>
                </ul>
              </div>-->
              <!-- /.tab-pane -->
			  <?php 
			  if($_SESSION['admin_id'] && $_REQUEST['deleteThumbnail'])
				{
					$update_news="update site_setting set photo='' where admin_id='".$_SESSION['admin_id']."'";
					$db_q=mysql_query($update_news);
					
					if($data_staff['photo'] && file_exists("../faculty_login/staff_photo/".$data_staff['photo']))
						unlink("../faculty_login/staff_photo/".$data_staff['photo']);
				}
			  if(isset($_POST['submit']))
              {
				$name=( ($_POST['name'])) ? $_POST['name'] : "";
				$contact_phone=( ($_POST['contact_phone'])) ? $_POST['contact_phone'] : "";
				$email=( ($_POST['email'])) ? $_POST['email'] : "";
				$personal_email=( ($_POST['alt_email'])) ? $_POST['alt_email'] : "";
				$address=( ($_POST['address'])) ? $_POST['address'] : "";
				//$username=( ($_POST['username'])) ? $_POST['username'] : "";
				//$pass=( ($_POST['password'])) ? $_POST['password'] : "";
				$dob=( ($_POST['dob'])) ? $_POST['dob'] : "";
				if($_POST['dob'] !=''){
					$explode=explode('/',$dob);	
					$sep_dob=$explode[2].'-'.$explode[1].'-'.$explode[0];
				}
				else{
					$sep_dob="";
				}
				$photo=( ($_POST['photo'])) ? $_POST['photo'] : "";
				
				
				$uploaded_url="";
				if(count($errors)==0 && $_FILES['photo']["name"])
				{
					if($_SESSION['admin_id']!='')
					{
						$update_news="update site_setting set photo='' where admin_id='".$_SESSION['admin_id']."'";
						$db->query($update_news);
						if($row_record['photo'] && file_exists("../faculty_login/staff_photo/".$row_record['photo']))
							unlink("../faculty_login/staff_photo/".$row_record['photo']);
						if($row_record['photo'] && file_exists("../faculty_login/staff_photo/".$row_record['photo']))
							unlink("../faculty_login/staff_photo/".$row_record['photo']);
					}
					$uploaded_url=time().basename($_FILES['photo']["name"]);
					$newfile = "../faculty_login/staff_photo/";
					$filename = $_FILES['photo']['tmp_name']; // File being uploaded.
					$filetype = $_FILES['photo']['type'];// type of file being uploaded
					$filesize = filesize($filename); // File size of the file being uploaded.
					$source1 = $_FILES['photo']['tmp_name'];
					$target_path1 = $newfile.$uploaded_url;
					list($width1, $height1, $type1, $attr1) = getimagesize($source1);
					if(strtolower($filetype) == "image/jpeg" || strtolower($filetype) == "image/pjpeg" || strtolower($filetype) == "image/GIF" || strtolower($filetype) == "image/gif" || strtolower($filetype) == "image/png")
					{
						if(move_uploaded_file($source1, $target_path1))
						{
							$thump_target_path="../faculty_login/staff_photo/".$uploaded_url;
							copy($target_path1,$thump_target_path);
							list($width, $height, $type, $attr) = getimagesize($thump_target_path);
							//echo $width.$height;
							if($width<=170 && $height<=170)
							{
								$file_uploaded=1;
							}
							else
							{
								//------------resize the image----------------
								$obj_img1 = new thumbnail_images();
								$obj_img1->PathImgOld = $thump_target_path;
								$obj_img1->PathImgNew = $thump_target_path;
								$obj_img1->NewWidth = 150;
								$obj_img1->NewHeight = 171;
								if (!$obj_img1->create_thumbnail_images())
								{
									$file_uploaded=0;
									unlink($target_path1);
									$success=0;
									$errors[$i++]="There are some errors while uploading image, please try again";
								}
								else
								{
									$file_uploaded=1;
								 }
							}
						}
						else
						{
							$file_uploaded=0;
							$success=0;
							$errors[$i++]="There are some errors while uploading image, please try again";
						}
					}
					else
					{
						$file_uploaded=0;
						$success=0;
						$errors[$i++]="Location image: Only image files allowed";
					}
				}// photo
				
				$sel_staff_id="update site_setting set name='".$name."',email='".$email."' ,alternate_email='".$personal_email."' ,contact_phone='".$contact_phone."' ,dob='".$sep_dob."',contact_address='".$address."',photo='".$uploaded_url."' where admin_id='".$_SESSION['admin_id']."'";
				$ptr_staff=mysql_query($sel_staff_id);
				
				$insert="INSERT INTO `log_history`(`category`, `action`, `name`, `id`, `date`, `cm_id`, `admin_id`) VALUES ('update_staff_details_app','update','".$name."','".$_SESSION['admin_id']."','".date('Y-m-d H:i:s')."','".$_SESSION['cm_id']."','".$_SESSION['admin_id']."')";
				$query=mysql_query($insert);  
			  }
			  
			  $sele_staff="select * from site_setting where 1 and admin_id='".$_SESSION['admin_id']."'";
			  $ptr_staff=mysql_query($sele_staff);
			  $data_staff=mysql_fetch_array($ptr_staff);
			  ?>
              <div class="active tab-pane" id="settings">
                <form class="form-horizontal">
                  <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label">Name</label>

                    <div class="col-sm-10">
                      <input type="text" class="form-control" name="name" id="inputName" value="<?php if($_POST['name']!='') echo $_POST['name']; else echo $data_staff['name'];  ?>" placeholder="Name">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputEmail" class="col-sm-2 control-label">Official Email</label>

                    <div class="col-sm-10">
                      <input type="email" class="form-control" name="email" value="<?php if($_POST['email']!='') echo $_POST['email']; else echo $data_staff['email'];  ?>" id="inputEmail" placeholder="Official Email">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputEmail" class="col-sm-2 control-label">Personal Email</label>

                    <div class="col-sm-10">
                      <input type="email" class="form-control" name="alt_email" value="<?php if($_POST['alt_email']!='') echo $_POST['alt_email']; else echo $data_staff['alternate_email'];  ?>" id="inputEmail" placeholder="Personal Email">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputName" class="col-sm-2 control-label">Contact No.</label>

                    <div class="col-sm-10">
                      <input type="text" class="form-control" name="contact_phone" value="<?php if($_POST['contact_phone']!='') echo $_POST['contact_phone']; else echo $data_staff['contact_phone'];  ?>" id="inputName" placeholder="Name">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputExperience" class="col-sm-2 control-label">Address</label>

                    <div class="col-sm-10">
                      <textarea class="form-control" id="inputExperience" name="address" placeholder="Address"><?php if($_POST['contact_address']!='') echo $_POST['contact_address']; else echo $data_staff['contact_address'];  ?></textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputExperience" class="col-sm-2 control-label">DOB</label>
                    <div class="col-sm-10">
                      <input type="text" class="form-control" name="dob" value="<?php if($_POST['dob']!='') echo $_POST['dob']; else echo date('d/m/Y',strtotime($data_staff['dob']));  ?>" id="datepicker" placeholder="DOB (DD/MM/YYYY)">
                    </div>
                  </div>
                  <!--<div class="form-group">
                    <label for="inputExperience" class="col-sm-2 control-label">Username</label>
                    <div class="col-sm-10">
                      <textarea class="form-control" id="inputExperience" name="username" placeholder="DOB"><?php //if($_POST['username']!='') echo $_POST['username']; else echo $data_staff['username'];  ?></textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputExperience" class="col-sm-2 control-label">Password</label>
                    <div class="col-sm-10">
                      <textarea class="form-control" id="inputExperience" name="password" placeholder="DOB"><?php //if($_POST['password']!='') echo $_POST['password']; else echo $data_staff['password'];  ?></textarea>
                    </div>
                  </div>-->
                  <div class="form-group">
                    <label for="inputSkills" class="col-sm-2 control-label">Photo</label>

                    <div class="col-sm-10">
                    <?php
	            if($_SESSION['admin_id'] && $data_staff['photo'] && file_exists("../faculty_login/staff_photo/".$data_staff['photo']))
    	            echo '<img height="77px" width="77px" src="../faculty_login/staff_photo/'.$data_staff['photo'].'"><br><a href="'.$_SERVER['PHP_SELF'].'?deleteThumbnail=1&record_id='.$_SESSION['admin_id'].'">Delete / Upload new</a></td><td width="40%"></td>';
                else
                    echo '<input type="file" name="photo" class="form-control" name="photo" id="inputSkills"></td>';?>
                    </div>
                  </div>
                  <!--<div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <div class="checkbox">
                        <label>
                          <input type="checkbox"> I agree to the <a href="#">terms and conditions</a>
                        </label>
                      </div>
                    </div>
                  </div>-->
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <input type="submit" name="submit" id="submit" value="Update" class="btn btn-success">
                    </div>
                  </div>
                </form>
              </div>
              <!-- /.tab-pane -->
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- /.nav-tabs-custom -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  <?php include "include/footer-main.php"; ?>
</div>
<!-- ./wrapper -->
<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- Sparkline -->
<script src="bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!-- date-range-picker -->
<script src="bower_components/moment/min/moment.min.js"></script>
<script src="bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker -->
<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- jvectormap  -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- ChartJS -->
<script src="bower_components/chart.js/Chart.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard2.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<script>
  $(function () {
    //Initialize Select2 Elements
    //Date picker
    $('#datepicker').datepicker({
      autoclose: true,
	  format: 'dd/mm/yyyy',
	  /*startDate: '-1d',*/
	  Default: true,
	  todayHighlight: true
    })
	
  })
</script>
</body>
</html>
