Changeset 3371398
- Timestamp:
- 10/01/2025 07:42:12 PM (6 months ago)
- Location:
- cwsl-lotto-1049
- Files:
-
- 52 added
- 7 edited
-
tags/1.3 (added)
-
tags/1.3/README.txt (added)
-
tags/1.3/admin (added)
-
tags/1.3/admin/_notes (added)
-
tags/1.3/admin/_notes/dwsync.xml (added)
-
tags/1.3/admin/class-cwsl-lotto-1049-admin.php (added)
-
tags/1.3/admin/css (added)
-
tags/1.3/admin/css/_notes (added)
-
tags/1.3/admin/css/_notes/dwsync.xml (added)
-
tags/1.3/admin/css/cwsl-lotto-1049-admin.css (added)
-
tags/1.3/admin/index.php (added)
-
tags/1.3/admin/js (added)
-
tags/1.3/admin/js/_notes (added)
-
tags/1.3/admin/js/_notes/dwsync.xml (added)
-
tags/1.3/admin/js/cwsl-lotto-1049-admin.js (added)
-
tags/1.3/admin/partials (added)
-
tags/1.3/admin/partials/_notes (added)
-
tags/1.3/admin/partials/_notes/dwsync.xml (added)
-
tags/1.3/admin/partials/cwsl-lotto-1049-admin-display.php (added)
-
tags/1.3/cwsl-lotto-1049.php (added)
-
tags/1.3/includes (added)
-
tags/1.3/includes/_notes (added)
-
tags/1.3/includes/_notes/dwsync.xml (added)
-
tags/1.3/includes/class-cwsl-lotto-1049-activator.php (added)
-
tags/1.3/includes/class-cwsl-lotto-1049-deactivator.php (added)
-
tags/1.3/includes/class-cwsl-lotto-1049-i18n.php (added)
-
tags/1.3/includes/class-cwsl-lotto-1049-loader.php (added)
-
tags/1.3/includes/class-cwsl-lotto-1049.php (added)
-
tags/1.3/includes/index.php (added)
-
tags/1.3/index.php (added)
-
tags/1.3/languages (added)
-
tags/1.3/languages/_notes (added)
-
tags/1.3/languages/_notes/dwsync.xml (added)
-
tags/1.3/languages/cwsl-lotto-1049.pot (added)
-
tags/1.3/public (added)
-
tags/1.3/public/_notes (added)
-
tags/1.3/public/_notes/dwsync.xml (added)
-
tags/1.3/public/class-cwsl-lotto-1049-public.php (added)
-
tags/1.3/public/css (added)
-
tags/1.3/public/css/_notes (added)
-
tags/1.3/public/css/_notes/dwsync.xml (added)
-
tags/1.3/public/css/cwsl-lotto-1049-public.css (added)
-
tags/1.3/public/index.php (added)
-
tags/1.3/public/js (added)
-
tags/1.3/public/js/_notes (added)
-
tags/1.3/public/js/_notes/dwsync.xml (added)
-
tags/1.3/public/js/cwsl-lotto-1049-public.js (added)
-
tags/1.3/public/partials (added)
-
tags/1.3/public/partials/_notes (added)
-
tags/1.3/public/partials/_notes/dwsync.xml (added)
-
tags/1.3/public/partials/cwsl-lotto-1049-public-display.php (added)
-
tags/1.3/uninstall.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/admin/class-cwsl-lotto-1049-admin.php (modified) (12 diffs)
-
trunk/admin/css/cwsl-lotto-1049-admin.css (modified) (2 diffs)
-
trunk/admin/js/cwsl-lotto-1049-admin.js (modified) (1 diff)
-
trunk/admin/partials/cwsl-lotto-1049-admin-display.php (modified) (4 diffs)
-
trunk/cwsl-lotto-1049.php (modified) (2 diffs)
-
trunk/includes/class-cwsl-lotto-1049.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cwsl-lotto-1049/trunk/README.txt
r3275004 r3371398 3 3 Tags: lotto 649, lotto 1049, lotto1049 4 4 Tested up to: 6.8 5 Stable tag: 1. 25 Stable tag: 1.3 6 6 License: GPLv2 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 43 43 44 44 == Changelog == 45 = 1.3 = 46 List lottos active first and then in descending date order. 47 45 48 = 1.2 = 46 49 Test with WordPress 6.8 … … 62 65 63 66 == Upgrade Notice == 67 = 1.3 = 68 Change order by. Upgrade when convenient. 69 64 70 = 1.2 = 65 71 Test with WordPress 6.8. Upgrade when convenient. -
cwsl-lotto-1049/trunk/admin/class-cwsl-lotto-1049-admin.php
r3218453 r3371398 444 444 $results_save = array(); 445 445 } 446 446 $total_active_draws = 0; 447 447 // Get current Lotto 10/49 draws 448 448 $results_draws = cwslGetLotto1049Draws(); … … 457 457 $found = true; 458 458 $search_lotto1049_draw = $draw->ID; 459 $start_lotto1049_draw = $draw->date_start; 459 460 } 460 461 } … … 462 463 if (!$found) { 463 464 $search_lotto1049_draw = $draws[0]->ID; 465 $start_lotto1049_draw = $draws[0]->date_start; 466 } 467 } 468 // do I have the selected draws start date? 469 if (isset($search_lotto1049_draw) && $search_lotto1049_draw>=0 && !isset($start_lotto1049_draw)) { 470 $results_start = cwslGetLottoStartDateForID($search_lotto1049_draw); 471 if (!is_array($results_start)) { 472 $start_lotto1049_draw = $results_start; 473 } elseif (isset($results_start['message'])) { 474 echo '<p>ERROR GETTING START DATE: '.$results_start['message'].'</p>'; 475 } else { 476 echo '<p>ERROR GETTING START DATE</p>'; 477 } 478 } 479 // how many remaining draws are there? 480 if (isset($start_lotto1049_draw) && isset($draws) && is_array($draws) && count($draws) > 0 && $search_lotto1049_draw>0) { 481 foreach ($draws as $i => $draw) { 482 if ($start_lotto1049_draw <= $draw->date_start && $draw->active == 1) { 483 $total_active_draws++; 484 } 464 485 } 465 486 } … … 468 489 // Display forms 469 490 cwslShowFilterDraws($menu_slug, $results_draws, $search_lotto1049_draw); 470 cwslShowLottoPlayerPayment($menu_slug, $results, $results_save, $search_lotto1049_draw );491 cwslShowLottoPlayerPayment($menu_slug, $results, $results_save, $search_lotto1049_draw, $total_active_draws); 471 492 } else { 472 493 echo '<p class="cwsl_failmsg">You are not authorized to be here. </p>'; … … 810 831 function cwslGetLotto1049Draws() { 811 832 global $wpdb; 812 $values = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'cws_lotto1049draw ORDER BY date_start ASC' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery833 $values = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'cws_lotto1049draw ORDER BY active DESC, date_start ASC' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 813 834 if (!is_object($values) && !is_array($values)) { 814 835 $tmp = 'Failed to find lotto 1049 draws. Error is '.$wpdb->last_error.'. '; … … 820 841 } 821 842 822 // Retrieve all draws for the 2024/2025 season843 // Retrieve all active draws 823 844 function cwslGetActiveLotto1049Draws() { 824 845 global $wpdb; … … 831 852 return $results; 832 853 } 833 854 // get start date for a given draw id 855 function cwslGetLottoStartDateForID($search_lotto1049_draw) { 856 global $wpdb; 857 $values = $wpdb->get_results( $wpdb->prepare('SELECT date_start FROM '.$wpdb->prefix.'cws_lotto1049draw WHERE ID=%d', array($search_lotto1049_draw) )); // phpcs:ignore WordPress.DB.DirectDatabaseQuery 858 if (!is_object($values) && !is_array($values)) { 859 $results = array("status"=>0, "message"=>'Failed to find lotto 1049 draws. Error is '.$wpdb->last_error.'. '); 860 } elseif (count($values) != 1 || !isset($values[0]->date_start)) { 861 $results = array("status"=>0, "message"=>'Failed to find lotto 1049 draws. Error is '.$wpdb->last_error.'. '); 862 } else { 863 $results = $values[0]->date_start; 864 } 865 return $results; 866 } 834 867 ////////////////////////////////// 835 868 // cws_lotto_player Table FUNCTIONS … … 1196 1229 $good_msg = ""; 1197 1230 $methods = array("Cash", "Credit", "Debit", "E-Transfer"); 1198 1231 // validate 1232 if (!isset($values['lotto1049draw_id']) || $values['lotto1049draw_id'] == "") { 1233 $results = array("status"=>0, "message"=>"Please select a lotto first."); 1234 return $results; 1235 } 1236 $results_start = cwslGetLottoStartDateForID($values['lotto1049draw_id']); 1237 if (!is_array($results_start)) { 1238 $start_lotto1049_draw = $results_start; 1239 } elseif (isset($results_start['message'])) { 1240 $results = array("status"=>0, "message"=>'ERROR GETTING START DATE: '.$results_start['message']); 1241 return $results; 1242 } else { 1243 $results = array("status"=>0, "message"=>'ERROR GETTING START DATE. No message'); 1244 return $results; 1245 } 1199 1246 foreach ($values as $n => $v) { 1200 if (stristr($n, "amount_sales") && $v >= 0) { 1247 if (stristr($n, "cwsl_row_changed") && $v==1) { 1248 $action = "insert"; 1201 1249 $player_id = -1; 1202 $ action = "insert";1250 $id = str_replace("cwsl_row_changed", "", $n); 1203 1251 $array = explode("_", $n); 1204 $id = str_replace("amount_sales", "", $n); 1205 $amount_sales = $v; 1206 $method_of_payment = $values[$id.'method_of_payment']; 1252 1207 1253 if (is_array($array) && isset($array[0])) { 1208 1254 $player_id = $array[0]; … … 1213 1259 } 1214 1260 // validate 1215 if (!isset($player_id) || $player_id < 0 || 1216 !isset($values['lotto1049draw_id']) || $values['lotto1049draw_id'] == "") { 1217 $results = array("status"=>0, "message"=>"Please enter all form values for ".$values[$id.'player_name']); 1218 return $results; 1261 if (!isset($player_id) || $player_id < 0) { 1262 $results = array("status"=>0, "message"=>"Please enter all form values for ".$values[$id.'player_name']); 1263 return $results; 1264 } 1265 if (!isset($values[$id.'amount_sales']) || $values[$id.'amount_sales'] <= 0) { 1266 $amount_sales = 0; 1267 } else { 1268 $amount_sales = $values[$id.'amount_sales']; 1219 1269 } 1220 1270 if (!isset($values[$id.'paid']) || $values[$id.'paid'] <= 0) { … … 1223 1273 $paid = $values[$id.'paid']; 1224 1274 } 1275 if (!isset($values[$id.'method_of_payment'])) { 1276 $method_of_payment = "E-Transfer"; 1277 } else { 1278 $method_of_payment = $values[$id.'method_of_payment']; 1279 } 1280 // handle for the selected lotto 1225 1281 if ($action == "insert") { 1226 1282 $query = $wpdb->insert($wpdb->prefix.'cws_lotto_payment', array('player_id' => sanitize_text_field($player_id), 'lotto1049draw_id' => sanitize_text_field($values['lotto1049draw_id']), 'amount_sales' => sanitize_text_field($amount_sales), 'paid' => sanitize_text_field($paid), 'method_of_payment' => sanitize_text_field($method_of_payment)), array('%d', '%d', '%d', '%d', '%s')); // phpcs:ignore WordPress.DB.DirectDatabaseQuery … … 1245 1301 } 1246 1302 } // END is amount_sales 1247 } 1248 // determine if already exists and whether should insert or update 1303 } // END loop 1249 1304 if ($bad_msg == "") { 1250 1305 $status = 1; … … 1638 1693 } 1639 1694 if (!isset($sent) || !$sent) { 1640 $message .= "Could not send email to $email. Sending stopped. "; 1695 $message = "Could not send email to $to. <br />From: $email_from. <br />Headers are: "; 1696 foreach ($headers as $n => $v) { 1697 $message .= "<br />$n: $v"; 1698 } 1641 1699 $results = array("status"=>0, "message"=>$message); 1642 1700 return $results; -
cwsl-lotto-1049/trunk/admin/css/cwsl-lotto-1049-admin.css
r3218453 r3371398 57 57 } 58 58 59 .cwsl_admin input[type=date], .cwsl_admin input[type=datetime-local], .cwsl_admin input[type=datetime], .cwsl_admin input[type=email], .cwsl_admin input[type=month], .cwsl_admin input[type=number], .cwsl_admin input[type=password], .cwsl_admin input[type=search], .cwsl_admin input[type=tel], .cwsl_admin input[type=text], .cwsl_admin input[type=time], .cwsl_admin input[type=url], .cwsl_admin input[type=week], .cwsl_admin textarea {59 .cwsl_admin input[type=date], .cwsl_admin input[type=datetime-local], .cwsl_admin input[type=datetime], .cwsl_admin input[type=email], .cwsl_admin input[type=month], .cwsl_admin input[type=number], .cwsl_admin input[type=password], .cwsl_admin input[type=search], .cwsl_admin input[type=tel], .cwsl_admin input[type=text], .cwsl_admin input[type=time], .cwsl_admin input[type=url], .cwsl_admin input[type=week], .cwsl_admin textarea, .cwsl_admin select { 60 60 width:95%; 61 61 } … … 133 133 background:rgba(11,156,49,0.2); 134 134 } 135 tr.cwsl_row_changed td { 136 color:blue !important; 137 } 135 138 @media print { 136 139 /* print version */ -
cwsl-lotto-1049/trunk/admin/js/cwsl-lotto-1049-admin.js
r3218453 r3371398 61 61 } 62 62 }); 63 // Payment screen 64 $('.cwsl_cell_sales').change(function(e){ 65 var rowname = $(this).attr("id"); 66 var hiddenname = rowname.replace("cwsl_cell_sales", "cwsl_row_changed"); 67 rowname = rowname.replace("cwsl_cell_sales", "cwsl_row_payment"); 68 if (!$('#' + rowname).hasClass("cwsl_row_changed")) { 69 $('#' + rowname).addClass("cwsl_row_changed"); 70 } 71 $('#' + hiddenname).val("1"); 72 }); 73 $('.cwsl_cell_paid').change(function(e){ 74 var rowname = $(this).parent().attr("id"); 75 var hiddenname = rowname.replace("cwsl_cell_paid", "cwsl_row_changed"); 76 rowname = rowname.replace("cwsl_cell_paid", "cwsl_row_payment"); 77 if (!$('#' + rowname).hasClass("cwsl_row_changed")) { 78 $('#' + rowname).addClass("cwsl_row_changed"); 79 } 80 $('#' + hiddenname).val("1"); 81 }); 82 $('.cwsl_cell_method').change(function(e){ 83 var rowname = $(this).parent().attr("id"); 84 var hiddenname = rowname.replace("cwsl_cell_method", "cwsl_row_changed"); 85 rowname = rowname.replace("cwsl_cell_method", "cwsl_row_payment"); 86 if (!$('#' + rowname).hasClass("cwsl_row_changed")) { 87 $('#' + rowname).addClass("cwsl_row_changed"); 88 } 89 $('#' + hiddenname).val("1"); 90 }); 63 91 }); // END load 64 92 })( jQuery ); -
cwsl-lotto-1049/trunk/admin/partials/cwsl-lotto-1049-admin-display.php
r3234240 r3371398 664 664 // MANAGE Lotto 1049 Player Payments 665 665 /////////////////////////////////////// 666 function cwslShowLottoPlayerPayment($menu_slug, $results, $results_save, $search_lotto1049_draw ) {666 function cwslShowLottoPlayerPayment($menu_slug, $results, $results_save, $search_lotto1049_draw, $total_active_draws) { 667 667 $methods = array("Cash", "Credit", "Debit", "E-Transfer"); 668 668 $total_sales = 0; … … 711 711 <tr> 712 712 <th width="5%">Num</th> 713 <th width="2 5%">Name</th>714 <th width="2 0%">Email(s)</th>713 <th width="20%">Name</th> 714 <th width="25%">Email(s)</th> 715 715 <th width="15%">Amount</th> 716 716 <th width="15%">Paid?</th> … … 745 745 $output = cwslFormatPlayerName($row); 746 746 echo ' 747 <tr> 748 <td>'.esc_html($num).'</td> 749 <td class="'.esc_html($class).'">'.esc_html($output).'<br /> 747 <tr class="cwsl_row_payment" id="'.esc_html($id).'cwsl_row_payment"> 748 <input type="hidden" name="'.esc_html($id).'cwsl_row_changed" id="'.esc_html($id).'cwsl_row_changed" value="0" /> 749 <td class="cwsl_cell_num">'.esc_html($num).'</td> 750 <td class="'.esc_html($class).' cwsl_cell_name">'.esc_html($output).'<br /> 750 751 <input type="hidden" name="'.esc_html($id).'player_name" value="'.esc_html($row->player_name).'" /> 751 752 </td> 752 <td >'.esc_html($row->email);753 <td class="cwsl_cell_email">'.esc_html($row->email); 753 754 if ($row->email2 != "") { 754 755 echo ", ".esc_html($row->email2); 755 756 } 756 757 echo '</td> 757 <td><input type="number" name="'.esc_html($id).'amount_sales" value="'.esc_html($amount_sales).'" placeholder="$" /></td>758 758 <td> 759 <select name="'.esc_html($id).'paid"> 759 <input type="number" name="'.esc_html($id).'amount_sales" value="'.esc_html($amount_sales).'" placeholder="$" class="cwsl_cell_sales" id="'.esc_html($id).'cwsl_cell_sales" /> 760 </td> 761 <td id="'.esc_html($id).'cwsl_cell_paid"> 762 <select name="'.esc_html($id).'paid" class="cwsl_cell_paid"> 760 763 <option value=0'; 761 764 if (!isset($row->paid) || $row->paid == 0) { … … 772 775 </select> 773 776 </td> 774 <td >775 <select name="'.esc_html($id).'method_of_payment" >777 <td id="'.esc_html($id).'cwsl_cell_method"> 778 <select name="'.esc_html($id).'method_of_payment" class="cwsl_cell_method"> 776 779 <option value="">Choose ...</option>'; 777 780 foreach ($methods as $ctr => $entry) { -
cwsl-lotto-1049/trunk/cwsl-lotto-1049.php
r3275004 r3371398 16 16 * Plugin Name: CWSL Lotto 1049 17 17 * Description: Set up a Lotto 1049 18 * Version: 1. 218 * Version: 1.3 19 19 * Author: Charlene's Web Services 20 20 * Author URI: https://charlenesweb.ca … … 33 33 * First release 1.0.0 and then using SemVer - https://semver.org X.Y.Z (Major.Minor.Patch) 34 34 */ 35 define( 'CWSL_LOTTO_VERSION', '1. 2' );35 define( 'CWSL_LOTTO_VERSION', '1.3' ); 36 36 define('CWSL_LOTTO_SRC_DIR', dirname(__FILE__) ); 37 37 /** -
cwsl-lotto-1049/trunk/includes/class-cwsl-lotto-1049.php
r3275004 r3371398 73 73 $this->version = CWSL_LOTTO_VERSION; 74 74 } else { 75 $this->version = '1. 2';75 $this->version = '1.3'; 76 76 } 77 77 $this->plugin_name = 'cwsl-lotto-1049';
Note: See TracChangeset
for help on using the changeset viewer.