create a printable timesheet

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

create a printable timesheet

Post by fgazza » 2019-05-25 15:30

Hi everyone,
I'm still fighting with the need to create a timesheet from the "appuntamenti" table and from the child table "partecip_riunione_evento_partner". I created a "timesheet" button that directs to this link:
http://sullabuonastrada.org/governance/ ... entiID=104

in fact I have created an file appointments_foglio_firme.php with this code:

<?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 appuntamenti table */
$appuntamenti1_from = get_sql_from('appuntamenti1');
if(!$appuntamenti1_from) exit(error_message('Accesso Negato!', false));

/* get invoice */
$appuntamenti1_id = intval($_REQUEST['pri_key']);
if(!$appuntamenti1_id) exit(error_message('ID appuntamento non valido!', false));

/* retrieve appuntamenti info */
$appuntamenti1_fields = get_sql_fields('appuntamenti1');
$res = sql("select {$appuntamenti1_fields} from {$appuntamenti1_from} and pri_key={$appuntamenti1_id}", $eo);
$appuntamenti1 = db_fetch_assoc($res);

var_dump($appuntamenti1);

include_once("$currDir/footer.php");
?>

The following error appears on the page:
You have an error in your SQL syntax; check the right syntax to use near 'and AppointmentsID = 104' at line 1.


The query code that appears below is:

Query:
select `appuntamenti`.`pri_key` as 'pri_key', `appuntamenti`.`titolo` as 'titolo', `appuntamenti`.`ente_proponente` as 'ente_proponente', `appuntamenti`.`attivo` as 'attivo', IF( CHAR_LENGTH(`azioni_progetto1`.`n_attivita`) || CHAR_LENGTH(`azioni_progetto1`.`azione`), CONCAT_WS('', `azioni_progetto1`.`n_attivita`, ' ', `azioni_progetto1`.`azione`), '') as 'azione_di_progetto', `appuntamenti`.`tipologia_incontro` as 'tipologia_incontro', `appuntamenti`.`interno_pubblico` as 'interno_pubblico', `appuntamenti`.`accesso_op_enti_partner` as 'accesso_op_enti_partner', `appuntamenti`.`accesso_op_enti_non_partner` as 'accesso_op_enti_non_partner', `appuntamenti`.`accesso_genitori_bambini_vari_interessati` as 'accesso_genitori_bambini_vari_interessati', `appuntamenti`.`chi_puo_partecipare` as 'chi_puo_partecipare', if(`appuntamenti`.`data_appuntamento`,date_format(`appuntamenti`.`data_appuntamento`,'%d/%m/%Y'),'') as 'data_appuntamento', `appuntamenti`.`ora_inizio` as 'ora_inizio', `appuntamenti`.`ora_fine` as 'ora_fine', `appuntamenti`.`luogo` as 'luogo', `appuntamenti`.`piu_date_luoghi_orari` as 'piu_date_luoghi_orari', `appuntamenti`.`descrizione` as 'descrizione', `appuntamenti`.`recapito_mail_info` as 'recapito_mail_info', IF( CHAR_LENGTH(`schede_tratt_dati1`.`nome_scheda`), CONCAT_WS('', `schede_tratt_dati1`.`nome_scheda`), '') as 'nome_sch_inf_tratt_dati', IF( CHAR_LENGTH(`schede_tratt_dati1`.`descrizione`), CONCAT_WS('', `schede_tratt_dati1`.`descrizione`), '') as 'sintesi_informativa', IF( CHAR_LENGTH(`schede_tratt_dati1`.`scheda_html`), CONCAT_WS('', `schede_tratt_dati1`.`scheda_html`), '') as 'inf_trattamento_dati' from and AppuntamentiID=104

I want to inform you that the table in appgini is called appointments but in phpmyadmin it's called appuntamenti1 because probably the appuntamenti table already existed in my database (due to a previous table created in applications and then deleted).

Hope someone will help me!

Thank you to all!

Fabiano

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

Re: create a printable timesheet

Post by pbottcher » 2019-05-25 17:47

Hi,

in you posted query you are missing the table(s) from which you want to get your data

your code:
as 'inf_trattamento_dati' from and AppuntamentiID=104

as 'inf_trattamento_dati' from "HERE YOU NEED TO HAVE THE TABLE(S) AND THE WHERE CLAUSE" and AppuntamentiID=104
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: create a printable timesheet

Post by fgazza » 2019-05-25 18:36

Hello and thanks for the reply.
The code I entered seems exactly the same as the one shown in the course that Ahmad offers on udemy.com, as you can see from the screenshots but he gets the data from his table and I don't!

I can't understand where I'm wrong.

Thanks for your help!
Fabiano
code.jpg
code.jpg (215.06 KiB) Viewed 1658 times
result.jpg
result.jpg (113.58 KiB) Viewed 1658 times

Post Reply