From ae2ab3276da65f894435fe8626b03e64185ba72c Mon Sep 17 00:00:00 2001 From: atm-ph Date: Sun, 26 Mar 2017 14:37:25 +0200 Subject: [PATCH] Refactoring and class/method documentation --- htdocs/core/class/coreobject.class.php | 10 +++--- htdocs/core/class/listview.class.php | 37 ++++++++++++---------- htdocs/inventory/class/inventory.class.php | 7 ++-- htdocs/inventory/inventory.php | 6 ++-- htdocs/inventory/lib/inventory.lib.php | 5 +++ 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 92da1604dca..396caf029cc 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -287,11 +287,11 @@ class CoreObject extends CommonObject } elseif($this->is_int($info)) { - $this->{$field} = (int)$obj->{$field}; + $this->{$field} = (int) $obj->{$field}; } elseif($this->is_float($info)) { - $this->{$field} = (double)$obj->{$field}; + $this->{$field} = (double) $obj->{$field}; } elseif($this->is_null($info)) { @@ -604,7 +604,7 @@ class CoreObject extends CommonObject * @param string $format Output date format * @return string */ - public function get_date($field, $format='') + public function getDate($field, $format='') { if(empty($this->{$field})) return ''; else @@ -620,7 +620,7 @@ class CoreObject extends CommonObject * @param string $date formatted date to convert * @return mixed */ - public function set_date($field, $date) + public function setDate($field, $date) { if (empty($date)) { @@ -648,7 +648,7 @@ class CoreObject extends CommonObject { if($this->checkFieldType($key, 'date')) { - $this->set_date($key, $value); + $this->setDate($key, $value); } else if( $this->checkFieldType($key, 'array')) { diff --git a/htdocs/core/class/listview.class.php b/htdocs/core/class/listview.class.php index 38645dbca0a..4394a1230da 100644 --- a/htdocs/core/class/listview.class.php +++ b/htdocs/core/class/listview.class.php @@ -19,6 +19,9 @@ along with this program. If not, see . */ +/** + * Class to manage the lists view + */ class Listview { /** @@ -92,8 +95,8 @@ class Listview } /** - * @param $key - * @param $TParam + * @param string $key field name + * @param array $TParam array of configuration * @return array */ private function getSearchKey($key, &$TParam) @@ -129,7 +132,7 @@ class Listview } /** - * @param $date + * @param string $date date to convert * @return int|string Date TMS or '' */ private function dateToSQLDate($date) @@ -139,9 +142,9 @@ class Listview /** - * @param $TSQLMore - * @param $value - * @param $sKey + * @param array $TSQLMore contain some additional sql instructions + * @param string $value date with read format + * @param string $sKey field name */ private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey) { @@ -171,11 +174,11 @@ class Listview /** - * @param $TSQLMore - * @param $value - * @param $TParam - * @param $sKey - * @param $key + * @param array $TSQLMore contain some additional sql instructions + * @param string $value value to filter + * @param array $TParam array of configuration + * @param string $sKey field name + * @param string $key reference of sKey to find value into TParam * @return bool */ private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key) @@ -209,8 +212,8 @@ class Listview /** - * @param $sql - * @param $TParam + * @param string $sql standard select sql + * @param array $TParam array of configuration * @return string */ private function search($sql, &$TParam) @@ -270,8 +273,8 @@ class Listview } /** - * @param $sql - * @param array $TParam + * @param string $sql standard select sql + * @param array $TParam array of configuration * @return string */ public function render($sql, $TParam=array()) @@ -292,8 +295,8 @@ class Listview } /** - * @param $THeader - * @param $TParam + * @param array $THeader the configuration of header + * @param array $TParam array of configuration * @return array */ private function setSearch(&$THeader, &$TParam) diff --git a/htdocs/inventory/class/inventory.class.php b/htdocs/inventory/class/inventory.class.php index 5f172c7c697..14230d90893 100644 --- a/htdocs/inventory/class/inventory.class.php +++ b/htdocs/inventory/class/inventory.class.php @@ -24,6 +24,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/coreobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +/** + * Class to manage inventories + */ class Inventory extends CoreObject { public $element='inventory'; @@ -307,8 +310,8 @@ class Inventory extends CoreObject $det->load_product(); - $date = $this->get_date('date_inventory', 'Y-m-d'); - if(empty($date)) $date = $this->get_date('datec', 'Y-m-d'); + $date = $this->getDate('date_inventory', 'Y-m-d'); + if(empty($date)) $date = $this->getDate('datec', 'Y-m-d'); $det->setStockDate($date, $fk_warehouse); return true; diff --git a/htdocs/inventory/inventory.php b/htdocs/inventory/inventory.php index f9297951c22..c10cbd1ab20 100644 --- a/htdocs/inventory/inventory.php +++ b/htdocs/inventory/inventory.php @@ -381,12 +381,12 @@ function card(&$inventory, $action='edit') $lines = array(); card_line($inventory, $lines, $action); - print ''.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'

'; + print ''.$langs->trans('inventoryOnDate')." ".$inventory->getDate('date_inventory').'

'; $inventoryTPL = array( 'id'=> $inventory->id - ,'date_cre' => $inventory->get_date('date_cre', 'd/m/Y') - ,'date_maj' => $inventory->get_date('date_maj', 'd/m/Y H:i') + ,'date_cre' => $inventory->getDate('date_cre', 'd/m/Y') + ,'date_maj' => $inventory->getDate('date_maj', 'd/m/Y H:i') ,'fk_warehouse' => $inventory->fk_warehouse ,'status' => $inventory->status ,'entity' => $inventory->entity diff --git a/htdocs/inventory/lib/inventory.lib.php b/htdocs/inventory/lib/inventory.lib.php index 767d7416fc7..eb79ae67cc4 100644 --- a/htdocs/inventory/lib/inventory.lib.php +++ b/htdocs/inventory/lib/inventory.lib.php @@ -22,6 +22,11 @@ * \brief This file is an example module library */ +/** + * Define head array for tabs of inventory tools setup pages + * + * @return Array of head + */ function inventoryAdminPrepareHead() { global $langs, $conf;