Jump to content

Hourly Schedule


sniperscope

Recommended Posts

Hello

I am trying to figure out something of my project for 4 days but seems i have no luck. And lastly i decided post a topic here and hopefuly to get help.

 

What am i trying to do is hourly schedule, please let me explain.

 

Let's say we have a staff who call him Mr. A

And mr. A works today from 19:00 to 23:00 also mr. A has schedule such as following

19:00 to 19:20 free

19:20 to 20:40 working at Station A

20:40 to 20:50 free

20:50 to 22:10 working at Station B

22:10 to 23:00 working at Station C

 

My sample data is:

 

CREATE TABLE IF NOT EXISTS `reserv` (
`r_id` int(6) unsigned NOT NULL AUTO_INCREMENT,
`staff_id` int(4) NULL,
`r_date` int(10) NULL,
`start_to_work` varchar(5) NULL,
`start_to_work_len` int(2) NULL,
PRIMARY KEY (`r_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

INSERT INTO `reserv` (`r_id`, `staff_id`, `r_date`, `start_to_work`, `start_to_work_len`) VALUES
(1, 1, 1354460400, '19:20', ;

in here table says: Staff who has id #1 going to work 19:20 to 8 times 10 minutes(which means 80 minutes) at 2012/12/3

 

 

On my html is:

<tr>
<td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>
<td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>
<td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>
<td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>
<td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>
</tr>

<!-- Every single hour has 6 <td></td> which reference to 10 minutes -->

<tr><th colspan="6">19:00</th><th colspan="6">20:00</th><th colspan="6">21:00</th><th colspan="6">22:00</th></tr>


<tr>
<td colspan="2" style="background-color:blue;">Free<br />19:00<br />~19:20</td> (colspan is 2 because he has 20 minutes free time)
<td colspan="8" style="background-color:red;">working<br />19:20<br />~20:40</td>(colspan is 8 because he has 80 minutes working time)
<td colspan="1" style="background-color:blue;">Free<br />20:40<br />~20:50</td> (colspan is 1 because he has 10 minutes free time)
<td colspan="8" style="background-color:red;">working<br />20:50<br />~22:10</td>(colspan is 8 because he has 80 minutes working time)
<td colspan="5" style="background-color:red;">working<br />22:10<br />~23:00</td>(colspan is 5 because he has 50 minutes working time)
</tr>

 

So far, i can make table with a blank <td> by;

 

function BlankTd()
{
$blank_td = '<tr>';
for($i=$this->work_from; $i<$this->work_to; $i++)
 $blank_td .= '
 <td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td><td class="scale"> </td>';

$blank_td .= '</tr>';
return $blank_td;
}

 

and working hours by;

 

function Working()
{
$working_td = '<tr>';
for($i=$this->work_from; $i<$this->work_to; $i++)
{
$working_td .= '
<th colspan="6">' .$i. ':00</th>';
$this->works[] = $i;
}
$working_td .= '</tr>';
return $working_td;
}

 

 

And where did i stopped, i cannot make any further.

 

I really appreciate for any help or advice.

Edited by sniperscope
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.