/** * Get job tuples * @return mixed[int] The jobs */ private function getJobs() { $jobs = new Jobs(); $jobList = $jobs->getJobs(); Tools::usort($jobList); $smartyJobs = array(); $jobsWithoutSupport = array(); foreach ($jobList as $job) { $smartyJobs[$job->getId()] = array("name" => $job->getName(), "type" => $job->getType(), "typeName" => Job::$typeNames[$job->getType()], "color" => $job->getColor()); if (Jobs::JOB_SUPPORT != $job->getId() && Jobs::JOB_NA != $job->getId()) { $jobsWithoutSupport[] = $job->getId(); $smartyJobs[$job->getId()]["deletedJob"] = true; } } $formattedJobs = implode(", ", $jobsWithoutSupport); // if job already used for TimeTracking, delete forbidden $query2 = "SELECT jobid, COUNT(jobid) as count " . "FROM `codev_timetracking_table` " . "WHERE jobid IN ({$formattedJobs}) GROUP BY jobid;"; $result2 = SqlWrapper::getInstance()->sql_query($query2); if (!$result2) { return NULL; } while ($row = SqlWrapper::getInstance()->sql_fetch_object($result2)) { $smartyJobs[$row->jobid]["deletedJob"] = 0 == $row->count; } return $smartyJobs; }
* Homepage * Front page controller */ $app->get('/(:page)', function ($page = null) use($app) { global $categories; if (isset($page) && $page != '') { $content = R::findOne('pages', ' url=:url ', array(':url' => $page)); if ($content && $content->id) { // show page information $seo_title = $content->name . ' | ' . APP_NAME; $seo_desc = excerpt($content->description); $seo_url = BASE_URL . $page; $app->render(THEME_PATH . 'page.php', array('seo_url' => $seo_url, 'seo_title' => $seo_title, 'seo_desc' => $seo_desc, 'content' => $content)); } else { $app->flash('danger', 'The page you are looking for could not be found.'); $app->redirect(BASE_URL, 404); } } else { // show list of job $seo_title = APP_NAME; $seo_desc = APP_DESC; $seo_url = BASE_URL; $j = new Jobs(); foreach ($categories as $cat) { $jobs[$cat->id] = $j->getJobs(ACTIVE, $cat->id, 0, HOME_LIMIT); } $app->render(THEME_PATH . 'home.php', array('seo_url' => $seo_url, 'seo_title' => $seo_title, 'seo_desc' => $seo_desc, 'jobs' => $jobs)); } }); // Run app $app->run();
unset($_SESSION['email']); unset($_SESSION['is_admin']); $app->flash('success', 'Logout successful. Please login again.'); $app->redirect('login'); }); /* * Manage group * Manage inactive jobs, categories list, cities list */ $app->group('/manage', function () use($app) { // manage inactive jobs $app->get('/', 'validateUser', function () use($app) { global $categories; $j = new Jobs(); foreach ($categories as $cat) { $jobs[$cat->id] = $j->getJobs(INACTIVE, $cat->id); } $app->render(ADMIN_THEME . 'home.php', array('jobs' => $jobs)); }); /* * Manage categories group */ $app->group('/categories', function () use($app) { $app->post('/', 'isValidReferrer', 'validateUser', function () use($app) { $data = $app->request->post(); $c = new Categories($data['id']); $c->addCategory($data); if ($data && $data['id'] != '') { $message = 'Category was successfully updated.'; } else { $message = 'New category has been added.';