+ Reply to Thread
Page 2 of 3
FirstFirst 1 2 3 LastLast
Results 11 to 20 of 27

Thread: php calendar??

  1. #11
    x10 Elder freecrm is an unknown quantity at this point freecrm's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    611

    Re: php calendar??

    _____

    This has come a long way since the beginning!

    The whole calendar is now php driven with no JS!

    PHP Code:


    <?php require_once('../Connections/freecrm.php');?>

    <?php //include ("../includes/setprefs.php");?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/fullpagetemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <!-- InstanceBeginEditable name="EditRegionhead" -->
    <title>Welcome to Free CRM</title>
    <meta name="Description" content="Free CRM (Customer Relations Management) provides an unlimited fully functional online multi user CRM system." />
    <meta name="Keywords" content="CRM, Customer Relations Management, PRM, Contact Management, Contact Database, Online, Opportunity, Tasks, Calendar, To Do, Reports" />

    <style type="text/css">
    /*all of the table*/
    .caltable 
    {
    font-family: Arial;
    empty-cells: hide;
    border: none;
    }
    /*month and year header*/
    .calheading
    {
    font-size: 14px;
    font-weight: bold;
    border: 1px solid #006666;
    background-color:#99CCCC;
    padding: 2px;
    empty-cells:show;
    }

    /*days of the week cells*/
    .calday
    {
    font-size: 11px;
    font-style: italic;
    border: 1px solid #006666;
    background-color:#ccc;
    padding: 2px;
    empty-cells:show;
    }
    /*date cells that are not today*/
    .caldate 
    {
    font-size: 11px;
    border: 1px solid #006666;
    background-color:#E3E9F1;
    padding: 2px;
    empty-cells:show;
    vertical-align: text-top;
    }
    /*date cells that are today*/
    .caldatetoday {
    font-size: 11px;
    font-weight: bold;
    color:#FF3300;
    border: 3px solid #006666;
    background-color:#FCEBC2;
    padding: 2px;
    empty-cells:show;
    }
    </style>

    <?php mysql_select_db($database_freecrm$freecrm);?>

    <?php
    class Calendar

        function 
    generate_calendar($year$month$day_func NULL$day_heading_length 3)
        {
            
    $first_of_month mktime (0,0,0$month1$year);//first of the month
            
    static $day_headings = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
            
    $maxdays   date('t'$first_of_month); //number of days in the month
            
    $date_info getdate($first_of_month);   //get info about the first day of the month
            
    $month $date_info['mon']; //get name of month
            
    $year $date_info['year']; // get year
            
    $calendar "<br /><table width='100%' class='caltable'>"//create table
            
    $calendar .= "<tr><td colspan='7' class='calheading'>$date_info[month] $year</td></tr>"//create header with Month & Year
             //create days of week header
            
    $calendar .= "
                <tr>
                    <td class='calday'>Sun</td>
                    <td class='calday'>Mon</td>
                    <td class='calday'>Tue</td>
                    <td class='calday'>Wed</td>
                    <td class='calday'>Thu</td>
                    <td class='calday'>Fri</td>
                    <td class='calday'>Sat</td>
                 </tr>
            "

            
    //start of main repeating date cells
            
    $calendar .= "<tr>";
            
    $class  "";
            
    $weekday $date_info['wday']; //weekday (zero based) of the first day of the month
            
    $day 1//starting day of the month
            //take care of the first "empty" days of the month
            
    if($weekday 0)
            {
                
    $calendar .= "<td colspan='$weekday'> </td>";
            } 
    //print the days of the month
            
    while ($day <= $maxdays)
            {
                if(
    $weekday == 7)
                { 
    //start a new week
                    
    $calendar .= "</tr><tr>";
                    
    $weekday 0;
                }
                
    $linkDate =  mktime (0,0,0$month$day$year);
                if(((
    $day<10 AND "0$day"==date('d')) OR ($day>=10 AND "$day"==date('d'))) AND (($month<10 AND "0$month"==date('m')) OR ($month>=10 AND "$month"==date('m'))) AND $year==date('Y'))
                {
                    
    $class="caldatetoday";
                } 
                else
                {
                    
    $d date('m/d/Y'$linkDate);
                    
    $class "caldate";
                } 
                
    //output date    
                
    $link "dates.php?date=$linkDate";
                
    $query_RS_Events "SELECT EVID, EVGROUPCODE, EVCOMPLETED, EVSTART, EVDURATION, EVMANAGER, EVTITLE FROM EVENTS WHERE EVSTART LIKE '$linkDate' ";
                
    $RS_Events mysql_query($query_RS_Events) or die(mysql_error());
                
    $totalRows_RS_Events mysql_num_rows($RS_Events);
                
    $calendar .= "<td class='$class'>
                "
    .$day."<br>";
                do
                {
                    
    $calendar .= $linkDate."
                    <a href='../crmevents/updateevent.php?evid="
    .$row_RS_Events['EVID']."' target='_blank'>".$row_RS_Events['EVTITLE']."</a><br/>
                    "
    ;
                }
                   while (
    $row_RS_Events mysql_fetch_assoc($RS_Events));
                   
    mysql_free_result($RS_Events);
                
    $calendar .= "
                  </td>
                  "
    ;  
                
    //finish output
                //increase day and weekday by 1          
                
    $day++;            
                
    $weekday++;        
            }        
            if(
    $weekday != 7)
            {            
                
    $calendar .= "<td colspan='" . ($weekday) . "'> </td>";        
            }        
            return 
    $calendar "</tr></table>";   
        }
    }
    ?>

    <?php
    //define month and year to view
    //if post value is empty, fill with now
    if (!isset($_POST['selectyear']))
    {
         
    $yeartoview date('Y');
    }
    else 
    //or filled with value from form
    {
        
    $yeartoview $_POST['selectyear'];
    }

    if (!isset(
    $_POST['selectmonth']))
    {
         
    $monthtoview date('m');
    }
    else
    {
        
    $monthtoview $_POST['selectmonth'];
    }
    ?>


    <!-- InstanceEndEditable -->
    <link href="../css/page.css" rel="stylesheet" type="text/css" />
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

    </head>
    <?php include ("../includes/googleanalytics.php");?>

    <body class="oneColFixCtr">

    <div id="container">
    <td>
    <?php include ("../includes/header.php");?>
    </td>
     <div id="mainContent">
     <!-- InstanceBeginEditable name="EditRegionmaincontent" -->
       <h1>Calendar</h1>
       
       <form name="form1" method="post" action="">
        Month:
        <select name="selectmonth" id="selectmonth">
        <option value="<?php echo $monthtoview;?>" selected><?php echo $monthtoview;?></option>
        <option value="01">01</option>
        <option value="02">02</option>
        <option value="03">03</option>
        <option value="04">04</option>
        <option value="05">05</option>
        <option value="06">06</option>
        <option value="07">07</option>
        <option value="08">08</option>
        <option value="09">09</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        </select>
        Year: 
        <select name="selectyear" id="selectyear">
        <option value="<?php echo $yeartoview;?>" selected><?php echo $yeartoview;?></option>
        <option value="2001">2001</option>
        <option value="2002">2002</option>
        <option value="2003">2003</option>
        <option value="2004">2004</option>
        <option value="2005">2005</option>
        <option value="2006">2006</option>
        <option value="2007">2007</option>
        <option value="2008">2008</option>
        <option value="2009">2009</option>
        <option value="2010">2010</option>
        <option value="2011">2011</option>
        <option value="2012">2012</option>
        <option value="2013">2013</option>
        <option value="2014">2014</option>
        <option value="2015">2015</option>
        <option value="2016">2016</option>
        <option value="2017">2017</option>
        <option value="2018">2018</option>
        <option value="2019">2019</option>
        <option value="2020">2020</option>
        </select>
        User:
        
        <label>
        <select name="selectuser2" id="selectuser2">
          </select>
        </label>
        <input type="submit" name="Submit" value="Submit">
        </form>

       
           <p>
        <?php 
        $cal_m 
    = new Calendar;
        echo 
    $cal_m -> generate_calendar($yeartoview$monthtoview$day_func NULL$day_heading_length 3);
        
    ?>
        </p>
            
       <!-- InstanceEndEditable -->
       <!-- end #mainContent -->
    </div>
    <td>
    <?php include("../includes/footer.php");?>
    </td>
    <!-- end #container -->
    </div>
    </body>
    <!-- InstanceEnd --></html>
    This is the whole page (excluding includes) and the page works well - ish (link to page above)

    The only problem I have is the the $linkDate variable created on each do..while is an epoch number based just on year month and date which generates a number with a double zero at the end.

    I need to reference this variable in the sql but the values in the db are complete timestamps, including time.

    As a result, the two values do not match exactly and I get no recordset returned.

    How do I shorten or amend either value so I can get a like comparison?

    i.e. WHERE EVSTART(full timestamp) LIKE $linkDate (partial timestamp)

    When this is cracked, I think I'm pretty much done....
    Rich. If you found this post useful, I would appreciate the reputation. It costs nothing but makes my day!

    My Site: www.freecrm.x10hosting.com:

  2. #12
    x10 Elder mattura is an unknown quantity at this point mattura's Avatar
    Join Date
    Oct 2007
    Posts
    542

    Re: php calendar??

    That's a nice start, I'm liking the style.
    You could have used thead (for the Sun,Mon...) and tbody for the cells, styling them appropriately, but not essential.

    It seems to me you have two options with javascript. But before that, its would be a great idea to code it all in php (same effect, but with page refreshing). You have made a great start.

    When it's working in php, you can add the javascript, your options being:
    Use AJAX, which basically can retrieve data by means of another php file without refreshing the page, placing it in some container (eg div).
    OR use javascript only, downloading ALL your calendar events with the page load, storing them in arrays, and displaying only what is needed.
    The latter solution will take a long time to download if your calendar database is large., but be quicker when loaded.
    Let me know.

    yeah c++ can be a pain, especially when someone else's code that you have to figure out (what were they thinking with a function name like "PositionLeftFromToOfFromBottomFrom()"?!! I kid you not...), but I have to work with it now!
    ----
    Please donate credits if you had a really good reply from me! Rep is also appreciated. Thanks
    matt.elementfx.com

  3. #13
    x10 Elder freecrm is an unknown quantity at this point freecrm's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    611

    Re: php calendar??

    Quote Originally Posted by mattura View Post
    That's a nice start, I'm liking the style.
    You could have used thead (for the Sun,Mon...) and tbody for the cells, styling them appropriately, but not essential.

    It seems to me you have two options with javascript. But before that, its would be a great idea to code it all in php (same effect, but with page refreshing). You have made a great start.

    When it's working in php, you can add the javascript, your options being:
    Use AJAX, which basically can retrieve data by means of another php file without refreshing the page, placing it in some container (eg div).
    OR use javascript only, downloading ALL your calendar events with the page load, storing them in arrays, and displaying only what is needed.
    The latter solution will take a long time to download if your calendar database is large., but be quicker when loaded.
    Let me know.

    yeah c++ can be a pain, especially when someone else's code that you have to figure out (what were they thinking with a function name like "PositionLeftFromToOfFromBottomFrom()"?!! I kid you not...), but I have to work with it now!
    I'm not sure I even need any JS now.

    The only thing I need to sort is the comparison with these two variables.

    When thats done, the recordset within the do..while will return the right values and echo the titles and links dynamically within the box with the right links.

    Almost there - so veeeery close....
    Rich. If you found this post useful, I would appreciate the reputation. It costs nothing but makes my day!

    My Site: www.freecrm.x10hosting.com:

  4. #14
    x10 Elder mattura is an unknown quantity at this point mattura's Avatar
    Join Date
    Oct 2007
    Posts
    542

    Re: php calendar??

    well took me a while to figure out what you meant!

    You can get the bounds $linkdate1=day x @ 00:00:00 and $linkdate2=day x @23:59:59
    and have:
    WHERE EVSTART>$linkdate1 AND EVSTART<$linkdate2

    There are problems with using timestamps in calendars - eg that they are only in the range 1970-2037. It might be better to store a date field, and a time field separately (then you don't need to SELECT the time when not necessary, and have no timestamp issues)
    Edit:
    Good luck mate, I'm off to bed (early start and all), I'll check back tomo
    Last edited by mattura; 10-09-2008 at 05:05 PM. Reason: Automerged Doublepost
    ----
    Please donate credits if you had a really good reply from me! Rep is also appreciated. Thanks
    matt.elementfx.com

  5. #15
    x10 Elder freecrm is an unknown quantity at this point freecrm's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    611

    Re: php calendar??

    Quote Originally Posted by mattura View Post

    You can get the bounds $linkdate1=day x @ 00:00:00 and $linkdate2=day x @23:59:59
    and have:
    WHERE EVSTART>$linkdate1 AND EVSTART<$linkdate2
    Matt - thanks but... not working yet.

    I'll try again tomorrow - getting more problems with additional functions...
    Rich. If you found this post useful, I would appreciate the reputation. It costs nothing but makes my day!

    My Site: www.freecrm.x10hosting.com:

  6. #16
    x10 Elder mattura is an unknown quantity at this point mattura's Avatar
    Join Date
    Oct 2007
    Posts
    542

    Re: php calendar??

    do you have something like this:
    PHP Code:
     $linkDate =  mktime (0,0,0$month$day$year); 
     
    $linkDateEnd mktime(23,59,59$month$day$year);
     ...
     
    $query_RS_Events "SELECT EVID, EVGROUPCODE, EVCOMPLETED, EVSTART, EVDURATION, EVMANAGER, EVTITLE FROM EVENTS WHERE EVSTART > '$linkDate' AND EVSTART < '$linkDateEnd' "
    ?
    ----
    Please donate credits if you had a really good reply from me! Rep is also appreciated. Thanks
    matt.elementfx.com

  7. #17
    x10 Elder freecrm is an unknown quantity at this point freecrm's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    611

    Re: php calendar??

    LOL - should have thought of that!!!

    Works a treat and finally, all the values are now coming through correctly and it looks awesome.

    This is now a very powerful script and one that is not easy to achieve without Javascript!

    I only have one problem now.

    At the top of the script is a recordset created of users (RS_Users). I have a form with 3 fields (drop-down) which calls this recordset and it isn't calling results from the recordset!

    I have butchered this script so many times now, there's probably a simple error but I can't find it!

    Ideally, I would have alist drop-down with multiple selections but I haven't got a clue how to do this.

    Matt I'm giving you 100 cres for the fact that you've stuck with it!

    Current Code attached
    Attached Files
    Rich. If you found this post useful, I would appreciate the reputation. It costs nothing but makes my day!

    My Site: www.freecrm.x10hosting.com:

  8. #18
    x10 Elder freecrm is an unknown quantity at this point freecrm's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    611

    Re: php calendar??

    ______
    Has anyone got any ideas on this?
    Rich. If you found this post useful, I would appreciate the reputation. It costs nothing but makes my day!

    My Site: www.freecrm.x10hosting.com:

  9. #19
    x10Hosting Member exemption is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    66

    Re: php calendar??

    I could create something like this for you for a measly 600 or 900 credits..
    I will message you once I have a small sample finished...


    I program PHP..so if you need help lemme know!


  10. #20
    x10 Elder mattura is an unknown quantity at this point mattura's Avatar
    Join Date
    Oct 2007
    Posts
    542

    Re: php calendar??

    Hey thanks for the credits, glad I was able to help.
    I may be able to take a look at it tomorrow, as you know I don't have a lot of time these days!

    exemption - he's already done pretty much all of the work!
    ----
    Please donate credits if you had a really good reply from me! Rep is also appreciated. Thanks
    matt.elementfx.com

+ Reply to Thread
Page 2 of 3
FirstFirst 1 2 3 LastLast

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. Important PHP Information
    By Bryon in forum News and Announcements
    Replies: 0
    Last Post: 11-21-2007, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts