function week2period($annee, $semaine)
 {
     $lundi = new DateTime();
     $lundi->setISOdate($annee, $semaine);
     $dimanche = new DateTime();
     $dimanche->setISOdate($annee, $semaine);
     date_modify($dimanche, '+27 day');
     $date = $lundi->diff($dimanche);
     $dimanche = $dimanche->modify('+1 day');
     $interval = new DateInterval('P1D');
     $daterange = new DatePeriod($lundi, $interval, $dimanche);
     setlocale(LC_TIME, 'fr_FR.utf8', 'fra');
     $cleNbSemaine = $semaine;
     $jours = [];
     $nbJours = 0;
     foreach ($daterange as $date) {
         if ($date->format("w") != 0 && $date->format("w") != 6) {
             $jour = strftime("%A", $date->getTimestamp());
             $mois = strftime("%B", $date->getTimestamp());
             $cle = $date->format('d') . $date->format('m') . $date->format('Y');
             $jours[$cleNbSemaine][$cle] = $jour . ' ' . $date->format("d") . ' ' . $mois . ' ' . $date->format('Y');
             $nbJours++;
             if ($nbJours == 5) {
                 $nbJours = 0;
                 $cleNbSemaine++;
             }
         }
     }
     return $jours;
 }
 public function add_objectives(Request $request)
 {
     $week_of = \DateTime::createFromFormat('Y-m-d', $request->week_of);
     $objectives = $request->objective;
     $lessons = array();
     foreach ($objectives as $key1 => $objective) {
         foreach ($objective as $key => $val) {
             $temp = clone $week_of;
             switch ($key) {
                 case 'monday':
                     date_modify($temp, '+0 days');
                     break;
                 case 'tuesday':
                     date_modify($temp, '+1 day');
                     break;
                 case 'wednesday':
                     date_modify($temp, '+2 days');
                     break;
                 case 'thursday':
                     date_modify($temp, '+3 days');
                     break;
                 case 'friday':
                     date_modify($temp, '+4 days');
                     break;
             }
             $objective = new \App\Objective();
             $objective->section_id = str_replace('s_', '', $key1);
             $objective->user_id = 1;
             $objective->lesson_date = date_format($temp, 'Y-m-d');
             $objective->objective = $val;
             $objective->save();
         }
     }
 }
 public function brandcsvAction()
 {
     Mage::getSingleton('core/session')->setParameter('second');
     $this->loadLayout();
     $status = $this->getRequest()->getPost('status');
     $fromDate = $this->getRequest()->getPost('from');
     $toDate = $this->getRequest()->getPost('to');
     $toDate = date_create($toDate);
     date_modify($toDate, '+1 day');
     $toDate = $toDate->format('Y-m-d');
     if ($status == 'pending') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending')));
     } elseif ($status == 'process') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('processing')));
     } elseif ($status == 'both') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending', 'processing')));
     } elseif ($status == 'all') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate));
     }
     foreach ($orders as $order) {
         $orderIds[] = $order->getIncrementId();
     }
     Mage::register('orderIds', $orderIds);
     $this->renderLayout();
 }
 public function performaAction()
 {
     Mage::getSingleton('core/session')->setParameter('second');
     $this->loadLayout();
     $status = $this->getRequest()->getPost('stsatus');
     $fromDate = $this->getRequest()->getPost('from');
     $toDate = $this->getRequest()->getPost('to');
     $toDate = date_create($toDate);
     date_modify($toDate, '+1 day');
     $toDate = $toDate->format('Y-m-d');
     if ($status == 'pending') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending')));
     } elseif ($status == 'process') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('processing')));
     } elseif ($status == 'both') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending', 'processing')));
     } elseif ($status == 'all') {
         $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate));
     }
     foreach ($orders as $order) {
         $addressDetails = $order->getShippingAddress()->getData();
         $orderData[] = array('id' => $order->getIncrementId(), 'customer' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'address' => $addressDetails['street'], 'city' => $addressDetails['city'], 'phone' => $order->getShippingAddress()->getTelephone(), 'weight' => '450', 'price' => $order->getGrandTotal(), 'email' => $order->getCustomerEmail());
     }
     Mage::register('orderData', $orderData);
     $this->renderLayout();
 }
 public function tgl_jatuh_tempo($tgl_invoice)
 {
     $jarak_hari = 15;
     $date = date_create($tgl_invoice);
     date_modify($date, "+ " . $jarak_hari . " days");
     $tgl_jatuh_tempo = date_format($date, "Y-m-d");
     return $tgl_jatuh_tempo;
 }
示例#6
0
 public function addHoliday($date_from, $date_to = '', $calendar_id)
 {
     global $wpdb;
     global $blog_id;
     $blog_prefix = $blog_id . "_";
     if ($blog_id == 1) {
         $blog_prefix = "";
     }
     if ($date_to == '') {
         //check if this day already exists
         $numrows = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $date_from, $calendar_id));
         if ($numrows > 0) {
             return 0;
         } else {
             $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $date_from, $calendar_id));
             $lastId = $wpdb->insert_id;
             //check if there are reservation for that date
             $checkQry = $wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $date_from, $calendar_id);
             $checkRows = $wpdb->query($checkQry);
             if ($checkRows > 0) {
                 $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $date_from, $calendar_id));
             } else {
                 $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id= %d", $date_from, $calendar_id));
             }
             return $lastId;
         }
     } else {
         $arrNewIds = array();
         $datefromnum = str_replace("-", "", $date_from);
         $datetonum = str_replace("-", "", $date_to);
         $date = date_create($date_from);
         while ($datefromnum <= $datetonum) {
             $dateformat = date_format($date, 'Y-m-d');
             //check if this day already exists
             $holidayCheck = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $dateformat, $calendar_id));
             if ($holidayCheck == 0) {
                 $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $dateformat, $calendar_id));
                 array_push($arrNewIds, $wpdb->insert_id);
                 //check if there are reservation for that date
                 $check = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $dateformat, $calendar_id));
                 if ($check > 0) {
                     $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $dateformat, $calendar_id));
                 } else {
                     $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id=%d", $dateformat, $calendar_id));
                 }
             }
             if (function_exists("date_add")) {
                 date_add($date, date_interval_create_from_date_string('1 days'));
             } else {
                 date_modify($date, '+1 day');
             }
             //date_modify($date, '+1 day');
             $datefromnum = date_format($date, 'Ymd');
         }
         return $arrNewIds;
     }
 }
 public static function getItems($period, $user, $yachs = 'ntime', $sport = '*', $currentpage = 'weekpage')
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id,a.tdate,  sc.sport_abbr as sport , a.method, a.description, a.comment, a.location,a.competition,' . 'sum( i.km ) AS km, sum( i.climb ) AS climb, sum( i.etime ) AS etime, sum( i.ntime ) AS ntime,' . 'sum(i.' . $yachs . '*(c.group=1)) as RECOM,sum(i.' . $yachs . '*(c.group=2)) as GA1,sum(i.' . $yachs . '*(c.group=3)) as KA1,' . 'sum(i.' . $yachs . '*(c.group=4)) as GA2,sum(i.' . $yachs . '*(c.group=5)) as KA2,sum(i.' . $yachs . '*(c.group=6)) as WSA,' . 'sum(i.' . $yachs . '*(c.group=0)) as Alt');
     $query->from($db->quoteName('#__htraininglogs_tr_sessions') . ' AS a');
     $query->leftjoin($db->quoteName('#__htraininglogs_tr_splittimes') . ' AS s ON a.id = s.tr_id');
     $query->leftjoin($db->quoteName('#__htraininglogs_tr_intensitylevels') . 'as i ON (s.id = i.split_id) AND (i.state = 1)');
     $query->leftjoin($db->quoteName('#__htraininglogs_cfg_sport') . 'AS sc ON a.sport_id = sc.id');
     $query->leftjoin($db->quoteName('#__htraininglogs_cfg_intensity') . ' AS c ON i.int_id = c.id');
     if ($sport != '*') {
         $query->where('a.sport_id in (' . $sport . ')');
     }
     $query->where('a.user_id = ' . $user->id);
     $query->where('a.state = 1');
     $query->where('a.tdate BETWEEN "' . $period->anfdatback->format('Y-m-d') . ' 0:00:00" AND "' . $period->enddat->format('Y-m-d') . ' 23:59:59"');
     $query->group('a.id,a.tdate,sport, a.method, a.description, a.comment, a.location,a.competition');
     $query->order('a.tdate ASC');
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     $i = 0;
     $k = -$period->backviewdays;
     $itemsfull = array();
     $dat = new DateTime($period->anfdatback->format('Y-m-d'));
     while ($dat <= $period->enddat) {
         if ($items[$i] and $dat->format('Y-m-d') == JFactory::getDate($items[$i]->tdate)->format('Y-m-d')) {
             while ($items[$i] and $dat->format('Y-m-d') == JFactory::getDate($items[$i]->tdate)->format('Y-m-d')) {
                 $itemsfull[$k++] = $items[$i++];
             }
         } else {
             $itemsfull[$k] = new stdClass();
             $itemsfull[$k]->id = 0;
             $itemsfull[$k]->tdate = $dat->format('Y-m-d');
             $itemsfull[$k]->sport = '';
             $itemsfull[$k]->method = '';
             $itemsfull[$k]->location = '';
             $itemsfull[$k]->description = '';
             $itemsfull[$k]->comment = '';
             $itemsfull[$k]->competition = 0;
             $itemsfull[$k]->km = 0;
             $itemsfull[$k]->climb = 0;
             $itemsfull[$k]->etime = 0;
             $itemsfull[$k]->ntime = 0;
             $itemsfull[$k]->RECOM = 0;
             $itemsfull[$k]->GA1 = 0;
             $itemsfull[$k]->KA1 = 0;
             $itemsfull[$k]->GA2 = 0;
             $itemsfull[$k]->KA2 = 0;
             $itemsfull[$k]->WSA = 0;
             $itemsfull[$k++]->Alt = 0;
         }
         $dat = date_modify($dat, '+1 day');
     }
     //		print_r($itemsfull);exit;
     return $itemsfull;
 }
示例#8
0
 public function setUp()
 {
     $this->dayDates = array('today' => $today = new \DateTime(), 'yesterday' => date_modify(clone $today, '-1 day'), 'tomorrow' => date_modify(clone $today, '+1 day'), 'day after tomorrow' => date_modify(clone $today, '+2 days'));
     $storage = new \SplObjectStorage();
     $storage[$this->dayDates['today']] = 'today';
     $storage[$this->dayDates['yesterday']] = 'yesterday';
     $storage[$this->dayDates['tomorrow']] = 'tomorrow';
     $this->storage = $storage;
     // Assume we have map with 3 pairs.
     $this->dayNames = new PairMap(new SplObjectStoragePairs($storage));
 }
 /**
  *  Return a set of status items for a list of instruments over a given
  *  range of times.
  *
  *  @param array  $instrument_list The list of instruments to use in this query this query
  *                                       this query
  *  @param string $time_period     a strtotime() parseable relative datetime object specifier datetime object specifier
  *                                       datetime object specifier
  *
  *  @return array
  *
  *  @author Ken Auberry <*****@*****.**>
  */
 public function get_status_for_instrument_over_range($instrument_list, $time_period = '1 day')
 {
     $current_time_obj = new DateTime();
     if (strtotime($time_period)) {
         $current_time_obj->setTime($current_time_obj->getHours(), 0, 0);
         $start_time = date_modify($current_time_obj, "-{$time_period}");
     } else {
         $start_time = $current_time_obj;
     }
     return $this->get_status_for_instrument_before_date($instrument_list, $start_time);
 }
示例#10
0
function reminderAddReasonToManager($data)
{
    if (!empty($data)) {
        $userObj = new rating();
        $pending_count = 0;
        $lead_name = "Lead";
        $subject = "Parakh - You have <PENDING_COUNT> pending ratings.";
        $message_template .= "Dear <LEAD_NAME>," . NEWLINE . NEWLINE;
        $due_date = date('Y-m-d 23:59:59', strtotime("+10 days"));
        $message_template .= "You have rated the following team member(s) without providing rating reason. We request you to add a reason to your rating, else the ratings will be reverted." . NEWLINE . NEWLINE;
        $message_template .= "<table width='70%' border='0' cellpadding='4' cellspacing='1'><tr style='background-color:#0099CC;color:#FFF'><td>Team Member</td><td>Rating</td><td>Rating On</td><td>Expires On</td><tr>";
        $message = "";
        $total_record = count($data);
        for ($i = 0; $i < $total_record;) {
            $bgcolor = $i % 2 == 0 ? "#FFFFFF" : "#87CEEB";
            $message .= "<tr style='background-color:" . $bgcolor . ";'>";
            $message .= "<td>" . $data[$i]["tm_name"] . "</td>";
            $message .= "<td>" . ($data[$i]["rating"] == 1 ? "+1" : "&nbsp;-1") . "</td>";
            $date_tobe_formatted = @date_create($data[$i]["created_date"]);
            $create_on = @date_format($date_tobe_formatted, "jS F, Y  h:iA");
            $expire_date = @date_modify($date_tobe_formatted, '+10 day');
            $expire_date = @date_format($expire_date, "jS F, Y");
            $message .= "<td>" . $create_on . "</td>";
            $message .= "<td>" . $expire_date . "</td>";
            $message .= "</tr>";
            $pending_count++;
            if ($data[$i]["given_by"] !== $data[$i + 1]["given_by"] || $i == $total_record - 1) {
                $message .= "</table>";
                $lead_name = $userObj->get_user_full_name($data[$i]['given_by']);
                $to["name"] = $lead_name;
                $lead_name = explode(" ", trim($lead_name));
                $lead_name = $lead_name[0];
                $message = $message_template . $message;
                $message .= NEWLINE;
                $message .= EMAIL_FOOTER;
                $to["email"] = $userObj->get_user_email($data[$i]['lead_id']);
                $subject = str_replace('<PENDING_COUNT>', $pending_count, $subject);
                $message = str_replace('<LEAD_NAME>', $lead_name, $message);
                if (ENVIRONMENT != 'LIVE') {
                    $to["email"] = LEAD_EMAIL;
                }
                smtp_send_mail($to, $subject, $message);
                $pending_count = 0;
                $message = '';
                $i++;
                continue;
            }
            $i++;
        }
    } else {
        echo 'No records found to send reminder email.<BR/><BR/>';
    }
}
示例#11
0
 /**
  * Take the difference of two datetime ranges
  *
  * The difference of two datetime ranges in this case means that the overlap of
  * the two ranges will be removed from the first range, and the result will
  * be returned.
  *
  * This method will refuse to bisect the current datetime range (thus,
  * confusingly, creating two datetime ranges), so the argument datetime range must
  * begin prior to and end during the current datetime range, or begin during and
  * end after the current datetime range.
  *
  * @param DateRange|DateTimeRange $arg Other DateRange or DateTimeRange to test
  *
  * @return DateTimeRange
  * @throws OutOfRangeException
  */
 public function diff(DateRange $arg)
 {
     if (!$this->overlaps($arg)) {
         throw new OutOfRangeException('Argument must overlap this range');
     }
     if ($this->getStart() < $arg->getStart() && $this->getEnd() > $arg->getEnd()) {
         throw new OutOfRangeException('Argument must not be exclusively contained within this range');
     }
     if ($this->getStart() < $arg->getStart()) {
         return new static(clone $this->getStart(), date_modify(clone $arg->getStart(), '-1 second'));
     }
     return new static(date_modify(clone $arg->getEnd(), '+1 second'), clone $this->getEnd());
 }
示例#12
0
 /**
  * convert data from local to GMT
  * TODO handle solar and legal time where is present.
  */
 function local_to_GMT_data($local_data)
 {
     $GMT_data = $local_data;
     if (!empty($local_data)) {
         $config = JFactory::getConfig();
         $offset = $config->get('config.offset');
         $offset = 0 - $offset;
         $date = date_create($local_data);
         date_modify($date, $offset . ' hour');
         $GMT_data = date_format($date, 'Y-m-d H:i:s');
     }
     return $GMT_data;
 }
示例#13
0
function get_trips($trip_date)
{
    global $DB;
    $before_date = date_create($trip_date);
    $after_date = date_create($trip_date);
    date_modify($before_date, '-1 day');
    date_modify($after_date, '+1 day');
    echo date_format($before_date, 'Y-m-d');
    echo date_format($after_date, 'Y-m-d');
    $req = $DB->prepare("SELECT * \r\n\t\t\t\t\t\t\tFROM trips\r\n\t\t\t\t\t\t\tWHERE departure BETWEEN :before_date AND :after_date\r\n\t\t\t\t\t\t\t\tAND available_sits > 0\r\n\t\t\t\t\t\t\tORDER BY departure") or die(print_r($req->errorInfo()));
    $req->execute(array('before_date' => date_format($before_date, 'Y-m-d'), 'after_date' => date_format($after_date, 'Y-m-d')));
    $trips = $req->fetchAll();
    return $trips;
}
示例#14
0
 /**
  * Override parent::_getData() to insert groupBy and orderBy clauses into query
  *  
  * @return unknown_type
  */
 function _getData()
 {
     $state = $this->_getState();
     $order_states = array('3', '5', '17');
     $filter_date_from = $state['filter_date_from'];
     $filter_date_to = $state['filter_date_to'];
     if (empty($filter_date_to) and empty($filter_date_from)) {
         $date = JFactory::getDate();
         $today = $date->toFormat("%Y-%m-%d 00:00:00");
         $filter_date_to = $today;
         $database = JFactory::getDBO();
         $query = " SELECT DATE_SUB('" . $today . "', INTERVAL 1 MONTH) ";
         $database->setQuery($query);
         $filter_date_from = $database->loadResult();
     } else {
         if (empty($filter_date_to) and !empty($filter_date_from)) {
             $filter_date_to = $filter_date_from;
         } else {
             if (!empty($filter_date_to) and empty($filter_date_from)) {
                 $filter_date_from = $filter_date_to;
             }
         }
     }
     $date_tmp = date_create($filter_date_to);
     date_modify($date_tmp, '24 hour');
     $database = JFactory::getDBO();
     $curdate = TiendaHelperBase::local_to_GMT_data($filter_date_from);
     $enddate = TiendaHelperBase::local_to_GMT_data(date_format($date_tmp, 'Y-m-d H:i:s'));
     while ($curdate < $enddate) {
         // set working variables
         $variables = TiendaHelperBase::setDateVariables($curdate, $enddate, 'daily');
         $thisdate = $variables->thisdate;
         $nextdate = $variables->nextdate;
         $query = new TiendaQuery();
         $query->select('COUNT(tbl.order_id) AS num, SUM(order_total) AS amount');
         $query->from('#__tienda_orders AS tbl');
         $query->where("tbl.order_state_id IN (" . $this->getStatesCSV() . ")");
         $query->where("tbl.modified_date >= '" . $curdate . "'");
         $query->where("tbl.modified_date <= '" . $nextdate . "'");
         $database->setQuery((string) $query);
         $return_daily_report = $database->loadObject();
         $date_tmp = date_create(TiendaHelperBase::GMT_to_local_data($curdate));
         $data_print = date_format($date_tmp, 'd-m-Y');
         $return_range_report->{$data_print} = $return_daily_report;
         // increase curdate to the next value
         $curdate = $nextdate;
     }
     return $return_range_report;
 }
示例#15
0
 /**
  * Retrieve the date on which salaries should be paid for this specific month
  * Will return null if no salaries should be paid
  * @return \DateTime|null
  */
 private function getSalaryDate()
 {
     // Get last day of month
     $clone = clone $this->currentDate;
     $lastDay = $clone->modify('last day of this month');
     // If last day of month is a weekend, pay the friday beforehand
     if ($this->isWeekend($lastDay)) {
         $lastDay = date_modify($lastDay, 'previous friday');
     }
     // Return null if salary has already been paid this month
     if ($this->currentDate > $lastDay) {
         return null;
     }
     return $lastDay;
 }
 public function insert($param)
 {
     switch ($_SERVER['REQUEST_METHOD']) {
         case 'GET':
             if (isset($_SESSION['user'])) {
                 $this->load->model("Activite");
                 $jour = substr($param, 0, 2);
                 $mois = substr($param, 2, 2);
                 $annee = substr($param, 4, 4);
                 $heureDebut = substr($param, 8, 2)[0] == '0' ? substr($param, 9, 1) . 'h' : substr($param, 8, 2) . 'h';
                 $heureFin = substr($param, 10, 2)[0] == '0' ? substr($param, 11, 1) . 'h' : substr($param, 10, 2) . 'h';
                 $activites = Activite::getAll();
                 $date = new \DateTime($annee . '-' . $mois . '-' . $jour);
                 setlocale(LC_TIME, 'fr_FR.utf8', 'fra');
                 $titre = ucfirst(strftime("%A", $date->getTimestamp())) . ' ' . $date->format('d') . ' ' . ucfirst(strftime("%B", $date->getTimestamp())) . ' - ' . $heureDebut . '-' . $heureFin;
                 $data['titre'] = $titre;
                 $data["hidden"] = $date->format('Y-m-d') . '|' . $heureDebut . ':' . $heureFin;
                 $data['activites'] = $activites;
                 $this->load->view("ajoutActiviteAgenda", $data);
             } else {
                 $_SESSION['messagee'] = "Erreur, accès refusé";
                 header('Location: ' . BASEURL);
                 exit;
             }
             break;
         case 'POST':
             if (isset($_SESSION['user']) && isset($_POST['redondance']) && $_POST['redondance'] != null) {
                 $this->load->model("Agenda");
                 $dateHeure = preg_split('/[|]/', $_POST['dateDebut']);
                 $dateDebut = new \DateTime($dateHeure[0] . '00:00:01');
                 $redondance = $_POST['redondance'];
                 $dateFin = date_modify(new \DateTime($dateHeure[0] . '23:59:59'), "+ " . $redondance . ' week');
                 $hDebut = preg_split('/[:]/', $dateHeure[1])[0];
                 $heureMinuteSecondeDebut = preg_split('/h/', $hDebut);
                 $hFin = preg_split('/[:]/', $dateHeure[1])[1];
                 $heureMinuteSecondeFin = preg_split('/h/', $hFin);
                 $heureDebut = $heureMinuteSecondeDebut[1] != "" ? $heureMinuteSecondeDebut[0] . ':' . $heureMinuteSecondeDebut[1] . ':00' : $heureMinuteSecondeDebut[0] . ':00:00';
                 $heureFin = $heureMinuteSecondeFin[1] != "" ? $heureMinuteSecondeFin[0] . ':' . $heureMinuteSecondeFin[1] . ':00' : $heureMinuteSecondeFin[0] . ':00:00';
                 $idActivite = $_POST['activite'];
                 $jour = $dateDebut->format('N');
                 $ajoutActivite = new Agenda(null, $idActivite, $dateDebut->format("Y-m-d H:i:s"), $dateFin->format("Y-m-d H:i:s"), $jour, $heureDebut, $heureFin);
                 $ajoutActivite->create();
                 header('Location: ' . base_url() . '/index.php/agendaActivite/gestion');
                 exit;
             }
             break;
     }
 }
示例#17
0
 public static function getPeriod($date1, $page, $user)
 {
     $backwiewdays = 1;
     $back = 6;
     $period = new stdClass();
     if ($date1 == "") {
         $date1 = date("Y-m-d");
     }
     if ($page == 'daypage') {
         $backwiewdays = 1;
         $back = 0;
         //			$period->anfdat=date_modify(new DateTime($date1), '-'.$back.' day');
     } else {
         if ($page == 'weekpage') {
             $backwiewdays = 1;
             $back = 6;
             //			$period->anfdat=date_modify(new DateTime($date1), '-'.$back.' day');
         } else {
             if ($page == 'monthpage') {
                 $backwiewdays = 7;
                 $back = 41;
                 //			$period->anfdat=date_modify(new DateTime($date1), '-'.$back.' day');
             } else {
                 if ($page == 'yearpage') {
                     $backwiewdays = 14;
                     $back = 365;
                     //			$period->anfdat=date_modify(new DateTime($date1), '-'.$back.' day');
                 } else {
                     if ($page == 'lifepage') {
                         $lifestartdate = HTraininglogsHelper::getlifestartdate($user);
                         $period->anfdat = new DateTime($lifestartdate);
                         $anf = strtotime($period->anfdat->format("Y-m-d"));
                         $end = strtotime($date1);
                         $back = round(($end - $anf) / 3600 / 24) - 1;
                     }
                 }
             }
         }
     }
     $t = explode("-", $date1);
     $period->shift = date("z", mktime(0, 0, 0, $t[1], $t[2], $t[0])) + 1;
     $period->anfdatback = date_modify(new DateTime($date1), '-' . ($back + $backwiewdays) . ' day');
     $period->backviewdays = $backwiewdays;
     $period->enddat = new DateTime($date1);
     $period->anfdat = date_modify(new DateTime($date1), '-' . $back . ' day');
     $period->days = $back + 1;
     return $period;
 }
示例#18
0
 function proses_skpdj($spt_id, $omset)
 {
     $this->load->model('sptpd_model');
     $this->load->model('pajak_model');
     $sptpd = $this->sptpd_model->get($spt_id);
     $tahun = date('Y');
     $sptno = $this->sptpd_model->generate_sptno($tahun);
     $omset_skpdj = $omset * 125 / 100;
     $terimatgl = date('Y-m-d');
     $lastmonth = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
     $lastmonth = date('Y-m-d', $lastmonth);
     $masadari = date("Y-m-01", strtotime($lastmonth));
     $masasd = date("Y-m-t", strtotime($lastmonth));
     $jatuhtempo = date_create($terimatgl);
     date_modify($jatuhtempo, "+30 days");
     $jatuhtempotgl = date_format($jatuhtempo, "Y-m-d");
     $skpdj_type_id = '3';
     // <------------ id default
     $skpdj_type = $this->db->query("select id from pad_spt_type where typenm ilike '%skpdj%' limit 1");
     if ($skpdj_type->num_rows() !== 0) {
         $skpdj_type_id = $skpdj_type->row()->id;
     }
     $so = 'O';
     $pajak_id = $sptpd->pajak_id;
     $tarif = $this->db->query("select tarif from pad_tarif_pajak where pajak_id={$pajak_id}\r\n            order by tmt desc limit 1")->row()->tarif;
     $pajak_terhutang = $omset_skpdj * $tarif;
     $notes = 'entry by system';
     $user_id = sipkd_user_id();
     //SPT
     $sql = "insert into pad_spt(\r\n            tahun, sptno, type_id, so, masadari, masasd, jatuhtempotgl, \r\n            dasar, tarif, denda, bunga, setoran, kenaikan, kompensasi, lain2, \r\n            pajak_terhutang, \r\n            enabled, created, create_uid, terimanip, terimatgl, isprint_dc, \r\n            status_pembayaran, notes,\r\n\r\n            customer_id, customer_usaha_id, rekening_id, \r\n            pajak_id, r_bayarid, \r\n            minimal_omset, air_manfaat_id, air_zona_id, meteran_awal, \r\n            meteran_akhir, volume, satuan, r_panjang, r_lebar, r_muka, r_banyak, \r\n            r_luas, r_tarifid, r_kontrak, r_lama, r_jalan_id, r_jalanklas_id, \r\n            r_lokasi, r_judul, r_kelurahan_id, r_lokasi_id, r_calculated, \r\n            r_nsr, r_nsrno, r_nsrtgl, r_nsl_kecamatan_id, r_nsl_type_id, \r\n            r_nsl_nilai, unit_id, \r\n            r_nsr_id, r_lokasi_pasang_id, r_lokasi_pasang_val, r_jalanklas_val, \r\n            r_sudut_pandang_id, r_sudut_pandang_val, r_tinggi, r_njop, r_status, \r\n            r_njop_ketinggian, rek_no_paneng, sptno_lengkap, \r\n            sptno_lama, r_nama, r_alamat)\r\n\r\n            (select \r\n            {$tahun}, {$sptno}, {$skpdj_type_id}, '{$so}', '{$masadari}', '{$masasd}', '{$jatuhtempotgl}', \r\n            {$omset_skpdj}, {$tarif}, 0 denda, 0 bunga, 0 setoran, 0 kenaikan, 0 kompensasi, 0lain2, \r\n            {$pajak_terhutang}, \r\n            1 enabled, '{$terimatgl}', {$user_id}, {$user_id}, '{$terimatgl}', false isprint_dc, \r\n            0 status_pembayaran, '{$notes}', \r\n\r\n            customer_id, customer_usaha_id, rekening_id, \r\n            pajak_id, r_bayarid, \r\n            minimal_omset, air_manfaat_id, air_zona_id, meteran_awal, \r\n            meteran_akhir, volume, satuan, r_panjang, r_lebar, r_muka, r_banyak, \r\n            r_luas, r_tarifid, r_kontrak, r_lama, r_jalan_id, r_jalanklas_id, \r\n            r_lokasi, r_judul, r_kelurahan_id, r_lokasi_id, r_calculated, \r\n            r_nsr, r_nsrno, r_nsrtgl, r_nsl_kecamatan_id, r_nsl_type_id, \r\n            r_nsl_nilai, unit_id, \r\n            r_nsr_id, r_lokasi_pasang_id, r_lokasi_pasang_val, r_jalanklas_val, \r\n            r_sudut_pandang_id, r_sudut_pandang_val, r_tinggi, r_njop, r_status, \r\n            r_njop_ketinggian, rek_no_paneng, sptno_lengkap, \r\n            sptno_lama, r_nama, r_alamat\r\n            from pad_spt where id={$spt_id})";
     $this->db->query($sql);
     $new_spt_id = $this->db->insert_id();
     //SKPD J
     $usaha_id = $this->pajak_model->get($sptpd->pajak_id)->usaha_id;
     $kohirno = $this->generate_kohirno($tahun, $usaha_id);
     $update_data = array('spt_id' => $new_spt_id, 'kohirno' => $kohirno, 'usaha_id' => $usaha_id, 'tahun' => $tahun, 'kohirtgl' => $terimatgl, 'enabled' => 1, 'created' => $terimatgl, 'create_uid' => $user_id);
     $this->save($update_data);
     /*        
     $ret = new stdClass();
     $ret->cid  = $new_cid;
     $ret->cuid = $new_cuid;
     return $ret; 
     */
 }
示例#19
0
 private static function create_table($items, $order, $period, $step)
 {
     $i = 0;
     $itemsfull = array();
     $itemnew = new stdClass();
     $itemnew->tdate = 0;
     $item = new stdClass();
     $item = $items[$i];
     $dat = new DateTime($period->enddat->format('Y-m-d'));
     while ($dat >= $period->anfdat) {
         if ($item and $dat->format('Y-m-d') == JFactory::getDate($item->tdate)->format('Y-m-d')) {
             while ($item and $i < $period->days - $step and $dat->format('Y-m-d') == JFactory::getDate($item->tdate)->format('Y-m-d')) {
                 array_push($itemsfull, $item);
                 $i++;
                 $item = $items[$i];
             }
         } else {
             $j = array_push($itemsfull, new $itemnew());
             $itemsfull[$j - 1]->id = 0;
             $itemsfull[$j - 1]->sport = '';
             $itemsfull[$j - 1]->method = '';
             $itemsfull[$j - 1]->location = '';
             $itemsfull[$j - 1]->description = '';
             $itemsfull[$j - 1]->comment = '';
             $itemsfull[$j - 1]->competition = '';
             $itemsfull[$j - 1]->km = 0;
             $itemsfull[$j - 1]->climb = 0;
             $itemsfull[$j - 1]->etime = 0;
             $itemsfull[$j - 1]->ntime = 0;
             $itemsfull[$j - 1]->RECOM = 0;
             $itemsfull[$j - 1]->GA1 = 0;
             $itemsfull[$j - 1]->KA1 = 0;
             $itemsfull[$j - 1]->GA2 = 0;
             $itemsfull[$j - 1]->KA2 = 0;
             $itemsfull[$j - 1]->WSA = 0;
             $itemsfull[$j - 1]->Alt = 0;
             $itemsfull[$j - 1]->tdate = $dat->format('Y-m-d');
         }
         $dat = date_modify($dat, '-' . $step . ' day');
     }
     return $itemsfull;
 }
/**
 * Preprocess function for Date pager template.
 */
function rfht2_preprocess_date_views_pager(&$vars)
{
    ctools_add_css('date_views', 'date_views');
    $plugin = $vars['plugin'];
    $input = $vars['input'];
    $view = $plugin->view;
    $vars['nav_title'] = '';
    $vars['next_url'] = '';
    $vars['prev_url'] = '';
    if (empty($view->date_info) || empty($view->date_info->min_date)) {
        return;
    }
    $date_info = $view->date_info;
    // Make sure we have some sort of granularity.
    $granularity = !empty($date_info->granularity) ? $date_info->granularity : 'month';
    $pos = $date_info->date_arg_pos;
    if (!empty($input)) {
        $id = $plugin->options['date_id'];
        if (array_key_exists($id, $input) && !empty($input[$id])) {
            $view->args[$pos] = $input[$id];
        }
    }
    $next_args = $view->args;
    $prev_args = $view->args;
    $min_date = $date_info->min_date;
    $max_date = $date_info->max_date;
    // Set up the pager link format. Setting the block identifier
    // will force pager style links.
    if (isset($date_info->date_pager_format) && $date_info->date_pager_format != 'clean' || !empty($date_info->mini)) {
        if (empty($date_info->block_identifier)) {
            $date_info->block_identifier = $date_info->pager_id;
        }
    }
    if (empty($date_info->hide_nav)) {
        $prev_date = clone $min_date;
        date_modify($prev_date, '-1 ' . $granularity);
        $next_date = clone $min_date;
        date_modify($next_date, '+1 ' . $granularity);
        $format = array('year' => 'Y', 'month' => 'Y-m', 'day' => 'Y-m-d');
        switch ($granularity) {
            case 'week':
                $next_week = date_week(date_format($next_date, 'Y-m-d'));
                $prev_week = date_week(date_format($prev_date, 'Y-m-d'));
                $next_arg = date_format($next_date, 'Y-\\W') . date_pad($next_week);
                $prev_arg = date_format($prev_date, 'Y-\\W') . date_pad($prev_week);
                break;
            default:
                $next_arg = date_format($next_date, $format[$granularity]);
                $prev_arg = date_format($prev_date, $format[$granularity]);
        }
        $next_path = str_replace($date_info->date_arg, $next_arg, $date_info->url);
        $prev_path = str_replace($date_info->date_arg, $prev_arg, $date_info->url);
        $next_args[$pos] = $next_arg;
        $prev_args[$pos] = $prev_arg;
        $vars['next_url'] = date_pager_url($view, NULL, $next_arg);
        $vars['prev_url'] = date_pager_url($view, NULL, $prev_arg);
        $vars['next_options'] = $vars['prev_options'] = array();
    } else {
        $next_path = '';
        $prev_path = '';
        $vars['next_url'] = '';
        $vars['prev_url'] = '';
        $vars['next_options'] = $vars['prev_options'] = array();
    }
    // Check whether navigation links would point to
    // a date outside the allowed range.
    if (!empty($next_date) && !empty($vars['next_url']) && date_format($next_date, 'Y') > $date_info->limit[1]) {
        $vars['next_url'] = '';
    }
    if (!empty($prev_date) && !empty($vars['prev_url']) && date_format($prev_date, 'Y') < $date_info->limit[0]) {
        $vars['prev_url'] = '';
    }
    $vars['prev_options'] += array('attributes' => array());
    $vars['next_options'] += array('attributes' => array());
    $prev_title = '';
    $next_title = '';
    // Build next/prev link titles.
    switch ($granularity) {
        case 'year':
            $prev_title = t('Navigate to previous year');
            $next_title = t('Navigate to next year');
            break;
        case 'month':
            $prev_title = t('Navigate to previous month');
            $next_title = t('Navigate to next month');
            break;
        case 'week':
            $prev_title = t('Navigate to previous week');
            $next_title = t('Navigate to next week');
            break;
        case 'day':
            $prev_title = t('Navigate to previous day');
            $next_title = t('Navigate to next day');
            break;
    }
    $vars['prev_options']['attributes'] += array('title' => $prev_title);
    $vars['next_options']['attributes'] += array('title' => $next_title);
    // Add nofollow for next/prev links.
    $vars['prev_options']['attributes'] += array('rel' => 'nofollow');
    $vars['next_options']['attributes'] += array('rel' => 'nofollow');
    // Need this so we can use '&laquo;' or images in the links.
    $vars['prev_options'] += array('html' => TRUE);
    $vars['next_options'] += array('html' => TRUE);
    $link = FALSE;
    // Month navigation titles are used as links in the block view.
    if (!empty($date_info->mini) && $granularity == 'month') {
        $link = TRUE;
    }
    $params = array('granularity' => $granularity, 'view' => $view, 'link' => $link);
    $nav_title = theme('date_nav_title', $params);
    $vars['nav_title'] = $nav_title;
    $vars['mini'] = !empty($date_info->mini);
    // Get the date information from the view.
    $date_info = $view->date_info;
    // Choose the dislpay format of the month name.
    $format = 'F';
    // Get the previous month.
    $dateString = $date_info->min_date;
    $prev_month = new DateTime($dateString);
    $prev_month->modify('-1 month');
    $prev_pager_title = format_date($prev_month->getTimestamp(), 'custom', $format);
    $vars['prev_title'] = $prev_pager_title;
    // Get the next month.
    $next_month = new DateTime($dateString);
    $next_month->modify('+1 month');
    $next_pager_title = format_date($next_month->getTimestamp(), 'custom', $format);
    $vars['next_title'] = $next_pager_title;
}
示例#21
0
function calcFromDate($date)
{
    if (date('Y-m-d') == date_format(date_modify(date_create($date), '-1 day'), 'Y-m-d') or date('Y-m-d') == date_format(date_modify(date_create($date), '-2 day'), 'Y-m-d') or date('Y-m-d') == date_format(date_modify(date_create($date), '-3 day'), 'Y-m-d')) {
        return '#fcf8e3';
    }
    if ($date == date('Y-m-d')) {
        return '#f2dede';
    }
    if (strtotime($date) < strtotime(date('Y-m-d'))) {
        return '#f5f5f5';
    }
    return '#dff0d8';
}
示例#22
0
    $log_system = $log_row["system_name"];
    // coordinates
    $log_coordx = $log_row["x"];
    $log_coordy = $log_row["y"];
    $log_coordz = $log_row["z"];
    if (!valid_coordinates($log_coordx, $log_coordy, $log_coordz)) {
        $lb_res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_systems_own\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $log_system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
        $lb_arr = mysqli_fetch_assoc($lb_res);
        $log_coordx = $lb_arr["x"] == "" ? "" : $lb_arr["x"];
        $log_coordy = $lb_arr["y"] == "" ? "" : $lb_arr["y"];
        $log_coordz = $lb_arr["z"] == "" ? "" : $lb_arr["z"];
    }
    if (valid_coordinates($log_coordx, $log_coordy, $log_coordz)) {
        $log_date = $log_row["stardate"];
        $date = date_create($log_date);
        $log_added = date_modify($date, "+1286 years");
        $text = $log_row["log_entry"];
        if (mb_strlen($text) > 40) {
            $text = "" . substr($text, 0, 40) . "...";
        }
        $cat = ',"cat":[11]';
        $info .= '<div class="map_info"><span class="map_info_title">Logged System</span><br />';
        $info .= '<strong>Log entry</strong><br /><a href="/log.php?system=' . urlencode($log_system) . '" style="color:inherit;font-weight:bold" title="View the log for this system">' . $text . ' </a><br /><br />';
        $info .= '<strong>Added</strong><br />' . date_format($log_added, "j M Y, H:i") . '';
        $info .= '</div>';
        $data = '{"name":"' . $log_system . '"' . $cat . ',"coords":{"x":' . $log_coordx . ',"y":' . $log_coordy . ',"z":' . $log_coordz . '},"infos":' . json_encode($info) . '}' . $last_row . '';
        $last_row = "," . $data . "";
    }
}
//$info = '</div>';
$cur_sys_data = "";
示例#23
0
function amr_goto_byday($dateobj, $byday, $sign)
{
    global $amr_day_of_week_no;
    $dayofweek = $dateobj->format('w');
    /* 0=sunday, 6 = saturday */
    if ($dayofweek == '-1') {
        $dayofweek = get_oldweekdays($dateobj);
    }
    /* php seems to break around 1760   */
    $target = $amr_day_of_week_no[$byday];
    /*  mo=1 ,su=7  */
    $adjustment = $target - $dayofweek;
    if (isset($_GET['rdebug'])) {
        echo '<br />GO to day of week from ' . $dateobj->format('Ymd l') . ' going to ' . $sign . $byday . ' Target = ' . $target . ' Dayofweek = ' . $dayofweek . ' ' . $dateobj->format('l');
    }
    if ($sign === '+') {
        if ($adjustment < 0) {
            $adjustment = $adjustment + 7;
        }
    } else {
        // sign must be neg
        if ($adjustment > 0) {
            $adjustment = $adjustment - 7;
        }
    }
    if ($adjustment == 7) {
        $adjustment = 0;
    }
    // else will skip the first one if it matches
    if (isset($_GET['rdebug'])) {
        echo '<br />Adj = ' . $adjustment;
    }
    $d2 = new DateTime();
    // if cloning ok dont need tz
    $d2 = clone $dateobj;
    date_modify($d2, $adjustment . ' days');
    if (isset($_GET['rdebug'])) {
        echo ' Got date = ' . $d2->format('Ymd l');
    }
    return $d2;
}
示例#24
0
 public function next()
 {
     $mainframe = JFactory::getApplication();
     $date1 = JRequest::getVar('date1');
     $page = JRequest::getVar('page');
     $datum = new DateTime($date1);
     if ($page == 'daypage') {
         $datum = date_modify($datum, '+1 day');
     } else {
         if ($page == 'weekpage') {
             $datum = date_modify($datum, '+7 day');
         } else {
             if ($page == 'monthpage') {
                 $datum = date_modify($datum, '+30 day');
             } else {
                 if ($page == 'yearpage') {
                     $datum = date_modify($datum, '+365 day');
                 }
             }
         }
     }
     $mainframe->setUserState('com_htraininglogs.plansessions.filter.date1', $datum->format('Y-m-d'));
     $this->setRedirect(JRoute::_('index.php?option=com_htraininglogs&view=plansessions', false));
 }
示例#25
0
 public function add()
 {
     $jsonHosting = array();
     if (isset($this->request->post['product_id'])) {
         $product_id = $this->request->post['product_id'];
     } else {
         $product_id = 0;
     }
     if (isset($this->request->post['is_hosting'])) {
         $is_hosting = $this->request->post['is_hosting'];
     } else {
         $is_hosting = 'no';
     }
     if (isset($this->request->post['hosting_renew_order_hosting_id']) && (int) $this->request->post['hosting_renew_order_hosting_id'] > 0) {
         //sto aggiungendo un rinnovo di hosting esistente
         $hosting_renew_order_hosting_id = (int) $this->request->post['hosting_renew_order_hosting_id'];
         //la data di inizio del nuovo servizio deve essere uguale alla data di scadenza dell'hosting che sto rinnovando, nella forma "2012-07-22 00:00:00"
         $hosting_renew_date_start = $this->request->post['hosting_renew_date_end'];
         //calcolo la nuova data di scadenza
         $old_date_start = date_create_from_format('Y-m-d H:i:s', $this->request->post['hosting_renew_date_start']);
         $old_date_start->setTime(0, 0, 0);
         $old_date_end = date_create_from_format('Y-m-d H:i:s', $this->request->post['hosting_renew_date_end']);
         $old_date_end->setTime(0, 0, 0);
         //$this->log->writeVar($old_date_end);
         //$this->log->writeVar($old_date_start);
         //calcolo la durata (interval_days) del vecchio (e quindi anche del nuovo) servizio
         $interval = $old_date_start->diff($old_date_end);
         $interval_days = (int) $interval->format('%R%a');
         //la nuova data di scadenza sarà data dalla scadenza del vecchio servizio più la durata
         date_modify($old_date_end, '+' . $interval_days . ' days');
         $hosting_renew_date_end = $old_date_end->format('Y-m-d H:i:s');
         //salvo anche il vecchio server
         $hosting_renew_server = $this->request->post['hosting_renew_server'];
     } else {
         //sto aggiungengo un nuovo hosting
         $hosting_renew_order_hosting_id = 0;
         $hosting_renew_date_start = "";
         $hosting_renew_date_end = "";
         $hosting_renew_server = "";
     }
     if (isset($this->request->post['hosting_domain'])) {
         $hosting_domain = $this->request->post['hosting_domain'];
     } else {
         $hosting_domain = '';
     }
     /*
     if (isset($this->request->post['hosting_duration'])) {
     	$hosting_duration = (int)$this->request->post['hosting_duration'];
     } else {
     	$hosting_duration = 0;
     }
     if (isset($this->request->post['hosting_size'])) {
     	$hosting_size = (int)$this->request->post['hosting_size'];
     } else {
     	$hosting_size = 0;
     }
     if (isset($this->request->post['hosting_quantity'])) {
     	$hosting_quantity = (int)$this->request->post['hosting_quantity'];
     } else {
     	$hosting_quantity = 0;
     }
     */
     if (isset($this->request->post['hosting_domain_extension'])) {
         $hosting_domain_extension = $this->request->post['hosting_domain_extension'];
     } else {
         $hosting_domain_extension = '';
     }
     if (isset($this->request->post['hosting_domain_selected'])) {
         $hosting_domain_selected = $this->request->post['hosting_domain_selected'];
     } else {
         if (isset($this->request->post['hosting_domain']) && isset($this->request->post['hosting_domain_extension'])) {
             $hosting_domain_selected = $this->request->post['hosting_domain'] . '.' . $this->request->post['hosting_domain_extension'];
         } else {
             $hosting_domain_selected = '';
         }
     }
     if (isset($this->request->post['hosting_mailbox_selected'])) {
         $hosting_mailbox_selected = $this->request->post['hosting_mailbox_selected'];
     } else {
         $hosting_mailbox_selected = '';
     }
     //registrant
     if (isset($this->request->post['hosting_registrant_type'])) {
         $hosting_registrant_type = $this->request->post['hosting_registrant_type'];
     } else {
         $hosting_registrant_type = '';
     }
     if (isset($this->request->post['hosting_registrant_company'])) {
         //$hosting_registrant_company = $this->request->post['hosting_registrant_company'];
         parse_str(html_entity_decode($this->request->post['hosting_registrant_company']), $hosting_registrant_company);
     } else {
         $hosting_registrant_company = array();
     }
     if (isset($this->request->post['hosting_registrant_person'])) {
         //$hosting_registrant_person = $this->request->post['hosting_registrant_person'];
         parse_str(html_entity_decode($this->request->post['hosting_registrant_person']), $hosting_registrant_person);
     } else {
         $hosting_registrant_person = array();
     }
     if (isset($this->request->post['hosting_registrant'])) {
         $hosting_registrant = $this->request->post['hosting_registrant'];
     } else {
         $hosting_registrant = array();
     }
     if ($is_hosting == 'yes') {
         /*
         $this->log->write( "ciao, sono catalog/controller/burro/hosting/add(), e mi arriva in post:" );
         $this->log->writeVar($this->request->post);
         */
         //must populate with hostings saved in oc_product_hostings for my product_id
         $this->load->model('burro/hosting');
         $hostings = $this->model_burro_hosting->getProductHostings($product_id);
         //get longest hosting associated to product, and have duration for oc_order_hostings
         $hosting_duration = 0;
         foreach ($hostings as $my_hosting) {
             if (isset($my_hosting['duration']) && (int) $my_hosting['duration'] > $hosting_duration) {
                 $hosting_duration = (int) $my_hosting['duration'];
             }
         }
         //if sessions for hostings are not created yet, init it!
         if (!isset($this->session->data['hostings'])) {
             $this->session->data['hostings'] = array();
         }
         //store in sessions
         array_push($this->session->data['hostings'], array('product_id' => $product_id, 'hosting_domain' => $hosting_domain, 'hosting_domain_extension' => $hosting_domain_extension, 'hosting_domain_selected' => $hosting_domain_selected, 'hosting_mailbox_selected' => $hosting_mailbox_selected, 'hosting_duration' => $hosting_duration, 'hostings' => $hostings, 'hosting_renew_order_hosting_id' => $hosting_renew_order_hosting_id, 'hosting_registrant_type' => $hosting_registrant_type, 'hosting_registrant_company' => $hosting_registrant_company, 'hosting_registrant_person' => $hosting_registrant_person, 'hosting_registrant' => $hosting_registrant, 'hosting_renew_date_start' => $hosting_renew_date_start, 'hosting_renew_date_end' => $hosting_renew_date_end, 'hosting_renew_server' => $hosting_renew_server));
         //$this->log->write('dopo che ho aggiunto le session valgono: ');
         //$this->log->writeVar($this->session->data['hostings']);
     }
     $jsonHosting['success'] = "OK!";
     $this->response->setOutput(json_encode($jsonHosting));
 }
示例#26
0
 public function isValid($data)
 {
     if (!parent::isValid($data)) {
         return false;
     }
     $startDate = new DateTime($data['start']);
     $endDate = new DateTime($data['end']);
     if ($startDate > $endDate) {
         $this->start->addError($this->getTranslator()->translate('The start date must be on or before the end date.'));
         $this->end->addError($this->getTranslator()->translate('The end date must be on or after the start date.'));
         return false;
     }
     $facility = $this->em->find('Tillikum\\Entity\\Facility\\Facility', $data['facility_id']);
     $holdQueryBuilder = $this->em->createQueryBuilder()->select('h')->from('Tillikum\\Entity\\Facility\\Hold\\Hold', 'h')->where('h.start <= :proposedEnd')->andWhere('h.end >= :proposedStart')->andWhere('h.facility = :facility')->orderBy('h.start')->setParameter('facility', $facility)->setParameter('proposedStart', $startDate)->setParameter('proposedEnd', $endDate);
     if ($this->entity && isset($this->entity->id)) {
         $holdQueryBuilder->andWhere('h != :entity')->setParameter('entity', $this->entity);
     }
     $holds = $holdQueryBuilder->getQuery()->getResult();
     $bookings = $this->em->createQueryBuilder()->select('b')->from('Tillikum\\Entity\\Booking\\Facility\\Facility', 'b')->where('b.start <= :proposedEnd')->andWhere('b.end >= :proposedStart')->andWhere('b.facility = :facility')->orderBy('b.start')->setParameter('facility', $facility)->setParameter('proposedStart', $startDate)->setParameter('proposedEnd', $endDate)->getQuery()->getResult();
     $configs = $this->em->createQueryBuilder()->select('c')->from('Tillikum\\Entity\\Facility\\Config\\Config', 'c')->where('c.facility = :facility')->orderBy('c.start')->setParameter('facility', $facility)->getQuery()->getResult();
     if (count($holds) > 0) {
         foreach ($holds as $hold) {
             $errorMessage = sprintf($this->getTranslator()->translate('An existing hold from %s to %s overlaps your intended hold.'), $hold->start->format('Y-m-d'), $hold->end->format('Y-m-d'));
             $this->start->addError($errorMessage);
             $this->end->addError($errorMessage);
         }
         return false;
     }
     $occupancyInputs = array(new OccupancyInput($startDate, $data['space'] * -1, sprintf('start of the hold you specified from %s to %s', $startDate->format('Y-m-d'), $endDate->format('Y-m-d'))), new OccupancyInput(date_modify(clone $endDate, '+1 day'), $data['space'], sprintf('end of the hold you specified from %s to %s', $startDate->format('Y-m-d'), $endDate->format('Y-m-d'))));
     foreach ($bookings as $booking) {
         $occupancyInputs[] = new OccupancyInput($booking->start, -1, sprintf('start of a booking from %s to %s', $booking->start->format('Y-m-d'), $booking->end->format('Y-m-d')));
         $occupancyInputs[] = new OccupancyInput(date_modify(clone $booking->end, '+1 day'), 1, sprintf('end of a booking from %s to %s', $booking->start->format('Y-m-d'), $booking->end->format('Y-m-d')));
     }
     $currentConfigSpace = 0;
     foreach ($configs as $config) {
         $occupancyInputs[] = new OccupancyInput($config->start, $config->capacity - $currentConfigSpace, sprintf('start of a facility configuration from %s to %s', $config->start->format('Y-m-d'), $config->end->format('Y-m-d')));
         $currentConfigSpace = $config->capacity;
     }
     foreach ($holds as $hold) {
         $occupancyInputs[] = new OccupancyInput($hold->start, $hold->space * -1, sprintf('start of a hold from %s to %s', $hold->start->format('Y-m-d'), $hold->end->format('Y-m-d')));
         $occupancyInputs[] = new OccupancyInput(date_modify(clone $hold->end, '+1 day'), $hold->space, sprintf('end of a hold from %s to %s', $hold->start->format('Y-m-d'), $hold->end->format('Y-m-d')));
     }
     $occupancyEngine = new OccupancyEngine($occupancyInputs);
     $occupancyResult = $occupancyEngine->run();
     if (!$occupancyResult->getIsSuccess()) {
         $errorMessage = sprintf($this->getTranslator()->translate('There is no available space in this facility to add another ' . 'hold during the specified time period. The problem occurred ' . 'at the %s.'), $occupancyResult->getCulprit()->getDescription());
         $this->start->addError($errorMessage);
         $this->end->addError($errorMessage);
         return false;
     }
     return true;
 }
示例#27
0
 function log_cache_event($text)
 {
     global $wpdb, $blogid;
     $network = ausers_job_prefix();
     $wpdb->show_errors();
     $datetime = date_create('now', $this->tz);
     if (!empty($network)) {
         $text = $network . ' blogid=' . $wpdb->blogid . ' ' . $text;
     }
     /* clean up oldder log entries first  if there are any */
     $old = date_create();
     $old = clone $datetime;
     date_modify($old, '-1 day');
     $sql = "DELETE FROM " . $this->eventlog_table . " WHERE eventtime <= '" . date_format($old, 'Y-m-d H:i:s') . "'";
     $results = $wpdb->query($sql);
     /* now log our new message  */
     $sql = "INSERT INTO " . $this->eventlog_table . " ( eventtime, eventdescription ) " . "VALUES ('" . date_format($datetime, 'Y-m-d H:i:s') . "','" . $text . "')";
     $results = $wpdb->query($sql);
     return $results;
 }
示例#28
0
文件: _base.php 项目: annggeel/tienda
 /**
  * convert GMT data to Local data
  */
 public static function GMT_to_local_data($GMT_data)
 {
     $local_data = $GMT_data;
     if (!empty($local_data)) {
         $config = JFactory::getConfig();
         $offset = $config->getValue('config.offset');
         $date = date_create($GMT_data);
         date_modify($date, $offset . ' hour');
         $local_data = date_format($date, 'Y-m-d H:i:s');
     }
     return $local_data;
 }
示例#29
0
*/
$ress = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT user_poi.text AS text, user_visited_systems.visit AS visit\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_poi LEFT JOIN user_visited_systems ON user_visited_systems.system_name = user_poi.system_name\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_poi.system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tOR user_visited_systems.system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tUNION SELECT user_poi.text AS text, user_visited_systems.visit AS visit\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_poi RIGHT JOIN user_visited_systems ON user_visited_systems.system_name = user_poi.system_name\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_poi.system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tOR user_poi.poi_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tOR user_visited_systems.system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
$count = mysqli_num_rows($ress);
if ($count > 0) {
    $arra = mysqli_fetch_assoc($ress);
    $text = htmlspecialchars($arra["text"]);
    $visit = $arra["visit"];
    $visit_og = $arra["visit"];
    if (!$visit && !$text) {
        echo '<a href="System.php?system_name=' . urlencode($system) . '" style="color:inherit">' . $system . '</a>' . $screenshots . '<br />No additional information';
    } else {
        $logres = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT id, LEFT(log_entry , 100) AS text\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_log\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY stardate\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
        $logged = mysqli_num_rows($logres);
        if (isset($visit)) {
            $visit = date_create($visit);
            $visit_date = date_modify($visit, "+1286 years");
            $visit = date_format($visit_date, "d.m.Y, H:i");
        }
        if ($text != null) {
            echo "" . $text . "<br />";
        }
        if (!empty($visit)) {
            $visits = mysqli_num_rows(mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_visited_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "'"));
            $visit_unix = strtotime($visit_og);
            $visit_ago = get_timeago($visit_unix);
            echo "<a href=\"/System.php?system_name=" . urlencode($system) . "\" style=\"color:inherit;\">" . $system . "</a>" . $screenshots . "&nbsp;&nbsp;|&nbsp;\n\t\t\tTotal visits: " . $visits . "&nbsp;&nbsp;|&nbsp;&nbsp;First visit: " . $visit . " (" . $visit_ago . ")";
        } else {
            echo "<a href=\"/System.php?system_name=" . urlencode($system) . "\" style=\"color:inherit;\">" . $system . "</a>";
        }
        if ($logged > 0) {
            $logarr = mysqli_fetch_assoc($logres);
示例#30
0
function ParseOzi($trackFile, &$trackData)
{
    if (!preg_match('/OziExplorer/i', $trackFile, $m)) {
        return 0;
    }
    $nbPts = 0;
    foreach (preg_split('/[\\n\\r]+/', $trackFile, null, PREG_SPLIT_NO_EMPTY) as $line) {
        if (preg_match('/^\\s+
                (?P<lat>[-\\d\\.]+)[,\\s]+
                (?P<lon>[-\\d\\.]+)[,\\s]+[01][,\\s]+
                (?P<elev>[-\\d\\.]+)[,\\s]+
                (?P<date>[\\d\\.]+).*$
                /xim', $line, $m)) {
            $trackData['lat'][$nbPts] = floatval($m['lat']);
            $trackData['lon'][$nbPts] = floatval($m['lon']);
            $trackData['elev'][$nbPts] = max(intval($m['elev'] * 0.3048), 0);
            $time = floatval($m['date']) - intval($m['date']);
            $time = $time * 24;
            $hour = intval($time);
            $time = ($time - $hour) * 60;
            $min = intval($time);
            $time = ($time - $min) * 60;
            $sec = intval($time);
            $trackData['time']['hour'][$nbPts] = $hour;
            $trackData['time']['min'][$nbPts] = $min;
            $trackData['time']['sec'][$nbPts] = $sec;
            $nbPts++;
        }
    }
    if ($nbPts > 5) {
        $date = date_create();
        date_date_set($date, 1899, 12, 30);
        date_modify($date, intval($m['date']) . ' days');
        $trackData['date']['day'] = intval(date_format($date, 'j'));
        $trackData['date']['month'] = intval(date_format($date, 'n'));
        $trackData['date']['year'] = intval(date_format($date, 'Y'));
    }
    return $nbPts;
}