]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-payments.php
More rewrites to make use of (cached) wrapper functions
[mailer.git] / inc / modules / admin / what-payments.php
index 8de522a367b76e695a5a096bbb7edf2b858bfd7b..1df93ee820e85d7e70a1150a1e1e50bc2e646efc 100644 (file)
@@ -52,9 +52,9 @@ if (((!isPostRequestParameterSet(('t_wait'))) || (!isPostRequestParameterSet(('p
 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__);
+                       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) {
                                // Re-init the array here
                                initSqls();
@@ -89,9 +89,9 @@ if (isFormSent()) {
 
        // Output template
        loadTemplate('admin_settings_saved', false, $content);
-} elseif ((isFormSent('del')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
        // Delete entries here
-       $OUT = ''; $SW = 2;
+       $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__);
@@ -100,7 +100,6 @@ if (isFormSent()) {
 
                // Prepare array for the row template
                $content = array(
-                       'sw'    => $SW,
                        'id'    => $id,
                        'time'  => $time,
                        'title' => $title,
@@ -108,14 +107,13 @@ if (isFormSent()) {
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_del_payments_row', true, $content);
-               $SW = 3 - $SW;
-       }
+       } // END - foreach
 
        // Load main template
        loadTemplate('admin_del_payments', false, $OUT);
-} elseif ((isFormSent('edit')) && (countPostSelection() > 0)) {
+} elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
        // Edit entries
-       $OUT = ''; $SW = 2;
+       $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__);
@@ -124,7 +122,6 @@ if (isFormSent()) {
 
                // Prepare array for the row template
                $content = array(
-                       'sw'    => $SW,
                        'id'    => $id,
                        'time'  => $time,
                        'title' => $title,
@@ -134,34 +131,21 @@ if (isFormSent()) {
 
                // Load row template and switch colors
                $OUT .= loadTemplate('admin_edit_payments_row', true, $content);
-               $SW = 3 - $SW;
-       }
+       } // END - foreach
 
        // Load main template
        loadTemplate('admin_edit_payments', false, $OUT);
 } else {
        // Referal levels
        $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Make referal levels editable and deletable
-               $OUT = ''; $SW = 2;
+               $OUT = '';
 
                // List already existing categories for editing
                while ($content = SQL_FETCHARRAY($result)) {
-                       // Prepare array for the row template
-                       // @TODO Rewritings: title->mail_title, pay->payment in template
-                       $content = array(
-                               'sw'    => $SW,
-                               'id'    => $content['id'],
-                               'time'  => $content['time'],
-                               'title' => $content['mail_title'],
-                               'pay'   => translateComma($content['payment']),
-                               'price' => translateComma($content['price'])
-                       );
-
                        // Load row template and switch colors
-                       $OUT .= loadTemplate('admin_payments_list_row', true, $content);
-                       $SW = 3 - $SW;
+                       $OUT .= loadTemplate('admin_list_payments_row', true, $content);
                } // END - switch
 
                // Free memory