fetch object in include file

This commit is contained in:
frederic34 2015-03-02 17:54:35 +01:00
parent 73afe1513d
commit 4af26c119f
11 changed files with 548 additions and 548 deletions

View File

@ -84,10 +84,7 @@ $extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref)) {
$ret = $object->fetch($id, $ref);
$ret = $object->fetch_thirdparty();
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordercard','globalcard'));

View File

@ -0,0 +1,40 @@
<?php
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/actions_fetchobject.inc.php
* \brief Code for actions on fetching object page
*/
// $action must be defined
// $object must be defined (object is loaded in this file with fetch)
// $id or $ref must be defined (object is loaded in this file with fetch)
if ($id > 0 || ! empty($ref))
{
$ret = $object->fetch($id,$ref);
if ($ret > 0) {
$object->fetch_thirdparty();
$id=$object->id;
} else {
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}

View File

@ -76,10 +76,7 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co
$object = new Expedition($db);
// Load object
if ($id > 0 || ! empty($ref))
{
$ret=$object->fetch($id, $ref);
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('expeditioncard','globalcard'));

View File

@ -1,460 +1,460 @@
<?php
//
// FPDF_TPL - Version 1.2.3
//
// Copyright 2004-2013 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends FPDF {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
if (is_subclass_of($this, 'TCPDF')) {
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
return;
}
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'o_FontFamily' => $this->FontFamily,
'o_FontStyle' => $this->FontStyle,
'o_FontSizePt' => $this->FontSizePt,
'o_FontSize' => $this->FontSize,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
$this->SetRightMargin($this->w - $w + $this->rMargin);
if ($this->CurrentFont) {
$fontkey = $this->FontFamily . $this->FontStyle;
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
}
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize'];
$fontkey = $this->FontFamily . $this->FontStyle;
if ($fontkey)
$this->CurrentFont =& $this->fonts[$fontkey];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
if ($this->page <= 0)
$this->error('You have to add a page first!');
if (!isset($this->tpls[$tplidx]))
$this->error('Template does not exist!');
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w / $w),
'scaleY' => ($_h / $h),
'tx' => $_x,
'ty' => ($this->h - $_y - $_h),
'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h)
);
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array('w' => $_w, 'h' => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w = 0, $_h = 0) {
if (!isset($this->tpls[$tplidx]))
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w == 0)
$_w = $_h * $w / $h;
if($_h == 0)
$_h = $_w * $h / $w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
public function SetFont($family, $style = '', $size = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
}
parent::SetFont($family, $style, $size);
$fontkey = $this->FontFamily . $this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
}
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
}
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link);
}
function AddLink() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
}
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y = 0, $page = -1) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
}
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'] * $this->k,
// lly
-$tpl['y'] * $this->k,
// urx
($tpl['w'] + $tpl['x']) * $this->k,
// ury
($tpl['h'] - $tpl['y']) * $this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state == 2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s . "\n";
} else {
parent::_out($s);
}
}
}
<?php
//
// FPDF_TPL - Version 1.2.3
//
// Copyright 2004-2013 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends FPDF {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x = null, $y = null, $w = null, $h = null) {
if (is_subclass_of($this, 'TCPDF')) {
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
return;
}
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'o_FontFamily' => $this->FontFamily,
'o_FontStyle' => $this->FontStyle,
'o_FontSizePt' => $this->FontSizePt,
'o_FontSize' => $this->FontSize,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x + $this->lMargin, $y + $this->tMargin);
$this->SetRightMargin($this->w - $w + $this->rMargin);
if ($this->CurrentFont) {
$fontkey = $this->FontFamily . $this->FontStyle;
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
}
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize'];
$fontkey = $this->FontFamily . $this->FontStyle;
if ($fontkey)
$this->CurrentFont =& $this->fonts[$fontkey];
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
if ($this->page <= 0)
$this->error('You have to add a page first!');
if (!isset($this->tpls[$tplidx]))
$this->error('Template does not exist!');
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w / $w),
'scaleY' => ($_h / $h),
'tx' => $_x,
'ty' => ($this->h - $_y - $_h),
'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h)
);
$this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array('w' => $_w, 'h' => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w = 0, $_h = 0) {
if (!isset($this->tpls[$tplidx]))
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w == 0)
$_w = $_h * $w / $h;
if($_h == 0)
$_h = $_w * $h / $w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
public function SetFont($family, $style = '', $size = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
}
parent::SetFont($family, $style, $size);
$fontkey = $this->FontFamily . $this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args);
}
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
return $ret;
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
}
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces = 0) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args);
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link);
}
function AddLink() {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
}
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y = 0, $page = -1) {
if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
}
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'] * $this->k,
// lly
-$tpl['y'] * $this->k,
// urx
($tpl['w'] + $tpl['x']) * $this->k,
// ury
($tpl['h'] - $tpl['y']) * $this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state == 2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s . "\n";
} else {
parent::_out($s);
}
}
}

View File

@ -49,17 +49,8 @@ $hookmanager->initHooks(array('projectcard','globalcard'));
$object = new Project($db);
$extrafields = new ExtraFields($db);
if ($id > 0 || ! empty($ref))
{
$ret = $object->fetch($id,$ref);
if ($ret > 0) {
$object->fetch_thirdparty();
$id=$object->id;
} else {
setEventMessage($object->error, 'errors');
$action='';
}
}
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Security check
$socid=GETPOST('socid');

View File

@ -41,12 +41,8 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id,$ref);
$object->fetch_thirdparty();
$id=$object->id;
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Security check
$socid=0;

View File

@ -46,11 +46,11 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result=restrictedArea($user,'projet',$id,'');
$object = new Project($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id,$ref);
$object->fetch_thirdparty();
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
if ($id > 0 || ! empty($ref)) {
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
// Get parameters

View File

@ -80,21 +80,9 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$projectid=$id; // For backward compatibility
$project = new Project($db);
if ($id > 0 || ! empty($ref))
{
$ret=$project->fetch($id,$ref);
if ($ret > 0)
{
$projectid=$project->id;
$project->fetch_thirdparty();
}
else
{
setEventMessages($project->error, $project->errors, 'errors');
$action='';
}
}
$object = new Project($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Security check
$socid=0;
@ -116,10 +104,10 @@ $formfile = new FormFile($db);
$userstatic=new User($db);
// To verify role of users
$userAccess = $project->restrictedProjectArea($user);
$userAccess = $object->restrictedProjectArea($user);
$head=project_prepare_head($project);
dol_fiche_head($head, 'element', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$head=project_prepare_head($object);
dol_fiche_head($head, 'element', $langs->trans("Project"),0,($object->public?'projectpub':'project'));
print '<table class="border" width="100%">';
@ -130,36 +118,36 @@ print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
$projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
$object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
print $form->showrefnav($project, 'ref', $linkback, 1, 'ref', 'ref');
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
if (! empty($project->thirdparty->id)) print $project->thirdparty->getNomUrl(1);
if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
print dol_print_date($project->date_start,'day');
print dol_print_date($object->date_start,'day');
print '</td></tr>';
// Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($project->date_end,'day');
print dol_print_date($object->date_end,'day');
print '</td></tr>';
print '</table>';
@ -263,18 +251,18 @@ if ($action=="addelement")
{
$tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect");
$result=$project->update_element($tablename, $elementselectid);
$result=$object->update_element($tablename, $elementselectid);
if ($result<0) {
setEventMessage($project->error,'errors');
setEventMessage($object->error,'errors');
}
}elseif ($action == "unlink") {
$tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect");
$result = $project->remove_element($tablename, $elementselectid);
$result = $object->remove_element($tablename, $elementselectid);
if ($result < 0) {
setEventMessage($project->error, 'errors');
setEventMessage($object->error, 'errors');
}
}
@ -317,7 +305,7 @@ foreach ($listofreferent as $key => $value)
print_titre($langs->trans($title));
$selectList=$formproject->select_element($tablename,$project->thirdparty->id);
$selectList=$formproject->select_element($tablename,$object->thirdparty->id);
if (! $selectList || ($selectList<0))
{
setEventMessages($formproject->error,$formproject->errors,'errors');
@ -352,7 +340,7 @@ foreach ($listofreferent as $key => $value)
else print '<td width="120"></td>';
print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
print '</tr>';
$elementarray = $project->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
if (is_array($elementarray) && count($elementarray)>0)
{
$var=true;
@ -544,32 +532,32 @@ foreach ($listofreferent as $key => $value)
*/
print '<div class="tabsAction">';
if ($project->statut > 0)
if ($object->statut > 0)
{
if ($project->thirdparty->prospect || $project->thirdparty->client)
if ($object->thirdparty->prospect || $object->thirdparty->client)
{
if ($key == 'propal' && ! empty($conf->propal->enabled) && $user->rights->propale->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$project->thirdparty->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddProp").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal.php?socid='.$object->thirdparty->id.'&amp;action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'">'.$langs->trans("AddProp").'</a>';
}
if ($key == 'order' && ! empty($conf->commande->enabled) && $user->rights->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$project->thirdparty->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->thirdparty->id.'&amp;action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'">'.$langs->trans("AddCustomerOrder").'</a>';
}
if ($key == 'invoice' && ! empty($conf->facture->enabled) && $user->rights->facture->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$project->thirdparty->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?socid='.$object->thirdparty->id.'&amp;action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'">'.$langs->trans("AddCustomerInvoice").'</a>';
}
}
if ($project->thirdparty->fournisseur)
if ($object->thirdparty->fournisseur)
{
if ($key == 'order_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?socid='.$project->thirdparty->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?socid='.$object->thirdparty->id.'&amp;action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'">'.$langs->trans("AddSupplierInvoice").'</a>';
}
if ($key == 'invoice_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?socid='.$project->thirdparty->id.'&amp;action=create&amp;origin='.$project->element.'&amp;originid='.$project->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?socid='.$object->thirdparty->id.'&amp;action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'">'.$langs->trans("AddSupplierOrder").'</a>';
}
}
}
@ -607,7 +595,7 @@ foreach ($listofreferent as $key => $value)
{
$element = new $classname($db);
$elementarray = $project->get_element_list($key, $tablename);
$elementarray = $object->get_element_list($key, $tablename);
if (count($elementarray)>0 && is_array($elementarray))
{
$var=true;

View File

@ -38,12 +38,8 @@ $mine = ($mode == 'mine' ? 1 : 0);
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id,$ref);
$object->fetch_thirdparty();
$id=$object->id;
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Security check
$socid=0;

View File

@ -36,12 +36,8 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db);
if ($id > 0 || ! empty($ref))
{
$object->fetch($id,$ref);
$object->fetch_thirdparty();
$id=$object->id;
}
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
// Security check
$socid=0;

View File

@ -47,12 +47,11 @@ $object = new Project($db);
$taskstatic = new Task($db);
$extrafields_project = new ExtraFields($db);
$extrafields_task = new ExtraFields($db);
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
if ($id > 0 || ! empty($ref))
{
$object->fetch($id,$ref);
$id=$object->id;
$ref=$object->ref;
// fetch optionals attributes and labels
$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);