This topic is locked

remove edit from list page row if date expired

2/25/2008 1:20:00 PM
PHPRunner General questions
M
mrpeeble author

Hi,
Following other posts, i am attempting to remove the edit button on the list page if for example, the date of the MONAssignDate (date type field) is less than today.
In the _list.htm page I have added {if $row.1editable} before the link as so:
{if $allow_edit}

{if $row.1editable}

<td align="center">

<a href="SA_Monthly_Payment_Review_edit.php?{$row.1editlink}" >

Edit</a>
</td>

{/if}

{/if}
and in the _list.php page I have inserted just before the "$rowinfo[]=$row;"
if($data["MONAssignDate"]<now())

$row["1editable"] = false;

else

$row["1editable"] = true;
$rowinfo[]=$row;
The edit link is however, removed for all records. I only want to remove it for the records which are less than today.
Any assistance would be appreciated.

J
Jane 2/26/2008

Hi,
try to use List page: After record processed event on the Events tab for this purpose.

M
mrpeeble author 2/26/2008

Hi,

try to use List page: After record processed event on the Events tab for this purpose.


Thanks Jane, that fixed it !

I had to make one change though, because some of the edit columns are missing the alignment of the table is off.

I realigned the columns by adding four blank spaces in the situation where the edit is missing as so in the _list.htm:
{if $row.1editable}

<TD align=middle><A

href="SA_Monthly_Payment_Review_edit.php?{$row.1editlink}">Edit</A> </TD>

{else}

<TD align=middle><A

href=""> </A> </TD>

{/if}

{/if}
Now everhting is aligned properly and the expired entries no longer have an edit control.

M
mrpeeble author 2/26/2008



Thanks Jane, that fixed it !

I had to make one change though, because some of the edit columns are missing the alignment of the table is off.

I realigned the columns by adding four blank spaces in the situation where the edit is missing as so in the _list.htm:
{if $row.1editable}

<TD align=middle><A

href="SA_Monthly_Payment_Review_edit.php?{$row.1editlink}">Edit</A> </TD>

{else}

<TD align=middle><A

href=""> </A> </TD>

{/if}

{/if}
Now everhting is aligned properly and the expired entries no longer have an edit control.


Ooops ! Spoke too soon. What it really needs is a little change in the _list.php as well to deal with the Now() - 1 day:
$arr = db2time($data["MONAssignDate"]);

// construct time

$t = mktime($arr[3],$arr[4],$arr[5],$arr[1],$arr[2],$arr[0]);

// compare time with current time subtracted by 2 days

if($t < time()-16060*24)

//$value = "<font color=red>".$value."</font>";

$row["1editable"] = false;

else

$row["1editable"] = true;
Now it works ! Thanks again for your assistance.