From fe12512c973bdebbd4cd7adb8c52ce53411057af Mon Sep 17 00:00:00 2001
From: Venny Larasati <venny_la@yahoo.com>
Date: Mon, 4 Apr 2016 14:03:26 +0700
Subject: [PATCH] insert into & update perilaku kerja working
---
P3/form_perilaku_kerja.php | 16 +++---
P3/perilaku_kerja.php | 71 +++++++++++++++++++++++++
P3/perilaku_kerja_controller.php | 89 ++++++++++++++++++++++++++++++++
3 files changed, 168 insertions(+), 8 deletions(-)
create mode 100644 P3/perilaku_kerja.php
create mode 100644 P3/perilaku_kerja_controller.php
diff --git a/P3/form_perilaku_kerja.php b/P3/form_perilaku_kerja.php
index 7ccad75..5e8aaf2 100644
--- a/P3/form_perilaku_kerja.php
+++ b/P3/form_perilaku_kerja.php
@@ -53,46 +53,46 @@
<div class="panel panel-default">
<div class="panel-heading font-bold">Perilaku Kerja</div>
<div class="panel-body">
- <form class="bs-example form-horizontal">
+ <form class="bs-example form-horizontal" action="perilaku_kerja_controller.php" method="post">
<div class="form-group">
<label class="col-lg-3 control-label">Orientasi Pelayanan</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="pelayanan">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Integritas</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="integritas">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Komitmen</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="komitmen">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Disiplin</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="disiplin">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Kerjasama</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="kerjasama">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Kepemimpinan</label>
<div class="col-lg-9">
- <input type="text" class="form-control">
+ <input type="number" min="0" class="form-control" name="kepemimpinan">
</div>
</div>
<div class="form-group">
- <div class="col-lg-offset-10 col-lg-2">
+ <div class="col-lg-offset-8 col-lg-4">
<button type="submit" class="btn btn-sm btn-info">Simpan</button>
</div>
</div>
diff --git a/P3/perilaku_kerja.php b/P3/perilaku_kerja.php
new file mode 100644
index 0000000..7499acb
--- /dev/null
+++ b/P3/perilaku_kerja.php
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html lang="en" class="">
+<head>
+ <meta charset="utf-8" />
+ <title>Penilaian Perilaku Kerja</title>
+ <meta name="description" content="Bandung Web Kit" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
+ <link rel="stylesheet" href="../libs/assets/animate.css/animate.css" type="text/css" />
+ <link rel="stylesheet" href="../libs/assets/font-awesome/css/font-awesome.min.css" type="text/css" />
+ <link rel="stylesheet" href="../libs/assets/simple-line-icons/css/simple-line-icons.css" type="text/css" />
+ <link rel="stylesheet" href="../libs/jquery/bootstrap/dist/css/bootstrap.css" type="text/css" />
+
+ <link rel="stylesheet" href="css/font.css" type="text/css" />
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
+
+
+</head>
+<body>
+<div class="app app-header-fixed ">
+
+ <?php require_once 'header.php' ?>
+ <?php require_once 'aside.php' ?>
+
+<!-- content -->
+<div id="content" class="app-content" role="main">
+
+ <div class="hbox hbox-auto-xs hbox-auto-sm ng-scope">
+ <div class="col">
+
+ <div class="bg-light lter">
+ <ul class="breadcrumb bg-grey-breadcrumb m-b-none">
+ <li><a href="#" class="btn no-shadow" ui-toggle-class="app-aside-folded" target=".app">
+ <i class="icon-bdg_expand1 text"></i>
+ <i class="icon-bdg_expand2 text-active"></i>
+ </a> </li>
+ <li><a href>Penilaian Perilaku Kerja</a></li>
+ </ul>
+ </div>
+
+ <div class="bg-light lter b-b wrapper-md padder-md">
+ <h1 class="m-n font-bold h4 padder">Penilaian Perilaku Kerja</h1>
+ </div>
+ <!-- App-content-body -->
+ <div class="wrapper-lg bg-light">
+
+ </div>
+
+
+ </div>
+ </div>
+ <!-- end hbox hbox-auto-xs -->
+</div>
+
+
+<?php require_once 'footer.php' ?>
+
+
+
+</div>
+
+<script src="../libs/jquery/jquery/dist/jquery.js"></script>
+<script src="../libs/jquery/bootstrap/dist/js/bootstrap.js"></script>
+<script src="js/ui-load.js"></script>
+<script src="js/ui-jp.config.js"></script>
+<script src="js/ui-jp.js"></script>
+<script src="js/ui-nav.js"></script>
+<script src="js/ui-toggle.js"></script>
+<script src="js/ui-client.js"></script>
+
+</body>
+</html>
diff --git a/P3/perilaku_kerja_controller.php b/P3/perilaku_kerja_controller.php
new file mode 100644
index 0000000..1363ec6
--- /dev/null
+++ b/P3/perilaku_kerja_controller.php
@@ -0,0 +1,89 @@
+<?php
+
+require_once 'controller/connectdb.php';
+$conn = connect_database();
+
+$id_pegawai = '196006041982101099'; //dari POST
+$id_penilai = '195608011981111099'; //dari POST
+
+// Cek apakah NIP & periode sudah ada di tabel penilaian
+$id_penilaian = 0;
+$sql = "SELECT id_penilaian FROM penilaian WHERE id_pegawai ='$id_pegawai' AND periode = YEAR(CURDATE())";
+$result = $conn->query($sql);
+
+// Jika sudah ada, ambil id_penilaiannya
+if ($result->num_rows > 0) {
+ while($row = $result->fetch_assoc()) {
+ $id_penilaian = $row["id_penilaian"];
+ echo "udah ada penilaian " . $id_penilaian. "<br>";
+ }
+} else { // Jika belum ada, buat record di tabel penilaian
+ $sql1 = "INSERT INTO penilaian (id_pegawai, id_penilai, periode)
+ VALUES ('$id_pegawai','$id_penilai', YEAR(CURDATE()))";
+
+ if ($conn->query($sql1) === TRUE) {
+ echo "New record created successfully";
+ } else {
+ echo "Error: " . $sql . "<br>" . $conn->error;
+ }
+
+ $sql2 = "SELECT id_penilaian FROM penilaian WHERE id_pegawai ='$id_pegawai' AND periode = YEAR(CURDATE())";
+ $result = $conn->query($sql2);
+
+ if ($result->num_rows > 0) {
+ while($row = $result->fetch_assoc()) {
+ $id_penilaian = $row["id_penilaian"];
+ }
+ }
+
+ echo "belom ada penilaian " . $id_penilaian. "<br>";
+
+}
+
+// Cek apakah perilaku udah ada dgn id_penilaian yg didapatkan
+echo "id_penilaian " . $id_penilaian. "<br>";
+$id_perilaku = 0;
+$sql = "SELECT id_perilaku FROM perilaku_kerja WHERE id_penilaian = $id_penilaian";
+$result = $conn->query($sql);
+
+$pelayanan = (int) $_POST["pelayanan"];
+$integritas = (int) $_POST["integritas"];
+$komitmen = (int) $_POST["komitmen"];
+$disiplin = (int) $_POST["disiplin"];
+$kerjasama = (int) $_POST["kerjasama"];
+$kepemimpinan = (int) $_POST["kepemimpinan"];
+
+// Jika sudah ada, update
+if ($result->num_rows > 0) {
+ while($row = $result->fetch_assoc()) {
+ $id_perilaku = $row["id_perilaku"];
+ }
+
+ $sql1 = "UPDATE perilaku_kerja
+ SET pelayanan=$pelayanan , integritas=$integritas, komitmen=$komitmen, disiplin=$disiplin, kerjasama=$kerjasama, kepemimpinan=$kepemimpinan
+ WHERE id_perilaku = '$id_perilaku' ";
+
+ if ($conn->query($sql1) === TRUE) {
+ echo "New record created successfully";
+ } else {
+ echo "Error: " . $sql . "<br>" . $conn->error;
+ }
+
+
+} else { // Jika belom ada, insert
+
+ $sql1 = "INSERT INTO perilaku_kerja (pelayanan, integritas, komitmen, disiplin, kerjasama, kepemimpinan, id_penilaian)
+ VALUES ($pelayanan, $integritas, $komitmen, $disiplin, $kerjasama, $kepemimpinan, $id_penilaian)";
+
+ if ($conn->query($sql1) === TRUE) {
+ echo "New record created successfully";
+ } else {
+ echo "Error: " . $sql . "<br>" . $conn->error;
+ }
+
+}
+
+header( 'Location: perilaku_kerja.php' ) ;
+exit();
+
+?>
\ No newline at end of file
--
GitLab