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))
{
$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'))
{

View File

@@ -19,6 +19,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* 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)

View File

@@ -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;

View File

@@ -381,12 +381,12 @@ function card(&$inventory, $action='edit')
$lines = array();
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(
'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

View File

@@ -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;