debug
This commit is contained in:
parent
dfb9ae234c
commit
baf1acb4fd
@ -25,6 +25,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
|||||||
|
|
||||||
class CoreObject extends CommonObject {
|
class CoreObject extends CommonObject {
|
||||||
|
|
||||||
|
public $db;
|
||||||
|
|
||||||
protected $__fields=array();
|
protected $__fields=array();
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -33,8 +35,6 @@ class CoreObject extends CommonObject {
|
|||||||
*/
|
*/
|
||||||
function __construct(DoliDB &$db) {
|
function __construct(DoliDB &$db) {
|
||||||
|
|
||||||
$this->db = &$db;
|
|
||||||
|
|
||||||
$this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ?
|
$this->date_0 = '1001-01-01 00:00:00'; //TODO there is a solution for this ?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,27 +179,55 @@ class CoreObject extends CommonObject {
|
|||||||
return implode(',', $keys);
|
return implode(',', $keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function set_vars_by_db(&$obj){
|
||||||
|
|
||||||
|
foreach ($this->__fields as $field=>$info) {
|
||||||
|
if($this->is_date($info)){
|
||||||
|
if($obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00')$this->{$field} = 0;
|
||||||
|
else $this->{$field} = strtotime($obj->{$field});
|
||||||
|
}
|
||||||
|
elseif($this->is_array($info)){
|
||||||
|
$this->{$field} = @unserialize($obj->{$field});
|
||||||
|
//HACK POUR LES DONNES NON UTF8
|
||||||
|
if($this->{$field}===FALSE)@unserialize(utf8_decode($obj->{$field}));
|
||||||
|
}
|
||||||
|
elseif($this->is_int($info)){
|
||||||
|
$this->{$field} = (int)$obj->{$field};
|
||||||
|
}
|
||||||
|
elseif($this->is_float($info)){
|
||||||
|
$this->{$field} = (double)$obj->{$field};
|
||||||
|
}
|
||||||
|
elseif($this->is_null($info)){
|
||||||
|
$val = $obj->{$field};
|
||||||
|
// zero is not null
|
||||||
|
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0')?null:$val);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->{$field} = $obj->{$field};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function fetch($id, $loadChild = true) {
|
public function fetch($id, $loadChild = true) {
|
||||||
|
|
||||||
if(empty($id)) return false;
|
if(empty($id)) return false;
|
||||||
|
|
||||||
$sql = 'SELECT '.$this->get_field_list().',datec,tms
|
$sql = 'SELECT '.$this->get_field_list().',datec,tms
|
||||||
FROM '.$this->table_element.'
|
FROM '.MAIN_DB_PREFIX.$this->table_element.'
|
||||||
WHERE rowid='.$id;
|
WHERE rowid='.$id;
|
||||||
|
|
||||||
$res = $this->db->query( $sql );
|
|
||||||
var_dump($sql);
|
var_dump($sql);
|
||||||
if($obj = $db->fetch_object($res)) {
|
$res = $this->db->query( $sql );
|
||||||
|
|
||||||
|
if($obj = $this->db->fetch_object($res)) {
|
||||||
$this->rowid=$id;
|
$this->rowid=$id;
|
||||||
|
|
||||||
$this->set_vars_by_db($db);
|
$this->set_vars_by_db($obj);
|
||||||
|
|
||||||
$this->datec=$this->db->idate($obj->datec);
|
$this->datec=$this->db->idate($obj->datec);
|
||||||
$this->tms=$this->db->idate($obj->tms);
|
$this->tms=$this->db->idate($obj->tms);
|
||||||
|
|
||||||
if($loadChild) $this->loadChild($db);
|
if($loadChild) $this->fetchChild();
|
||||||
|
|
||||||
$this->run_trigger($db, 'load');
|
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
@ -208,6 +236,38 @@ class CoreObject extends CommonObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fetchChild() {
|
||||||
|
if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) {
|
||||||
|
|
||||||
|
foreach($this->childtables as &$childTable) {
|
||||||
|
|
||||||
|
$className = ucfirst($childTable);
|
||||||
|
|
||||||
|
$this->{$className}=array();
|
||||||
|
|
||||||
|
$sql = " SELECT rowid FROM ".MAIN_DB_PREFIX.$childTable." WHERE ".$this->fk_element."=".$this->rowid;
|
||||||
|
$res = $this->db->query($sql);
|
||||||
|
if($res) {
|
||||||
|
|
||||||
|
while($obj = $db->fetch_object($res)) {
|
||||||
|
|
||||||
|
$o=new $className($this->db);
|
||||||
|
$o->fetch($obj->rowid);
|
||||||
|
|
||||||
|
$this->{$className}[] = $o;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -820,7 +820,6 @@ class Listview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function parse_sql( &$THeader, &$TField,&$TParam, $sql) {
|
private function parse_sql( &$THeader, &$TField,&$TParam, $sql) {
|
||||||
global $db;
|
|
||||||
|
|
||||||
$this->sql = $this->limitSQL($sql, $TParam);
|
$this->sql = $this->limitSQL($sql, $TParam);
|
||||||
|
|
||||||
@ -828,9 +827,13 @@ class Listview {
|
|||||||
|
|
||||||
$this->THideFlip = array_flip($TParam['hide']);
|
$this->THideFlip = array_flip($TParam['hide']);
|
||||||
|
|
||||||
$res = $db->query($this->sql);
|
$res = $this->db->query($this->sql);
|
||||||
|
if($res!==false) {
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_DEBUG);
|
||||||
|
|
||||||
$first=true;
|
$first=true;
|
||||||
while($currentLine = $db->fetch_object($res)) {
|
while($currentLine = $this->db->fetch_object($res)) {
|
||||||
if($first) {
|
if($first) {
|
||||||
$this->init_entete($THeader, $TParam, $currentLine);
|
$this->init_entete($THeader, $TParam, $currentLine);
|
||||||
$first = false;
|
$first = false;
|
||||||
@ -841,4 +844,9 @@ class Listview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
dol_syslog(get_class($this)."::parse_sql id=".$this->id." sql=".$this->sql, LOG_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,6 +69,8 @@ class Inventory extends CoreObject
|
|||||||
,'title'=>array('type'=>'string')
|
,'title'=>array('type'=>'string')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public $db;
|
||||||
|
|
||||||
function __construct(DoliDB &$db)
|
function __construct(DoliDB &$db)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -292,15 +294,22 @@ class Inventory extends CoreObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNomUrl($picto = 1) {
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
$title = !empty($this->title) ? $this->title : $langs->trans('inventoryTitle').' '.$this->id;
|
||||||
|
|
||||||
|
return '<a href="'.dol_buildpath('/inventory/inventory.php?id='.$this->id, 1).'">'.($picto ? img_picto('','object_list.png','',0).' ' : '').$title.'</a>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static function getLink($id) {
|
static function getLink($id) {
|
||||||
global $langs,$db;
|
global $langs,$db;
|
||||||
|
|
||||||
$i = new Inventory($db);
|
$i = new Inventory($db);
|
||||||
$i->fetch($id, false);
|
$i->fetch($id, false);
|
||||||
|
|
||||||
$title = !empty($i->title) ? $i->title : $langs->trans('inventoryTitle').' '.$i->id;
|
return $i->getNomUrl();
|
||||||
|
|
||||||
return '<a href="'.dol_buildpath('/inventory/inventory.php?id='.$i->id.'&action=view', 1).'">'.img_picto('','object_list.png','',0).' '.$title.'</a>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +318,7 @@ class Inventory extends CoreObject
|
|||||||
|
|
||||||
if($type=='All') {
|
if($type=='All') {
|
||||||
|
|
||||||
$sql="SELECT i.rowid, e.label, i.date_inventory, i.fk_warehouse, i.date_cre, i.date_maj, i.status
|
$sql="SELECT i.rowid, e.label, i.date_inventory, i.fk_warehouse, i.datec, i.tms, i.status
|
||||||
FROM ".MAIN_DB_PREFIX."inventory i
|
FROM ".MAIN_DB_PREFIX."inventory i
|
||||||
LEFT JOIN ".MAIN_DB_PREFIX."entrepot e ON (e.rowid = i.fk_warehouse)
|
LEFT JOIN ".MAIN_DB_PREFIX."entrepot e ON (e.rowid = i.fk_warehouse)
|
||||||
WHERE i.entity=".(int) $conf->entity;
|
WHERE i.entity=".(int) $conf->entity;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user