Assembla home | Assembla project page
 

Changeset 111

Show
Ignore:
Timestamp:
11/09/06 14:01:30 (2 years ago)
Author:
moensch
Message:

Separated "Checkin/Checkout" page and "Barcodes" page. Checkout now working as well. Ready for testing, so feel free to download and install.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/com_mls_events/barcodes/admin.mls_events.html.php

    r110 r111  
    10171017        } 
    10181018         
     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">&nbsp;</td> 
     1057                        </tr> 
     1058                        <tr> 
     1059                                <td align="right" valign="top">&nbsp;</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 **/ 
     1073class HTML_MLS_events_checkin { 
    10191074        function showUserform( $type, $lists, $option, $act ) { 
    10201075                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> 
    10271082                </tr> 
    10281083                </table> 
     
    10511106                <input type="hidden" name="option" value="<?php echo $option; ?>" /> 
    10521107                <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" /> 
    10541109                </form> 
    10551110                <script language="JavaScript"> 
     
    10611116         
    10621117        function checkinForm( $user, $event, $option, $act ) { 
    1063                 global $l
    1064                 $l->setBlock("barcodes"); 
     1118                global $l, $database
     1119                $l->setBlock("checkin"); 
    10651120                ?> 
    10661121                <form action="index2.php" method="post" name="adminForm"> 
     
    11021157                                <td colspan="2" valign="top" align="right">&nbsp;</td> 
    11031158                        </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                        ?> 
    11081170                        <tr> 
    11091171                                <td align="right" valign="top">&nbsp;</td> 
     
    11161178                <input type="hidden" name="act" value="<?php echo $act; ?>" /> 
    11171179                <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">&nbsp;</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">&nbsp;</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" /> 
    11181254                </form> 
    11191255                <script language="JavaScript"> 
  • branches/com_mls_events/barcodes/admin.mls_events.php

    r108 r111  
    199199                                checkinFormMLS_events_barcodes( $option, $act ); 
    200200                                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; 
    201229                        case "checkoutsave": 
    202230                                checkoutSaveMLS_events_barcodes( $option, $act ); 
    203231                                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; 
    216232                        default: 
    217                                 showMLS_events_barcodes( $option, $act ); 
     233                                checkinUserMLS_events_checkin( $option, $act ); 
    218234                                break; 
    219235                } 
     
    275291} 
    276292 
    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 **/ 
     294function checkinUserMLS_events_checkin( $option, $act ) { 
    329295        global $database, $l; 
    330296        $l->setBlock("barcodes"); 
     
    350316        array_unshift($users, $stdOpt); 
    351317        $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 
     321function searchUserMLS_events_checkin( $option, $act ) { 
     322        global $database, $l, $mainframe, $mosConfig_absolute_path; 
    370323        // First, get through the user stuff 
    371324        $userid = mosGetParam($_POST, 'userid', NULL); 
     
    376329        if($select_user) { $userid = $select_user; } 
    377330        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'" ); 
    379332                $database->loadObject( $user ); 
    380333        } 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" ); 
    382335                $database->loadObject( $user ); 
    383336        } 
    384337         
    385338        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") ); 
    387340        } else { 
    388                 echo "<pre>"; 
    389                 print_r($user); 
    390                 echo "</pre>"; 
    391341                $event = new mosMLS_events( $database ); 
    392342                $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        } 
    400366} 
    401367 
    402368function checkinSaveMLS_events_barcodes( $option, $act ) { 
    403369        global $database, $mosConfig_offset, $mainframe, $my, $l, $mosConfig_absolute_path; 
    404         $l->setBlock("barcodes"); 
     370        $l->setBlock("checkin"); 
    405371        $userid = mosGetParam($_POST, 'userid', NULL); 
    406372        $eventid = mosGetParam($_POST, 'eventid', NULL); 
     
    421387         
    422388        //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        } 
    439407        //Set user as "checked in" 
    440408        $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 
     
    447415                $msg = sprintf($l->m("msg_barcodes_deposit_saved","general"),$barcodecount,$deposit); 
    448416        } 
    449         mosRedirect( "index2.php?option=$option&act=$act&task=checkin&mosmsg=".urlencode($msg) ); 
     417        mosRedirect( "index2.php?option=$option&act=$act", $msg ); 
     418
     419 
     420function 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 **/ 
     488function 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 
     528function 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")) ); 
    450539} 
    451540 
     
    462551 
    463552        mosRedirect( "index2.php?option=$option&act=$act" ); 
     553} 
     554 
     555function 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 
     571function 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") ); 
    464591} 
    465592 
  • branches/com_mls_events/barcodes/install.mls_events.php

    r36 r111  
    1919        $database->setQuery("UPDATE `#__components` SET `admin_menu_img`='js/ThemeOffice/config.png' WHERE `admin_menu_link`='option=com_mls_events&act=configuration'"); 
    2020        $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(); 
    2225        //Start installation/upgrade 
    2326        include($mosConfig_absolute_path."/administrator/components/com_mls_events/comupgrade.class.php"); 
  • branches/com_mls_events/barcodes/lang/english.php

    r108 r111  
    4949                "msg_status_changed" => "Status changed", 
    5050                "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!"); 
    5257 
    5358$lang_data["events"] = array( 
     
    236241$lang_data["barcodes"] = array( 
    237242                "barcodes" => "Barcodes", 
     243                "add_barcode" => "Add Barcode", 
    238244                "checkin" => "Checkin", 
    239245                "checkout" => "Checkout", 
    240246                "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                 
    247250                "name" => "Name", 
    248251                "username" => "Username", 
     
    252255                "lastupdate" => "Last Update", 
    253256                "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", 
    254269                "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 
    257277 
    258278?> 
  • branches/com_mls_events/barcodes/mls_events.xml

    r105 r111  
    2929                        <menu act="times">Times</menu> 
    3030                        <menu act="coupons">Coupons</menu> 
     31                        <menu act="checkin">Checkin/Checkout</menu> 
    3132                        <menu act="barcodes">Barcodes</menu> 
    3233                        <menu act="configuration">Configuration</menu> 
  • branches/com_mls_events/barcodes/toolbar.mls_events.html.php

    r108 r111  
    8080                mosMenuBar::startTable(); 
    8181                mosMenuBar::spacer(); 
    82                 mosMenuBar::custom('checkin','edit.png','edit_f2.png','Checkin', false); 
     82                mosMenuBar::custom('enable','edit.png','edit_f2.png','Enable',false); 
    8383                mosMenuBar::spacer(); 
    84                 mosMenuBar::custom('checkout','edit.png','edit_f2.png','Checkout', false); 
     84                mosMenuBar::custom('disable','edit.png','edit_f2.png','Disable',false); 
    8585                mosMenuBar::spacer(); 
    8686                mosMenuBar::deleteList(); 
     87                mosMenuBar::spacer(); 
     88                mosMenuBar::addNew(); 
    8789                mosMenuBar::spacer(); 
    8890                mosMenuBar::endTable(); 
  • branches/com_mls_events/barcodes/toolbar.mls_events.php

    r108 r111  
    5050                break; 
    5151        case "barcodes