$query .= " AND module_pageurl<>'{$fhidpageurl}'"; } if ($result = $mysqli->query($query)) { if ($result->num_rows > 0) { $alert[] = array('type' => 'danger', 'message' => 'PageURL sudah pernah didaftarkan!'); $go = false; } } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $go = false; } } /* Validation Success */ if ($go == true) { if ($fcommand == 'create') { $fid = autoGenerateID($mysqli, "MOD", "tmodule", "module_id", 4); $query = "INSERT INTO tmodule VALUES ('{$fid}','{$fname}','{$fcategory}','{$fdesc}','{$fpageurl}',{$fissub},{$fhascrud});"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Module baru telah ditambahkan.'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { $query = "UPDATE tmodule SET \n\t\t\t\t\t\t\t\t\t\t\t\tmodule_name='{$fname}',\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tmodule_category='{$fcategory}',\n\t\t\t\t\t\t\t\t\t\t\t\tmodule_description='{$fdesc}',\n\t\t\t\t\t\t\t\t\t\t\t\tmodule_pageurl='{$fpageurl}',\n\t\t\t\t\t\t\t\t\t\t\t\tmodule_issub={$fissub},\n\t\t\t\t\t\t\t\t\t\t\t\tmodule_hascrud={$fhascrud}\n\t\t\t\t\t\t\t\t\t\t\tWHERE module_id='{$fid}'"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Data Module berhasil diubah.'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false;
} } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $go = false; } if ($fnominal > $debtremain) { $alert[] = array('type' => 'danger', 'message' => 'Nominal pembayaran melebihi sisa utang!'); $go = false; } } /* Validation Success */ if ($go == true) { // Convert DateTime to String $fpaymentdate = $ftempdate->format('Y-m-d'); if ($fcommand == 'create') { $fid = autoGenerateID($mysqli, "PU" . $ftempdate->format('ym'), "tdebtpayment", "debtpayment_id", 6); $query = "INSERT INTO tdebtpayment \n\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$fid}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fpaymentdate}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fdebtid}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fuser}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fdescription}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$fnominal},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fstatus}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL)\n\t\t\t\t\t\t\t\t\t\t "; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Pembayaran utang baru telah ditambahkan.'); // Insert Activity Log addLog($mysqli, $flogin['user_id'], $fcurrpage['category'] . ' ' . $fcurrpage['name'], $fid, 'Tambah'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { $query = "UPDATE tdebtpayment SET \n\t\t\t\t\t\t\t\t\t\t\t\tdebtpayment_date='{$fpaymentdate}',\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tdebt_id='{$fdebtid}',\n\t\t\t\t\t\t\t\t\t\t\t\tuser_id='{$fuser}',\n\t\t\t\t\t\t\t\t\t\t\t\tdebtpayment_description='{$fdescription}',\n\t\t\t\t\t\t\t\t\t\t\t\tdebtpayment_nominal={$fnominal},\n\t\t\t\t\t\t\t\t\t\t\t\tdebtpayment_status='{$fstatus}'\n\t\t\t\t\t\t\t\t\t\t\tWHERE debtpayment_id='{$fid}'"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Data Pembayaran utang berhasil diubah.'); // Insert Activity Log
$alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $go = false; } } if (strlen($faddress) < 6) { $alert[] = array('type' => 'danger', 'message' => 'Panjang Alamat minimal 6 karakter!'); $go = false; } if (strlen($fcity) < 3) { $alert[] = array('type' => 'danger', 'message' => 'Panjang Kota minimal 3 karakter!'); $go = false; } /* Validation Success */ if ($go == true) { if ($fcommand == 'create') { $fid = autoGenerateID($mysqli, "SUP", "tsupplier", "supplier_id", 4); $query = "INSERT INTO tsupplier \n\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$fid}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fname}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$faddress}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fcity}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fphone}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fdescription}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL)\n\t\t\t\t\t\t\t\t\t\t "; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Supplier baru telah ditambahkan.'); // Insert Activity Log addLog($mysqli, $flogin['user_id'], $fcurrpage['category'] . ' ' . $fcurrpage['name'], $fid, 'Tambah'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { $query = "UPDATE tsupplier SET \n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_name='{$fname}',\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_address='{$faddress}',\n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_city='{$fcity}',\n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_phone='{$fphone}',\n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_description='{$fdescription}'\n\t\t\t\t\t\t\t\t\t\t\tWHERE supplier_id='{$fid}'"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Data Supplier berhasil diubah.'); // Insert Activity Log
$go = false; } if ($fphoto == '') { $alert[] = array('type' => 'danger', 'message' => 'Foto masih kosong!'); $go = false; } if ($fnominal < 1) { $alert[] = array('type' => 'danger', 'message' => 'Nominal utang harus lebih dari 0!'); $go = false; } /* Validation Success */ if ($go == true) { // Convert DateTime to String $fdebtdate = $ftempdate->format('Y-m-d'); if ($fcommand == 'create') { $fid = autoGenerateID($mysqli, "DB" . $ftempdate->format('ym'), "tdebt", "debt_id", 6); $query = "INSERT INTO tdebt \n\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$fid}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fdebtdate}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fsupplier}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fuser}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fdescription}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$fnominal},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fphoto}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fstatus}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL)\n\t\t\t\t\t\t\t\t\t\t "; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Utang baru telah ditambahkan.'); // Insert Activity Log addLog($mysqli, $flogin['user_id'], $fcurrpage['category'] . ' ' . $fcurrpage['name'], $fid, 'Tambah'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { $query = "UPDATE tdebt SET \n\t\t\t\t\t\t\t\t\t\t\t\tdebt_date='{$fdebtdate}',\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tsupplier_id='{$fsupplier}',\n\t\t\t\t\t\t\t\t\t\t\t\tuser_id='{$fuser}',\n\t\t\t\t\t\t\t\t\t\t\t\tdebt_description='{$fdescription}',\n\t\t\t\t\t\t\t\t\t\t\t\tdebt_nominal={$fnominal},\n\t\t\t\t\t\t\t\t\t\t\t\tdebt_imageblob='{$fphoto}',\n\t\t\t\t\t\t\t\t\t\t\t\tdebt_status='{$fstatus}'\n\t\t\t\t\t\t\t\t\t\t\tWHERE debt_id='{$fid}'"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Data Utang berhasil diubah.'); // Insert Activity Log
$go = false; } } if (strlen($fcompletename) < 4) { $alert[] = array('type' => 'danger', 'message' => 'Panjang Nama Lengkap minimal 4 karakter!'); $go = false; } if ($flevel == '0') { $alert[] = array('type' => 'danger', 'message' => 'Isi data Level User terlebih dahulu!'); $go = false; } /* Validation Success */ if ($go == true) { if ($fcommand == 'create') { // Insert User $fid = autoGenerateID($mysqli, "USER", "tuser", "user_id", 4); $fpass = sha1(md5(123456)); $query = "INSERT INTO tuser \n\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$fid}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fname}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fpass}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$fcompletename}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$flevel}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Offline',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNULL)\n\t\t\t\t\t\t\t\t\t\t "; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'User baru telah ditambahkan.'); // Insert Activity Log addLog($mysqli, $flogin['user_id'], $fcurrpage['category'] . ' ' . $fcurrpage['name'], $fid, 'Tambah'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { // Update User Level $query = "UPDATE tuser SET \n\t\t\t\t\t\t\t\t\t\t\t\tuser_name='{$fname}',\n\t\t\t\t\t\t\t\t\t\t\t\tuser_completename='{$fcompletename}',\n\t\t\t\t\t\t\t\t\t\t\t\tlevel_id='{$flevel}'\n\t\t\t\t\t\t\t\t\t\t\tWHERE user_id='{$fid}'"; if ($result = $mysqli->query($query)) {
} if ($result = $mysqli->query($query)) { if ($result->num_rows > 0) { $alert[] = array('type' => 'danger', 'message' => 'Nama Level User sudah pernah didaftarkan!'); $go = false; } } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $go = false; } } /* Validation Success */ if ($go == true) { if ($fcommand == 'create') { // Insert User Level $fid = autoGenerateID($mysqli, "LEV", "tuser_level", "level_id", 4); $query = "INSERT INTO tuser_level VALUES ('{$fid}','{$fname}','{$fdesc}',NULL);"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Level User baru telah ditambahkan.'); // Insert Activity Log addLog($mysqli, $flogin['user_id'], $fcurrpage['category'] . ' ' . $fcurrpage['name'], $fid, 'Tambah'); } else { $alert[] = array('type' => 'danger', 'message' => "Errormessage: " . $mysqli->error); $isSuccess = false; } } else { if ($fcommand == 'update') { // Update User Level $query = "UPDATE tuser_level SET \n\t\t\t\t\t\t\t\t\t\t\t\tlevel_name='{$fname}',\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tlevel_description='{$fdesc}'\n\t\t\t\t\t\t\t\t\t\t\tWHERE level_id='{$fid}'"; if ($result = $mysqli->query($query)) { $alert[] = array('type' => 'success', 'message' => 'Data Level User berhasil diubah.');