Show_preview

48 views
Skip to first unread message

MassimoA

unread,
Mar 14, 2016, 2:37:03 PM3/14/16
to Simple Groupware
Hello,
i have activated the show_preview attributes to see a photo in the companies shema.
I can see the link of the photo too, but i would not: is it possible to remove only the photo's link? How?

Best regards
Massimo

Patrick Pliessnig

unread,
Mar 15, 2016, 3:54:21 AM3/15/16
to Simple Groupware
Hi Massimo

Maybe you should attach the schema you use for the companies. There seems to be no photo data field in the standard schema
Another possibility is to learn from other standard schemas. For example from gallery schema.

Patrick

Massimo Arnaudo

unread,
Mar 16, 2016, 5:49:00 AM3/16/16
to simple-g...@googlegroups.com
Hi Patrick,

my custom schema to have a image field is:
...
<field name="image" displayname="Immagine" simple_type="files" simple_file_size="5M" simple_size="10">
    <validate function="fileupload|jpg,jpeg,gif,png,tif"/>
</field>
...

and i have an additional file with a list of the view and the characteristics of each called companies_view.xml
...
<view name="visite" displayname="Da visitare" where="(insegna='?' or gruppo='?' or canaledistributivo='sconosciuto' or valutazione_rapporto='indipendente' or valutazione_rapporto='sconosciuto' or valutazione_rapporto='?')" template="display" showonly="street|companyname|zipcode|city|state|insegna|gruppo|canaledistributivo|valutazione_rapporto|category|phone|chiusura|orario_apertura|image" orderby="zipcode" show_preview="true" image_width="50" limit="100" >
</view>
...

Like you have suggested i went to see the gallery schema, and the only difference i noticed is the template name: is "free": i have changed in my custom companies_view.xml but it is not changed anything; in the gallery folder appear only the name of the image's filename instead in the company appear the path too.

So i have made a new test, i created a new view:
...
<view name="test" displayname="Test" template="free" show_preview="true" >
</view>
...

Also in this view shows the full path

I attach the same foto, the first in the new companies test view and the second in the galley: both have been uploaded from my tablet/smartphone.

Any suggestions?

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-groupwa...@googlegroups.com.
To post to this group, send email to simple-g...@googlegroups.com.
Visit this group at https://groups.google.com/group/simple-groupware.
For more options, visit https://groups.google.com/d/optout.

Patrick Pliessnig

unread,
Mar 17, 2016, 4:22:08 AM3/17/16
to Simple Groupware
Massimo

I have this problem too. I believe that it is a program error in the data-passing between the automatically generated SQL statement of the view and the simple_type 'files'.

My normal workaround for this problem is to configure my own SQL statement. Instead of using the 'image' column directly in the SQL statement, I load it in a subquery and use the result of the subquery as 'subquery_image' field.

Let's say the key to identify a company in your schema is the field 'id', then in your view 'visite' something like the statement below should do the job:

default_sql = "select t1.*, (select t2.image from @table@ t2 where locate(t1.id, t2.id)>0 ) as subquery_image from @table@ t1"

I am not sure if you need to include the where="" clause directly in the statement or not.

In the view schema then you simply use:

<field name="subquery_image" displayname="Immagine" simple_type="files" </field>

and also adapt the showonly="" clause.
 
That's not really efficient, but I never saw performance problems.
I hope this helps

Patrick

Massimo Arnaudo

unread,
Mar 17, 2016, 2:42:49 PM3/17/16
to simple-g...@googlegroups.com
Hello Patrick,
thanks for your answer.

I inserted this block, according with you suggested in the file companies_view.xml:

<view name="test" displayname="Test" template="display" default_sql="select t1.*, (select t2.image from @table@ t2 where locate(t1.id, t2.id)>0 ) as subquery_image from @table@ t1" show_preview="true" showonly="companyname|image|subquery_image" >
</view>

<field name="subquery_image" displayname="Immagine" simple_type="files">
</field>

After that i flagged an asset with the photo and clicked on the tab TEST receiving this error message:

Php Warning: 17/03/16 19:32:27 pm mysqli_query(): (21000/1242): Subquery returns more than 1 row /bin/core/functions.php 2157
Php Warning: 17/03/16 19:32:27 pm mysqli_query(): (21000/1242): Subquery returns more than 1 row /bin/core/functions.php 2157
I tried modifying the select in:
default_sql="select t1.*, (select t2.image from @table@ t2 ) as subquery_image from @table@ t1"

but the error was the same: no assets was displayed.

Where is my fault?

Thanks
Massimo

Patrick Pliessnig

unread,
Mar 18, 2016, 2:39:43 AM3/18/16
to Simple Groupware
your subquery is supposed to return only 1 row per execution, but seems to return more than 1 row. this is a hint that the field 'id' is not a key to identify a company.

to be sure 'id' is a key, there should be something like:
<field name="id" ... is_unique="true" ...>  </field>
or probably better
<field name="id" ... is_unique_with_trash="true" ...>  </field>

in case 'id' is not a key but some combination of fields, then you should adjust the where clause of the subquery accordingly.

my proposition:
  1. Just to try out, add a limit 1 clause to the subquery like this:
    default_sql="select t1.*, (select t2.image from @table@ t2 where locate(t1.id, t2.id)>0 limit 1 ) as subquery_image from @table@ t1"

  2. if the previous step yields no error, start thinking about how to uniquely identify a company and adjust the where clause in the subquery accordingly
  3. if there is still an error, come back with the new error

Massimo Arnaudo

unread,
Mar 21, 2016, 9:14:45 AM3/21/16
to simple-g...@googlegroups.com
Hi Patrick,
you are right, for the company form have changed long ago the unique field, but could not remember:
...
<field name="companyid" displayname="id azienda" simple_type="text" is_unique="true" simple_default_function="myclass::fillcompany|myclass::companyid">
    <validate function="regexp|/^[a-z0-9-_@\.]{3,128}$/i|ID non puo essere nullo, minimo 3 caratteri, massimo 128 contenenti [a-z0-9_-@.]."/>
        <store function="myclass::companyid"/>
        <notin views="display" />
</field>
...

i have adjusted the where clause in: 'where locate(t1.companyid, t2.companyid)>0 limit 1', selected a record and clicked on the tab TEST, but no records and no errors are displayed.


instead if i click on the tab 'Tutti' (ALL) are displayed all the assets with an error message:
Php Warning: 21/03/16 14:01:59 pm Illegal string offset 'data' /var/www/html/bin/core/classes/modify.php 230


but the '1 - Spider Man Mandant' asset is dispalyed:


Thank for your help
Massimo


Patrick Pliessnig

unread,
Mar 22, 2016, 2:37:59 AM3/22/16
to Simple Groupware
Hm,

That error points to a problem with the background color settings.
I suggest you try the following:
  1. take away now the 'Limit 1' clause as you don't need it, if companyid is the key
  2. if that doesn't help, check if in the 'imagine_test' field the simple_size is set to 1
  3. if that doesnt't help, check the bgcolor settings of the schema
  4. if that doesn't help, send me over you schema

Massimo Arnaudo

unread,
Mar 23, 2016, 1:44:07 PM3/23/16
to simple-g...@googlegroups.com
Hi Patrick,
this is the report:

Point 1)
i get the error message, like if the the key was wrong:
Php Warning: 23/03/16 18:06:12 pm mysqli_query(): (21000/1242): Subquery returns more than 1 row /var/www/html/bin/core/functions.php 2157
Php Warning: 23/03/16 18:06:12 pm mysqli_query(): (21000/1242): Subquery returns more than 1 row /var/www/html/bin/core/functions.php 2157
so i execute the sql command 'describe simple_companies' and appeared only one primary key: id
then i execute 'select id, companyid, companyname from simple_companies where companyid is null;' and nothing appeared.

Point 2)
Now my block of code is:
<field name="subquery_image" displayname="ImmagineTest" simple_type="files" simple_size="1">
</field>

Point 3)
i have not any bg_color definition

Point 4)
this is my companies_view.xml:

<?xml version="1.0" encoding="utf-8"?>

<table>

<view name="display" displayname="Visualizza" showonly="street|companyname|zipcode|city|state|insegna|gruppo|canaledistributivo|valutazione_rapporto|category|phone" orderby="zipcode" >
</view>

<view name="details" template_mode="small" displayname="Dettagli" showinsingleview="true" show_preview="true">
</view>

<view name="display2" displayname="Clienti" template="display" where="(valutazione_rapporto='cliente')" showonly="companyname|street|zipcode|city|state|insegna|merchandiser|chiusura|orario_apertura|percorso" orderby="zipcode" >
</view>

<view name="riepilogo" displayname="Riepilogo" template="display" >
</view>

<!-- purtroppo inserendo and|or not|NOT category='Non interessante' porta al risultato aspettato... -->
<view name="visite" displayname="Da visitare" where="(insegna='?' or gruppo='?' or canaledistributivo='sconosciuto' or valutazione_rapporto='indipendente' or valutazione_rapporto='sconosciuto' or valutazione_rapporto='?')" template="display" showonly="street|companyname|zipcode|city|state|insegna|gruppo|canaledistributivo|valutazione_rapporto|category|phone|chiusura|orario_apertura" orderby="zipcode" show_preview="true" image_width="50" limit="100" >
</view>

<view name="mail" displayname="@" template="display" showonly="companyname|insegna|gruppo|canaledistributivo|valutazione_rapporto|email|last_name|state">
</view>

<view name="homepage" displayname="Home Page" template="display" showonly="companyname|insegna|gruppo|canaleditributivo|street|zipcode|city|state|phone|homepage" orderby="zipcode" >
</view>

<view name="map" displayname="Mappa" template="map" showonly="companyname|street|zipcode|city|state|valutazione_rapporto" >
</view>

<view name="test" displayname="Test" template="display" default_sql = "select t1.*, (select t2.image from @table@ t2 where locate(t1.id, t2.id)>0 ) as subquery_image from @table@ t1" showonly="companyname|image|subquery_image" show_preview="true" >
</view>
<field name="subquery_image" displayname="ImmagineTest" simple_type="files" simple_size="1">
</field>

</table>

You have need of something else?

Massimo
                                                                                                                                     1,1           Cim


Patrick Pliessnig

unread,
Mar 24, 2016, 5:52:05 AM3/24/16
to Simple Groupware
Hi Massimo

This companies_view.xml is only a differential schema, not a full schema.
I need the basic module schema of the folder 6301 too to see the whole schema.

and can you also give me the result of the command:
describe simple_companies;

thank you

Massimo Arnaudo

unread,
Mar 24, 2016, 6:49:56 AM3/24/16
to simple-g...@googlegroups.com
and here the schema:

mysql> describe simple_companies;
+----------------------+---------------+------+-----+---------+-------+
| Field                | Type          | Null | Key | Default | Extra |
+----------------------+---------------+------+-----+---------+-------+
| id                   | decimal(15,0) | NO   | PRI | 0       |       |
| companyname          | varchar(255)  | YES  |     | NULL    |       |
| numberofemps         | varchar(255)  | YES  |     | NULL    |       |
| industry             | varchar(255)  | YES  |     | NULL    |       |
| street               | varchar(255)  | YES  |     | NULL    |       |
| zipcode              | varchar(255)  | YES  |     | NULL    |       |
| city                 | varchar(255)  | YES  |     | NULL    |       |
| state                | varchar(255)  | YES  |     | NULL    |       |
| country              | varchar(255)  | YES  |     | NULL    |       |
| homepage             | varchar(255)  | YES  |     | NULL    |       |
| description          | text          | YES  |     | NULL    |       |
| category             | varchar(255)  | YES  |     | NULL    |       |
| bgcolor              | varchar(255)  | YES  |     | NULL    |       |
| notification         | text          | YES  |     | NULL    |       |
| notification_summary | varchar(255)  | YES  |     | NULL    |       |
| created              | decimal(10,0) | YES  |     | NULL    |       |
| createdby            | varchar(255)  | YES  |     | NULL    |       |
| lastmodified         | decimal(10,0) | YES  |     | NULL    |       |
| lastmodifiedby       | varchar(255)  | YES  |     | NULL    |       |
| dsize                | decimal(10,0) | YES  |     | 0       |       |
| history              | text          | YES  |     | NULL    |       |
| folder               | decimal(15,0) | YES  | MUL | NULL    |       |
| insegna              | varchar(255)  | YES  |     | NULL    |       |
| gruppo               | varchar(255)  | YES  |     | NULL    |       |
| percorso             | varchar(255)  | YES  |     | NULL    |       |
| valutazione_rapporto | varchar(255)  | YES  |     | NULL    |       |
| canaledistributivo   | varchar(255)  | YES  |     | NULL    |       |
| merchandiser         | varchar(255)  | YES  |     | NULL    |       |
| codicefiscale        | varchar(255)  | YES  |     | NULL    |       |
| partitaiva           | varchar(255)  | YES  |     | NULL    |       |
| noncontattare        | varchar(255)  | YES  |     | NULL    |       |
| phone                | varchar(255)  | YES  |     | NULL    |       |
| fax                  | varchar(255)  | YES  |     | NULL    |       |
| email                | varchar(255)  | YES  |     | NULL    |       |
| cod_alber            | varchar(255)  | YES  |     | NULL    |       |
| chiusura             | varchar(255)  | YES  |     | NULL    |       |
| companyid            | varchar(255)  | YES  |     | NULL    |       |
| alber_orders         | text          | YES  |     | NULL    |       |
| iban                 | varchar(255)  | YES  |     | NULL    |       |
| cod_rif              | varchar(255)  | YES  |     | NULL    |       |
| last_name            | text          | YES  |     | NULL    |       |
| image                | text          | YES  |     | NULL    |       |
| cod_compacomm        | varchar(255)  | YES  |     | NULL    |       |
| email_pec            | varchar(255)  | YES  |     | NULL    |       |
| icon                 | text          | YES  |     | NULL    |       |
| referenti            | varchar(255)  | YES  |     | NULL    |       |
| orario_apertura      | varchar(255)  | YES  |     | NULL    |       |
| referenti_reparto    | varchar(255)  | YES  |     | NULL    |       |
| orario_consegne      | varchar(255)  | YES  |     | NULL    |       |
| subquery_image       | varchar(255)  | YES  |     | NULL    |       |
+----------------------+---------------+------+-----+---------+-------+
50 rows in set (0.04 sec)

Thanks
Massimo

Patrick Pliessnig

unread,
Mar 27, 2016, 10:19:12 AM3/27/16
to Simple Groupware
Hi Massimo

I could not download the companies.xml. Anyway I think the companies.xml is the basic schema and the others are differential schemas. the problem is probably caused by field 'image' being in another file than the basic schema.

I see two possible concepts to solve the problem:
  1. the first one, I did not test:
    • put the whole schema in one custom schema file 'companies.xml'
    • use differential schemas to hide or deactivate parts of the basic schema for the desired folders.

  2. the 2nd one works on my test installation:
    • configure the 'Test View' with the image field as a sub-schema ( rather than a differential schema )
      see the attached file for the sub-schema nodb_company_test_view.xml.
      you can adapt the sub-schema to show exactly the fields you like. you can change the filename of the sub-schema, but it is important that the filename starts with the prefix 'nodb_'. this prefix prevents any database manipulations ( it is only a view )

    • in your differential schema use the following to link the 'Test View' to the differential schema
      <table>
         <view name="test" displayname="Test" schema="nodb_company_test_view" show_preview="true">
         </view>
      </table>


Try the 2nd one and if it works think about the first one.


I hope this helps


Patrick



nodb_company_test_view.xml

Massimo Arnaudo

unread,
Mar 29, 2016, 9:41:56 AM3/29/16
to simple-g...@googlegroups.com
Hi Patrick,
i have done what you suggested, and now in my custom/modules/schema/compamies/ i have only one file (companies.xml).

The test view worked partiality: the file name is short without all the route, but the preview give an error.




Thank you for the resources that you spent in the answer to my question.

Massimo

Patrick Pliessnig

unread,
Mar 30, 2016, 9:35:53 AM3/30/16
to Simple Groupware
You are welcome Massimo :-)

This time the error message points to another error.
Send me your new unified schema companies.xml, I'll test it on my test installation.
Please attach it here instead of Amazone cloud ( I had problems downloading it from amazone) and indicate your exacte version of sgs. thank you.

Patrick

Massimo Arnaudo

unread,
Mar 31, 2016, 4:12:22 AM3/31/16
to simple-g...@googlegroups.com
Right!

This is my SGS info:
Simple Groupware version: 0.745
Simple Groupware language: it
PHP Version: 5.4.45
Database + Version: mysql 562
Server OS: Linux ip-10-0-0-70 4.1.13-19.30.amzn1.x86_64 #1 SMP Fri Dec 11 03:42:10 UTC 2015 x86_64
Webserver: Apache/2.4.18 (Amazon) PHP/5.4.45
Webbrowser: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0
APC cache usage: 31 MB / 64 MB
Disk usage: 4 GB / 8 GB
And in attach the companies.xml file


Massimo
companies.xml

Patrick Pliessnig

unread,
Apr 1, 2016, 4:43:34 AM4/1/16
to Simple Groupware
I see 3 things in your differential schema:

   in the differential schema you define the cardinality 10:
         <field name="image" ... simple_size="10" >

    so in the sub-schema you should define the same cardinality because the image is probably stored differently:
         <field name="image" ... simple_size="10" >

    If you use a cardinality larger than 1, SGS normaly stores the information between vertical lines |image1|image2|image3| in the database.

---
the attributes modulename="Aziende" order="asc" limit="50" should probably not be there. ( but maybe they do not harm neither.  )

---
also in the view="visite" you use the function="truncate|1".
What is the use of this function there? Does it need to be there?

Can you solve the problems with these indications?

Massimo Arnaudo

unread,
Apr 3, 2016, 12:24:29 PM4/3/16
to simple-g...@googlegroups.com
Hi Patrick,

The first point.
I have changed the valus.

The second point.
The attribute help to sort and visualize the assets, but it is not so important, so i changed.

The third point.
I tested this function to visualize only a thumbnail but not the link; the result is the opposite: it show the first link's value and not the photo...
Removed!

The file modified is in attach.

I have retested but the error is the same:
Php Notice: 03/04/16 18:10:55 pm Undefined offset: 0
/var/www/html/bin/core/functions.php 919

Thanks
Massimo

companies.xml

Patrick Pliessnig

unread,
Apr 4, 2016, 7:42:14 AM4/4/16
to Simple Groupware
G'day Massimo

No good.

I remember vaguely that you preferred Vlad's patches. The error message points to a point in functions.php where Vlad did some work.

Please attach this file so that I can checked its content:

/var/www/html/bin/core/functions.php

Thank you

Massimo Arnaudo

unread,
Apr 4, 2016, 10:04:39 AM4/4/16
to simple-g...@googlegroups.com
Hi,
in attach the file!

Massimo
functions.php

Patrick Pliessnig

unread,
Apr 5, 2016, 2:05:56 PM4/5/16
to Simple Groupware
Massimo

The php error point to line 919 which is part of the patch Vlad Zaritsky added. It was never tested by a third party.
This patch should be useful only if you use cifs mountpoints. If you don't use cifs mountpoints, you could simply take it away.

to take it away, you could simply:
  1. comment out lines: 915 - 923
    // .....
  2. instead add a new line before line 927:
    $folder = $tfolder;

do you think this is a valid option for you?
could this help?


I did the modification in the attachment if you like to try it.
functions.php

Massimo Arnaudo

unread,
Apr 6, 2016, 3:28:30 AM4/6/16
to simple-g...@googlegroups.com
Hi Patrick,
i have modified the file functions.php like you suggested, and now the error message disappeared.

Thanks!
Massimo

Patrick Pliessnig

unread,
Apr 6, 2016, 9:10:37 AM4/6/16
to Simple Groupware
:-)


btw: please indicate in the future which patched version you installed.
If there will be a need I will take over selected patches from Vlad after third party testing or testing myself.

Massimo Arnaudo

unread,
Apr 6, 2016, 10:01:37 AM4/6/16
to simple-g...@googlegroups.com
OK!

Massimo
Reply all
Reply to author
Forward
0 new messages