Welcome, Guest
Username: Password: Remember me

TOPIC: [solved] Creating a PDF with Cook

Re: conflict with new template 02 Jul 2012 14:59 #2732

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Still in the controller :

Try to understand how to load your datas (2-3 lines)

then send them to your PDF class.

Just curious, wich PDF class are you using ? FPDF ?
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 02 Jul 2012 17:56 #2734

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
using Fpdf
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 18:01 #2735

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I ask this question because I am currently searching for a better PDF class.
FPDF is good but very limited in deed.

(For example : impossible to output richtext formated or css stylized like)
Coding is now a piece of cake
The administrator has disabled public write access.

Re: conflict with new template 02 Jul 2012 18:54 #2739

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
it's ok for call params of my config and data forms
$params = JComponentHelper::getParams('com_batenergie');
		$label_b = $params->get('label_b', 1);
		$surface = trim ($_POST['surface']);

but how to display my file containing pdf class ?
and in my view there are data caculate not send with the methof POSt ...
LJ
thank you for your patience
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 19:26 #2740

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
So I exceptionally give you the answer using your correct context (COPY and PASTE)

Wherever you want in your component :

To get your list :
$model = JModel::getInstance('BatenergiepartModel', 'BatenergieModel');
$items = $model->getItems();
echo("<pre>"); print_r($items); echo("</pre>");

To get an item (myItemId = id of the concerned item)
$model = JModel::getInstance('BatenergiepartitemModel', 'BatenergieModel');
$model->setId($myItemId);
$item = $model->getItem();
echo("<pre>"); print_r($item); echo("</pre>");

The best is to place it in your controller.
All the datas are ready for your PDF

Then, if you want some joined datas, or ordering, etc... you can use some functions on your model before the call of getItem(s) ()
$model->addJoin("LEFT JOIN #__xxx ....");
$model->addSelect("_mytable_.title AS _mytable_title");
$model->addOrder("a.title");
...
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: LJ01

Re: conflict with new template 03 Jul 2012 12:57 #2745

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
thks
sorry i don't know how to call my pdf class or file ...
LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: conflict with new template 04 Jul 2012 09:35 #2752

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
To this stage, I cannot help you more.

I am working alone for Cook Self Service, and I really need to consacrate to the new coming version 2.0

I hope you will find your answer here or somewhere else, but don't worry, FPDF is really cool I know it well. The big advantage of this class is the simplicity of it, even if sometimes it lacks on functionalities.

You need to work with a graphic approch (defining x, y) for each element you have to place.
You need to redefine the color and text size (and ...) for every text to write or shape to draw, because all these informations are stored in global, so it conflicts if you don't care.
That are the main advices for FPDF.

My advice is also to create a different super class (herit FPDF) for every different PDF you have to do. Even if you only need one type of PDF.

In this super class, create all the pre-made functionalities for your document.

For example, if you want to create a title style, create a function H1($text) for instance.
This function will instanciate the font-size, the color, the position of it ...

But as you see, we are out of the box, so I can continue to help you regarding Cook.

Have fun.
I really like to play with PDF, it is fantastic even if it is low level of programing (no pre-made nice classes of plugins).

Hope it helps.
Coding is now a piece of cake
Last Edit: 04 Jul 2012 11:13 by admin.
The administrator has disabled public write access.

Re: conflict with new template 04 Jul 2012 17:02 #2761

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
i understand really your time
but my pdf file is good, for example on joomla1.5 this is an joint

i want just know how to call this file or call the fpdf class in a function for my controller

good job for the 2.0 version, your tool is very great

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

Re: Creating a PDF with Cook 05 Jul 2012 08:07 #2762

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
this is write that i using...
function printy()
	{   
		require('/my_url/print/batiment.php');

		Jexit();
	}


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

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:03 #2914

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
This is the fucntion using
    function printy()
    {   
        $model = $this->getModel('batenergiepartitem');
        $item = $model->getItem();
             //echo("<pre>"); print_r($item); echo("</pre>");
    
   require('......./components/com_batenergie/print/batiment.php');
      
          $pdf->Output();   
    }
it display corectkly the pdf file but models data aren't displaying
perhaps the "echo print-r is good

how to do displaying models datas in /batiment.php
i have tested
$this->
$item->
$this->batenergiepartitem
$item->batenergiepartitem

without success ...

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

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:09 #2915

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
can you dump the model ?

echo("<pre>"); print_r($model); echo("</pre>");
Coding is now a piece of cake
The administrator has disabled public write access.

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:12 #2916

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
the model displaying with echo but not in pdf file
LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:15 #2917

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
<?php

/**                               ______________________________________________
*                          o O   |                                              |
*                 (((((  o      <  Generated with Cook           (100% Vitamin) |
*                ( o o )         |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version		1.6
* @package		Batenergie
* @subpackage	Batenergiepart
* @copyright	Copyright 2012, All rights reserved
* @author		LJ01 - http://lau.jarry.free.fr - lau.jarry@free.fr
* @license		GNU/GPL
*
* /!\  Joomla! is free software.
* This version may have been modified pursuant to the GNU General Public License,
* and as distributed it includes or is derivative of works licensed under the
* GNU General Public License or other free or open source software licenses.
*
*             .oooO  Oooo.     See COPYRIGHT.php for copyright notices and details.
*             (   )  (   )
* -------------\ (----) /----------------------------------------------------------- +
*               \_)  (_/
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );


jimport('joomla.application.component.model');
require_once(JPATH_ADMIN_BATENERGIE .DS.'classes'.DS.'jmodel.item.php');

/**
 * Batenergie Component Batenergiepartitem Model
 *
 * @package		Joomla
 * @subpackage	Batenergie
 *
 */
class BatenergieModelBatenergiepartitem extends BatenergieModelItem
{
	var $_name_plur = 'batenergiepart';
	var $params;



	/**
	 * Constructor
	 *
	 */
	function __construct()
	{
		parent::__construct();
		$this->_modes = array_merge($this->_modes, array(''));

	}

	/**
	 * Method to initialise the batenergiepartitem data
	 *
	 * @access	private
	 * @return	boolean	True on success
	 */
	function _initData()
	{
		if (empty($this->_data))
		{
			//Default values shown in the form for new item creation
			$data = new stdClass();

			$data->id = 0;
			$data->attribs = null;
			$data->author = null;
			$data->name = null;
			$data->adresse = null;
			$data->commune = null;
			$data->image = null;
			$data->publish = null;
			$data->date = null;
			$data->equipement = JRequest::getVar('filter_equipement', $this->getState('filter.equipement'));
			$data->type = null;
			$data->year = null;
			$data->surface = null;
			$data->volume = null;
			$data->puissance = null;
			$data->puissancelec = null;
			$data->description = null;
			$data->travaux = null;
			$data->fioul = null;
			$data->gas = null;
			$data->gasp = null;
			$data->elec = null;
			$data->elek = null;
			$data->boisp = null;
			$data->boisg = null;
			$data->boisb = null;
			$data->eau09 = null;
			$data->eau10 = null;
			$data->eau11 = null;
			$data->eau12 = null;
			$data->eauprix09 = null;
			$data->eauprix10 = null;
			$data->eauprix11 = null;
			$data->eauprix12 = null;
			$data->dpe09_fioul = null;
			$data->dpe10_fioul = null;
			$data->dpe11_fioul = null;
			$data->dpe12_fioul = null;
			$data->prix09_fioul = null;
			$data->prix10_fioul = null;
			$data->prix11_fioul = null;
			$data->prix12_fioul = null;
			$data->dpe09_gas = null;
			$data->dpe10_gas = null;
			$data->dpe11_gas = null;
			$data->dpe12_gas = null;
			$data->prix09_gas = null;
			$data->prix10_gas = null;
			$data->prix11_gas = null;
			$data->prix12_gas = null;
			$data->dpe09_gasp = null;
			$data->dpe10_gasp = null;
			$data->dpe11_gasp = null;
			$data->dpe12_gasp = null;
			$data->prix09_gasp = null;
			$data->prix10_gasp = null;
			$data->prix11_gasp = null;
			$data->prix12_gasp = null;
			$data->dpe09_elec = null;
			$data->dpe10_elec = null;
			$data->dpe11_elec = null;
			$data->dpe12_elec = null;
			$data->prix09_elec = null;
			$data->prix10_elec = null;
			$data->prix11_elec = null;
			$data->prix12_elec = null;
			$data->dpe09_elek = null;
			$data->dpe10_elek = null;
			$data->dpe11_elek = null;
			$data->dpe12_elek = null;
			$data->prix09_elek = null;
			$data->prix10_elek = null;
			$data->prix11_elek = null;
			$data->prix12_elek = null;
			$data->dpe09_boisp = null;
			$data->dpe10_boisp = null;
			$data->dpe11_boisp = null;
			$data->dpe12_boisp = null;
			$data->prix09_boisp = null;
			$data->prix10_boisp = null;
			$data->prix11_boisp = null;
			$data->prix12_boisp = null;
			$data->dpe09_boisg = null;
			$data->dpe10_boisg = null;
			$data->dpe11_boisg = null;
			$data->dpe12_boisg = null;
			$data->prix09_boisg = null;
			$data->prix10_boisg = null;
			$data->prix11_boisg = null;
			$data->prix12_boisg = null;
			$data->dpe09_boisb = null;
			$data->dpe10_boisb = null;
			$data->dpe11_boisb = null;
			$data->dpe12_boisb = null;
			$data->prix09_boisb = null;
			$data->prix10_boisb = null;
			$data->prix11_boisb = null;
			$data->prix12_boisb = null;
			$data->dpe13_fioul = null;
			$data->dpe14_fioul = null;
			$data->dpe15_fioul = null;
			$data->prix13_fioul = null;
			$data->prix14_fioul = null;
			$data->prix15_fioul = null;
			$data->dpe13_gas = null;
			$data->dpe14_gas = null;
			$data->dpe15_gas = null;
			$data->prix13_gas = null;
			$data->prix14_gas = null;
			$data->prix15_gas = null;
			$data->dpe13_gasp = null;
			$data->dpe14_gasp = null;
			$data->dpe15_gasp = null;
			$data->prix13_gasp = null;
			$data->prix14_gasp = null;
			$data->prix15_gasp = null;
			$data->dpe13_elec = null;
			$data->dpe14_elec = null;
			$data->dpe15_elec = null;
			$data->prix13_elec = null;
			$data->prix14_elec = null;
			$data->prix15_elec = null;
			$data->dpe13_elek = null;
			$data->dpe14_elek = null;
			$data->dpe15_elek = null;
			$data->prix13_elek = null;
			$data->prix14_elek = null;
			$data->prix15_elek = null;
			$data->dpe13_boisp = null;
			$data->dpe14_boisp = null;
			$data->dpe15_boisp = null;
			$data->prix13_boisp = null;
			$data->prix14_boisp = null;
			$data->prix15_boisp = null;
			$data->dpe13_boisg = null;
			$data->dpe14_boisg = null;
			$data->dpe15_boisg = null;
			$data->prix13_boisg = null;
			$data->prix14_boisg = null;
			$data->prix15_boisg = null;
			$data->dpe13_boisb = null;
			$data->dpe14_boisb = null;
			$data->dpe15_boisb = null;
			$data->prix13_boisb = null;
			$data->prix14_boisb = null;
			$data->prix15_boisb = null;
			$data->eau13 = null;
			$data->eau14 = null;
			$data->eau15 = null;
			$data->eauprix13 = null;
			$data->eauprix14 = null;
			$data->eauprix15 = null;

			$this->_data = $data;

			return (boolean) $this->_data;
		}
		return true;
	}


	/**
	 * Method to auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @return	void
	 * @since	1.6
	 */
	protected function populateState($ordering = null, $direction = null)
	{
		// Initialise variables.
		$app = JFactory::getApplication();
		$session = JFactory::getSession();

		parent::populateState();
	}


	/**
	 * Method to build a the query string for the Batenergiepartitem
	 *
	 * @access public
	 * @return integer
	 */
	function _buildQuery()
	{
		if (isset($this->_active['predefined']))
		switch($this->_active['predefined'])
		{
			case 'batenergiepartitem': return $this->_buildQuery_batenergiepartitem(); break;
		}
			$query = 'SELECT a.*'
					. 	$this->_buildQuerySelect()
					.	' FROM `#__batenergie_batenergiepart` AS a'
					. 	$this->_buildQueryJoin()
					. 	$this->_buildQueryWhere()
					.	'';
		return $query;
	}

	function _buildQuery_batenergiepartitem()
	{
			$query = 'SELECT a.*'
					.	' , _author_.name AS `_author_name`'
					.	' , _author_.username AS `_author_username`'
					.	' , _author_.email AS `_author_email`'
					.	' , _author_.usertype AS `_author_usertype`'
					. 	$this->_buildQuerySelect()
					.	' FROM `#__batenergie_batenergiepart` AS a'
					.	' LEFT JOIN `#__users` AS _author_ ON _author_.id = a.author'
					. 	$this->_buildQueryJoin()
					. 	$this->_buildQueryWhere()
					.	'';
		return $query;
	}



	function _buildQueryWhere($where = array())
	{
		$app = JFactory::getApplication();
		$acl = BatenergieHelper::getAcl();

		$where[] = 'a.id = '.(int) $this->_id;

		return parent::_buildQueryWhere($where);
	}

	/**
	 * Method to update batenergiepartitem in mass
	 *
	 * @access	public
	 * @return	boolean	True on success
	 */
	function update($cids, $data)
	{
		foreach($cids as $cid)
		{
			if ($cid == 0)
				continue;
			$data['id'] = $cid;
			if (!$this->save($data))
				return false;
		}
		return true;
	}

	/**
	 * Method to save the batenergiepartitem
	 *
	 * @access	public
	 * @return	boolean	True on success
	 */
	function save($data)
	{
		$row = $this->getTable();

		//Convert data from a stdClass
		if (get_class($data) == 'stdClass')
			$data = JArrayHelper::fromObject($data);

		//Current id if unspecified
		if ($data['id'] != null)
			$id = $data['id'];
		else if (($this->_id != null) && ($this->_id > 0))
			$id = $this->_id;


		//Load the current object, in order to process an update
		if (isset($id))
			$row->load($id);

		//Some security checks
		$acl = BatenergieHelper::getAcl();

		//Secure the published tag if not allowed to change
		if (isset($data['publish']) && !$acl->get('core.edit.state'))
			unset($data['publish']);

		//Secure the author key if not allowed to change
		if (isset($data['author']) && !$acl->get('core.edit'))
			unset($data['author']);


		// Bind the form fields to the batenergie table
		$ignore = array();
		if (!$row->bind($data, $ignore)) {
			JError::raiseWarning(1000, $this->_db->getErrorMsg());
			return false;
		}

		// Make sure the batenergie table is valid
		if (!$row->check()) {
			JError::raiseWarning(1000, $this->_db->getErrorMsg());
			return false;
		}

		// Store the batenergie table to the database
		if (!$row->store())
        {
			JError::raiseWarning(1000, $this->_db->getErrorMsg());
			return false;
		}

		$this->_id = $row->id;
		$this->_data = $row;

		return true;
	}
	/**
	 * Method to delete a batenergiepartitem
	 *
	 * @access	public
	 * @return	boolean	True on success
	 */
	function delete($cid = array())
	{
		$result = false;

		if (count( $cid ))
		{
			JArrayHelper::toInteger($cid);
			$cids = implode( ',', $cid );

			$query = 'DELETE FROM `#__batenergie_batenergiepart`'
				. ' WHERE id IN ( '.$cids.' )';
			$this->_db->setQuery( $query );
			if(!$this->_db->query()) {
				JError::raiseWarning(1000, $this->_db->getErrorMsg());
				return false;
			}
		}

		return true;
	}
	/**
	 * Method to (un)publish a batenergiepartitem
	 *
	 * @access	public
	 * @return	boolean	True on success
	 */
	function publish($cid = array(), $publish = 1)
	{
		$user 	= JFactory::getUser();

		if (count( $cid ))
		{
			JArrayHelper::toInteger($cid);
			$cids = implode( ',', $cid );

			$query = 'UPDATE #__batenergie_batenergiepart'
				. ' SET `publish` = '.(int) $publish
				. ' WHERE id IN ( '.$cids.' )'
			;
			$this->_db->setQuery( $query );
			if (!$this->_db->query()) {
				JError::raiseWarning(1000, $this->_db->getErrorMsg());
				return false;
			}
		}

		return true;
	}
	/**
	 * Method to Convert the parameter fields into objects.
	 *
	 * @access public
	 * @return void
	 */
	protected function populateParams()
	{
		parent::populateParams();

		if (!isset($this->_data))
			return;

		$item = $this->_data;
		$acl = BatenergieHelper::getAcl();
		$isAuthor = ($item->author == JFactory::getUser()->id);

		if ($acl->get('core.edit.state')
			|| (bool)$item->publish
			|| ($acl->get('core.view.own') && $isAuthor))
			$item->params->set('access-view', true);

		if ($acl->get('core.edit')
			|| ($acl->get('core.edit.own') && $isAuthor))
			$item->params->set('access-edit', true);

		if ($acl->get('core.delete')
			|| ($acl->get('core.delete.own') && $isAuthor))
			$item->params->set('access-delete', true);
	}

	  function nbrbatiment()
	  {    	                                    
	  $user = JFactory::getUser();
	  $userid = $user->id;
		                       
		$database =& JFactory::getDBO();	 	 
		$database->setQuery( "SELECT profile_value 
					FROM #__user_profiles 
					WHERE user_id='$userid' 
					AND profile_key='profile.address1'" );
			if (!$database->query()) {
			echo $database->stderr();
			return false;
 			}
	  return $result = $database->loadResult();
	  } 

	  function imageprofile()
	  {    	                                    
	  $user = JFactory::getUser();
	  $userid = $user->id;
		                       
		$database =& JFactory::getDBO();	 	 
		$database->setQuery( "SELECT profile_value 
					FROM #__user_profiles 
					WHERE user_id='$userid' 
					AND profile_key='profilepicture.file'" );
			if (!$database->query()) {
			echo $database->stderr();
			return false;
 			}
	  return $result = $database->loadResult();
	  } 

	/*function userprofile()
	{   $user = JFactory::getUser();

	    $db = JFactory::getDbo();
            $db->setQuery(
                'SELECT profile_key, profile_value FROM #__user_profiles' .
                ' WHERE user_id = '.(int) $user." AND profile_key LIKE 'profile.address1'" .
                ' ORDER BY ordering'
            );
            $userprofile = $db->loadRowList();
	    //$db->setQuery( $query );
	    //$userprofile = $db->loadResult();

	    return $userprofile;
	}*/
}
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:23 #2918

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Are you using a predefined query ?

Try this in your view BEFORE the getItem();
$model->active('predefined', 'batenergiepartitem');


If your datas are accessible, it is a problem how you treat them.
I cannot help you more.

Is somebody want to help here ?
Coding is now a piece of cake
The administrator has disabled public write access.

Re: [solved] Creating a PDF with Cook 27 Jul 2012 10:52 #2919

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
actually never treatments
it's data of my database from 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.143 seconds

Get Started