to use specific tpl within his own theme

This commit is contained in:
Grand Philippe 2012-04-28 18:24:52 +02:00
parent 7977897fd8
commit 922703879f

View File

@ -2,7 +2,8 @@
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -865,93 +866,93 @@ abstract class CommonObject
} }
} }
/** /**
* Change the payments methods * Change the payments methods
* *
* @param int $id Id of new payment method * @param int $id Id of new payment method
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function setPaymentMethods($id) function setPaymentMethods($id)
{ {
dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); dol_syslog(get_class($this).'::setPaymentMethods('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe') if ($this->statut >= 0 || $this->element == 'societe')
{ {
// TODO uniformize field name // TODO uniformize field name
$fieldname = 'fk_mode_reglement'; $fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement'; if ($this->element == 'societe') $fieldname = 'mode_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id; $sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->mode_reglement_id = $id; $this->mode_reglement_id = $id;
$this->mode_reglement = $id; // for compatibility $this->mode_reglement = $id; // for compatibility
return 1; return 1;
} }
else else
{ {
dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
} }
else else
{ {
dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible'); dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut; $this->error='Status of the object is incompatible '.$this->statut;
return -2; return -2;
} }
} }
/** /**
* Change the payments terms * Change the payments terms
* *
* @param int $id Id of new payment terms * @param int $id Id of new payment terms
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function setPaymentTerms($id) function setPaymentTerms($id)
{ {
dol_syslog(get_class($this).'::setPaymentTerms('.$id.')'); dol_syslog(get_class($this).'::setPaymentTerms('.$id.')');
if ($this->statut >= 0 || $this->element == 'societe') if ($this->statut >= 0 || $this->element == 'societe')
{ {
// TODO uniformize field name // TODO uniformize field name
$fieldname = 'fk_cond_reglement'; $fieldname = 'fk_cond_reglement';
if ($this->element == 'societe') $fieldname = 'cond_reglement'; if ($this->element == 'societe') $fieldname = 'cond_reglement';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.$id; $sql .= ' SET '.$fieldname.' = '.$id;
$sql .= ' WHERE rowid='.$this->id; $sql .= ' WHERE rowid='.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->cond_reglement_id = $id; $this->cond_reglement_id = $id;
$this->cond_reglement = $id; // for compatibility $this->cond_reglement = $id; // for compatibility
return 1; return 1;
} }
else else
{ {
dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
} }
else else
{ {
dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible'); dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
$this->error='Status of the object is incompatible '.$this->statut; $this->error='Status of the object is incompatible '.$this->statut;
return -2; return -2;
} }
} }
/** /**
* Define delivery address * Define delivery address
* *
* @param int $id Address id * @param int $id Address id
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function setDeliveryAddress($id) function setDeliveryAddress($id)
{ {
$fieldname = 'fk_adresse_livraison'; $fieldname = 'fk_adresse_livraison';
if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
@ -962,14 +963,14 @@ abstract class CommonObject
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->fk_delivery_address = $id; $this->fk_delivery_address = $id;
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
return -1; return -1;
} }
} }
/** /**
@ -1851,18 +1852,18 @@ abstract class CommonObject
$sql.= " WHERE rowid=".$elementId; $sql.= " WHERE rowid=".$elementId;
dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::setStatut sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->db->commit(); $this->db->commit();
$this->statut = $status; $this->statut = $status;
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
@ -2145,35 +2146,35 @@ abstract class CommonObject
return $nb; return $nb;
} }
/** /**
* Set extra parameters * Set extra parameters
* *
* @return void * @return void
*/ */
function setExtraParameters() function setExtraParameters()
{ {
$this->db->begin(); $this->db->begin();
$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null); $extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null"); $sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (! $resql)
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
else else
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} }
@ -2378,7 +2379,14 @@ abstract class CommonObject
global $form,$bcnd,$var; global $form,$bcnd,$var;
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_create.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php');
}
} }
/** /**
@ -2398,7 +2406,14 @@ abstract class CommonObject
global $form,$bcnd,$var; global $form,$bcnd,$var;
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_create.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_create.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php');
}
} }
@ -2537,12 +2552,26 @@ abstract class CommonObject
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
// Use global variables + $seller and $buyer // Use global variables + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_view.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_view.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_view.tpl.php');
}
} }
else else
{ {
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_view.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_view.tpl.php');
}
} }
} }
@ -2552,12 +2581,26 @@ abstract class CommonObject
if ($line->fk_product > 0) if ($line->fk_product > 0)
{ {
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/predefinedproductline_edit.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_edit.tpl.php');
}
} }
else else
{ {
// Use global variables + $dateSelector + $seller and $buyer // Use global variables + $dateSelector + $seller and $buyer
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/freeproductline_edit.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_edit.tpl.php');
}
} }
} }
} }
@ -2696,8 +2739,15 @@ abstract class CommonObject
$this->tpl['price'] = price($line->subprice); $this->tpl['price'] = price($line->subprice);
$this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;'; $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : '&nbsp;';
$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;'; $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php'); if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/originproductline.tpl.php"))
{
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/originproductline.tpl.php");
}
else
{
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
}
} }
} }