2
0
forked from Wavyzz/dolibarr

Refactoring and class/method documentation

This commit is contained in:
atm-ph
2017-03-26 14:37:25 +02:00
parent 09f645fc9f
commit ae2ab3276d
5 changed files with 38 additions and 27 deletions

View File

@@ -287,11 +287,11 @@ class CoreObject extends CommonObject
} }
elseif($this->is_int($info)) elseif($this->is_int($info))
{ {
$this->{$field} = (int)$obj->{$field}; $this->{$field} = (int) $obj->{$field};
} }
elseif($this->is_float($info)) elseif($this->is_float($info))
{ {
$this->{$field} = (double)$obj->{$field}; $this->{$field} = (double) $obj->{$field};
} }
elseif($this->is_null($info)) elseif($this->is_null($info))
{ {
@@ -604,7 +604,7 @@ class CoreObject extends CommonObject
* @param string $format Output date format * @param string $format Output date format
* @return string * @return string
*/ */
public function get_date($field, $format='') public function getDate($field, $format='')
{ {
if(empty($this->{$field})) return ''; if(empty($this->{$field})) return '';
else else
@@ -620,7 +620,7 @@ class CoreObject extends CommonObject
* @param string $date formatted date to convert * @param string $date formatted date to convert
* @return mixed * @return mixed
*/ */
public function set_date($field, $date) public function setDate($field, $date)
{ {
if (empty($date)) if (empty($date))
{ {
@@ -648,7 +648,7 @@ class CoreObject extends CommonObject
{ {
if($this->checkFieldType($key, 'date')) if($this->checkFieldType($key, 'date'))
{ {
$this->set_date($key, $value); $this->setDate($key, $value);
} }
else if( $this->checkFieldType($key, 'array')) else if( $this->checkFieldType($key, 'array'))
{ {

View File

@@ -19,6 +19,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/**
* Class to manage the lists view
*/
class Listview class Listview
{ {
/** /**
@@ -92,8 +95,8 @@ class Listview
} }
/** /**
* @param $key * @param string $key field name
* @param $TParam * @param array $TParam array of configuration
* @return array * @return array
*/ */
private function getSearchKey($key, &$TParam) 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 '' * @return int|string Date TMS or ''
*/ */
private function dateToSQLDate($date) private function dateToSQLDate($date)
@@ -139,9 +142,9 @@ class Listview
/** /**
* @param $TSQLMore * @param array $TSQLMore contain some additional sql instructions
* @param $value * @param string $value date with read format
* @param $sKey * @param string $sKey field name
*/ */
private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey) private function addSqlFromTypeDate(&$TSQLMore, &$value, $sKey)
{ {
@@ -171,11 +174,11 @@ class Listview
/** /**
* @param $TSQLMore * @param array $TSQLMore contain some additional sql instructions
* @param $value * @param string $value value to filter
* @param $TParam * @param array $TParam array of configuration
* @param $sKey * @param string $sKey field name
* @param $key * @param string $key reference of sKey to find value into TParam
* @return bool * @return bool
*/ */
private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key) private function addSqlFromOther(&$TSQLMore, &$value, &$TParam, $sKey, $key)
@@ -209,8 +212,8 @@ class Listview
/** /**
* @param $sql * @param string $sql standard select sql
* @param $TParam * @param array $TParam array of configuration
* @return string * @return string
*/ */
private function search($sql, &$TParam) private function search($sql, &$TParam)
@@ -270,8 +273,8 @@ class Listview
} }
/** /**
* @param $sql * @param string $sql standard select sql
* @param array $TParam * @param array $TParam array of configuration
* @return string * @return string
*/ */
public function render($sql, $TParam=array()) public function render($sql, $TParam=array())
@@ -292,8 +295,8 @@ class Listview
} }
/** /**
* @param $THeader * @param array $THeader the configuration of header
* @param $TParam * @param array $TParam array of configuration
* @return array * @return array
*/ */
private function setSearch(&$THeader, &$TParam) private function setSearch(&$THeader, &$TParam)

View File

@@ -24,6 +24,9 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/coreobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/coreobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
/**
* Class to manage inventories
*/
class Inventory extends CoreObject class Inventory extends CoreObject
{ {
public $element='inventory'; public $element='inventory';
@@ -307,8 +310,8 @@ class Inventory extends CoreObject
$det->load_product(); $det->load_product();
$date = $this->get_date('date_inventory', 'Y-m-d'); $date = $this->getDate('date_inventory', 'Y-m-d');
if(empty($date)) $date = $this->get_date('datec', 'Y-m-d'); if(empty($date)) $date = $this->getDate('datec', 'Y-m-d');
$det->setStockDate($date, $fk_warehouse); $det->setStockDate($date, $fk_warehouse);
return true; return true;

View File

@@ -381,12 +381,12 @@ function card(&$inventory, $action='edit')
$lines = array(); $lines = array();
card_line($inventory, $lines, $action); card_line($inventory, $lines, $action);
print '<b>'.$langs->trans('inventoryOnDate')." ".$inventory->get_date('date_inventory').'</b><br><br>'; print '<b>'.$langs->trans('inventoryOnDate')." ".$inventory->getDate('date_inventory').'</b><br><br>';
$inventoryTPL = array( $inventoryTPL = array(
'id'=> $inventory->id 'id'=> $inventory->id
,'date_cre' => $inventory->get_date('date_cre', 'd/m/Y') ,'date_cre' => $inventory->getDate('date_cre', 'd/m/Y')
,'date_maj' => $inventory->get_date('date_maj', 'd/m/Y H:i') ,'date_maj' => $inventory->getDate('date_maj', 'd/m/Y H:i')
,'fk_warehouse' => $inventory->fk_warehouse ,'fk_warehouse' => $inventory->fk_warehouse
,'status' => $inventory->status ,'status' => $inventory->status
,'entity' => $inventory->entity ,'entity' => $inventory->entity

View File

@@ -22,6 +22,11 @@
* \brief This file is an example module library * \brief This file is an example module library
*/ */
/**
* Define head array for tabs of inventory tools setup pages
*
* @return Array of head
*/
function inventoryAdminPrepareHead() function inventoryAdminPrepareHead()
{ {
global $langs, $conf; global $langs, $conf;