Does anybody knows how to do this?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Does anybody knows how to do this?

Post by wilmira » 2015-07-28 17:46

Hello eveybody. I hope anybody can help me!!

I have a parent table: "Contenedores" and a child table: "vehiencontenedor".

The table "vehiencontenedor" has a look up field "numlote_vc", where numlot_vc is the niumber of the vehicule. I need to filter this lookup field in order to show only the options that goes to the "aduana" that the "contenedor" is going to. This is the custom query for that lookup field:

SELECT `vehiculos`.`id_vehiculo`, IF(CHAR_LENGTH(`vehiculos`.`numlote`) || CHAR_LENGTH(`vehiculos`.`aduana_v`), CONCAT_WS('', `vehiculos`.`numlote`, '-', IF( CHAR_LENGTH(`aduanas1`.`nombre_aduana`), CONCAT_WS('', `aduanas1`.`nombre_aduana`), '')), '') FROM `vehiculos` LEFT JOIN `clientes` as clientes1 ON `clientes1`.`id_cliente`=`vehiculos`.`cliente_v` LEFT JOIN `paises` as paises1 ON `paises1`.`id_pais`=`clientes1`.`pais` LEFT JOIN `aduanas` as aduanas1 ON `aduanas1`.`id_aduana`=`clientes1`.`Aduana` LEFT JOIN `contenedores` as contenedores1 ON `contenedores1`.`aduana_con`=`clientes1`.`Aduana` WHERE `vehiculos`.`estatus` != 'Contenedor' AND `aduanas1`.`id_aduana` = '$aduana_con' ORDER BY 2

If I substitute $aduana_con for the proper aduana number, the query works OK.

Can anybody knows how can I pass that value of the variable to the query.

I attarch 2 images to better explain the issue.

Thanks in advance,

Wilfredo
Attachments
2.gif
2.gif (172.12 KiB) Viewed 3445 times
1.png
1.png (83.28 KiB) Viewed 3445 times

lucicd
Posts: 13
Joined: 2015-09-16 08:48

Re: Does anybody knows how to do this?

Post by lucicd » 2015-09-20 08:23

HI,

have you already received an answer to this questions?

The data model is a bit complex and is hard for me to understand it and give a precise answer. However, it looks like you need to use cascading combo boxes as described in this screencast http://bigprof.com/appgini/screencasts/ ... th-appgini

It might require from you to introduce additional foreign keys, for example, 'id_aduana' into `vehiencontenedor` and `vehiculos` tables (also 'id_contenador' into `vehiencontenedor` table). This will introduce some duplication into your model, but this seems to be the only way with AppGini at the moment.

Upon adding those attributes, you can declare them as lookup fields and create combo boxes that will let you chose 'contenedor' and `aduana`. Afterwards, you can use those as a filter to choose 'vehiculos'.'numlote'.

Post Reply