/* insert Potongan */
function insertPotongan($id_pot, $nama_pot, $jenis) {
$query = “insert into tbl_potongan(id_pot,nama_pot,jenis) values(‘$id_pot’,'$nama_pot’,'$jenis’)”;
$result = mysql_query($query);
return($result);
}
/* update Potongan */
function updatePotongan($id_pot, $nama_pot, $jenis) {
$query = “update tbl_potongan set nama_pot=’$nama_pot’,jenis=’$jenis’ where id_pot=’$id_pot’”;
$result = mysql_query($query);
return($result);
}
/* Delete Potongan */
function deletePotongan($id_pot) {
$query = “delete from tbl_potongan where id_pot=’$id_pot’”;
$result = mysql_query($query);
return($result);
}
if ($f == ‘potongan’) {
if (isset($_POST['txtNamaPot']) || isset($_POST['pilJenisPot'])) {
$nama_pot = $_POST['txtNamaPot'];
$jenis = $_POST['pilJenisPot'];
}
if ($p == ‘insert’) {
$query = “select max(id_pot)as kd from tbl_potongan”;
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$kdPot = $row[0];
$noUrut = (int) substr($kdPot, 1, 4);
$noUrut++;
$id_pot = “P” . sprintf(“%04s”, $noUrut);
insertPotongan($id_pot, $nama_pot, $jenis);
header(“location:../index.php?f=dftPot&conf=1″);
}
if ($p == ‘update’) {
$id_pot = $_POST['txtIdPot'];
updatePotongan($id_pot, $nama_pot, $jenis);
header(“location:../index.php?f=dftPot&conf=2″);
}
if ($p == ‘delete’) {
$id = $_GET['id'];
$data = explode(“,”, $id);
$jml = count($data);
$n = 0;
for ($i = 0; $i < $jml; $i++) {
deletePotongan($data[$n + $i]);
}
header(“location:../index.php?f=dftPot&conf=3″);
}
}
No comments:
Post a Comment