DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • July 20, 2017, 11:35:07 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: HTML Table Help  (Read 317 times)
0 Members and 1 Guest are viewing this topic.
RaynDarren
Mod God
*****
Offline Offline

Posts: 730


View Profile WWW
« on: June 01, 2017, 05:24:59 PM »

Evening Everyone, Smiley

I'm working on a module to display a time card. I have several problems in completing this module that are frankly driving me crazy.

1. I wish the date laid out as follows: (example) Tuesday, January 04, 2020, in a Sunday - Saturday format across the columns of the table. Currently I'm using

$date = date('l, F d, Y');

This correctly displays the current date, so each day shows as Thursday, June 01, 2017. I can't get the code to display correctly short of setting the whole thing in a calendar setting which I would very much like to avoid as I wish this particular table to be by week and not by month.

2. I wish to have an if statement per column after the first in each row. Example: Hours worked and Task completed are displayed if a time card has been filled out, otherwise the cell would be filled with a red background and the output of "Timecard Needed". I have the latter part of this set already, but I cannot get the if statement to actually work.

3. I wish to have the "Timecard Needed" cell clickable. I can make a hyperlink of just the words with no problem but the cell itself is proving to be very frustrating. I thought of making it a button, but cannot get that code to work correctly either.

4. Once the week is up, I'd like to store the data in a month and once the year is up in a year page by staffer. I haven't the foggiest idea how to do that short of calling everything by date.

Any help would be greatly appreciated, thanks!

~Rayn
Logged

Anharat
Codemeister
****
Offline Offline

Posts: 259



View Profile WWW
« Reply #1 on: June 02, 2017, 05:01:13 PM »

1. Calculate the date of the first day in your current week of the year. In your case the sunday and then create the table and use $date = date('l, F d, Y', $firstDayOfTheWeek + x days);. I think you have to provide your x days in seconds.

2. Assuming you have your hours needed and done in variables you can decide wether you wrap the whole table row in the if or just the table cell or even only apply a style to the table cell.
Code:
if($hoursWorked >= $hoursRequired)
  rawoutput("<tr><td>$dayStuff</td><td></td></tr>");
else
    rawoutput("<tr><td>$dayStuff</td><td style='background-color: red;'>Timecard needed</td></tr>");

// or
rawoutput("<style>
    .doYourDamnWork {
        background: red;
    }
    .doYourDamnWork:after {
        content: 'Timecard Needed';
    }
</style>");
// and in your table
rawoutput("<tr><td>$dayStuff</td><td class='" . ($hoursWorked < $hoursRequired?"doYourDamnWork":"") . "'></td></tr>");

3. When you have an anchor element in your table cell you could use something like this:
Code:
    .doYourDamnWork {
        background: red;
    }
    .doYourDamnWork a {
        display: block;
        width: 100%;
        height: 100%;
    }
    .doYourDamnWork a:after {
        content: 'Timecard Needed';
    }

rawoutput("<tr><td>$dayStuff</td><td class='" . ($hoursWorked < $hoursRequired?"doYourDamnWork":"workDone") . "'><a href='#'></a></td></tr>");

4. A little more description on what you want to achieve would be nice. Do you just want to save some thing like "User X worked Y of Z hours this week/month/year", or do you wish to store every single day with required and worked hours?

I guarantee that the given code examples are 100% un-tested and may contain errors or unwished behavior, due I just scribbled it down here.  Wink

Have fun tinkering.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
18 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search