Commit f8a16683 authored by reynaldi adriantama's avatar reynaldi adriantama

limit tambah.phtml, ubah ApiController.php dan generate-website-token.js,...

limit tambah.phtml, ubah ApiController.php dan generate-website-token.js, action-js/index-js/user-profile-action.js, profile.phtml
parent a7ee31ee
...@@ -223,6 +223,31 @@ class ApiController extends \Application\Master\GlobalActionController { ...@@ -223,6 +223,31 @@ class ApiController extends \Application\Master\GlobalActionController {
return $this->getOutput($result->toJson()); return $this->getOutput($result->toJson());
} }
public function loadmaxwebAction(){
$result = new Result();
$request = $this->getRequest();
$post = $request->getPost();
//$name = $this->isFieldMandatory(@$data['name'], 'name');
$storage = \Application\Model\Param\Storage::factory($this->getDb(), $this->getConfig());
$test = new \Application\Model\Param($storage);
$load = $test->loadmaxweb($post->id);
if($load->code == 0){
$result->code = $result::CODE_SUCCESS;
$result->info = $result::INFO_SUCCESS;
$result->data = $load->data;
}else{
$result->code = 1;
$result->info = 'Not Found';
}
return $this->getOutput($result->toJson());
}
//load chart //load chart
public function loadchartAction(){ public function loadchartAction(){
$result = new Result(); $result = new Result();
......
...@@ -242,4 +242,9 @@ class Param extends Mapper { ...@@ -242,4 +242,9 @@ class Param extends Mapper {
return $data; return $data;
} }
public function loadmaxweb($iduser){
$data = $this->_storage->loadmaxweb($iduser);
return $data;
}
} }
...@@ -2262,5 +2262,43 @@ public function loadvisitorbytime($idweb, $year, $month, $province, $country){ ...@@ -2262,5 +2262,43 @@ public function loadvisitorbytime($idweb, $year, $month, $province, $country){
return $result; return $result;
} }
public function loadmaxweb($iduser){
$result = new Result();
try {
$sql = "SELECT
COUNT(*)
FROM
website_list
WHERE
id_user = $iduser";
$stmt = $this->_db->query($sql);
$resdata = $stmt->execute();
$listdata = array();
foreach($resdata as $val){
array_push($listdata, $val);
}
if ($listdata) {
$result->code = 0;
$result->info = 'OK';
$result->data = $listdata;
}else{
$result->code = 1;
$result->info = 'nok';
}
}catch (\Zend\Db\Adapter\Exception\RuntimeException $ex) {
$result->code = 3;
$result->info = 'ERROR : ' . $ex->getMessage();
}catch (\Exception $ex) {
$result->code = 4;
$result->info = 'ERROR : ' . $ex->getMessage();
}
return $result;
}
} }
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
</div> </div>
<hr> <hr>
<form class="user"> <form class="user">
<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%"/>
<input type="file" onchange="readURL(this)" id="myfile" style="display:none"/>
</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>
<div class="col-xl-4 col-md-4 col-lg-3 " id="usernameProfile"><?php //echo $this->username; ?></div> <div class="col-xl-4 col-md-4 col-lg-3 " id="usernameProfile"><?php //echo $this->username; ?></div>
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<input type="hidden" class="form-control" id="tokenweb" value="<?php if(isset($this->token)){echo $this->token ;} ?>"> <input type="hidden" class="form-control" id="tokenweb" value="<?php if(isset($this->token)){echo $this->token ;} ?>">
</div> </div>
<hr> <hr>
<div class="form-group"> <div id="alertweb" class="form-group text-center">
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
......
...@@ -149,6 +149,11 @@ $(document).ready(function(){ ...@@ -149,6 +149,11 @@ $(document).ready(function(){
return false return false
} }
if(isMaxWebsite(iduser) >= 5){
$("#alertweb").html("Tidak bisa menambahkan lebih dari 5 website");
return false;
}
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
...@@ -174,9 +179,30 @@ $(document).ready(function(){ ...@@ -174,9 +179,30 @@ $(document).ready(function(){
} }
isMaxWebsite(iduser) // console.log(isMaxWebsite(iduser));
function isMaxWebsite(id){ function isMaxWebsite(id){
console.log(id) var website;
// console.log("ini id user"+id)
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/loadmaxweb',
async: false,
data: {
id: id,
},
success: function(result){
//console.log("success");
//callback(location);
// redirected();
//console.log(result.data[0].count);
website = result.data[0].count;
},
error: function(xhr){
//alert(xhr.status+'-'+xhr.statusText);
}
});
return website;
} }
// function isSiteOnline(url,callback) { // function isSiteOnline(url,callback) {
......
...@@ -25,6 +25,24 @@ $("#btnPas").on("click", function(e){ ...@@ -25,6 +25,24 @@ $("#btnPas").on("click", function(e){
editPassword(tblUserPassword); editPassword(tblUserPassword);
}) })
$(document).ready(function(){
$('#image').click(function(){
$('#myfile').click()
})
})
function readURL(input){
if(input.files && input.files[0]){
var reader = new FileReader();
reader.onload = function(e){
$("#image").attr("src", e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
function editProfile(){ function editProfile(){
$username = $("#usernameUP").val(); $username = $("#usernameUP").val();
$name = $("#nameUP").val(); $name = $("#nameUP").val();
......
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