diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9d17d65910d..d31d53e1d6f 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -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')); diff --git a/htdocs/core/actions_fetchobject.inc.php b/htdocs/core/actions_fetchobject.inc.php new file mode 100644 index 00000000000..463b3113c2a --- /dev/null +++ b/htdocs/core/actions_fetchobject.inc.php @@ -0,0 +1,40 @@ + + * Copyright (C) 2015 Frederic France + * + * 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 . + * 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=''; + } +} diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 846323ba6b6..7b05b4a20c6 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -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')); diff --git a/htdocs/includes/tcpdi/fpdf_tpl.php b/htdocs/includes/tcpdi/fpdf_tpl.php index 8482ba336ed..0c60a6ed6f3 100644 --- a/htdocs/includes/tcpdi/fpdf_tpl.php +++ b/htdocs/includes/tcpdi/fpdf_tpl.php @@ -29,13 +29,21 @@ class FPDF_TPL extends FPDF { * @var int */ var $tpl = 0; +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * "In Template"-Flag * @var boolean */ var $_intpl = false; +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Nameprefix of Templates used in Resources-Dictonary * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / @@ -47,14 +55,22 @@ class FPDF_TPL extends FPDF { * @var array */ var $_res = array(); +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Last used Template data * * @var array */ var $lastUsedTemplateData = array(); +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Start a Template * @@ -74,11 +90,19 @@ class FPDF_TPL extends FPDF { * @return int The ID of new created Template */ function beginTemplate($x = null, $y = null, $w = null, $h = null) { +<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); return; } +======= + if (is_subclass_of($this, 'TCPDF')) { + $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); + return; + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->page <= 0) $this->error("You have to add a page to fpdf first!"); @@ -116,7 +140,11 @@ class FPDF_TPL extends FPDF { ); $this->SetAutoPageBreak(false); +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 // Define own high and width to calculate possitions correct $this->h = $h; $this->w = $w; @@ -127,6 +155,7 @@ class FPDF_TPL extends FPDF { if ($this->CurrentFont) { $fontkey = $this->FontFamily . $this->FontStyle; +<<<<<<< HEAD $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); @@ -135,6 +164,16 @@ class FPDF_TPL extends FPDF { return $this->tpl; } +======= + $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; + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * End Template * @@ -143,6 +182,7 @@ class FPDF_TPL extends FPDF { * @return mixed If a template is opened, the ID is returned. If not a false is returned. */ function endTemplate() { +<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); @@ -150,6 +190,15 @@ class FPDF_TPL extends FPDF { if ($this->_intpl) { $this->_intpl = false; +======= + 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; +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $tpl =& $this->tpls[$this->tpl]; $this->SetXY($tpl['o_x'], $tpl['o_y']); $this->tMargin = $tpl['o_tMargin']; @@ -158,6 +207,7 @@ class FPDF_TPL extends FPDF { $this->h = $tpl['o_h']; $this->w = $tpl['o_w']; $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); +<<<<<<< HEAD $this->FontFamily = $tpl['o_FontFamily']; $this->FontStyle = $tpl['o_FontStyle']; @@ -168,12 +218,28 @@ class FPDF_TPL extends FPDF { if ($fontkey) $this->CurrentFont =& $this->fonts[$fontkey]; +======= + + $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]; + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 return $this->tpl; } else { return false; } } +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Use a Template in current Page or other Template * @@ -193,6 +259,7 @@ class FPDF_TPL extends FPDF { */ function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { if ($this->page <= 0) +<<<<<<< HEAD $this->error('You have to add a page first!'); if (!isset($this->tpls[$tplidx])) @@ -206,10 +273,26 @@ class FPDF_TPL extends FPDF { $w = $tpl['w']; $h = $tpl['h']; +======= + $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']; + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($_x == null) $_x = 0; if ($_y == null) $_y = 0; +<<<<<<< HEAD $_x += $tpl['x']; $_y += $tpl['y']; @@ -218,6 +301,16 @@ class FPDF_TPL extends FPDF { $_w = $wh['w']; $_h = $wh['h']; +======= + + $_x += $tpl['x']; + $_y += $tpl['y']; + + $wh = $this->getTemplateSize($tplidx, $_w, $_h); + $_w = $wh['w']; + $_h = $wh['h']; + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $tData = array( 'x' => $this->x, 'y' => $this->y, @@ -229,6 +322,7 @@ class FPDF_TPL extends FPDF { 'ty' => ($this->h - $_y - $_h), 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) ); +<<<<<<< HEAD $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)); @@ -238,6 +332,17 @@ class FPDF_TPL extends FPDF { return array('w' => $_w, '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); + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Get The calculated Size of a Template * @@ -255,12 +360,17 @@ class FPDF_TPL extends FPDF { $tpl =& $this->tpls[$tplidx]; $w = $tpl['w']; $h = $tpl['h']; +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($_w == 0 and $_h == 0) { $_w = $w; $_h = $h; } +<<<<<<< HEAD if($_w == 0) $_w = $_h * $w / $h; if($_h == 0) @@ -269,11 +379,22 @@ class FPDF_TPL extends FPDF { return array("w" => $_w, "h" => $_h); } +======= + if($_w == 0) + $_w = $_h * $w / $h; + if($_h == 0) + $_h = $_w * $h / $w; + + return array("w" => $_w, "h" => $_h); + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF/TCPDF-Documentation ;-) */ public function SetFont($family, $style = '', $size = 0) { if (is_subclass_of($this, 'TCPDF')) { +<<<<<<< HEAD $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); } @@ -282,17 +403,32 @@ class FPDF_TPL extends FPDF { $fontkey = $this->FontFamily . $this->FontStyle; +======= + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); + } + + parent::SetFont($family, $style, $size); + + $fontkey = $this->FontFamily . $this->FontStyle; + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) { $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } else { $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; } } +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF/TCPDF-Documentation ;-) */ function Image( +<<<<<<< HEAD $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() @@ -302,22 +438,41 @@ class FPDF_TPL extends FPDF { return call_user_func_array(array($this, 'TCPDF::Image'), $args); } +======= + $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); + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $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]; } +<<<<<<< HEAD return $ret; } +======= + + return $ret; + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * See FPDF-Documentation ;-) * * AddPage is not available when you're "in" a template. */ function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { +<<<<<<< HEAD if (is_subclass_of($this, 'TCPDF')) { $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); @@ -326,6 +481,16 @@ class FPDF_TPL extends FPDF { if ($this->_intpl) $this->Error('Adding pages in templates isn\'t possible!'); +======= + 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!'); + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 parent::AddPage($orientation, $format); } @@ -334,6 +499,7 @@ class FPDF_TPL extends FPDF { */ function Link($x, $y, $w, $h, $link, $spaces = 0) { if (is_subclass_of($this, 'TCPDF')) { +<<<<<<< HEAD $args = func_get_args(); return call_user_func_array(array($this, 'TCPDF::Link'), $args); } @@ -350,10 +516,29 @@ class FPDF_TPL extends FPDF { return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); } +======= + $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); + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) $this->Error('Adding links in templates aren\'t possible!'); return parent::AddLink(); } +<<<<<<< HEAD function SetLink($link, $y = 0, $page = -1) { if (is_subclass_of($this, 'TCPDF')) { @@ -361,16 +546,30 @@ class FPDF_TPL extends FPDF { return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); } +======= + + 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); + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if ($this->_intpl) $this->Error('Setting links in templates aren\'t possible!'); parent::SetLink($link, $y, $page); } +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Private Method that writes the form xobjects */ function _putformxobjects() { $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; +<<<<<<< HEAD reset($this->tpls); foreach($this->tpls AS $tplidx => $tpl) { @@ -378,6 +577,15 @@ class FPDF_TPL extends FPDF { $this->_newobj(); $this->tpls[$tplidx]['n'] = $this->n; $this->_out('<<'.$filter.'/Type /XObject'); +======= + 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'); +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 $this->_out('/Subtype /Form'); $this->_out('/FormType 1'); $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', @@ -390,12 +598,17 @@ class FPDF_TPL extends FPDF { // ury ($tpl['h'] - $tpl['y']) * $this->k )); +<<<<<<< HEAD +======= + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 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 )); } +<<<<<<< HEAD $this->_out('/Resources '); @@ -413,12 +626,32 @@ class FPDF_TPL extends FPDF { 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'); +======= + + $this->_out('/Resources '); + + $this->_out('<_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'); +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 } 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('>>'); +<<<<<<< HEAD } $this->_out('>>'); @@ -428,6 +661,17 @@ class FPDF_TPL extends FPDF { } } +======= + } + $this->_out('>>'); + + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + } + } + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 /** * Overwritten to add _putformxobjects() after _putimages() * @@ -436,10 +680,17 @@ class FPDF_TPL extends FPDF { parent::_putimages(); $this->_putformxobjects(); } +<<<<<<< HEAD function _putxobjectdict() { parent::_putxobjectdict(); +======= + + function _putxobjectdict() { + parent::_putxobjectdict(); + +>>>>>>> 4af26c119faa512590faad44e296b64b6c9e1978 if (count($this->tpls)) { foreach($this->tpls as $tplidx => $tpl) { $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index cd19f25a97c..990640f0fee 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -50,6 +50,9 @@ $hookmanager->initHooks(array('projectcard','globalcard')); $object = new Project($db); $extrafields = new ExtraFields($db); + +// Load object +//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Can use generic include because when creating a project, ref is defined and we dont want error if fetch fails from ref. if ($id > 0 || ! empty($ref)) { $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database @@ -103,10 +106,10 @@ if (empty($reshook)) header("Location: ".$backtopage); exit; } - + $action = ''; } - + if ($action == 'add' && $user->rights->projet->creer) { $error=0; @@ -120,7 +123,7 @@ if (empty($reshook)) setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors'); $error++; } - + if (! $error) { $error=0; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index bc8f5b3098c..594ed1feffe 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -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; diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index cb9742e40cc..bb381ae8b38 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -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 diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 540ceff1bfa..85e8406d708 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -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 ''; @@ -130,36 +118,36 @@ print ''; -print ''; +print ''; print ''; // Visibility print ''; // Statut -print ''; +print ''; // Date start print ''; // Date end print ''; print '
'.$langs->trans("Ref").''; // 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 '
'.$langs->trans("Label").''.$project->title.'
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("ThirdParty").''; -if (! empty($project->thirdparty->id)) print $project->thirdparty->getNomUrl(1); +if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1); else print ' '; print '
'.$langs->trans("Visibility").''; -if ($project->public) print $langs->trans('SharedProject'); +if ($object->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("Status").''.$project->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("DateStart").''; -print dol_print_date($project->date_start,'day'); +print dol_print_date($object->date_start,'day'); print '
'.$langs->trans("DateEnd").''; -print dol_print_date($project->date_end,'day'); +print dol_print_date($object->date_end,'day'); print '
'; @@ -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 ''; print ''.$langs->trans("Status").''; print ''; - $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 '
'; - 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 ''.$langs->trans("AddProp").''; + print ''.$langs->trans("AddProp").''; } if ($key == 'order' && ! empty($conf->commande->enabled) && $user->rights->commande->creer) { - print ''.$langs->trans("AddCustomerOrder").''; + print ''.$langs->trans("AddCustomerOrder").''; } if ($key == 'invoice' && ! empty($conf->facture->enabled) && $user->rights->facture->creer) { - print ''.$langs->trans("AddCustomerInvoice").''; + print ''.$langs->trans("AddCustomerInvoice").''; } } - if ($project->thirdparty->fournisseur) + if ($object->thirdparty->fournisseur) { if ($key == 'order_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->creer) { - print ''.$langs->trans("AddSupplierInvoice").''; + print ''.$langs->trans("AddSupplierInvoice").''; } if ($key == 'invoice_supplier' && ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->creer) { - print ''.$langs->trans("AddSupplierOrder").''; + print ''.$langs->trans("AddSupplierOrder").''; } } } @@ -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; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 81acd18e301..181aeca032a 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -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; diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index b581ca01be9..6e7b0e28595 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -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; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 1b69fd5757e..96618fc83d4 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -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);