Clean dead code

This commit is contained in:
Laurent Destailleur 2017-01-03 11:22:03 +01:00
parent 728dd3f7b3
commit febd23fe41
10 changed files with 20 additions and 363 deletions

View File

@ -253,23 +253,19 @@ class Skeleton_Class extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
//$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new Skeleton_ClassLine();
$line = new self($this->db);
$line->id = $obj->rowid;
$line->prop1 = $obj->field1;
$line->prop2 = $obj->field2;
//$this->lines[$line->id] = $line;
//...
}
$this->db->free($resql);

View File

@ -39,10 +39,6 @@ class Cpaiement
*/
public $table_element = 'c_paiement';
/**
* @var CpaiementLine[] Lines
*/
public $lines = array();
/**
*/
@ -227,84 +223,6 @@ class Cpaiement
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.id,';
$sql .= " t.code,";
$sql .= " t.libelle,";
$sql .= " t.type,";
$sql .= " t.active,";
$sql .= " t.accountancy_code,";
$sql .= " t.module";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new CpaiementLine();
$line->id = $obj->id;
$line->code = $obj->code;
$line->libelle = $obj->libelle;
$line->type = $obj->type;
$line->active = $obj->active;
$line->accountancy_code = $obj->accountancy_code;
$line->module = $obj->module;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*

View File

@ -43,11 +43,6 @@ class Cchargesociales
*/
public $table_element = 'c_chargesociales';
/**
* @var CchargesocialesLine[] Lines
*/
public $lines = array();
/**
*/
@ -237,83 +232,6 @@ class Cchargesociales
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= " t.id,";
$sql .= " t.libelle,";
$sql .= " t.deductible,";
$sql .= " t.active,";
$sql .= " t.code,";
$sql .= " t.fk_pays,";
$sql .= " t.module,";
$sql .= " t.accountancy_code";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new CchargesocialesLine();
$line->id = $obj->id;
$line->libelle = $obj->libelle;
$line->deductible = $obj->deductible;
$line->active = $obj->active;
$line->code = $obj->code;
$line->fk_pays = $obj->fk_pays;
$line->module = $obj->module;
$line->accountancy_code = $obj->accountancy_code;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*

View File

@ -380,7 +380,7 @@ class EcmFiles //extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();

View File

@ -596,7 +596,7 @@ class CommandeFournisseurDispatch extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();

View File

@ -28,6 +28,5 @@ CREATE TABLE llx_website_page
content mediumtext, -- text is not enough in size
status integer,
date_creation datetime,
date_modification datetime,
tms timestamp
) ENGINE=innodb;

View File

@ -256,92 +256,6 @@ class Productlot extends CommonObject
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.entity,";
$sql .= " t.fk_product,";
$sql .= " t.batch,";
$sql .= " t.eatby,";
$sql .= " t.sellby,";
$sql .= " t.datec,";
$sql .= " t.tms,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,";
$sql .= " t.import_key";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
$sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql))
{
$line = new ProductlotLine();
$line->id = $obj->rowid;
$line->entity = $obj->entity;
$line->fk_product = $obj->fk_product;
$line->batch = $obj->batch;
$line->eatby = $this->db->jdate($obj->eatby);
$line->sellby = $this->db->jdate($obj->sellby);
$line->datec = $this->db->jdate($obj->datec);
$line->tms = $this->db->jdate($obj->tms);
$line->fk_user_creat = $obj->fk_user_creat;
$line->fk_user_modif = $obj->fk_user_modif;
$line->import_key = $obj->import_key;
$this->lines[$line->id] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*
@ -595,32 +509,3 @@ class Productlot extends CommonObject
}
/**
* Class ProductlotLine
*/
class ProductlotLine
{
/**
* @var int ID
*/
public $id;
/**
* @var mixed Sample line property 1
*/
public $entity;
public $fk_product;
public $batch;
public $eatby = '';
public $sellby = '';
public $datec = '';
public $tms = '';
public $fk_user_creat;
public $fk_user_modif;
public $import_key;
/**
* @var mixed Sample line property 2
*/
}

View File

@ -273,7 +273,7 @@ class ProductStockEntrepot extends CommonObject
// "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch
if (!empty($sortfield)) $sql .= $this->db->order($sortfield,$sortorder);
if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit, $offset);
$lines = array();

View File

@ -286,7 +286,6 @@ class Website extends CommonObject
$sql = 'SELECT';
$sql .= ' t.rowid,';
$sql .= " t.entity,";
$sql .= " t.ref,";
$sql .= " t.description,";
@ -296,7 +295,6 @@ class Website extends CommonObject
$sql .= " t.date_creation,";
$sql .= " t.date_modification,";
$sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
@ -314,7 +312,7 @@ class Website extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->records = array();
@ -323,7 +321,7 @@ class Website extends CommonObject
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new WebsiteLine();
$line = new self($this->db);
$line->id = $obj->rowid;
@ -650,50 +648,3 @@ class Website extends CommonObject
}
/**
* Class WebsiteLine
*/
class WebsiteLine
{
/**
* @var int ID
*/
public $id;
/**
* @var int
*/
public $entity;
/**
* @var string
*/
public $ref;
/**
* @var string
*/
public $description;
/**
* @var int
*/
public $status;
/**
* @var int
*/
public $fk_default_home;
/**
* @var string
*/
public $virtualhost;
/**
* @var mixed
*/
public $date_creation;
/**
* @var mixed
*/
public $date_modification;
/**
* @var mixed
*/
public $tms = '';
}

View File

@ -57,7 +57,6 @@ class WebsitePage extends CommonObject
public $status;
public $date_creation;
public $date_modification;
public $tms;
/**
*/
@ -203,8 +202,7 @@ class WebsitePage extends CommonObject
$sql .= " t.content,";
$sql .= " t.status,";
$sql .= " t.date_creation,";
$sql .= " t.date_modification,";
$sql .= " t.tms";
$sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $website_id) {
@ -231,9 +229,6 @@ class WebsitePage extends CommonObject
$this->status = $obj->status;
$this->date_creation = $this->db->jdate($obj->date_creation);
$this->date_modification = $this->db->jdate($obj->date_modification);
$this->tms = $this->db->jdate($obj->tms);
}
$this->db->free($resql);
@ -278,8 +273,7 @@ class WebsitePage extends CommonObject
$sql .= " t.content,";
$sql .= " t.status,";
$sql .= " t.date_creation,";
$sql .= " t.date_modification,";
$sql .= " t.tms";
$sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
$sql .= ' WHERE t.fk_website = '.$websiteid;
// Manage filter
@ -301,9 +295,8 @@ class WebsitePage extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();
$resql = $this->db->query($sql);
if ($resql) {
@ -311,7 +304,7 @@ class WebsitePage extends CommonObject
while ($obj = $this->db->fetch_object($resql))
{
$record = new WebsitePage($this->db);
$record = new self($this->db);
$record->id = $obj->rowid;
$record->fk_website = $obj->fk_website;
@ -323,7 +316,6 @@ class WebsitePage extends CommonObject
$record->status = $obj->status;
$record->date_creation = $this->db->jdate($obj->date_creation);
$record->date_modification = $this->db->jdate($obj->date_modification);
$record->tms = $this->db->jdate($obj->tms);
//var_dump($record->id);
$records[$record->id] = $record;
}
@ -389,8 +381,7 @@ class WebsitePage extends CommonObject
$sql .= ' content = '.(isset($this->content)?"'".$this->db->escape($this->content)."'":"null").',';
$sql .= ' status = '.(isset($this->status)?$this->status:"null").',';
$sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').',';
$sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').',';
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'");
$sql .= ' tms = '.(dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : "'".$this->db->idate(dol_now())."'");
$sql .= ' WHERE rowid=' . $this->id;
$this->db->begin();
@ -633,18 +624,17 @@ class WebsitePage extends CommonObject
{
$this->id = 0;
$now=dol_now();
$this->fk_website = '';
$this->pageurl = '';
$this->title = '';
$this->description = '';
$this->keywords = '';
$this->content = '';
$this->title = 'My Page';
$this->description = 'This is my page';
$this->keywords = 'keyword1, keyword2';
$this->content = '<html><body>This is a html content</body></html>';
$this->status = '';
$this->date_creation = '';
$this->date_modification = '';
$this->tms = '';
$this->date_creation = $now - (24 * 30 * 3600);
$this->date_modification = $now - (24 * 7 * 3600);
}
}