Skip to content

Commit

Permalink
Merge branch 'develop' of https://gitlab.com/slims/slims9_bulian into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
drajathasan committed Jun 18, 2023
2 parents 08cc7e9 + 802e8b1 commit b918d1c
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 69 deletions.
4 changes: 4 additions & 0 deletions admin/admin_template/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1450,4 +1450,8 @@ button.prev-btn {

pre.sf-dump, pre.sf-dump .sf-dump-default {
z-index: 0 !important;
}

input[id*='simbio-checkbox-'], label[for*='simbio-checkbox-'] {
cursor: pointer !important;
}
6 changes: 5 additions & 1 deletion admin/modules/bibliography/marcsru.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
die('<div class="errorBox">'.__('You are not authorized to view this section').'</div>');
}

if (!\Marc\XMLParser::isSupport()) {
die('<div class="errorBox">'.__('Extension XML is not enabled').'</div>');
}

// get servers
$server_q = $dbs->query('SELECT name, uri FROM mst_servers WHERE server_type = 4 ORDER BY name ASC');
while ($server = $server_q->fetch_assoc()) {
Expand All @@ -59,7 +63,7 @@
$inList = (bool)count(array_filter($sysconf['marc_SRU_source'], fn($sru) => trim(urldecode($_GET['marc_SRU_source'])) == $sru['uri']));
$zserver = $inList ? trim(urldecode($_GET['marc_SRU_source'])) : '';
} else {
$zserver = 'http://opac.perpusnas.go.id/sru.aspx';
$zserver = 'https://opac.perpusnas.go.id/sru.aspx';
}

function getAcronym($sentence)
Expand Down
2 changes: 1 addition & 1 deletion admin/modules/stock_take/resync.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
LEFT JOIN biblio AS b ON i.biblio_id=b.biblio_id
LEFT JOIN mst_gmd AS g ON b.gmd_id=g.gmd_id
SET sti.title=b.title, sti.gmd_name=g.gmd_name,
sti.classification=b.classification, sti.call_number=b.call_number,
sti.classification=b.classification, sti.call_number=i.call_number,
sti.coll_type_name=ct.coll_type_name');
if (!$dbs->error) {
$aff_rows = $dbs->affected_rows;
Expand Down
44 changes: 23 additions & 21 deletions admin/modules/system/plugin_action.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<?php
/**
* @Source by : Waris Agung Widodo ([email protected])
* @Created Date : 05/11/20 21.33
* @File name : plugins.php
* @Modified by : Drajat Hasan ([email protected])
*/

use SLiMS\DB;
use SLiMS\Migration\Runner;
use SLiMS\Json;
use SLiMS\Jquery;
use SLiMS\Plugins;
use SLiMS\Filesystems\Storage;
use SLiMS\Parcel\Package;
use SLiMS\Migration\Runner;
use SLiMS\Filesystems\Storage;

define('INDEX_AUTH', 1);

Expand All @@ -14,6 +22,7 @@
require SB . 'admin/default/session_check.inc.php';

$plugins = Plugins::getInstance();
$upload_success = false;

if (count($_POST) == 0) $_POST = json_decode(file_get_contents('php://input'), true);

Expand Down Expand Up @@ -53,7 +62,7 @@
if (dirname($plugin->path) == $pluginPath) return true;
}));
});

$upload_success = true;
}
else
{
Expand Down Expand Up @@ -107,27 +116,20 @@

$run = $query->execute();

if ($run) {
if (isset($_POST['format'])) echo json_encode(['status' => true, 'message' => $message]);
} else {
if (isset($_POST['format'])) echo json_encode(['status' => false, 'message' => DB::getInstance()->errorInfo()]);
}
if (!$run) $message = __('Something error : turn on development mode to get more information');

if (!isset($_POST['format'])) {
$message = toastr($run == false ? DB::getInstance()->errorInfo() : $message);
if ($run == false) $message->error();
else $message->success();
}
if (isset($_POST['format'])) echo Json::stringify(['status' => (bool)$run, 'message' => $message])->withHeader();
else toastr($message . ' 1')->{($run === false ? 'error' : 'success')};

} catch (Exception $exception) {
if (isset($_POST['format'])) echo json_encode(['status' => false, 'message' => $exception->getMessage()]);
else toastr($exception->getMessage())->error();
if (isset($_POST['format'])) echo Json::stringify(['status' => false, 'message' => $exception->getMessage()])->withHeader();
else toastr($exception->getMessage() . ' 2')->error();
}

// redirect content
if ($upload_success) {
Jquery::raw('colorbox.close()');
redirect()->simbioAJAX(AWB . 'modules/system/plugins.php');
}
exit();
}

// if (isset($_POST['upload'])) {

// exit;
// }
}
2 changes: 1 addition & 1 deletion admin/modules/system/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{
$package = Package::prepare(SB . 'files/temp/test.zip');
ob_start();
if ($package->isCompressorExists()) {
if ($package?->isCompressorExists()) {
// create new instance
$form = new simbio_form_table_AJAX('mainForm', MWB . 'system/plugin_action.php', 'post');
$form->submit_button_attr = 'name="upload" value="' . __('Save') . '" class="s-btn btn btn-default"';
Expand Down
2 changes: 1 addition & 1 deletion install/install.sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@
$sql['create'][] = "CREATE TABLE IF NOT EXISTS `mst_visitor_room` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`unique_code` int(11) NOT NULL COMMENT 'Code for identification each room',
`unique_code` varchar(5) NOT NULL COMMENT 'Code for identification each room',
`created_at` datetime DEFAULT NULL,
`updated_at`datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
Expand Down
129 changes: 129 additions & 0 deletions lib/Jquery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
* @author Drajat Hasan
* @email [email protected]
* @create date 2023-06-06 05:39:26
* @modify date 2023-06-06 15:59:35
* @license GPLv3
* @desc [description]
*/
namespace SLiMS;

use Closure;

class Jquery
{
private static ?object $instance = null;
private string $mainSelector = '';
private string $result = '';
private string $contents = '';
public string $position = 'top.';

private function __construct(){}

public static function getInstance(string $mainSelector)
{
if (is_null(self::$instance)) self::$instance = new Jquery;
self::$instance->mainSelector = $mainSelector;
return self::$instance;
}

public static function raw(string $content)
{
$instance = self::getInstance('');
$instance->contents = $instance->position . 'jQuery.' . $content;
echo $instance;
$instance->contents = '';
}

public function writeIfExists(string $contents):void
{
$position = $this->position;
$message = isDev() ? "alert('jQuery not exists!')" : "console.log('jQuery not exists!')";
$this->result = <<<HTML
<script type="text/javascript">
if (typeof {$position}\$ === 'function') {
{$position}\$(document).ready(function(){
{$contents}
})
} else { {$message} }
</script>
HTML;
}

public function delayIn(int $timeout)
{
$contents = $this->contents;
$this->contents = '';
$this->setContent(<<<HTML
setTimeout(() => {$contents}, {$timeout})
HTML);
return $this;
}

public function on(string $selector, string $eventListener, Closure|string $contents)
{
$position = $this->position;
$mainSelector = $this->mainSelector;
$this->setContent(<<<HTML
{$position}\$('{$mainSelector}').on('{$eventListener}', '{$selector}', function(e){
{$contents}
})
HTML);
}

public function getContents()
{
return $this->contents;
}

public function getResult()
{
return $this->result;
}

public function setPosition(string $position)
{
$this->position = $position;
return $this;
}

private function setContent(string $content)
{
$this->contents .= $content . PHP_EOL;
}


public function __call($method, $parameters)
{
if (!method_exists($this, $method)) {
$mainSelector = $this->mainSelector;
$position = $this->position;

if (count($parameters) === 1 && is_callable($parameters[0]))
{
$contents = <<<HTML
function(e) {
{$parameters[0]()}
}
HTML;
} else if (count($parameters) === 1 && substr($parameters[0], 0,1) === "'") {
$contents = $parameters[0];
} else {
$contents = "'" . implode(',', $parameters) . "'";
}

$this->setContent(<<<HTML
{$position}\$('{$mainSelector}').{$method}({$contents})
HTML);

return $this;
}
}

public function __toString():String
{
$this->writeIfExists($this->contents);
return $this->getResult();
}
}
14 changes: 13 additions & 1 deletion lib/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Drajat Hasan
* @email [email protected]
* @create date 2022-10-06 22:44:30
* @modify date 2022-11-12 05:27:50
* @modify date 2023-06-04 06:20:36
* @license GPLv3
* @desc [description]
*/
Expand Down Expand Up @@ -51,6 +51,7 @@ private function __construct()
//Recipients
$this->setFrom($mail['from'], $mail['from_name']);
$this->addReplyTo($mail['reply_to'], $mail['reply_to_name']);
$this->charSet($mail['charset']??'UTF-8');
}

public static function getInstance()
Expand Down Expand Up @@ -85,6 +86,17 @@ public function subject(string $mailObject)
return $this;
}

/**
* Set content charset
*
* @param string $charSet
* @return void
*/
public function charSet(string $charSet)
{
$this->CharSet = $charSet;
}

/**
* Set plain message without html format
*
Expand Down
7 changes: 6 additions & 1 deletion lib/Parcel/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Drajat Hasan
* @email [email protected]
* @create date 2023-04-06 07:59:09
* @modify date 2023-04-06 13:36:54
* @modify date 2023-06-06 05:35:28
* @license GPLv3
* @desc [description]
*/
Expand Down Expand Up @@ -92,4 +92,9 @@ public function getIterator(): \Traversable
{
return new \ArrayIterator($this->packages);
}

public static function getError()
{
return self::getInstance()->error;
}
}
2 changes: 1 addition & 1 deletion lib/Session/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public function start(string $sessionSection)
if (!method_exists($this->driver, $sessionSection)) throw new \Exception("Section fro $sessionSection is not available!");
$this->driver->{$sessionSection}();
// start session
session_start();
if (session_status() === PHP_SESSION_NONE) session_start();
}
}
21 changes: 17 additions & 4 deletions lib/helper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
*
*/

use SLiMS\{Config,Ip,Number,Currency,Json};
use SLiMS\Config;
use SLiMS\Ip;
use SLiMS\Number;
use SLiMS\Currency;
use SLiMS\Json;
use SLiMS\Jquery;
use SLiMS\Http\Redirect;
use SLiMS\Session\Flash;

Expand Down Expand Up @@ -134,6 +139,15 @@ public function __call($method, $arguments)
}
}

if (!function_exists('jQuery'))
{
function jQuery(string $selector = '')
{
if (!empty($selector)) return Jquery::getInstance($selector);
echo Jquery::getInstance('');
}
}

if (!function_exists('redirect'))
{
/**
Expand All @@ -159,9 +173,7 @@ function redirect(string $urlOrPath = '')
public function simbioAJAX(string $url, string $data = '', string $position = 'top.', string $selector = '#mainContent', int $timeout = 0)
{
$params = empty($data) ? "'$url'" : "'$url', {method: 'post', addData: '$data'}";
exit(<<<HTML
<script>setTimeout(() => {$position}\$('{$selector}').simbioAJAX({$params}), {$timeout})</script>
HTML);
exit(jQuery($selector)->setPosition($position)->simbioAJAX($params)->delayIn($timeout));
}

public function __call($method, $arguments)
Expand All @@ -179,6 +191,7 @@ public function __call($method, $arguments)
}
}


if (!function_exists('toastr'))
{
/**
Expand Down
Loading

0 comments on commit b918d1c

Please sign in to comment.