Example #1
0
    if (!$error) {
        $project->setItem($items);
        if ($project->save()) {
            $this->addTwigVars("validation_ok", true);
        } else {
            $this->addTwigVars("validation_ok", false);
        }
    } else {
        $this->addTwigVars("validation_ok", false);
    }
}
//Load projects
$obj_p = new Project();
// Today projects
$today = date('Y-m-d', time());
$todayProjects = $obj_p->getLastProjects($today);
$this->addTwigVars('todayProjects', $todayProjects);
// Yesterday projects
$yDay = date('Y-m-d', time());
$yesterday = strtotime('-1 day', strtotime($yDay));
$yesterday = date('Y-m-d', $yesterday);
$yesterdayProjects = $obj_p->getLastProjects($yesterday);
$this->addTwigVars('yesterdayProjects', $yesterdayProjects);
// 2 days ago projects
$twoDay = date('Y-m-d', time());
$twoAgo = strtotime('-2 day', strtotime($twoDay));
$twoAgo = date('Y-m-d', $twoAgo);
$twoAgoProjects = $obj_p->getLastProjects($twoAgo);
$this->addTwigVars('twoAgoProjects', $twoAgoProjects);
$template = $this->twig->loadTemplate('home.twig');
echo $template->render($this->twigVars);
//set new project object
$p = new Project();
// prepare day block
$datetime = DateTime::createFromFormat('Y-m-d', $last_date);
$datetime->sub(new DateInterval('P1D'));
$date = $datetime->format('Y-m-d');
$dateHeader = $datetime->format("l, F jS");
$headerBlock = '<div class="block-day">

    <time class="date center" datetime="' . $date . '">
        <i class="fa fa-calendar"></i>
            ' . $dateHeader . '
        </time>';
$footerBlock = '</div>';
//Limit our results within a specified date
$results = $p->getLastProjects($date);
if ($results) {
    //set new user
    $u = new User();
    if (!$_user->logged) {
        $modal = 'data-toggle="modal" data-target="#postModal"';
    }
    foreach ($results as $item) {
        if ($_user->logged) {
            if ($u->checkPoint($item->id, $_user->id)) {
                $point = '<a href="#" class="vote" data-id="' . $item->id . '" data-status="1" ' . $modal . '>
		        <i class="vote-icon-active fa fa-caret-square-o-up fa-2x"></i></a>';
            } else {
                $point = '<a href="#" class="vote" data-id="' . $item->id . '" data-status="0" ' . $modal . '>
		        <i class="vote-icon fa fa-caret-square-o-up fa-2x"></i></a>';
            }