Welcome, Guest
Username: Password: Remember me

TOPIC: [solved] Creating a PDF with Cook

[solved] Creating a PDF with Cook 24 Jun 2012 12:01 #2627

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
hi
in one view i load a new template _print
this template use a form with the method post for enjoy data in a php file for create a pdf file

but it's in conflict with the component, the toolbar of my view don't work ...

this method is correct or no ? how solved ?

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
Last Edit: 05 Jul 2012 08:08 by LJ01.
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 07:51 #2630

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Yes, of course, because your MVC has only one method to receive the datas from the post for each table.

TODO :
In the controller :
Get the layout name and separate the treatements in case of the layout is your new layout alias.

What kind of conflicts ?
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 08:32 #2632

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
conflct = toolbar button don't work, isn't active

i precise some data are calculate in my view_item, and i want export these in a php file

Original coding
<form method="POST" action="/components/com_batenergie/print/batiment.php" target="_blank">

<input type="hidden" name="surface" value="<?php echo $this->batiment->surface ?>" />
<input type="hidden" name="name" value="<?php echo $this->batiment->name ?>" />
<input type="hidden" name="adresse" value="<?php echo $this->batiment->adresse ?>" />
<input type="hidden" name="photo" value="<?php echo $this->batiment->photo; ?>" />
<input type="hidden" name="type1" value="<?php  echo $this->batiment->type1  ?>" />
<input type="hidden" name="travaux" value="<?php  echo $this->batiment->travaux  ?>" />
<input type="hidden" name="Prixm2" value="<?php echo round($Prixm2,1) ?>" />
<input type="hidden" name="resco2" value="<?php echo round($resco2,1)  ?>" />
<input type="hidden" name="reskwhep" value="<?php  echo round($reskwhep,1)  ?>" />
<input type="hidden" name="Puissanc3" value="<?php  echo round($Puissanc3,1)  ?>" />
<input type="hidden" name="tco2" value="<?php  echo round($tco2,1)  ?>" />

<input type="hidden" name="conso09b" value="<?php echo $conso09b ?>" />
<input type="hidden" name="conso10b" value="<?php echo $conso10b ?>" />
<input type="hidden" name="conso11b" value="<?php echo $conso11b ?>" />
<input type="hidden" name="conso12b" value="<?php echo $conso12b ?>" />

<input type="hidden" name="conso09elekb" value="<?php echo $conso09elekb ?>" />
<input type="hidden" name="conso10elekb" value="<?php echo $conso10elekb ?>" />
<input type="hidden" name="conso11elekb" value="<?php echo $conso11elekb ?>" />
<input type="hidden" name="conso12elekb" value="<?php echo $conso12elekb ?>" />

<input type="hidden" name="conso11elek" value="<?php echo $conso11elek ?>" />
<input type="hidden" name="prixelek" value="<?php echo $prixelek ?>" />

<input type="hidden" name="coutmoyeneau" value="<?php echo round($coutmoyeneau,1) ?>" />

<input type="hidden" name="eau09b" value="<?php echo $eau09b ?>" />
<input type="hidden" name="eau10b" value="<?php echo $eau10b ?>" />
<input type="hidden" name="eau11b" value="<?php echo $eau11b ?>" />
<input type="hidden" name="eau12b" value="<?php echo $eau12b ?>" />

<input type="hidden" name="eau09" value="<?php echo $this->batiment->eau09 ?>" />
<input type="hidden" name="eau10" value="<?php echo $this->batiment->eau10 ?>" />
<input type="hidden" name="eau11" value="<?php echo $this->batiment->eau11 ?>" />
<input type="hidden" name="eau12" value="<?php echo $this->batiment->eau12 ?>" />

<input type="hidden" name="label_b" value="<?php echo $label_b ?>" />
<input type="hidden" name="label_c" value="<?php echo $label_c ?>" />
<input type="hidden" name="label_d" value="<?php echo $label_d ?>" />
<input type="hidden" name="label_e" value="<?php echo $label_e ?>" />
<input type="hidden" name="label_f" value="<?php echo $label_f ?>" />
<input type="hidden" name="label_g" value="<?php echo $label_g ?>" />
                                
<input type="hidden" name="label_bco2" value="<?php echo $label_bco2 ?>" />
<input type="hidden" name="label_cco2" value="<?php echo $label_cco2 ?>" />
<input type="hidden" name="label_dco2" value="<?php echo $label_dco2 ?>" />
<input type="hidden" name="label_eco2" value="<?php echo $label_eco2 ?>" />
<input type="hidden" name="label_fco2" value="<?php echo $label_fco2 ?>" />
<input type="hidden" name="label_gco2" value="<?php echo $label_gco2 ?>" />
*/?>
<div align="right"><font color="#d43c0f">Fiche de synthèse</font>
<input type="image" src="/components/com_batenergie/images/print.png" 
        			width="25" 
        			height="25" 
        			align="right" 
        			border="0" 
        			alt="Edit" />
</div>
</form>

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 09:03 #2634

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
action="/components/com_batenergie/print/batiment.php"

You cannot do that in Joomla

Leave the original action url.

Catch your values in your controller.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 13:51 #2653

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
i had this function in my controller, it's a copy of edit function
function printy()

	{
		//Check Component ACL
		if (!$this->can(array('core.edit', 'core.edit.own'), JText::_("PRINT")))
			return;

		$model = $this->getModel('batenergiepartitem');
		$item = $model->getItem();

		//Check Item ACL
		if (!$this->can('access-edit', JText::_("PRINT"), $item->params))
			return;

		$vars = array();
		$layout = JRequest::getVar( 'layout');
		switch($layout)
		{
			case 'default':
				JRequest::setVar( 'view'  , 'batenergiepartitem');
				JRequest::setVar( 'layout', 'batiment' );
				break;


			default:
				JRequest::setVar( 'view'  , 'batenergiepartitem');
				JRequest::setVar( 'layout', 'batiment' );
				break;

		}

		$this->setRedirect(BatenergieHelper::urlRequest($vars));
	}

i hab a button print in my toolbar

bur then i click on that -> white page with only site header !? the url is correct with "/nw_wiew/id"

this view require a file fpdf that i put in the same directory ...

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 14:02 #2654

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
White page = Fatal error

Active the "display_errors" to be able to debug.

Note also that if you output a PDF, nothing should be writed before the PDF header.
Means, that you must finish your code by a jexit(), which is the exit() function of Joomla. (setRedirect is useless in that case)
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 16:48 #2660

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
i active journal errors
on white page there are
Strict Standards: Only variables should be assigned by reference in /homez.506/ingallni/www/joomlatest/components/com_batenergie/batenergie.php on line 39

Strict Standards: Declaration of BatenergieControllerBatenergiepart::display() should be compatible with that of JController::display() in /homez.506/ingallni/www/joomlatest/components/com_batenergie/controllers/batenergiepart.php on line 479

Strict Standards: Non-static method BatenergieHelper::getACL() should not be called statically, assuming $this from incompatible context in /homez.506/ingallni/www/joomlatest/administrator/components/com_batenergie/classes/jcontroller.php on line 59

Strict Standards: Non-static method BatenergieHelper::getACL() should not be called statically, assuming $this from incompatible context in /homez.506/ingallni/www/joomlatest/components/com_batenergie/models/batenergiepartitem.php on line 309

Notice: Undefined property: BatenergieModelBatenergiepartitem::$stateSet in /homez.506/ingallni/www/joomlatest/administrator/components/com_batenergie/classes/jmodel.item.php on line 380

Strict Standards: Non-static method BatenergieHelper::getACL() should not be called statically, assuming $this from incompatible context in /homez.506/ingallni/www/joomlatest/components/com_batenergie/models/batenergiepartitem.php on line 485
LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 16:58 #2661

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Thanks for the warnings I have to clean.

Ok, it is not a real blank page. All these notices don't stop the execution.
Can you see the footer of the page ?

It should be something else.
I don't have enough informations to answer you.

Is your code really executed until setRedirect() ?
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 25 Jun 2012 17:07 #2662

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
yes i see the footer

i create the code is corectly executed ....

test.ingall-niger.org/ma-maison-a-moi
login with "LJ01" passw "123"
Ce sont les fils qui font les cordes
ingall-niger.org
Last Edit: 25 Jun 2012 17:09 by LJ01.
The administrator has disabled public write access.

Re: conflict with new template 27 Jun 2012 12:59 #2708

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
i precise my layout "batiment" is the file constructor of pdf view ...
LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 27 Jun 2012 13:47 #2709

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Forget it, you cannot do this.

you should better call your code from the view.html.php file.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 27 Jun 2012 17:16 #2711

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
in my view html
if ($access->get('core.edit') || ($isNew && $access->get('core.create') || $access->get('core.edit.own')))
		$bar->appendButton( 'Standard', "edit", "Imprimer", "printy", false);

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
Last Edit: 27 Jun 2012 17:17 by LJ01.
The administrator has disabled public write access.

Re: conflict with new template 29 Jun 2012 18:33 #2719

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
i precise
my controller is batenergiepart, my view is batenergiepartiem (the edit form of batenergiepart view)
lj
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 02 Jul 2012 08:54 #2726

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
When you press the toolbar button, the printy() function of your controller is called.

If you have parrent::display() at the end, then it calls a template.
In your case, don't call the template, but finish with a jexit()

To understand better, try to echo some text in that function. But if you have setted a redirection, then you will not see the echos because it loads another page.

Now, in the printy() function of your controller, add the code that receive the parameters and call the pdf creation class or code.

Hope it helps. It is really easy.


If you still have problems, send me your code because I cannot understand where is your issue.
Regards.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 02 Jul 2012 13:58 #2731

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
thanks
it's ok with the echo+txt

my problem is called the pdf file who contain the code for pdf creation (this file is in an another directory with the librairies fpdf)
and i want that some data of my register go in the pdf (these data has calculed in the view because it's more easy than the model ...

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.
Time to create page: 0.122 seconds

Get Started