Commit b6beb3c7 authored by Azy Mushofy Anwary's avatar Azy Mushofy Anwary

Tambah Gambar

parent cd87a10e
......@@ -610,7 +610,6 @@ class ApiController extends \Application\Master\GlobalActionController {
return $this->getOutput($result->toJson());
}
public function savekelolapoliAction(){
if($this->isLoggedIn()){
$result = new Result();
......@@ -620,37 +619,66 @@ class ApiController extends \Application\Master\GlobalActionController {
$table_poli= 'poli';
if ($request->isPost()) {
$storage = \Application\Model\Param\Storage::factory($this->getDb(), $this->getConfig());
$param = new \Application\Model\Param($storage);
try{
$fileupload = $_FILES['fileupload']['tmp_name'];
// print_r($fileupload);die;
$nama_poli = $post->inama_poli;
$kode_poli = $post->ikode_poli;
$deskripsi_poli = $post->ideskripsi_poli;
$dataArrayPoli = array (
'nama_poli' => $nama_poli,
'kode_poli' =>$kode_poli,
'deskripsi_poli'=>$deskripsi_poli,
if (!empty($fileupload)){
$ImageName = $_FILES['fileupload']['name'];
$tipes = $_FILES['fileupload']['type'];
$size = $_FILES['fileupload']['size'];
$uploaddir = './public/tamplate/img/poli/'; // directory file
);
$alamatfile = $uploaddir.$ImageName;
if (move_uploaded_file($_FILES['fileupload']['tmp_name'],$alamatfile)){
// print_r('berhasil');die;
/* jika upload berhasil ke folder sever */
$dataAtt = array(
'nama_poli' => $nama_poli,
'image_poli' => $ImageName,
'deskripsi_poli' => $deskripsi_poli,
'kode_poli' => $kode_poli,
);
$param->saveGlobal($dataAtt, $table_poli);
$result->code = 0;
$result->info = 'ok';
$result->data = $dataArrayPoli->data;
}else{
$result->code = 17;
$result->info = 'FAILED UPLOAD FILE to SERVER';
}
}else{
$result->info = 'File tidak boleh kosong';
}
// print_r($dataArrayPoli);die;
$param->saveGlobal($dataArrayPoli, $table_poli);
// $param->saveGlobal($dataArrayPoli, $table_poli);
$result->code = 0;
$result->info = 'ok';
$result->data = $dataArrayPoli;
// $result->code = 0;
// $result->info = 'ok';
// $result->data = $dataArrayPoli;
}catch (\Exception $exc) {
......@@ -663,6 +691,7 @@ class ApiController extends \Application\Master\GlobalActionController {
return $this->getOutput($result->toJson());
}
public function editkelolapoliAction(){
if($this->isLoggedIn()){
$result = new Result();
......
......@@ -94,10 +94,10 @@
</a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
<div class="dropdown-header">Dropdown Header:</div>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" id="poli"></a>
<select name="poli" id="poli" class="form-control" >
<option disable selected> Pilih </option>
</select>
</div>
</div>
</div>
......
......@@ -53,7 +53,7 @@
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<form id="myForm">
<form id="myForm" method="POST" action="<?php $this->basePath('/api/savekelolapoli') ?>" enctype="multipart/form-data">
<div class="form-group">
<label>Nama Poli</label>
......@@ -70,12 +70,12 @@
</div>
<div class="form-group " >
<label>Gambar Poli</label>
<input type="file" name="image_poli" id="image_poli" class="form-control-file">
<input type="file" name="gambar_poli" id="gambar_poli" class="form-control-file">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="tambah">Add</button>
<button type="submit" class="btn btn-primary" id="tambah">Add</button>
<button type="button" class="btn btn-danger" onclick="reset()">Reset</button>
<button type="submit" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
......
......@@ -4,6 +4,7 @@ Chart.defaults.global.defaultFontColor = '#858796';
// Pie Chart Example
var ctx = document.getElementById("myPieChart");
var myPieChart = new Chart(ctx, {
type: 'doughnut',
data: {
......@@ -33,3 +34,44 @@ var myPieChart = new Chart(ctx, {
cutoutPercentage: 80,
},
});
loadpoli()
function loadpoli() {
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/loadRegisterpoli',
success: function (result) {
if (result['code'] == 0) {
//console.log (result);
var res = result['data'];
optionseg = '';
optionseg += '<option value="Pilih" disabled selected>Pilih</option>';
for (var i = 0; i < res.length; i++) {
optionseg += '<option value="' + res[i].id_poli + '">' + res[i].nama_poli + '</option>';
}
$("select#poli").html(optionseg);
} else {
bootbox.dialog({
message: "<span class='bigger-110'>" + result['info'] + "</span>",
buttons:
{
"OK":
{
"label": "<i class='icon-ok'></i> OK ",
"className": "btn-sm btn-danger",
"callback": function () {
notifyCancel('ERROR: ' + result['info'] + '. Bila ada kesulitan dimohon untuk menghubungi Admin terkait');
}
}
}
});
}
}
});
}
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