Example #1
2
function test_date_sub()
{
    $datetime = date_create("2010-08-16");
    $interval = date_interval_create_from_date_string("2 weeks");
    $dt2 = date_sub($datetime, $interval);
    return date_format($dt2, "Y-m-d");
}
 public function jireRest(Request $request)
 {
     try {
         //$jira_rest = \Drupal::service('jira_rest.jira_rest_service');
         $container = \Drupal::getContainer();
         $jira = JiraRestController::create($container);
         $author_name = $jira->config('jira_rest.settings')->get('jira_rest.username');
         $interval = "-2d";
         $res = $jira->jira_rest_searchissue("updated >= " . $interval . " AND assignee in (" . $author_name . ")");
     } catch (JiraRestException $e) {
         $responce['messages'][] = $e->getMessage();
     }
     $responce = array();
     $interval = abs(intval($interval));
     $sub_days = "{$interval} days";
     $date = date_create();
     $toDate = date_format($date, 'Y-m-d');
     date_sub($date, date_interval_create_from_date_string($sub_days));
     $fromDate = date_format($date, 'Y-m-d');
     foreach ($res->issues as $issue) {
         $worklog = $jira->jira_rest_get_worklog($issue->key);
         foreach ($worklog->worklogs as $entry) {
             $shortDate = substr($entry->started, 0, 10);
             # keep a worklog entry on $key item,
             # iff within the search time period
             if ($entry->author->name == $author_name && $shortDate >= $fromDate && $shortDate <= $toDate) {
                 $responce[$issue->key] += $entry->timeSpentSeconds;
             }
         }
     }
 }
 /**
  * Loads a page in the registration process
  * Page 1 = Login information
  * Page 2 = Profile information
  * Page 3 = Profile information
  * Page 4 = Confirm information
  * @param $page int requested page number
  */
 public function page($page)
 {
     if (!isset($page)) {
         $page = 0;
     }
     if ($page == 1) {
         $this->view->title = 'Login information';
         $this->view->render('register/authenticationInfo');
     } elseif ($page == 2) {
         $this->view->title = 'Profile information';
         $this->view->genders = $this->model->getGenders();
         $this->view->maxDate = date_sub(date_create(), date_interval_create_from_date_string('13 years'));
         $this->view->minDate = date_sub(date_create(), date_interval_create_from_date_string('101 years'));
         $this->view->render('register/userInfo');
     } elseif ($page == 3) {
         $this->view->title = 'Profile information';
         $this->view->countries = $this->model->getCountries();
         $this->view->render('register/addressInfo');
     } elseif ($page == 4) {
         $this->view->title = 'Confirm information';
         if (isset($this->newUser['gender_id'])) {
             $this->view->gender = $this->model->getGender($this->newUser['gender_id']);
         }
         if (isset($this->newUser['country'])) {
             $this->view->country = $this->model->getCountry($this->newUser['country']);
         }
         $this->view->canSubmit = $this->validate();
         $this->view->render('register/regConfirm');
     } else {
         $this->view->render('register/index');
     }
 }
 /**
  * Creates a new Events entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Events();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     // On récupère la date de début et de fin d'évènement afin de les comparer
     $startEvent = $form->getViewData()->getStart();
     $startEvent_string = strftime("%A %#d %B %Y à %k:%M", $startEvent->getTimestamp());
     $endEvent = $form->getViewData()->getEnd();
     if ($form->isValid()) {
         // On détermine la différence entre les heures et les minutes
         $diffTime_min = date_diff($startEvent, $endEvent)->i;
         $diffTime_hour = date_diff($startEvent, $endEvent)->h;
         // Si la durée de l'event est inferieur à une heure, alors, on le met à une heure automatiquement
         if ($diffTime_min <= 59 && $diffTime_hour == 0) {
             date_sub($endEvent, date_interval_create_from_date_string($diffTime_min . 'min'));
             $entity->setEnd($endEvent->modify('+1 hours'));
         }
         $em = $this->getDoctrine()->getManager();
         $user = $this->container->get('security.token_storage')->getToken()->getUser();
         // On se protège de la faille XSS
         $entity->setTitre(htmlspecialchars($form->getViewData()->getTitre()));
         $entity->setResume(htmlspecialchars($form->getViewData()->getResume()));
         $entity->setDateAjout(new \DateTime());
         $entity->setIdUser($user);
         $this->colorEvent($entity);
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('agenda_homepage'));
     }
     return $this->render('AgendaBundle:Events:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'startEvent' => $startEvent_string));
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     if (Util::checkUserIsLoggedIn()) {
         $loggedInUserId = $session->get('user/id');
         $clientId = $session->get('client/id');
         $clientSettings = $session->get('client/settings');
     } else {
         $loggedInUserId = null;
         $clientId = $this->getRepository(UbirimiClient::class)->getClientIdAnonymous();
         $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     }
     $projectId = $request->get('id');
     $project = $this->getRepository(YongoProject::class)->getById($projectId);
     if ($project['client_id'] != $clientId) {
         return new RedirectResponse('/general-settings/bad-link-access-denied');
     }
     $currentDate = Util::getServerCurrentDateTime();
     $dateFrom = date_create(Util::getServerCurrentDateTime());
     $dateTo = date_format(date_create(Util::getServerCurrentDateTime()), 'Y-m-d');
     date_sub($dateFrom, date_interval_create_from_date_string('1 months'));
     $dateFrom = date_format($dateFrom, 'Y-m-d');
     $issueQueryParameters = array('project' => array($projectId), 'resolution' => array(-2));
     $issues = $this->getRepository(Issue::class)->getByParameters($issueQueryParameters, $loggedInUserId, null, $loggedInUserId);
     $hasGlobalAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_ADMINISTRATORS);
     $hasGlobalSystemAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_SYSTEM_ADMINISTRATORS);
     $hasAdministerProjectsPermission = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($clientId, $loggedInUserId, Permission::PERM_ADMINISTER_PROJECTS);
     $hasAdministerProject = $hasGlobalSystemAdministrationPermission || $hasGlobalAdministrationPermission || $hasAdministerProjectsPermission;
     $sectionPageTitle = $clientSettings['title_name'] . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / ' . $project['name'] . ' / Reports';
     $menuSelectedCategory = 'project';
     return $this->render(__DIR__ . '/../../Resources/views/project/ViewReportsSummary.php', get_defined_vars());
 }
Example #6
0
function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') > $dayofmonth) {
        // Billing day is past, so it is next month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 month'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 month'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' month'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' month'));
    }
    // date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 day'));
    $date_from = date_format($date_start, 'Ymd') . '000000';
    $date_to = date_format($date_end, 'Ymd') . '235959';
    date_sub($date_start, date_interval_create_from_date_string('1 month'));
    date_sub($date_end, date_interval_create_from_date_string('1 month'));
    $last_from = date_format($date_start, 'Ymd') . '000000';
    $last_to = date_format($date_end, 'Ymd') . '235959';
    $return = array();
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
 public function sendmailAction()
 {
     //Print header for log
     echo "********************\n";
     echo "sendmailAction START\n";
     echo date('Y-m-d H:i:s e') . "\n";
     echo "********************\n";
     //Initialize variables
     $sm = $this->getServiceLocator();
     $books = new Books($sm);
     $users = new Users($sm);
     $mailler = new Mailler($sm);
     //Get new books from last week
     $lastDate = date("o-m-d", date_sub(new DateTime(), date_interval_create_from_date_string("7 days"))->getTimestamp());
     $bookList = $books->listBooks(array("sql" => "date >= '{$lastDate}'"))->toArray();
     //Print list of new books
     echo "LIST OF BOOKS:\n";
     foreach ($bookList as $book) {
         echo "\t" . $book['title'] . "\n";
     }
     //Get list of subscribed users
     $userList = $users->listUsers("weeklynews = 1")->toArray();
     //Print list of subscribed users
     echo "LIST OF EMAILS:\n";
     foreach ($userList as $user) {
         echo "\t" . $user['email'] . "\n";
     }
     //Send mails if there is at least one new book
     if (count($bookList) > 0) {
         $mailler->newsletterEmail($userList, $bookList, date("d/m/o"));
     }
     die;
 }
Example #8
0
 public function beforeFilter()
 {
     //        if($this->Auth->user('role') != 'admin'){
     //            $this->Session->setFlash('No esta autorizado a consultar esa pagina');
     //            $this->redirect(array('controller' => 'application', 'action' => 'detail','addon.simplylock.theme.example'));
     //            die();
     //        }
     //algunas cosas de aca se tienen que validar en el metodo como es el caso del upload cuando este
     $this->Auth->allow('logout');
     //        if ($this->Session->check('Config.language')) {
     //            Configure::write('Config.language', $this->Session->read('Config.language'));
     //        }
     //        else{
     //            Configure::write('Config.language', 'esp');
     //        }
     $this->set('logged_in', $this->Auth->loggedIn());
     $this->set('userAutenticated', $this->Auth->user());
     $this->set('isadmin', $this->Auth->user()['role'] == 'admin' ? 1 : 0);
     //data for menu
     //put data en la pagina
     $config = $this->Configuration->find('first', array('conditions' => array('Configuration.id' => 1)));
     $dayToNew = $config['Configuration']['days_to_new'];
     $date = date_create('now');
     date_sub($date, date_interval_create_from_date_string($dayToNew . ' days'));
     $settings = array('conditions' => array('Application.created >= "' . $date->format('Y-m-d H:i:s') . '"'));
     $cantNew = $this->Application->find('count', $settings);
     $settings1 = array('conditions' => array('Application.recommended ' => 1));
     $cantRecomended = $this->Application->find('count', $settings1);
     $settings1 = array('conditions' => array('Application.verificate ' => 1));
     $cantverificate = $this->Application->find('count', $settings1);
     $this->set('cantnews', $cantNew);
     $this->set('recommended', $cantRecomended);
     $this->set('verificate', $cantverificate);
 }
Example #9
0
 /**
  * Return an array of raw html notifications, delay in [s]
  */
 private function getAndIndexNotifications($daysBack = 14, $delay = 0.5)
 {
     $date = new DateTime();
     // DateTime::createFromFormat('d-m-Y', $enddate);
     date_sub($date, date_interval_create_from_date_string($daysBack . ' days'));
     $p = 0;
     $alreadyStoredPages = 0;
     // remove database entries older than given date
     $this->deleteEntriesInDatabase($date);
     $Scraper = new P2000Scraper("http://www.p2000-online.net/alleregiosf.html");
     while ($this->entriesInDatabase($date) == 0) {
         //&& $alreadyStoredPages<5) {
         $Scraper->scrapePage();
         $now = round(microtime(true) * 1000);
         $alreadyStored = $this->indexNotifications($Scraper->getRawNotifications());
         $elapsed = round(microtime(true) * 1000) - $now;
         if ($elapsed < $delay * 1000.0) {
             // ensure proper delay between requests
             usleep(($delay - $elapsed / 1000.0) * 1000000);
         }
         $end = round(microtime(true) * 1000) - $now;
         if ($alreadyStored == 15) {
             $alreadyStoredPages++;
         }
         $Scraper->clearRawNotifications();
         $Scraper->loadNextPage();
         $p++;
         //echo "Scraped " . $p . " pages - Time elapsed: " . $elapsed . "[ms] <br/>"; // for webpage
         fwrite(STDOUT, "\n\tScraped " . $p . " pages - Time elapsed: " . $end . "[ms]\n");
         // for CLI
         $amount = $this->entriesInDatabase($date);
         fwrite(STDOUT, $amount . " pages indexed of date: " . $date->format('d-m-Y') . "\n");
         //->format('d-m-Y')."\n");
     }
 }
Example #10
0
    public function show()
    {
        //nuvarande månad
        $d = "20" . $this->year . "-" . $this->monthNr . "-01";
        $date = date_create($d);
        //nästa månad
        $nextdate = date_add($date, date_interval_create_from_date_string('1 month'));
        $next = "y=" . date_format($nextdate, "y") . "&amp;m=" . date_format($nextdate, "n");
        //föregående månad
        $prevdate = date_sub($date, date_interval_create_from_date_string('2 months'));
        $prev = "y=" . date_format($prevdate, "y") . "&amp;m=" . date_format($prevdate, "n");
        $html = <<<EOT
     <header>
     <a class="left navsquare" href="?p=calendar&amp;{$prev}">&#10094;</a>
     <a class="right navsquare" href="?p=calendar&amp;{$next}">&#10095;</a>
     <h2 class="strokeme">{$this->month} 20{$this->year}</h2>
     <img class="header" src="img/calendar/{$this->getMonthImage()}" 
     alt="image of the month"></header>
     

    <section>\t
     {$this->calendarTable()}
     {$this->showHollidays()}
    </section>
EOT;
        return $html;
    }
function getDates($dayofmonth, $months = 0)
{
    $dayofmonth = zeropad($dayofmonth);
    $year = date('Y');
    $month = date('m');
    if (date('d') >= $dayofmonth) {
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_add($date_end, date_interval_create_from_date_string('1 月'));
    } else {
        // Billing day will happen this month, therefore started last month
        $date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
        $date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
        date_sub($date_start, date_interval_create_from_date_string('1 月'));
    }
    if ($months > 0) {
        date_sub($date_start, date_interval_create_from_date_string($months . ' 月'));
        date_sub($date_end, date_interval_create_from_date_string($months . ' 月'));
    }
    #  date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 天'));
    $date_from = date_format($date_start, 'Ymd') . "000000";
    $date_to = date_format($date_end, 'Ymd') . "235959";
    date_sub($date_start, date_interval_create_from_date_string('1 月'));
    date_sub($date_end, date_interval_create_from_date_string('1 月'));
    $last_from = date_format($date_start, 'Ymd') . "000000";
    $last_to = date_format($date_end, 'Ymd') . "235959";
    $return['0'] = $date_from;
    $return['1'] = $date_to;
    $return['2'] = $last_from;
    $return['3'] = $last_to;
    return $return;
}
Example #12
0
 public function indexAction($actif, $page, $maxPerPage)
 {
     $em = $this->getDoctrine()->getManager();
     $layout = $this->getLayout($em);
     // $maxPerPage = 1;
     // suppression des offres datant de plus d'un an
     $dateOld = new \Datetime();
     date_sub($dateOld, date_interval_create_from_date_string('1 year'));
     $query = $this->getDoctrine()->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findOld($dateOld);
     $offresOld = $query->getResult();
     for ($i = 0; $i < sizeof($offresOld); $i++) {
         $em->remove($offresOld[$i]);
         $em->flush();
     }
     switch ($actif) {
         case 'actif':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'A'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         case 'inactif':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'F'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         case 'tous':
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array(), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             break;
         default:
             $offres = $em->getRepository('AMiEOffreEmploiBundle:OffreEmploi')->findBy(array('actif' => 'A'), array('updatedDate' => 'DESC'));
             $pagerfanta = new Pagerfanta(new ArrayAdapter($offres));
             $pagerfanta->setMaxPerPage($maxPerPage);
             try {
                 $pagerfanta->setCurrentPage($page);
             } catch (NotValidCurrentPageException $e) {
                 throw new NotFoundHttpException();
             }
             $actif = 'actif';
             break;
     }
     return $this->render('AMiEOffreEmploiBundle:Offres:index.html.twig', array('layout' => $layout, 'actif' => $actif, 'offres' => $pagerfanta));
 }
Example #13
0
function getTimeRange($deltaTime)
{
    global $toDate, $fromDate;
    $toDate = date_create(date("Y-m-d"));
    $fromDate = date_create(date("Y-m-d"));
    date_sub($fromDate, date_interval_create_from_date_string($deltaTime));
    $fromDate = date_format($fromDate, "Y-m-d");
    $toDate = date_format($toDate, "Y-m-d");
}
Example #14
0
 function getHomeTopNews($catId = 0)
 {
     global $_CORELANG, $objDatabase;
     $catId = intval($catId);
     $i = 0;
     $this->_objTemplate->setTemplate($this->_pageContent, true, true);
     if ($this->_objTemplate->blockExists('newsrow')) {
         $this->_objTemplate->setCurrentBlock('newsrow');
     } else {
         return null;
     }
     $newsLimit = intval($this->arrSettings['news_top_limit']);
     if ($newsLimit > 50) {
         //limit to a maximum of 50 news
         $newsLimit = 50;
     }
     if ($newsLimit < 1) {
         //do not get any news if 0 was specified as the limit.
         $objResult = false;
     } else {
         //fetch news
         $objResult = $objDatabase->SelectLimit("\n                SELECT DISTINCT(tblN.id) AS id,\n                       tblN.`date`, \n                       tblN.teaser_image_path,\n                       tblN.teaser_image_thumbnail_path,\n                       tblN.redirect,\n                       tblN.publisher,\n                       tblN.publisher_id,\n                       tblN.author,\n                       tblN.author_id,\n                       tblL.title AS title, \n                       tblL.teaser_text\n                  FROM " . DBPREFIX . "module_news AS tblN\n            INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n            INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n                  WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n                   AND tblN.teaser_only='0'\n                   AND tblL.lang_id=" . FRONTEND_LANG_ID . "\n                   AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n                   AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid=" . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . "ORDER BY\n                       (SELECT COUNT(*) FROM " . DBPREFIX . "module_news_stats_view WHERE news_id=tblN.id AND time>'" . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' day')), 'Y-m-d H:i:s') . "') DESC", $newsLimit);
     }
     if ($objResult !== false && $objResult->RecordCount()) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['id'];
             $newstitle = $objResult->fields['title'];
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $newsCategories = $this->getCategoriesByNewsId($newsid);
             $newsUrl = empty($objResult->fields['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher)));
             if (!empty($image)) {
                 $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->parse('news_image');
                 }
             } else {
                 if ($this->_objTemplate->blockExists('news_image')) {
                     $this->_objTemplate->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             $this->_objTemplate->parseCurrentBlock();
             $i++;
             $objResult->MoveNext();
         }
     } else {
         $this->_objTemplate->hideBlock('newsrow');
     }
     $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']);
     return $this->_objTemplate->get();
 }
 function date_subtract($no_of_days, $start_date = NULL, $format = "Y-m-d")
 {
     if (isset($start_date)) {
         $date = $start_date;
     } else {
         $date = date_create(date("Y-m-d"));
     }
     date_sub($date, date_interval_create_from_date_string($no_of_days . ' days'));
     return date_format($date, $format);
 }
 public function last30days($project_id)
 {
     $user = \Auth::user();
     $today = new \Datetime();
     $time_ago = new \Datetime();
     date_sub($time_ago, date_interval_create_from_date_string('31 days'));
     $project = $user->projects()->where('id', '=', $project_id)->get()->first();
     $str = $time_ago->format('Y-m-d H:i:s');
     $times = $project->times()->where('times.created_at', '>=', $str)->get();
     return view('dashboard.last30days', ['times' => $times, 'time_ago' => $time_ago, 'today' => $today]);
 }
Example #17
0
 public static function subtractOneDayTodate($date)
 {
     //echo "original".$date."<br>";
     $date = date_create($date);
     //echo "data = ".$date;
     date_sub($date, date_interval_create_from_date_string("1 days"));
     //echo date_format($date, Generalkeys::PATTERN_DATE_MYSQL);
     $fechaParts = explode('-', trim(date_format($date, Generalkeys::PATTERN_DATE_MYSQL)));
     // yyyy/mm/dd
     return $fechaParts[Generalkeys::NUMBER_ZERO] . Generalkeys::STRING_DASH . $fechaParts[Generalkeys::NUMBER_ONE] . Generalkeys::STRING_DASH . $fechaParts[Generalkeys::NUMBER_TWO];
 }
Example #18
0
function countView($lessonid, $days, $dbnew)
{
    $date = date('Y-m-d');
    $lday = date_create($date);
    date_sub($lday, date_interval_create_from_date_string("{$days} days"));
    $lastday = date_format($lday, "Y-m-d");
    /*echo $lastday,$date;*/
    $stat = $dbnew->query("SELECT SUM(view_count) AS VIEWS FROM viewcount WHERE lesson_id = :id and v_date<=:tday and v_date >:lastday", array("id" => $lessonid, "tday" => $date, "lastday" => $lastday));
    $stat = $stat[0]["VIEWS"];
    if ($stat == false) {
        return 0;
    }
    return $stat;
}
Example #19
0
function getSchedulePeriod($year, $weekno)
{
    $a = array();
    $data = date_create($year . '-1-1');
    $size = ($weekno - 1) * 7;
    $dow = date_format($data, 'N') - 1;
    date_add($data, new DateInterval('P' . $size . 'D'));
    date_sub($data, new DateInterval('P' . $dow . 'D'));
    $a['date_begin'] = $data;
    $data1 = date_create(date_format($data, 'Y-m-d'));
    date_add($data1, new DateInterval('P6D'));
    $a['date_end'] = $data1;
    return $a;
}
 public static function addOmsConfUsageClientAreaPage($vars)
 {
     global $product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url;
     $clientId = $_SESSION['uid'];
     if (is_numeric($clientId)) {
         $whmcsDbService = new \Opennode\Whmcs\Service\WhmcsDbService();
         $whmcsExternalService = new \Opennode\Whmcs\Service\WhmcsExternalService($whmcs_admin_user, $whmcs_admin_password, $whmcs_api_url, $oms_usage_db);
         $omsReduction = new \Opennode\Whmcs\Service\OmsReductionService($product_core_name, $product_disk_name, $product_memory_name, $oms_usage_db, $whmcsExternalService, $whmcsDbService);
         $startDate = date_sub(date_create(), date_interval_create_from_date_string("1 months"));
         $endDate = date_create();
         $confChanges = $omsReduction->findClientConfChanges($clientId, $startDate, $endDate);
         $parsedChanges = $omsReduction->parseClientConfChanges($confChanges, $clientId);
         return array("omsconfs" => $parsedChanges);
     }
 }
/**
 * @param $auction DbAuction
 * @param $numViews int
 */
function addViews($auction, $numViews)
{
    global $faker;
    //var_dump($auction);
    $startTime = new DateTime($auction->getField("startTime"));
    $endTime = new DateTime($auction->getField("endTime"));
    //echo "startTime: " . $startTime->getTimestamp() . "\t";
    //echo "endTime: " . $endTime->getTimestamp() . "\t";
    date_sub($endTime, date_interval_create_from_date_string("5 seconds"));
    $timeDiff = (int) ($endTime->getTimestamp() - $startTime->getTimestamp());
    //echo "timeDiff: ".$timeDiff . "\t";
    for ($i = 0; $i < $numViews; $i++) {
        $viewTime = new DateTime('@' . ($startTime->getTimestamp() + $faker->numberBetween(1, $timeDiff)));
        addViedAtTime($auction, $viewTime);
    }
}
 /**
  * Expedited orders
  *
  * @param Model $Model
  * @param int $day
  * @param bool|true $count
  * @param bool $non_shipped
  * @return mixed
  */
 public function expeditedOrders(Model $Model, $day = 0, $count = true, $non_shipped = false)
 {
     $Model->useDbConfig = 'replicated';
     $Model->virtualFields = [];
     $now = new DateTime();
     if ($now->format('H') > 11) {
         $now = new DateTime('today noon');
     } else {
         $now = new DateTime('yesterday noon');
     }
     $now = date_sub($now, date_interval_create_from_date_string($day . ' days'));
     $current_day = new DateTime();
     //long story short this is confusing stuff because now becomes yesterday in certain cases.
     if ($current_day->format('D') == 'Mon') {
         $expedited_shipping_date = date_sub($now, date_interval_create_from_date_string('3 days'));
     } elseif ($current_day->format('D') == 'Sun') {
         $expedited_shipping_date = date_sub($now, date_interval_create_from_date_string('2 days'));
     } elseif ($current_day->format('D') == 'Sat') {
         $expedited_shipping_date = date_sub($now, date_interval_create_from_date_string('1 days'));
     } else {
         $expedited_shipping_date = $now;
     }
     $expedited_shipping_date_formatted = $expedited_shipping_date->format('Y-m-d H:i:s');
     if ($count == true) {
         $find = 'count';
         $fields = ['COUNT(DISTINCT Order.id) as count'];
         $limit = '';
     } else {
         $find = 'all';
         $fields = ['Order.id', 'Order.date_completed', 'Order.order_market_id', 'Order.user_id', 'Order.presenter_id'];
         $limit = 100;
     }
     if ($day != 0) {
         // If subtracting days only show entered status orders
         $expedited_shipping_date_formatted_range = date_sub($now, date_interval_create_from_date_string('1 days'))->format('Y-m-d H:i:s');
         $conditions = ['Order.order_status_id' => [Order::STATUS_ENTERED], 'Order.order_type_id !=' => Order::TYPE_REPLACEMENT, 'Order.date_completed >=' => $expedited_shipping_date_formatted_range, 'Order.date_completed <=' => $expedited_shipping_date_formatted, 'OrderShipment.shipment_method' => OrderShipmentMethod::$expedited_shipment_methods];
     } else {
         if ($non_shipped) {
             $status = [Order::STATUS_ENTERED, Order::STATUS_PRINTED, Order::STATUS_PROCESSING];
         } else {
             $status = [Order::STATUS_ENTERED, Order::STATUS_PRINTED, Order::STATUS_PROCESSING, Order::STATUS_SHIPPED];
         }
         $conditions = ['Order.order_status_id' => $status, 'Order.order_type_id !=' => Order::TYPE_REPLACEMENT, 'Order.date_completed >=' => $expedited_shipping_date_formatted, 'OrderShipment.shipment_method' => OrderShipmentMethod::$expedited_shipment_methods];
     }
     $result = $Model->find($find, ['fields' => $fields, 'conditions' => $conditions, 'contain' => ['OrderShipment', 'Order' => ['Error', 'OrderCustomer' => ['Address', 'Email', 'Phone']]], 'joins' => [['table' => 'orders', 'alias' => 'Order', 'type' => 'INNER', 'conditions' => ['Order.id = OrderShipment.order_id']]], 'limit' => $limit]);
     return $result;
 }
Example #23
0
 public static function get()
 {
     $return = array();
     $meteo = Database::getMeteo(self::$table);
     if (empty($meteo)) {
         Database::insertMeteo(self::$table);
         return self::refresh();
     }
     $now = date_create();
     $interval = date_interval_create_from_date_string(self::$intervalRefresh);
     $dateRefresh = date_sub($now, $interval);
     if ($meteo['date_maj'] < $dateRefresh->format('Y-m-d H:i:s')) {
         return self::refresh();
     }
     $return['today'] = json_decode(SqlFields::unprotect($meteo['today']), true);
     $return['next'] = json_decode(SqlFields::unprotect($meteo['next']), true);
     return $return;
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     $projectId = $request->request->get('id');
     $loggedInUserId = $session->get('user/id');
     $clientId = $session->get('client/id');
     $client = $this->getRepository(UbirimiClient::class)->getById($clientId);
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     if (Util::checkUserIsLoggedIn()) {
         $hasBrowsingPermission = $this->getRepository(YongoProject::class)->userHasPermission(array($projectId), Permission::PERM_BROWSE_PROJECTS, $loggedInUserId);
     } else {
         $loggedInUserId = null;
         $httpHOST = Util::getHttpHost();
         $hasBrowsingPermission = $this->getRepository(YongoProject::class)->userHasPermission(array($projectId), Permission::PERM_BROWSE_PROJECTS);
     }
     if ($hasBrowsingPermission) {
         $helpDeskFlag = 0;
         if ($session->get('selected_product_id') == SystemProduct::SYS_PRODUCT_HELP_DESK) {
             $helpDeskFlag = 1;
         }
         $endDate = Util::getServerCurrentDateTime();
         $startDate = date_sub(new \DateTime($endDate, new \DateTimeZone($clientSettings['timezone'])), date_interval_create_from_date_string('2 days'));
         $historyList = null;
         do {
             $historyList = Util::getProjectHistory(array($projectId), $helpDeskFlag, null, date_format($startDate, 'Y-m-d'), $endDate);
             if (null == $historyList && date_format($startDate, 'Y-m-d H:i:s') == $client['date_created']) {
                 break;
             }
             $startDate = date_sub($startDate, date_interval_create_from_date_string('2 days'));
             $startDate->setTime(0, 0, 0);
             if (date_format($startDate, 'Y-m-d') < $client['date_created']) {
                 $startDate = new \DateTime($client['date_created'], new \DateTimeZone($clientSettings['timezone']));
                 break;
             }
         } while ($historyList == null);
         $historyData = array();
         $userData = array();
         while ($historyList && ($history = $historyList->fetch_array(MYSQLI_ASSOC))) {
             $historyData[substr($history['date_created'], 0, 10)][$history['user_id']][$history['date_created']][] = $history;
             $userData[$history['user_id']] = array('picture' => $history['avatar_picture'], 'first_name' => $history['first_name'], 'last_name' => $history['last_name']);
         }
     }
     $index = 0;
     return $this->render(__DIR__ . '/../../Resources/views/project/ViewActivityStream.php', get_defined_vars());
 }
 /**
  * @test
  */
 public function getCurrentDateTimeReturnsACurrentDateAndTime()
 {
     $mockHttpRequestHandler = $this->getMock('TYPO3\\FLOW3\\Http\\HttpRequestHandlerInterface');
     $mockHttpRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue(\TYPO3\FLOW3\Http\Request::create(new \TYPO3\FLOW3\Http\Uri('http://myhost/'))));
     $mockBootstrap = $this->getMock('TYPO3\\FLOW3\\Core\\Bootstrap', array('getActiveRequestHandler'), array(), '', FALSE);
     $mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($mockHttpRequestHandler));
     $mockDomainRepository = $this->getMock('TYPO3\\TYPO3\\Domain\\Repository\\DomainRepository', array(), array(), '', FALSE);
     $mockDomainRepository->expects($this->once())->method('findByHost')->with('myhost')->will($this->returnValue(array()));
     $mockSiteRepository = $this->getMock('TYPO3\\TYPO3\\Domain\\Repository\\SiteRepository', array('findFirst'), array(), '', FALSE);
     $contentContext = $this->getMock($this->buildAccessibleProxy('TYPO3\\TYPO3\\Domain\\Service\\ContentContext'), array('dummy'), array('live'));
     $contentContext->_set('bootstrap', $mockBootstrap);
     $contentContext->_set('domainRepository', $mockDomainRepository);
     $contentContext->_set('siteRepository', $mockSiteRepository);
     $contentContext->initializeObject();
     $almostCurrentTime = new \DateTime();
     date_sub($almostCurrentTime, new \DateInterval('P0DT1S'));
     $currentTime = $contentContext->getCurrentDateTime();
     $this->assertTrue($almostCurrentTime < $currentTime);
 }
Example #26
0
 public function getAttractionStat($id)
 {
     $start_date = date('Y-m-d H:i:s');
     $date = new DateTime('now');
     $end_date = date_sub($date, date_interval_create_from_date_string("6 days"));
     $end_date = date_format($date, "Y-m-d");
     //        $qr = 'SELECT DATE(date) AS dates, SUM(quantity) AS total_visit
     //               GROUP BY dates';
     $this->db->select('DATE(date) AS date, SUM(quantity) AS total_visit');
     //        $this->db->where('date <=', 'DATE_SUB(NOW(),INTERVAL 6 DAYS )');
     $this->db->where('location', $id);
     $this->db->where('date <=', $start_date);
     $this->db->where('date >=', $end_date);
     $this->db->group_by('date');
     $this->db->from('attractions_attendance');
     $query = $this->db->get();
     $result = $query->result_array();
     return $result;
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     if (Util::checkUserIsLoggedIn()) {
         $clientId = $session->get('client/id');
         $clientSettings = $session->get('client/settings');
     } else {
         $clientId = $this->getRepository(UbirimiClient::class)->getClientIdAnonymous();
         $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     }
     $client = $this->getRepository(UbirimiClient::class)->getById($clientId);
     $date = $request->request->get('date');
     $project = $request->request->get('project');
     if ($project == 'all') {
         $projectsMenu = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($session->get('client/id'), $session->get('user/id'), Permission::PERM_BROWSE_PROJECTS, 'array');
         $projectIds = Util::array_column($projectsMenu, 'id');
     } else {
         $projectIds = array($project);
     }
     $historyList = null;
     $endDate = $date;
     $startDate = date_sub(new \DateTime($date, new \DateTimeZone($clientSettings['timezone'])), date_interval_create_from_date_string('2 days'));
     do {
         $historyList = Util::getProjectHistory($projectIds, 0, null, date_format($startDate, 'Y-m-d'), $endDate);
         if (null == $historyList && date_format($startDate, 'Y-m-d H:i:s') == $client['date_created']) {
             break;
         }
         $startDate = date_sub($startDate, date_interval_create_from_date_string('2 days'));
         $startDate->setTime(0, 0, 0);
         if (date_format($startDate, 'Y-m-d') < $client['date_created']) {
             $startDate = new \DateTime($client['date_created'], new \DateTimeZone($clientSettings['timezone']));
             break;
         }
     } while ($historyList == null);
     $historyData = array();
     $userData = array();
     while ($historyList && ($history = $historyList->fetch_array(MYSQLI_ASSOC))) {
         $historyData[substr($history['date_created'], 0, 10)][$history['user_id']][$history['date_created']][] = $history;
         $userData[$history['user_id']] = array('picture' => $history['avatar_picture'], 'first_name' => $history['first_name'], 'last_name' => $history['last_name']);
     }
     $index = 0;
     return $this->render(__DIR__ . '/../Resources/views/project/_activityStream.php', get_defined_vars());
 }
Example #28
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientSettings = $session->get('client/settings');
     $projectId = $request->get('id');
     $slaSelectedId = $request->get('sla_id');
     $project = $this->getRepository(YongoProject::class)->getById($projectId);
     $SLAs = $this->getRepository(Sla::class)->getByProjectId($projectId);
     $menuSelectedCategory = 'help_desk';
     $menuProjectCategory = 'reports';
     $sectionPageTitle = $clientSettings['title_name'] . ' / ' . SystemProduct::SYS_PRODUCT_HELP_DESK_NAME . ' / Help Desks';
     $queues = $this->getRepository(Queue::class)->getByProjectId($projectId);
     if ($queues) {
         $queueSelected = $queues->fetch_array(MYSQLI_ASSOC);
     }
     $slaSelected = $this->getRepository(Sla::class)->getById($slaSelectedId);
     $dateTo = date('Y-m-d');
     $dateFrom = new \DateTime($dateTo, new \DateTimeZone($clientSettings['timezone']));
     $dateFrom = date_sub($dateFrom, date_interval_create_from_date_string('1 months'))->format('Y-m-d');
     return $this->render(__DIR__ . '/../../Resources/views/report/View.php', get_defined_vars());
 }
 public function launch()
 {
     global $interface;
     if (isset($_REQUEST['startDate'])) {
         $startDate = new DateTime($_REQUEST['startDate']);
     } else {
         $startDate = new DateTime();
         date_sub($startDate, new DateInterval('P1M'));
     }
     if (isset($_REQUEST['endDate'])) {
         $endDate = new DateTime($_REQUEST['endDate']);
     } else {
         $endDate = new DateTime();
     }
     $interface->assign('startDate', $startDate->getTimestamp());
     $interface->assign('endDate', $endDate->getTimestamp());
     $offlineHolds = array();
     $offlineHoldsObj = new OfflineHold();
     $offlineHoldsObj->whereAdd("timeEntered >= " . $startDate->getTimestamp() . " AND timeEntered <= " . $endDate->getTimestamp());
     $offlineHoldsObj->find();
     while ($offlineHoldsObj->fetch()) {
         $offlineHold = array();
         require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
         $recordDriver = new MarcRecord($offlineHoldsObj->bibId);
         if ($recordDriver->isValid()) {
             $offlineHold['title'] = $recordDriver->getTitle();
         }
         $offlineHold['patronBarcode'] = $offlineHoldsObj->patronBarcode;
         $offlineHold['bibId'] = $offlineHoldsObj->bibId;
         $offlineHold['timeEntered'] = $offlineHoldsObj->timeEntered;
         $offlineHold['status'] = $offlineHoldsObj->status;
         $offlineHold['notes'] = $offlineHoldsObj->notes;
         $offlineHolds[] = $offlineHold;
     }
     $interface->setPageTitle('Offline Holds Report');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->assign('offlineHolds', $offlineHolds);
     $interface->setTemplate('offlineHoldsReport.tpl');
     $interface->display('layout.tpl');
 }
/**
 * @param $auction DbAuction
 * @param $numBids int
 * @param $userIds array
 */
function makeBidsForAuction($auction, $numBids, $userIds)
{
    $faker = Faker\Factory::create();
    $startTime = new DateTime($auction->getField("startTime"));
    $endTime = new DateTime($auction->getField("endTime"));
    date_sub($endTime, date_interval_create_from_date_string("5 seconds"));
    $bidInterval = (int) (($endTime->getTimestamp() - $startTime->getTimestamp()) / $numBids);
    $price = (double) $auction->getField("startPrice");
    $userId = null;
    for ($i = 0; $i < $numBids; $i++) {
        $time = new DateTime('@' . ($startTime->getTimestamp() + $bidInterval * ($i + 1)));
        $price = $price + 0.5 * $faker->numberBetween(2, 10);
        $userId = $faker->randomElement($userIds);
        $bid = new DbBid(array("userId" => $userId, "auctionId" => $auction->getId(), "bidTime" => $time->format('Y-m-d H:i:s'), "bidPrice" => $price));
        $bid->create();
        $auction->setField("highestBid", $price);
    }
    $auction->setField("numBids", $numBids);
    $auction->setField("highestBidderId", $userId);
    $auction->save();
    //addViews($auction, $numBids);
}