Skip to content

Commit

Permalink
Merge pull request #125 from reactmore/development
Browse files Browse the repository at this point in the history
Add : General Settings School
  • Loading branch information
ikhsan3adi authored Jul 27, 2024
2 parents f278b44 + 0910b1c commit 59ba924
Show file tree
Hide file tree
Showing 34 changed files with 762 additions and 91 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ phpunit
vendor/

# uploads
public/uploads
public/uploads/*
!public/uploads/index.html
!public/uploads/logo/index.html
!public/uploads/tmp/index.html

#-------------------------
# IDE / Development Files
Expand Down
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,9 @@ Aplikasi Web Sistem Absensi Sekolah Berbasis QR Code adalah sebuah proyek yang b
>
> - Konfigurasi file `.env` untuk mengatur base url(terutama jika melakukan hosting), koneksi database dan pengaturan lainnya sesuai dengan lingkungan pengembangan Anda.
>
> - Untuk mengubah konfigurasi nama sekolah, tahun ajaran dll, buka file konfigurasi `app/Config/AbsensiSekolah.php` dan ubah pada:
>
> ```php
> // NAMA SEKOLAH
> const SCHOOL_NAME = 'SMK 1 Indonesia';
>
> // TAHUN AJARAN
> const SCHOOL_YEAR = '2024/2025';
>
> // ...
> ```
> - Untuk mengubah konfigurasi nama sekolah, tahun ajaran logo sekolah dll sudah disediakan pengaturan di admin panel.
>
> - Ganti/replace logo sekolah di `public/assets/img/logo_sekolah.jpg`.
> - Logo Sekolah Rekomendasi 100x100px atau 1:1 dan berformat PNG/JPG.
>
> - Jika ingin mengubah email, username & password dari superadmin, buka file `app\Database\Migrations\2023-08-18-000004_AddSuperadmin.php` lalu ubah & sesuaikan kode berikut:
>
Expand All @@ -157,7 +147,7 @@ Aplikasi Web Sistem Absensi Sekolah Berbasis QR Code adalah sebuah proyek yang b
Dengan aplikasi web sistem absensi sekolah berbasis QR code ini, diharapkan proses absensi di sekolah menjadi lebih efisien dan terotomatisasi. Proyek ini dapat diadaptasi dan dikembangkan lebih lanjut sesuai dengan kebutuhan dan persyaratan sekolah Anda.
Jangan lupa beri star ya...⭐
Jangan lupa beri star ya...⭐⭐⭐
## Contributing
Expand Down
248 changes: 248 additions & 0 deletions app/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,251 @@
*
* @see: https://codeigniter4.github.io/CodeIgniter4/
*/


//clean string
if (!function_exists('cleanStr')) {
function cleanStr($str)
{
$str = strTrim($str);
$str = removeSpecialCharacters($str);
return esc($str);
}
}

//clean number
if (!function_exists('cleanNumber')) {
function cleanNumber($num)
{
$num = strTrim($num);
$num = esc($num);
if (empty($num)) {
return 0;
}
return intval($num);
}
}

//clean number
if (!function_exists('clrQuotes')) {
function clrQuotes($str)
{
$str = strReplace('"', '', $str);
$str = strReplace("'", '', $str);
return $str;
}
}

/**
* Get validation rules
*
* @return Rules
*/
if (!function_exists('getValRules')) {
function getValRules($val)
{
$rules = $val->getRules();
$newRules = array();
if (!empty($rules)) {
foreach ($rules as $key => $rule) {
$newRules[$key] = [
'label' => $rule['label'],
'rules' => $rule['rules'],
'errors' => [
'required' => lang("Validation.form_validation_required"),
'min_length' => lang("Validation.form_validation_min_length"),
'max_length' => lang("Validation.form_validation_max_length"),
'matches' => lang("Validation.form_validation_matches"),
'is_unique' => lang("Validation.form_validation_is_unique")
]
];
}
}
return $newRules;
}
}

/**
* STR TRIM
*
* TRIM string
*
* @return string
*/
if (!function_exists('strTrim')) {
function strTrim($str)
{
if (!empty($str)) {
return trim($str);
}
}
}

/**
* STR Replace
*
* Replace string
*
* @return string
*/
if (!function_exists('strReplace')) {
function strReplace($search, $replace, $str)
{
if (!empty($str)) {
return str_replace($search, $replace, $str);
}
}
}

/**
* POST Request
*
* Sanitaze Input Post
*
* @return string
*/
if (!function_exists('inputPost')) {
function inputPost($input_name, $removeForbidden = false)
{
$input = \Config\Services::request()->getPost($input_name);
if (!is_array($input)) {
$input = strTrim($input);
}
if ($removeForbidden) {
$input = removeForbiddenCharacters($input);
}
return $input;
}
}

/**
* GET Request
*
* Sanitaze Input GET
*
* @return string
*/
if (!function_exists('inputGet')) {
function inputGet($input_name, $removeForbidden = false)
{
$input = \Config\Services::request()->getGet($input_name);
if (!is_array($input)) {
$input = strTrim($input);
}
if ($removeForbidden) {
$input = removeForbiddenCharacters($input);
}
return $input;
}
}

/**
* remove forbidden characters
*
*
* @return string
*/
if (!function_exists('removeForbiddenCharacters')) {
function removeForbiddenCharacters($str)
{
$str = strTrim($str);
$str = strReplace(';', '', $str);
$str = strReplace('"', '', $str);
$str = strReplace('$', '', $str);
$str = strReplace('%', '', $str);
$str = strReplace('*', '', $str);
$str = strReplace('/', '', $str);
$str = strReplace('\'', '', $str);
$str = strReplace('<', '', $str);
$str = strReplace('>', '', $str);
$str = strReplace('=', '', $str);
$str = strReplace('?', '', $str);
$str = strReplace('[', '', $str);
$str = strReplace(']', '', $str);
$str = strReplace('\\', '', $str);
$str = strReplace('^', '', $str);
$str = strReplace('`', '', $str);
$str = strReplace('{', '', $str);
$str = strReplace('}', '', $str);
$str = strReplace('|', '', $str);
$str = strReplace('~', '', $str);
$str = strReplace('+', '', $str);
return $str;
}
}

/**
* remove special characters
*
*
* @return string
*/
if (!function_exists('removeSpecialCharacters')) {
function removeSpecialCharacters($str, $removeQuotes = false)
{
$str = removeForbiddenCharacters($str);
$str = strReplace('#', '', $str);
$str = strReplace('!', '', $str);
$str = strReplace('(', '', $str);
$str = strReplace(')', '', $str);
if ($removeQuotes) {
$str = clrQuotes($str);
}
return $str;
}
}

/**
* Get Logo
*
* @return string
*/
if (!function_exists('getLogo')) {
function getLogo()
{
$schoolConfigurations = new \Config\School();
$generalSettings = $schoolConfigurations::$generalSettings;
if (!empty($generalSettings)) {
if (!empty($generalSettings->logo) && file_exists(FCPATH . $generalSettings->logo)) {
return base_url($generalSettings->logo);
}
return base_url("assets/img/logo_sekolah.jpg");
}
return base_url("assets/img/logo_sekolah.jpg");
}
}

/**
* Invalid Feedback
*
* @return
*/
if (!function_exists('invalidFeedback')) {
function invalidFeedback($input)
{
$session = session();
if ($session->getFlashdata('errors')) {
$errors = $session->getFlashdata('errors');
if (!empty($errors[$input])) {
return esc($errors[$input]);
}

return null;
}

return null;
}
}

//generate unique id
if (!function_exists('generateToken')) {
function generateToken($short = false)
{
$token = uniqid('', true);
$token = strReplace('.', '-', $token);
if ($short == false) {
$token = $token . '-' . rand(10000000, 99999999);
}
return $token;
}
}
26 changes: 0 additions & 26 deletions app/Config/AbsensiSekolah.php

This file was deleted.

4 changes: 3 additions & 1 deletion app/Config/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class Autoload extends AutoloadConfig
*
* @var array<string, string>
*/
public $classmap = [];
public $classmap = [
'School' => APPPATH . 'Config/School.php'
];

/**
* -------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
$routes->post('petugas/edit', 'Admin\DataPetugas::updatePetugas');
// superadmin hapus data petugas
$routes->delete('petugas/delete/(:any)', 'Admin\DataPetugas::delete/$1');

// Settings
$routes->group('general-settings', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
$routes->get('/', 'GeneralSettings::index');
$routes->post('update', 'GeneralSettings::generalSettingsPost');
});
});


Expand Down
26 changes: 26 additions & 0 deletions app/Config/School.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/* Don't change or add any new config in this file */

namespace Config;

use CodeIgniter\Config\BaseConfig;

class School extends BaseConfig
{
private $db;

public static $generalSettings;

public function __construct()
{
$this->db = \Config\Database::connect();
$this->setGlobalConfigurations();
}

private function setGlobalConfigurations()
{
// Get General Settings
self::$generalSettings = $this->db->table('general_settings')->where('id', 1)->get()->getRow();
}
}
5 changes: 0 additions & 5 deletions app/Controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class Dashboard extends BaseController

protected PetugasModel $petugasModel;

protected string $namaSekolah;

public function __construct()
{
$this->siswaModel = new SiswaModel();
Expand All @@ -35,7 +33,6 @@ public function __construct()
$this->presensiSiswaModel = new PresensiSiswaModel();
$this->presensiGuruModel = new PresensiGuruModel();
$this->petugasModel = new PetugasModel();
$this->namaSekolah = ConfigAbsensiSekolah::SCHOOL_NAME;
}

public function index()
Expand Down Expand Up @@ -101,8 +98,6 @@ public function index()
],

'petugas' => $this->petugasModel->getAllPetugas(),

'namaSekolah' => $this->namaSekolah,
];

return view('admin/dashboard', $data);
Expand Down
Loading

0 comments on commit 59ba924

Please sign in to comment.