mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
- Renamed controller system/UDF.php to system/FAS_UDF.php
- Renamed view system/udf.php to system/fas_udf.php - Adapted code with new names - Added model system/FAS_UDF_model with only FAS functionalities - Removed FAS functionalities from model system/UDF_model - Fixed session problems in controller system/FAS_UDF
This commit is contained in:
+22
-15
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
class UDF extends Auth_Controller
|
class FAS_UDF extends Auth_Controller
|
||||||
{
|
{
|
||||||
|
const FAS_UDF_SESSION_NAME = 'fasUdfSessionName';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
@@ -22,31 +24,33 @@ class UDF extends Auth_Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$fasUdfSession = getSession(self::FAS_UDF_SESSION_NAME);
|
||||||
|
|
||||||
$person_id = $this->input->get('person_id');
|
$person_id = $this->input->get('person_id');
|
||||||
if (isset($this->session->person_id))
|
if (isset($fasUdfSession['person_id']))
|
||||||
{
|
{
|
||||||
if (!isset($person_id))
|
if (!isset($person_id))
|
||||||
{
|
{
|
||||||
$person_id = $this->session->person_id;
|
$person_id = $fasUdfSession['person_id'];
|
||||||
}
|
}
|
||||||
unset($this->session->person_id);
|
unset($fasUdfSession['person_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$prestudent_id = $this->input->get('prestudent_id');
|
$prestudent_id = $this->input->get('prestudent_id');
|
||||||
if (isset($this->session->prestudent_id))
|
if (isset($fasUdfSession['prestudent_id']))
|
||||||
{
|
{
|
||||||
if (!isset($prestudent_id))
|
if (!isset($prestudent_id))
|
||||||
{
|
{
|
||||||
$prestudent_id = $this->session->prestudent_id;
|
$prestudent_id = $fasUdfSession['prestudent_id'];
|
||||||
}
|
}
|
||||||
unset($this->session->prestudent_id);
|
unset($fasUdfSession['prestudent_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = null;
|
$result = null;
|
||||||
if (isset($this->session->result))
|
if (isset($fasUdfSession['result']))
|
||||||
{
|
{
|
||||||
$result = clone $this->session->result;
|
$result = clone $fasUdfSession['result'];
|
||||||
$this->session->set_userdata('result', null);
|
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array('result' => $result);
|
$data = array('result' => $result);
|
||||||
@@ -71,7 +75,7 @@ class UDF extends Auth_Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->load->view('system/udf', $data);
|
$this->load->view('system/fas_udf', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,9 +94,9 @@ class UDF extends Auth_Controller
|
|||||||
if (isSuccess($validation))
|
if (isSuccess($validation))
|
||||||
{
|
{
|
||||||
// Load model UDF_model
|
// Load model UDF_model
|
||||||
$this->load->model('system/UDF_model', 'UDFModel');
|
$this->load->model('system/FAS_UDF_model', 'FASUDFModel');
|
||||||
|
|
||||||
$result = $this->UDFModel->saveUDFs($udfs);
|
$result = $this->FASUDFModel->saveUDFs($udfs);
|
||||||
|
|
||||||
$userdata['result'] = $result;
|
$userdata['result'] = $result;
|
||||||
}
|
}
|
||||||
@@ -101,8 +105,11 @@ class UDF extends Auth_Controller
|
|||||||
$userdata['result'] = $validation;
|
$userdata['result'] = $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->session->set_userdata($userdata);
|
setSessionElement(self::FAS_UDF_SESSION_NAME, 'person_id', $userdata['person_id']);
|
||||||
redirect('system/UDF');
|
setSessionElement(self::FAS_UDF_SESSION_NAME, 'prestudent_id', $userdata['prestudent_id']);
|
||||||
|
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', $userdata['result']);
|
||||||
|
|
||||||
|
redirect('system/FAS_UDF');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class FAS_UDF_model extends DB_Model
|
||||||
|
{
|
||||||
|
// String values of booleans
|
||||||
|
const STRING_NULL = 'null';
|
||||||
|
const STRING_TRUE = 'true';
|
||||||
|
const STRING_FALSE = 'false';
|
||||||
|
|
||||||
|
const UDF_DROPDOWN_TYPE = 'dropdown';
|
||||||
|
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Methods to save data from FAS
|
||||||
|
*/
|
||||||
|
public function saveUDFs($udfs)
|
||||||
|
{
|
||||||
|
$result = error('No way man!');
|
||||||
|
$resultPerson = success('person');
|
||||||
|
$resultPrestudent = success('prestudent');
|
||||||
|
|
||||||
|
$person_id = null;
|
||||||
|
if (isset($udfs['person_id'])) $person_id = $udfs['person_id'];
|
||||||
|
unset($udfs['person_id']);
|
||||||
|
|
||||||
|
$prestudent_id = null;
|
||||||
|
if (isset($udfs['prestudent_id'])) $prestudent_id = $udfs['prestudent_id'];
|
||||||
|
unset($udfs['prestudent_id']);
|
||||||
|
|
||||||
|
$jsons = array();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isset($person_id))
|
||||||
|
{
|
||||||
|
// Load model Person_model
|
||||||
|
$this->load->model('person/Person_model', 'PersonModel');
|
||||||
|
|
||||||
|
$result = $this->load(array('public', 'tbl_person'));
|
||||||
|
if (isSuccess($result) && count($result->retval) == 1)
|
||||||
|
{
|
||||||
|
$jsons = json_decode($result->retval[0]->jsons);
|
||||||
|
}
|
||||||
|
|
||||||
|
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
||||||
|
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
||||||
|
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
||||||
|
|
||||||
|
$resultPerson = $this->PersonModel->update($person_id, $udfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isset($prestudent_id))
|
||||||
|
{
|
||||||
|
// Load model Prestudent_model
|
||||||
|
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||||
|
|
||||||
|
$result = $this->load(array('public', 'tbl_prestudent'));
|
||||||
|
if (isSuccess($result) && count($result->retval) == 1)
|
||||||
|
{
|
||||||
|
$jsons = json_decode($result->retval[0]->jsons);
|
||||||
|
}
|
||||||
|
|
||||||
|
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
||||||
|
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
||||||
|
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
||||||
|
|
||||||
|
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
|
||||||
|
{
|
||||||
|
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
|
||||||
|
}
|
||||||
|
else if(isError($resultPerson))
|
||||||
|
{
|
||||||
|
$result = $resultPerson;
|
||||||
|
}
|
||||||
|
else if(isError($resultPrestudent))
|
||||||
|
{
|
||||||
|
$result = $resultPrestudent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function _fillMissingChkboxUDF($udfs, $jsons)
|
||||||
|
{
|
||||||
|
$_fillMissingChkboxUDF = $udfs;
|
||||||
|
|
||||||
|
foreach($jsons as $udfDescription)
|
||||||
|
{
|
||||||
|
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
|
||||||
|
{
|
||||||
|
if (!isset($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}]))
|
||||||
|
{
|
||||||
|
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_FALSE)
|
||||||
|
{
|
||||||
|
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
|
||||||
|
}
|
||||||
|
else if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_TRUE)
|
||||||
|
{
|
||||||
|
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_fillMissingChkboxUDF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function _fillMissingDropdownUDF($udfs, $jsons)
|
||||||
|
{
|
||||||
|
$_fillMissingDropdownUDF = $udfs;
|
||||||
|
|
||||||
|
foreach($jsons as $udfDescription)
|
||||||
|
{
|
||||||
|
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
|
||||||
|
|| $udfDescription->{UDFLib::TYPE} == UDF_model::UDF_MULTIPLEDROPDOWN_TYPE)
|
||||||
|
{
|
||||||
|
if (!isset($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}]))
|
||||||
|
{
|
||||||
|
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
|
||||||
|
}
|
||||||
|
else if($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_NULL)
|
||||||
|
{
|
||||||
|
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_fillMissingDropdownUDF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function _fillMissingTextUDF($udfs, $jsons)
|
||||||
|
{
|
||||||
|
$_fillMissingTextUDF = $udfs;
|
||||||
|
|
||||||
|
foreach($jsons as $udfDescription)
|
||||||
|
{
|
||||||
|
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
|
||||||
|
|| $udfDescription->{UDFLib::TYPE} == 'textfield')
|
||||||
|
{
|
||||||
|
if (!isset($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]))
|
||||||
|
{
|
||||||
|
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
|
||||||
|
}
|
||||||
|
else if(trim($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]) == '')
|
||||||
|
{
|
||||||
|
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_fillMissingTextUDF;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,14 +2,6 @@
|
|||||||
|
|
||||||
class UDF_model extends DB_Model
|
class UDF_model extends DB_Model
|
||||||
{
|
{
|
||||||
// String values of booleans
|
|
||||||
const STRING_NULL = 'null';
|
|
||||||
const STRING_TRUE = 'true';
|
|
||||||
const STRING_FALSE = 'false';
|
|
||||||
|
|
||||||
const UDF_DROPDOWN_TYPE = 'dropdown';
|
|
||||||
const UDF_MULTIPLEDROPDOWN_TYPE = 'multipledropdown';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -38,164 +30,4 @@ class UDF_model extends DB_Model
|
|||||||
|
|
||||||
return $udfResults;
|
return $udfResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
|
||||||
// These methods work only with the this version of FAS, not with the future versions
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods to save data from FAS
|
|
||||||
*/
|
|
||||||
public function saveUDFs($udfs)
|
|
||||||
{
|
|
||||||
$result = error('No way man!');
|
|
||||||
$resultPerson = success('person');
|
|
||||||
$resultPrestudent = success('prestudent');
|
|
||||||
|
|
||||||
$person_id = null;
|
|
||||||
if (isset($udfs['person_id'])) $person_id = $udfs['person_id'];
|
|
||||||
unset($udfs['person_id']);
|
|
||||||
|
|
||||||
$prestudent_id = null;
|
|
||||||
if (isset($udfs['prestudent_id'])) $prestudent_id = $udfs['prestudent_id'];
|
|
||||||
unset($udfs['prestudent_id']);
|
|
||||||
|
|
||||||
$jsons = array();
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isset($person_id))
|
|
||||||
{
|
|
||||||
// Load model Person_model
|
|
||||||
$this->load->model('person/Person_model', 'PersonModel');
|
|
||||||
|
|
||||||
$result = $this->load(array('public', 'tbl_person'));
|
|
||||||
if (isSuccess($result) && count($result->retval) == 1)
|
|
||||||
{
|
|
||||||
$jsons = json_decode($result->retval[0]->jsons);
|
|
||||||
}
|
|
||||||
|
|
||||||
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
|
||||||
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
|
||||||
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
|
||||||
|
|
||||||
$resultPerson = $this->PersonModel->update($person_id, $udfs);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isset($prestudent_id))
|
|
||||||
{
|
|
||||||
// Load model Prestudent_model
|
|
||||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
|
||||||
|
|
||||||
$result = $this->load(array('public', 'tbl_prestudent'));
|
|
||||||
if (isSuccess($result) && count($result->retval) == 1)
|
|
||||||
{
|
|
||||||
$jsons = json_decode($result->retval[0]->jsons);
|
|
||||||
}
|
|
||||||
|
|
||||||
$udfs = $this->_fillMissingTextUDF($udfs, $jsons);
|
|
||||||
$udfs = $this->_fillMissingChkboxUDF($udfs, $jsons);
|
|
||||||
$udfs = $this->_fillMissingDropdownUDF($udfs, $jsons);
|
|
||||||
|
|
||||||
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSuccess($resultPerson) && isSuccess($resultPrestudent))
|
|
||||||
{
|
|
||||||
$result = success(array($resultPerson->retval, $resultPrestudent->retval));
|
|
||||||
}
|
|
||||||
else if(isError($resultPerson))
|
|
||||||
{
|
|
||||||
$result = $resultPerson;
|
|
||||||
}
|
|
||||||
else if(isError($resultPrestudent))
|
|
||||||
{
|
|
||||||
$result = $resultPrestudent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function _fillMissingChkboxUDF($udfs, $jsons)
|
|
||||||
{
|
|
||||||
$_fillMissingChkboxUDF = $udfs;
|
|
||||||
|
|
||||||
foreach($jsons as $udfDescription)
|
|
||||||
{
|
|
||||||
if ($udfDescription->{UDFLib::TYPE} == UDFLib::CHKBOX_TYPE)
|
|
||||||
{
|
|
||||||
if (!isset($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}]))
|
|
||||||
{
|
|
||||||
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_FALSE)
|
|
||||||
{
|
|
||||||
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = false;
|
|
||||||
}
|
|
||||||
else if ($_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_TRUE)
|
|
||||||
{
|
|
||||||
$_fillMissingChkboxUDF[$udfDescription->{UDFLib::NAME}] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_fillMissingChkboxUDF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function _fillMissingDropdownUDF($udfs, $jsons)
|
|
||||||
{
|
|
||||||
$_fillMissingDropdownUDF = $udfs;
|
|
||||||
|
|
||||||
foreach($jsons as $udfDescription)
|
|
||||||
{
|
|
||||||
if ($udfDescription->{UDFLib::TYPE} == UDF_model::UDF_DROPDOWN_TYPE
|
|
||||||
|| $udfDescription->{UDFLib::TYPE} == UDF_model::UDF_MULTIPLEDROPDOWN_TYPE)
|
|
||||||
{
|
|
||||||
if (!isset($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}]))
|
|
||||||
{
|
|
||||||
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
|
|
||||||
}
|
|
||||||
else if($_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] == UDF_model::STRING_NULL)
|
|
||||||
{
|
|
||||||
$_fillMissingDropdownUDF[$udfDescription->{UDFLib::NAME}] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_fillMissingDropdownUDF;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private function _fillMissingTextUDF($udfs, $jsons)
|
|
||||||
{
|
|
||||||
$_fillMissingTextUDF = $udfs;
|
|
||||||
|
|
||||||
foreach($jsons as $udfDescription)
|
|
||||||
{
|
|
||||||
if ($udfDescription->{UDFLib::TYPE} == 'textarea'
|
|
||||||
|| $udfDescription->{UDFLib::TYPE} == 'textfield')
|
|
||||||
{
|
|
||||||
if (!isset($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]))
|
|
||||||
{
|
|
||||||
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
|
|
||||||
}
|
|
||||||
else if(trim($_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}]) == '')
|
|
||||||
{
|
|
||||||
$_fillMissingTextUDF[$udfDescription->{UDFLib::NAME}] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_fillMissingTextUDF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<form action="<?php echo site_url('system/UDF/saveUDF'); ?>" method="POST">
|
<form action="<?php echo site_url('system/FAS_UDF/saveUDF'); ?>" method="POST">
|
||||||
|
|
||||||
<div class="div-table">
|
<div class="div-table">
|
||||||
<div class="div-row">
|
<div class="div-row">
|
||||||
+1
-1
@@ -32,6 +32,6 @@ function loadUDF(person_id, prestudent_id)
|
|||||||
|
|
||||||
if (udfIFrame != null && udfIFrame.getAttribute('src') == 'about:blank')
|
if (udfIFrame != null && udfIFrame.getAttribute('src') == 'about:blank')
|
||||||
{
|
{
|
||||||
udfIFrame.setAttribute('src', '<?php echo APP_ROOT ?>index.ci.php/system/UDF?person_id='+person_id+'&prestudent_id='+prestudent_id);
|
udfIFrame.setAttribute('src', '<?php echo APP_ROOT ?>index.ci.php/system/FAS_UDF?person_id='+person_id+'&prestudent_id='+prestudent_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user