Ejemplo n.º 1
0
 function visited($adId)
 {
     $result = $this->db->get_where('visits', array('addId' => $adId, 'majboorId' => $_SESSION['user_id']))->result();
     if ($result) {
         $ad = $result[0];
         $newNow = $this->carbon->now(new DateTimeZone('Asia/Karachi'))->toDateString();
         $timeDiff = array();
         $date = new DateTime($ad->time);
         $date->modify("+5 hours");
         $date = $date->format("Y-m-d");
         $timeDiff = timeDifference($date, $newNow);
         if ($timeDiff["days"] < 1) {
             return true;
         } else {
             false;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
function visited($addId, $majboorId)
{
    $ad = ORM::for_table('visits')->where(array('addId' => $addId, 'majboorId' => $majboorId))->find_one();
    if ($ad) {
        $now = date("Y-m-d H:i:s");
        $date = new DateTime($now);
        $date->modify("+5 hours");
        $newNow = $date->format("Y-m-d H:i:s");
        $timeDiff = array();
        $date = new DateTime($ad->time);
        $date->modify("+5 hours");
        $date = $date->format("Y-m-d");
        $timeDiff = timeDifference($date, $newNow);
        if ($timeDiff["days"] >= 1) {
            return 0;
            // means ad is not visited tody but before.
        } else {
            return 1;
            // means add is visited today.
        }
    } else {
        return 2;
        //add was never visited till now
    }
}
Ejemplo n.º 3
0
function leftSpace($reservation_time, $occupancy)
{
    global $general;
    $time = $reservation_time;
    if (substr($reservation_time, 0, 1) == "'") {
        $time = substr($reservation_time, 0, -1);
        $time = substr($time, 1);
    }
    //Check availability
    list($h, $m) = explode(":", $time);
    $leftspace = $_SESSION['outlet_max_capacity'] - $occupancy[$time];
    $endtime = timeDifference($time, $_SESSION['selOutlet']['avg_duration'], 'ADD', 0);
    if ($endtime < $time) {
        $endtime = $time;
    }
    $ii = 1;
    while ($time <= $endtime) {
        $space = $_SESSION['outlet_max_capacity'] - $occupancy[$time];
        //store lowest availability of space
        if ($space < $leftspace) {
            $leftspace = $space;
        }
        $time = date('H:i', mktime($h + 0, $m + $ii * $general['timeintervall'], 0, date("m"), date("d"), date("Y")));
        $ii++;
    }
    return $leftspace;
}
<?php

include '../../functions.php';
include '../../connectdb.php';
//Get data from the former page via POST method
$id = $_POST["order-id"];
$returned_time = $_POST["returned-time"];
$returned_bicycle_outlet_user_id = $_POST["returned-bicycle-outlet-user-id"];
$rented_time = $_POST["rented-time"];
$bicycle_info_id = $_POST["bicycle-info-id"];
$sum_before_discount = 0;
$hour_discount = 0;
$total_order_sum = 0;
$bicycle = getBicycle($bicycle_info_id);
$bicycle = mysql_fetch_array($bicycle);
$rent_price_hour = $bicycle["rent_price_hour"];
$rent_discount_hour = $bicycle["rent_discount_hour"];
$rent_discount_percent = $bicycle["rent_discount_percent"];
$total_hours = timeDifference($rented_time, $returned_time);
$sum_before_discount = $rent_price_hour * $total_hours;
if ($total_hours >= $rent_discount_hour) {
    $hour_discount = $rent_discount_percent / 100 * $sum_before_discount;
}
$total_order_sum = $sum_before_discount - $hour_discount;
finalizeOrder($id, $returned_bicycle_outlet_user_id, $returned_time, $hour_discount, $sum_before_discount, $total_order_sum);
//Go to the dashboard
header("Location: add-new-order.php");