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; } } } }
public function notify_payment() { $this->load->model('client_model'); $this->load->model('bill_model'); $received_data = $this->input->post(); $user_name = $this->session->userdata('username'); $get_email = $this->client_model->get_email_id($user_name); $get_balance = $this->bill_model->get_balance($received_data["invoice"], $get_email); $balance = floatval($get_balance[0]['balance']) - floatval($received_data["mc_gross_1"]); // echo $get_balance[0]['balance']."<br/>".$received_data["mc_gross_1"]."<br/>".$balance; $data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "user_email" => $get_email, "credit" => $received_data["mc_gross_1"], "vat" => $received_data['mc_gross_2'], "balance" => $balance, "transaction_date_time" => $received_data["payment_date"]); $this->bill_model->insert_transaction($data); $partial_status = 0; $bill_due_date = $this->bill_model->bill_due_date($received_data["invoice"]); if ($balance > 0) { $date = date_create($bill_due_date[0]['bill_due_date']); date_add($date, date_interval_create_from_date_string("15 days")); $bill_date = date_format($date, "Y-m-d"); $data = array("bill_due_date" => $bill_date, "bill_allow_partial" => 0, "bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "partial_status" => 1); $data1 = array("status" => 1); $this->bill_model->update_bill($data, $received_data["invoice"]); $this->bill_model->update_bill_service($data1, $received_data["invoice"]); } else { $data = array("bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "bill_status" => 1); $data1 = array("status" => 1); $this->bill_model->update_bill($data, $received_data["invoice"]); $this->bill_model->update_bill_service($data1, $received_data["invoice"]); } $data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "balance" => $balance, "credit" => $received_data["mc_gross_1"], "transaction_date_time" => $received_data["payment_date"]); $this->session->set_userdata($data); redirect('/client/view_bill_details/' . $received_data["invoice"]); }
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()); }
/** * 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'); } }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $colonie = $builder->getData(); $lastDate = $colonie->getDateColonie(); if (!$colonie->getVisites()->isEmpty()) { $date = $colonie->getVisites()->last()->getDate(); if ($lastDate < $date) { $lastDate = $date; } } if (!$colonie->getTranshumances()->isEmpty()) { $date = $colonie->getTranshumances()->last()->getDate(); if ($lastDate < $date) { $lastDate = $date; } } if (!$colonie->getRecoltes()->isEmpty()) { $date = $colonie->getRecoltes()->last()->getDate(); if ($lastDate < $date) { $lastDate = $date; } } if (!$colonie->getRemerages()->isEmpty()) { $date = $colonie->getRemerages()->last()->getDate(); if ($lastDate < $date) { $lastDate = $date; } } $startDate = date_add($lastDate, date_interval_create_from_date_string("1 days")); $startDateFormat = date_format($startDate, "Y-m-d"); $builder->add('dateMort', 'collot_datetime', array('pickerOptions' => array('format' => 'dd/mm/yyyy', 'autoclose' => true, 'startDate' => (string) $startDateFormat, 'endDate' => date("Y-m-d"), 'startView' => 'month', 'minView' => 'month', 'maxView' => 'month', 'todayBtn' => false, 'todayHighlight' => true, 'keyboardNavigation' => true, 'language' => 'fr', 'forceParse' => true, 'pickerReferer ' => 'default', 'pickerPosition' => 'bottom-right', 'viewSelect' => 'month', 'initialDate' => date("Y-m-d")), 'constraints' => new CheckDateMort($colonie), 'read_only' => true, 'attr' => array('input_group' => array('prepend' => '.icon-calendar'))))->add('causes', 'entity', array('class' => 'KGBeekeepingManagementBundle:Cause', 'choice_label' => 'libelle', 'multiple' => true, 'required' => false))->add('autreCause', 'text', array('required' => false, 'constraints' => new CheckCauseMort())); }
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; }
public function indexChef() { $filiere = Session::get('user')->filieres[0]; $etudiants_count = Filiere::nbreEtudiantByFiliere($filiere->id); $enseignants_count = Enseignant::count(); $etudiants = Etudiant::etudiants_plus_3_absences(); $promotions = $filiere->promos; $promos_count = count($promotions); $stats_cours = array(); $today = Carbon::now(); $liste = null; $j = 0; $absences_count = 0; if ($promos_count > 0) { foreach ($promotions as $promotion) { $absences_count = $absences_count + Filiere::nbreAbsencesByPromo($promotion->id); } } $stats_cours = array(); $today = Carbon::now(); for ($i = 0; $i < 10; $i++) { $nb = Absence::whereDate('created_at', '=', date("Y-m-d", strtotime($today)))->count(); date_add($today, date_interval_create_from_date_string('-1 days')); array_push($stats_cours, $nb); } return View('app/dashboardChef', ['etudiants_count' => $etudiants_count, 'enseignants_count' => $enseignants_count, 'absences_count' => $absences_count, 'promos_count' => $promos_count, 'etudiants' => $etudiants, 'statistics' => $liste[0], 'promotions' => $promotions, 'filiere' => $filiere, 'statistics' => $stats_cours]); }
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); }
public static function getOfficeCampaignBeginDate($date = null) { $end_date = self::getOfficeCampaignEndDate($date); $start_date = clone $end_date; $start_date->sub(date_interval_create_from_date_string('1 month')); return $start_date; }
private function setDefaultDatesFromRequest($event, Request $request) { $event->setStart($this->getStartDateFromRequest($request)); $end = clone $event->getStart(); $end->add(date_interval_create_from_date_string('1 hour')); $event->setEnd($end); }
public function finanzas() { $user = \Auth::User(); $now = new \DateTime(); $lasth_month = date_add($now, date_interval_create_from_date_string("-1 months")); $now = new \DateTime(); $last_last_month = date_add($now, date_interval_create_from_date_string("-2 months")); $now = new \DateTime(); //\DB::select("delete from comisiones where periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?)", [$now, $lasth_month, $last_last_month]); if (!$user->isContabilidad) { $distribuidores = []; $subdistribuidores = []; if ($user->isAdmin) { $distribuidores = \DB::table('users')->get(); foreach ($distribuidores as $distribuidor) { $subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get(); } } else { $subdistribuidores = \DB::table('subdistribuidores')->where('emailDistribuidor', $user->email)->get(); } $periodos = \DB::select("select distinct periodo from comisiones order by periodo desc"); return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos)); } else { $distribuidores = \DB::table('users')->where('name', '<>', 'OFICINA')->get(); foreach ($distribuidores as $distribuidor) { $subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get(); } $periodos = \DB::select("select distinct periodo from comisiones order by periodo desc"); return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos)); } }
function getMySQLFormat($dateTime, $round = 0) { // format as YYYY-MM-DD HH:MM:SS $formatstr = $dateTime->format('Y-m-d H:i:s'); // check if round is -1 to round down if ($round == -1) { // get the minutes $minutes = date_parse($formatstr)['minute']; // check if it already is at the nearest hour (if minutes = 0) if ($minutes != 0) { // subtract the minutes $dateTime->sub(date_interval_create_from_date_string("{$minutes} minutes")); // reset the string $formatstr = $dateTime->format('Y-m-d H:i:s'); } // check if round is 1 to round up } else { if ($round == 1) { // get the minutes $minutes = date_parse($formatstr)['minute']; // check if it already is at the nearest hour (if minutes = 0) if ($minutes != 0) { // determine the minutes to be added $minutes = 60 - $minutes; // add the minutes $dateTime->add(date_interval_create_from_date_string("{$minutes} minutes")); // reset the string $formatstr = $dateTime->format('Y-m-d H:i:s'); } } } // return the formatted string return $formatstr; }
function groupHasThirdWeekHours($groupInfo) { $today = new DateTime(); date_add($today, date_interval_create_from_date_string('14 days')); $nextWeek = date_format($today, "Y-m-d"); return strcmp($groupInfo['addHrsType'], "week") == 0 && strcmp($nextWeek, $groupInfo['startDate']) > 0 && strcmp($nextWeek, $groupInfo['endDate']) < 0; }
public function checkValidCode($referCode) { $isEnabled = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_enable', 1); $period = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_trial', 0); $now = date("Y-m-d H:i:s"); $invite = Engine_Api::_()->invite()->getRowCode($referCode); //check invite code active if (isset($invite) && !$invite->active) { return false; } if ($isEnabled && $invite) { //if exist code then get expire date if ($period == 1) { $type = 'day'; } else { $type = 'days'; } $expiration_date = date_add(date_create($invite->timestamp), date_interval_create_from_date_string($period . " " . $type)); $nowDate = date_create($now); if ($period != 0) { if ($nowDate >= $expirationDate) { return true; } else { return false; } } else { //if code never expired return true; } } else { return false; } }
/** * 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"); } }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $clientSettings = $session->get('client/settings'); $slaId = $request->get('id'); $dateFrom = $request->get('date_from'); $dateTo = $request->get('date_to'); $issues = $this->getRepository(Sla::class)->getIssues($slaId, $dateFrom, $dateTo); $dates = array(); $succeeded = array(); $breached = array(); $dateTemporary = new \DateTime($dateFrom, new \DateTimeZone($clientSettings['timezone'])); while (date_format($dateTemporary, 'Y-m-d') <= $dateTo) { $dates[] = date_format($dateTemporary, 'Y-m-d'); $succeeded[end($dates)] = 0; $breached[end($dates)] = 0; date_add($dateTemporary, date_interval_create_from_date_string('1 days')); } while ($issues && ($issue = $issues->fetch_array(MYSQLI_ASSOC))) { if ($issue['sla_value'] >= 0) { $succeeded[substr($issue['stopped_date'], 0, 10)]++; } else { $breached[substr($issue['stopped_date'], 0, 10)]++; } } $data = array('dates' => $dates, 'succeeded' => $succeeded, 'breached' => $breached); return new JsonResponse($data); }
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; }
public function check_due_date($date) { echo $date; $query = $this->db->query('SELECT * FROM rent_details')->result_array(); //exit(); foreach ($query as $key) { $due_date = $key['rent_due_date']; $rent = $key['rent']; $id = $key['id']; $rent_balance = $key['rent_balance']; $new_rent_balance = $rent_balance + $rent; $new_date = date_create($due_date); date_add($new_date, date_interval_create_from_date_string("30 days")); $new_rent_due_date = date_format($new_date, "Y-m-d"); echo $new_rent_due_date; $date1 = date_create($date); $date2 = date_create($due_date); $diff = date_diff($date1, $date2); $dif = $diff->format("%a"); if ($dif == 0) { if ($new_rent_balance <= 0) { $this->db->query("UPDATE rent_details SET rent_due = '0' WHERE id ='" . $id . "'"); # code... } else { $this->db->query("UPDATE rent_details SET rent_due = '" . $new_rent_balance . "' WHERE id ='" . $id . "'"); } $this->db->query("UPDATE rent_details SET rent_balance = '" . $new_rent_balance . "' WHERE id ='" . $id . "'"); $this->db->query("UPDATE rent_details SET rent_due_date = '" . $new_rent_due_date . "' WHERE id ='" . $id . "'"); } else { //$this->db->query('UPDATE rent_details SET rent_due = '0''); } } }
public function depreciated_date() { $date = date_create($this->purchase_date); date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months . ' months')); return $date; //date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization }
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 historico_acceso($data, $limit = -1, $offset = -1) { $fecha = date_create(date('Y-m-j')); date_add($fecha, date_interval_create_from_date_string('-1 month')); $data['fecha_inicial'] = date_format($fecha, 'm'); $data['fecha_final'] = $data['fecha_final'] = date('m'); $this->db->select("AES_DECRYPT(h.email,'{$this->key_hash}') AS email", FALSE); $this->db->select('p.id_perfil, p.perfil, p.operacion'); $this->db->select('u.nombre,u.apellidos'); $this->db->select('h.ip_address, h.user_agent, h.id_usuario'); $this->db->select("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%d-%m-%Y %H:%i:%s') END ) AS fecha", FALSE); $this->db->from($this->historico_acceso . ' As h'); $this->db->join($this->usuarios . ' As u', 'u.id = h.id_usuario', 'LEFT'); $this->db->join($this->perfiles . ' As p', 'u.id_perfil = p.id_perfil', 'LEFT'); //gmt_to_local( $timestamp, 'UM1', TRUE) ) if ($data['fecha_inicial'] and $data['fecha_final']) { $this->db->where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_inicial']); $this->db->or_where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_final']); } if ($limit != -1) { $this->db->limit($limit, $offset); } $this->db->order_by('h.fecha', 'desc'); $login = $this->db->get(); if ($login->num_rows() > 0) { return $login->result(); } else { return FALSE; } $login->free_result(); }
/** * 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)); }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var EntityManager em */ $em = $this->getContainer()->get('doctrine')->getManager(); $users = $em->getRepository('ESNUserBundle:User')->findBy(array("esner" => 1)); $concerned_users = new ArrayCollection(); /** @var User $user */ foreach ($users as $user) { /** @var EsnerFollow $follow */ $follow = $user->getFollow(); if ($follow) { $trial = $follow->getTrialstarted(); $end_trial = $trial; date_add($trial, date_interval_create_from_date_string('21 days')); $now = new \DateTime(); if ($end_trial->format('d/m/Y') == $now->format('d/m/Y')) { $concerned_users->add($user); } } } /** @var User $concerned_user */ foreach ($concerned_users as $concerned_user) { $message = \Swift_Message::newInstance()->setSubject('[ESN Lille][ERP] Periode d\'essaie terminé pour ' . $concerned_user->getFullname())->setFrom($this->getContainer()->getParameter('mailer_from'))->setTo($user->getEmail())->setBody($this->getContainer()->get('templating')->render('ESNHRBundle:Emails:trial_ended.html.twig', array('user' => $concerned_user)), 'text/html'); $this->getContainer()->get('mailer')->send($message); } }
function getSMA_sub_real($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $samplePeriod = 15, $enSignals = false, $host, $db, $user, $pass) { $intervalPeriod = $samplePeriod * 1.5; //from date has to be adjusted for the bollinger bands $date = date_create($from); date_add($date, date_interval_create_from_date_string("-{$intervalPeriod} days")); $fromAdjusted = date_format($date, "Y-m-d"); $dataOhlc = []; //OHLC data format [timestamp,open,high,low,close,volume] if ($dataorg == "highchart") { $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array2", $host, $db, $user, $pass); } else { $dataOhlc = getOHLC($company, $fromAdjusted, $to, "array", $host, $db, $user, $pass); } //Return if $dataOhlc is null if ($dataOhlc == [] || $dataOhlc == 0) { return 0; } //Input for SMA functions should be [timestamp,close] $ctr = 0; foreach ((array) $dataOhlc as $ohlc) { $dbreturn[$ctr][0] = $ohlc[0]; //timestamp $dbreturn[$ctr++][1] = $ohlc[4]; //close } return $dbreturn; }
private function addDaysFromNow($days) { $now = date('Y-m-d'); $date = date_create($now); date_add($date, date_interval_create_from_date_string($days . ' days')); return date_format($date, 'Y-m-d'); }
public function testCreateVehicle() { $problem = $this->initWithProblem(); $vehicle = new stdClass(); $startlocation = new stdClass(); $startlocation->Coordinate = new stdClass(); $startlocation->Coordinate->Latitude = "62.254622"; $startlocation->Coordinate->Longitude = "25.787020"; $startlocation->Coordinate->System = "WGS84"; $endlocation = new stdClass(); $endlocation->Coordinate = new stdClass(); $endlocation->Coordinate->Latitude = "62.254622"; $endlocation->Coordinate->Longitude = "25.787020"; $endlocation->Coordinate->System = "WGS84"; $vehicle = new stdClass(); $vehicle->Name = "Vehicle1"; $vehicle->StartLocation = $startlocation; $vehicle->EndLocation = $endlocation; $vehicle->RelocationType = "None"; $timeWindow = new stdClass(); $now = new DateTime(); $timeWindow->Start = $now->format('Y-m-d H:i:s'); $end = date_add($now, date_interval_create_from_date_string('12 hours')); $timeWindow->End = $end->format('Y-m-d H:i:s'); $vehicle->TimeWindows = $timeWindow; $vehicle->Capacities = array(array("Amount" => 100, "Name" => "Weight")); $resp = $this->api->navigate(getLink($problem, "create-vehicle"), $vehicle); $v = $this->api->navigate($resp); $this->assertEquals("Vehicle1", $v->Name); unset($api); }
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") . "&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") . "&m=" . date_format($prevdate, "n"); $html = <<<EOT <header> <a class="left navsquare" href="?p=calendar&{$prev}">❮</a> <a class="right navsquare" href="?p=calendar&{$next}">❯</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; }
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)); }
function processWalking($results, $fileRow) { global $csvData; global $sqlDB; global $plat; //this is where I'm going to do things foreach ($results as $result) { $startDate = $result['DateBegan']; $endDate = $result['DateStopped']; $diff = date_diff($startDate, $endDate); $days = $diff->format("%a"); $currentDate = $result['DateBegan']; $formattedDate = date_format($currentDate, 'm/d/y'); $tempData = array(); while ($currentDate <= $endDate) { $dayDate = $formattedDate . ' ' . "00:00:00"; $endDay = $formattedDate . ' ' . "23:59:59"; $querry = "SELECT TOP 1 RecID FROM vPhoneData1\n\t\t\t\tWHERE (TaskSetName = '1 PING' or TaskSetName =\n\t\t\t\t '3 REPORT CGI_OR_H2RL') AND LocalTimetag1 > ? and\n\t\t\t\t LocalTimetag1 < ? and cast(FORMDATA as varchar(max)) like\n\t\t\t\t '%" . $plat . "%'"; $stmt = sqlsrv_prepare($sqlDB, $querry, array(&$dayDate, &$endDay)); sqlsrv_execute($stmt); $fetched = sqlsrv_fetch_array($stmt); if (!empty($fetched)) { $formattedDate = date_format($currentDate, 'm/d/y'); $fileRow['Survey Dt'] = $formattedDate; $fileRow['Completed By'] = $result['TechName']; $fileRow['Instrument'] = $result['Instrument']; $fileRow['Rate'] = $result['RateCode']; $fileRow['Survey Method'] = 'WALK'; $tempData[] = $fileRow; } $currentDate = date_add($currentDate, date_interval_create_from_date_string('1 days')); $formattedDate = date_format($currentDate, 'm/d/y'); $fetched = null; } if (!empty($tempData)) { $daycount = count($tempData); if ($result[6] > 0) { $dailyTotal = floor($result[6] / $daycount); $firstTotal = $dailyTotal + $result[6] % $daycount; $isFirst = TRUE; } else { $dailyTotal = 0; } foreach ($tempData as $tempRow) { if ($isFirst === TRUE) { $tempRow['Quantity'] = $firstTotal; $isFirst = FALSE; } elseif ($dailyTotal > 0) { $tempRow['Quantity'] = $dailyTotal; } else { $tempRow['Quantity'] = 0; } if ($tempRow['Quantity'] > 0) { $csvData[] = $tempRow; } } } } }