<?php include_once "../class/Config.php"; include_once "../class/Asset.php"; include_once "../class/CheckAsset.php"; $delAsset = new Asset(); $delChkAsset = new CheckAsset(); $db = new Config(); $delId = $_GET["assetId"]; //$delId = "12"; $delAsset->setAssetId($delId); $arr = $delAsset->getAssetById(); $res = $db->fetch_array($arr); $DelChkType = $res['assetTypeId']; $DelChkGroup = $res['assetGroupId']; $DelChkAsset = $res['assetId']; $delChkAsset->setAssetTypeId($DelChkType); $delChkAsset->setAssetGroupId($DelChkGroup); $delChkAsset->setAssetId($DelChkAsset); $delChkAsset->delCheckAsset(); $delAsset->delAsset();
//********************************************** include_once "../class/Asset.php"; include_once "../class/CheckAsset.php"; $updateAsset = new Asset(); $updateChk = new CheckAsset(); $assetId = $_GET["assetId"]; $upAssName = $_GET["upAssName"]; $upAssPrice = $_GET["upAssPrice"]; $upRemark = $_GET["upRemark"]; $upAssAddDate = $_GET["upAddDate"]; $dateM = substr($upAssAddDate, 0, 6); $month = substr($upAssAddDate, 3, 2); $text = substr($upAssAddDate, 6, 4); $YearD = substr($upAssAddDate, 6, 4); if ($month >= 10 && $month <= 12) { $YearD++; } $year = $text - 543; $dateType = $dateM . "" . $year; $datetime = DateTime::createFromFormat('d/m/yy', $dateType); $dateT = $datetime->format('Y-m-d'); $updateAsset->setAssetId($assetId); $updateAsset->setAssetName($upAssName); $updateAsset->setAssetPrice($upAssPrice); $updateAsset->setRemark($upRemark); $updateAsset->setAssetAddDate($dateT); $updateAsset->setAssetYear($YearD); $updateAsset->editAsset(); $updateChk->setAssetId($assetId); $updateChk->setAssetAddDate($dateT); $updateChk->editCheckAsset();
if ($month >= 10 && $month <= 12) { $yearD++; } $assYear = $yearD + 543; $year = $text - 543; $dateType = $dateM . "" . $year; $datetime = DateTime::createFromFormat('d/m/yy', $dateType); $dateT = $datetime->format('Y-m-d'); if ($assetNum == "") { $addAsset->setValues($assetCode, $assetName, $assetPrice, $assetTypeId, $assetGroupId, $yearD, $assetLocation, $dateT, $remark, $userId); $addAsset->addAsset(); $arr = $addAsset->getAssetIdToCheck($assetTypeId, $assetGroupId, $assetCode); $result = $db->fetch_array($arr); $addCheck->setAssetTypeId($assetTypeId); $addCheck->setAssetGroupId($assetGroupId); $addCheck->setAssetId($result['assetId']); $addCheck->setAssetYear($yearD); $addCheck->setAssetAddDate($dateT); $addCheck->setUserId($userId); $addCheck->addCheckAsset(); } else { if ($assetNum > 1) { $i = 1; $gens = $assetCode; $gen = $gens - 1; while ($i <= $assetNum) { $genCode = str_pad($gen + 1, 3, "0", STR_PAD_LEFT); $addAsset->setValues($genCode, $assetName, $assetPrice, $assetTypeId, $assetGroupId, $yearD, $assetLocation, $dateT, $remark, $userId); $addAsset->addAsset(); $arr = $addAsset->getAssetIdToCheck($assetTypeId, $assetGroupId, $genCode); $result = $db->fetch_array($arr);