Changeset 111
- Timestamp:
- 11/09/06 14:01:30 (2 years ago)
- Files:
-
- branches/com_mls_events/barcodes/admin.mls_events.html.php (modified) (5 diffs)
- branches/com_mls_events/barcodes/admin.mls_events.php (modified) (7 diffs)
- branches/com_mls_events/barcodes/install.mls_events.php (modified) (1 diff)
- branches/com_mls_events/barcodes/lang/english.php (modified) (3 diffs)
- branches/com_mls_events/barcodes/mls_events.xml (modified) (1 diff)
- branches/com_mls_events/barcodes/toolbar.mls_events.html.php (modified) (1 diff)
- branches/com_mls_events/barcodes/toolbar.mls_events.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/com_mls_events/barcodes/admin.mls_events.html.php
r110 r111 1017 1017 } 1018 1018 1019 function addNew( $lists, $option, $act ) { 1020 global $l; 1021 $l->setBlock("barcodes"); 1022 ?> 1023 <script language="javascript" type="text/javascript"> 1024 function submitbutton(pressbutton) { 1025 if(pressbutton == 'save') { 1026 if (document.adminForm.userid.value == 0) { 1027 alert('<?php echo $l->m("err_please_select_user","general"); ?>'); 1028 } else { 1029 submitform(pressbutton); 1030 } 1031 } else { 1032 submitform(pressbutton); 1033 } 1034 } 1035 </script> 1036 <form action="index2.php" method="post" name="adminForm"> 1037 <table class="adminheading"> 1038 <tr> 1039 <th>myLANsite Events: <?php echo $l->m("add_barcode"); ?></th> 1040 </tr> 1041 </table> 1042 <table class="adminform"> 1043 <tr> 1044 <td width="20%" valign="top" align="right"><?php echo $l->m("user"); ?>:</td> 1045 <td width="80%"><?php echo $lists["userid"]; ?></td> 1046 </tr> 1047 <tr> 1048 <td width="20%" valign="top" align="right"><?php echo $l->m("code") ?>:</td> 1049 <td width="80%"><input class="text_area" id="code" type="text" name="code" size="10" maxlength="10" value="" onChange="submitbutton('save')" /></td> 1050 </tr> 1051 <tr> 1052 <td align="right" valign="top"><?php echo $l->m("status") ?>:</td> 1053 <td><?php echo $lists["status"]; ?></td> 1054 </tr> 1055 <tr> 1056 <td colspan="2"> </td> 1057 </tr> 1058 <tr> 1059 <td align="right" valign="top"> </td> 1060 <td><input type="button" class="button" name="submitCodes" onclick="submitbutton('save')" value="<?php echo $l->m("save");?>" /></td> 1061 </tr> 1062 </table> 1063 <input type="hidden" name="option" value="<?php echo $option; ?>" /> 1064 <input type="hidden" name="act" value="<?php echo $act; ?>" /> 1065 <input type="hidden" name="task" value="" /> 1066 </form> 1067 <?php 1068 HTML_MLS::printFooter($option); 1069 } 1070 } 1071 1072 /** Checkin **/ 1073 class HTML_MLS_events_checkin { 1019 1074 function showUserform( $type, $lists, $option, $act ) { 1020 1075 global $l; 1021 $l->setBlock(" barcodes");1022 ?> 1023 <form action="index2.php" method="post" name="adminForm"> 1024 <table class="adminheading"> 1025 <tr> 1026 <th>myLANsite Events: <?php echo $l->m( $type); ?> :: <?php echo $l->m("select_user"); ?></th>1076 $l->setBlock("checkin"); 1077 ?> 1078 <form action="index2.php" method="post" name="adminForm"> 1079 <table class="adminheading"> 1080 <tr> 1081 <th>myLANsite Events: <?php echo $l->m("checkin_checkout"); ?> :: <?php echo $l->m("select_user"); ?></th> 1027 1082 </tr> 1028 1083 </table> … … 1051 1106 <input type="hidden" name="option" value="<?php echo $option; ?>" /> 1052 1107 <input type="hidden" name="act" value="<?php echo $act; ?>" /> 1053 <input type="hidden" name="task" value=" <?php echo $type; ?>form" />1108 <input type="hidden" name="task" value="search" /> 1054 1109 </form> 1055 1110 <script language="JavaScript"> … … 1061 1116 1062 1117 function checkinForm( $user, $event, $option, $act ) { 1063 global $l ;1064 $l->setBlock(" barcodes");1118 global $l, $database; 1119 $l->setBlock("checkin"); 1065 1120 ?> 1066 1121 <form action="index2.php" method="post" name="adminForm"> … … 1102 1157 <td colspan="2" valign="top" align="right"> </td> 1103 1158 </tr> 1104 <tr> 1105 <td width="20%" valign="top" align="right"><?php echo $l->m("money_deposit") ?>:</td> 1106 <td width="80%"><input class="text_area" id="deposit" type="text" name="deposit" size="10" maxlength="12" value="" /></td> 1107 </tr> 1159 <?php 1160 $database->setQuery( "SELECT COUNT(*) FROM `#__components` WHERE `option`='com_mls_catering'" ); 1161 if($database->loadResult()) { 1162 ?> 1163 <tr> 1164 <td width="20%" valign="top" align="right"><?php echo $l->m("money_deposit") ?>:</td> 1165 <td width="80%"><input class="text_area" id="deposit" type="text" name="deposit" size="10" maxlength="12" value="" /></td> 1166 </tr> 1167 <?php 1168 } 1169 ?> 1108 1170 <tr> 1109 1171 <td align="right" valign="top"> </td> … … 1116 1178 <input type="hidden" name="act" value="<?php echo $act; ?>" /> 1117 1179 <input type="hidden" name="task" value="checkinsave" /> 1180 </form> 1181 <script language="JavaScript"> 1182 document.getElementById('barcode1').focus(); 1183 </script> 1184 <?php 1185 HTML_MLS::printFooter($option); 1186 } 1187 1188 function checkoutForm( $user, $event, $lists, $option, $act ) { 1189 global $l; 1190 $l->setBlock("checkin"); 1191 ?> 1192 <form action="index2.php" method="post" name="adminForm"> 1193 <table class="adminheading"> 1194 <tr> 1195 <th>myLANsite Events: <?php echo $l->m("checkout"); ?></th> 1196 </tr> 1197 </table> 1198 <table class="adminform"> 1199 <tr> 1200 <td width="20%" valign="top" align="right"><?php echo $l->m("event") ?>:</td> 1201 <td width="80%"><?php echo $event->name; ?></td> 1202 </tr> 1203 <tr> 1204 <td width="20%" valign="top" align="right"><?php echo $l->m("user") ?>:</td> 1205 <td width="80%"><?php echo $user->id; ?>: <?php echo $user->name; ?> (<?php echo $user->username; ?>)</td> 1206 </tr> 1207 <?php 1208 if($user->balance) { 1209 ?> 1210 <tr> 1211 <td width="20%" valign="top" align="right"><?php echo $l->m("account_balance") ?>:</td> 1212 <td width="80%"><?php echo $user->balance; ?></td> 1213 </tr> 1214 <tr> 1215 <td width="20%" valign="top" align="right"><?php echo $l->m("payback_balance") ?>:</td> 1216 <td width="80%"><?php echo $lists["payback"]; ?></td> 1217 </tr> 1218 <?php 1219 } 1220 ?> 1221 <tr> 1222 <td colspan="2" valign="top" align="right"> </td> 1223 </tr> 1224 <tr> 1225 <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 1:</td> 1226 <td width="80%"><input class="text_area" id="barcode1" type="text" name="barcodes[]" size="10" maxlength="12" value="" onChange="document.getElementById('barcode2').focus()" /></td> 1227 </tr> 1228 <tr> 1229 <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 2:</td> 1230 <td width="80%"><input class="text_area" id="barcode2" type="text" name="barcodes[]" size="10" maxlength="12" value="" onChange="document.getElementById('barcode3').focus()" /></td> 1231 </tr> 1232 <tr> 1233 <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 3:</td> 1234 <td width="80%"><input class="text_area" id="barcode3" type="text" name="barcodes[]" size="10" maxlength="12" value="" onChange="document.getElementById('barcode4').focus()" /></td> 1235 </tr> 1236 <tr> 1237 <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 4:</td> 1238 <td width="80%"><input class="text_area" id="barcode4" type="text" name="barcodes[]" size="10" maxlength="12" value="" onChange="document.getElementById('barcode5').focus()" /></td> 1239 </tr> 1240 <tr> 1241 <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 5:</td> 1242 <td width="80%"><input class="text_area" id="barcode5" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 1243 </tr> 1244 <tr> 1245 <td align="right" valign="top"> </td> 1246 <td><input type="button" class="button" name="submitCodes" onclick="document.adminForm.submit()" value="<?php echo $l->m("save");?>" /></td> 1247 </tr> 1248 </table> 1249 <input type="hidden" name="userid" value="<?php echo $user->id; ?>" /> 1250 <input type="text" name="eventid" value="<?php echo $event->id; ?>" /> 1251 <input type="hidden" name="option" value="<?php echo $option; ?>" /> 1252 <input type="hidden" name="act" value="<?php echo $act; ?>" /> 1253 <input type="hidden" name="task" value="checkoutsave" /> 1118 1254 </form> 1119 1255 <script language="JavaScript"> branches/com_mls_events/barcodes/admin.mls_events.php
r108 r111 199 199 checkinFormMLS_events_barcodes( $option, $act ); 200 200 break; 201 case "enable": 202 changeMLS_events_barcodes( $cid, 1, $option, $act ); 203 break; 204 case "disable": 205 changeMLS_events_barcodes( $cid, 0, $option, $act ); 206 break; 207 case "remove": 208 removeMLS_events_barcodes( $cid, $option, $act ); 209 break; 210 case "new": 211 addMLS_events_barcodes( $option, $act ); 212 break; 213 case "save": 214 saveMLS_events_barcodes( $option, $act ); 215 break; 216 default: 217 showMLS_events_barcodes( $option, $act ); 218 break; 219 } 220 break; 221 case "checkin": 222 switch($task) { 223 case "search": 224 searchUserMLS_events_checkin( $option, $act ); 225 break; 226 case "checkinsave": 227 checkinSaveMLS_events_barcodes( $option, $act ); 228 break; 201 229 case "checkoutsave": 202 230 checkoutSaveMLS_events_barcodes( $option, $act ); 203 231 break; 204 case "checkinsave":205 checkinSaveMLS_events_barcodes( $option, $act );206 break;207 case "enable":208 changeMLS_events_barcodes( $cid[0], 1, $option, $act );209 break;210 case "disable":211 changeMLS_events_barcodes( $cid[0], 0, $option, $act );212 break;213 case "remove":214 removeMLS_events_barcodes( $cid, $option, $act );215 break;216 232 default: 217 showMLS_events_barcodes( $option, $act );233 checkinUserMLS_events_checkin( $option, $act ); 218 234 break; 219 235 } … … 275 291 } 276 292 277 /** Barcodes **/ 278 function showMLS_events_barcodes( $option, $act ) { 279 global $database, $l, $mainframe; 280 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 ); 281 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); 282 $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); 283 $search = $database->getEscaped( trim( strtolower( $search ) ) ); 284 $userid = $mainframe->getUserStateFromRequest( "filter_id{$option}", 'userid_filter', 0 ); 285 286 $where = ""; 287 $words = explode(" ",$search); 288 foreach($words as $word) { 289 if($word) { 290 $op = $where ? "AND" : "WHERE"; 291 $where .= " $op (u.name LIKE '%$word%' OR u.username LIKE '%$word%' OR c.code LIKE '%$word%' OR u.email LIKE '%$word%')"; 292 } 293 } 294 $op = $where ? "AND" : "WHERE"; 295 $where .= $userid ? " $op u.id = '$userid'" : ""; 296 297 // get the total number of records 298 $database->setQuery( "SELECT COUNT(*) FROM `#__mls_events_barcodes` AS `c`" 299 ."\n INNER JOIN `#__users` AS `u` ON u.id=c.userid $where" ); 300 $total = $database->loadResult(); 301 302 require_once( "includes/pageNavigation.php" ); 303 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 304 305 $database->setQuery( "SELECT u.name, u.username, u.email, c.* FROM `#__mls_events_barcodes` AS `c`" 306 ."\n INNER JOIN `#__users` AS `u` ON u.id=c.userid $where" 307 ."\n ORDER BY u.username ASC" 308 ."\n LIMIT $pageNav->limitstart, $pageNav->limit" ); 309 $rows = $database->loadObjectList(); 310 311 // Select lists 312 $user_select = HTML_MLS::showUserSelect( $userid, $option, $act ); 313 314 HTML_MLS_events_barcodes::showBarcodes( $rows, $pageNav, $user_select, $search, $option, $act ); 315 316 } 317 318 function changeMLS_events_barcodes( $cid, $status, $option, $act ) { 319 global $database, $mosConfig_offset, $l; 320 $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 321 $query = "UPDATE `#__mls_events_barcodes` SET `status`='".$status."', `lastupdate`='".$time."' WHERE `id` = '".$cid."'"; 322 $database->setQuery($query); 323 $database->query(); 324 325 mosRedirect( "index2.php?option=$option&act=$act&mosmsg=".urlencode($l->m("msg_status_changed","general")) ); 326 } 327 328 function checkinUserMLS_events_barcodes( $option, $act ) { 293 /** Checkin **/ 294 function checkinUserMLS_events_checkin( $option, $act ) { 329 295 global $database, $l; 330 296 $l->setBlock("barcodes"); … … 350 316 array_unshift($users, $stdOpt); 351 317 $lists["users"] = mosHTML::selectList($users, 'select_user', ' class="inputbox"', 'value', 'text', '0'); 352 HTML_MLS_events_barcodes::showUserform( "checkin", $lists, $option, $act ); 353 } 354 355 function checkoutUserMLS_events_barcodes( $option, $act ) { 356 global $database, $l; 357 $l->setBlock("barcodes"); 358 $database->setQuery( "SELECT `id` AS `value`, CONCAT(`name`,' (',`username`,')') AS `text` FROM `#__users` ORDER BY `name` ASC" ); 359 $users = $database->loadObjectList(); 360 $stdOpt = new stdClass(); 361 $stdOpt->value = '0'; 362 $stdOpt->text = $l->m("select_user"); 363 array_unshift($users, $stdOpt); 364 $lists["users"] = mosHTML::selectList($users, 'select_user', ' class="inputbox"', 'value', 'text', '0'); 365 HTML_MLS_events_barcodes::showUserform( "checkout", $lists, $option, $act ); 366 } 367 368 function checkinFormMLS_events_barcodes( $option, $act ) { 369 global $database, $l; 318 HTML_MLS_events_checkin::showUserform( "checkin", $lists, $option, $act ); 319 } 320 321 function searchUserMLS_events_checkin( $option, $act ) { 322 global $database, $l, $mainframe, $mosConfig_absolute_path; 370 323 // First, get through the user stuff 371 324 $userid = mosGetParam($_POST, 'userid', NULL); … … 376 329 if($select_user) { $userid = $select_user; } 377 330 if($userid) { 378 $database->setQuery( "SELECT u.id,u.name,u.username FROM `#__users` AS `u` INNER JOIN `#__mls_events_participants` AS `p` ON p.userid=u.id WHERE u.id='$userid' AND p.eventid='$eventid'" );331 $database->setQuery( "SELECT u.id,u.name,u.username,p.checkin FROM `#__users` AS `u` INNER JOIN `#__mls_events_participants` AS `p` ON p.userid=u.id WHERE u.id='$userid' AND p.eventid='$eventid'" ); 379 332 $database->loadObject( $user ); 380 333 } elseif($search_user) { 381 $database->setQuery( "SELECT u.id,u.name,u.username FROM `#__users` AS `u` INNER JOIN `#__mls_events_participants` AS `p` ON p.userid=u.id WHERE (u.name LIKE '%".$search_user."%' OR u.username LIKE '%".$search_user."%') AND p.eventid='$eventid' LIMIT 1" );334 $database->setQuery( "SELECT u.id,u.name,u.username,p.checkin FROM `#__users` AS `u` INNER JOIN `#__mls_events_participants` AS `p` ON p.userid=u.id WHERE (u.name LIKE '%".$search_user."%' OR u.username LIKE '%".$search_user."%') AND p.eventid='$eventid' LIMIT 1" ); 382 335 $database->loadObject( $user ); 383 336 } 384 337 385 338 if(!$user->id) { 386 mosRedirect( "index2.php?option=$option&act=$act &task=checkin", $l->m("err_no_such_user", "general") );339 mosRedirect( "index2.php?option=$option&act=$act", $l->m("err_no_such_user", "general") ); 387 340 } else { 388 echo "<pre>";389 print_r($user);390 echo "</pre>";391 341 $event = new mosMLS_events( $database ); 392 342 $event->load( $eventid ); 393 HTML_MLS_events_barcodes::checkinForm( $user, $event, $option, $act ); 394 } 395 } 396 397 function checkoutFormMLS_events_barcodes( $option, $act ) { 398 global $database; 399 343 if($user->checkin == 1) { 344 $database->setQuery( "SELECT COUNT(*) FROM `#__components` WHERE `option`='com_mls_catering'" ); 345 if($database->loadResult()) { 346 //Catering component exists 347 //Load balance 348 require_once( $mainframe->getPath( 'class', 'com_mls_catering' ) ); 349 require_once( $mosConfig_absolute_path."/components/com_mls_catering/mls_catering.config.php" ); 350 $database->setQuery("SELECT SUM(credit) - SUM(debit) AS `balance`" 351 ."\n FROM `#__mls_catering_money`" 352 ."\n WHERE `userid`='".$user->id."'" ); 353 $user->balance = $database->loadResult() ? $database->loadResult() : "0.00"; 354 mosMLS_catering_money::addZeros($user->balance, TRUE, TRUE, TRUE); 355 356 //Payback list 357 $lists["payback"] = mosHTML::yesnoRadioList('payback', ' class="inputbox"', '1'); 358 } else { 359 $lists = array(); 360 } 361 HTML_MLS_events_checkin::checkoutForm( $user, $event, $lists, $option, $act ); 362 } else { 363 HTML_MLS_events_checkin::checkinForm( $user, $event, $option, $act ); 364 } 365 } 400 366 } 401 367 402 368 function checkinSaveMLS_events_barcodes( $option, $act ) { 403 369 global $database, $mosConfig_offset, $mainframe, $my, $l, $mosConfig_absolute_path; 404 $l->setBlock(" barcodes");370 $l->setBlock("checkin"); 405 371 $userid = mosGetParam($_POST, 'userid', NULL); 406 372 $eventid = mosGetParam($_POST, 'eventid', NULL); … … 421 387 422 388 //Save deposit 423 if($deposit) { 424 require_once( $mainframe->getPath( 'class', 'com_mls_catering' ) ); 425 $trans = new mosMLS_catering_money( $database ); 426 $trans->userid = $userid; 427 $trans->bankerid = $my->id; 428 $trans->time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 429 $trans->description = $l->m( "deposit_at_checkin" ); 430 $trans->credit = $deposit; 431 432 if($trans->check()) { 433 $trans->store(); 434 require_once( $mosConfig_absolute_path."/components/com_mls_catering/mls_catering.config.php" ); 435 mosMLS_catering_money::addZeros($debit, TRUE, FALSE, FALSE); 436 } 437 } 438 389 $database->setQuery( "SELECT COUNT(*) FROM `#__components` WHERE `option`='com_mls_catering'" ); 390 if($database->loadResult()) { 391 if($deposit) { 392 require_once( $mainframe->getPath( 'class', 'com_mls_catering' ) ); 393 $trans = new mosMLS_catering_money( $database ); 394 $trans->userid = $userid; 395 $trans->bankerid = $my->id; 396 $trans->time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 397 $trans->description = $l->m( "deposit_at_checkin" ); 398 $trans->credit = $deposit; 399 400 if($trans->check()) { 401 $trans->store(); 402 require_once( $mosConfig_absolute_path."/components/com_mls_catering/mls_catering.config.php" ); 403 mosMLS_catering_money::addZeros($debit, TRUE, FALSE, FALSE); 404 } 405 } 406 } 439 407 //Set user as "checked in" 440 408 $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); … … 447 415 $msg = sprintf($l->m("msg_barcodes_deposit_saved","general"),$barcodecount,$deposit); 448 416 } 449 mosRedirect( "index2.php?option=$option&act=$act&task=checkin&mosmsg=".urlencode($msg) ); 417 mosRedirect( "index2.php?option=$option&act=$act", $msg ); 418 } 419 420 function checkoutSaveMLS_events_barcodes( $option, $act ) { 421 global $database, $mosConfig_offset, $mainframe, $my, $l, $mosConfig_absolute_path; 422 $l->setBlock("checkin"); 423 $userid = mosGetParam($_POST, 'userid', NULL); 424 $eventid = mosGetParam($_POST, 'eventid', NULL); 425 $payback = mosGetParam($_POST, 'payback', NULL); 426 $barcodes = mosGetParam($_POST, 'barcodes', array(0)); 427 428 //Verify the barcodes 429 $wrongcodes = array(); 430 $goodcodes = array(); 431 foreach($barcodes as $code) { 432 if($code) { 433 $database->setQuery( "SELECT `id` FROM `#__mls_events_barcodes` WHERE `userid`='".$userid."' AND `code`='".$code."'" ); 434 if($database->loadResult()) { 435 $goodcodes[] = $code; 436 } else { 437 $wrongcodes[] = $code; 438 } 439 } 440 } 441 442 if(count($wrongcodes)) { 443 //There were some wrong codes 444 mosRedirect( "index2.php?option=$option&act=$act", $l->m("err_codes_mismatch","general") ); 445 } else { 446 //All codes ok, disable codes 447 $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 448 $database->setQuery( "UPDATE `#__mls_events_barcodes` SET `status`='0', `lastupdate`='".$time."' WHERE `userid`='".$userid."' AND `code` IN (".implode( ',', $goodcodes ).")" ); 449 $database->query(); 450 451 //Set user as "checked out" 452 $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 453 $database->setQuery( "UPDATE `#__mls_events_participants` SET `checkout`='1', `checkout_time`='".$time."' WHERE `userid`='".$userid."' AND `eventid`='".$eventid."'" ); 454 $database->query(); 455 456 //Check payback 457 if($payback) { 458 require_once( $mainframe->getPath( 'class', 'com_mls_catering' ) ); 459 $database->setQuery("SELECT SUM(credit) - SUM(debit) AS `balance`" 460 ."\n FROM `#__mls_catering_money`" 461 ."\n WHERE `userid`='".$userid."'" ); 462 $balance = $database->loadResult(); 463 464 $trans = new mosMLS_catering_money( $database ); 465 $trans->userid = $userid; 466 $trans->bankerid = $my->id; 467 $trans->time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 468 $trans->description = $l->m( "payback_at_checkout" ); 469 $trans->debit = $balance; 470 471 if($trans->check()) { 472 $trans->store(); 473 require_once( $mosConfig_absolute_path."/components/com_mls_catering/mls_catering.config.php" ); 474 mosMLS_catering_money::addZeros($balance, TRUE, FALSE, FALSE); 475 } 476 } 477 //Redirect 478 if(!$payback) { 479 $msg = $l->m("msg_user_checked_out","general"); 480 } else { 481 $msg = sprintf($l->m("msg_user_checked_out_payback","general"),$balance); 482 } 483 mosRedirect( "index2.php?option=$option&act=$act", $msg ); 484 } 485 } 486 487 /** Barcodes **/ 488 function showMLS_events_barcodes( $option, $act ) { 489 global $database, $l, $mainframe; 490 $limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 10 ); 491 $limitstart = $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ); 492 $search = $mainframe->getUserStateFromRequest( "search{$option}", 'search', '' ); 493 $search = $database->getEscaped( trim( strtolower( $search ) ) ); 494 $userid = $mainframe->getUserStateFromRequest( "filter_id{$option}", 'userid_filter', 0 ); 495 496 $where = ""; 497 $words = explode(" ",$search); 498 foreach($words as $word) { 499 if($word) { 500 $op = $where ? "AND" : "WHERE"; 501 $where .= " $op (u.name LIKE '%$word%' OR u.username LIKE '%$word%' OR c.code LIKE '%$word%' OR u.email LIKE '%$word%')"; 502 } 503 } 504 $op = $where ? "AND" : "WHERE"; 505 $where .= $userid ? " $op u.id = '$userid'" : ""; 506 507 // get the total number of records 508 $database->setQuery( "SELECT COUNT(*) FROM `#__mls_events_barcodes` AS `c`" 509 ."\n INNER JOIN `#__users` AS `u` ON u.id=c.userid $where" ); 510 $total = $database->loadResult(); 511 512 require_once( "includes/pageNavigation.php" ); 513 $pageNav = new mosPageNav( $total, $limitstart, $limit ); 514 515 $database->setQuery( "SELECT u.name, u.username, u.email, c.* FROM `#__mls_events_barcodes` AS `c`" 516 ."\n INNER JOIN `#__users` AS `u` ON u.id=c.userid $where" 517 ."\n ORDER BY u.username ASC" 518 ."\n LIMIT $pageNav->limitstart, $pageNav->limit" ); 519 $rows = $database->loadObjectList(); 520 521 // Select lists 522 $user_select = HTML_MLS::showUserSelect( $userid, $option, $act ); 523 524 HTML_MLS_events_barcodes::showBarcodes( $rows, $pageNav, $user_select, $search, $option, $act ); 525 526 } 527 528 function changeMLS_events_barcodes( $cid, $status, $option, $act ) { 529 global $database, $mosConfig_offset, $l; 530 531 if (count( $cid )) { 532 $cids = implode( ',', $cid ); 533 $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 534 $query = "UPDATE `#__mls_events_barcodes` SET `status`='".$status."', `lastupdate`='".$time."' WHERE `id` IN ($cids)"; 535 $database->setQuery($query); 536 $database->query(); 537 } 538 mosRedirect( "index2.php?option=$option&act=$act&mosmsg=".urlencode($l->m("msg_status_changed","general")) ); 450 539 } 451 540 … … 462 551 463 552 mosRedirect( "index2.php?option=$option&act=$act" ); 553 } 554 555 function addMLS_events_barcodes( $option, $act ) { 556 global $database, $l; 557 558 $l->setBlock("barcodes"); 559 $database->setQuery( "SELECT `id` AS `value`, CONCAT(`name`,' (',`username`,')') AS `text` FROM `#__users` ORDER BY `name` ASC" ); 560 $users = $database->loadObjectList(); 561 $stdOpt = new stdClass(); 562 $stdOpt->value = '0'; 563 $stdOpt->text = $l->m("select_user"); 564 array_unshift($users, $stdOpt); 565 $lists["userid"] = mosHTML::selectList($users, 'userid', ' class="inputbox"', 'value', 'text', '0'); 566 567 $lists["status"] = mosHTML::yesnoRadioList('status', ' class="inputbox"', '1'); 568 HTML_MLS_events_barcodes::addNew( $lists, $option, $act ); 569 } 570 571 function saveMLS_events_barcodes( $option, $act ) { 572 global $database, $mosConfig_offset, $l; 573 574 $row = new mosMLS_events_barcode( $database ); 575 576 if (!$row->bind( $_POST )) { 577 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 578 exit(); 579 } 580 $row->lastupdate = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 581 if (!$row->check()) { 582 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 583 exit(); 584 } 585 if (!$row->store()) { 586 echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; 587 exit(); 588 } 589 590 //mosRedirect( "index2.php?option=$option&act=$act", $l->m("msg_barcode_saved","general") ); 464 591 } 465 592 branches/com_mls_events/barcodes/install.mls_events.php
r36 r111 19 19 $database->setQuery("UPDATE `#__components` SET `admin_menu_img`='js/ThemeOffice/config.png' WHERE `admin_menu_link`='option=com_mls_events&act=configuration'"); 20 20 $database->query(); 21 21 $database->setQuery("UPDATE `#__components` SET `admin_menu_img`='js/ThemeOffice/home.png' WHERE `admin_menu_link`='option=com_mls_catering&act=checkin'"); 22 $database->query(); 23 $database->setQuery("UPDATE `#__components` SET `admin_menu_img`='js/ThemeOffice/content.png' WHERE `admin_menu_link`='option=com_mls_catering&act=barcodes'"); 24 $database->query(); 22 25 //Start installation/upgrade 23 26 include($mosConfig_absolute_path."/administrator/components/com_mls_events/comupgrade.class.php"); branches/com_mls_events/barcodes/lang/english.php
r108 r111 49 49 "msg_status_changed" => "Status changed", 50 50 "msg_barcodes_saved" => "%s Barcodes saved!", 51 "msg_barcodes_deposit_saved" => "%s Barcodes saved and %s deposited on Bank Account!"); 51 "msg_barcodes_deposit_saved" => "%s Barcodes saved and %s deposited on Bank Account!", 52 "msg_barcode_saved" => "Barcode saved!", 53 "err_please_select_user" => "Please select User!", 54 "err_codes_mismatch" => "Some of the codes entered mismatch!", 55 "msg_user_checked_out" => "The user has been checked out!", 56 "msg_user_checked_out_payback" => "The user has been checked out! Please Pay %s back to user!"); 52 57 53 58 $lang_data["events"] = array( … … 236 241 $lang_data["barcodes"] = array( 237 242 "barcodes" => "Barcodes", 243 "add_barcode" => "Add Barcode", 238 244 "checkin" => "Checkin", 239 245 "checkout" => "Checkout", 240 246 "select_user" => "Select User", 241 "userid" => "User ID", 242 "search_user" => "Search User", 243 "user" => "User", 244 "event" => "Event", 245 "save" => "Save", 246 "search" => "Search", 247 "user" => "User", 248 "event" => "Event", 249 247 250 "name" => "Name", 248 251 "username" => "Username", … … 252 255 "lastupdate" => "Last Update", 253 256 "enter_barcodes" => "Enter Barcodes", 257 "barcode" => "Barcode"); 258 259 $lang_data["checkin"] = array( 260 "checkin_checkout" => "Checkin/Checkout", 261 "select_user" => "Select User", 262 "search_user" => "Search User", 263 "userid" => "User ID", 264 "search" => "Search", 265 "money_deposit" => "Money Deposit", 266 "deposit_at_checkin" => "Deposit at Checkin", 267 "event" => "Event", 268 "user" => "User", 254 269 "barcode" => "Barcode", 255 "money_deposit" => "Money Deposit", 256 "deposit_at_checkin" => "Deposit at Checkin"); 270 "save" => "Save", 271 "checkin" => "Checkin", 272 "checkout" => "Checkout", 273 "account_balance" => "Accout Balance", 274 "payback_balance" => "Payback Balance", 275 "payback_at_checkout" => "Payback at checkout"); 276 257 277 258 278 ?> branches/com_mls_events/barcodes/mls_events.xml
r105 r111 29 29 <menu act="times">Times</menu> 30 30 <menu act="coupons">Coupons</menu> 31 <menu act="checkin">Checkin/Checkout</menu> 31 32 <menu act="barcodes">Barcodes</menu> 32 33 <menu act="configuration">Configuration</menu> branches/com_mls_events/barcodes/toolbar.mls_events.html.php
r108 r111 80 80 mosMenuBar::startTable(); 81 81 mosMenuBar::spacer(); 82 mosMenuBar::custom(' checkin','edit.png','edit_f2.png','Checkin',false);82 mosMenuBar::custom('enable','edit.png','edit_f2.png','Enable',false); 83 83 mosMenuBar::spacer(); 84 mosMenuBar::custom(' checkout','edit.png','edit_f2.png','Checkout',false);84 mosMenuBar::custom('disable','edit.png','edit_f2.png','Disable',false); 85 85 mosMenuBar::spacer(); 86 86 mosMenuBar::deleteList(); 87 mosMenuBar::spacer(); 88 mosMenuBar::addNew(); 87 89 mosMenuBar::spacer(); 88 90 mosMenuBar::endTable(); branches/com_mls_events/barcodes/toolbar.mls_events.php
r108 r111 50 50 break; 51 51 case "barcodes