mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
- priority display and priority change possible on infocenterdetails page
- different sort order of zgvpruefungen (prestudenten)
This commit is contained in:
@@ -278,4 +278,229 @@ class Prestudent_model extends DB_Model
|
||||
|
||||
return $this->execQuery($qry, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with Bewerber (applicants)
|
||||
* @param $person_id person who sent application(s)
|
||||
* @param string $studiensemester_kurzbz
|
||||
* @param bool $abgeschickt optional, wether application was filled out and sent
|
||||
* @param bool $bestaetigt optional, wether application was confirmed by infocenter
|
||||
* @return array with Bewerber
|
||||
*/
|
||||
public function getBewerber($person_id, $studiensemester_kurzbz = null, $abgeschickt = null, $bestaetigt = null)
|
||||
{
|
||||
$bewerber = array();
|
||||
$prestudents = $this->loadWhere(array('person_id' => $person_id));
|
||||
|
||||
if (!hasData($prestudents))
|
||||
return $bewerber;
|
||||
|
||||
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
|
||||
|
||||
foreach ($prestudents->retval as $prestudent)
|
||||
{
|
||||
$lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent->prestudent_id, $studiensemester_kurzbz);
|
||||
|
||||
if (!hasData($lastStatus))
|
||||
continue;
|
||||
|
||||
$lastStatus = $lastStatus->retval[0];
|
||||
|
||||
if ($lastStatus->status_kurzbz !== 'Interessent')
|
||||
continue;
|
||||
|
||||
$bewerbung_abgeschicktamum = $lastStatus->bewerbung_abgeschicktamum;
|
||||
$bestaetigtam = $lastStatus->bestaetigtam;
|
||||
|
||||
$abgeschicktcond = true;
|
||||
if (($abgeschickt === false && isset($bewerbung_abgeschicktamum)) || ($abgeschickt === true && !isset($bewerbung_abgeschicktamum)))
|
||||
$abgeschicktcond = false;
|
||||
|
||||
$bestaetigtcond = true;
|
||||
if (($bestaetigt === false && isset($bestaetigtam)) || ($bestaetigt === true && !isset($bestaetigtam)))
|
||||
$bestaetigtcond = false;
|
||||
|
||||
if ($bestaetigtcond && $abgeschicktcond)
|
||||
{
|
||||
$prestudent->lastStatus = $lastStatus;
|
||||
$bewerber[] = $prestudent;
|
||||
}
|
||||
}
|
||||
|
||||
return $bewerber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if application priority can be changed for a prestudent
|
||||
* @param $prestudent_id
|
||||
* @param $studiensemester Semester in which Prestudent applied
|
||||
* @param $change increase priority (< 0) or decrease priority (> 0)
|
||||
* @return bool wether priority can be changed
|
||||
*/
|
||||
public function checkPrioChange($prestudent_id, $studiensemester, $change)
|
||||
{
|
||||
if (!is_numeric($change))
|
||||
return false;
|
||||
|
||||
$this->addSelect('person_id, priorisierung');
|
||||
$prestudent = $this->load($prestudent_id);
|
||||
|
||||
if (!hasData($prestudent))
|
||||
return false;
|
||||
|
||||
$person_id = $prestudent->retval[0]->person_id;
|
||||
|
||||
$bewerberarr = $this->getBewerber($person_id, $studiensemester);
|
||||
|
||||
if (count($bewerberarr) <= 1)
|
||||
return false;
|
||||
|
||||
if (!isset($prestudent->retval[0]->priorisierung))
|
||||
{
|
||||
if ($change < 0)
|
||||
return true; //null values can be changed to priority numbers, when there are other bewerber
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
$priomin = 0;
|
||||
$priomax = PHP_INT_MAX;
|
||||
$currprio = intval($prestudent->retval[0]->priorisierung);
|
||||
|
||||
foreach ($bewerberarr as $bewerber)
|
||||
{
|
||||
if (is_numeric($bewerber->priorisierung))
|
||||
{
|
||||
$bewprio = intval($bewerber->priorisierung);
|
||||
if ($bewprio < $priomax)
|
||||
$priomax = $bewprio;
|
||||
|
||||
if ($bewprio > $priomin)
|
||||
$priomin = $bewprio;
|
||||
}
|
||||
}
|
||||
|
||||
if (($currprio === $priomax && $change < 0)|| ($currprio === $priomin && $change > 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes application priority for a prestudent
|
||||
* Swaps priorities with nearest neighbour (nearest bewerber/prestudent)
|
||||
* for the same studiensemester in order to move priority up/down
|
||||
* @param $prestudent_id
|
||||
* @param $change increase priority (< 0) or decrease priority (> 0)
|
||||
* @return bool wether change of priority was sucessfull
|
||||
*/
|
||||
public function changePrio($prestudent_id, $change)
|
||||
{
|
||||
$this->addSelect('person_id, priorisierung');
|
||||
$prestudent = $this->load($prestudent_id);
|
||||
|
||||
if (!hasData($prestudent))
|
||||
return false;
|
||||
|
||||
$this->load->model('prestudentstatus_model', 'PrestudentstatusModel');
|
||||
$lastStatus = $this->PrestudentstatusModel->getLastStatus($prestudent_id, null, 'Interessent');
|
||||
|
||||
if (!hasData($lastStatus))
|
||||
return false;
|
||||
|
||||
$studiensemester_kurzbz = $lastStatus->retval[0]->studiensemester_kurzbz;
|
||||
|
||||
if (!$this->checkPrioChange($prestudent_id, $studiensemester_kurzbz, $change))
|
||||
return false;
|
||||
|
||||
$person_id = $prestudent->retval[0]->person_id;
|
||||
$currprio = intval($prestudent->retval[0]->priorisierung);
|
||||
|
||||
$difftonext = PHP_INT_MAX;
|
||||
$neighbour = null;
|
||||
|
||||
$bewerberarr = $this->getBewerber($person_id, $studiensemester_kurzbz );
|
||||
|
||||
foreach ($bewerberarr as $bewerber)
|
||||
{
|
||||
if (is_numeric($bewerber->priorisierung))
|
||||
{
|
||||
$bewprio = intval($bewerber->priorisierung);
|
||||
|
||||
$diff = 0;
|
||||
if ($change < 0 && ($bewprio < $currprio || is_null($prestudent->retval[0]->priorisierung))) //prio up
|
||||
{
|
||||
$diff = $currprio - $bewprio;
|
||||
}
|
||||
elseif ($change > 0 && $bewprio > $currprio)
|
||||
{
|
||||
$diff = $bewprio - $currprio;
|
||||
}
|
||||
|
||||
if ($diff !== 0 && $diff < $difftonext)
|
||||
{
|
||||
$difftonext = $diff;
|
||||
$neighbour = $bewerber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($prestudent->retval[0]->priorisierung))
|
||||
{
|
||||
//if null value before, add lowest prio
|
||||
$newprio = isset($neighbour->priorisierung) ? intval($neighbour->priorisierung) + 1 : 1;
|
||||
|
||||
$result = $this->PrestudentModel->update(
|
||||
$prestudent_id,
|
||||
array(
|
||||
'priorisierung' => $newprio
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_start(false);
|
||||
//prio swap
|
||||
$resultFirst = $this->PrestudentModel->update(
|
||||
$prestudent_id,
|
||||
array(
|
||||
'priorisierung' => intval($neighbour->priorisierung)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$resultSecond = $this->PrestudentModel->update(
|
||||
$neighbour->prestudent_id,
|
||||
array(
|
||||
'priorisierung' => $currprio
|
||||
)
|
||||
);
|
||||
|
||||
// Transaction complete!
|
||||
$this->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->db->trans_status() === false || isError($resultFirst) || isError($resultSecond))
|
||||
{
|
||||
$this->db->trans_rollback();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->trans_commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,11 @@ class Prestudentstatus_model extends DB_Model
|
||||
array_push($parametersArray, $studiensemester_kurzbz);
|
||||
$query .= ' AND studiensemester_kurzbz = ?';
|
||||
}
|
||||
|
||||
if ($status_kurzbz != '')
|
||||
{
|
||||
array_push($parametersArray, $status_kurzbz);
|
||||
$query .= ' AND status_kurzbz = ?';
|
||||
$query .= ' AND tbl_prestudentstatus.status_kurzbz = ?';
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1';
|
||||
|
||||
Reference in New Issue
Block a user