/** * get next services for current user * @param string $short * @return string */ function churchservice_getUserNextServices($short = true) { global $user; include_once './' . CHURCHDB . '/churchdb_db.php'; $pid = $user->id; $res = db_query("\n SELECT e.id event_id, cal.bezeichnung AS event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') AS datum,\n s.bezeichnung AS service, sg.bezeichnung AS servicegroup, cdb_person_id,\n DATE_FORMAT(es.modified_date, '%d.%m.%Y %H:%i') AS modified_date\n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_servicegroup} sg, {cs_service} s\n WHERE cal.id=e.cc_Cal_id AND e.valid_yn=1 AND cdb_person_id=:pid AND e.startdate>=current_date AND zugesagt_yn=1\n AND es.valid_yn=1 AND es.event_id=e.id AND es.service_id=s.id AND sg.id=s.servicegroup_id order by e.startdate", array(':pid' => $pid)); $nr = 0; $txt = ""; foreach ($res as $arr) { $nr++; if ($nr <= 5 || !$short) { $txt .= "<p><a href='?q=churchservice&id={$arr->event_id}'>{$arr->datum} - {$arr->event}</a>:\n <a href='?q=churchservice&id={$arr->event_id}'><b>{$arr->service}</b></a> ({$arr->servicegroup})"; $files = churchcore_getFilesAsDomainIdArr("service", $arr->event_id); $txt .= '<span class="pull-right">'; if (isset($files) && isset($files[$arr->event_id])) { $i = 0; foreach ($files[$arr->event_id] as $file) { $i++; if ($i < 4) { $txt .= churchcore_renderFile($file) . " "; } else { $txt .= "..."; } // TODO: ... for each additional file? } } $txt .= "</span><small><br> " . t("confirmed.on", $arr->modified_date) . "</small>"; } } return $txt; }
function churchservice_getUserNextServices($shorty = true) { global $user; include_once './' . CHURCHDB . '/churchdb_db.php'; $pid = $user->id; $res = db_query("SELECT e.id event_id, cal.bezeichnung event, DATE_FORMAT(e.startdate, '%d.%m.%Y %H:%i') datum, s.bezeichnung service, sg.bezeichnung servicegroup, cdb_person_id, DATE_FORMAT(es.modified_date, '%d.%m.%Y %H:%i') modified_date\n FROM {cs_eventservice} es, {cs_event} e, {cc_cal} cal, {cs_servicegroup} sg, {cs_service} s where\n cal.id=e.cc_Cal_id and e.valid_yn=1 and \n cdb_person_id={$pid} and e.startdate>=current_date and zugesagt_yn=1 and es.valid_yn=1 and es.event_id=e.id and es.service_id=s.id and sg.id=s.servicegroup_id order by e.startdate"); $nr = 0; $txt = ""; foreach ($res as $arr) { $nr = $nr + 1; if ($nr <= 5 || !$shorty) { $txt .= '<p><a href="?q=churchservice&id=' . $arr->event_id . '">' . $arr->datum . " - " . $arr->event . "</a>: "; $txt .= '<a href="?q=churchservice&id=' . $arr->event_id . '"><b>' . $arr->service . "</b></a> (" . $arr->servicegroup . ")"; $files = churchcore_getFilesAsDomainIdArr("service", $arr->event_id); $txt .= '<span class="pull-right">'; if (isset($files) && isset($files[$arr->event_id])) { $i = 0; foreach ($files[$arr->event_id] as $file) { $i++; if ($i < 4) { $txt .= churchcore_renderFile($file) . " "; } else { $txt .= "..."; } } } $txt .= "</span><small><br> "; $txt .= t("confirmed.on", $arr->modified_date) . "</small>"; } } return $txt; }