This commit is contained in:
kindlm
2016-07-28 11:12:37 +02:00
21 changed files with 894 additions and 337 deletions
@@ -63,27 +63,6 @@ class Prestudent extends APIv1_Controller
$this->response();
}
}
/**
* @return void
*/
public function getLastStatus()
{
$prestudent_id = $this->get('prestudent_id');
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
$status_kurzbz = $this->get('status_kurzbz');
if (isset($prestudent_id))
{
$result = $this->PrestudentModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
@@ -24,8 +24,6 @@ class Prestudentstatus extends APIv1_Controller
parent::__construct();
// Load model PrestudentstatusModel
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
}
/**
@@ -49,6 +47,27 @@ class Prestudentstatus extends APIv1_Controller
$this->response();
}
}
/**
* @return void
*/
public function getLastStatus()
{
$prestudent_id = $this->get("prestudent_id");
$studiensemester_kurzbz = $this->get("studiensemester_kurzbz");
$status_kurzbz = $this->get("status_kurzbz");
if (isset($prestudent_id))
{
$result = $this->PrestudentstatusModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
@@ -89,4 +108,4 @@ class Prestudentstatus extends APIv1_Controller
{
return true;
}
}
}
+205 -191
View File
@@ -1,10 +1,9 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
if (! defined("BASEPATH")) exit("No direct script access allowed");
/**
* Name: Messaging Library for FH-Complete
*
*
*/
class MessageLib
{
@@ -24,24 +23,24 @@ class MessageLib
// CI Parser library
$this->ci->load->library("parser");
// Loads LogLib
$this->ci->load->library('LogLib');
$this->ci->load->library("LogLib");
// Loads VorlageLib
$this->ci->load->library('VorlageLib');
$this->ci->load->library("VorlageLib");
// Initializing email library with the loaded configurations
$this->ci->email->initialize($this->ci->config->config["mail"]);
// Loading models
$this->ci->load->model('system/Message_model', 'MessageModel');
$this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel');
$this->ci->load->model('system/Recipient_model', 'RecipientModel');
$this->ci->load->model('system/Attachment_model', 'AttachmentModel');
$this->ci->load->model("system/Message_model", "MessageModel");
$this->ci->load->model("system/MsgStatus_model", "MsgStatusModel");
$this->ci->load->model("system/Recipient_model", "RecipientModel");
$this->ci->load->model("system/Attachment_model", "AttachmentModel");
// Loads fhc helper
$this->ci->load->helper('fhc');
$this->ci->load->helper("fhc");
//$this->ci->load->helper('language');
$this->ci->lang->load('message');
$this->ci->lang->load("message");
}
// ------------------------------------------------------------------------
@@ -52,19 +51,22 @@ class MessageLib
* @param integer $msg_id REQUIRED
* @return array
*/
function getMessage($msg_id)
public function getMessage($msg_id)
{
if (!is_numeric($msg_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
$this->ci->MessageModel->addJoin('public.tbl_person', 'person_id');
$msg = $this->ci->MessageModel->loadWhere(array('message_id' => $msg_id));
//$msg = $this->ci->MessageModel->getMessage($msg_id);
$stat = $this->ci->MsgStatusModel->loadWhere(array('message_id' => $msg_id));
$this->ci->MessageModel->addJoin("public.tbl_person", "person_id");
$msg = $this->ci->MessageModel->loadWhere(array("message_id" => $msg_id));
// Sorts the statuses by the insert date, so the first in the array is the most updated
$this->ci->MsgStatusModel->addOrder("insertamum", "DESC");
$stat = $this->ci->MsgStatusModel->loadWhere(array("message_id" => $msg_id));
$msg->retval[0]->stat = $stat->retval;
$recp = $this->ci->RecipientModel->loadWhere(array('message_id' => $msg_id));
$recp = $this->ci->RecipientModel->loadWhere(array("message_id" => $msg_id));
$msg->retval[0]->recp = $recp->retval;
$attm = $this->ci->AttachmentModel->loadWhere(array('message_id' => $msg_id));
$attm = $this->ci->AttachmentModel->loadWhere(array("message_id" => $msg_id));
$msg->retval[0]->attm = $attm->retval;
return $msg;
@@ -76,7 +78,7 @@ class MessageLib
* @param string $uid REQUIRED
* @return array
*/
function getMessagesByUID($uid, $all = false)
public function getMessagesByUID($uid, $all = false)
{
if (empty($uid))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
@@ -92,7 +94,7 @@ class MessageLib
* @param bigint $person_id REQUIRED
* @return array
*/
function getMessagesByPerson($person_id, $all = false)
public function getMessagesByPerson($person_id, $all = false)
{
if (empty($person_id))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
@@ -110,7 +112,7 @@ class MessageLib
* @param integer $msg_id REQUIRED
* @return array
*/
function getSubMessages($msg_id)
public function getSubMessages($msg_id)
{
if (!is_numeric($msg_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
@@ -124,7 +126,7 @@ class MessageLib
* @param token string
* @return array
*/
function getMessagesByToken($token)
public function getMessagesByToken($token)
{
if (empty($token))
return $this->_error(MSG_ERR_INVALID_MSG_ID);
@@ -132,31 +134,33 @@ class MessageLib
$result = $this->ci->MessageModel->getMessagesByToken($token);
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
if ($result->retval[0]->status == MSG_STATUS_UNREAD)
// Searches for a status that is different from unread
$found = -1;
for ($i = 0; $i < count($result->retval); $i++)
{
if ($result->retval[$i]->status > MSG_STATUS_UNREAD)
{
$found = $i;
break;
}
}
// If not found then insert the read status
if ($found == -1)
{
$statusKey = array(
'message_id' => $result->retval[0]->message_id,
'person_id' => $result->retval[0]->receiver_id,
'status' => MSG_STATUS_UNREAD
"message_id" => $result->retval[0]->message_id,
"person_id" => $result->retval[0]->receiver_id,
"status" => MSG_STATUS_READ
);
$resTmp = $this->ci->MsgStatusModel->update($statusKey, array('status' => MSG_STATUS_READ));
if (!is_object($resTmp) || (is_object($resTmp) && $resTmp->error != EXIT_SUCCESS))
{
$result = $resTmp;
}
else
{
$result->retval[0]->status = MSG_STATUS_READ;
}
$result = $this->ci->MsgStatusModel->insert($statusKey);
}
}
return $result;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
/**
@@ -167,7 +171,7 @@ class MessageLib
* @param integer $status_id REQUIRED - should come from config/message.php list of constants
* @return array
*/
function updateMessageStatus($message_id, $person_id, $status)
public function updateMessageStatus($message_id, $person_id, $status)
{
if (empty($message_id))
{
@@ -185,10 +189,23 @@ class MessageLib
return $this->_invalid_id(MSG_ERR_INVALID_STATUS_ID);
}
$result = $this->ci->MsgStatusModel->update(
array('message_id' => $message_id, 'person_id' => $person_id),
array('status' => $status)
);
// Searches if the status is already present
$result = $this->ci->MsgStatusModel->load(array($message_id, $person_id, $status));
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
// status already present
}
else
{
// Insert the new status
$statusKey = array(
"message_id" => $message_id,
"person_id" => $person_id,
"status" => $status
);
$result = $this->ci->MsgStatusModel->insert($statusKey);
}
return $result;
}
@@ -202,7 +219,7 @@ class MessageLib
* @param integer $user_id REQUIRED
* @return array
*/
function addRecipient($person_id)
public function addRecipient($person_id)
{
if (!is_numeric($person_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
@@ -212,8 +229,6 @@ class MessageLib
return true;
}
// ------------------------------------------------------------------------
/**
@@ -226,7 +241,7 @@ class MessageLib
* @param integer $priority
* @return array
*/
function sendMessage($sender_id, $subject = '', $body = '', $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null)
public function sendMessage($sender_id, $subject = "", $body = "", $priority = PRIORITY_NORMAL, $relationmessage_id = null, $oe_kurzbz = null)
{
if (!is_numeric($sender_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
@@ -235,12 +250,12 @@ class MessageLib
$this->ci->db->trans_start(false);
//save Message
$data = array(
'person_id' => $sender_id,
'subject' => $subject,
'body' => $body,
'priority' => $priority,
'relationmessage_id' => $relationmessage_id,
'oe_kurzbz' => $oe_kurzbz
"person_id" => $sender_id,
"subject" => $subject,
"body" => $body,
"priority" => $priority,
"relationmessage_id" => $relationmessage_id,
"oe_kurzbz" => $oe_kurzbz
);
$result = $this->ci->MessageModel->insert($data);
@@ -251,9 +266,9 @@ class MessageLib
*/
$msg_id = $result->retval;
$statusData = array(
'message_id' => $msg_id,
'person_id' => $sender_id,
'status' => MSG_STATUS_UNREAD
"message_id" => $msg_id,
"person_id" => $sender_id,
"status" => MSG_STATUS_UNREAD
);
$result = $this->ci->MsgStatusModel->insert($statusData);
}
@@ -282,13 +297,13 @@ class MessageLib
* @param integer $priority
* @return array
*/
function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null)
public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null)
{
if (!is_numeric($sender_id) || !is_numeric($receiver_id))
return $this->_invalid_id(MSG_ERR_INVALID_MSG_ID);
// Load reveiver data to get its relative language
$this->ci->load->model('person/Person_model', 'PersonModel');
$this->ci->load->model("person/Person_model", "PersonModel");
$result = $this->ci->PersonModel->load($receiver_id);
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
{
@@ -314,12 +329,12 @@ class MessageLib
$this->ci->db->trans_start(false);
// Save Message
$msgData = array(
'person_id' => $sender_id,
'subject' => $result->retval[0]->subject,
'body' => $parsedText,
'priority' => PRIORITY_NORMAL,
'relationmessage_id' => $relationmessage_id,
'oe_kurzbz' => $oe_kurzbz
"person_id" => $sender_id,
"subject" => $result->retval[0]->subject,
"body" => $parsedText,
"priority" => PRIORITY_NORMAL,
"relationmessage_id" => $relationmessage_id,
"oe_kurzbz" => $oe_kurzbz
);
$result = $this->ci->MessageModel->insert($msgData);
if (is_object($result) && $result->error == EXIT_SUCCESS)
@@ -327,18 +342,18 @@ class MessageLib
// Link the message with the receiver
$msg_id = $result->retval;
$recipientData = array(
'person_id' => $receiver_id,
'message_id' => $msg_id,
'token' => generateToken()
"person_id" => $receiver_id,
"message_id" => $msg_id,
"token" => generateToken()
);
$result = $this->ci->RecipientModel->insert($recipientData);
if (is_object($result) && $result->error == EXIT_SUCCESS)
{
// Save message status
$statusData = array(
'message_id' => $msg_id,
'person_id' => $receiver_id,
'status' => MSG_STATUS_UNREAD
"message_id" => $msg_id,
"person_id" => $receiver_id,
"status" => MSG_STATUS_UNREAD
);
$result = $this->ci->MsgStatusModel->insert($statusData);
}
@@ -362,21 +377,21 @@ class MessageLib
// Better message error
if (!is_array($result->retval) || (is_array($result->retval) && count($result->retval) == 0))
{
$result = $this->_error('Vorlage not found', EXIT_ERROR);
$result = $this->_error("Vorlage not found", EXIT_ERROR);
}
else if (is_array($result->retval) && count($result->retval) > 0)
{
if (is_null($result->retval[0]->oe_kurzbz))
{
$result = $this->_error('Vorlage not found', EXIT_ERROR);
$result = $this->_error("Vorlage not found", EXIT_ERROR);
}
else if (empty($result->retval[0]->text))
{
$result = $this->_error('Vorlage has an empty text', EXIT_ERROR);
$result = $this->_error("Vorlage has an empty text", EXIT_ERROR);
}
else if (empty($result->retval[0]->subject))
{
$result = $this->_error('Vorlage has an empty subject', EXIT_ERROR);
$result = $this->_error("Vorlage has an empty subject", EXIT_ERROR);
}
}
}
@@ -389,123 +404,6 @@ class MessageLib
return $result;
}
// ------------------------------------------------------------------------
// Private Functions from here out!
// ------------------------------------------------------------------------
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = MSG_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = '', $message = MSG_ERROR)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang('message_' . $message);
$return->retval = $retval;
return $return;
}
/**
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
private function _invalid_id($error = '')
{
return array(
'err' => 1,
'code' => $error,
'msg' => lang('message_'.$error)
);
}
/**
* Gets an item from the email configuration array
*/
private function getEmailCfgItem($itemName)
{
return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX);
}
/**
* Sends a single email
*/
private function sendOne($from, $to, $subject, $message, $alias = "", $cc = null, $bcc = null)
{
$this->ci->email->from($from, $alias);
$this->ci->email->to($to);
if (!is_null($cc)) $this->ci->email->cc($cc);
if (!is_null($bcc)) $this->ci->email->bcc($bcc);
$this->ci->email->subject($subject);
$this->ci->email->message($message);
// Avoid printing on standard output ugly error messages
return @$this->ci->email->send();
}
/**
* Update the table tbl_message_recipient
*/
private function _updateMessageRecipient($message_id, $receiver_id, $parameters)
{
$updated = false;
// Changes the status of the message from unread to read
$resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters);
// Checks if errors were occurred
if (is_object($resultUpdate) && $resultUpdate->error == EXIT_SUCCESS && is_array($resultUpdate->retval))
{
$updated = true;
}
return $updated;
}
/**
* Changes the status of the message from unsent to sent
*/
private function setMessageSent($message_id, $receiver_id)
{
$parameters = array("sent" => "NOW()", "sentinfo" => null);
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
/**
* Sets the sentInfo with the error
*/
private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null)
{
if (!is_null($prevSentInfo) && $prevSentInfo != "")
{
$sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo;
}
$parameters = array("sent" => null, "sentinfo" => $sentInfo);
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
/**
* Gets all the messages from DB and sends them via email
@@ -631,4 +529,120 @@ class MessageLib
return $sent;
}
// ------------------------------------------------------------------------
// Private Functions from here out!
// ------------------------------------------------------------------------
/** ---------------------------------------------------------------
* Success
*
* @param mixed $retval
* @return array
*/
protected function _success($retval, $message = MSG_SUCCESS)
{
$return = new stdClass();
$return->error = EXIT_SUCCESS;
$return->Code = $message;
$return->msg = lang("message_" . $message);
$return->retval = $retval;
return $return;
}
/** ---------------------------------------------------------------
* General Error
*
* @return array
*/
protected function _error($retval = "", $message = MSG_ERROR)
{
$return = new stdClass();
$return->error = EXIT_ERROR;
$return->Code = $message;
$return->msg = lang("message_" . $message);
$return->retval = $retval;
return $return;
}
/**
* Invalid ID
*
* @param integer config.php error code numbers
* @return array
*/
private function _invalid_id($error = "")
{
return array(
"err" => 1,
"code" => $error,
"msg" => lang("message_".$error)
);
}
/**
* Gets an item from the email configuration array
*/
private function getEmailCfgItem($itemName)
{
return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX);
}
/**
* Sends a single email
*/
private function sendOne($from, $to, $subject, $message, $alias = "", $cc = null, $bcc = null)
{
$this->ci->email->from($from, $alias);
$this->ci->email->to($to);
if (!is_null($cc)) $this->ci->email->cc($cc);
if (!is_null($bcc)) $this->ci->email->bcc($bcc);
$this->ci->email->subject($subject);
$this->ci->email->message($message);
// Avoid printing on standard output ugly error messages
return @$this->ci->email->send();
}
/**
* Update the table tbl_message_recipient
*/
private function _updateMessageRecipient($message_id, $receiver_id, $parameters)
{
$updated = false;
// Changes the status of the message from unread to read
$resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters);
// Checks if errors were occurred
if (is_object($resultUpdate) && $resultUpdate->error == EXIT_SUCCESS && is_array($resultUpdate->retval))
{
$updated = true;
}
return $updated;
}
/**
* Changes the status of the message from unsent to sent
*/
private function setMessageSent($message_id, $receiver_id)
{
$parameters = array("sent" => "NOW()", "sentinfo" => null);
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
/**
* Sets the sentInfo with the error
*/
private function setMessageError($message_id, $receiver_id, $sentInfo, $prevSentInfo = null)
{
if (!is_null($prevSentInfo) && $prevSentInfo != "")
{
$sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo;
}
$parameters = array("sent" => null, "sentinfo" => $sentInfo);
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
}
+54 -12
View File
@@ -8,11 +8,16 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
class MigrationLib extends CI_Migration
{
// Prefixes and separator for messages
private $MSG_PREFIX = "[-]";
private $INFO_PREFIX = "[I]";
private $ERROR_PREFIX = "[E]";
private $SEPARATOR = "------------------------------";
const MSG_PREFIX = "[-]";
const INFO_PREFIX = "[I]";
const ERROR_PREFIX = "[E]";
const SEPARATOR = "------------------------------";
// Console colors codes
const ERROR_COLOR = 31;
const INFO_COLOR = 33;
// HTML colors names
private $HTML_COLORS = array(31 => "red", 33 => "orange");
// Used to set if the migration process is called via command line or via browser
private $cli;
@@ -58,12 +63,42 @@ class MigrationLib extends CI_Migration
}
}
/**
* Returns the string needed to color the output
*/
private function getColored($color)
{
$colored = "%s";
if (!is_null($color))
{
if ($this->cli === true)
{
$colored = "\033[" . $color . "m%s\033[37m";
}
else
{
$colored = "<font color=\"" . $this->HTML_COLORS[$color] . "\">%s</font>";
}
}
return $colored;
}
/**
* Print a message, even colored if specified
*/
private function _print($prefix, $text, $color = null)
{
printf($this->getColored($color), sprintf("%s %s" . $this->getEOL(), $prefix, $text));
}
/**
* Prints a formatted message
*/
private function printMessage($message)
{
printf("%s %s" . $this->getEOL(), $this->MSG_PREFIX, $message);
$this->_print(MigrationLib::MSG_PREFIX, $message);
}
/**
@@ -71,7 +106,7 @@ class MigrationLib extends CI_Migration
*/
private function printInfo($info)
{
printf("%s %s" . $this->getEOL(), $this->INFO_PREFIX, $info);
$this->_print(MigrationLib::INFO_PREFIX, $info, MigrationLib::INFO_COLOR);
}
/**
@@ -79,7 +114,7 @@ class MigrationLib extends CI_Migration
*/
private function printError($error)
{
printf("%s %s" . $this->getEOL(), $this->ERROR_PREFIX, $error);
$this->_print(MigrationLib::ERROR_PREFIX, $error, MigrationLib::ERROR_COLOR);
}
/**
@@ -102,7 +137,9 @@ class MigrationLib extends CI_Migration
*/
protected function startUP()
{
$this->printInfo(sprintf("%s Start method up of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
$this->printInfo(sprintf("%s Start method up of class %s %s",
MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR)
);
}
/**
@@ -110,7 +147,9 @@ class MigrationLib extends CI_Migration
*/
protected function endUP()
{
$this->printInfo(sprintf("%s End method up of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
$this->printInfo(sprintf("%s End method up of class %s %s",
MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR)
);
}
/**
@@ -118,7 +157,9 @@ class MigrationLib extends CI_Migration
*/
protected function startDown()
{
$this->printInfo(sprintf("%s Start method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
$this->printInfo(sprintf("%s Start method down of class %s %s",
MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR)
);
}
/**
@@ -126,7 +167,9 @@ class MigrationLib extends CI_Migration
*/
protected function endDown()
{
$this->printInfo(sprintf("%s End method down of class %s %s", $this->SEPARATOR, get_called_class(), $this->SEPARATOR));
$this->printInfo(sprintf("%s End method down of class %s %s",
MigrationLib::SEPARATOR, get_called_class(), MigrationLib::SEPARATOR)
);
}
/**
@@ -477,7 +520,6 @@ class MigrationLib extends CI_Migration
}
}
/**
* Executes the given query
*/
+38
View File
@@ -0,0 +1,38 @@
<?php
if (! defined("BASEPATH")) exit("No direct script access allowed");
require_once APPPATH . "/libraries/MigrationLib.php";
class Migration_Akte extends MigrationLib
{
public function __construct()
{
parent::__construct();
}
public function up()
{
$this->startUP();
// Add nachgereicht_am to public.tbl_akte
$columns = array(
"nachgereicht_am" => array(
"type" => "date",
"null" => true
)
);
$this->addColumn("public", "tbl_akte", $columns);
$this->endUP();
}
public function down()
{
$this->startDown();
$this->dropColumn("public", "tbl_akte", "nachgereicht_am");
$this->endDown();
}
}
@@ -11,50 +11,4 @@ class Prestudent_model extends DB_Model
$this->dbTable = 'public.tbl_prestudent';
$this->pk = 'prestudent_id';
}
/**
* @return void
*/
public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '')
{
// Checks if the operation is permitted by the API caller
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('lehre.tbl_studienplan'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('lehre.tbl_studienplan'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_status'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_status'), FHC_MODEL_ERROR);
$query = "SELECT tbl_prestudentstatus.*,
bezeichnung AS studienplan_bezeichnung,
tbl_status.bezeichnung_mehrsprachig
FROM public.tbl_prestudentstatus LEFT JOIN lehre.tbl_studienplan USING (studienplan_id)
JOIN public.tbl_status USING (status_kurzbz)
WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz
AND prestudent_id = ?";
$parametersArray = array($prestudent_id);
if ($studiensemester_kurzbz != '')
{
array_push($parametersArray, $studiensemester_kurzbz);
$query .= ' AND studiensemester_kurzbz = ?';
}
if ($status_kurzbz != '')
{
array_push($parametersArray, $status_kurzbz);
$query .= ' AND status_kurzbz = ?';
}
$query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1';
$result = $this->db->query($query, $parametersArray);
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
}
@@ -12,4 +12,50 @@ class Prestudentstatus_model extends DB_Model
$this->pk = array('ausbildungssemester', 'studiensemester_kurzbz', 'status_kurzbz', 'prestudent_id');
$this->hasSequence = false;
}
/**
* @return void
*/
public function getLastStatus($prestudent_id, $studiensemester_kurzbz = '', $status_kurzbz = '')
{
// Checks if the operation is permitted by the API caller
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_prestudentstatus'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('lehre.tbl_studienplan'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('lehre.tbl_studienplan'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_status'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_status'), FHC_MODEL_ERROR);
$query = "SELECT tbl_prestudentstatus.*,
bezeichnung AS studienplan_bezeichnung,
tbl_status.bezeichnung_mehrsprachig
FROM public.tbl_prestudentstatus LEFT JOIN lehre.tbl_studienplan USING (studienplan_id)
JOIN public.tbl_status USING (status_kurzbz)
WHERE tbl_status.status_kurzbz = tbl_prestudentstatus.status_kurzbz
AND prestudent_id = ?";
$parametersArray = array($prestudent_id);
if ($studiensemester_kurzbz != '')
{
array_push($parametersArray, $studiensemester_kurzbz);
$query .= ' AND studiensemester_kurzbz = ?';
}
if ($status_kurzbz != '')
{
array_push($parametersArray, $status_kurzbz);
$query .= ' AND status_kurzbz = ?';
}
$query .= ' ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1';
$result = $this->db->query($query, $parametersArray);
if (is_object($result))
return $this->_success($result->result());
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}
}
+59 -58
View File
@@ -1,6 +1,6 @@
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! defined("BASEPATH")) exit("No direct script access allowed");
class Message_model extends DB_Model
{
@@ -10,8 +10,8 @@ class Message_model extends DB_Model
public function __construct()
{
parent::__construct();
$this->dbTable = 'public.tbl_msg_message';
$this->pk = 'message_id';
$this->dbTable = "public.tbl_msg_message";
$this->pk = "message_id";
}
public function getMessagesByUID($uid, $all)
@@ -21,50 +21,46 @@ class Message_model extends DB_Model
// if same user
if ($uid === getAuthUID())
{
if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message', FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> basis/message", FHC_MODEL_ERROR);
}
// if different user, for reading messages from other users
else
{
if (! $this->fhc_db_acl->isBerechtigt('basis/message', 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> basis/message:all', FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt("basis/message", "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> basis/message:all", FHC_MODEL_ERROR);
}
// get Data
$sql = 'SELECT uid,
person_id,
message_id,
subject,
body,
priority,
relationmessage_id,
oe_kurzbz,
$sql = "SELECT b.uid,
m.person_id,
m.message_id,
m.subject,
m.body,
m.priority,
m.relationmessage_id,
m.oe_kurzbz,
m.insertamum,
anrede,
titelpost,
titelpre,
nachname,
vorname,
vornamen,
status,
statusinfo,
p.anrede,
p.titelpost,
p.titelpre,
p.nachname,
p.vorname,
p.vornamen,
s.status,
s.statusinfo,
s.insertamum AS statusamum
FROM public.tbl_msg_message m JOIN public.tbl_person USING (person_id)
JOIN public.tbl_benutzer USING (person_id)
LEFT OUTER JOIN (
SELECT message_id, person_id, status, statusinfo, tbl_msg_status.insertamum
FROM public.tbl_msg_status INNER JOIN (
SELECT message_id, person_id, max(insertamum) AS insertamum
FROM public.tbl_msg_status
GROUP BY message_id, person_id
) status USING (message_id, person_id)
WHERE tbl_msg_status.insertamum=status.insertamum
) s USING (message_id, person_id)
WHERE uid = ?';
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (r.person_id = p.person_id)
JOIN public.tbl_benutzer b ON (r.person_id = b.person_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE b.uid = ?";
if (! $all)
$sql .= ' AND (status < 3 OR status IS NULL)';
$sql .= " AND (status < 3 OR status IS NULL)";
$result = $this->db->query($sql, array($uid));
if (is_object($result))
return $this->_success($result->result());
@@ -75,16 +71,16 @@ class Message_model extends DB_Model
public function getMessagesByPerson($person_id, $all)
{
// Check wrights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_recipient'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_recipient'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_message'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_message'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_person'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_person'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_status'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_status'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_person"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_person"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = 'SELECT r.message_id,
$sql = "SELECT r.message_id,
m.person_id,
m.subject,
m.body,
@@ -93,11 +89,13 @@ class Message_model extends DB_Model
m.oe_kurzbz,
s.status,
s.statusinfo,
s.updateamum
s.insertamum AS statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_person p ON (p.person_id = m.person_id)
JOIN public.tbl_msg_status s USING (message_id)
WHERE r.person_id = ?';
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (m.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.person_id = ?";
$result = $this->db->query($sql, array($person_id));
if (is_object($result))
@@ -109,14 +107,14 @@ class Message_model extends DB_Model
public function getMessagesByToken($token)
{
// Check wrights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_recipient'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_recipient'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_message'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_message'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz('public.tbl_msg_status'), 's'))
return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->getBerechtigungKurzbz('public.tbl_msg_status'), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_message"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_status"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_status"), FHC_MODEL_ERROR);
$sql = 'SELECT r.message_id,
$sql = "SELECT r.message_id,
r.person_id as receiver_id,
m.person_id as sender_id,
m.subject,
@@ -126,11 +124,14 @@ class Message_model extends DB_Model
m.oe_kurzbz,
s.status,
s.statusinfo,
s.updateamum
s.insertamum as statusamum
FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
JOIN public.tbl_msg_status s USING (message_id)
JOIN (
SELECT * FROM public.tbl_msg_status ORDER BY insertamum DESC LIMIT 1
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.token = ?
AND status < ?';
AND status < ?
ORDER BY s.insertamum DESC";
$result = $this->db->query($sql, array($token, MSG_STATUS_DELETED));
if (is_object($result))
@@ -11,7 +11,7 @@ class MsgStatus_model extends DB_Model
{
parent::__construct();
$this->dbTable = "public.tbl_msg_status";
$this->pk = array("message_id", "person_id");
$this->pk = array("message_id", "person_id", "status");
$this->hasSequence = false;
}
}
@@ -24,7 +24,7 @@ class Recipient_model extends DB_Model
*/
public function getMessages($kontaktType, $sent, $limit = null)
{
// Check wrights
// Check rights
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_recipient"), "s"))
return $this->_error(lang("fhc_".FHC_NORIGHT)." -> ".$this->getBerechtigungKurzbz("public.tbl_msg_recipient"), FHC_MODEL_ERROR);
if (! $this->fhc_db_acl->isBerechtigt($this->getBerechtigungKurzbz("public.tbl_msg_message"), "s"))
@@ -67,8 +67,6 @@ class Recipient_model extends DB_Model
array_push($parametersArray, $limit);
}
// Get data of the messages to sent
$result = $this->db->query($query, $parametersArray);
if (is_object($result))
+220
View File
@@ -0,0 +1,220 @@
<?php
/* Copyright (C) 2016 Technikum-Wien
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Andreas Moik <moik@technikum-wien.at>.
*/
require_once(dirname(__FILE__).'/../config/vilesci.config.inc.php');
require_once(dirname(__FILE__).'/../include/pdf.class.php');
require_once(dirname(__FILE__).'/../include/dokument_export.class.php');
require_once(dirname(__FILE__).'/../include/phrasen.class.php');
require_once(dirname(__FILE__).'/../include/prestudent.class.php');
require_once(dirname(__FILE__).'/../include/dms.class.php');
$sprache = getSprache();
$p=new phrasen($sprache);
$db = new basis_db();
$user = get_uid();
if(!isset($_GET["prestudent_ids"]) || !isset($_GET["vorlage_kurzbz"]))
die($p->t('anwesenheitsliste/fehlerhafteParameteruebergabe'));
$prestudent_ids = explode(";", $_GET["prestudent_ids"]);
if(count($prestudent_ids) < 1)
die($p->t('anwesenheitsliste/fehlerhafteParameteruebergabe'));
/*
* Temporaeren Ordner fuer die erstellung der Dokumente generieren
*/
$tmpDir = sys_get_temp_dir() . "/dokumentenakt_" . uniqid();
if (!file_exists($tmpDir))
mkdir($tmpDir, 0777, true);
/*
* converter classes
*/
$pdf = new pdf();
$docExp = new dokument_export();
/*
* Create Documents
*/
$allDocs = array();
foreach($prestudent_ids as $pid)
{
$prestudent = new prestudent();
if(!$prestudent->load($pid))
cleanUpAndDie($p->t('tools/studentWurdeNichtGefunden')."(".$pid.")", $tmpDir);
/*
* Deckblatt
*/
$filename = $tmpDir . "/".uniqid();
$doc = new dokument_export('Bewerberakt');
$doc->addDataArray(array('vorname' => $prestudent->vorname, 'nachname' => $prestudent->nachname),'bewerberakt');
if(!$doc->create('pdf'))
die($doc->errormsg);
// $doc->temp_filename = $filename;
$document = $doc->output(false);
$filename = $tmpDir.'/'.uniqid();
file_put_contents($filename, $document);
$doc->close();
$allDocs[] = $filename;
/*
* Get all Documents
*/
$query= '
SELECT
titel, dms_id, inhalt
FROM
public.tbl_dokumentstudiengang
JOIN public.tbl_prestudent USING(studiengang_kz)
JOIN public.tbl_akte USING(person_id,dokument_kurzbz)
WHERE
onlinebewerbung
AND prestudent_id='.$db->db_add_param($pid, FHC_INTEGER).';
';
$result = $db->db_query($query);
while($row = $db->db_fetch_object($result))
{
$filename = "";
if($row->dms_id != null)
{
$dms = new dms();
$dms->load($row->dms_id);
$filename = DMS_PATH . $dms->filename;
}
else if($row->inhalt != null)
{
$filename = $tmpDir . "/".uniqid();
$fileData = base64_decode($row->inhalt);
file_put_contents($filename, $fileData);
}
if($filename == "")
continue;
/*
* Determine the filetype
* and convert, if nessecary
*/
$explodedTitle = explode(".", $row->titel);
$type = $explodedTitle[count($explodedTitle)-1];
if($type == "jpg" || $type = "jpeg")
{
$fullFilename = $tmpDir . "/".uniqid() . ".pdf";
if(!$pdf->jpegToPdf($filename, $fullFilename))
cleanUpAndDie($pdf->errormsg, $tmpDir);
}
else if($type == "odt" || $type == "doc" || $type == "docx")
{
$fullFilename = $tmpDir . "/".uniqid() . ".pdf";
$docExp->convert($filename, $fullFilename, "pdf");
}
else if($type == "pdf")
{
$fullFilename = $row->titel;
}
else
cleanUpAndDie("falscher typ TODO", $tmpDir);
// only filled, if the file is supported
if($fullFilename != "")
{
$allDocs[] = $fullFilename;
}
}
}
/*
* generate the merged PDF
*/
$finishedPdf = $tmpDir . "/Dokumentenakt.pdf";
if(!$pdf->merge($allDocs, $finishedPdf))
cleanUpAndDie($pdf->errormsg, $tmpDir);
$fsize = filesize($finishedPdf);
if(!$handle = fopen($finishedPdf,'r'))
die('load failed');
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.$finishedPdf);
header('Content-Length: '.$fsize);
while (!feof($handle))
{
echo fread($handle, 8192);
}
fclose($handle);
/*
* Cleanup
*/
removeFolder($tmpDir);
/*
* Functions
*/
function cleanUpAndDie($msg, $tmpDir)
{
removeFolder($tmpDir);
die($msg);
}
function removeFolder($dir)
{
if($dir == "/")
return false;
if (is_dir($dir) === true)
{
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file)
{
unlink($dir . "/" . $file);
}
return rmdir($dir);
}
return false;
}
?>
+7
View File
@@ -120,6 +120,7 @@ foreach($addon_obj->result as $addon)
<command id="menu-statistic-studentendetails:command" oncommand="StatistikPrintStudentExportExtended();"/>
<command id="menu-statistic-lektorenstatistik:command" oncommand="StatistikPrintLektorenstatistik();"/>
<command id="menu-statistic-stromanalyse:command" oncommand="StatistikPrintStromanalyse();"/>
<command id="menu-dokumente-bewerberakt:command" oncommand="StudentPrintBewerberakt(event);"/>
<command id="menu-dokumente-inskriptionsbestaetigung:command" oncommand="StudentPrintInskriptionsbestaetigung(event);"/>
<command id="menu-dokumente-zeugnis:command" oncommand="StudentCreateZeugnis('Zeugnis',event);"/>
<command id="menu-dokumente-zeugniseng:command" oncommand="StudentCreateZeugnis('ZeugnisEng',event);"/>
@@ -475,6 +476,12 @@ foreach($addon_obj->result as $addon)
<!-- ********** DOKUMENTE ********** -->
<menu id="menu-dokumente" label="&menu-dokumente.label;" accesskey="&menu-dokumente.accesskey;">
<menupopup id="menu-dokumente-popup">
<menuitem
id = "menu-dokumente-bewerberakt"
key = "menu-dokumente-bewerberakt:key"
label = "&menu-dokumente-bewerberakt.label;"
command = "menu-dokumente-bewerberakt:command"
accesskey = "&menu-dokumente-bewerberakt.accesskey;"/>
<menuitem
id = "menu-dokumente-accountinfoblatt"
key = "menu-dokumente-accountinfoblatt:key"
+39
View File
@@ -2164,6 +2164,45 @@ function StudentPrintInskriptionsbestaetigung(event)
alert('Bitte einen Studenten auswaehlen');
}
// ****
// * Druckt den Bewerberakt
// ****
function StudentPrintBewerberakt(event)
{
tree = document.getElementById('student-tree');
//Alle markierten Studenten holen
var start = new Object();
var end = new Object();
var numRanges = tree.view.selection.getRangeCount();
var paramList= '';
var anzahl=0;
for (var t = 0; t < numRanges; t++)
{
tree.view.selection.getRangeAt(t,start,end);
for (var v = start.value; v <= end.value; v++)
{
var prestudent_id = getTreeCellText(tree, 'student-treecol-prestudent_id', v);
if(paramList!='')
paramList = paramList+";";
paramList += prestudent_id;
anzahl = anzahl+1;
}
}
if (event.shiftKey)
var output='odt';
else if (event.ctrlKey)
var output='doc';
else
var output='pdf';
if(anzahl>0)
window.open('<?php echo APP_ROOT; ?>content/dokumentenakt.pdf.php?prestudent_ids='+paramList+'&output='+output+'&vorlage_kurzbz=Bewerberakt','Bewerberakt', 'height=200,width=350,left=0,top=0,hotkeys=0,resizable=yes,status=no,scrollbars=yes,toolbar=no,location=no,menubar=no,dependent=yes');
else
alert('Bitte markieren Sie zuerst eine oder mehrere Personen');
}
// ****
// * Excel Export der Studentendaten
// ****
+29 -2
View File
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Andreas Moik <moik@technikum-wien.at>.
*/
require_once(dirname(__FILE__).'/vorlage.class.php');
require_once(dirname(__FILE__).'/addon.class.php');
@@ -37,8 +38,11 @@ class dokument_export
/**
* Konstruktor
*/
public function __construct($vorlage, $oe_kurzbz=0, $version=null)
public function __construct($vorlage = null, $oe_kurzbz=0, $version=null)
{
if(!isset($vorlage))
return;
//Vorlage aus der Datenbank holen
$this->vorlage = new vorlage();
if(!$this->vorlage->getAktuelleVorlage($oe_kurzbz, $vorlage, $version))
@@ -321,7 +325,7 @@ class dokument_export
}
else
{
$data = fread($handle, filesize($file));
$data = fread($handle, $fsize);
fclose($handle);
return $data;
}
@@ -389,5 +393,28 @@ class dokument_export
}
return $_xml_data->asXML();
}
/**
* Konvertiert ein Dokument in ein anderes Format
* @param string $inFile Origin File Path
* @param string $outFile Output file
* @param string $format Format to export To
* @return boolean
*/
public function convert($inFile, $outFile, $format = "pdf")
{
$command = 'unoconv --format %s --output %s %s';
$command = sprintf($command, $format, $outFile, $inFile);
exec($command, $out, $ret);
if($ret!=0)
{
$this->errormsg = 'Dokumentenkonvertierung ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
return false;
}
return true;
}
}
?>
+107
View File
@@ -0,0 +1,107 @@
<?php
/* Copyright (C) 2016 fhcomplete.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Andreas Moik <moik@technikum-wien.at>.
*/
class Pdf
{
public $errormsg = "";
/**
* Fügt beliebig viele PDF Dateien zu einer zusammen
* @param array $files Array mit Dateien
* @param string $outFile Zieldatei
* @return boolean
*/
public function merge($files, $outFile)
{
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile ";
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// add all pdf files to the command
foreach($files as $f)
{
$cmd .= $f." ";
if(!file_exists($f))
{
$this->errormsg = "File not found: '$f'";
return false;
}
if(finfo_file($finfo, $f) != "application/pdf")
{
$this->errormsg = "Wrong format: '$f'";
return false;
}
}
finfo_close($finfo);
exec($cmd, $out, $ret);
if($ret!=0)
{
$this->errormsg = 'PDF-zusammenfuegung ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
return false;
}
return true;
}
/**
* Konvertiert eine jpeg Datei zu einer PDF
* @param string $image jpeg Datei
* @param string $outFile Zieldatei
* @return boolean
*/
public function jpegToPdf($image, $outFile)
{
if(!file_exists($image))
{
$this->errormsg = "File not found: '$image'";
return false;
}
$s = getimagesize($image);
/*
* längere Seite ermitteln
* Hochformat wenn die Seiten gleich lang sind.
*/
if($s[0] > $s[1])
{
$height = 595;
$width = 842;
}
else
{
$height = 842;
$width = 595;
}
// -r300 = 300 ppi
$cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -r100 -o '.$outFile.' viewjpeg.ps -c "('.$image.') << /PageSize [' . $width . ' ' . $height .'] /.HWMargins [18 18 18 13.5] /countspaces { [ exch { dup 32 ne { pop } if } forall ] length } bind def >> setpagedevice viewJPEG"';
exec($cmd, $out, $ret);
if($ret!=0)
{
$this->errormsg = 'jpegToPdf ist derzeit nicht möglich. Bitte informieren Sie den Administrator';
return false;
}
return true;
}
}
+4
View File
@@ -191,6 +191,10 @@
<!ENTITY menu-dokumente-inskriptionsbestaetigung.label "Inskriptionsbestätigung">
<!ENTITY menu-dokumente-inskriptionsbestaetigung.accesskey "I">
<!ENTITY menu-dokumente-bewerberakt.key "B">
<!ENTITY menu-dokumente-bewerberakt.label "Bewerberakt">
<!ENTITY menu-dokumente-bewerberakt.accesskey "B">
<!ENTITY menu-dokumente-zeugnis.key "Z">
<!ENTITY menu-dokumente-zeugnis.label "Zeugnis Deutsch">
<!ENTITY menu-dokumente-zeugnis.accesskey "Z">
+33
View File
@@ -1297,6 +1297,39 @@ if(!@$db->db_query("SELECT bezeichnung_mehrsprachig FROM public.tbl_status LIMIT
}
/************************************ 07.16 Vorlage für bewerberakt ************************************/
if($result = $db->db_query("SELECT * FROM public.tbl_vorlage WHERE vorlage_kurzbz='Bewerberakt'"))
{
if($db->db_num_rows($result)==0)
{
$qry_oe = "SELECT oe_kurzbz FROM public.tbl_organisationseinheit WHERE oe_parent_kurzbz is null";
if($result = $db->db_query($qry_oe))
{
$qry = "INSERT INTO public.tbl_vorlage(vorlage_kurzbz, bezeichnung, anmerkung,mimetype)
VALUES('Bewerberakt','Bewerberakt Deckblatt', 'wird als Deckblatt fuer den Bewerberakt verwendet', 'application/vnd.oasis.opendocument.text');";
$text = file_get_contents('xsl/Bewerberakt.xsl');
while($row = $db->db_fetch_object($result))
{
$qry.="INSERT INTO public.tbl_vorlagestudiengang(vorlage_kurzbz, studiengang_kz, version, text,
oe_kurzbz, style, berechtigung, anmerkung_vorlagestudiengang, aktiv) VALUES(
'Bewerberakt',0,0,".$db->db_add_param($text).",".$db->db_add_param($row->oe_kurzbz).",null,null,'',true);";
}
}
if(!$db->db_query($qry))
echo '<strong>Bewerberakt Dokumentenvorlage: '.$db->db_last_error().'</strong><br>';
else
echo 'Bewerberakt Dokumentenvorlage hinzugefuegt<br>';
}
}
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
Binary file not shown.
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
>
<xsl:output method="xml" version="1.0" indent="yes"/>
<xsl:template match="bewerberakt">
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Heading_20_1"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/></style:style><style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard"><style:text-properties officeooo:rsid="0003bc74" officeooo:paragraph-rsid="0003bc74"/></style:style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Title">Bewerberakt</text:p><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:p text:style-name="P2"/><text:h text:style-name="P1" text:outline-level="1"><xsl:value-of select="vorname" /> <xsl:value-of select="nachname" /></text:h></office:text></office:body></office:document-content>
</xsl:template>
</xsl:stylesheet>
@@ -8,4 +8,14 @@ $I->haveHttpHeader("FHC-API-KEY", "testapikey@fhcomplete.org");
$I->sendGET("v1/system/message/MessagesByPersonID", array("person_id" => "1"));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["error" => 0]);
$I->sendGET("v1/system/message/MessagesByUID", array("uid" => "mckenzie"));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["error" => 0]);
$I->sendGET("v1/system/message/MessagesByToken", array("token" => "token"));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["error" => 0]);
@@ -8,4 +8,9 @@ $I->haveHttpHeader("FHC-API-KEY", "testapikey@fhcomplete.org");
$I->sendGET("v1/crm/Prestudentstatus/Prestudentstatus", array("ausbildungssemester" => "0", "studiensemester_kurzbz" => "0", "status_kurzbz" => "0", "prestudent_id" => "0"));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["error" => 0]);
$I->sendGET("v1/crm/Prestudentstatus/LastStatus", array("prestudent_id" => 3));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(["error" => 0]);