Added private method _fillMissingChkboxUDF to UDF_model.

It checks if UDF checkboxes are NOT posted and sets theirs values to
false
This commit is contained in:
Paolo
2017-07-28 18:36:08 +02:00
parent 0ff635f5ea
commit 59045e1136
2 changed files with 32 additions and 0 deletions
+1
View File
@@ -36,6 +36,7 @@ class DB_Model extends FHC_Model
const UDF_MAX_LENGTH = 'max-length';
const UDF_MIN_LENGTH = 'min-length';
// String values of booleans
const STRING_TRUE = 'true';
const STRING_FALSE = 'false';
+31
View File
@@ -61,6 +61,8 @@ class UDF_model extends DB_Model
// Load model Person_model
$this->load->model('person/Person_model', 'PersonModel');
$udfs = $this->_fillMissingChkboxUDF($udfs, 'public', 'tbl_person');
$resultPerson = $this->PersonModel->update($person_id, $udfs);
}
@@ -70,6 +72,8 @@ class UDF_model extends DB_Model
// Load model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$udfs = $this->_fillMissingChkboxUDF($udfs, 'public', 'tbl_prestudent');
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
}
@@ -88,4 +92,31 @@ class UDF_model extends DB_Model
return $result;
}
/**
*
*/
private function _fillMissingChkboxUDF($udfs, $schema, $table)
{
$_fillMissingChkboxUDF = $udfs;
$result = $this->load(array($schema, $table));
if (isSuccess($result) && count($result->retval) == 1)
{
$jsons = json_decode($result->retval[0]->jsons);
foreach($jsons as $udfDescription)
{
if ($udfDescription->{DB_Model::UDF_TYPE_NAME} == DB_Model::UDF_CHKBOX_TYPE)
{
if (!isset($_fillMissingChkboxUDF[$udfDescription->{DB_Model::UDF_ATTRIBUTE_NAME}]))
{
$_fillMissingChkboxUDF[$udfDescription->{DB_Model::UDF_ATTRIBUTE_NAME}] = DB_Model::STRING_FALSE;
}
}
}
}
return $_fillMissingChkboxUDF;
}
}