예제 #1
0
 public static function add($paymetID, $amount, $is_success, $pay_type, $veh_id)
 {
     $companyId = $_SESSION['user']['company'];
     $userId = $_SESSION['user']['id'];
     $db = new Connection();
     $conn = $db->connect();
     $paytime = $db->getTimeNow();
     if ($pay_type == 2) {
         $paid_amount = 0;
         $act_date = $paytime;
     } else {
         $act_date = Payments::getVehicleActivationDateFromDB($veh_id);
         $paid_amount = Payments::getPreviousPaymentForVehicle($veh_id, $companyId);
     }
     $total_amount = DEF_MEM_AMOUNT;
     $paid_amount += $amount;
     $paid_per = 100 - ($total_amount - $paid_amount) / $total_amount * 100;
     $rest_amount = $total_amount - $paid_amount;
     $sql = "INSERT INTO `payments`(`amount`, `company_id`, `user_id`, `timestamp`, `is_success`, `pay_type`, `rest_amount`, `paid_perc`, `paid_amount`, `vehicle_id`, `total_amount`, `veh_activation_date`, `paymentId`) VALUES ('{$amount}','{$companyId}','{$userId}','{$paytime}','{$is_success}','{$pay_type}','{$rest_amount}','{$paid_per}','{$paid_amount}', '{$veh_id}', '{$total_amount}', '{$act_date}', '{$paymetID}')";
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         return mysqli_error($conn);
     }
     return false;
 }
예제 #2
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require_once '../../framework/Connection.php';
//if(!isset($_SESSION))
// opening db connection
$db = new Connection();
$conn = $db->connect();
//print_r($_POST);
//print_r($_POST);
$id = $_POST['id'];
$solution = $_POST['solution'];
$user = $_SESSION['user']['id'];
$state = "closed";
$fgDate = $db->getTimeNow();
//add user
$issue = "UPDATE issue SET `state` = '{$state}', `solution` = '{$solution} ', `closed_by` = '{$user}', `date_closed` = '{$fgDate}' WHERE id = '{$id}'";
//echo $issue;
if (mysqli_query($conn, $issue)) {
    echo "Issue Resolved!!!";
    echo "<br><br><a href='index.php'>BACK TO LIST</a>";
} else {
    echo "<br>error";
}
예제 #3
0
 function deploy()
 {
     $db = new Connection();
     $conn = $db->connect();
     $lattitude_list;
     $longitude_list;
     $last_last_update;
     $this->isDeployed = 1;
     $fgDate = $db->getTimeNow();
     $sql = "UPDATE vehicle SET deployed = '1', date_deployed = '{$fgDate}' WHERE id = '{$this->id}'";
     //print_r($sql);
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         return false;
         //print_r("Error updating record: " . mysqli_error($conn));
     }
 }
예제 #4
0
 public static function addTimelineEvent($type, $vehicle, $driver, $employee, $addedBy, $action)
 {
     // opening db connection
     $db = new Connection();
     $conn = $db->connect();
     $today = date('Y-m-d');
     $fgDate = $db->getTimeNow();
     if ($vehicle != "") {
         $mVehicle = new Vehicle($vehicle);
     }
     if ($driver != "") {
         $mDriver = new Vehicle($driver);
     }
     if ($employee != "") {
         $mEmployee = new Vehicle($employee);
     }
     $mAddedBy = new User($addedBy);
     $companyId = $mAddedBy->getCompany();
     $mCompany = new Company($companyId);
     $adminId = $mCompany->getAdmin();
     $sql = "INSERT INTO `timeline` (`type`, `vehicle`, `driver`, `employee`, `company`, `admin`, `added_by`, `action`, `date_added`) VALUES ('{$type}', '{$vehicle}', '{$driver}', '{$employee}', '{$companyId}', '{$adminId}', '{$addedBy}', '{$action}', '{$fgDate}')";
     //echo $sql;
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         return false;
     }
 }
예제 #5
0
 function setLocation($lattitude, $longitude)
 {
     //require_once '../framework/DBConnect.php';
     // opening db connection
     $db = new Connection();
     $conn = $db->connect();
     $lattitude_list;
     $longitude_list;
     $last_last_update;
     /*
      * Select values from vehicle table
      */
     $sql = "SELECT * FROM location WHERE job_id = '{$this->id}'";
     $result = $conn->query($sql);
     echo "-------->" . $sql . "<br>";
     if ($result->num_rows > 0) {
         print_r($sql);
         while ($row = $result->fetch_assoc()) {
             $lattitude_list = floatval($_POST['lattitude']) . ";" . $row['lattitude_list'];
             $longitude_list = floatval($_POST['longitude']) . ";" . $row['longitude_list'];
             $last_last_update = $row['last_update'];
         }
     }
     /*
      * Finally update the vehicle table with latest values
      */
     $fgDate = $db->getTimeNow();
     $sql = "UPDATE location SET lattitude = '{$lattitude}', longitude = '{$longitude}', last_update = '{$fgDate}', lattitude_list = '{$lattitude_list}', longitude_list = '{$longitude_list}', last_last_update = '{$last_last_update}' WHERE job_id = '{$this->id}'";
     print_r($sql);
     if (mysqli_query($conn, $sql)) {
         print_r("Record updated successfully");
     } else {
         print_r("Error updating record: " . mysqli_error($conn));
     }
 }
예제 #6
0
 function deploy()
 {
     //require_once '../framework/DBConnect.php';
     // opening db connection
     $db = new Connection();
     $conn = $db->connect();
     $lattitude_list;
     $longitude_list;
     $last_last_update;
     /*
      * Finally update the retvehicle table with latest values
      */
     $this->isDeployed = 1;
     $fgDate = $db->getTimeNow();
     $sql = "UPDATE retvehicle SET deployed = '1', date_deployed = '{$fgDate}' WHERE id = '{$this->id}'";
     //print_r($sql);
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         return false;
         //print_r("Error updating record: " . mysqli_error($conn));
     }
 }
예제 #7
0
 public static function addBatteryNotification($type, $driver, $vehicle, $latitude, $longitude)
 {
     $db = new Connection();
     $conn = $db->connect();
     $today = date('Y-m-d');
     $fgDate = $db->getTimeNow();
     //$type = "power_battery_plugged";
     $origin = "vehicle";
     $priority = Notification::getPriority($type);
     $mVehicle = new Vehicle($vehicle);
     $companyId = $mVehicle->getCompany();
     $adminId = $mVehicle->getAddedBy();
     $sql = "INSERT INTO `notification` (priority, type, origin, driver, vehicle, latitude, longitude, company, admin, date_added) VALUES ('{$priority}', '{$type}', '{$origin}', '{$driver}', '{$vehicle}', '{$latitude}', '{$longitude}', '{$companyId}', '{$adminId}', '{$fgDate}')";
     //echo $sql;
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         return false;
     }
 }