Commit 8d1be082 authored by reynaldi adriantama's avatar reynaldi adriantama

profile picture

parent f8a16683
...@@ -35,6 +35,16 @@ return [ ...@@ -35,6 +35,16 @@ return [
], ],
], ],
], ],
'profile' => [
'type' => Literal::class,
'options' => [
'route' => '/user/profile',
'defaults' => [
'controller' => Controller\UserController::class,
'action' => 'profile',
],
],
],
'application' => [ 'application' => [
'type' => Segment::class, 'type' => Segment::class,
'options' => [ 'options' => [
...@@ -160,7 +170,7 @@ return [ ...@@ -160,7 +170,7 @@ return [
'not_found_template' => 'error/404', 'not_found_template' => 'error/404',
'exception_template' => 'error/index', 'exception_template' => 'error/index',
'template_map' => [ 'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/login.phtml', 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml', 'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml', 'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml', 'error/index' => __DIR__ . '/../view/error/index.phtml',
......
...@@ -1687,6 +1687,59 @@ class ApiController extends \Application\Master\GlobalActionController { ...@@ -1687,6 +1687,59 @@ class ApiController extends \Application\Master\GlobalActionController {
return $this->getOutput($result->toJson()); return $this->getOutput($result->toJson());
} }
public function editpictureAction(){
$result = new Result();
$request = $this->getRequest();
$post = $request->getPost();
$uri = $this->getRequest()->getUri();
$baseurl = sprintf('//%s', $uri->getHost());
$storage = \Application\Model\Param\Storage::factory($this->getDb(), $this->getConfig());
$param = new \Application\Model\Param($storage);
$session_data = $this->getSession();
// echo "halo braiiiiiiiiiiiiiiiiiiii";
if($request->isPost()){
$datafile = $request->getFiles()->toArray();
$datapost = $request->getPost()->toArray();
}
$array_merge = array_merge($datafile, $datapost);
// $this->redirect()->toRoute('home');
// print_r($array_merge['myfile2']['name']);die;
// return new ViewModel();
$namafile = $array_merge['myfile2']['name'];
$namasementara = $array_merge['myfile2']['tmp_name'];
$dirUpload = "public/img/profilepic";
$upload = move_uploaded_file($namasementara, $dirUpload."/".$namafile);
if($upload){
$tabel = 'user_data_header';
$dataArray = array(
'profilepicture' => $namafile,
);
$where = array(
'iduser' => $array_merge['id'],
);
$load = $param->updateGlobal($tabel, $dataArray, $where);
// echo "sucess";
if($load){
$result->code = $result::CODE_SUCCESS;
$result->info = $result::INFO_SUCCESS;
// $result->data = $load->data;
$session_data->put(null, array('profilepicture' => $namafile));
$this->redirect()->toRoute('profile');
}else{
$result->code = 1;
$result->info = 'Not Found';
}
}
}
} }
......
...@@ -115,7 +115,7 @@ class UserController extends \Application\Master\GlobalActionController ...@@ -115,7 +115,7 @@ class UserController extends \Application\Master\GlobalActionController
'create_dtm' => $user->create_dtm, 'create_dtm' => $user->create_dtm,
'access' => $accessArray, 'access' => $accessArray,
'role_code' => $access->data[0]['role_code'], 'role_code' => $access->data[0]['role_code'],
'profilepicture' => $user->profilepicture,
)); ));
$session->flush(); $session->flush();
...@@ -206,6 +206,7 @@ class UserController extends \Application\Master\GlobalActionController ...@@ -206,6 +206,7 @@ class UserController extends \Application\Master\GlobalActionController
'name' => $session_data->get('name'), 'name' => $session_data->get('name'),
'email' => $session_data->get('email'), 'email' => $session_data->get('email'),
'username' => $session_data->get('usernamed'), 'username' => $session_data->get('usernamed'),
'pp' => $session_data->get('profilepicture'),
)); ));
...@@ -213,6 +214,7 @@ class UserController extends \Application\Master\GlobalActionController ...@@ -213,6 +214,7 @@ class UserController extends \Application\Master\GlobalActionController
$this->headScript->appendScript(' var idUserProfile = "' . $session_data->get('user_id') . '"'); $this->headScript->appendScript(' var idUserProfile = "' . $session_data->get('user_id') . '"');
$this->headScript->appendFile('/action-js/index-js/user-profile-action.js'); $this->headScript->appendFile('/action-js/index-js/user-profile-action.js');
$this->layout()->myParameter = $session_data->get('usernamed'); $this->layout()->myParameter = $session_data->get('usernamed');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout("layout/menu"); $this->layout("layout/menu");
return $view; return $view;
} }
...@@ -242,4 +244,6 @@ class UserController extends \Application\Master\GlobalActionController ...@@ -242,4 +244,6 @@ class UserController extends \Application\Master\GlobalActionController
return $view; return $view;
} }
} }
...@@ -99,6 +99,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -99,6 +99,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
$this->layout()->myParameter = $session_data->get('usernamed'); $this->layout()->myParameter = $session_data->get('usernamed');
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname= $session_data->get('websitename'); $this->layout()->webname= $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout("layout/menu"); $this->layout("layout/menu");
return $view; return $view;
} }
...@@ -135,11 +136,13 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -135,11 +136,13 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
'username' => $session_data->get('usernamed'), 'username' => $session_data->get('usernamed'),
'email' => $session_data->get('email'), 'email' => $session_data->get('email'),
'token' => $session_data->get('token'), 'token' => $session_data->get('token'),
'pp' => $session_data->get('profilepicture'),
)); ));
//print_r($session_data->get('token'));die; //print_r($session_data->get('token'));die;
$this->layout()->myParameter = $session_data->get('usernamed'); $this->layout()->myParameter = $session_data->get('usernamed');
$this->layout()->token= $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname= $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout("layout/menu"); $this->layout("layout/menu");
return $view; return $view;
} }
...@@ -167,6 +170,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -167,6 +170,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
$this->layout()->myParameter = $session_data->get('usernamed'); $this->layout()->myParameter = $session_data->get('usernamed');
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout("layout/menu"); $this->layout("layout/menu");
return $view; return $view;
} }
...@@ -207,6 +211,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -207,6 +211,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname= $session_data->get('websitename'); $this->layout()->webname= $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -237,6 +242,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -237,6 +242,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -272,6 +278,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -272,6 +278,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -303,6 +310,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -303,6 +310,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -334,6 +342,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -334,6 +342,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -365,6 +374,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -365,6 +374,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -396,6 +406,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -396,6 +406,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
...@@ -429,6 +440,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController ...@@ -429,6 +440,7 @@ class UseranalyticsController extends \Application\Master\GlobalActionController
//print_r($baseurl);die; //print_r($baseurl);die;
$this->layout()->token = $session_data->get('token'); $this->layout()->token = $session_data->get('token');
$this->layout()->webname = $session_data->get('websitename'); $this->layout()->webname = $session_data->get('websitename');
$this->layout()->pp = $session_data->get('profilepicture');
$this->layout('layout/menu'); $this->layout('layout/menu');
return $view; return $view;
} }
......
<div class="container-fluid"> <div class="container-fluid">
<div class="row justify-content-center" id="hui"> <div class="row justify-content-center" id="hui">
<div class="col-xl-5 col-lg-12 col-md-9" > <div class="col-xl-6 col-lg-6 col-md-9" >
<div class="card o-hidden border-0 shadow-lg my-5"> <div class="card o-hidden border-0 shadow-lg my-5">
<div class="card-body p-0 border-left-primary"> <div class="card-body p-0 border-left-primary">
<!-- Nested Row within Card Body --> <!-- Nested Row within Card Body -->
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
<hr> <hr>
<form class="user"> <form class="user">
<div class="row justify-content-center mb-2"> <div class="row justify-content-center mb-2">
<img id="image" src="http://via.placeholder.com/150x150" style="width:100px; height:100px;border-radius:50%"/> <img id="image" src="<?php $img = $this->pp; if(isset($this->pp)){echo $this->basePath('/img/profilepic/').$img;}else { echo "http://via.placeholder.com/150x150";} ?>" style="width:100px; height:100px;border-radius:50%"/>
<input type="file" onchange="readURL(this)" id="myfile" style="display:none"/>
</div> </div>
<div class="row "> <div class="row ">
<div class="col-xl-4 col-md-4 col-lg-3 "><b>Username</b> </div> <div class="col-xl-4 col-md-4 col-lg-3 "><b>Username</b> </div>
...@@ -121,4 +120,35 @@ ...@@ -121,4 +120,35 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- profile modal -->
<div class="modal fade" id="picturemodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Change Profile picture</h5>
<button class="close" type="button" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="user" method="post" action="<?php $this->basePath(); ?>/api/editpicture" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $this->id_user; ?>">
<div class="row justify-content-center">
<img id="image2" src="<?php $img = $this->pp; if(isset($this->pp)){echo $this->basePath('/img/profilepic/').$img;}else { echo "http://via.placeholder.com/150x150";} ?>" style="width:100px; height:100px;border-radius:50%"/>
</div>
<div class="row justify-content-center mt-4">
<br><input type="file" onchange="readURL(this)" id="myfile2" name="myfile2" />
</div>
<!-- <button value="upload" type="submit" class="btn btn-primary" id="btnEditpp" href="<?php //echo $this->basePath('user/logout'); ?>">Change</button> -->
<!-- </form> -->
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
<button value="upload" type="submit" class="btn btn-primary" id="btnEditpp" href="<?php //echo $this->basePath('user/logout'); ?>">Change</button>
</form>
</div>
</div>
</div>
</div> </div>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="p-5"> <div class="p-5">
<div class="text-center"> <div class="text-center">
<h1 class="h4 text-gray-900 mb-4">Pilih website</h1> <h1 class="h4 text-gray-900 mb-4">Pilih website <?php //echo $this->pp;?></h1>
</div> </div>
<hr> <hr>
<form class="user"> <form class="user">
......
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
<li class="nav-item dropdown no-arrow"> <li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span id="usernameDisplay" class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo $this->myParameter; ?></span> <span id="usernameDisplay" class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo $this->myParameter; ?></span>
<img class="img-profile rounded-circle" src="https://www.dovercourt.org/wp-content/uploads/2019/11/610-6104451_image-placeholder-png-user-profile-placeholder-image-png.jpg"> <img class="img-profile rounded-circle" src="<?php $img = $this->pp; if(isset($this->pp)){echo $this->basePath('/img/profilepic/').$img;}else { echo "http://via.placeholder.com/150x150";} ?>">
</a> </a>
<!-- Dropdown - User Information --> <!-- Dropdown - User Information -->
<div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown"> <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
......
...@@ -138,14 +138,17 @@ $(document).ready(function(){ ...@@ -138,14 +138,17 @@ $(document).ready(function(){
let $post = false; let $post = false;
if($websiteName == null || $websiteName ==""){ if($websiteName == null || $websiteName ==""){
alert("nama website kosong"); // alert("nama website kosong");
//$post = false; //$post = false;
$("#alertweb").html("nama website tidak boleh kosong");
return false return false
}else if($websiteDomain == null || $websiteDomain==""){ }else if($websiteDomain == null || $websiteDomain==""){
alert("domain kosong"); // alert("domain kosong");
$("#alertweb").html("domain tidak boleh kosong");
return false return false
} else if($averageAge == null || $averageAge==""){ } else if($averageAge == null || $averageAge==""){
alert("age kosong"); // alert("age kosong");
$("#alertweb").html("age tidak boleh kosong");
return false return false
} }
......
...@@ -27,7 +27,17 @@ $("#btnPas").on("click", function(e){ ...@@ -27,7 +27,17 @@ $("#btnPas").on("click", function(e){
$(document).ready(function(){ $(document).ready(function(){
$('#image').click(function(){ $('#image').click(function(){
$('#myfile').click() // $('#myfile').click()
// document.getElementById("picturemodal").showModal();
$("#picturemodal").modal();
})
})
$(document).ready(function(){
$('#image2').click(function(){
$('#myfile2').click()
// document.getElementById("picturemodal").showModal();
// $("#picturemodal").modal();
}) })
}) })
...@@ -36,7 +46,7 @@ function readURL(input){ ...@@ -36,7 +46,7 @@ function readURL(input){
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function(e){ reader.onload = function(e){
$("#image").attr("src", e.target.result); $("#image2").attr("src", e.target.result);
}; };
reader.readAsDataURL(input.files[0]); reader.readAsDataURL(input.files[0]);
......
...@@ -49,6 +49,7 @@ class User extends \Khansia\Generic\Objects\Mapper { ...@@ -49,6 +49,7 @@ class User extends \Khansia\Generic\Objects\Mapper {
new Map('create_dtm'), new Map('create_dtm'),
new Map('retries'), new Map('retries'),
new Map('email'), new Map('email'),
new Map('profilepicture'),
), ),
parent::CASE_INSENSITIVE parent::CASE_INSENSITIVE
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment