diff --git a/application/controllers/jobs/AmpelMail.php b/application/controllers/jobs/AmpelMail.php index f77122735..fdc6ad405 100644 --- a/application/controllers/jobs/AmpelMail.php +++ b/application/controllers/jobs/AmpelMail.php @@ -17,10 +17,10 @@ if (! defined('BASEPATH')) class AmpelMail extends FHC_Controller { const CIS_AMPELVERWALTUNG_URL = - CIS_ROOT. "index.php?sprache=German&content_id=&menu=". - CIS_ROOT. "menu.php?content_id=&content=". - CIS_ROOT. "private/tools/ampelverwaltung.php"; - + CIS_ROOT. "cis/index.php?menu=". + CIS_ROOT. "cis/menu.php?content_id=&content=". + CIS_ROOT. "cis/private/tools/ampelverwaltung.php"; + /** * Constructor */ @@ -39,11 +39,11 @@ class AmpelMail extends FHC_Controller echo "Jobs must be run from the CLI"; exit; } - + // Load models $this->load->model('content/Ampel_model', 'AmpelModel'); $this->load->model('person/Person_model', 'PersonModel'); - + // Load helpers $this->load->helper('sancho'); } @@ -60,7 +60,7 @@ class AmpelMail extends FHC_Controller echo $result. PHP_EOL; } - + /** * Generates mail content for new and overdue Ampeln, which * 1. are not confirmed by the user yet and @@ -81,7 +81,7 @@ class AmpelMail extends FHC_Controller if (hasData($result_active_ampeln)) { $ampel_arr = $result_active_ampeln->retval; - + // Loop through ampeln foreach ($ampel_arr as $ampel) { @@ -95,11 +95,11 @@ class AmpelMail extends FHC_Controller // get all user, who get this ampel $result_ampel_user = $this->AmpelModel->execBenutzerSelect($qry_all_ampel_user); - + if (hasData($result_ampel_user)) { $ampel_user_arr = $result_ampel_user->retval; - + // loop through all user, who get this ampel foreach ($ampel_user_arr as $ampel_user) { @@ -131,7 +131,7 @@ class AmpelMail extends FHC_Controller $html_text = '

'. strtoupper($ampel->kurzbz). '
- Die Deadline für die Bestätigung war am + Die Deadline für die Bestätigung war am '. date_format($deadline, 'Y-m-d'). '


'; @@ -177,7 +177,7 @@ class AmpelMail extends FHC_Controller ); }; } - + // ------------------------------------------------------------------------ // Private methods /** @@ -190,10 +190,10 @@ class AmpelMail extends FHC_Controller private function _getAmpelContentData($uid, $html_text, $ampel_data_arr) { $firstName = $this->PersonModel->getByUid($uid)->retval[0]->vorname; - + // check if user already exists in the array $key_position = array_search($uid, array_column($ampel_data_arr, 'uid')); - + // If user already exists in the array, add only new ampel data to users ampel list if ($key_position !== false) { diff --git a/application/models/content/Ampel_model.php b/application/models/content/Ampel_model.php index e569755df..aeb260a5c 100644 --- a/application/models/content/Ampel_model.php +++ b/application/models/content/Ampel_model.php @@ -10,7 +10,7 @@ class Ampel_model extends DB_Model $this->dbTable = 'public.tbl_ampel'; $this->pk = 'ampel_id'; } - + /** * Returns all active Ampeln, that are actually: * 1. not after the deadline date @@ -25,24 +25,24 @@ class Ampel_model extends DB_Model SELECT * FROM public.tbl_ampel WHERE'; - + if ($email === true) { $parametersArray['email'] = $email; $query .= ' email = ? AND'; } - + $query .= ' - (NOW()<(deadline+(verfallszeit || \' days\')::interval)::date) - OR (verfallszeit IS NULL AND NOW() < deadline) - AND (NOW()>(deadline-(vorlaufzeit || \' days\')::interval)::date) - OR (vorlaufzeit IS NULL AND NOW() > deadline)'; - + (NOW()<(deadline+(COALESCE(verfallszeit,0) || \' days\')::interval)::date) + OR (verfallszeit IS NULL) + AND (NOW()>(deadline-(COALESCE(vorlaufzeit,0) || \' days\')::interval)::date) + OR (vorlaufzeit IS NULL AND NOW() < deadline)'; + $query .= ' ORDER BY deadline DESC'; - + return $this->execQuery($query, $parametersArray); } - + /** * Returns all Ampel-receiver of a specific Ampel. * @param string $benutzer_select SQL Statement which defines the Ampel-receiver. @@ -55,7 +55,7 @@ class Ampel_model extends DB_Model return $this->execQuery($benutzer_select); } } - + /** * Checks if Ampel was confirmed by the user. * @param int $ampel_id Ampel-ID @@ -75,7 +75,7 @@ class Ampel_model extends DB_Model { $result = $this->execQuery($query, array($ampel_id, $uid)); } - + if ($result) { if (count($result->retval) > 0) @@ -87,7 +87,7 @@ class Ampel_model extends DB_Model return false; } } - else + else return $result; //will contain the error-msg from execQuery } } diff --git a/cis/ampel.php b/cis/ampel.php index e767d9a6f..9434d3fb7 100644 --- a/cis/ampel.php +++ b/cis/ampel.php @@ -24,75 +24,75 @@ function hide_ampel_div() if(is_user_logged_in()) { $user = get_uid(); - + $ampel = new ampel(); $ampel->loadUserAmpel($user); $rot=0; - $gelb = 0; + $gelb = 0; $gruen = 0; $verpflichtend = false; - $cnt_verpflichtend = 0; - $cnt_abgelaufen = 0; + $cnt_verpflichtend = 0; + $cnt_abgelaufen = 0; $cnt_notConf_notOverdue = 0; //counts mandatory, not confirmed && not overdued ampeln (for popup) - + $datum = new datum(); $now = $datum->mktime_fromdate(date('Y-m-d')); foreach($ampel->result as $row) - { + { $deadline =$datum->mktime_fromdate($row->deadline); $vorlaufzeit = $row->vorlaufzeit; $verfallszeit = $row->verfallszeit; $bestaetigt = $ampel->isBestaetigt($user, $row->ampel_id); $verpflichtend = $row->verpflichtend; $abgelaufen = false; - + $datum_liegt_vor_vorlaufzeit = false; $datum_liegt_nach_verfallszeit = false; - + if (!is_null($vorlaufzeit)) - $datum_liegt_vor_vorlaufzeit = $now < strtotime('-' . $vorlaufzeit . ' day', $deadline); - + $datum_liegt_vor_vorlaufzeit = $now < strtotime('-' . $vorlaufzeit . ' day', $deadline); + if (!is_null($verfallszeit)) $datum_liegt_nach_verfallszeit = $now > strtotime('+' . $verfallszeit . ' day', $deadline); - + //count mandatory if($verpflichtend == 't') $cnt_verpflichtend++; - + //count overdue if ($datum_liegt_nach_verfallszeit) $cnt_abgelaufen++; //set status if ($bestaetigt) - $gruen++; - else if ($now >= $deadline && !$datum_liegt_nach_verfallszeit && !$bestaetigt) + $gruen++; + else if ($now >= $deadline && !$datum_liegt_nach_verfallszeit && !$bestaetigt) $rot++; else if (!$datum_liegt_nach_verfallszeit && !$datum_liegt_vor_vorlaufzeit) - $gelb++; - + $gelb++; + //count mandatory ampeln that are not confirmed and not overdue (for popup) if ($verpflichtend == 't' && !$bestaetigt && !$datum_liegt_nach_verfallszeit && !$datum_liegt_vor_vorlaufzeit) - $cnt_notConf_notOverdue++; + $cnt_notConf_notOverdue++; } - + //if at least ONE mandatory notification, which is not overdue -> trigger notification-POPUP if ($cnt_notConf_notOverdue > 0) - { + { echo ' '; - + echo ' '; } - + //show & color header ampel-link if($rot > 0) echo ''.$p->t("tools/ampelsystem").'  |  '; elseif($gelb > 0) echo ''.$p->t("tools/ampelsystem").'  |  '; elseif($rot==0 || $rot <= $cnt_abgelaufen && $gelb==0) - echo ''.$p->t("tools/ampelsystem").'  |  '; + echo ''.$p->t("tools/ampelsystem").'  |  '; } else { echo ""; } -?> \ No newline at end of file +?> diff --git a/cis/index.php b/cis/index.php index 401f0d51f..60c9aceeb 100644 --- a/cis/index.php +++ b/cis/index.php @@ -165,11 +165,12 @@ $db = new basis_db(); - - - - - + + + + + +