$page->addCSS("assets/js/sweetalert/sweetalert.css"); $page->addJavascript("assets/js/jquery.validate.min.js"); $page->addJavascript("assets/js/sweetalert/sweetalert.min.js"); $page->startBody(); $insert = null; $update = null; $delete = null; $control = new Controls(Controls::Insert); //Chưa chọn loại sản phẩm; $Device = new Device(); if (isset($_POST["btnSave"])) { 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();
if (isset($_POST['page']) && !empty($_POST['page'])) { $curPage = $_POST['page']; //truyền thứ tự trang cần xem } if (isset($_POST['show']) && !empty($_POST['show'])) { $rowsPerPage = $_POST['show']; //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