There should be more fields in the table '#__bl_season', they are for:
's_pl_yellow_points' - deduction of discipline points for yellow card of one player;
's_pl_red_points' - deduction of discipline points for red card of one player;
's_tm_yellow_points' - deduction of discipline points for yellow card of one team;
's_tm_red_points' - deduction of discipline points forred card of one team;
They should be integer, but for extensiblity, I set them as DECIMAL(10,2)
ALTER TABLE jos_bl_seasons ADD s_pl_yellow_points decimal(10,2) NOT NULL DEFAULT '1.00';
ALTER TABLE jos_bl_seasons ADD s_pl_red_points decimal(10,2) NOT NULL DEFAULT '2.00';
ALTER TABLE jos_bl_seasons ADD s_tm_yellow_points decimal(10,2) NOT NULL DEFAULT '1.00';
ALTER TABLE jos_bl_seasons ADD s_tm_red_points decimal(10,2) NOT NULL DEFAULT '3.00';
Change of PHP:
/administrator/components/com_joomsport/admin.joomsport.class.php
add lines to class 'JTableSeason':
// added by Vincent 12-Nov-2011
var $s_pl_yellow_points = null;
var $s_pl_red_points = null;
var $s_tm_yellow_points = null;
var $s_tm_red_points = null;
/administrator/components/com_joomsport/admin.joomsport.html.php
add lines to function 'bl_editSeason'
<!-- added by Vincent 14-Nov-2011 -->
<tr>
<td width="150">
<?php echo JText::_( '球員黃牌扣除紀律分數' ); ?>
</td>
<td>
<input type="text" maxlength="5" size="10" name="s_pl_yellow_points" value="<?php echo floatval($row->s_pl_yellow_points)?>" />
</td>
</tr>
<tr>
<td width="150">
<?php echo JText::_( '球員紅牌扣除紀律分數' ); ?>
</td>
<td>
<input type="text" maxlength="5" size="10" name="s_pl_red_points" value="<?php echo floatval($row->s_pl_red_points)?>" />
</td>
</tr>
<tr>
<td width="150">
<?php echo JText::_( '球隊黃牌扣除紀律分數' ); ?>
</td>
<td>
<input type="text" maxlength="5" size="10" name="s_tm_yellow_points" value="<?php echo floatval($row->s_tm_yellow_points)?>" />
</td>
</tr>
<tr>
<td width="150">
<?php echo JText::_( '球隊紅牌扣除紀律分數' ); ?>
</td>
<td>
<input type="text" maxlength="5" size="10" name="s_tm_red_points" value="<?php echo floatval($row->s_tm_red_points)?>" />
</td>
</tr>
<!-- end -->
Add one 'results_remark' field to table '#__bl_season_teams'
/administrator/components/com_joomsport/admin.joomsport.html.php:
add lines to function 'bl_editTeam'
<?php
echo '<table class="adminlist">';
echo '<tr>';?>
<th class="title"><?php echo JText::_( 'BLBE_SEASON' ); ?></th>
<th class="title"><?php echo JText::_( '成績龍虎榜備註' ); ?></th>
<th class="title"><?php echo JText::_( 'BLBE_BONUSES' ); ?></th>
<?php echo '</tr>';
for($i=0;$i<count($lists['bonuses']);$i++){
$bonuses = $lists['bonuses'][$i];
echo '<tr><td><input type="hidden" name="sids[]" value="'.$bonuses->season_id.'" />'.$bonuses->name.'</td>';
echo '<td><input style="width:300px" type="text" name="remarks[]" value="'.$bonuses->results_remark.'" />'.'</td>';
echo '<td><input type="text" name="bonuses[]" value="'.floatval($bonuses->bonus_point).'" />'.'</td></tr>';
}
?>
</table>
/administrator/components/com_joomsport/admin.joomsport.php
add lines to function 'BL_TeamSave'
//-------Bonuses points----//
if(isset($_POST['sids']) && count($_POST['sids']))
{
dumpMessage('here');
//dump($_POST['sids'],'sids');
dump($_POST['bonuses'],'bonuses');
dump($_POST['remarks'],'remarks');
for($p=0;$p<count($_POST['sids']);$p++)
{
$query = "UPDATE #__bl_season_teams SET bonus_point = ".($_POST['bonuses'][$p])
.", results_remark = '".($_POST['remarks'][$p]) // modified by Vincent 14th-Nov-2011
."' WHERE season_id=".$_POST['sids'][$p]." AND team_id=".$row->id;
$db->setQuery($query);
$db->query();
}
}
Update PaneltyRecord [VIEW] to utilize the new fields inserted into Season:
/components/com_joomsport/views/paneltyrecord/view.html.php
add two fields into the query:
$query = "SELECT s.s_id as id, CONVERT(s.s_pl_disci_point, UNSIGNED) AS disci_point,"
." CONVERT(s.s_pl_yellow_points, UNSIGNED) AS yellow_disci_point,"
." CONVERT(s.s_pl_red_points, UNSIGNED) AS red_disci_point,"
." CONCAT(t.name,' ',s.s_name) as name "
."FROM #__bl_tournament as t, #__bl_seasons as s "
."WHERE s.published = '1' AND s.t_id = t.id AND s.s_id = "
. $sid;
$db->setQuery($query);
$st_name = $db->loadAssoc();
Use the two values to calculate the discipline points:
$rec->yellow_card = intval($rec->yellow_card);
$rec->red_card = intval($rec->red_card);
$rec->disci = intval($rec->disci);
$rec->overall = intval($st_name["red_disci_point"]) * $rec->red_card
+ intval($st_name["yellow_disci_point"]) * $rec->yellow_card
+ $rec->disci;