]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-payments.php
Some more cleanups/improvements:
[mailer.git] / inc / modules / admin / what-payments.php
index 2860ab6933860b50a393895b9144f64318519700..71dad294d453508ec150b0d1cc3615d5c0a34720 100644 (file)
@@ -53,27 +53,22 @@ if (isFormSent()) {
        switch (getRequestParameter('do')) {
                case 'add':
                        addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
-                       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `time`='%s' LIMIT 1",
-                               array(postRequestParameter('t_wait')), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result) == 1) {
+                       if (countSumTotalData(postRequestParameter('t_wait'), 'payments', 'id', 'time', true) == 1) {
                                // Re-init the array here
                                initSqls();
-
-                               // Free memory
-                               SQL_FREERESULT($result);
-                       }
+                       } // END - if
                        break;
 
                case 'edit':
                        foreach (postRequestParameter('time') as $id => $value) {
-                               addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('pay', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('title', $id)."' WHERE `id`='".$id."' LIMIT 1");
-                       }
+                               addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('payment', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1");
+                       } // END - foreach
                        break;
 
                case 'del':
                        foreach (postRequestParameter('id') as $id => $value) {
                                addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
-                       }
+                       } // END - foreach
                        break;
        } // END - switch
 
@@ -93,17 +88,12 @@ if (isFormSent()) {
        // Delete entries here
        $OUT = '';
        foreach (postRequestParameter('sel') as $id => $value) {
-               $result = SQL_QUERY_ESC("SELECT time, mail_title FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
-               array(bigintval($id)), __FILE__, __LINE__);
-               list($time, $title) = SQL_FETCHROW($result);
-               SQL_FREERESULT($result);
+               $result = SQL_QUERY_ESC("SELECT `id`, `time`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
+                       array(bigintval($id)), __FILE__, __LINE__);
+               $content = SQL_FETCHARRAY($result);
 
-               // Prepare array for the row template
-               $content = array(
-                       'id'    => $id,
-                       'time'  => $time,
-                       'title' => $title,
-               );
+               // Free result
+               SQL_FREERESULT($result);
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_del_payments_row', true, $content);
@@ -115,19 +105,12 @@ if (isFormSent()) {
        // Edit entries
        $OUT = '';
        foreach (postRequestParameter('sel') as $id => $value) {
-               $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
-               array(bigintval($id)), __FILE__, __LINE__);
-               list($time, $pay, $title, $price) = SQL_FETCHROW($result);
-               SQL_FREERESULT($result);
+               $result = SQL_QUERY_ESC("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
+                       array(bigintval($id)), __FILE__, __LINE__);
+               $content = SQL_FETCHARRAY($result);
 
-               // Prepare array for the row template
-               $content = array(
-                       'id'    => $id,
-                       'time'  => $time,
-                       'title' => $title,
-                       'pay'   => $pay,
-                       'price' => $price,
-               );
+               // Free result
+               SQL_FREERESULT($result);
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_edit_payments_row', true, $content);