Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Application Development » BUTTON IN THE DATA AREA
BUTTON IN THE DATA AREA [message #5085] Mon, 19 October 2015 00:30 Go to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Dear Tony

I'm trying to add a button in the data area but I can't get radicore do this.

This is my screen file:
$structure['xsl_file'] = 'std.detail1.xsl';

$structure['tables']['main'] = 'tarifa';

// identify the column specs - may use 'width' or 'class'
$structure['main']['columns'][] = array('width' => '25%');
$structure['main']['columns'][] = array('width' => '*');

$structure['main']['fields'][] = array('descripcionevento' => 'Evento');
$structure['main']['fields'][] = array('idlocalidad' => 'Id.Localidad');
$structure['main']['fields'][] = array('descripciontarifa' => 'Tarifa');
$structure['main']['fields'][] = array('idtipotarifa' => 'Id.Tipo Tarifa');
$structure['main']['fields'][] = array('idformatoimpresion' => 'Formato');
$structure['main']['fields'][] = array('tarifa' => 'Tarifa');

$structure['main']['fields'][] = array('aimprimir' => 'Cantidad a Imprimir');
$structure['main']['fields'][] = array('printbutton' => '');

$structure['main']['fields'][] = array('copiable' => 'Se copia a otros Eventos');
$structure['main']['fields'][] = array('secuenciasri' => 'Lleva secuencia SRI');
$structure['main']['fields'][] = array('maxticketstarifa' => 'Maximo de Tickets');
$structure['main']['fields'][] = array('tasaiva' => 'Tasa de IVA');
$structure['main']['fields'][] = array('tasaimpuesto1' => 'Tasa de Impuesto');
$structure['main']['fields'][] = array('descimpuesto1' => 'Descripción del Impuesto');
$structure['main']['fields'][] = array('tasaimpuesto2' => 'Tasa de Impuesto');
$structure['main']['fields'][] = array('descimpuesto2' => 'Descripcion del Impuesto');
$structure['main']['fields'][] = array('cargo1' => 'Valor por cargo');
$structure['main']['fields'][] = array('cargo2' => 'Valor por Cargo');
$structure['main']['fields'][] = array('estado' => 'Estado');
$structure['main']['fields'][] = array('fechahoracreacion' => 'Fecha de Creación');
$structure['main']['fields'][] = array('fechahoraactualizacion' => 'Fecha de Actualización');
[/quote]


And this is my _cm_changeConfig() method:
function _cm_changeConfig ($where, $fieldarray)
// $where = a string in SQL 'where' format.
// $fieldarray = the contents of $where as an array.
{
if ($GLOBALS['mode'] == 'update') {
$prev_script = getPreviousScript();
if ($prev_script == '/access/tarifa_print_ticket(list2).php') {

unset ($GLOBALS['act_buttons']['submit']);
unset ($GLOBALS['act_buttons']['submitnext']);
unset ($GLOBALS['act_buttons']['copy']);
unset ($GLOBALS['act_buttons']['paste']);

$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'subtype' => 'button',
'value' => 'IMPRIMIR',
'task_id' => 'ticket(add4)');

$this->fieldspec['idlocalidad']['noedit'] = 'y';
$this->fieldspec['descripciontarifa']['noedit'] = 'y';
$this->fieldspec['idtipotarifa']['noedit'] = 'y';
$this->fieldspec['idformatoimpresion']['noedit'] = 'y';
$this->fieldspec['tarifa']['noedit'] = 'y';

$fieldarray['aimprimir'] = 0;
$this->fieldspec['aimprimir'] = array ('type'=> 'integer',
'size'=> 5,
'minvalue' => 0,
'maxvalue' => 1000,
'default'=> 10,
'nondb'=>'y');

$this->fieldspec['copiable']['nodisplay'] = 'y';
$this->fieldspec['secuenciasri']['nodisplay'] = 'y';
$this->fieldspec['maxticketstarifa']['nodisplay'] = 'y';
$this->fieldspec['tasaiva']['nodisplay'] = 'y';
$this->fieldspec['tasaimpuesto1']['nodisplay'] = 'y';
$this->fieldspec['descimpuesto1']['nodisplay'] = 'y';
$this->fieldspec['tasaimpuesto2']['nodisplay'] = 'y';
$this->fieldspec['descimpuesto2']['nodisplay'] = 'y';
$this->fieldspec['cargo1']['nodisplay'] = 'y';
$this->fieldspec['cargo2']['nodisplay'] = 'y';
$this->fieldspec['estado']['nodisplay'] = 'y';
$this->fieldspec['fechahoracreacion']['nodisplay'] = 'y';
$this->fieldspec['fechahoraactualizacion']['nodisplay'] = 'y';
}
} // if
return $fieldarray;

} // _cm_changeConfig


And this is my entry in the language_text.inc file:
// navigation button details for subsystem XXX
$array['printbutton'] = 'IMPRIMIR';

You can find attached the screen where you can see it's only added the "aimprimir" non-db field, but not the button at all.

My Radicore version is 1.67.

Please let me know what I'm doing wrong.



Thanks for advance!!
Re: BUTTON IN THE DATA AREA [message #5086 is a reply to message #5085] Mon, 19 October 2015 05:18 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You are not executing an ADD transaction, therefore you need to follow what it says it FAQ137:

"Unless you are in an ADD transaction you will also need to ensure that this non-database field appears in the data array otherwise it will not appear in the screen. You will need code similar to the following:

$this->fieldarray['add_attachment'] = null;"


Re: BUTTON IN THE DATA AREA [message #5087 is a reply to message #5086] Mon, 19 October 2015 10:57 Go to previous messageGo to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Thanks for your answer.

I've tried the following changes in _cm_chageConfig:

first try, nothing happens
$this->fieldarray['printbutton'] = null;
$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'subtype' => 'button',
'value' => 'IMPRIMIR',
'task_id' => 'ticket(add4)');

second try, nothing happens
$this->fieldarray['printbutton'] = null;
$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'subtype' => 'button',
'value' => 'IMPRIMIR',
'task_id' => 'ticket(add4)',
'nondb'=>'y');

third try, Fatal Error: Mysql: Unkknow column ´tarifa.printbutton´.........
$fieldarray['printbutton'] = null;
$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'subtype' => 'button',
'value' => 'IMPRIMIR',
'task_id' => 'ticket(add4)');

fourth try, the "button" appears like a string input field
$fieldarray['printbutton'] = null;
$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'subtype' => 'button',
'value' => 'IMPRIMIR',
'task_id' => 'ticket(add4)',
'nondb'=>'y');

Sorry to bother, and thanks for your patience.
Re: BUTTON IN THE DATA AREA [message #5090 is a reply to message #5087] Tue, 20 October 2015 09:09 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
It may be because you are still using a very old version of the framework - 1.67. Try the latest version, which is 1.91.

This is what I have in one of my tasks to display an "Add Attachment" button.

In the _cm_changeConfig() method I have the following:
$this->fieldspec['add_attachment'] = array('type' => 'string',
                                           'control' => 'input',
                                           'task_id' => 'py_email_attachment(add2)');
$fieldarray['add_attachment'] = null;

In my language_text.inc file I have the following:
$array['add_attachment']                   = "Add Attachment";

The XML output contains the following:
<add_attachment name="task#py_email_attachment(fileupload)" control="input">Add Attachment</add_attachment>



Re: BUTTON IN THE DATA AREA [message #5112 is a reply to message #5090] Sun, 01 November 2015 00:11 Go to previous messageGo to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Hi Tony,
I installed the last version (1.91) and then modified my script to follow your _cm_chageConfig() (only changing variable names) and your language_text.inc file, what I get is:


( ! ) Warning: error_log() [function.error-log]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\AppServ\www\cse\includes\error.inc on line 255
Call Stack
# Time Memory Function Location
1 0.0004 64352 {main}( ) ..\tarifa(upd1).php:0
2 0.0036 166488 require( 'D:\AppServ\www\cse\includes\std.update1.inc' ) ..\tarifa(upd1).php:17
3 0.1705 8117160 Default_Table->getData( ) ..\std.update1.inc:111
4 0.1787 8504840 Default_Table->_dml_getData( ) ..\std.table.class.inc:2007
5 0.1787 8506624 mysql->getData( ) ..\std.table.class.inc:7798
6 0.1792 8512320 trigger_error ( ) ..\dml.mysqli.class.inc:634
7 0.1792 8512320 errorHandler( ) ..\dml.mysqli.class.inc:634
8 0.1860 8604640 error_log ( ) ..\error.inc:255
This application has encountered an unrecoverable error

The following has been reported to the administrator:

2015-10-31 23:02:59

Fatal Error: MySQL: Unknown column 'tarifa.printbutton' in 'where clause' (# 1054)

SQL query: SELECT SQL_CALC_FOUND_ROWS tarifa.*, evento.descripcionevento, formatoimpresion.descripcionformato, localidad.descripcionlocalidad, tipotarifa.descripciontipotarifa FROM tarifa LEFT JOIN evento ON (evento.idevento=tarifa.idevento) LEFT JOIN formatoimpresion ON (formatoimpresion.idformatoimpresion=tarifa.idformatoimpresi on) LEFT JOIN localidad ON (localidad.idlocalidad=tarifa.idlocalidad) LEFT JOIN tipotarifa ON (tipotarifa.idtipotarifa=tarifa.idtipotarifa) WHERE tarifa.idtarifa='4412' AND tarifa.printbutton IS NULL LIMIT 1 OFFSET 0

Error in line 634 of file 'D:\AppServ\www\cse\includes\dml.mysqli.class.inc'.

Host Info: localhost via TCP/IP
Server Version: 5.0.51b-community-nt-log
Client Version: 5.0.51a, Character sets - client: utf8, - connection: utf8, - database: utf8, - server: utf8

PHP_SELF: /cse/access/tarifa(upd1).php

CURRENT DIRECTORY: D:\AppServ\www\cse\access

SERVER_ADDR: 127.0.0.1

SERVER_NAME: localhost

HTTP_HOST: localhost

User Id: MGR

Role Id: GLOBAL

REMOTE_ADDR: 127.0.0.1

REQUEST_URI: /cse/access/tarifa(upd1).php?session_name=menu4


Can you suggest me where should I look for in order to debug and see what's happening?
Thanks for advance
Re: BUTTON IN THE DATA AREA [message #5113 is a reply to message #5112] Sun, 01 November 2015 05:21 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
You have two errors here:

(1) MySQL: Unknown column 'tarifa.printbutton' in 'where clause' is caused by the fact that you have "AND tarifa.printbutton IS NULL" in your WHERE clause. A column called 'printbutton' does not exist in the database.

(2) error_log() [function.error-log]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini is caused by the fact that the error_log() is trying to use the mail() command, but you have not set up the corresonding values in your PHP.INI file.


Re: BUTTON IN THE DATA AREA [message #5123 is a reply to message #5113] Tue, 03 November 2015 15:33 Go to previous messageGo to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Yes, but what I want to solve is the fact that "printbutton" is the button on my data area, but it never appears on screen, even when I follow your instructions.
The problem seems to be that the framework do not recognize "printbutton" as a button but it does like a database field.

My _cm_changeConfig is:
$this->fieldspec['printbutton'] = null;
$this->fieldspec['printbutton'] = array ('type'=> 'string',
'control'=> 'input',
'task_id' => 'ticket(add4)');
$fieldarray['printbutton'] = null;


My language.text.inc:
// navigation button details for subsystem XXX
$array['printbutton'] = 'IMPRIMIR';

My xxx.detail.screen.inc file:
$structure['main']['fields'][] = array('printbutton' => '');

What I want is to debug the radicore script wich discerns if a field is a button, or a database field or a non-database field, in order to determine where is my error.

Thanks for advance.



Re: BUTTON IN THE DATA AREA [message #5129 is a reply to message #5123] Wed, 04 November 2015 05:52 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
The problem is that the line "$fieldarray['printbutton'] = null;" is being executed too soon, and it is causing the $where string to be regenerated to include 'printbutton'. To avoid this you need to use the following code inside _cm_changeConfig():
if (empty($where) AND !empty($fieldarray)) {
    $fieldarray['printbutton'] = null;
}


Re: BUTTON IN THE DATA AREA [message #5134 is a reply to message #5129] Wed, 04 November 2015 23:42 Go to previous messageGo to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Thank you!!
It's working now!
Re: BUTTON IN THE DATA AREA [message #5441 is a reply to message #5134] Wed, 23 March 2016 13:26 Go to previous messageGo to next message
edortizq is currently offline  edortizq
Messages: 82
Registered: August 2008
Location: Ecuador
Member

Can I get a button on the OUTER DETAILS area of MULTI4 transaction?
Do you have some example?

Thanks for advance!
Re: BUTTON IN THE DATA AREA [message #5442 is a reply to message #5441] Thu, 24 March 2016 06:20 Go to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Take a look at FAQ137

Previous Topic: JAVASCRIPT CODE FOR INPUT FIELD
Next Topic: RETURN MORE THAN ONE TRANSACTION
Goto Forum:
  


Current Time: Tue Dec 03 11:54:24 EST 2024

Total time taken to generate the page: 0.01399 seconds