Dragonfly CMS v9 ⇒ Gamers Modules & Blocks :: Archives ⇒ color code calendar fixtures in mteam :: Archived ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks Gamers Modules & Blocks ⇒ Archives

Archived ⇒ color code calendar fixtures in mteam


Hello,
I have mteam installed & finally working on my site. But I would really like some one to make the calendar display the fixture (matches) according to results.
EG: a fixture that was won by our team would be in green. a loss would be in red & not played yet would be white.

I can't seem to get much help with this module because the porter sales it now & refuses to help any one who got it before he was selling it.

I know it would be fairly easy but I am lost when it comes to creating the code to query the db for a fixtures results, if any results at all, then making it echo the text in a certain color.
Help me please 🙏

T4Dog

Don't ask until you've asked google

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/ Apache 2.0.63/ 4.1.22/ 5.2.6/ 9.1.2.1


a little help here please... Whistling

T4Dog

Don't ask until you've asked google

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/ Apache 2.0.63/ 4.1.22/ 5.2.6/ 9.1.2.1


I'm not the porter, I'm the author, and I don't refuse to help anyone with anything, I just prioritise my limited time. Someone who's paid for something gets my time ahead of someone who hasn't (and the module's only �10, which goes no-where near reflecting the time that went into making it).

Attached is a replacement calendar with colour coded entries. You can change the colours used by editing the define statements at the top of the file, but I've used the ones you requested for now.

define('COLORWIN','green'); define('COLORLOSS','red'); define('COLORNONE','white');

Here's what it looks like on my Clan's site:-

www.raw-dod.com/index....e=calendar

(this file goes in /modules/Team by the way)

Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


My deepest apologies for any comments that may have offended you. I completely understand presidence of paid users. I thought your site said it was 20 dollars, my mistake again.
I did read a post some where that said you dropped this module for mComp though, or I could swear to it.
Thanks for the code.
Thanks for your help & again my apologies for my comments.

T4Dog

Don't ask until you've asked google

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/ Apache 2.0.63/ 4.1.22/ 5.2.6/ 9.1.2.1


I did once intend to drop it, but having started to use it again myself I do now intend to develope it further. Unfortunately I'm knee deep in mComp development at the moment, so it's slow going on pretty much everything else.

Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Problem with pound sign, I think it is ten pounds which is approximately twenty US dollars or a little less. Smile

Diagon Alley - Top Design

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/1.3.37/4.1.21-standard/4.4.4/9.1.1


I can't seem to get it to work.
I dropped that file in "../modules/Team/" but I get a blank page when viewing the calendar.
I tried to place the code in "after the defrine cpg" & where open table is "declared" for the "db sql_numrows" echo <a href""> but it is ignored & all is like it was never changed. Here is my code (ver 1.1.6).

<?php /************************************************************************/ /* Team Management Module for xNuke */ /* ================================ */ /* */ /* Copyright (c) 2005 by Mark Roper */ /* www.markroper.co.uk */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /************************************************************************/ /************************************************************************/ /* calendar.php :: Calendar view of Fixtures */ /************************************************************************/ require_once('includes/mr/functions.php'); global $mrCMS; if ( ($mrCMS=='dragonfly' && !defined('CPG_NUKE')) || ($mrCMS=='cpg-nuke' && !defined('CPG_NUKE')) || ($mrCMS=='php-nuke' && !eregi("modules.php", $_SERVER['PHP_SELF'])) ) { exit; } define('COLORWIN','green'); define('COLORLOSS','red'); define('COLORNONE','white'); $module_name = basename(dirname(__FILE__)); require_once('header.php'); require_once('includes/mr/team.inc'); global $enable_fixture; if ($enable_fixture) { calendarMain(); } else { titleBox('Calendar'); mr_messageBox('The Fixture system has been disabled by the Admin!<br /><br />'._GOBACK.'<br />'); } adminBox(); footerBox(); require('footer.php'); function get_month_list($month=0) { $mnthlist = ''; if (!isset($month) || $month==0) { $today = getdate(); $month = $today['mon']; if ( $month < 10 ) { $month = '0' . $month; } } for ($i=1; $i<=12; $i++) { $s = $i; if ($i < 10) { $s = '0' . $s; } $sel = ($s == $month) ? 'selected' : '' ; $mnthlist .= '<option value="'.$s.'" '.$sel.'>'.$s.'</option>'; } return $mnthlist; } function get_year_list($year=0) { $yearlist = ''; if (!isset($year) || $year==0) { $today = getdate(); $year = $today['year']; } for ($i=$year; $i<($year+2); $i++) { $s = $i; $sel = ($s == $year) ? 'selected' : '' ; $yearlist .= "<option value='$s' $sel>$s</option>"; } return $yearlist; } function calendarMain() { global $prefix, $db, $mrUid; $tid = mr_getParam('tid','num',''); $gid = mr_getParam('gid','num',''); $eid = mr_getParam('eid','num',''); $month = mr_getParam('month','str',''); $year = mr_getParam('year','str',''); $inc = ($tid) ? 'tid='.$tid : 'tid<>0' ; $inc .= ($gid) ? ' AND gid='.$gid : '' ; $inc .= ($eid) ? ' AND eid='.$eid : '' ; if ($month=='' && $year=='') { $today = getdate(); $month = $today['mon']; $year = $today['year']; if ( $month < 10 ) { $month = '0' . $month; } } // previous month and year $pdate = getdate(mktime(0,0,0,(intval($month) - 1),1,intval($year))); $pmnth = $pdate['mon']; if ($pmnth < 10) { $pmnth = '0' . $pmnth; } $pyear = $pdate['year']; // next month and year $ndate = getdate(mktime(0,0,0,(intval($month) + 1),1,intval($year))); $nmnth = $ndate['mon']; if ($nmnth < 10) { $nmnth = '0' . $nmnth; } $nyear = $ndate['year']; // first day of selected month $stday = getdate(mktime(0,0,0,intval($month),1,intval($year))); $start = $stday['wday']; // last day of selected month $enday = getdate(mktime(0,0,0,(intval($month) + 1),0,intval($year))); $end = $enday['mday']; // number of rows to display (based on number of days in selected month) $rows = ceil(($end+$start)/7); // current month and year $cdate = mr_currentDate(); $count = 0; titleBox('Calendar'); OpenTable(); echo ' <table border="0" width="100%" cellpadding="4"> <tr> <td align="center" colspan="3"> <form action="'.getlink('&file=calendar').'" method="post"> <input type="hidden" name="month" value="'.$month.'" /> <input type="hidden" name="year" value="'.$year.'" /> Team <select name="tid">'.get_team_list($tid,1).'</select>     Game <select name="gid">'.get_game_list($gid,1).'</select>     Event <select name="eid">'.get_event_list($eid,1).'</select> <input type="submit" value="Go" /> </form> </td> </tr> <tr> <td align="left">[ <a href="'.getlink('&file=calendar&month='.$pmnth.'&year='.$pyear).'">Previous</a> ]</td> <td align="center"> <form action="'.getlink('&file=calendar').'" method="post"> <input type="hidden" name="tid" value="'.$tid.'" /> <input type="hidden" name="gid" value="'.$gid.'" /> <input type="hidden" name="eid" value="'.$eid.'" /> Month <select name="month">'.get_month_list($month).'</select> Year <select name="year">'.get_year_list($year).'</select> <input type="submit" value="Go" /> </form> </td> <td align="right">[ <a href="'.getlink('&file=calendar&month='.$nmnth.'&year='.$nyear).'">Next</a> ]</td> </tr> </table> '; CloseTable(); OpenTable(); echo ' <table class="forumline" width="100%" cellpadding="3" cellspacing="1" border="0"> <tr> <td class="cat" width="14%" align="center"><span class="cattitle">Sun</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Mon</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Tue</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Wed</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Thu</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Fri</span></td> <td class="cat" width="14%" align="center"><span class="cattitle">Sat</span></td> </tr> '; for ($r=0; $r<$rows; $r++) { echo '<tr>'; for ($c=0; $c<=6; $c++) { if ($c==0 || $c==6) { $coltype='row2'; } else { $coltype='row1'; } echo '<td class="'.$coltype.'" width="14%" height="50" align="left" valign="top">'; if ( ($c>=$start || $r) && $count<$end ) { $count++; if ($count==intval(substr($cdate,8,2)) && $month==substr($cdate,5,2)) { echo '<font color="red"><b>'.$count.'</b></font>'; } else { echo '<b>'.$count.'</b>'; } echo '<br />'; $day = ($count < 10) ? '0' . $count : $count ; $frtime = $year . '-' . $month . '-' . $day . ' 00:00'; $totime = $year . '-' . $month . '-' . $day . ' 99:99'; $intime = " AND datetime>='$frtime' AND datetime<='$totime'"; $where = $inc . $intime; $sql = 'SELECT fixture, tid, oid, datetime FROM '.$prefix.'_team_fixture WHERE '.$where.' ORDER BY datetime'; $res = $db->sql_query($sql); if($db->sql_numrows($res)) { while (list($fixture, $team, $oid, $datetime, $played, $score_us, $score_them) = $db->sql_fetchrow($res)) { $color = COLORNONE; if ($played && $score_us > $score_them) { $color = COLORWIN; } elseif ($played && $score_us <= $score_them) { $color = COLORLOSS; } echo '<a href="'.getlink('&file=result&op=displayDetail&fixture='.$fixture).'">'.substr($datetime,11,5).' - '.get_team_name($team,0).' v '.get_oppo_name($oid,0).'</a><br />'; } } $db->sql_freeresult($res); } else { echo '   '; } echo '</td>'; } echo '</tr>'; } echo '</table>'; CloseTable(); $cadmin = get_permission($mrUid,0); if ($cadmin) { OpenTable(); echo ' <center> <b>Add Fixture</b><br /><br /> <form method="post" action="'.getlink('&file=fixture').'"> <input type="hidden" name="op" value="addFixture" /> <input type="hidden" name="rcode" value="2" /> Team : <select name="tid">'.get_team_list(0).'</select>   Event : <select name="eid">'.get_event_list(0).'</select>   <input type="submit" name="_submit" value="Add Fixture" /> </form> </center> '; CloseTable(); } } ?>

I will edit out the other stuff after resolved to reflect only the fix.

T4Dog

Don't ask until you've asked google

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux/ Apache 2.0.63/ 4.1.22/ 5.2.6/ 9.1.2.1


edit: see below, for some reason I can't post using the [ php ] tags ??

Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):

Last edited by Kendle on Wed Feb 28, 2007 8:01 am; edited 1 time in total


The file I attached is for v1.1.7 (no idea what the difference is between that and v1.1.6, so long ago I wrote this!).

But the key part is the central loop, which should look like this:-

$sql = 'SELECT fixture, tid, oid, datetime, played, score_us, score_them FROM '.$prefix.'_team_fixture WHERE '.$where.' ORDER BY datetime'; $res = $db->sql_query($sql); if($db->sql_numrows($res)) { while (list($fixture, $team, $oid, $datetime, $played, $score_us, $score_them) = $db->sql_fetchrow($res)) { $color = COLORNONE; if ($played && $score_us > $score_them) { $color = COLORWIN; } elseif ($played && $score_us <= $score_them) { $color = COLORLOSS; } echo '<a href="'.getlink('&file=result&op=displayDetail&fixture='.$fixture).'"><font color="'.$color.'">'.substr($datetime,11,5).' - '.get_team_name($team,0).' v '.get_oppo_name($oid,0).'</font></a><br />'; } $db->sql_freeresult($res);

You were nearly there, you'd just not added the additional fields to be read in the SQL statement or surrounded the output with a <font color=""> tag.

Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):

All times are UTC