/** * @author Julie Engel <*****@*****.**> * @copyright Copyright (c) 2015, METANET AG */ function tracks_get(DateTime $date) { $previous_day = clone $date; $previous_day = $previous_day->sub(DateInterval::createfromdatestring('+1 day')); $next_day = clone $date; $next_day = $next_day->sub(DateInterval::createfromdatestring('-1 day')); //var_dump("-----------------------"); //var_dump($date); //var_dump($previous_day); //var_dump($next_day); $LASTFM_API_URL = 'http://ws.audioscrobbler.com/2.0/'; $LASTFM_API_METHOD = 'user.getrecenttracks'; $LASTFM_API_KEY = 'your_api_key'; $LASTFM_USER = '******'; $params = array('method' => $LASTFM_API_METHOD, 'user' => $LASTFM_USER, 'api_key' => $LASTFM_API_KEY, 'from' => $previous_day->getTimestamp(), 'to' => $next_day->getTimestamp(), 'format' => 'json'); $query = http_build_query($params); $call = $LASTFM_API_URL . '?' . $query; $curl = curl_init($call); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $curl_response = curl_exec($curl); if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die('error occured during curl exec. Additioanl info: ' . var_export($info)); } curl_close($curl); $decoded = json_decode($curl_response); if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') { die('error occured: ' . $decoded->response->errormessage); } else { //echo 'response ok!'; } //var_dump($decoded); if (isset($decoded->recenttracks->track)) { $tracks = $decoded->recenttracks->track; if (is_array($tracks)) { $tracks = array_reverse($tracks); } else { $track_item = $tracks; $tracks = array($track_item); } return $tracks; } else { return null; } }
function blendercloud_api($atts) { $user_data = array('shop_id' => '0', 'cloud_access' => 0, 'expiration_date' => '1970-01-01 00:00:00'); $last_expiration_date = new DateTime('1970-01-01 00:00:00'); // map blenderid to userid $args = array('search' => $_GET['blenderid'], 'search_columns' => array('user_login')); $user_query = new WP_User_Query($args); // Get the results from the query, returning the first user $users = $user_query->get_results(); if (!empty($users)) { $user_id = $users[0]->ID; $user_data['shop_id'] = $user_id; // process simple products (prepaid subscriptions) $order_ids = bo_get_all_user_orders($user_id, 'completed'); foreach ($order_ids as $order_id) { $order = new WC_Order($order_id); $order_date = $order->order_date; $items = $order->get_items(); foreach ($items as $item) { $tmp = bo_empty_subscription_line(); $product_id = $item['product_id']; $product = get_product($product_id); $sku = $product->get_sku(); $expiry_date = new DateTime($order_date); $tmp['sku'] = $sku; switch ($sku) { case 'cloud-prepaid-3': case 'cloud-prepaid-3-renewal': $expiry_date->modify('+3 month'); break; case 'cloud-prepaid-18': $expiry_date->modify('+18 month'); break; default: continue 2; // skip to next product } $tmp['expiration_date'] = $expiry_date->format('Y-m-d H:i:s'); $tmp['subscription_status'] = 'prepaid'; $now = new DateTime("now"); if ($expiry_date > $now) { $tmp['cloud_access'] = 1; } if ($expiry_date > $last_expiration_date) { $last_expiration_date = $expiry_date; } $user_data['subscriptions'][] = $tmp; } } // process recurring subscriptions $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions($user_id); if (!empty($subscriptions)) { // iterate over all subscriptions. foreach ($subscriptions as $subscription_details) { if ($subscription_details['status'] != 'trash') { $order_id = $subscription_details['order_id']; $product_id = $subscription_details['product_id']; $order = new WC_Order($order_id); // print_r($order); // $next_payment_date = WC_Subscriptions_Manager::get_next_payment_date( $subscription_key, $user_id, 'mysql' ); $subscription_key = WC_Subscriptions_Manager::get_subscription_key($order_id, $product_id); if ($subscription_details['expiry_date'] == 0 && !in_array($subscription_details['status'], array('cancelled', 'switched'))) { $end_time = WC_Subscriptions_Manager::get_next_payment_date($subscription_key, $user_id, 'mysql'); $end_timestamp = strtotime($end_time); } else { if (in_array($subscription_details['status'], array('cancelled', 'switched'))) { $end_of_prepaid_term = wc_next_scheduled_action('scheduled_subscription_end_of_prepaid_term', array('user_id' => (int) $user_id, 'subscription_key' => $subscription_key)); if (false === $end_of_prepaid_term) { $end_timestamp = strtotime($subscription_details['end_date']); } else { $end_timestamp = $end_of_prepaid_term; } } else { $end_timestamp = strtotime($subscription_details['expiry_date']); } } // if( $users[0]->data->user_email == '*****@*****.**' ) { // print_r($subscription_details); // } if ($subscription_details['status'] == 'cancelled') { $end_timestamp = strtotime($subscription_details['trial_expiry_date']); } if ($subscription_details['status'] == 'on-hold') { $end_timestamp = strtotime($subscription_details['last_payment_date']); } $end_time = date("Y-m-d H:i:s", $end_timestamp); $product = get_product($product_id); $sku = $product->get_sku(); $tmp = bo_empty_subscription_line(); $tmp['expiration_date'] = $end_time; $tmp['subscription_status'] = $subscription_details['status']; $expiry_date = new DateTime($end_time); if ($expiry_date > $last_expiration_date) { $last_expiration_date = $expiry_date; } $now = new DateTime("now"); $tmp['cloud_access'] = $expiry_date > $now ? 1 : 0; $tmp['sku'] = $sku; // if order is refunded, stop access if ($order->status == 'refunded') { $tmp['expiration_date'] = $end_time; $tmp['subscription_status'] = 'refunded'; $tmp['cloud_access'] = 0; } switch ($sku) { case 'cloud-subscription-1-renewal': case 'cloud-subscription-3': //$tmp['failed_payments'] = $subscription['failed_payments']; break; case 'cloud-subscription-team': // purchased team size $variation_id = $subscription_details['variation_id']; // find variation info from order to pass on # of seats $order = new WC_Order($order_id); $items = $order->get_items(); $team_members = 0; foreach ($items as $item) { // does product variation id match the current subscription? if ($item['item_meta']['_variation_id'][0] == $variation_id) { $team_members = $item['item_meta']['pa_team-size'][0]; } } $tmp['team_members'] = $team_members; break; } $user_data['subscriptions'][] = $tmp; } } } } // add one grace day to expiration $last_expiration_date->add(DateInterval::createfromdatestring('+1 day')); $user_data['expiration_date'] = $last_expiration_date->format('Y-m-d H:i:s'); $now = new DateTime("now"); if ($last_expiration_date > $now) { $user_data['cloud_access'] = 1; } //echo "<pre>";print_r($user_data); echo json_encode($user_data, JSON_PRETTY_PRINT); die; }
$pdate = $row['pdate']; $arrFin[$pdate] = $row['num']; $log->logInfo("Fin pDate:" % $pdate); } $tableName = "six_matches_status"; $dateField = "updated"; $sql = "SELECT date( " . $dateField . " ) AS pdate, COUNT( id ) AS num\n FROM " . $tableName . " \n WHERE " . $dateField . " > date_sub( date( now( ) ) , INTERVAL " . $days . " DAY )\n AND " . $dateField . " < CURRENT_DATE()\n GROUP BY pdate\n ORDER BY pdate ASC"; $result = mysql_query($sql); $log->logInfo($sql); $arrUnfin = array(); while ($row = mysql_fetch_array($result)) { $arrUnfin[$row['pdate']] = $row['num']; } $startDate = new DateTime(); $startDate->add(DateInterval::createfromdatestring('-' . $days . ' day')); $day = DateInterval::createfromdatestring('+1 day'); while ($startDate->getTimestamp() < time()) { $dateStr = $startDate->format('Y-m-d'); $startDate = $startDate->add($day); if (array_key_exists($dateStr, $arrFin)) { $pts = $arrFin[$dateStr]; $myData->AddPoints($pts, "Finished"); } else { $myData->AddPoints(VOID, "Finished"); } if (array_key_exists($dateStr, $arrUnfin)) { $pts = $arrUnfin[$dateStr]; $myData->AddPoints($pts, "Unfinished"); } else { $myData->AddPoints(VOID, "Unfinished"); }
public function Add() { if ($this->user->IsUserLogger() == false) { $this->routemanager->RedirectToAction('index', 'home'); } if ($this->request->server['REQUEST_METHOD'] == 'POST') { //если все данные введены корректно if ($this->ValidateAddForm()) { //подключаем модель и регестрируем пользователя\ $this->loader->model("taskRepository"); $this->model_taskRepository->AddTask($this->user->GetUserId(), $this->request->post); $this->routemanager->RedirectToAction('index', 'task', array("msg" => "as")); } $this->data["name"] = $this->request->post["name"]; $this->data["description"] = $this->request->post["description"]; $this->data["start"] = $this->request->post["start"]; $this->data["end"] = $this->request->post["end"]; $this->data["email_notify"] = $this->request->post["email_notify"]; $this->data["phone_notify"] = $this->request->post["phone_notify"]; } else { //инициализация дат (ближайщий час) $format = 'd.m.Y H'; $data = new DateTime(); $data->add(DateInterval::createfromdatestring('+1 hour')); $this->data["start"] = $data->format($format) . '.00'; $data->add(DateInterval::createfromdatestring('+1 hour')); $this->data["end"] = $data->format($format) . '.00'; } $this->data["title"] = "Добавить задачу"; $this->text["name"] = "Название задачи"; $this->text["description"] = "Описание задачи"; $this->text["start"] = "Начало"; $this->text["end"] = "Конец"; $this->text["email_notify"] = "Уведомить на email"; $this->text["phone_notify"] = "Уведомить на телефон"; $this->View(); }
<?php //Datumsspanne if (isset($_GET['startDate']) && isset($_GET['endDate'])) { $startDate = DateTime::createFromFormat('d.m.Y', $_GET['startDate']); $endDate = DateTime::createFromFormat('d.m.Y', $_GET['endDate']); if ($startDate === false || $endDate === false) { $_SESSION['message'] = ['type' => 'danger', 'text' => 'Datum in Format d.m.Y']; //Seite neu laden --> falsches Format header('location: ' . LINK_MONEY); } } else { $endDate = new DateTime(); $startDate = new DateTime(); //enddatum --> 6Monate zurück $interv = DateInterval::createfromdatestring('-6 months'); $startDate->add($interv); } $acc_histories = $dbmanager->getRange('Account_History', ['payed', 'date_payed'], 'ASC', ['account_id' => $acc->getId()], ['start' => $startDate, 'end' => $endDate]); ?> <div class="row"> <div class="col-md-1"> <label for="range_start" class="pull-right">Von:</label> </div> <div class="col-md-3"> <input type="text" class="form-control input-sm datepicker-range" id="range_start" value="<?php echo $startDate->format('d.m.Y'); ?> "> </div>