您的位置:首页 > 其它

Get Minutes for Match Event Back!!!

2012-08-01 20:59 169 查看
For the new pop-up window functionality, we need this field back.



And how does the field look in real world?



So this is the time when the backups come to be useful. I have backed up my whole Joomla! site before I started to develop on the project. So, now, go to the original copy of this two files:

\administrator\components\com_joomsport\admin.joomsport.php

\administrator\components\com_joomsport\admin.joomsport.html.php

Get it From Database:

Let's open admin.joomsport.php, locate function BL_MatchEdit($is_id, $option), on the bottom of its body, we find:

$query = "SELECT me.*,ev.e_name,CONCAT(p.first_name,' ',p.last_name) as p_name FROM  #__bl_events as ev , #__bl_players as p, #__bl_match_events as me WHERE me.player_id = p.id AND ev.player_event = '1' AND  me.e_id = ev.id AND me.match_id = ".$row->id." ORDER BY CAST(me.minutes AS UNSIGNED),p.first_name,p.last_name";
$db->setQuery($query);
//echo mysql_error();die();
$lists['m_events'] = $db->loadObjectList();

$query = "SELECT me.*,ev.e_name,p.t_name as p_name,p.id as pid FROM  #__bl_events as ev, #__bl_teams as p , #__bl_match_events as me WHERE me.t_id = p.id AND ev.player_event = '0' AND  me.e_id = ev.id AND me.match_id = ".$row->id." ORDER BY p.t_name";
$db->setQuery($query);
//echo mysql_error();die();
$lists['t_events'] = $db->loadObjectList();


These two blocks did the similar jobs, they both get the data from events,teams andmatch_events
table, but with field player_event of different value.

Actually in my implementation, I removed the query for the case that player_event is 0, which for match events, because we don't need that.

Since the query gets all the fields of table
match_events, we don't need change anything here.

Now open admin.joomsport.html.php, find function
bl_editMatch($row, $lists, $option), here will be complex:

<table class="adminlist" id="new_events">
<tr>
<th align="center" colspan="5" class="title">
<?php echo JText::_( 'BLBE_PLAYEREVENTS' ); ?>
</th>
</tr>
<tr>
<th class="title" width="2%">
<?php echo JText::_( 'Num' ); ?>				</th>

<th class="title" width="170">
<?php echo JText::_( 'BLBE_PLAYEREVENT' ); ?>
</th>
<th>
<?php echo JText::_( 'BLBE_PLAYER' ); ?>
</th>

<th class="title" width="60">
<?php echo JText::_( 'BLBE_MINUTES' ); ?>
</th>
<th class="title" width="60">
<?php echo JText::_( 'BLBE_COUNT' ); ?>
</th>
</tr>
<?php
if(count($lists['m_events'])){
foreach($lists['m_events'] as $m_events){
echo "<tr>";
echo '<td><input type="hidden" name="em_id[]" value="'.$m_events->id.'" /><a href="javascript: void(0);" onClick="javascript:Delete_tbl_row(this); return false;" title="Delete"><img src="components/com_joomsport/img/publish_x.png"  border="0" alt="Delete"></a></td>';
echo '<td><input type="hidden" name="new_eventid[]" value="'.$m_events->e_id.'" />'.$m_events->e_name.'</td>';
echo '<td><input type="hidden" name="new_player[]" value="'.$m_events->player_id.'" />'.$m_events->p_name.'</td>';
echo '<td><input type="text" size="5" maxlength="5" name="e_minuteval[]" value="'.$m_events->minutes.'" /></td>';
echo '<td><input type="text" size="5" maxlength="5" name="e_countval[]" value="'.$m_events->ecount.'" /></td>';
echo "</tr>";
}
}
?>
</table>


It seems that I've removed the th for minutes and its td. Not finished yet, there is a button, which will trigger a js function: bl_add_event(), it has been changed before, when I cut off the field for minutes. And we get back
all the lines for creating the table cell of minutes.

Save the Data:

As to this problem, we open admin.joomsport.php again, and find function
BL_MatchSave($option), the queries are already there, with the minutes updated into database:

for ($i=0; $i< count($_POST['new_eventid']); $i++)
{
if(!intval($_POST['em_id'][$i]))
{

$new_event = $_POST['new_eventid'][$i];

$query = "SELECT team_id FROM #__bl_players WHERE id=".intval($_POST['new_player'][$i]);
$db->setQuery($query);
$teamid = $db->loadResult();

$query = "INSERT INTO #__bl_match_events(e_id,player_id,match_id,ecount,minutes,t_id) VALUES(".$new_event.",".$_POST['new_player'][$i].",".$row->id.",".intval($_POST['e_countval'][$i]).",".intval($_POST['e_minuteval'][$i]).",".intval($teamid).")";
$db->setQuery($query);
$db->query();

$me_arr[] = $db->insertid();
}else{
$query = "SELECT * FROM #__bl_match_events WHERE id=".intval($_POST['em_id'][$i]);
$db->setQuery($query);
$event_bl = $db->loadObjectList();

if(count($event_bl)){
$query = "UPDATE #__bl_match_events SET minutes=".intval($_POST['e_minuteval'][$i]).",ecount=".intval($_POST['e_countval'][$i])." WHERE id=".intval($_POST['em_id'][$i]);
$db->setQuery($query);
$db->query();

$me_arr[] = intval($_POST['em_id'][$i]);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐