Setting Colour on font depending on their status!
Setting Colour on font depending on their status!
Hello im not very skilled with php if im honest and was just wondering if anyone would be able to help.
I have designed a database for my work which basically controls logistic jobs....I wont go into too much detail.... what I require is that when I select the Status of each entry ("row") it changes the colour of the rows background or font colour....
So if the job status is listed as "Pending" the font or background of the row will be Red, if the status is set to "Booked" the font or background will be blue and finally if the status is set to "Loaded" itll be listed as green.
The jobs status is selected by a Drop Down Menu obviously....
Please can someone help....Im extremely new too php so any help would be greatful....I am also willing to pay a small amount of money for anyone to help me develop this system further.
I have designed a database for my work which basically controls logistic jobs....I wont go into too much detail.... what I require is that when I select the Status of each entry ("row") it changes the colour of the rows background or font colour....
So if the job status is listed as "Pending" the font or background of the row will be Red, if the status is set to "Booked" the font or background will be blue and finally if the status is set to "Loaded" itll be listed as green.
The jobs status is selected by a Drop Down Menu obviously....
Please can someone help....Im extremely new too php so any help would be greatful....I am also willing to pay a small amount of money for anyone to help me develop this system further.
Re: Setting Colour on font depending on their status!
If I understood what you want, it is almost exactly like this topic:
http://forums.appgini.com/phpbb/viewtopic.php?f=8&t=577
Have a nice day
http://forums.appgini.com/phpbb/viewtopic.php?f=8&t=577
Have a nice day
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper
Re: Setting Colour on font depending on their status!
Ahhh yes I saw this....however I dont know where to put it...perhaps you could explain? Like I said im very new to php....
Re: Setting Colour on font depending on their status!
ok so i have kinda worked out that there is a hook file and that I need to edit the file named VIDA.php which is the customer ill be working with....I have edited the code tow hat I think is correct but I cannot seem to make it work....
The table is called VIDA and the field i want to edit is the "Status" would the fact im using a drop down menu instead of the radio button cause a problem?
Any help would be greatly appreciated thank you.
The table is called VIDA and the field i want to edit is the "Status" would the fact im using a drop down menu instead of the radio button cause a problem?
Any help would be greatly appreciated thank you.
Code: Select all
<?php
// For help on using hooks, please refer to http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks
function VIDA_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'Due' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`VIDA`.`status`'){
$options->QueryFieldsTV['IF(`VIDA`.`Status`=\'Pending\', \'<b style="color: red;">Pending</b>\', IF(`VIDA`.`Status`=\'Loaded\', \'<b style="color: green;">Loaded</b>\', `Vida`.`Status`))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
}
function VIDA_header($contentType, $memberInfo, &$args){
$header='';
switch($contentType){
case 'tableview':
$header='';
break;
case 'detailview':
$header='';
break;
case 'tableview+detailview':
$header='';
break;
case 'print-tableview':
$header='';
break;
case 'print-detailview':
$header='';
break;
case 'filters':
$header='';
break;
}
return $header;
}
function VIDA_footer($contentType, $memberInfo, &$args){
$footer='';
switch($contentType){
case 'tableview':
$footer='';
break;
case 'detailview':
$footer='';
break;
case 'tableview+detailview':
$footer='';
break;
case 'print-tableview':
$footer='';
break;
case 'print-detailview':
$footer='';
break;
case 'filters':
$footer='';
break;
}
return $footer;
}
function VIDA_before_insert(&$data, $memberInfo, &$args){
return TRUE;
}
function VIDA_after_insert($data, $memberInfo, &$args){
return TRUE;
}
function VIDA_before_update(&$data, $memberInfo, &$args){
return TRUE;
}
function VIDA_after_update($data, $memberInfo, &$args){
return TRUE;
}
function VIDA_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){
return TRUE;
}
function VIDA_after_delete($selectedID, $memberInfo, &$args){
}
function VIDA_dv($selectedID, $memberInfo, &$html, &$args){
}
function VIDA_csv($query, $memberInfo, $args){
return $query;
}
Re: Setting Colour on font depending on their status!
ok so I managed to get it working sorry to be a pain haha 
What I would like now is to add another section to the code that if status is "Booked" it changes the colour of the text to blue...everytime I try adding it i get errors...
This is the code im trying but it keeps giving me errors?
This is my last question....how do i get it to work....thank you :S

What I would like now is to add another section to the code that if status is "Booked" it changes the colour of the text to blue...everytime I try adding it i get errors...
Code: Select all
<?php
// For help on using hooks, please refer to http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks
function VIDA_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'Due' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`VIDA`.`Status`'){
$options->QueryFieldsTV['IF(`VIDA`.`Status`=\'Pending\', \'<b style="color: red;">Pending</b>\', IF(`VIDA`.`Status`=\'Booked\', \'<b style="color: blue;">Booked</b>\', IF(`VIDA`.`Status`=\'Loaded\', \'<b style="color: green;">Loaded</b>\', `VIDA`.`Status`))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
}
This is my last question....how do i get it to work....thank you :S
Re: Setting Colour on font depending on their status!
I'm trying to do a similar thing too and not managing 
Anyone got any ideas ?

Anyone got any ideas ?
Re: Setting Colour on font depending on their status!
djb2002 wrote:I'm trying to do a similar thing too and not managing
Anyone got any ideas ?
Hello djb2002....inside your hooks folder there will be your tables php file....my table is called VIDA so the file is called VIDA.php
Inside here is where the code has to go....
The following code has been tried and tested to work ... im just having problems trying to add another bit to the code so when i put the status to Booked it goes Blue...
Code: Select all
function VIDA_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'Due' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`VIDA`.`Status`'){
$options->QueryFieldsTV['IF(`VIDA`.`Status`=\'Pending\', \'<b style="color: red;">Pending</b>\', IF(`VIDA`.`Status`=\'Loaded\', \'<b style="color: green;">Loaded</b>\', `VIDA`.`Status`))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
Re: Setting Colour on font depending on their status!
Code: Select all
<?php
// For help on using hooks, please refer to http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks
function VIDA_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'Due' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`VIDA`.`Status`'){
$options->QueryFieldsTV['IF(`VIDA`.`Status`=\'Pending\', \'<b style="color: red;">Pending</b>\', IF(`VIDA`.`Status`=\'Booked\', \'<b style="color: blue;">Booked</b>\', IF(`VIDA`.`Status`=\'Loaded\', \'<b style="color: green;">Loaded</b>\', `VIDA`.`Status`))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
}
Re: Setting Colour on font depending on their status!
Hello,
I tried to enter this code with the changes to my page.
If I insert only two values ​​(eg YES and NO - red and green) works.
But if I try to add an extra field with a more color (blue) I have this error:
Errore: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as `stato`, `db`.`id` as 'db.id' from `db` limit 0,2000' at line 1
Someone can help me to solve?
I tried to enter this code with the changes to my page.
If I insert only two values ​​(eg YES and NO - red and green) works.
But if I try to add an extra field with a more color (blue) I have this error:
Errore: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as `stato`, `db`.`id` as 'db.id' from `db` limit 0,2000' at line 1
Someone can help me to solve?
Re: Setting Colour on font depending on their status!
Hello,
I solved it.
It was necessary to add one) in more than reported in the sample code.
... Loaded </ b> \ ', `` VIDA. `Status`)))'] = $ caption;
I solved it.
It was necessary to add one) in more than reported in the sample code.
... Loaded </ b> \ ', `` VIDA. `Status`)))'] = $ caption;
Re: Setting Colour on font depending on their status!
Could you include the full section of code for me?
Re: Setting Colour on font depending on their status!
This is 
function db_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'no' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`db`.`stato`'){
$options->QueryFieldsTV['IF(`db`.`stato`=\'si\', \'<b style="color: green;">SI</b>\', IF(`db`.`stato`=\'no\', \'<b style="color: red;">NO</b>\', IF(`db`.`stato`=\'forse\', \'<b style="color: blue;">FORSE</b>\', `db`.`stato`)))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
}

function db_init(&$options, $memberInfo, &$args){
// modify the status field of the table view query to display 'no' invoices in bold red
$oldArray=$options->QueryFieldsTV;
$options->QueryFieldsTV='';
foreach($oldArray as $field => $caption){
if($field=='`db`.`stato`'){
$options->QueryFieldsTV['IF(`db`.`stato`=\'si\', \'<b style="color: green;">SI</b>\', IF(`db`.`stato`=\'no\', \'<b style="color: red;">NO</b>\', IF(`db`.`stato`=\'forse\', \'<b style="color: blue;">FORSE</b>\', `db`.`stato`)))']=$caption;
}else{
$options->QueryFieldsTV[$field]=$caption;
}
}
return TRUE;
}
Re: Setting Colour on font depending on their status!
Thank you i have it working 
