FAS UDF tab

This commit is contained in:
Paolo
2017-07-18 12:48:47 +02:00
parent de2c9703de
commit b9c846f18f
6 changed files with 202 additions and 66 deletions
+84 -5
View File
@@ -8,11 +8,15 @@ class UDF extends VileSci_Controller
{
parent::__construct();
// Load session library
$this->load->library('session');
// Loads the widget library
$this->load->library('WidgetLib');
//
$this->load->model('person/Person_model', 'PersonModel');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
}
/**
@@ -21,19 +25,94 @@ class UDF extends VileSci_Controller
public function index()
{
$person_id = $this->input->get('person_id');
if (isset($this->session->person_id))
{
if (!isset($person_id))
{
$person_id = $this->session->person_id;
}
unset($this->session->person_id);
}
$prestudent_id = $this->input->get('prestudent_id');
if (isset($this->session->prestudent_id))
{
if (!isset($prestudent_id))
{
$prestudent_id = $this->session->prestudent_id;
}
unset($this->session->prestudent_id);
}
$result = null;
if (isset($this->session->result))
{
$result = clone $this->session->result;
$this->session->set_userdata('result', null);
}
$person = $this->PersonModel->load($person_id);
$prestudent = $this->PrestudentModel->load($prestudent_id);
$udfs = $this->PersonModel->getUDFs();
$personUdfs = $this->PersonModel->getUDFs();
$prestudentUdfs = $this->PrestudentModel->getUDFs();
$udfs['person_id'] = 1;
$udfs['prestudent_id'] = 1;
$udfs['caller'] = 'system/UDF?person_id=1';
$personUdfs['person_id'] = $person_id;
$prestudentUdfs['prestudent_id'] = $prestudent_id;
$data = array(
'udfs' => $udfs
'personUdfs' => $personUdfs,
'prestudentUdfs' => $prestudentUdfs,
'result' => $result
);
$this->load->view('system/udf', $data);
}
/**
*
*/
public function saveUDF()
{
$udfs = $this->input->post();
$validation = $this->_validate($udfs);
$userdata = array(
'person_id' => $udfs['person_id'],
'prestudent_id' => $udfs['prestudent_id']
);
if (isSuccess($validation))
{
// Load model UDF_model
$this->load->model('system/UDF_model', 'UDFModel');
$result = $this->UDFModel->saveUDFs($udfs);
$userdata['result'] = $result;
}
else
{
$userdata['result'] = $validation;
}
$this->session->set_userdata($userdata);
redirect('system/UDF');
}
/**
*
*/
private function _validate($udfs)
{
$validation = error('person_id or prestudent_id is missing');
if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != ''))
|| (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != '')))
{
$validation = success(true);
}
return $validation;
}
}
+8 -8
View File
@@ -49,27 +49,27 @@ class UDF_model extends DB_Model
$resultPerson = success('person');
$resultPrestudent = success('prestudent');
$person_id = $udfs['person_id'];
unset($udfs['person_id']);
$prestudent_id = $udfs['prestudent_id'];
unset($udfs['prestudent_id']);
//
if (isset($udfs['person_id']))
if (isset($person_id))
{
// Load model Person_model
$this->load->model('person/Person_model', 'PersonModel');
$person_id = $udfs['person_id'];
unset($udfs['person_id']);
$resultPerson = $this->PersonModel->update($person_id, $udfs);
}
//
if (isset($udfs['prestudent_id']))
if (isset($prestudent_id))
{
// Load model Prestudent_model
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$prestudent_id = $udfs['prestudent_id'];
unset($udfs['prestudent_id']);
$resultPrestudent = $this->PrestudentModel->update($prestudent_id, $udfs);
}
+100 -19
View File
@@ -1,28 +1,109 @@
<?php $this->load->view("templates/header", array("title" => "UDF")); ?>
<body>
<body style="background-color: #eff0f1;">
<form action="/core/index.ci.php/api/v1/system/UDF/UDF" method="POST">
<?php
if ($result != null)
{
if (isSuccess($result))
{
?>
<div style="color: black;">
Saved!
</div>
<div>
<?php
echo $this->widgetlib->UDFWidget(
array(
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_person',
UDFWidgetTpl::UDFS_ARG_NAME => $udfs
)
);
?>
</div>
<br>
<?php
}
else
{
?>
<div style="color: red;">
Error while saving!
</div>
<br>
<div style="color: red;">
<?php
$errors = $result->retval;
foreach($errors as $error)
{
foreach($error as $fieldError)
{
echo $fieldError->msg . ' -> ' . $fieldError->retval . '<br>';
}
}
?>
</div>
<div>
<input type="submit" value="Save">
</div>
<br>
<br>
<br>
<?php
}
}
?>
<form action="/core/index.ci.php/system/UDF/saveUDF" method="POST">
<table>
<tr>
<td>
Person
</td>
<td width="30px">
&nbsp;
</td>
<td>
Prestudent
</td>
</tr>
<tr>
<td colspan="3">
&nbsp;
</td>
</tr>
<tr>
<td>
<?php
echo $this->widgetlib->UDFWidget(
array(
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_person',
UDFWidgetTpl::UDFS_ARG_NAME => $personUdfs
)
);
?>
</td>
<td width="30px">
&nbsp;
</td>
<td>
<?php
echo $this->widgetlib->UDFWidget(
array(
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_prestudent',
UDFWidgetTpl::UDFS_ARG_NAME => $prestudentUdfs
)
);
?>
</td>
</tr>
<tr>
<td colspan="3">
&nbsp;
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="Save">
</td>
</tr>
</table>
<input type="hidden" name="person_id" value="<?php echo $personUdfs['person_id']; ?>">
<input type="hidden" name="prestudent_id" value="<?php echo $prestudentUdfs['prestudent_id']; ?>">
<input type="hidden" name="person_id" value="<?php echo $udfs['person_id']; ?>">
<input type="hidden" name="caller" value="<?php echo $udfs['caller']; ?>">
<!-- <input type="hidden" name="prestudent_id" value="<?php echo $udfs['prestudent_id']; ?>"> -->
</form>
</body>
+6
View File
@@ -1540,6 +1540,12 @@ function StudentAuswahl()
document.getElementById('student-messages').setAttribute('src','messages.xul.php?person_id='+person_id);
}
// ***** UDF *****
if (document.getElementById('student-content-tabs').selectedItem == document.getElementById('student-tab-udf'))
{
document.getElementById('student-udf').setAttribute('src', 'udf.xul.php?person_id='+person_id+'&prestudent_id='+prestudent_id);
}
// Notizen laden
var studentnotiz = document.getElementById('student-box-notizen');
studentnotiz.LoadNotizTree('','','','',person_id,'','','','');
+2 -32
View File
@@ -20,34 +20,6 @@
require_once('../config/vilesci.config.inc.php');
?>
// ********** FUNKTIONEN ********** //
var UDFPersonID = null;
var UDFTreeDatasource = ''; // Datasource des Adressen Trees
var UDFSelectID = '';
var UDFIFrameIsInitialized = false;
var UDFTreeSinkObserver =
{
onBeginLoad : function(pSink) {},
onInterrupt : function(pSink) {},
onResume : function(pSink) {},
onError : function(pSink, pStatus, pError) {},
onEndLoad : function(pSink)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
};
var UDFTreeListener =
{
willRebuild : function(builder) { },
didRebuild : function(builder)
{
//timeout nur bei Mozilla notwendig da sonst die rows
//noch keine values haben. Ab Seamonkey funktionierts auch
//ohne dem setTimeout
//window.setTimeout(KontaktAdressenTreeSelectID,10);
}
};
// ****
// * Laedt die Trees
@@ -58,10 +30,8 @@ function loadUDF(person_id, prestudent_id)
var udfIFrame = document.getElementById('udfIFrame');
alert(udfIFrame.src);
if (udfIFrame != null)
if (udfIFrame != null && udfIFrame.getAttribute('src') == 'about:blank')
{
udfIFrame.src = '/core/index.ci.php/system/UDF?person_id=' + person_id + '&prestudent_id' + prestudent_id;
udfIFrame.setAttribute('src', '/core/index.ci.php/system/UDF?person_id='+person_id+'&prestudent_id='+prestudent_id);
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ echo ']>
<vbox flex="1">
<hbox flex="1">
<iframe id="udfIFrame" editortype="html" src="about:blank" flex="1" type="content-primary" style="min-width: 100px; min-height: 100px; border: 1px solid gray; margin: 10px;"/>
<iframe id="udfIFrame" editortype="html" src="about:blank" flex="1" type="content-primary" style="min-width: 100px; min-height: 100px; border: 0px; margin: 10px;"/>
</hbox>
</vbox>