Beispiel #1
0
     if (isset($_POST["txtControl"])) {
         $control->setValue($_POST["txtControl"]);
     }
     if (isset($_POST["txtDeviceID"])) {
         $Device->setDeviceID($_POST["txtDeviceID"]);
     }
     if (isset($_POST["txtDeviceName"])) {
         $Device->setDeviceName($_POST["txtDeviceName"]);
     }
     if ($control == Controls::Insert) {
         $Device->insert();
         $insert = true;
     } else {
         if ($control == Controls::Update) {
             if (isset($_POST["chkStatus"])) {
                 $Device->setStatus($_POST["chkStatus"]);
             } else {
                 $Device->setStatus(0);
             }
             $Device->update();
             $update = true;
         }
     }
 } else {
     if (isset($_GET["DeviceID"]) && isset($_GET["control"])) {
         $control->setValue($_GET["control"]);
         $Device = Device::getDevice($_GET["DeviceID"]);
         if ($Device != null) {
             if ($control == Controls::Update) {
                 echo "<script> \$(function () { \$(window).load(function(){ \$('#modalDevice').modal( { backdrop: 'static', keyboard: false }, 'show');});  });</script>";
             } else {
 public function convertToDeviceObject($deviceDto)
 {
     $datetime = new DateTime('-10 seconds');
     $tenSecondsBeforeNow = $datetime->format("Y-m-d H:i:s");
     $device = new Device();
     $device->setId($deviceDto->getId());
     $device->setSerialNumber($deviceDto->getSerialNumber());
     $device->setTitle($deviceDto->getTitle());
     $device->setStatisticsPagePasscode($deviceDto->getStatisticsPagePasscode());
     $device->setResetCounterButton($deviceDto->getResetCounterButton());
     $device->setAmd100Qty($deviceDto->getAmd100Qty());
     $device->setAmd200Qty($deviceDto->getAmd200Qty());
     $device->setAmd500Qty($deviceDto->getAmd500Qty());
     $device->setAmd100ChargeSeconds($deviceDto->getAmd100ChargeSeconds());
     $device->setAmd200ChargeSeconds($deviceDto->getAmd200ChargeSeconds());
     $device->setAmd500ChargeSeconds($deviceDto->getAmd500ChargeSeconds());
     $device->setIsBusy($deviceDto->getIsBusy());
     $device->setLastPing($deviceDto->getLastPing());
     $device->setServerPingUrl($deviceDto->getServerPingUrl());
     $device->setServerImagePostUrl($deviceDto->getServerImagePostUrl());
     $device->setCameraAvailable($deviceDto->getCameraAvailable());
     $device->setServerHost($deviceDto->getServerHost());
     $lastPing = $deviceDto->getLastPing();
     $deviceIsOn = $tenSecondsBeforeNow < $deviceDto->getLastPing() && !empty($lastPing);
     if (!$deviceIsOn) {
         $device->setStatus('off');
     } else {
         $device->setStatus($deviceDto->getIsBusy() == 1 ? 'busy' : 'free');
     }
     $totalAmd = $deviceDto->getAmd100Qty() * 100 + $deviceDto->getAmd200Qty() * 200 + $deviceDto->getAmd500Qty() * 500;
     $device->setTotalAmd($totalAmd);
     return $device;
 }
Beispiel #3
0
    //truyền số record cần hiển thịs
}
$offset = ($curPage - 1) * $rowsPerPage;
// tính offset bắt đầu load
//filter
$SortName = "";
$SortType = true;
$filterDevice = new Device();
if (isset($_POST['DeviceID']) & !empty($_POST['DeviceID'])) {
    $filterDevice->setDeviceID($_POST['DeviceID']);
}
if (isset($_POST['DeviceName']) & !empty($_POST['DeviceName'])) {
    $filterDevice->setDeviceName($_POST['DeviceName']);
}
if (isset($_POST['Status']) & !empty($_POST['Status'])) {
    $filterDevice->setStatus($_POST['Status']);
}
if (isset($_POST['SortName']) & !empty($_POST['SortName'])) {
    $SortName = $_POST['SortName'];
}
if (isset($_POST['SortType']) & !empty($_POST['SortType'])) {
    $SortType = $_POST['SortType'];
}
$numberOfRows = $filterDevice->countRecords();
// Số lượng dòng của bảng
$ListDevices = array();
if ($rowsPerPage == -1) {
    // nếu là chọn hiển thị là ALL
    $rowsPerPage = $numberOfRows;
    $ListDevices = $filterDevice->loadLimit($rowsPerPage, 0, $SortName, $SortType);
} else {