This topic is locked
[SOLVED]

 time column using drop down format?

10/14/2008 8:55:50 PM
PHPRunner General questions
A
amuro author

Hi,
I have 2 time type columns that recode begining and ending.
Could they be designed like calendar template, drop down list?
Thanks

J
Jane 10/15/2008

Hi,
time dropdown in the Calendar is created using custom code on the Visual Editor tab.

Here is just a sample:

$t=date("G",strtotime(now()));

$m=date("i",strtotime(now()));
global $conn;

global $dal;

$tperiod = 60;
for ($i=1;$i<=60/$tperiod;$i++)

{

if ($m<=$tperiod$i)

{

$m=$tperiod
$i;

$i=100;

}

}
if ($m>=60)

{

$t++;

$m=0;

}
if ($t>23)

$t=0;
$tm = array(0,0,0,$t,$m,0);

$t=format_time($tm);
$str = "";

$str.= "<select name=\"value_TimeField\" onchange=\"if(document.editform.value_EndTime.value==''){t=document.editform.value_TimeField.selectedIndex+2;if(t>document.editform.value_TimeField.length-1)t-=2;document.editform.value_EndTime.options[t].selected=true;return false;}\">";

$str.= "<option value=\"\">Please select</option>";

for ($i=0; $i<24;$i++)

{

for ($j=1;$j<=60/$tperiod;$j++)

{

$s1="";

$p=($j-1)*$tperiod;

$tm1 = array(0,0,0,$i,$p,0);

if ($t==format_time($tm1))

$s1=" selected";

$time1 = sprintf("%02d:%02d:%02d",$i,$p,0);

$str.= "<option value=\"".$time1."\"".$s1.">".format_time($tm1)."</option>";

}

}

$str.= "</select>";

echo $str;

A
amuro author 10/16/2008

time dropdown in the Calendar is created using custom code on the Visual Editor tab.


It doesn't work.
The column is time type in the db.
I put your code in "View as setting" custom block

and change "value_TimeField", "value_EndTime" into my own fields name.

Is it right?
Thanks.

J
Jane 10/20/2008

This code should be in the custom event (Insert PHP code snippet option on the Visual Editor tab).

A
amuro author 11/26/2008

This code should be in the custom event (Insert PHP code snippet option on the Visual Editor tab).


Hi, Jane
It works fine at build437, but doesn't at build587.

Data doesn't insert into the time column.
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35469&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 11/26/2008

Hi,
this code works fine on my test box.

Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

A
amuro author 11/27/2008

Hi, Jane
The project has been uploaded to the site.
I think the error is that when I replaced original time column into php code snippet, the time column is checked off at add column list of Choose fields to appear on each page.
So, I can't see the column on the browser.
How can I do for it?
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35494&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 11/27/2008

Hi,
I see what you're saying.

You can do the following:

  1. add new row for your code snippet.
  2. hide time column in the Add page: Before display event on theEvents tab:
    $xt->assign("TimeField_fieldblock",false);

A
amuro author 11/28/2008

Hi, Jane
It works well, thank you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35554&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

A
amuro author 12/9/2008

Hi,
Could those time fields only have period of time during our working time?
For instance, our working time is during AM8:30~PM5:30,
the time drop down list only show up AM8:30-PM5:30
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35811&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 12/9/2008

Hi,
edit highlighted code for this purpose:

...

for ($i=8; $i<18;$i++)

{

for ($j=1;$j<=60/$tperiod;$j++)

{

$s1="";

$p=($j-1)*$tperiod;

$tm1 = array(0,0,0,$i,$p,0);

if ($t==format_time($tm1))

$s1=" selected";

$time1 = sprintf("%02d:%02d:%02d",$i,$p,0);

$str.= "<option value=\"".$time1."\"".$s1.">".format_time($tm1)."</option>";

}

}

...

A
amuro author 12/10/2008

Hi, Jane
Thank you, it works well.
Another problem is could time fields be operated for drop down list format on edit page?
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=35833&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 12/10/2008

Hi,
use the same mothod for edit page.