Showselect and linkselect

12 views
Skip to first unread message

Massimo Arnaudo

unread,
Feb 27, 2018, 6:55:08 AM2/27/18
to simple-g...@googlegroups.com
Hello,
i have a trouble in using the showselect / linkselect statement.

the following piece of code returns the correct value:
...
<field name="test" displayname="TEST" simple_type="textarea" >
    <filter views="all" function="showselect|\n|simple_companies|companyid,companyid|companyname=@delivery@|" /> # WORK
    <filter views="all" function="showselect|\n|simple_companies|companyid,companyid|companyname = @delivery@|" /> # WORK
    <filter views="all" function="showselect|\n|simple_companies|companyid,companyid|companyname like @delivery@|" /> # WORK
    <filter views="all" function="showselect|\n|simple_companies|companyid,companyid|companyname in (@delivery@)|" /> # WORK
</field>
...

the problem occurs when the value present in the field has been inserted through a DBSELECT scheme like this:
...
<field name="company_ext" displayname="Azienda" simple_type="select" simple_size="5" simple_tab="responsible">
        <data function="dbselect|simple_companies|companyid,concat(companyname;' ';insegna)||companyname asc|"/>
        <link value="@index.php?find=asset|simple_companies||companyid=@company_ext@&amp;view=details"/>
</field>
...

in fact, the value present in the SGS database record is of the type | <VALUE> | that is, the value is inserted between two pipes

when looking for a corresponding value, nothing is found, i think this is because the value of @companyid@ is a pattern in the format <VALUE> and the value of @company_ext@ is in the in the format | <VALUE> |

<field name="tasks" displayname="Relations" simple_type="textarea" >
    <onlyin views="details"/>
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext||" /> # WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|@companyid@ in (company_ext)|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext in (@companyid@)|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext=|@companyid@||" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='|@companyid@|'|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext=concat('|';@companyid@;'|')|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext=@companyid@|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext=%@companyid@%|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext like @companyid@|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext like '@companyid@'|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext like %@companyid@%|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext like '%@companyid@%'|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='|ferrerogiuseppe|'|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='ferrerogiuseppe|'|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='|ferrerogiuseppe'|" /> # NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='%ferrerogiuseppe%'|" /> NOT WORK -->
    <!--    <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext='ferrerogiuseppe|'|" /> NOT WORK -->
             <filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|company_ext like '%ferrerogiuseppe%'|" /> # WORK -->
</field>

Obviously the values there are:
...
select subject, company_ext from simple_tasks where company_ext like '%ferrero%'

subjectVisita sul punto vendita: Ferrero Giuseppe - 503748
company_ext|ferrerogiuseppe|


 0.0183 secondi, 0.75 M memory usage

...
select companyname, companyid from simple_companies b where companyid like '%ferrerogiuseppe%'

companynameFerrero Giuseppe - 503748
companyidferrerogiuseppe


 0.0035 secondi, 0.75 M memory usage

So, the last <filter view... returns the value, but how to do with the variable @companyid@?
How to resolve?

Thanks
Massimo

Patrick Pliessnig

unread,
Feb 28, 2018, 2:18:28 AM2/28/18
to Simple Groupware
Hi Massimo

company_ext is of type simple_type="select" simple_size="5".
The content of the db-field is indeed: |Value1|Value2|Value3|Value4|Value5|

So you need to test, whether @companyid@ is a substring of company_ext.
something like this should work:

<filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|locate(@companyid@,company_ext)>0" />

this corresponds to:
select subject, company_ext from simple_tasks where
locate(@companyid@,company_ext)>0

for more info on locate, check this:
https://www.w3resource.com/mysql/string-functions/mysql-locate-function.php

cheers
Patrick

Massimo Arnaudo

unread,
Feb 28, 2018, 6:49:34 AM2/28/18
to simple-g...@googlegroups.com
Hi Patrick,
thanks for your answer!

I have tested the sql string and it produce a result:

select subject, company_ext from simple_tasks where locate('ferrerogiuseppe',company_ext)>0

subjectVisita sul punto vendita: Ferrero Giuseppe - 503748
company_ext|ferrerogiuseppe|


 0.0020 secondi, 0.75 M memory usage

so i wrote the line for SGS:
...
<filter views="all" function="showselect|\n|simple_tasks|subject,company_ext|locate('ferrerogiuseppe',company_ext)>0|" />
...
it works!

now, the right piece of code is:
...
<field name="tasks" displayname="Relazione" simple_type="textarea" nowrap="true" >
    <onlyin views="details"/>
    <filter views="all" function="showselect|\n|simple_tasks|description,subject|locate(@companyid@,company_ext)>0|" />
    <link value="@index.php?folder=^tasks_@username@&amp;view=tutti&amp;filters=company_ext|like|@companyid@" />
</field>
...

Thanks
Massimo

--
You received this message because you are subscribed to the Google Groups "Simple Groupware" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-groupware+unsubscribe@googlegroups.com.
To post to this group, send email to simple-groupware@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-groupware.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages