From 170e2796938fa48019a2eb57fa8190876159b2d5 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Fri, 8 Nov 2024 00:16:03 +0100 Subject: [PATCH] =?UTF-8?q?Poprawa=20walidacji=20danych=20w=20metodach=20p?= =?UTF-8?q?=C5=82atno=C5=9Bci=20oraz=20aktualizacja=20obs=C5=82ugi=20b?= =?UTF-8?q?=C5=82=C4=99d=C3=B3w=20w=20AJAX=20i=20poprawa=20formatowania=20?= =?UTF-8?q?kodu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop-payment-method/view-list.php | 3 +- libraries/grid/ajax.php | 2 ++ libraries/grid/gdb.min.php | 2 +- libraries/grid/grid.php | 5 +-- libraries/grid/js/grid.js | 2 +- libraries/grid/templates/edit.php | 32 +++++++++---------- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/admin/templates/shop-payment-method/view-list.php b/admin/templates/shop-payment-method/view-list.php index 08d9c01..23961f5 100644 --- a/admin/templates/shop-payment-method/view-list.php +++ b/admin/templates/shop-payment-method/view-list.php @@ -2,7 +2,8 @@ global $gdb; 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_types_list = []; diff --git a/libraries/grid/ajax.php b/libraries/grid/ajax.php index 56e203e..0d3214e 100644 --- a/libraries/grid/ajax.php +++ b/libraries/grid/ajax.php @@ -1,9 +1,11 @@ exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode($values, ', ') . ')'); + $this->exec('INSERT INTO "' . $table . '" (' . implode(', ', $columns) . ') VALUES (' . implode(', ',$values) . ')'); $lastId[] = $this->pdo->lastInsertId(); } diff --git a/libraries/grid/grid.php b/libraries/grid/grid.php index f77c6e5..0b477ad 100644 --- a/libraries/grid/grid.php +++ b/libraries/grid/grid.php @@ -145,7 +145,7 @@ class grid 'server' => $this -> gdb_opt['server'], 'username' => $this -> gdb_opt['username'], 'password' => $this -> gdb_opt['password'], - 'port' => $this -> gdb_opt['port'], + 'port' => isset( $this -> gdb_opt['port'] ) ? $this -> gdb_opt['port'] : 3306, 'charset' => 'utf8' ] ); } @@ -437,6 +437,7 @@ class grid public function getDataSummary() { + $summary = []; $where = self::getWhereCondition(); if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key ) @@ -511,7 +512,7 @@ class grid public function saveElement( $values ) { - if ( !$values[ $this -> id ] ) + if ( !isset( $values[ $this -> id ] ) or !$values[ $this -> id ] ) { unset( $values[ $this -> id ] ); return $this -> connectToDb() -> insert( $this -> table, $values ); diff --git a/libraries/grid/js/grid.js b/libraries/grid/js/grid.js index 75f3a7c..bd3c5bb 100644 --- a/libraries/grid/js/grid.js +++ b/libraries/grid/js/grid.js @@ -631,7 +631,7 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function() data: { gtable: gtable, - values: JSON.stringify( values ), + values: JSON.stringify( formattedValues ), a: 'gsave' }, beforeSend: function() diff --git a/libraries/grid/templates/edit.php b/libraries/grid/templates/edit.php index 2f7289c..3985f72 100644 --- a/libraries/grid/templates/edit.php +++ b/libraries/grid/templates/edit.php @@ -17,19 +17,19 @@
- $val ): - echo $key . '="' . $val . '"'; + $val ): + echo $key . '="' . $val . '"'; endforeach; endif; ?> value=" element[ $ce['db'] ] );?>" element[ $this -> values['id'] ] ):?>readonly="readonly" />