Hello All. I have a form called work that has fields/objects called arrival_date, working_date, completed_date, and departed_date.
I would like to add a status field/object (to be shown only on browse) that would show at what stage the work was at (ie Arrived/Working/Completed/Departed).. If the work had a value in arrival_date it would be Arrived, if it also had a value in working_date then the status would be Working and so on... Probably simple, but would be grateful for any pointers/hints.
Welcome to the nuBuilder forums!
Please register and login to view forums and other content only available to registered users.
Please register and login to view forums and other content only available to registered users.
Help or Hints requested..
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Help or Hints requested..
ricklincs,
if you don't want to store the stage of the work in a table field, you can built it creating a temp table in Custom Code > Before Browse (http://wiki.nubuilder.com/tiki-index.ph ... ore_Browse);
An example:
Then add the new status field in browse tab.
Hope this helps,
Max
if you don't want to store the stage of the work in a table field, you can built it creating a temp table in Custom Code > Before Browse (http://wiki.nubuilder.com/tiki-index.ph ... ore_Browse);
An example:
Code: Select all
$sql = "CREATE TABLE #browseTable#";
$sql .= " SELECT * FROM table ... ";
nuRunQuery($sql);
/* Add a column to temp table */
nuRunQuery("ALTER TABLE #browseTable# ADD status VARCHAR(150) NOT NULL ");
$rs = nuRunQuery("SELECT * FROM #browseTable# ");
/* For each record, fill the new column with the right value */
while ($row = db_fetch_object($rs)) {
$ID = $row->table_id;
if ($row->completed_date) {
$status = 'Completed';
}
else if ($row->departed_date) {
$status = 'Departed';
}
else if () {
// to be continued ...
}
/* Update temp table */
$sql = "UPDATE #browseTable# SET status = '".$status."' WHERE table_id = '".$ID."'";
nuRunQuery($sql);
}
Hope this helps,
Max
-
- Posts: 100
- Joined: Mon Jun 15, 2009 10:04 am
Re: Help or Hints requested..
what I would do is add another field for storing the status, and on the after save event in PHP I would update this field based on your criteria, then all you need to do is add that field to the browse, this keeps the sql in browser simple
-
- Posts: 78
- Joined: Mon Aug 01, 2011 5:39 pm