Page 1 of 1

Highlighting Specific Records

Posted: 2018-10-29 15:45
by ronwill
Hi All,

I've been using this code from the AppGini Tutorials in my hooks for an invoice:

// 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=='`commercial`.`status`'){
// $options->QueryFieldsTV['IF(`commercial`.`status`=\'Due\', \'<b style="color: red; background: white">Due</b>\', IF(`commercial`.`status`=\'Paid\', \'<b style="color: green; background: white">Paid</b>\', `commercial`.`status`))']=$caption;
// }
// else{
// $options->QueryFieldsTV[$field]=$caption;
// }
// }

It's been working fine without any issues until I upgraded from PHP5.6 to PHP7.2 as recommended by my service provider. After upgrade I get a stream of error messages:

Warning: Illegal string offset '`commercial`.`id`' in /homepages/5/d106639433/htdocs/web4u0/hooks/commercial.php on line 37
Warning: Illegal string offset 'IF( CHAR_LENGTH(`webdata1`.`user`), CONCAT_WS('', `webdata1`.`user`), '') /* clientusername */' in /homepages/5/d106639433/htdocs/web4u0/hooks/commercial.php on line 37
Warning: Illegal string offset 'IF( CHAR_LENGTH(`webdata1`.`title`) || CHAR_LENGTH(`webdata1`.`company`), CONCAT_WS('', `webdata1`.`title`, ' - ', `webdata1`.`company`), '') /* Client */' in /homepages/5/d106639433/htdocs/web4u0/hooks/commercial.php on line 37


I've stepped back to PHP7.1 same errors, then PHP7.0 and working again


Just thought I'd point this out in case anyone else uses same code from shown above in any of their projects.

Does anyone have a fix for this?

PHP7.0 has PHP community support until 12/2018 - so bit of time yet!!


Cheers, Ron

Re: Highlighting Specific Records

Posted: 2018-10-29 16:11
by pbottcher
Hi,

can you try to initialize your arrary and see.

Change
$options->QueryFieldsTV='';
to
$options->QueryFieldsTV=[];

Re: Highlighting Specific Records

Posted: 2018-10-29 16:36
by ronwill
Hi PBöttcher,

Tried your suggestion with both PHP7.1 & PHP7.2 - WORKING ON BOTH

Thank you very much for instant response, suggest the tutorial example is updated to show the same (who does that?)

Thanks again,
Ron :D