How to display image in printing page

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

How to display image in printing page

Post by Moh Youba » 2019-09-16 23:59

Hello

I am creating custom printing page and I want to display the image on it. I try this code

<div class="col-sm-6">
<!-- customer info -->
<h5> : <?php echo $order['description']; ?></h5>
<?php echo $order['logo']; ?>
</div>

but the image do not display, only the name of the image is showing. Please any help will be appreciated.
logo1.jpg
logo1.jpg (19.92 KiB) Viewed 8056 times
Thank you

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-09-17 09:54

Hi,

you need to add the image tag to the html code. The $order['logo'] will go to the src.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: How to display image in printing page

Post by Moh Youba » 2019-09-17 09:57

Thank you for support, will give a try

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: How to display image in printing page

Post by Moh Youba » 2019-09-17 10:45

Unfortunately I have try all these code below but no one works for me ! I am missing something...

<img src="images/<?php echo $order['logo']['name'] ?>"/>

<img src="images/<?php echo $_FILES['logo']['name'] ?>"/>

<img src="<?php echo images .'/' . $logo; ?>">

<?php echo $order['logo']; ?>

<?php echo '<img src="' .$logo.'">;' ?>


<?php echo "<img src='images/".$order['logo'].">"; ?>


<?php
echo'
<img src="images/'.$order['logo'].'" />
';
?>


<img src="<?php echo '".$order['logo'];"' ?>"

<?php echo '<img src=\'' . $order['logo'] . '\'>';?>

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to display image in printing page

Post by jsetzer » 2019-09-17 11:33

Hi,

as far as I can see the path is missing.

Can you please try:

Code: Select all

<?php
$logo_src = getUploadDir("") .$order["logo"];
echo "<img src=\"{$logo_src}\" />";
?>
Regards,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: How to display image in printing page

Post by Moh Youba » 2019-09-17 11:57

Yes, works absolutely fine. Thank you a lot for time and kind support.

All my best

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to display image in printing page

Post by jsetzer » 2019-09-17 12:11

Moh Youba wrote:
2019-09-17 11:57
Yes, works absolutely fine. Thank you a lot for time and kind support.
Great, I'm happy to hear that the problem is solved now!

Best,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-02 16:38

Hello.
I need to do the same thing but since the jpg file I want to display on the page is not in the same table but in a table called "pictures" I can't get the url of the image but only the primary key of the record of the "pictures" table (the url is in the "picture" field of the "pictures" table). More precisely I would like to insert the url saved in the "picture" field of the "pictures" table in the dv of the "subscriptions" table which contains an "image" field which is a lookup field of the "graphics" field of the "activity" table. The "graphics" field of the "activity" table is in turn a lookup field of the "picture" field of the "graphics" table.
In the image I try to better describe the problem
table and fields.jpeg
table and fields.jpeg (80.94 KiB) Viewed 7939 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-02 20:23

Hi,

well if you get the primary key of the pictures table (let call the variable key).
Then you can use

Code: Select all

$url = sqlvalue("SELECT url from pictures where pri_key = '{$key}'");
Assuming that the pictures table has the url field to hold the url of the image.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-03 08:41

Thank you very much pböttcher,
unfortunately it doesn't work:
I wrote like this:

________________________

$url = sqlvalue ("SELECT picture from pictures where pri_key = '{$key}'");

/* to test if work: */
echo $url;

________________________

but nothing appears!

I hope you can help me.
Thanks!
Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-03 12:11

Hi,

did you check that $key contains the correct primary key of the pictures table? Can you check the query on the DB directly?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-04 19:42

hello!

the strange thing is that if I look in the tables of my database the image column of the subscritpions table is empty (null)

if I run SELECT picture from pictures where pri_key = '1'
the result is the name of the jpg file loaded in the pictures table with pri_key = 1 but if I run the query

SELECT picture from pictures where pri_key = '{$ key}'

the result is that no table row is found and this message appears:

Warning: # 1292 Truncated incorrect DOUBLE value: '{$ key}'
_query1.jpeg
_query1.jpeg (64.37 KiB) Viewed 7876 times
could the problem depend on the use of multiple nested lookup fields?

In fact in the pictures table there are the description and picture fields.

In the activity table there are the title, the picture_description fields (which is a lookup that points to the description field of the pictures table) and the graphic field which is an auto-filled lookup* that points to the picture field of the pictures table).

Finally in the table subscriptions there are the activity field (which is a lookup that points to the title field of the activity table and the image field which is an auto-filled lookup that points to the graphic field of the activity table.

the strange thing is that in phpmyadmin looking at the table subscriptions I see that the lookup activity field with the value 2 (the pri_key of the record in the activity table) but the lookup image field remains empty (null).

* when I say "auto-filled" I refer to the "auto fill" option of the software appgini.

I enclose some screenshots to better illustrate the problem
phpmyadmin_columns.jpeg
phpmyadmin_columns.jpeg (50.94 KiB) Viewed 7876 times
select_from_activity.jpeg
select_from_activity.jpeg (34.82 KiB) Viewed 7876 times
select_from_pictures.jpeg
select_from_pictures.jpeg (38.56 KiB) Viewed 7876 times

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-04 22:19

Hi,

in the phpmyadmin you cannot run
SELECT picture from pictures where pri_key = '{$ key}' (anyway there is a blank between the $ and key which should not be there).

So you need to check the value of the variable $key at the time you call the SQL statement.

Try to add

echo "Key = ".$key;
exit;

and have a look at the output. Does it provide the expected primary key value for your image?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 06:43

sorry pböttcher can you tell me exactly what i have to write in sql query of phpmyadmin? sorry but i'm not expert with the code
Thanks!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-05 12:52

Hi,

not in phpmyadmin,

write the code

echo "Key = ".$key;
exit;

in you php file where you wil call

$url = sqlvalue ("SELECT picture from pictures where pri_key = '{$key}'");

afterwards.
This shall display the Key that you would use in the SQL statement.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 14:21

hi. Putting echo "Key = ".$key; the output is

Key =

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-05 16:37

ok, so that explains why your SQL statement fails.

Now you need to figure out how to populate the $key with the value of primary key that you have according to your description.
I need to do the same thing but since the jpg file I want to display on the page is not in the same table but in a table called "pictures" I can't get the url of the image but only the primary key of the record of the "pictures" table
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 17:14

Yes but I have no idea how to do it!
I'm trying to auto copy content of llokup field in another field so i made another help request in the forum (see my post viewtopic.php?f=7&t=3254#p11162
but I have problem with this work too.

Hope you or someone will help me again to solve!

Thank you so much

Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-05 18:39

ok, can you post the code you have currently.
Are you making your own page, or using a page generated by AppGini?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 19:29

Hi and Thank you so much for the help of the forum and specially to you pböttcher!

In the forum I spoke to simplify, of three tables "image", "activity" and "subscription" (tables that I actually used to do the tests). In reality, my tables are called "intestazioni_grafiche", "appuntamenti" and "partecipazione_evento_pubblico".
In the table "intestazioni_grafiche" I have a field "ig_ID" (primary key), a field "descrizione" (txt) and a field "grafica" (image upload).

In the table "appuntamenti" I have a field "pri_key", a field "intest_attestato_descr" (lookup to the field "descrizione" of the table "intestazioni_grafiche") and a field "intest_attestato_graph" (lookup to the field "grafica" of the table "headers_grafiche", set as "auto-fill") and a "url_intest_att_graph" field that I tried to use to copy on the fly (on change) the name of the image selected with the "url_intest_att_graph" field but with the following code (*see below) remains empty.

In the table "Partecipazione_evento_pubblico" I have a field "pri_key", a field "pri_key_appuntamento" (lookup that points to the field "pri_key" of the table "appuntamenti") and a field "int_attestato_graph" (lookup to the field "intest_attestato_graph" of the table "intestazioni_grafiche" , set as "auto-fill"),

* code where I try to copy and save the image name but it doesn't work (it’s in the file appuntamenti-dv.js):
function updateUrl() {
var intest_attestato_graph = $j( '#intest_attestato_graph' ).val(),
$j( '#url_intest_att_graph' ).text(intest_attestato_graph);
$j( '#url_intest_att_graph' ).val(intest_attestato_graph);

}

$j('#url_intest_att_graph').on('change', function() {
updateUrl();
});

Below there is the code inserted in the hook file of the partecipazione_evento_pubblico.php table to generate a "stampa attestato" button:
function partecipazione_evento_pubblico_dv($selectedID, $memberInfo, &$html, &$args){

/* if this is the print preview, don't modify the detail view */
if(isset($_REQUEST['dvprint_x'])) return;

ob_start(); ?>

<script>
$j(function(){
<?php if($selectedID){ ?>
$j('#partecipazione_evento_pubblico_dv_action_buttons .btn-toolbar').append(
'<div class="btn-group-vertical btn-group-lg" style="width: 100%;">' +
'<button type="button" class="btn btn-info btn-lg" onclick="stampa_attestato()">' +
'<i class="glyphicon glyphicon-print"></i> Stampa Attestato</button>' +
'</div>'
);
<?php } ?>
});

function stampa_attestato(){
var selectedID = '<?php echo urlencode($selectedID); ?>';
window.location = 'attestato_evento_pubblico.php?pri_key=' + selectedID;
}

</script>

<?php
$form_code = ob_get_contents();
ob_end_clean();

$html .= $form_code;

}

And finally here is the code I inserted in the "attestato_evento_pubblico.php" file that I created in the rott directory:

<?php
$currDir = dirname(__FILE__);
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
include_once("$currDir/header.php");


/* grant access to all users who have access to the partecipazione_evento_pubblico table */
$evento_from = get_sql_from('partecipazione_evento_pubblico');
if(!$evento_from) exit(error_message('Non sei autorizzato a visualizzare questa risorsa!', false));


/* grant access to all logged users
$mi = getMemberInfo();
if(!$mi['username'] || $mi['username'] == 'guest'){
echo "Access denied";
exit;
}*/

/* get evento */
$evento_id = intval($_REQUEST['pri_key']);
if(!$evento_id) exit(error_message('Identificativo Evento non valido!', false));

/* retrieve evento info */
$evento_fields = get_sql_fields('partecipazione_evento_pubblico');
$res = sql("select {$evento_fields} from {$evento_from} and partecipazione_evento_pubblico.pri_key={$evento_id}", $eo);
if(!($evento = db_fetch_assoc($res))) exit(error_message('evento non trovato', false));

/*var_dump($evento);*/

/* elimina i primi 11 caratteri dal campo riunione_evento in modo da eliminare la data che precede il campo stesso e i "due punti" che seguono la data */
$riunione_evento = $evento['riunione_evento'];
$riunione_evento_no_data = substr($riunione_evento, 11);

/* prendi la prima lettera dal nome del partecipante*/
$nome_partecipante = $evento['nome'];
$iniziale_nome_partecipante = $nome_partecipante{0};

/* prendi la prima lettera dal cognome del partecipante*/
$cognome_partecipante = $evento['cognome'];
$iniziale_cognome_partecipante = $cognome_partecipante{0};

/* prendi le ultime due cifre dell'anno dal campo data_evento*/
$data_evento = $evento['data_evento'];
$anno_evento_aa = substr($data_evento, 8, 2);

/* togli i secondi dal campo orario */
$orario_evento = $evento['orario'];
$ora_inizio_no_sec = substr($orario_evento, 0, 5);
$ora_fine_no_sec = substr($orario_evento, 8, 6);

/* prendi il nome dell'immagine dell'intestazione grafica dell'attestato */
$url = sqlvalue("SELECT grafica from intestazioni_grafiche where ig_ID = '{$key}'");
echo "Key = ".$key;
exit;
?>

Thank you so much!

Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-05 20:03

Hi,

you mention a table headers_grafiche, but you didn't discribe it.
In the appuntamenti-dv.js, what are you trying to catch? Is it, if the intest_attestato_descr changes, you want to have what?


In the attestato_evento_pubblico.php
what is the relation between the partecipazione_evento_pubblico and the intestazioni_grafiche table?
if it is based on the $evento_id, then you should try

$url = sqlvalue("SELECT grafica from intestazioni_grafiche where ig_ID = '{$evento_id}'");
echo "Key = ".$evento_id;
echo "Url= ".$url ;

to verify if that is correct.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 20:22

sorry I accidentally translated the name of the table "intestazioni_grafiche" into "header_grafiche" but the table "header_grafiche" does not exist. Instead of "header_grafiche" I wanted to write "intestazioni_grafiche".

Now I try the query you suggested and let you know.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-05 21:31

:-( the result is:
Key = 10Url=

I try to answer to your question:
what is the relation between the partecipazione_evento_pubblico and the intestazioni_grafiche table?

In the table "appuntamenti" i select an image uploaded with the table "intestazioni_grafiche" so there is a lookup field to choose the image in the appuntamenti table from "intestazioni_grafiche" table. In this way when i create an appointment in the "appuntamenti" table i can select what image will appear in the certificate (attestato) of each user that subscribe to the appointment by the "partecipazione_evento_pubblico" table. When an user select an appointment by the appuntamenti table the appointment is associated with an image stored in the "intestazioni_grafiche" table So in partecipazione_evento_pubblico a subscriber can print his certificate launching the file attestato_evento_pubblico.php in witch i want to display the image selected from the "intestazioni_grafiche" table in the "appuntamenti" table.

In summary:
I have a table intestazioni_grafiche in which I upload images
I have another table appuntamenti which I decide which image of the previous table is associated with that appointment.
I have a last table partecipazione_evento_pubblico where by signing up for an appointment I also want to take the image associated with that appointment.
In the table .... there is a button that allows you to open the "attestato_evento_pubblico" file where I see some data of the registration (practically a certificate of participation in the appointment) and I want to see also the image originally chosen.

Thank you!

Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: How to display image in printing page

Post by pbottcher » 2019-10-06 13:32

Hi Fabiano,

please try in attestato_evento_pubblico.php:

$url=sqlvalue("select i.grafica from partecipazione_evento_pubblico p left join appuntamenti a on p.riunione_evento=a.pri_key left join intestazioni_grafiche i on a.intest_attestato_descr=i.ig_ID where p.pri_key='{$evento_id}'");

$intestazione_src = getUploadDir("") .$url;
echo "<img src=\"{$intestazione_src}\" />";
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: How to display image in printing page

Post by fgazza » 2019-10-06 14:10

it works great!

Thank you so much!!!!

Fabiano

Post Reply