function get_shop_info_by_bssid($json) { $database = new Database(); $shopTbl = $database->getShopTbl(); $shop = $shopTbl->getByBSSID($json->{'BSSID'}); $ret_array = null; if ($shop) { $ret_array = array("ShopId" => $shop->ShopId, "OwnerId" => $shop->OwnerId, "Name" => $shop->Name, "Latitude" => $shop->Latitude, "Longitude" => $shop->Longitude, "Address" => $shop->Address, "PhoneNumber" => $shop->PhoneNumber, "ShopType" => $shop->ShopType, "PicturePath" => $shop->PicturePath); } echo "{Shop : " . json_encode($ret_array) . "}"; exit; }
function save_shop($json) { $newFilename = ""; if (!empty($_FILES['file']['name'])) { $filename = $_FILES['file']['name']; $spt = explode(".", $filename); $extension = $spt[1]; $newFilename = "resource/shop/" . uniqid(date('mdy', time())) . "." . $extension; $isMove = move_uploaded_file($_FILES['file']['tmp_name'], "../" . $newFilename); if (!$isMove) { echo_save_unsuc_msg(); } } $database = new Database(); $shopTbl = $database->getShopTbl(); $shop = new Shop(); if (!empty($json->{'ShopId'})) { $shop->ShopId = $json->{'ShopId'}; } $shop->Name = $json->{'ShopName'}; $shop->PhoneNumber = $json->{'PhoneNumber'}; $shop->Latitude = $json->{'Latitude'}; $shop->Longitude = $json->{'Longitude'}; $shop->Address = $json->{'Address'}; if (!empty($json->{'ShopType'})) { $shop->ShopType = $json->{'ShopType'}; } if (!empty($json->{'OwnerId'})) { $shop->OwnerId = $json->{'OwnerId'}; } $shop->PicturePath = $newFilename; $success = $shopTbl->save($shop); if ($success) { echo_save_suc_msg(); } else { if (!empty($_FILES['file']['name'])) { unlink("../" . $newFilename); } echo_save_unsuc_msg(); } }
function remove_shop($json) { $database = new Database(); $shopTbl = $database->getShopTbl(); $shop_info = $shopTbl->get($json->{'ShopId'}); if (!empty($shop_info->PicturePath)) { unlink("../" . $shop_info->PicturePath); } $success = $shopTbl->remove($json->{'ShopId'}); if ($success) { echo_rm_suc_msg(); } else { echo_rm_unsuc_msg(); } }