Hi there!
I´m making a PDF using data input to build a contract.
But there is an 'optional field', so, if the user fills in, the result is one text on the contract. If he leave blank, the result is another.
The name of the field is RAZAOSOCIAL.
I´ve tried this code (assuming that I´m terribly bad with PHP):
All the other things I wanted are working - thanks a lot!
Regards
Lucas Selbach
Brasil
I´m making a PDF using data input to build a contract.
But there is an 'optional field', so, if the user fills in, the result is one text on the contract. If he leave blank, the result is another.
The name of the field is RAZAOSOCIAL.
I´ve tried this code (assuming that I´m terribly bad with PHP):
<?php if ('{$form->data['razaosocial']}' == '') echo 'inscrito/a no CPF sob nº {cpf}, ' else echo 'inscrito/a no CPF sob nº {cpf}, representando a empresa {razaosocial}, inscrita no CNPJ sob no. {cnpj},'; ?>
All the other things I wanted are working - thanks a lot!
Regards
Lucas Selbach
Brasil
BTW, this code is within TCPDF action, in the field CONTENT, inside HTML code.
Hi Lucas,
It may be simpler to do this using a Custom Code action before the TCPDF action
Bob
PS Or it may be that fixing your PHP is enough. There is a mixture of quotes and brackets that aren't quite right.
It may be simpler to do this using a Custom Code action before the TCPDF action
<?php
if ( $form->data['razaosocial'] == '') {
$form->data['cpf_xxx'] = "inscrito/a no CPF sob nº {$form->data['cpf']}, ";
} else {
$form->data['cpf_xxx'] = "inscrito/a no CPF sob nº {$form->data['cpf']}, representando a empresa {$form->data['razaosocial']}, inscrita no CNPJ sob no. {$form->data['cnpj']},";
?>Then put {cpf_xxx} in the TCPDF content.
Bob
PS Or it may be that fixing your PHP is enough. There is a mixture of quotes and brackets that aren't quite right.
Hi Bob,
Thanks for replying!!
Sorry, but It dind´t worked!
Both the option (with or without info) get the label itself on PDF . Take a look
http://lucasselbach.com.br/contratos/Contrato_video__20140712195038.pdf
Any suggestion?
Thanks for helping and best regards!
Lucas
Thanks for replying!!
Sorry, but It dind´t worked!
Both the option (with or without info) get the label itself on PDF . Take a look
http://lucasselbach.com.br/contratos/Contrato_video__20140712195038.pdf
Any suggestion?
Thanks for helping and best regards!
Lucas
HI Lucas,
It works perfectly when I test it with a very simple form :-(
To debug add a debugger action to the form ON Submit event and a Show Stopper action and drag them both up before the TCPDF action, That will stop the PDF being created and let you see what the output from the PHP is.
Bob
It works perfectly when I test it with a very simple form :-(
To debug add a debugger action to the form ON Submit event and a Show Stopper action and drag them both up before the TCPDF action, That will stop the PDF being created and let you see what the output from the PHP is.
Bob
Hi Bob,
I did that, and the result is below.
If you can take a look, that would be awesome.
Thanks
Lucas
I did that, and the result is below.
If you can take a look, that would be awesome.
Thanks
Lucas
Hi Lucas,
I don't see any value there for [cpf_xxx] or anything similar . . . maybe there's a typo in the PHP?
Bob
I don't see any value there for [cpf_xxx] or anything similar . . . maybe there's a typo in the PHP?
Bob
Dear Bob,
I don´t understand: this is EXACTLY what you´ve posted above
So I tried with an empty form and also didn´t worked.
Can you send me the form you´ve tested so I install here and test too??
Thanks
Lucas
I don´t understand: this is EXACTLY what you´ve posted above
<?php
if ( $form->data['razaosocial'] == '') {
$form->data['cpf_xxx'] = "inscrito/a no CPF sob nº {$form->data['cpf']}, ";
} else {
$form->data['cpf_xxx'] = "inscrito/a no CPF sob nº {$form->data['cpf']}, representando a empresa {$form->data['razaosocial']}, inscrita no CNPJ sob no. {$form->data['cnpj']},";
?>
So I tried with an empty form and also didn´t worked.
Can you send me the form you´ve tested so I install here and test too??
Thanks
Lucas
Hi Lucas,
Sorry, my mistake. I misread the code in the strange image viewer here :-(
Here's my test form
Bob
Sorry, my mistake. I misread the code in the strange image viewer here :-(
Here's my test form
Bob
Hi Bob
The thing is that {cpf_xxx} doesn´t load on TCPDF action. (Even taking off underscore to {cpfxxx}
I also tried a simple code and still doesn´t work.
Or another version of code, based on what you´ve sent me
Still doesn´t work.
Should I send you the form??
regards
Lucas
The thing is that {cpf_xxx} doesn´t load on TCPDF action. (Even taking off underscore to {cpfxxx}
I also tried a simple code and still doesn´t work.
<?php
$form->data['cpfxxx'] == $form->data['razaosocial']
?>
Or another version of code, based on what you´ve sent me
<?php
if ( $form->data['razaosocial'] <> '') {
$form->data['cpfxxx'] = 'inscrito/a no CPF sob nº '.$form->data['cpf'].'
representando a empresa '.$form->data['razaosocial'].' inscrita no CNPJ sob no. '.$form->data['cnpj'];
} else {
$form->data['cpfxxx'] = 'inscrito/a no CPF sob nº '.$form->data['cpf'];
?>
Still doesn´t work.
Should I send you the form??
regards
Lucas
BTW, the CC field in EMAIL action can be filled with a fixed email? like me@provider.com ?
Because I did that and it´s not working!!
Thanks
Lucas
Because I did that and it´s not working!!
Thanks
Lucas
Hi Lucas,
The last code snippets you posted are missing a ; in the first one and a final } in the second. Please check the PHP carefully.
By all means send me a form backup.
Yes you can use a standard email address in the static CC box of an email action.
Bob
The last code snippets you posted are missing a ; in the first one and a final } in the second. Please check the PHP carefully.
By all means send me a form backup.
Yes you can use a standard email address in the static CC box of an email action.
Bob
Hi Lucas,
Thanks for the copy of the form; as far as I can tell it works perfectly provided that you fix the typos in the PHP - see my earlier post.
Bob
Thanks for the copy of the form; as far as I can tell it works perfectly provided that you fix the typos in the PHP - see my earlier post.
Bob
Dear Bob,
It was missing a BRACKET in the end.
The correct code is
Do you know how to JUSTIFY THE PARAGRAPH??
Regards
Lucas
It was missing a BRACKET in the end.
The correct code is
<?php
if ( $form->data['razaosocial'] <> '') {
$form->data['cpfxxx'] = 'inscrito/a no CPF sob nº '.$form->data['cpf'].'
representando a empresa '.$form->data['razaosocial'].' inscrita no CNPJ sob no. '.$form->data['cnpj'];
} else {
$form->data['cpfxxx'] = 'inscrito/a no CPF sob nº '.$form->data['cpf'];
}
?>
Do you know how to JUSTIFY THE PARAGRAPH??
Regards
Lucas
Hi Lucas,
Good to see you found the typo.
I don't much like justified text in HTML but you can try adding CSS to the paragraph - I expect that will work OK.
Bob
Good to see you found the typo.
I don't much like justified text in HTML but you can try adding CSS to the paragraph - I expect that will work OK.
Bob
Great, Bob,
Thanks for your precious help!
BTW, just to let you know that when I make login it appears 'Invalid Token' and I have to go back on the browser.
Best Regards
Lucas
Thanks for your precious help!
BTW, just to let you know that when I make login it appears 'Invalid Token' and I have to go back on the browser.
Best Regards
Lucas
This topic is locked and no more replies can be posted.
