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

View File

@ -74,10 +74,10 @@ class FPDF_TPL extends FPDF {
* @return int The ID of new created Template * @return int The ID of new created Template
*/ */
function beginTemplate($x = null, $y = null, $w = null, $h = null) { function beginTemplate($x = null, $y = null, $w = null, $h = null) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); $this->Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.');
return; return;
} }
if ($this->page <= 0) if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!"); $this->error("You have to add a page to fpdf first!");
@ -127,9 +127,9 @@ class FPDF_TPL extends FPDF {
if ($this->CurrentFont) { if ($this->CurrentFont) {
$fontkey = $this->FontFamily . $this->FontStyle; $fontkey = $this->FontFamily . $this->FontStyle;
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
$this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
} }
return $this->tpl; return $this->tpl;
@ -143,9 +143,9 @@ class FPDF_TPL extends FPDF {
* @return mixed If a template is opened, the ID is returned. If not a false is returned. * @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/ */
function endTemplate() { function endTemplate() {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args);
} }
if ($this->_intpl) { if ($this->_intpl) {
@ -160,13 +160,13 @@ class FPDF_TPL extends FPDF {
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
$this->FontFamily = $tpl['o_FontFamily']; $this->FontFamily = $tpl['o_FontFamily'];
$this->FontStyle = $tpl['o_FontStyle']; $this->FontStyle = $tpl['o_FontStyle'];
$this->FontSizePt = $tpl['o_FontSizePt']; $this->FontSizePt = $tpl['o_FontSizePt'];
$this->FontSize = $tpl['o_FontSize']; $this->FontSize = $tpl['o_FontSize'];
$fontkey = $this->FontFamily . $this->FontStyle; $fontkey = $this->FontFamily . $this->FontStyle;
if ($fontkey) if ($fontkey)
$this->CurrentFont =& $this->fonts[$fontkey]; $this->CurrentFont =& $this->fonts[$fontkey];
return $this->tpl; return $this->tpl;
} else { } else {
@ -193,7 +193,7 @@ class FPDF_TPL extends FPDF {
*/ */
function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) {
if ($this->page <= 0) if ($this->page <= 0)
$this->error('You have to add a page first!'); $this->error('You have to add a page first!');
if (!isset($this->tpls[$tplidx])) if (!isset($this->tpls[$tplidx]))
$this->error('Template does not exist!'); $this->error('Template does not exist!');
@ -261,10 +261,10 @@ class FPDF_TPL extends FPDF {
$_h = $h; $_h = $h;
} }
if($_w == 0) if($_w == 0)
$_w = $_h * $w / $h; $_w = $_h * $w / $h;
if($_h == 0) if($_h == 0)
$_h = $_w * $h / $w; $_h = $_w * $h / $w;
return array("w" => $_w, "h" => $_h); return array("w" => $_w, "h" => $_h);
} }
@ -274,8 +274,8 @@ class FPDF_TPL extends FPDF {
*/ */
public function SetFont($family, $style = '', $size = 0) { public function SetFont($family, $style = '', $size = 0) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); return call_user_func_array(array($this, 'TCPDF::SetFont'), $args);
} }
parent::SetFont($family, $style, $size); parent::SetFont($family, $style, $size);
@ -293,13 +293,13 @@ class FPDF_TPL extends FPDF {
* See FPDF/TCPDF-Documentation ;-) * See FPDF/TCPDF-Documentation ;-)
*/ */
function Image( function Image(
$file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false,
$dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false,
$hidden = false, $fitonpage = false, $alt = false, $altimgs = array() $hidden = false, $fitonpage = false, $alt = false, $altimgs = array()
) { ) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Image'), $args); return call_user_func_array(array($this, 'TCPDF::Image'), $args);
} }
$ret = parent::Image($file, $x, $y, $w, $h, $type, $link); $ret = parent::Image($file, $x, $y, $w, $h, $type, $link);
@ -318,9 +318,9 @@ class FPDF_TPL extends FPDF {
* AddPage is not available when you're "in" a template. * AddPage is not available when you're "in" a template.
*/ */
function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); return call_user_func_array(array($this, 'TCPDF::AddPage'), $args);
} }
if ($this->_intpl) if ($this->_intpl)
@ -334,8 +334,8 @@ class FPDF_TPL extends FPDF {
*/ */
function Link($x, $y, $w, $h, $link, $spaces = 0) { function Link($x, $y, $w, $h, $link, $spaces = 0) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::Link'), $args); return call_user_func_array(array($this, 'TCPDF::Link'), $args);
} }
if ($this->_intpl) if ($this->_intpl)
@ -345,9 +345,9 @@ class FPDF_TPL extends FPDF {
} }
function AddLink() { function AddLink() {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); return call_user_func_array(array($this, 'TCPDF::AddLink'), $args);
} }
if ($this->_intpl) if ($this->_intpl)
@ -356,9 +356,9 @@ class FPDF_TPL extends FPDF {
} }
function SetLink($link, $y = 0, $page = -1) { function SetLink($link, $y = 0, $page = -1) {
if (is_subclass_of($this, 'TCPDF')) { if (is_subclass_of($this, 'TCPDF')) {
$args = func_get_args(); $args = func_get_args();
return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); return call_user_func_array(array($this, 'TCPDF::SetLink'), $args);
} }
if ($this->_intpl) if ($this->_intpl)
@ -371,13 +371,13 @@ class FPDF_TPL extends FPDF {
*/ */
function _putformxobjects() { function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : ''; $filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls); reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) { foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj(); $this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n; $this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject'); $this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form'); $this->_out('/Subtype /Form');
$this->_out('/FormType 1'); $this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
@ -400,31 +400,31 @@ class FPDF_TPL extends FPDF {
$this->_out('/Resources '); $this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<'); $this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');
$this->_out('>>'); $this->_out('>>');
} }
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || 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'])) isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{ {
$this->_out('/XObject <<'); $this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image) foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');
} }
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R');
} }
$this->_out('>>'); $this->_out('>>');
} }
$this->_out('>>'); $this->_out('>>');
$this->_out('/Length ' . strlen($p) . ' >>'); $this->_out('/Length ' . strlen($p) . ' >>');
$this->_putstream($p); $this->_putstream($p);
$this->_out('endobj'); $this->_out('endobj');
} }
} }

View File

@ -49,17 +49,8 @@ $hookmanager->initHooks(array('projectcard','globalcard'));
$object = new Project($db); $object = new Project($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
if ($id > 0 || ! empty($ref)) // Load object
{ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
$ret = $object->fetch($id,$ref);
if ($ret > 0) {
$object->fetch_thirdparty();
$id=$object->id;
} else {
setEventMessage($object->error, 'errors');
$action='';
}
}
// Security check // Security check
$socid=GETPOST('socid'); $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 //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$object = new Project($db); $object = new Project($db);
if ($id > 0 || ! empty($ref))
{ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
$object->fetch($id,$ref);
$object->fetch_thirdparty();
$id=$object->id;
}
// Security check // Security check
$socid=0; $socid=0;

View File

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

View File

@ -80,21 +80,9 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
$projectid=$id; // For backward compatibility $projectid=$id; // For backward compatibility
$project = new Project($db); $object = new Project($db);
if ($id > 0 || ! empty($ref))
{ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not includ_once
$ret=$project->fetch($id,$ref);
if ($ret > 0)
{
$projectid=$project->id;
$project->fetch_thirdparty();
}
else
{
setEventMessages($project->error, $project->errors, 'errors');
$action='';
}
}
// Security check // Security check
$socid=0; $socid=0;
@ -116,10 +104,10 @@ $formfile = new FormFile($db);
$userstatic=new User($db); $userstatic=new User($db);
// To verify role of users // To verify role of users
$userAccess = $project->restrictedProjectArea($user); $userAccess = $object->restrictedProjectArea($user);
$head=project_prepare_head($project); $head=project_prepare_head($object);
dol_fiche_head($head, 'element', $langs->trans("Project"),0,($project->public?'projectpub':'project')); dol_fiche_head($head, 'element', $langs->trans("Project"),0,($object->public?'projectpub':'project'));
print '<table class="border" width="100%">'; 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. // Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire) if (! $user->rights->projet->all->lire)
{ {
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0); $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
$project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'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 '</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>'; 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;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Visibility // Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>'; 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'); else print $langs->trans('PrivateProject');
print '</td></tr>'; print '</td></tr>';
// Statut // 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 // Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td>'; 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>'; print '</td></tr>';
// Date end // Date end
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>'; 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 '</td></tr>';
print '</table>'; print '</table>';
@ -263,18 +251,18 @@ if ($action=="addelement")
{ {
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect"); $elementselectid = GETPOST("elementselect");
$result=$project->update_element($tablename, $elementselectid); $result=$object->update_element($tablename, $elementselectid);
if ($result<0) { if ($result<0) {
setEventMessage($project->error,'errors'); setEventMessage($object->error,'errors');
} }
}elseif ($action == "unlink") { }elseif ($action == "unlink") {
$tablename = GETPOST("tablename"); $tablename = GETPOST("tablename");
$elementselectid = GETPOST("elementselect"); $elementselectid = GETPOST("elementselect");
$result = $project->remove_element($tablename, $elementselectid); $result = $object->remove_element($tablename, $elementselectid);
if ($result < 0) { 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)); 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)) if (! $selectList || ($selectList<0))
{ {
setEventMessages($formproject->error,$formproject->errors,'errors'); setEventMessages($formproject->error,$formproject->errors,'errors');
@ -352,7 +340,7 @@ foreach ($listofreferent as $key => $value)
else print '<td width="120"></td>'; else print '<td width="120"></td>';
print '<td align="right" width="200">'.$langs->trans("Status").'</td>'; print '<td align="right" width="200">'.$langs->trans("Status").'</td>';
print '</tr>'; 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) if (is_array($elementarray) && count($elementarray)>0)
{ {
$var=true; $var=true;
@ -544,32 +532,32 @@ foreach ($listofreferent as $key => $value)
*/ */
print '<div class="tabsAction">'; 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) 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) 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) 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) 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) 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); $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)) if (count($elementarray)>0 && is_array($elementarray))
{ {
$var=true; $var=true;

View File

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

View File

@ -47,12 +47,11 @@ $object = new Project($db);
$taskstatic = new Task($db); $taskstatic = new Task($db);
$extrafields_project = new ExtraFields($db); $extrafields_project = new ExtraFields($db);
$extrafields_task = 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)) if ($id > 0 || ! empty($ref))
{ {
$object->fetch($id,$ref);
$id=$object->id;
$ref=$object->ref;
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element); $extralabels_projet=$extrafields_project->fetch_name_optionals_label($object->table_element);
$extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element); $extralabels_task=$extrafields_task->fetch_name_optionals_label($taskstatic->table_element);