Assembla home | Assembla project page
 

Changeset 108

Show
Ignore:
Timestamp:
11/07/06 17:43:46 (2 years ago)
Author:
moensch
Message:

Checkin working now. You can submit up to 5 barcodes and can directly deposit money. The participant is automatically marked as "checked_in" in the Database.

Files:

Legend:

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

    r107 r108  
    10161016                HTML_MLS::printFooter($option); 
    10171017        } 
     1018         
     1019        function showUserform( $type, $lists, $option, $act ) { 
     1020                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> 
     1027                </tr> 
     1028                </table> 
     1029                <table class="adminform"> 
     1030                        <tr>  
     1031                                <td width="20%" valign="top" align="right"><?php echo $l->m("select_event","general") ?>:</td> 
     1032                                <td width="80%"><?php echo $lists["events"]; ?></td> 
     1033                        </tr> 
     1034                        <tr>  
     1035                                <td width="20%" valign="top" align="right"><?php echo $l->m("userid") ?>:</td> 
     1036                                <td width="80%"><input class="text_area" id="userid" type="text" name="userid" size="10" maxlength="10" value="" /></td> 
     1037                        </tr> 
     1038                        <tr>  
     1039                                <td align="right" valign="top"><?php echo $l->m("search_user") ?>:</td> 
     1040                                <td><input class="text_area" id="search_user" type="text" name="search_user" size="30" maxlength="255" value="" /></td> 
     1041                        </tr> 
     1042                        <tr>  
     1043                                <td align="right" valign="top"><?php echo $l->m("select_user","general") ?>:</td> 
     1044                                <td><?php echo $lists["users"]; ?></td> 
     1045                        </tr> 
     1046                        <tr>  
     1047                                <td align="right" valign="top">&nbsp;</td> 
     1048                                <td><input type="submit" class="button" name="submitSearch" value="<?php echo $l->m("search");?>" /></td> 
     1049                        </tr> 
     1050                </table> 
     1051                <input type="hidden" name="option" value="<?php echo $option; ?>" /> 
     1052                <input type="hidden" name="act" value="<?php echo $act; ?>" /> 
     1053                <input type="hidden" name="task" value="<?php echo $type; ?>form" /> 
     1054                </form> 
     1055                <script language="JavaScript"> 
     1056                document.getElementById('userid').focus(); 
     1057                </script> 
     1058                <?php 
     1059                HTML_MLS::printFooter($option); 
     1060        } 
     1061         
     1062        function checkinForm( $user, $event, $option, $act ) { 
     1063                global $l; 
     1064                $l->setBlock("barcodes"); 
     1065                ?> 
     1066                <form action="index2.php" method="post" name="adminForm"> 
     1067                <table class="adminheading"> 
     1068                <tr> 
     1069                        <th>myLANsite Events: <?php echo $l->m("checkin"); ?> :: <?php echo $l->m("enter_barcodes"); ?></th> 
     1070                </tr> 
     1071                </table> 
     1072                <table class="adminform"> 
     1073                        <tr> 
     1074                                <td width="20%" valign="top" align="right"><?php echo $l->m("event") ?>:</td> 
     1075                                <td width="80%"><?php echo $event->name; ?></td> 
     1076                        </tr> 
     1077                        <tr> 
     1078                                <td width="20%" valign="top" align="right"><?php echo $l->m("user") ?>:</td> 
     1079                                <td width="80%"><?php echo $user->id; ?>: <?php echo $user->name; ?> (<?php echo $user->username; ?>)</td> 
     1080                        </tr> 
     1081                        <tr> 
     1082                                <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 1:</td> 
     1083                                <td width="80%"><input class="text_area" id="barcode1" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 
     1084                        </tr> 
     1085                        <tr> 
     1086                                <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 2:</td> 
     1087                                <td width="80%"><input class="text_area" id="barcode2" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 
     1088                        </tr> 
     1089                        <tr> 
     1090                                <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 3:</td> 
     1091                                <td width="80%"><input class="text_area" id="barcode3" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 
     1092                        </tr> 
     1093                        <tr> 
     1094                                <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 4:</td> 
     1095                                <td width="80%"><input class="text_area" id="barcode4" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 
     1096                        </tr> 
     1097                        <tr> 
     1098                                <td width="20%" valign="top" align="right"><?php echo $l->m("barcode") ?> 5:</td> 
     1099                                <td width="80%"><input class="text_area" id="barcode5" type="text" name="barcodes[]" size="10" maxlength="12" value="" /></td> 
     1100                        </tr> 
     1101                        <tr> 
     1102                                <td colspan="2" valign="top" align="right">&nbsp;</td> 
     1103                        </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> 
     1108                        <tr> 
     1109                                <td align="right" valign="top">&nbsp;</td> 
     1110                                <td><input type="submit" class="button" name="submitCodes" value="<?php echo $l->m("save");?>" /></td> 
     1111                        </tr> 
     1112                </table> 
     1113                <input type="hidden" name="userid" value="<?php echo $user->id; ?>" /> 
     1114                <input type="hidden" name="eventid" value="<?php echo $event->id; ?>" /> 
     1115                <input type="hidden" name="option" value="<?php echo $option; ?>" /> 
     1116                <input type="hidden" name="act" value="<?php echo $act; ?>" /> 
     1117                <input type="hidden" name="task" value="checkinsave" /> 
     1118                </form> 
     1119                <script language="JavaScript"> 
     1120                document.getElementById('barcode1').focus(); 
     1121                </script> 
     1122                <?php 
     1123                HTML_MLS::printFooter($option); 
     1124        } 
    10181125} 
    10191126 
  • branches/com_mls_events/barcodes/admin.mls_events.php

    r107 r108  
    188188                switch($task) { 
    189189                        case "checkout": 
    190                                 checkoutformMLS_events_barcodes( $option, $act ); 
     190                                checkoutUserMLS_events_barcodes( $option, $act ); 
    191191                                break; 
    192192                        case "checkin": 
    193                                 checkinformMLS_events_barcodes( $option, $act ); 
     193                                checkinUserMLS_events_barcodes( $option, $act ); 
     194                                break; 
     195                        case "checkoutform": 
     196                                checkoutFormMLS_events_barcodes( $option, $act ); 
     197                                break; 
     198                        case "checkinform": 
     199                                checkinFormMLS_events_barcodes( $option, $act ); 
     200                                break; 
     201                        case "checkoutsave": 
     202                                checkoutSaveMLS_events_barcodes( $option, $act ); 
     203                                break; 
     204                        case "checkinsave": 
     205                                checkinSaveMLS_events_barcodes( $option, $act ); 
    194206                                break; 
    195207                        case "enable": 
     
    198210                        case "disable": 
    199211                                changeMLS_events_barcodes( $cid[0], 0, $option, $act ); 
     212                                break; 
     213                        case "remove": 
     214                                removeMLS_events_barcodes( $cid, $option, $act ); 
    200215                                break; 
    201216                        default: 
     
    308323        $database->query(); 
    309324         
    310         mosRedirect( "index2.php?option=$option&act=$act&&mosmsg=".urlencode($l->m("msg_status_changed","general")) ); 
    311 
    312  
    313 function checkinformMLS_events_barcodes( $option ) { 
     325        mosRedirect( "index2.php?option=$option&act=$act&mosmsg=".urlencode($l->m("msg_status_changed","general")) ); 
     326
     327 
     328function checkinUserMLS_events_barcodes( $option, $act ) { 
     329        global $database, $l; 
     330        $l->setBlock("barcodes"); 
     331         
     332        //Event select list 
     333        $database->setQuery( "SELECT `id` AS `value`, `name` AS `text` FROM `#__mls_events` ORDER BY `name` ASC" ); 
     334        $users = $database->loadObjectList(); 
     335        $stdOpt = new stdClass(); 
     336        $stdOpt->value = '0'; 
     337        $stdOpt->text = $l->m("select_event","general"); 
     338        array_unshift($users, $stdOpt); 
     339        $database->setQuery( "SELECT `id` FROM `#__mls_events` WHERE `active`='1'" ); 
     340        $eventid = $database->loadResult(); 
     341        $eventid = $eventid ? $eventid : 0; 
     342        $lists["events"] = mosHTML::selectList($users, 'eventid', ' class="inputbox"', 'value', 'text', $eventid); 
     343         
     344        //User select list 
     345        $database->setQuery( "SELECT `id` AS `value`, CONCAT(`name`,' (',`username`,')') AS `text` FROM `#__users` ORDER BY `name` ASC" ); 
     346        $users = $database->loadObjectList(); 
     347        $stdOpt = new stdClass(); 
     348        $stdOpt->value = '0'; 
     349        $stdOpt->text = $l->m("select_user","general"); 
     350        array_unshift($users, $stdOpt); 
     351        $lists["users"] = mosHTML::selectList($users, 'select_user', ' class="inputbox"', 'value', 'text', '0'); 
     352        HTML_MLS_events_barcodes::showUserform( "checkin", $lists, $option, $act ); 
     353
     354 
     355function 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 
     368function checkinFormMLS_events_barcodes( $option, $act ) { 
     369        global $database, $l; 
     370        // First, get through the user stuff 
     371        $userid = mosGetParam($_POST, 'userid', NULL); 
     372        $eventid = mosGetParam($_POST, 'eventid', NULL); 
     373        $search_user = mosGetParam($_POST, 'search_user', NULL); 
     374        $select_user = mosGetParam($_POST, 'select_user', NULL); 
     375         
     376        if($select_user) { $userid = $select_user; } 
     377        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'" ); 
     379                $database->loadObject( $user ); 
     380        } 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" ); 
     382                $database->loadObject( $user ); 
     383        } 
     384         
     385        if(!$user->id) { 
     386                mosRedirect( "index2.php?option=$option&act=$act&task=checkin", $l->m("err_no_such_user", "general") ); 
     387        } else { 
     388                echo "<pre>"; 
     389                print_r($user); 
     390                echo "</pre>"; 
     391                $event = new mosMLS_events( $database ); 
     392                $event->load( $eventid ); 
     393                HTML_MLS_events_barcodes::checkinForm( $user, $event, $option, $act ); 
     394        } 
     395
     396 
     397function checkoutFormMLS_events_barcodes( $option, $act ) { 
    314398        global $database; 
    315 
    316  
    317 function checkoutformMLS_events_barcodes( $option ) { 
    318         global $database; 
     399         
     400
     401 
     402function checkinSaveMLS_events_barcodes( $option, $act ) { 
     403        global $database, $mosConfig_offset, $mainframe, $my, $l, $mosConfig_absolute_path; 
     404        $l->setBlock("barcodes"); 
     405        $userid = mosGetParam($_POST, 'userid', NULL); 
     406        $eventid = mosGetParam($_POST, 'eventid', NULL); 
     407        $deposit = mosGetParam($_POST, 'deposit', NULL); 
     408        $barcodes = mosGetParam($_POST, 'barcodes', array(0)); 
     409         
     410        //Save barcodes 
     411        $barcodecount = 0; 
     412        foreach($barcodes as $code) { 
     413                if($code) { 
     414                        $barcodecount++; 
     415                        $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 
     416                        $query = "INSERT INTO `#__mls_events_barcodes` (`id`,`code`,`userid`,`status`,`lastupdate`) VALUES ('','".$code."','".$userid."','1','".$time."')"; 
     417                        $database->setQuery( $query ); 
     418                        $database->query(); 
     419                } 
     420        } 
     421         
     422        //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         
     439        //Set user as "checked in" 
     440        $time = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); 
     441        $database->setQuery( "UPDATE `#__mls_events_participants` SET `checkin`='1', `checkin_time`='".$time."' WHERE `userid`='".$userid."' AND `eventid`='".$eventid."'" ); 
     442        $database->query(); 
     443         
     444        if(!$deposit) { 
     445                $msg = sprintf($l->m("msg_barcodes_saved","general"),$barcodecount); 
     446        } else { 
     447                $msg = sprintf($l->m("msg_barcodes_deposit_saved","general"),$barcodecount,$deposit); 
     448        } 
     449        mosRedirect( "index2.php?option=$option&act=$act&task=checkin&mosmsg=".urlencode($msg) ); 
     450
     451 
     452function removeMLS_events_barcodes($cid, $option, $act) { 
     453        global $database,$my; 
     454 
     455        if (count( $cid )) { 
     456                $cids = implode( ',', $cid ); 
     457                $database->setQuery( "DELETE FROM `#__mls_events_barcodes` WHERE `id` IN ($cids)" ); 
     458                if (!$database->query()) { 
     459                        echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; 
     460                } 
     461        } 
     462 
     463        mosRedirect( "index2.php?option=$option&act=$act" ); 
    319464} 
    320465 
  • branches/com_mls_events/barcodes/lang/english.php

    r105 r108  
    4444                "err_coupon_expired" => "This coupon has expired!", 
    4545                "err_coupon_pending" => "This coupon is not yet active. Please try again later!", 
     46                "err_no_such_user" => "User not found!", 
    4647                "details" => "Details", 
    4748                "parameters" => "Parameters", 
    48                 "msg_status_changed" => "Status changed"); 
     49                "msg_status_changed" => "Status changed", 
     50                "msg_barcodes_saved" => "%s Barcodes saved!", 
     51                "msg_barcodes_deposit_saved" => "%s Barcodes saved and %s deposited on Bank Account!"); 
    4952 
    5053$lang_data["events"] = array( 
     
    233236$lang_data["barcodes"] = array( 
    234237                "barcodes" => "Barcodes", 
    235                 "user" => "User", 
     238                "checkin" => "Checkin", 
     239                "checkout" => "Checkout", 
     240                "select_user" => "Select User", 
     241                "userid" => "User ID", 
     242                "search_user" => "Search User", 
     243                "user" => "User", 
     244                "event" => "Event", 
     245                "save" => "Save", 
    236246                "search" => "Search", 
    237247                "name" => "Name", 
     
    240250                "code" => "Code", 
    241251                "status" => "Status", 
    242                 "lastupdate" => "Last Update"); 
     252                "lastupdate" => "Last Update", 
     253                "enter_barcodes" => "Enter Barcodes", 
     254                "barcode" => "Barcode", 
     255                "money_deposit" => "Money Deposit", 
     256                "deposit_at_checkin" => "Deposit at Checkin"); 
    243257 
    244258?> 
  • branches/com_mls_events/barcodes/toolbar.mls_events.html.php

    r34 r108  
    7676                mosMenuBar::endTable(); 
    7777        } 
     78         
     79        function BARCODES_MENU() { 
     80                mosMenuBar::startTable(); 
     81                mosMenuBar::spacer(); 
     82                mosMenuBar::custom('checkin','edit.png','edit_f2.png','Checkin', false); 
     83                mosMenuBar::spacer(); 
     84                mosMenuBar::custom('checkout','edit.png','edit_f2.png','Checkout', false); 
     85                mosMenuBar::spacer(); 
     86                mosMenuBar::deleteList(); 
     87                mosMenuBar::spacer(); 
     88                mosMenuBar::endTable(); 
     89        } 
    7890}; 
    7991 
  • branches/com_mls_events/barcodes/toolbar.mls_events.php

    r34 r108  
    4949                } 
    5050                break; 
     51        case "barcodes": 
     52                menuMLS_events::BARCODES_MENU(); 
     53                break; 
    5154        case "": 
    5255                switch ( $task ) {