Esempio n. 1
0
 function get_state()
 {
     $this->db->select('User_Status as Sp, User_Current_Time as CT');
     $this->db->from('user');
     $this->db->where('User_ID', $this->get_data('id'));
     $query = $this->db->get();
     if ($query->num_rows() > 0) {
         $status = $query->row_array(1);
         $date = mdate('%Y-%m-%d %H:%i:%s', now('Asia/Manila'));
         $diff = date_diff(new DateTime($status['CT']), new DateTime($date));
         if (!$this->input->cookie("DTMSUserData")) {
             echo "no_cookie";
         } else {
             if ($this->input->cookie("DTMSUserData")) {
                 $data = json_decode($this->encrypt->decode(get_cookie("DTMSUserData")), TRUE);
                 if ($status['Sp'] == 1) {
                     echo "suspended";
                 } elseif ($status['Sp'] == 0) {
                     echo "activated";
                 } else {
                     echo $data["state"];
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public static function time_ago($timestamp)
 {
     $now = new DateTime('now');
     $from = new DateTime();
     $from->setTimestamp($timestamp);
     $diff = date_diff($now, $from);
     if ($diff->y > 0) {
         $message = $diff->y . ' year' . ($diff->y > 1 ? 's' : '');
     } else {
         if ($diff->m > 0) {
             $message = $diff->m . ' month' . ($diff->m > 1 ? 's' : '');
         } else {
             if ($diff->d > 0) {
                 $message = $diff->d . ' day' . ($diff->d > 1 ? 's' : '');
             } else {
                 if ($diff->h > 0) {
                     $message = $diff->h . ' hour' . ($diff->h > 1 ? 's' : '');
                 } else {
                     if ($diff->i > 0) {
                         $message = $diff->i . ' minute' . ($diff->i > 1 ? 's' : '');
                     } else {
                         if ($diff->s > 0) {
                             $message = $diff->s . ' second' . ($diff->s > 1 ? 's' : '');
                         } else {
                             $message = 'a moment';
                         }
                     }
                 }
             }
         }
     }
     return $message . ' ago';
 }
 public function deactivate_expired_listing()
 {
     $this->load->model('properties_listing_model');
     $this->load->model('users_model');
     $activated_lists = $this->properties_listing_model->find_all(array('activate' => 1));
     if (!empty($activated_lists)) {
         foreach ($activated_lists as $activated_list) {
             # last query here
             $current_date = new DateTime();
             $activate_date = new DateTime($activated_list->activate_time);
             $diff = date_diff($activate_date, $current_date, TRUE);
             $total_diff = $diff->format('%y') * 12 + $diff->format('%m');
             $expire_duration = $activated_list->deactivate_duration;
             if ((int) $total_diff >= $expire_duration) {
                 $activated_list->activate = 0;
                 $activated_list->save();
                 $user = $this->users_model->find_one(array('id' => $activated_list->user_id));
                 echo $activated_list->ref_tag . " is deactivated \n";
                 $data['ref_tag'] = $activated_list->ref_tag;
                 $this->_send_email('deactivation', $user['email'], $data);
                 echo "Notification sent to " . $user['email'];
             }
         }
     }
 }
Esempio n. 4
0
function duration(&$hrs) {
  $time = ceil(time()/3600)*3600;
  $now = new DateTime("@$time");
  $poh = new DateTime("@".($time-$hrs*3600));
  $age = date_diff($poh,$now);
  $hrs = "$hrs (".($age->y?"{$age->y}y, ":"").($age->m?"{$age->m}m, ":"").($age->d?"{$age->d}d, ":"")."{$age->h}h)";
}
Esempio n. 5
0
 public function age()
 {
     $bd = $this->patient->getOriginal('dateOfBirth');
     $diagDate = $this->schedule->getOriginal('diagDate');
     $age = date_diff(date_create($bd), date_create($diagDate))->y;
     return $age . ' ปี';
 }
Esempio n. 6
0
 public static function getLeaveDays($start_date, $end_date)
 {
     $start = new DateTime($start_date);
     $end = new DateTime($end_date);
     $diff = date_diff($start, $end);
     return $diff->d;
 }
Esempio n. 7
0
 public function niceDate($date, $preciseDate = false)
 {
     $dates = explode(' ', $date);
     $jours = explode('-', $dates[0]);
     $heures = explode(':', $dates[1]);
     if ($date > date('Y-m-d H:i:s')) {
         $date_a = new DateTime(date('Y-m-d H:i:s'));
         $date_b = new DateTime($date);
         $interval = date_diff($date_a, $date_b);
         $intervalFormat = explode(':', $interval->format('%d:%h:%I'));
         $str = $intervalFormat[0] > 0 ? $intervalFormat[0] . ' ' . __('day') . ($intervalFormat[0] > 1 ? 's' : '') . ' ' : '';
         $str .= $intervalFormat[1] > 0 ? $intervalFormat[1] . 'h' : '';
         $str .= $intervalFormat[0] == 0 && $intervalFormat[2] > 0 ? $intervalFormat[2] : '';
         if ($preciseDate && $dates[0] == date("Y-m-d")) {
             $str .= ' (' . __('Today at') . ' ' . $heures[0] . 'h' . $heures[1] . ')';
         } elseif ($preciseDate) {
             $str .= ' (' . $date_b->format('d/m/Y') . ')';
         }
         return __('in') . ' ' . $str;
     } elseif ($dates[0] == date("Y-m-d")) {
         $text = __('Today at');
         return $text . ' ' . $heures[0] . 'h' . $heures[1];
     } elseif ($dates[0] == date('Y-m-d', time() - 3600 * 24)) {
         $text = __('Yesterday at');
         return $text . ' ' . $heures[0] . 'h' . $heures[1];
     } else {
         $wording = $this->jour_semaine_court[date('w', mktime(0, 0, 0, $jours[1], $jours[2], $jours[0]))] . ' ';
         $wording .= $jours[2] . ' ' . strtolower($this->month[intval($jours[1])]) . ' ' . $jours[0];
         return $wording;
     }
 }
Esempio n. 8
0
function verbatim_date($date)
{
    $dt = new DateTime($date);
    $dt = new DateTime($dt->format('Y-m-d'));
    //only date we need
    $dt_now = new DateTime("now");
    $dt_now = new DateTime($dt_now->format('Y-m-d'));
    //only date we need
    if (!function_exists('date_diff')) {
        require_once ROOT_PATH . 'includes/date_diff_legacy.php';
        $interval = date_diff($dt, $dt_now);
    } else {
        $interval = date_diff($dt, $dt_now);
    }
    if ($interval->y == 0 && $interval->m == 0 && $interval->d == 0) {
        //		return array("Today","0x649812");
        return array($dt->format('d M'), "0x649812");
    } else {
        if ($interval->y == 0 && $interval->m == 0 && $interval->d == 1) {
            //		return array("Yesterday","0x000000");
            return array($dt->format('d M'), "0x000000");
        } else {
            if ($dt->format('Y') == $dt_now->format('Y')) {
                return array($dt->format('d M'), "0x000000");
            } else {
                return array($dt->format('d M Y'), "0x000000");
            }
        }
    }
}
 public function userViewAction($id)
 {
     $user = $this->getDoctrine()->getManager()->getRepository('BFUserBundle:User')->find($id);
     $numberfollows = count($listFollows = $this->getDoctrine()->getManager()->getRepository('BFSiteBundle:Follow')->findByFollowing($user));
     $numbervideos = count($listVideos = $this->getDoctrine()->getManager()->getRepository('BFSiteBundle:Video')->listVideos($user));
     $duelwins = $user->getDuelWins();
     $allChallenges = $this->getDoctrine()->getManager()->getRepository('BFSiteBundle:Challenge')->findall();
     $userChallenges = array();
     foreach ($allChallenges as $challenge) {
         //get the vidéos for every challenge
         $listChallengeVideos = $this->getDoctrine()->getManager()->getRepository('BFSiteBundle:Video')->videoForChallenge($challenge, $user);
         if (!empty($listChallengeVideos)) {
             array_push($userChallenges, $listChallengeVideos);
         }
     }
     $listDuels = $user->getDuels();
     //retrieving the service
     $info = $this->container->get('bf_site.rankinfo');
     $rankinfo = $info->rankInfo($user);
     $duelRankInfo = $info->duelRankInfo($user);
     //calculating the age of the user.
     $interval = date_diff(new \Datetime(), $user->getBirthday());
     $age = $interval->y;
     //here we create an array with all the informations for the profileTop
     $profileTopInfo = array('followscount' => $numberfollows, 'videoscount' => $numbervideos, 'age' => $age, 'duelwins' => $duelwins);
     $lists = array('listVideos' => $listVideos, 'listFollows' => $listFollows, 'listDuels' => $listDuels, 'userChallenges' => $userChallenges);
     $rank = array('rankinfo' => $rankinfo, 'duelrankinfo' => $duelRankInfo);
     return $this->render('BFAdminBundle:User:view.html.twig', array('lists' => $lists, 'user' => $user, 'rank' => $rank, 'profiletop' => $profileTopInfo));
 }
Esempio n. 10
0
function timeDifferance($dateTime1, $dateTime2)
{
    $call_start = new DateTime($dateTime1);
    $call_end = new DateTime($dateTime2);
    $interval = date_diff($call_start, $call_end);
    return $interval->format('%h hour %i min %s sec');
}
Esempio n. 11
0
function dateDifference($date_1, $date_2, $differenceFormat = '%a')
{
    $datetime1 = date_create($date_1);
    $datetime2 = date_create($date_2);
    $interval = date_diff($datetime1, $datetime2);
    return $interval->format($differenceFormat);
}
Esempio n. 12
0
 public static function diff($from, $to)
 {
     $datetime1 = date_create($from);
     $datetime2 = date_create($to);
     $interval = date_diff($datetime1, $datetime2);
     return $interval->format('%R%a days');
 }
Esempio n. 13
0
 static function exp_encode($days)
 {
     $datetime1 = date_create('1970-01-01');
     $datetime2 = date_create($days);
     $interval = date_diff($datetime1, $datetime2);
     return (int) $interval->format('%a');
 }
Esempio n. 14
0
 public static function compareDate($one, $two)
 {
     $datetime1 = date_create($one);
     $datetime2 = date_create($two);
     $interval = date_diff($datetime1, $datetime2);
     return $interval->days;
 }
Esempio n. 15
0
 /**
  * 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));
 }
Esempio n. 16
0
function datediff($date1, $date2)
{
    $date1 = date_create($date1);
    $date2 = date_create($date2);
    $diff = date_diff($date1, $date2);
    return $diff->format("%a");
}
Esempio n. 17
0
function task_select(&$state, &$HTML, $rec = -1)
{
    if ($rec < 0) {
        //checking returned
        if (!isset($_GET["row"])) {
            return;
        }
        $rec = $_GET["row"];
        //get row number
    }
    task_list($state);
    //restore the record list
    if (!array_key_exists($rec, $state->records)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid task id " . $rec, true);
    }
    $record = $state->records[$rec];
    if ($record[1] != "") {
        $inactive = new DateTime($record[1]);
        $diff = date_diff($state->from_date, $inactive)->days;
        if ($diff < $state->columns[COL_INACTIVE]) {
            $state->columns[COL_INACTIVE] = $diff;
            $state->columns[COL_AGENT] = "task";
        }
        $record[0] .= "<br>(inactive as of " . $record[1] . ")";
    }
    $state->task_id = $rec;
    $state->msgStatus = "";
    $HTML .= "cell = document.getElementById('TK_" . $state->row . "');\n";
    $HTML .= "cell.innerHTML = '" . $record[0] . "';\n";
}
 /**
  * Store the block booking. Booking is per court and date.
  * First step is to find out if block booking is repeat - see if a Finish date has been entered, Create a booking for each date, ie every Thursday etc.
  * Else just create a block booking for the selected date and court.
  * - if cancelled booking data send out email to user, with a booking which has been removed by an administrator.
  * @param StoreBlockBookingRequest $request
  * @return Redirect
  */
 public function store_block_bookings(StoreBlockBookingRequest $request)
 {
     if (!null == $request->input('finish_date')) {
         $diff = date_diff(date_create($request->input('date')), date_create($request->input('finish_date')));
         $dates = [];
         $cancelled_booking_data = [];
         $dates[] = $request->input('date');
         for ($i = 1; $i <= $diff->days / 7; $i++) {
             $week = '+%s week';
             $date = strtotime(sprintf($week, $i), strtotime($request->input('date')));
             $dates[] = date('Y-m-d', $date);
         }
         foreach ($dates as $date) {
             $cancelled_booking_data[] = $this->create_block_bookings($request, $date);
         }
     } else {
         $cancelled_booking_data[] = $this->create_block_bookings($request, $request->input('date'));
     }
     if (!empty($cancelled_booking_data)) {
         session()->flash('booking_data', $cancelled_booking_data);
         //with array of emails dates and booking info - go to a get request - create session with cancellation data.
         return redirect('email/admin-booking-cancellation');
     }
     session()->flash('flash_message', 'Your booking was successful');
     return redirect('administrator/block-bookings');
 }
Esempio n. 19
0
 public function getTimeDifference($otherDate)
 {
     $date1Timestamp = date_create($this->dayOfBirth);
     $date2Timestamp = date_create($otherDate);
     $diff = date_diff($date1Timestamp, $date2Timestamp);
     return $diff;
 }
Esempio n. 20
0
 /**
  *
  * @param type $post
  * @throws Exception
  */
 public function fetchProducts(&$post)
 {
     $interval = date_diff(new \DateTime($post['FromDt']), new \DateTime($post['ToDt']));
     $this->datediff = $interval->days;
     if ($interval->days > 30) {
         throw new Exception('Maximun period per request 30 days.');
     }
     getHotelDestination($post);
     $roomRequest = getRoomType($post);
     //find max pax room type request.
     $a_maxpax = array();
     foreach ($roomRequest as $item) {
         //15389
         if ($item['adults'] == 2 && $item['children'] > 0 && $item['rqbed'] == 'N') {
             throw new Exception('Not support case 2ad+1ch extrabeds=N');
         }
         $a_maxpax[] = $item['adults'] + $item['children'];
     }
     $i_maxpax = max($a_maxpax);
     unset($a_maxpax);
     $query = "SELECT \r\n                    hotel.SpHotelName,\r\n                    hotel.SpHotelCode,\r\n                    hotel.CommRate,\r\n                    hotel.CommType,\r\n                    hotel.CommCurrencyCode,\r\n                    hotel.MarkupRate,\r\n                    hotel.MarkupType,\r\n                    hotel.MarkupCurrencyCode,\r\n                    (CASE(hotel.CommType)\r\n                        WHEN 'PERCENT' THEN (\r\n                            product.Base_AmountAfterTax * (1-(hotel.CommRate / 100))\r\n                            +\r\n                            CASE(hotel.MarkupType)\r\n                                WHEN 'PERCENT' THEN (\r\n                                    hotel.MarkupRate / 100\r\n                                )\r\n\t                        END \r\n                                *\r\n\t                        CASE(hotel.CommType)\r\n\t                             WHEN 'PERCENT' THEN (\r\n                                        product.Base_AmountAfterTax * (1-(hotel.CommRate / 100))\r\n                                    )\r\n\t                        END\r\n\t\t\t)\r\n                    END) as Base_AmountAfterTax,\r\n               \r\n                    product.RestrictionStatus,\r\n                    product.RestrictionArrival,\r\n                    product.RestrictionDeparture,\r\n                    product.`start`,\r\n                    product.`end`,\r\n                    product.BookingLimit,\r\n                    product.SetMinLOS,\r\n                    product.SetMaxLOS,\r\n                    product.SpRoomCode,\r\n                    product.SpMealType,\r\n                    product.SpRoomName,\r\n                    product.Base_NumberOfGuests \r\n                 FROM \r\n                    " . _SUPPLIERCODE . "_sitec_hotels hotel\r\n                 INNER JOIN (SELECT\r\n                    Base_AmountAfterTax,\r\n                    av.RestrictionStatus,\r\n                    av.RestrictionArrival,\r\n                    av.RestrictionDeparture,\r\n                    av.`start`,\r\n                    av.`end`,\r\n                    av.BookingLimit,\r\n                    av.SetMinLOS,\r\n                    av.SetMaxLOS,\r\n                    prod.IdConfigs,\r\n                    prod.SpHotelCode,\r\n                    prod.SpRoomCode,\r\n                    prod.SpMealType,\r\n                    prod.SpRoomName,\r\n                    rate.Base_NumberOfGuests \r\n                 FROM\r\n                    " . _SUPPLIERCODE . "_sitec_products prod,\r\n                    " . _SUPPLIERCODE . "_sitec_avails av,\r\n                    " . _SUPPLIERCODE . "_sitec_rates rate \r\n                 WHERE\r\n                 rate.Base_NumberOfGuests >= " . $i_maxpax . "\r\n                 AND av.`start` BETWEEN '" . $post['FromDt'] . "' AND '" . $post['ToDt'] . "' \r\n                 AND rate.`start` BETWEEN '" . $post['FromDt'] . "' AND '" . $post['ToDt'] . "' \r\n                 " . $this->queryFilter($post)->roomcatg . $this->queryFilter($post)->mealtype . "\r\n                 AND av.HotelCode = prod.SpHotelCode \r\n                 AND av.InvTypeCode = prod.SpRoomCode \r\n                 AND av.RatePlanCode= prod.SpRatePlan \r\n                 AND rate.HotelCode = prod.SpHotelCode \r\n                 AND rate.InvTypeCode = prod.SpRoomCode \r\n                 AND rate.RatePlanCode= prod.SpRatePlan \r\n                 AND av.`start` = rate.`start` \r\n                 AND av.`end` = rate.`end` \r\n                 AND av.IdCL956supplierconfigs = prod.IdConfigs \r\n                 AND rate.IdConfigs = prod.IdConfigs \r\n                 ) product\r\n                 ON hotel.SpHotelCode = product.SpHotelCode AND hotel.IdConfigs = product.IdConfigs\r\n                 WHERE hotel.SpCityCode = '" . $post['DestCity'] . "'\r\n                 AND hotel.SpCountryCode = '" . $post['DestCountry'] . "' " . $this->queryFilter($post)->hotel . "\r\n                 ORDER BY\r\n                    product.SpRoomCode,\r\n                    product.SpMealType,\r\n                    product.`start` \r\n                 ASC";
     $rs = $this->db->query($query);
     if ($rs === FALSE) {
         throw new Exception('database was down,please try again.');
     }
     if ($rs->num_rows() == 0) {
         throw new Exception('No rate results (From : ' . $post['FromDt'] . ', To : ' . $post['ToDt'] . ')');
     }
     $this->filterResults($post, $rs->result_array());
     //free result memory.
     $rs->free_result();
 }
 /**
  * Reads data for an event.
  * @param [String => Mixed] $opts
  * @return [String => Mixed]
  * @override AttemtStarted
  */
 public function read(array $opts)
 {
     $end = (new \DateTime())->setTimestamp($opts['attempt']->timestart);
     $start = (new \DateTime())->setTimestamp($opts['attempt']->timefinish);
     $duration = date_diff($start, $end)->format('P%YY%MM%DDT%HH%IM%SS');
     return array_merge(parent::read($opts), ['recipe' => 'attempt_completed', 'attempt_result' => (double) ($opts['attempt']->sumgrades ?: 0), 'attempt_completed' => $opts['attempt']->state === 'finished', 'attempt_duration' => $duration]);
 }
Esempio n. 22
0
 public function getTable()
 {
     $u_s = json_decode($this->session->userdata('u_s'));
     $tbName = $this->getNowTableName();
     $datetime1 = date_create($this->input->get('date_start'));
     $datetime2 = date_create($this->input->get('date_end'));
     $interval = date_diff($datetime1, $datetime2);
     $count_table = $interval->format('%m') + 2;
     $where = "city_id=" . $u_s->city_id . " AND create_date BETWEEN '" . $this->input->get('date_start') . " 00:00:00' AND '" . $this->input->get('date_end') . " 23:59:59'";
     // total
     $str = '';
     for ($i = 0; $i < $count_table; $i++) {
         $date = new DateTime(date("Ym", strtotime($this->input->get('date_end'))));
         $date->sub(new DateInterval('P' . $i . 'M'));
         $tbName = 'log_' . $date->format('Ym');
         $str .= (strlen($str) > 0 ? ' UNION ' : '') . " SELECT `id`, `city_id`, `create_date`, `icmp`, `web_service`, `cpu`, `mem` , `sess` FROM " . $tbName . " WHERE " . $where;
     }
     $query = $this->db->query($str);
     $total = $query->num_rows();
     // real
     $str = '';
     for ($i = 0; $i < $count_table; $i++) {
         $date = new DateTime(date("Ym", strtotime($this->input->get('date_end'))));
         $date->sub(new DateInterval('P' . $i . 'M'));
         $tbName = 'log_' . $date->format('Ym');
         $str .= (strlen($str) > 0 ? ' UNION ' : '') . " SELECT id, city_id, create_date, icmp, web_service, cpu, mem, sess FROM " . $tbName . " WHERE " . $where;
     }
     $query = $this->db->query('SELECT * from (' . $str . ') as a' . " ORDER BY " . $this->input->get('sort') . ' ' . $this->input->get('order') . ' LIMIT ' . $this->input->get('limit') . ' OFFSET ' . $this->input->get('offset'));
     $ary_ret['rows'] = $query->result_array();
     $ary_ret['total'] = $total;
     return json_encode($ary_ret);
 }
 /**
  * таймдайн лента
  * 
  * @uses ApiController::_userId
  * @uses Controller::request
  * @return void
  */
 public function get_timeline()
 {
     if (!isset($this->_controller->request->data['start_date']) or !isset($this->_controller->request->data['end_date'])) {
         throw new ApiIncorrectRequestException();
     }
     $startDate = str_replace('T', ' ', $this->_controller->request->data['start_date']);
     $startDate = str_replace('Z', '', $startDate);
     $startDate = date('Y-m-d', strtotime($startDate));
     $endDate = str_replace('T', ' ', $this->_controller->request->data['end_date']);
     $endDate = str_replace('Z', '', $endDate);
     $endDate = date('Y-m-d', strtotime($endDate));
     $this->_controller->ApiTimeline->set(array('start_date' => $startDate, 'end_date' => $endDate));
     if (!$this->_controller->ApiTimeline->validates()) {
         throw new ApiIncorrectRequestException($this->_controller->ApiTimeline->validationErrors);
     }
     if (strtotime($startDate) > strtotime($endDate)) {
         throw new ApiIncorrectRequestException();
     }
     //ограничение запроса
     $daysDiff = date_diff(new DateTime($endDate), new DateTime($startDate))->days;
     if ($daysDiff > 30) {
         throw new ApiIncorrectRequestException();
     }
     $result = $this->_controller->ApiTimeline->getTimeline($this->_userId, $startDate, $endDate);
     $this->_controller->setResponse($result);
 }
Esempio n. 24
0
function field_input_audit()
{
    global $_STATE;
    $errors = "";
    foreach ($_STATE->fields as $name => $field) {
        if (($msg = $field->audit()) === true) {
            continue;
        }
        $errors .= "<br>" . $name . ": " . $msg;
    }
    if ($errors != "") {
        $_STATE->msgStatus = "Error:" . $errors;
        return false;
    }
    $diff = date_diff($_STATE->fields["Close Date"]->value, COM_NOW(), true);
    if ($diff->m > 2) {
        $_STATE->msgStatus = "The Close Date is suspect - proceeding anyway";
    }
    if (!array_key_exists(strval($_POST["selAccounting"]), $_STATE->accounting)) {
        throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid accounting id " . $_POST["selAccounting"]);
        //we're being spoofed
    }
    $_STATE->accounting_id = intval($_POST["selAccounting"]);
    //Should check to see if inactive is greater than any timelogs?
    foreach ($_STATE->fields as $name => $field) {
        $field->disabled = true;
    }
    return TRUE;
}
Esempio n. 25
0
 function dateDiff($s, $t)
 {
     $datetime1 = date_create($s);
     $datetime2 = date_create($t);
     $interval = date_diff($datetime1, $datetime2);
     return $interval->format('%R%a days');
 }
Esempio n. 26
0
 public function getage($birthday)
 {
     if (function_exists('date_diff')) {
         $now = date_create("now");
         $birthday = date_create($birthday);
         if ($now < $birthday) {
             return "* 岁";
         } else {
             $interval = date_diff($now, $birthday);
             return $interval->format("%y") . " 岁";
         }
     } else {
         $year_diff = '';
         $time = strtotime($birthday);
         if (FALSE === $time) {
             return '*';
         }
         $birthday = date('Y-m-d', $time);
         list($year, $month, $day) = explode("-", $birthday);
         $year_diff = date("Y") - $year;
         $month_diff = date("m") - $month;
         $day_diff = date("d") - $day;
         if ($day_diff < 0 || $month_diff < 0) {
             $year_diff--;
         }
         return $year_diff . ' 岁';
     }
 }
Esempio n. 27
0
 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'');
         }
     }
 }
Esempio n. 28
0
 /**
  * Obtenemos una fecha en formato amigable.
  * @return string
  */
 public function fuzzy()
 {
     // Obtenemos diferencia de tiempo.
     if (method_exists($this, 'diff')) {
         $diff = $this->diff(new DateTime("now"));
     } else {
         $diff = date_diff(new DateTime('now'));
     }
     if ($diff->invert) {
         $key = __('en %s', FALSE);
     } else {
         $key = __('hace %s', FALSE);
     }
     if ($diff->y != 0) {
         return sprintf($key, $this->pluralize($diff->y, __('a&ntilde;o', FALSE)));
     }
     if ($diff->m != 0) {
         return sprintf($key, $this->pluralize($diff->m, __('mes', FALSE)));
     }
     if ($diff->d != 0) {
         return sprintf($key, $this->pluralize($diff->d, __('dia', FALSE)));
     }
     if ($diff->h != 0) {
         return sprintf($key, $this->pluralize($diff->h, __('hora', FALSE)));
     }
     if ($diff->i != 0) {
         return sprintf($key, $this->pluralize($diff->i, __('minuto', FALSE)));
     }
     return sprintf($key, __('instantes', FALSE));
 }
Esempio n. 29
0
 public function displayAction($slug)
 {
     $session = $this->get('session');
     /** @var $reservation \AppBundle\Entity\Reservation */
     $reservation = $this->getDoctrine()->getRepository('AppBundle:Reservation')->findOneBySlug($slug);
     if ($reservation == null) {
         return $this->redirectToRoute('find_reservation');
     }
     if ($reservation->getSessionId() != $session->getId()) {
         return $this->redirectToRoute('find_reservation');
     }
     $diff = date_diff($reservation->getPickupDateTime(), $reservation->getReturnDateTime());
     $hours = $diff->h;
     $hours = $hours + $diff->days * 24;
     $hours = $hours + $diff->i / 60;
     $canceled = false;
     $confirmed = false;
     if ($reservation->getStatus()->getStatus() == "Canceled") {
         $canceled = true;
     }
     if ($reservation->getStatus()->getStatus() == "Confirmed") {
         $confirmed = true;
     }
     $isPaid = $reservation->getPaid();
     return $this->render('AppBundle:default:status.html.twig', array('reservation' => $reservation, 'hours' => $hours, 'canceled' => $canceled, 'confirmed' => $confirmed, 'paid' => $isPaid));
 }
Esempio n. 30
0
function test_date_diff()
{
    $dt1 = date_create("2010-08-02");
    $dt2 = date_create("2010-08-30");
    $interval = date_diff($dt1, $dt2, true);
    return date_interval_format($interval, "%d");
}