Poprawa walidacji danych w metodach płatności oraz aktualizacja obsługi błędów w AJAX i poprawa formatowania kodu

This commit is contained in:
2024-11-08 00:16:03 +01:00
parent bad0e5c830
commit 170e279693
6 changed files with 25 additions and 21 deletions

View File

@@ -2,7 +2,8 @@
global $gdb; global $gdb;
foreach ( $this -> apilo_payment_types_list as $payment_type ) foreach ( $this -> apilo_payment_types_list as $payment_type )
{ {
$payment_types[ $payment_type['id'] ] = $payment_type['name']; if ( isset( $payment_type['name'] ) && isset( $payment_type['id'] ) )
$payment_types[ $payment_type['id'] ] = $payment_type['name'];
} }
// sellasist payment methods // sellasist payment methods
$sellasist_payment_types_list = []; $sellasist_payment_types_list = [];

View File

@@ -1,9 +1,11 @@
<?php <?php
error_reporting( 0 );
require_once dirname( __FILE__ ) . '/config.php'; require_once dirname( __FILE__ ) . '/config.php';
/* grid - zapisanie elementu */ /* grid - zapisanie elementu */
if ( $_POST['a'] == 'gsave' ) if ( $_POST['a'] == 'gsave' )
{ {
$msg = '';
$grid = $_SESSION[ 'g' . $_POST[ 'gtable' ] ]; $grid = $_SESSION[ 'g' . $_POST[ 'gtable' ] ];
if ( is_a( $grid, 'grid' ) ) if ( is_a( $grid, 'grid' ) )
{ {

View File

@@ -722,7 +722,7 @@ class gdb
} }
} }
$this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode($values, ', ') . ')'); $this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode(', ',$values) . ')');
$lastId[] = $this->pdo->lastInsertId(); $lastId[] = $this->pdo->lastInsertId();
} }

View File

@@ -145,7 +145,7 @@ class grid
'server' => $this -> gdb_opt['server'], 'server' => $this -> gdb_opt['server'],
'username' => $this -> gdb_opt['username'], 'username' => $this -> gdb_opt['username'],
'password' => $this -> gdb_opt['password'], 'password' => $this -> gdb_opt['password'],
'port' => $this -> gdb_opt['port'], 'port' => isset( $this -> gdb_opt['port'] ) ? $this -> gdb_opt['port'] : 3306,
'charset' => 'utf8' 'charset' => 'utf8'
] ); ] );
} }
@@ -437,6 +437,7 @@ class grid
public function getDataSummary() public function getDataSummary()
{ {
$summary = [];
$where = self::getWhereCondition(); $where = self::getWhereCondition();
if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key ) if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key )
@@ -511,7 +512,7 @@ class grid
public function saveElement( $values ) public function saveElement( $values )
{ {
if ( !$values[ $this -> id ] ) if ( !isset( $values[ $this -> id ] ) or !$values[ $this -> id ] )
{ {
unset( $values[ $this -> id ] ); unset( $values[ $this -> id ] );
return $this -> connectToDb() -> insert( $this -> table, $values ); return $this -> connectToDb() -> insert( $this -> table, $values );

View File

@@ -631,7 +631,7 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
data: data:
{ {
gtable: gtable, gtable: gtable,
values: JSON.stringify( values ), values: JSON.stringify( formattedValues ),
a: 'gsave' a: 'gsave'
}, },
beforeSend: function() beforeSend: function()

View File

@@ -17,19 +17,19 @@
<label for="<?= $ce['db'];?>" class="col-lg-3 control-label"><?= $ce['name'];?>:</label> <label for="<?= $ce['db'];?>" class="col-lg-3 control-label"><?= $ce['name'];?>:</label>
<? if ( $ce['type'] == 'text' ):?> <? if ( $ce['type'] == 'text' ):?>
<div class="col-lg-9"> <div class="col-lg-9">
<input type="text" class="form-control <? if ( $ce['require'] ):?>require<? endif;?>" name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" <input type="text" class="form-control <? if ( isset( $ce['require'] ) and $ce['require'] ):?>require<? endif;?>" name="<?= $ce['db'];?>" id="<?= $ce['db'];?>"
<? <?
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ): if ( isset( $ce['params'] ) and is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"'; echo $key . '="' . $val . '"';
endforeach; endif; endforeach; endif;
?> value="<?= htmlspecialchars( $this -> element[ $ce['db'] ] );?>" <? if ( $ce['readonly-edit'] and $this -> element[ $this -> values['id'] ] ):?>readonly="readonly"<? endif;?> /> ?> value="<?= htmlspecialchars( $this -> element[ $ce['db'] ] );?>" <? if ( $ce['readonly-edit'] and $this -> element[ $this -> values['id'] ] ):?>readonly="readonly"<? endif;?> />
</div> </div>
<? elseif ( $ce['type'] == 'select' ):?> <? elseif ( $ce['type'] == 'select' ):?>
<div class="col-lg-9"> <div class="col-lg-9">
<select name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control <? if ( $ce['require'] ):?>require<? endif;?>" <select name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control <? if ( $ce['require'] ):?>require<? endif;?>"
<? <?
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ): if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"'; echo $key . '="' . $val . '"';
endforeach; endif; endforeach; endif;
?>> ?>>
<option value="null">---- <?= $ce['name'];?> ----</option> <option value="null">---- <?= $ce['name'];?> ----</option>
@@ -38,20 +38,20 @@
$results = $_SESSION[ 'g' . $g_table ] -> connectToDb() -> query( $ce['replace']['sql'] ) -> fetchAll(); $results = $_SESSION[ 'g' . $g_table ] -> connectToDb() -> query( $ce['replace']['sql'] ) -> fetchAll();
if ( is_array( $results ) ) foreach ( $results as $row ) if ( is_array( $results ) ) foreach ( $results as $row )
{ {
echo '<option value="' . $row[0] . '"'; echo '<option value="' . $row[0] . '"';
if ( $this -> element[ $ce['db'] ] !== null and $row[0] == $this -> element[ $ce['db'] ] ) if ( $this -> element[ $ce['db'] ] !== null and $row[0] == $this -> element[ $ce['db'] ] )
echo ' selected="selected" '; echo ' selected="selected" ';
echo '>' . $row[1] . '</option>'; echo '>' . $row[1] . '</option>';
} }
?> ?>
<? else:?> <? else:?>
<? <?
if ( is_array( $ce['replace']['array'] ) ): foreach ( $ce['replace']['array'] as $key => $val ): if ( is_array( $ce['replace']['array'] ) ): foreach ( $ce['replace']['array'] as $key => $val ):
?> ?>
<option value="<?= $key;?>" <option value="<?= $key;?>"
<? if ( <? if (
( $this -> element[ $ce['db'] ] !== null and $key == $this -> element[ $ce['db'] ] ) ( $this -> element[ $ce['db'] ] !== null and $key == $this -> element[ $ce['db'] ] )
or or
( $this -> element[ $ce['db'] ] === null and isset( $ce['default_value'] ) and $ce['default_value'] == $key ) ( $this -> element[ $ce['db'] ] === null and isset( $ce['default_value'] ) and $ce['default_value'] == $key )
):?> ):?>
selected="selected" selected="selected"
@@ -59,7 +59,7 @@
> >
<?= $val;?> <?= $val;?>
</option> </option>
<? <?
endforeach; endif; endforeach; endif;
?> ?>
<? endif;?> <? endif;?>
@@ -77,9 +77,9 @@
<? elseif ( $ce['type'] == 'textarea' ):?> <? elseif ( $ce['type'] == 'textarea' ):?>
<div class="col col-lg-9"> <div class="col col-lg-9">
<textarea name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control" <textarea name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control"
<? <?
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ): if ( isset( $ce['params'] ) and is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"'; echo $key . '="' . $val . '"';
endforeach; endif; endforeach; endif;
?>><?= $this -> element[ $ce['db'] ];?></textarea> ?>><?= $this -> element[ $ce['db'] ];?></textarea>
</div> </div>