From febd23fe41a16440310f9ff80ef85d21f4067dd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jan 2017 11:22:03 +0100 Subject: [PATCH] Clean dead code --- dev/skeletons/skeleton_class.class.php | 8 +- .../compta/paiement/class/cpaiement.class.php | 82 ------------- .../sociales/class/cchargesociales.class.php | 82 ------------- htdocs/ecm/class/ecmfiles.class.php | 2 +- .../fournisseur.commande.dispatch.class.php | 2 +- .../mysql/tables/llx_website_pages.sql | 1 - .../product/stock/class/productlot.class.php | 115 ------------------ .../class/productstockentrepot.class.php | 2 +- htdocs/websites/class/website.class.php | 53 +------- htdocs/websites/class/websitepage.class.php | 36 ++---- 10 files changed, 20 insertions(+), 363 deletions(-) diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 1c9b8cb52bf..01b48c35f75 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -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); diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 5428f4abdbf..d6031ae1685 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -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 * diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 538754e63b2..a44b820c8ea 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -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 * diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 431e27dd38f..2089a5b3bb8 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -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(); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 0464a9fb51f..7fd56f81aac 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -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(); diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_pages.sql index f1ea66bb56a..982420dd507 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_pages.sql @@ -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; diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 6128f8dcf17..0d92afe96e0 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -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 - */ - -} diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 2f4af887e3e..048be66461f 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -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(); diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php index 2d5f13570b8..51a61d90112 100644 --- a/htdocs/websites/class/website.class.php +++ b/htdocs/websites/class/website.class.php @@ -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 = ''; - -} diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index abd604bd3d9..883b6495c53 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -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 = 'This is a html content'; $this->status = ''; - $this->date_creation = ''; - $this->date_modification = ''; - $this->tms = ''; - - + $this->date_creation = $now - (24 * 30 * 3600); + $this->date_modification = $now - (24 * 7 * 3600); } }